1 /*
2 * Copyright (c) 2010 Stefano Sabatini
3 * Copyright (c) 2008 Victor Paesa
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * video presentation timestamp (PTS) modification filter
25 */
26
27 #include "config_components.h"
28
29 #include <inttypes.h>
30
41
43 "FRAME_RATE", ///< defined only for constant frame-rate video
44 "INTERLACED", ///< tell if the current frame is interlaced
45 "N", ///< frame / sample number (starting at zero)
46 "NB_CONSUMED_SAMPLES", ///< number of samples consumed by the filter (only audio)
47 "NB_SAMPLES", ///< number of samples in the current frame (only audio)
48 #if FF_API_FRAME_PKT
49 "POS", ///< original position in the file of the frame
50 #endif
51 "PREV_INPTS", ///< previous input PTS
52 "PREV_INT", ///< previous input time in seconds
53 "PREV_OUTPTS", ///< previous output PTS
54 "PREV_OUTT", ///< previous output time in seconds
55 "PTS", ///< original pts in the file of the frame
56 "SAMPLE_RATE", ///< sample rate (only audio)
57 "STARTPTS", ///< PTS at start of movie
58 "STARTT", ///< time at start of movie
59 "T", ///< original time in the file of the frame
60 "TB", ///< timebase
61 "RTCTIME", ///< wallclock (RTC) time in micro seconds
62 "RTCSTART", ///< wallclock (RTC) time at the start of the movie in micro seconds
63 "S", // Number of samples in the current frame
64 "SR", // Audio sample rate
65 "FR", ///< defined only for constant frame-rate video
66 "T_CHANGE", ///< time of first frame after latest command was applied
68 };
69
76 #if FF_API_FRAME_PKT
78 #endif
96 };
97
105
106 #define V(name_) \
107 setpts->var_values[VAR_##name_]
108
110 {
113
118 }
119
124 V(PREV_OUTPTS) =
NAN;
129 return 0;
130 }
131
133 {
136
140
141 V(SR) =
V(SAMPLE_RATE) =
143
144 V(FRAME_RATE) =
V(FR) =
147
149 V(
TB),
V(FRAME_RATE),
V(SAMPLE_RATE));
150 return 0;
151 }
152
154 {
156
157 return 0;
158 }
159
161
163 {
166 return buf;
167 }
168
170 {
174 }
177 }
180 #if FF_API_FRAME_PKT
184 #endif
186
193 }
194 }
195
197 }
198 #define d2istr(v) double2int64str((char[BUF_SIZE]){0}, v)
199
201 {
205
209
211 "N:%"PRId64" PTS:%s T:%f",
217 break;
222 break;
223 }
225
228 } else {
230 }
231
232 V(PREV_INPTS ) =
TS2D(in_pts);
238 }
240 }
241
243 {
251
253
259
262
266 return 0;
267 }
268
270
272 }
273
275 {
279 }
280
282 char *res,
int res_len,
int flags)
283 {
287
289
292
293 if (!strcmp(cmd, "expr")) {
295 // Only free and replace previous expression if new one succeeds,
296 // otherwise defensively keep everything intact even if reporting an error.
299 } else {
301 setpts->
expr = new_expr;
303 }
304 } else {
306 }
307
309 }
310 #undef V
311
312 #define OFFSET(x) offsetof(SetPTSContext, x)
313 #define V AV_OPT_FLAG_VIDEO_PARAM
314 #define A AV_OPT_FLAG_AUDIO_PARAM
315 #define R AV_OPT_FLAG_RUNTIME_PARAM
316 #define F AV_OPT_FLAG_FILTERING_PARAM
317
318 #if CONFIG_SETPTS_FILTER
319 static const AVOption setpts_options[] = {
322 };
324
325 static const AVFilterPad avfilter_vf_setpts_inputs[] = {
326 {
330 },
331 };
332
334 {
338 },
339 };
340
349
351 .priv_class = &setpts_class,
352
355 };
356 #endif /* CONFIG_SETPTS_FILTER */
357
358 #if CONFIG_ASETPTS_FILTER
359
360 static const AVOption asetpts_options[] = {
363 };
365
367 {
371 },
372 };
373
382 .priv_class = &asetpts_class,
386 };
387 #endif /* CONFIG_ASETPTS_FILTER */