1 /*
2 * Copyright (c) 2010 Stefano Sabatini
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file
23 * Set timebase for the output link.
24 */
25
26 #include "config_components.h"
27
28 #include <inttypes.h>
29 #include <stdio.h>
30
42
44 "AVTB", /* default timebase 1/AV_TIME_BASE */
45 "intb", /* input timebase */
46 "sr", /* sample rate */
48 };
49
55 };
56
62
63 #define OFFSET(x) offsetof(SetTBContext, x)
64 #define DEFINE_OPTIONS(filt_name, filt_type) \
65 static const AVOption filt_name##_options[] = { \
66 { "expr", "set expression determining the output timebase", OFFSET(tb_expr), AV_OPT_TYPE_STRING, {.str="intb"}, \
67 .flags=AV_OPT_FLAG_##filt_type##_PARAM|AV_OPT_FLAG_FILTERING_PARAM }, \
68 { "tb", "set expression determining the output timebase", OFFSET(tb_expr), AV_OPT_TYPE_STRING, {.str="intb"}, \
69 .flags=AV_OPT_FLAG_##filt_type##_PARAM|AV_OPT_FLAG_FILTERING_PARAM }, \
70 { NULL } \
71 }
72
74 {
80 double res;
81
85
88
93 }
94 time_base =
av_d2q(res, INT_MAX);
95 if (time_base.
num <= 0 || time_base.
den <= 0) {
97 "Invalid non-positive values for the timebase num:%d or den:%d.\n",
98 time_base.
num, time_base.
den);
100 }
101
106
107 return 0;
108 }
109
111 {
113 int64_t new_pts = orig_pts;
114
118 inlink ->time_base.num,
inlink ->time_base.den, orig_pts,
120 }
121
122 return new_pts;
123 }
124
126 {
129
131
133 }
134
136 {
143
145
151
154 return 0;
155 }
156
158
160 }
161
162 #if CONFIG_SETTB_FILTER
163
166
167 static const AVFilterPad avfilter_vf_settb_inputs[] = {
168 {
171 },
172 };
173
174 static const AVFilterPad avfilter_vf_settb_outputs[] = {
175 {
179 },
180 };
181
186 .priv_class = &settb_class,
191 };
192 #endif /* CONFIG_SETTB_FILTER */
193
194 #if CONFIG_ASETTB_FILTER
195
198
199 static const AVFilterPad avfilter_af_asettb_inputs[] = {
200 {
203 },
204 };
205
206 static const AVFilterPad avfilter_af_asettb_outputs[] = {
207 {
211 },
212 };
213
220 .priv_class = &asettb_class,
223 };
224 #endif /* CONFIG_ASETTB_FILTER */