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 <inttypes.h>
27 #include <stdio.h>
28
39
41 "AVTB", /* default timebase 1/AV_TIME_BASE */
42 "intb", /* input timebase */
43 "sr", /* sample rate */
45 };
46
52 };
53
59
60 #define OFFSET(x) offsetof(SetTBContext, x)
61 #define DEFINE_OPTIONS(filt_name, filt_type) \
62 static const AVOption filt_name##_options[] = { \
63 { "expr", "set expression determining the output timebase", OFFSET(tb_expr), AV_OPT_TYPE_STRING, {.str="intb"}, \
64 .flags=AV_OPT_FLAG_##filt_type##_PARAM|AV_OPT_FLAG_FILTERING_PARAM }, \
65 { "tb", "set expression determining the output timebase", OFFSET(tb_expr), AV_OPT_TYPE_STRING, {.str="intb"}, \
66 .flags=AV_OPT_FLAG_##filt_type##_PARAM|AV_OPT_FLAG_FILTERING_PARAM }, \
67 { NULL } \
68 }
69
71 {
76 int ret;
77 double res;
78
82
83 outlink->
w = inlink->
w;
84 outlink->
h = inlink->
h;
85
89 return ret;
90 }
91 time_base =
av_d2q(res, INT_MAX);
92 if (time_base.
num <= 0 || time_base.
den <= 0) {
94 "Invalid non-positive values for the timebase num:%d or den:%d.\n",
95 time_base.
num, time_base.
den);
97 }
98
103
104 return 0;
105 }
106
108 {
111
113 int64_t orig_pts = frame->
pts;
116 inlink ->time_base.num, inlink ->
time_base.
den, orig_pts,
118 }
119
121 }
122
123 #if CONFIG_SETTB_FILTER
124
127
128 static const AVFilterPad avfilter_vf_settb_inputs[] = {
129 {
133 },
135 };
136
137 static const AVFilterPad avfilter_vf_settb_outputs[] = {
138 {
142 },
144 };
145
150 .priv_class = &settb_class,
151 .
inputs = avfilter_vf_settb_inputs,
152 .
outputs = avfilter_vf_settb_outputs,
153 };
154 #endif /* CONFIG_SETTB_FILTER */
155
156 #if CONFIG_ASETTB_FILTER
157
160
161 static const AVFilterPad avfilter_af_asettb_inputs[] = {
162 {
166 },
168 };
169
170 static const AVFilterPad avfilter_af_asettb_outputs[] = {
171 {
175 },
177 };
178
183 .
inputs = avfilter_af_asettb_inputs,
184 .
outputs = avfilter_af_asettb_outputs,
185 .priv_class = &asettb_class,
186 };
187 #endif /* CONFIG_ASETTB_FILTER */
This structure describes decoded (raw) audio or video data.
Main libavfilter public API header.
int h
agreed upon image height
static const char *const var_names[]
#define DEFINE_OPTIONS(filt_name, filt_type)
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static double av_q2d(AVRational a)
Convert an AVRational to a double.
#define AV_LOG_VERBOSE
Detailed information.
static int config_output_props(AVFilterLink *outlink)
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
A link between two filters.
int av_expr_parse_and_eval(double *d, const char *s, const char *const *const_names, const double *const_values, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), void *opaque, int log_offset, void *log_ctx)
Parse and evaluate an expression.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int sample_rate
samples per second
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
int w
agreed upon image width
common internal API header
AVFilterContext * src
source filter
static const AVFilterPad outputs[]
static const AVFilterPad inputs[]
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
Utilties for rational number calculation.
AVFilterContext * dst
dest filter
#define AVFILTER_DEFINE_CLASS(fname)
double var_values[VAR_VARS_NB]
simple arithmetic expression evaluator