FFmpeg: libavfilter/yadif_common.c Source File
Go to the documentation of this file. 1 /*
2 * Copyright (C) 2006-2011 Michael Niedermayer <michaelni@gmx.at>
3 * 2010 James Darnley <james.darnley@gmail.com>
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
27
29 {
33
37 } else {
39 }
40
41 if (is_second) {
45
50 }
51
53
54 if (is_second) {
57
59 yadif->
out->
pts = cur_pts + next_pts;
63 }
64 } else {
66 }
67 }
68
71
74 }
75
77 {
80 if (
a->linesize[
i] !=
b->linesize[
i])
81 return 1;
82 return 0;
83 }
84
86 {
89 return;
97 }
98
100 {
103
105
107
110
116
122 }
123
127 }
134 return -1;
135 }
136
138 return 0;
139
144 ) {
148
155 }
156
160
163
166 if (!(yadif->
mode & 1))
170
172 }
173
175 {
179
182 return 0;
183 }
184
187
189
192
193 if (!next)
195
198
201 }
else if (
ret < 0) {
203 }
204
205 return 0;
206 }
207
209 {
216
219 } else {
223 }
224
225 outlink->
w =
ctx->inputs[0]->w;
226 outlink->
h =
ctx->inputs[0]->h;
227
228 if (outlink->
w < 3 || outlink->
h < 3) {
231 }
232
236 else
238
243 }
244
245 return 0;
246 }
247
249 {
251
256 }
257
258 #define OFFSET(x) offsetof(YADIFContext, x)
259 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
260
261 #define CONST(name, help, val, u) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, .unit = u }
262
269
274
278
280 };
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
int ff_yadif_request_frame(AVFilterLink *link)
@ YADIF_MODE_SEND_FIELD
send 1 frame for each field
#define AV_LOG_WARNING
Something somehow does not look correct.
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int64_t duration
Duration of the frame, in the same units as pts.
#define AVERROR_EOF
End of file.
const AVPixFmtDescriptor * csp
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
#define AV_LOG_VERBOSE
Detailed information.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
A link between two filters.
@ YADIF_MODE_SEND_FRAME
send 1 frame for each frame
Link properties exposed to filter code, but not external callers.
@ YADIF_MODE_SEND_FIELD_NOSPATIAL
send 1 frame for each field but skips spatial interlacing check
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
@ YADIF_PARITY_AUTO
auto detection
void ff_ccfifo_uninit(CCFifo *ccf)
Free all memory allocated in a CCFifo and clear the context.
@ YADIF_MODE_SEND_FRAME_NOSPATIAL
send 1 frame for each frame but skips spatial interlacing check
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int ff_ccfifo_inject(CCFifo *ccf, AVFrame *frame)
Insert CC data from the FIFO into an AVFrame (as side data)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
uint8_t nb_components
The number of components each pixel has, (1-4)
Rational number (pair of numerator and denominator).
int ff_ccfifo_extract(CCFifo *ccf, AVFrame *frame)
Extract CC data from an AVFrame.
static FilterLink * ff_filter_link(AVFilterLink *link)
static int checkstride(YADIFContext *yadif, const AVFrame *a, const AVFrame *b)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define AV_NOPTS_VALUE
Undefined timestamp value.
void(* filter)(AVFilterContext *ctx, AVFrame *dstpic, int parity, int tff)
int ff_yadif_config_output_common(AVFilterLink *outlink)
AVFilterContext * src
source filter
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
static void fixstride(AVFilterLink *link, AVFrame *f)
#define i(width, name, range_min, range_max)
int w
agreed upon image width
void ff_yadif_uninit(AVFilterContext *ctx)
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
const AVOption ff_yadif_options[]
int ff_ccfifo_init(CCFifo *ccf, AVRational framerate, void *log_ctx)
Initialize a CCFifo.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
@ YADIF_DEINT_ALL
deinterlace all frames
int h
agreed upon image height
@ YADIF_FIELD_END
The first or last field in a sequence.
static void av_image_copy2(uint8_t *const dst_data[4], const int dst_linesizes[4], uint8_t *const src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Wrapper around av_image_copy() to workaround the limitation that the conversion from uint8_t * const ...
@ AV_OPT_TYPE_INT
Underlying C type is int.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
@ YADIF_DEINT_INTERLACED
only deinterlace frames marked as interlaced
@ YADIF_FIELD_BACK_END
The last frame in a sequence.
@ YADIF_PARITY_TFF
top field first
int current_field
YADIFCurrentField.
#define CONST(name, help, val, u)
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
static int return_frame(AVFilterContext *ctx, int is_second)
int repeat_pict
Number of fields in this frame which should be repeated, i.e.
int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame)
@ YADIF_PARITY_BFF
bottom field first
Generated on Wed Nov 19 2025 19:23:08 for FFmpeg by
doxygen
1.8.17