43 #define INPUT_CLEANSRC 1
106 int cmask_linesize[4];
112 #define OFFSET(x) offsetof(FieldMatchContext, x)
113 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
124 {
"pc_n_ub",
"2-way match + 3rd match on combed + 4th/5th matches if still combed (p/c + u + u/b)", 0,
AV_OPT_TYPE_CONST, {.i64=
MODE_PC_N_UB}, INT_MIN, INT_MAX,
FLAGS,
"mode" },
127 {
"ppsrc",
"mark main input as a pre-processed input and activate clean source input stream",
OFFSET(ppsrc),
AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1,
FLAGS },
132 {
"mchroma",
"set whether or not chroma is included during the match comparisons",
OFFSET(mchroma),
AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1,
FLAGS },
133 {
"y0",
"define an exclusion band which excludes the lines between y0 and y1 from the field matching decision",
OFFSET(y0),
AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX,
FLAGS },
134 {
"y1",
"define an exclusion band which excludes the lines between y0 and y1 from the field matching decision",
OFFSET(y1),
AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX,
FLAGS },
144 {
"cthresh",
"set the area combing threshold used for combed frame detection",
OFFSET(cthresh),
AV_OPT_TYPE_INT, {.i64= 9}, -1, 0xff,
FLAGS },
146 {
"blockx",
"set the x-axis size of the window used during combed frame detection",
OFFSET(blockx),
AV_OPT_TYPE_INT, {.i64=16}, 4, 1<<9,
FLAGS },
147 {
"blocky",
"set the y-axis size of the window used during combed frame detection",
OFFSET(blocky),
AV_OPT_TYPE_INT, {.i64=16}, 4, 1<<9,
FLAGS },
148 {
"combpel",
"set the number of combed pixels inside any of the blocky by blockx size blocks on the frame for the frame to be detected as combed",
OFFSET(combpel),
AV_OPT_TYPE_INT, {.i64=80}, 0, INT_MAX,
FLAGS },
169 const int src1_linesize = f1->
linesize[0];
170 const int src2_linesize = f2->
linesize[0];
175 for (y = 0; y <
height; y++) {
176 for (x = 0; x <
width; x++)
177 acc += abs(srcp1[x] - srcp2[x]);
178 srcp1 += src1_linesize;
179 srcp2 += src2_linesize;
188 for (y = 0; y <
h; y++) {
196 int x, y,
plane, max_v = 0;
197 const int cthresh = fm->
cthresh;
198 const int cthresh6 = cthresh * 6;
200 for (plane = 0; plane < (fm->
chroma ? 3 : 1); plane++) {
209 fill_buf(cmkp, width, height, cmk_linesize, 0xff);
212 fill_buf(cmkp, width, height, cmk_linesize, 0);
215 #define FILTER(xm2, xm1, xp1, xp2) \
217 -3 * (srcp[x + (xm1)*src_linesize] + srcp[x + (xp1)*src_linesize]) \
218 + (srcp[x + (xm2)*src_linesize] + srcp[x + (xp2)*src_linesize])) > cthresh6
221 for (x = 0; x <
width; x++) {
222 const int s1 = abs(srcp[x] - srcp[x + src_linesize]);
223 if (s1 > cthresh &&
FILTER(2, 1, 1, 2))
226 srcp += src_linesize;
227 cmkp += cmk_linesize;
230 for (x = 0; x <
width; x++) {
231 const int s1 = abs(srcp[x] - srcp[x - src_linesize]);
232 const int s2 = abs(srcp[x] - srcp[x + src_linesize]);
233 if (s1 > cthresh && s2 > cthresh &&
FILTER(2, -1, 1, 2))
236 srcp += src_linesize;
237 cmkp += cmk_linesize;
240 for (y = 2; y < height-2; y++) {
241 for (x = 0; x <
width; x++) {
242 const int s1 = abs(srcp[x] - srcp[x - src_linesize]);
243 const int s2 = abs(srcp[x] - srcp[x + src_linesize]);
244 if (s1 > cthresh && s2 > cthresh &&
FILTER(-2, -1, 1, 2))
247 srcp += src_linesize;
248 cmkp += cmk_linesize;
252 for (x = 0; x <
width; x++) {
253 const int s1 = abs(srcp[x] - srcp[x - src_linesize]);
254 const int s2 = abs(srcp[x] - srcp[x + src_linesize]);
255 if (s1 > cthresh && s2 > cthresh &&
FILTER(-2, -1, 1, -2))
258 srcp += src_linesize;
259 cmkp += cmk_linesize;
262 for (x = 0; x <
width; x++) {
263 const int s1 = abs(srcp[x] - srcp[x - src_linesize]);
264 if (s1 > cthresh &&
FILTER(-2, -1, -1, -2))
277 uint8_t *cmkpp = cmkp - (cmk_linesize>>1);
278 uint8_t *cmkpn = cmkp + (cmk_linesize>>1);
279 uint8_t *cmkpnn = cmkp + cmk_linesize;
280 for (y = 1; y < height - 1; y++) {
281 cmkpp += cmk_linesize;
282 cmkp += cmk_linesize;
283 cmkpn += cmk_linesize;
284 cmkpnn += cmk_linesize;
285 cmkpV += cmk_linesizeUV;
286 cmkpU += cmk_linesizeUV;
287 for (x = 1; x < width - 1; x++) {
288 #define HAS_FF_AROUND(p, lz) (p[(x)-1 - (lz)] == 0xff || p[(x) - (lz)] == 0xff || p[(x)+1 - (lz)] == 0xff || \
289 p[(x)-1 ] == 0xff || p[(x)+1 ] == 0xff || \
290 p[(x)-1 + (lz)] == 0xff || p[(x) + (lz)] == 0xff || p[(x)+1 + (lz)] == 0xff)
291 if ((cmkpV[x] == 0xff &&
HAS_FF_AROUND(cmkpV, cmk_linesizeUV)) ||
292 (cmkpU[x] == 0xff &&
HAS_FF_AROUND(cmkpU, cmk_linesizeUV))) {
293 ((uint16_t*)cmkp)[x] = 0xffff;
294 ((uint16_t*)cmkpn)[x] = 0xffff;
295 if (y&1) ((uint16_t*)cmkpp)[x] = 0xffff;
296 else ((uint16_t*)cmkpnn)[x] = 0xffff;
303 const int blockx = fm->
blockx;
304 const int blocky = fm->
blocky;
305 const int xhalf = blockx/2;
306 const int yhalf = blocky/2;
311 const int xblocks = ((width+xhalf)/blockx) + 1;
312 const int xblocks4 = xblocks<<2;
313 const int yblocks = ((height+yhalf)/blocky) + 1;
315 const int arraysize = (xblocks*yblocks)<<2;
316 int heighta = (height/(blocky/2))*(blocky/2);
317 const int widtha = (width /(blockx/2))*(blockx/2);
318 if (heighta == height)
319 heighta = height - yhalf;
320 memset(c_array, 0, arraysize *
sizeof(*c_array));
322 #define C_ARRAY_ADD(v) do { \
323 const int box1 = (x / blockx) * 4; \
324 const int box2 = ((x + xhalf) / blockx) * 4; \
325 c_array[temp1 + box1 ] += v; \
326 c_array[temp1 + box2 + 1] += v; \
327 c_array[temp2 + box1 + 2] += v; \
328 c_array[temp2 + box2 + 3] += v; \
331 #define VERTICAL_HALF(y_start, y_end) do { \
332 for (y = y_start; y < y_end; y++) { \
333 const int temp1 = (y / blocky) * xblocks4; \
334 const int temp2 = ((y + yhalf) / blocky) * xblocks4; \
335 for (x = 0; x < width; x++) \
336 if (cmkp[x - cmk_linesize] == 0xff && \
337 cmkp[x ] == 0xff && \
338 cmkp[x + cmk_linesize] == 0xff) \
340 cmkp += cmk_linesize; \
346 for (y = yhalf; y < heighta; y += yhalf) {
347 const int temp1 = (y / blocky) * xblocks4;
348 const int temp2 = ((y + yhalf) / blocky) * xblocks4;
350 for (x = 0; x < widtha; x += xhalf) {
351 const uint8_t *cmkp_tmp = cmkp + x;
353 for (u = 0; u < yhalf; u++) {
354 for (v = 0; v < xhalf; v++)
355 if (cmkp_tmp[v - cmk_linesize] == 0xff &&
356 cmkp_tmp[v ] == 0xff &&
357 cmkp_tmp[v + cmk_linesize] == 0xff)
359 cmkp_tmp += cmk_linesize;
365 for (x = widtha; x <
width; x++) {
366 const uint8_t *cmkp_tmp = cmkp + x;
368 for (u = 0; u < yhalf; u++) {
369 if (cmkp_tmp[-cmk_linesize] == 0xff &&
370 cmkp_tmp[ 0] == 0xff &&
371 cmkp_tmp[ cmk_linesize] == 0xff)
373 cmkp_tmp += cmk_linesize;
379 cmkp += cmk_linesize * yhalf;
384 for (x = 0; x < arraysize; x++)
385 if (c_array[x] > max_v)
393 const uint8_t *nxtp,
int nxt_linesize,
394 uint8_t *tbuffer,
int tbuf_linesize,
399 prvp -= prv_linesize;
400 nxtp -= nxt_linesize;
401 for (y = 0; y <
height; y++) {
402 for (x = 0; x <
width; x++)
403 tbuffer[x] =
FFABS(prvp[x] - nxtp[x]);
404 prvp += prv_linesize;
405 nxtp += nxt_linesize;
406 tbuffer += tbuf_linesize;
414 const uint8_t *prvp,
int prv_linesize,
415 const uint8_t *nxtp,
int nxt_linesize,
424 fm->
tbuffer, tpitch, width, height>>1);
426 for (y = 2; y < height - 2; y += 2) {
427 for (x = 1; x < width - 1; x++) {
430 for (count = 0, u = x-1; u < x+2 && count < 2; u++) {
431 count += dp[u-tpitch] > 3;
433 count += dp[u+tpitch] > 3;
438 int upper = 0, lower = 0;
439 for (count = 0, u = x-1; u < x+2 && count < 6; u++) {
440 if (dp[u-tpitch] > 19) { count++; upper = 1; }
441 if (dp[u ] > 19) count++;
442 if (dp[u+tpitch] > 19) { count++; lower = 1; }
445 if (upper && lower) {
448 int upper2 = 0, lower2 = 0;
449 for (u =
FFMAX(x-4,0); u <
FFMIN(x+5,width); u++) {
450 if (y != 2 && dp[u-2*tpitch] > 19) upper2 = 1;
451 if ( dp[u- tpitch] > 19) upper = 1;
452 if ( dp[u+ tpitch] > 19) lower = 1;
453 if (y != height-4 && dp[u+2*tpitch] > 19) lower2 = 1;
455 if ((upper && (lower || upper2)) ||
456 (lower && (upper || lower2)))
467 dstp += dst_linesize;
475 return match < 3 ? 2 - field : 1 + field;
480 if (match ==
mP || match ==
mB)
return fm->
prv;
481 else if (match ==
mN || match ==
mU)
return fm->
nxt;
488 uint64_t accumPc = 0, accumPm = 0, accumPml = 0;
489 uint64_t accumNc = 0, accumNm = 0, accumNml = 0;
490 int norm1, norm2, mtn1, mtn2;
494 for (plane = 0; plane < (fm->
mchroma ? 3 : 1); plane++) {
495 int x, y, temp1, temp2, fbase;
501 const int srcf_linesize = src_linesize << 1;
502 int prv_linesize, nxt_linesize;
503 int prvf_linesize, nxtf_linesize;
506 const int y0a = fm->
y0 >> (plane != 0);
507 const int y1a = fm->
y1 >> (plane != 0);
508 const int startx = (plane == 0 ? 8 : 4);
509 const int stopx = width - startx;
510 const uint8_t *srcpf, *srcf, *srcnf;
511 const uint8_t *prvpf, *prvnf, *nxtpf, *nxtnf;
513 fill_buf(mapp, width, height, map_linesize, 0);
517 srcf = srcp + (fbase + 1) * src_linesize;
518 srcpf = srcf - srcf_linesize;
519 srcnf = srcf + srcf_linesize;
520 mapp = mapp + fbase * map_linesize;
523 prvf_linesize = prv_linesize << 1;
524 prvpf = prev->
data[
plane] + fbase * prv_linesize;
525 prvnf = prvpf + prvf_linesize;
531 nxtf_linesize = nxt_linesize << 1;
532 nxtpf = next->
data[
plane] + fbase * nxt_linesize;
533 nxtnf = nxtpf + nxtf_linesize;
536 if ((match1 >= 3 && field == 1) || (match1 < 3 && field != 1))
538 mapp, map_linesize, height, width, plane);
541 mapp + map_linesize, map_linesize, height, width, plane);
543 for (y = 2; y < height - 2; y += 2) {
544 if (y0a == y1a || y < y0a || y > y1a) {
545 for (x = startx; x < stopx; x++) {
546 if (mapp[x] > 0 || mapp[x + map_linesize] > 0) {
547 temp1 = srcpf[x] + (srcf[x] << 2) + srcnf[x];
549 temp2 = abs(3 * (prvpf[x] + prvnf[x]) - temp1);
550 if (temp2 > 23 && ((mapp[x]&1) || (mapp[x + map_linesize]&1)))
553 if ((mapp[x]&2) || (mapp[x + map_linesize]&2))
555 if ((mapp[x]&4) || (mapp[x + map_linesize]&4))
559 temp2 = abs(3 * (nxtpf[x] + nxtnf[x]) - temp1);
560 if (temp2 > 23 && ((mapp[x]&1) || (mapp[x + map_linesize]&1)))
563 if ((mapp[x]&2) || (mapp[x + map_linesize]&2))
565 if ((mapp[x]&4) || (mapp[x + map_linesize]&4))
571 prvpf += prvf_linesize;
572 prvnf += prvf_linesize;
573 srcpf += srcf_linesize;
574 srcf += srcf_linesize;
575 srcnf += srcf_linesize;
576 nxtpf += nxtf_linesize;
577 nxtnf += nxtf_linesize;
578 mapp += map_linesize;
582 if (accumPm < 500 && accumNm < 500 && (accumPml >= 500 || accumNml >= 500) &&
583 FFMAX(accumPml,accumNml) > 3*
FFMIN(accumPml,accumNml)) {
588 norm1 = (int)((accumPc / 6.0f) + 0.5f);
589 norm2 = (int)((accumNc / 6.0f) + 0.5f);
590 mtn1 = (int)((accumPm / 6.0f) + 0.5f);
591 mtn2 = (int)((accumNm / 6.0f) + 0.5f);
592 c1 = ((float)
FFMAX(norm1,norm2)) / ((
float)
FFMAX(
FFMIN(norm1,norm2),1));
593 c2 = ((float)
FFMAX(mtn1, mtn2)) / ((
float)
FFMAX(
FFMIN(mtn1, mtn2), 1));
594 mr = ((float)
FFMAX(mtn1, mtn2)) / ((
float)
FFMAX(
FFMAX(norm1,norm2),1));
595 if (((mtn1 >= 500 || mtn2 >= 500) && (mtn1*2 < mtn2*1 || mtn2*2 < mtn1*1)) ||
596 ((mtn1 >= 1000 || mtn2 >= 1000) && (mtn1*3 < mtn2*2 || mtn2*3 < mtn1*2)) ||
597 ((mtn1 >= 2000 || mtn2 >= 2000) && (mtn1*5 < mtn2*4 || mtn2*5 < mtn1*4)) ||
598 ((mtn1 >= 4000 || mtn2 >= 4000) && c2 > c1))
599 ret = mtn1 > mtn2 ? match2 : match1;
600 else if (mr > 0.005 &&
FFMAX(mtn1, mtn2) > 150 && (mtn1*2 < mtn2*1 || mtn2*2 < mtn1*1))
601 ret = mtn1 > mtn2 ? match2 : match1;
603 ret = norm1 > norm2 ? match2 : match1;
612 const int plane_h =
get_height(fm, src, plane);
613 const int nb_copy_fields = (plane_h >> 1) + (field ? 0 : (plane_h & 1));
616 get_width(fm, src, plane), nb_copy_fields);
648 AVFrame **gen_frames,
int field)
652 #define LOAD_COMB(mid) do { \
653 if (combs[mid] < 0) { \
654 if (!gen_frames[mid]) \
655 gen_frames[mid] = create_weave_frame(ctx, mid, field, \
656 fm->prv, fm->src, fm->nxt); \
657 combs[mid] = calc_combed_score(fm, gen_frames[mid]); \
664 if ((combs[m2] * 3 < combs[m1] || (combs[m2] * 2 < combs[m1] && combs[m1] > fm->
combpel)) &&
665 abs(combs[m2] - combs[m1]) >= 30 && combs[m2] < fm->
combpel)
679 int combs[] = { -1, -1, -1, -1, -1 };
680 int order, field, i, match, sc = 0;
686 #define SLIDING_FRAME_WINDOW(prv, src, nxt) do { \
688 av_frame_free(&prv); \
697 av_assert0(prv && src && nxt); \
714 av_assert0(order == 0 || order == 1 || field == 0 || field == 1);
729 combs[0], combs[1], combs[2], combs[3], combs[4]);
761 match =
checkmm(ctx, combs, match, match == fxo[mP] ? fxo[mC] : fxo[mP], gen_frames, field);
764 match =
checkmm(ctx, combs, match, fxo[mN], gen_frames, field);
767 match =
checkmm(ctx, combs, match, fxo[
mU], gen_frames, field);
770 match =
checkmm(ctx, combs, match, fxo[mN], gen_frames, field);
771 match =
checkmm(ctx, combs, match, fxo[mU], gen_frames, field);
772 match =
checkmm(ctx, combs, match, fxo[
mB], gen_frames, field);
776 match =
checkmm(ctx, combs, match, match == fxo[mP] ? fxo[mC] : fxo[mP], gen_frames, field);
779 match =
checkmm(ctx, combs, match, fxo[mU], gen_frames, field);
780 match =
checkmm(ctx, combs, match, fxo[mB], gen_frames, field);
793 if (!gen_frames[match]) {
796 dst = gen_frames[match];
797 gen_frames[match] =
NULL;
815 " match=%d combed=%s\n", sc, combs[0], combs[1], combs[2], combs[3], combs[4],
844 if ((fm->
eof & eof_mask) == eof_mask)
873 const int w = inlink->
w;
874 const int h = inlink->
h;
927 av_log(ctx,
AV_LOG_ERROR,
"Combed pixel should not be larger than blockx x blocky\n");
962 outlink->
w = inlink->
w;
963 outlink->
h = inlink->
h;
978 .
name =
"fieldmatch",
986 .priv_class = &fieldmatch_class,
#define VERTICAL_HALF(y_start, y_end)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
Main libavfilter public API header.
static av_cold int init(AVCodecContext *avctx)
int av_image_alloc(uint8_t *pointers[4], int linesizes[4], int w, int h, enum AVPixelFormat pix_fmt, int align)
Allocate an image with size w and h and pixel format pix_fmt, and fill pointers and linesizes accordi...
int h
agreed upon image height
static int get_width(const FieldMatchContext *fm, const AVFrame *f, int plane)
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
static int get_field_base(int match, int field)
static int config_output(AVFilterLink *outlink)
static void fill_buf(uint8_t *data, int w, int h, int linesize, uint8_t v)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
int combmatch
comb_matching_mode
BYTE int const BYTE * srcp
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static AVFrame * create_weave_frame(AVFilterContext *ctx, int match, int field, const AVFrame *prv, AVFrame *src, const AVFrame *nxt)
static av_cold int uninit(AVCodecContext *avctx)
timestamp utils, mostly useful for debugging/logging purposes
static const AVOption fieldmatch_options[]
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AVERROR_EOF
End of file.
int interlaced_frame
The content of the picture is interlaced.
A filter pad used for either input or output.
A link between two filters.
AVFilterPad * input_pads
array of input pads
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0, will be automatically copied from the first input of the source filter if it exists.
static av_cold int fieldmatch_init(AVFilterContext *ctx)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#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...
simple assert() macros that are a bit more flexible than ISO C assert().
uint32_t eof
bitmask for end of stream
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
static int request_frame(AVFilterLink *outlink)
static int request_inlink(AVFilterContext *ctx, int lid)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static int compare_fields(FieldMatchContext *fm, int match1, int match2, int field)
unsigned nb_inputs
number of input pads
static const AVFilterPad fieldmatch_outputs[]
static AVFrame * select_frame(FieldMatchContext *fm, int match)
AVFrame * nxt
main sliding window of 3 frames
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
AVFILTER_DEFINE_CLASS(fieldmatch)
AVFilterContext * src
source filter
static const AVFilterPad outputs[]
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int format
agreed upon media format
#define FF_ARRAY_ELEMS(a)
static void build_diff_map(FieldMatchContext *fm, const uint8_t *prvp, int prv_linesize, const uint8_t *nxtp, int nxt_linesize, uint8_t *dstp, int dst_linesize, int height, int width, int plane)
Build a map over which pixels differ a lot/a little.
#define AV_LOG_INFO
Standard information.
AVFilter ff_vf_fieldmatch
static const AVFilterPad inputs[]
char * av_strdup(const char *s)
Duplicate the string s.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int got_frame[2]
frame request flag for each input stream
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
BYTE int const BYTE int int int height
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Describe the class of an AVClass context structure.
#define HAS_FF_AROUND(p, lz)
const char * name
Filter name.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
static int checkmm(AVFilterContext *ctx, int *combs, int m1, int m2, AVFrame **gen_frames, int field)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static void build_abs_diff_mask(const uint8_t *prvp, int prv_linesize, const uint8_t *nxtp, int nxt_linesize, uint8_t *tbuffer, int tbuf_linesize, int width, int height)
#define FF_INLINK_IDX(link)
Find the index of a link.
#define SLIDING_FRAME_WINDOW(prv, src, nxt)
#define FILTER(xm2, xm1, xp1, xp2)
static int query_formats(AVFilterContext *ctx)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int config_input(AVFilterLink *inlink)
static av_cold void fieldmatch_uninit(AVFilterContext *ctx)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static void copy_fields(const FieldMatchContext *fm, AVFrame *dst, const AVFrame *src, int field)
static int64_t luma_abs_diff(const AVFrame *f1, const AVFrame *f2)
static av_always_inline int diff(const uint32_t a, const uint32_t b)
int top_field_first
If the content is interlaced, is top field displayed first.
AVFilterContext * dst
dest filter
AVFrame * nxt2
sliding window of the optional second stream
static int calc_combed_score(const FieldMatchContext *fm, const AVFrame *src)
int vsub
chroma subsampling values
int(* config_props)(AVFilterLink *link)
Link configuration callback.
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
AVPixelFormat
Pixel format.
static int get_height(const FieldMatchContext *fm, const AVFrame *f, int plane)
int64_t frame_count
Number of past frames sent through the link.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_CEIL_RSHIFT(a, b)
static int ff_insert_inpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new input pad for the filter.