FFmpeg: libavfilter/vf_idet.c Source File
Go to the documentation of this file. 1 /*
2 * Copyright (C) 2012 Michael Niedermayer <michaelni@gmx.at>
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 #include <float.h> /* FLT_MAX */
22
27
28 #define OFFSET(x) offsetof(IDETContext, x)
29 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
30
36 {
"analyze_interlaced_flag",
"set number of frames to use to determine if the interlace flag is accurate",
OFFSET(analyze_interlaced_flag),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX,
FLAGS },
38 };
39
41
43 {
45 case TFF :
return "tff";
46 case BFF :
return "bff";
49 }
51 }
52
53 #define PRECISION 1048576
54
55 static uint64_t
uintpow(uint64_t
b,
unsigned int e)
56 {
60 }
61
64 {
65 char valuestr[44];
66 uint64_t print_precision =
uintpow(10, digits);
67
69
70 snprintf(valuestr,
sizeof(valuestr),
"%"PRId64
".%0*"PRId64,
71 value / print_precision, digits,
value % print_precision);
72
74 }
75
77 {
78 switch(repeated_field) {
82 }
84 }
85
87 {
88 int x;
90
92 int v = (*
a++ + *
c++) - 2 * *
b++;
94 }
95
97 }
98
100 {
101 int x;
103
105 int v = (*
a++ + *
c++) - 2 * *
b++;
107 }
108
110 }
111
113 {
116 int64_t
alpha[2]={0};
118 int64_t gamma[2]={0};
121 int match = 0;
123
128
132 }
133
134 for (y = 2; y <
h - 2; y++) {
135 uint8_t *prev = &idet->
prev->
data[
i][y*refs];
136 uint8_t *cur = &idet->
cur ->
data[
i][y*refs];
137 uint8_t *next = &idet->
next->
data[
i][y*refs];
141 gamma[(y^1)&1] += idet->
filter_line(cur , prev, cur ,
w);
142 }
143 }
144
151 }else{
153 }
154
159 } else {
161 }
162
170
172 match++;
173 }else{
174 match=0;
175 break;
176 }
177 }
178 }
181 }else{
183 }
184
193 }
194
197
201 }
202
205
208
211
214
219
225
231 }
232
234 {
237
238 // initial frame(s) and not interlaced, just pass through for
239 // the analyze_interlaced_flag mode
244 }
249 }
250
252
259
262 }
263
267
271
273 return 0;
274
279 if (ARCH_X86)
281 }
282
293 }
296
302 }
303 }
304 } else {
306 }
307
309 }
310
312 {
316
319
321
324
325 if (!next)
327
330 }
331
333 }
334
336 {
338
339 av_log(
ctx,
AV_LOG_INFO,
"Repeated Fields: Neither:%6"PRId64
" Top:%6"PRId64
" Bottom:%6"PRId64
"\n",
343 );
344 av_log(
ctx,
AV_LOG_INFO,
"Single frame detection: TFF:%6"PRId64
" BFF:%6"PRId64
" Progressive:%6"PRId64
" Undetermined:%6"PRId64
"\n",
349 );
350 av_log(
ctx,
AV_LOG_INFO,
"Multi frame detection: TFF:%6"PRId64
" BFF:%6"PRId64
" Progressive:%6"PRId64
" Undetermined:%6"PRId64
"\n",
355 );
356
360 }
361
394 };
395
397 {
399
403
406 else
408
410
411 if (ARCH_X86)
413
414 return 0;
415 }
416
418 {
422 },
423 };
424
426 {
430 },
431 };
432
443 .priv_class = &idet_class,
444 };
AVPixelFormat
Pixel format.
static const char * type2str(Type type)
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
static int request_frame(AVFilterLink *link)
@ PROGRESSIVE
in the bitstream is reported as 00b
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AVERROR_EOF
End of file.
ff_idet_filter_func filter_line
#define FILTER_PIXFMTS_ARRAY(array)
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.
int depth
Number of bits in the component.
int top_field_first
If the content is interlaced, is top field displayed first.
static int filter_frame(AVFilterLink *link, AVFrame *picref)
#define AV_PIX_FMT_YUV420P10
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
static enum AVPixelFormat pix_fmts[]
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
int analyze_interlaced_flag_done
const char * name
Filter name.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int ff_idet_filter_line_c_16bit(const uint16_t *a, const uint16_t *b, const uint16_t *c, int w)
AVFILTER_DEFINE_CLASS(idet)
#define AV_PIX_FMT_YUV422P9
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
#define AV_PIX_FMT_GRAY16
float interlace_threshold
A filter pad used for either input or output.
#define AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV422P16
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define AV_PIX_FMT_YUV444P16
#define AV_CEIL_RSHIFT(a, b)
static int av_dict_set_fxp(AVDictionary **pm, const char *key, uint64_t value, unsigned int digits, int flags)
static const AVFilterPad idet_outputs[]
#define AV_PIX_FMT_YUV420P9
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_PIX_FMT_YUV420P16
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
static av_cold int init(AVFilterContext *ctx)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_INPUTS(array)
const AVPixFmtDescriptor * csp
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
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static const AVOption idet_options[]
const AVFilter ff_vf_idet
uint8_t nb_components
The number of components each pixel has, (1-4)
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
static const AVFilterPad idet_inputs[]
static uint64_t uintpow(uint64_t b, unsigned int e)
#define AV_PIX_FMT_YUV422P10
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
uint64_t total_poststat[4]
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int interlaced_flag_accuracy
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static void filter(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV444P12
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
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
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
int(* ff_idet_filter_func)(const uint8_t *a, const uint8_t *b, const uint8_t *c, int w)
int analyze_interlaced_flag
#define AV_LOG_INFO
Standard information.
int interlaced_frame
The content of the picture is interlaced.
#define i(width, name, range_min, range_max)
static const char * rep2str(RepeatedField repeated_field)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
const char * name
Pad name.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_PIX_FMT_YUV444P9
uint64_t total_prestat[4]
uint64_t total_repeats[3]
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P14
uint8_t history[HIST_SIZE]
AVDictionary * metadata
metadata.
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int ff_idet_filter_line_c(const uint8_t *a, const uint8_t *b, const uint8_t *c, int w)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
uint64_t decay_coefficient
float progressive_threshold
static const int16_t alpha[]
#define FILTER_OUTPUTS(array)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
#define AV_PIX_FMT_YUV444P14
void ff_idet_init_x86(IDETContext *idet, int for_16b)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_PIX_FMT_YUV420P14
Generated on Wed Aug 24 2022 21:38:14 for FFmpeg by
doxygen
1.8.17