#include <inttypes.h>
#include "libavutil/avassert.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/timestamp.h"
#include "avfilter.h"
#include "filters.h"
#include "internal.h"
Go to the source code of this file.
|
enum | fieldmatch_parity { FM_PARITY_AUTO = -1,
FM_PARITY_BOTTOM = 0,
FM_PARITY_TOP = 1
} |
|
enum | matching_mode {
MODE_PC,
MODE_PC_N,
MODE_PC_U,
MODE_PC_N_UB,
MODE_PCN,
MODE_PCN_UB,
NB_MODE
} |
|
enum | comb_matching_mode { COMBMATCH_NONE,
COMBMATCH_SC,
COMBMATCH_FULL,
NB_COMBMATCH
} |
|
enum | comb_dbg { COMBDBG_NONE,
COMBDBG_PCN,
COMBDBG_PCNUB,
NB_COMBDBG
} |
|
enum | {
mP,
mC,
mN,
mB,
mU
} |
|
|
| AVFILTER_DEFINE_CLASS (fieldmatch) |
|
static int | get_width (const FieldMatchContext *fm, const AVFrame *f, int plane) |
|
static int | get_height (const FieldMatchContext *fm, const AVFrame *f, int plane) |
|
static int64_t | luma_abs_diff (const AVFrame *f1, const AVFrame *f2) |
|
static void | fill_buf (uint8_t *data, int w, int h, int linesize, uint8_t v) |
|
static int | calc_combed_score (const FieldMatchContext *fm, const AVFrame *src) |
|
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) |
|
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. More...
|
|
static int | get_field_base (int match, int field) |
|
static AVFrame * | select_frame (FieldMatchContext *fm, int match) |
|
static int | compare_fields (FieldMatchContext *fm, int match1, int match2, int field) |
|
static void | copy_fields (const FieldMatchContext *fm, AVFrame *dst, const AVFrame *src, int field) |
|
static AVFrame * | create_weave_frame (AVFilterContext *ctx, int match, int field, const AVFrame *prv, AVFrame *src, const AVFrame *nxt) |
|
static int | checkmm (AVFilterContext *ctx, int *combs, int m1, int m2, AVFrame **gen_frames, int field) |
|
static int | filter_frame (AVFilterLink *inlink, AVFrame *in) |
|
static int | activate (AVFilterContext *ctx) |
|
static int | query_formats (AVFilterContext *ctx) |
|
static int | config_input (AVFilterLink *inlink) |
|
static av_cold int | fieldmatch_init (AVFilterContext *ctx) |
|
static av_cold void | fieldmatch_uninit (AVFilterContext *ctx) |
|
static int | config_output (AVFilterLink *outlink) |
|
Fieldmatching filter, ported from VFM filter (VapourSynth) by Clément. Fredrik Mellbin is the author of the VIVTC/VFM filter, which is itself a light clone of the TIVTC/TFM (AviSynth) filter written by Kevin Stone (tritical), the original author.
- See also
- http://bengal.missouri.edu/~kes25c/
-
http://www.vapoursynth.com/about/
Definition in file vf_fieldmatch.c.
◆ INPUT_MAIN
◆ INPUT_CLEANSRC
◆ OFFSET
◆ FLAGS
◆ FILTER
#define FILTER |
( |
|
xm2, |
|
|
|
xm1, |
|
|
|
xp1, |
|
|
|
xp2 |
|
) |
| |
Value:
-3 * (
srcp[x + (xm1)*src_linesize] +
srcp[x + (xp1)*src_linesize]) \
+ (
srcp[x + (xm2)*src_linesize] +
srcp[x + (xp2)*src_linesize])) > cthresh6
◆ HAS_FF_AROUND
#define HAS_FF_AROUND |
( |
|
p, |
|
|
|
lz |
|
) |
| |
Value: (p[(x)-1 - (lz)] == 0xff || p[(x) - (lz)] == 0xff || p[(x)+1 - (lz)] == 0xff || \
p[(x)-1 ] == 0xff || p[(x)+1 ] == 0xff || \
p[(x)-1 + (lz)] == 0xff || p[(x) + (lz)] == 0xff || p[(x)+1 + (lz)] == 0xff)
◆ C_ARRAY_ADD
Value: do { \
const int box1 = (x / blockx) * 4; \
const int box2 = ((x + xhalf) / blockx) * 4; \
c_array[temp1 + box1 ] += v; \
c_array[temp1 + box2 + 1] += v; \
c_array[temp2 + box1 + 2] += v; \
c_array[temp2 + box2 + 3] += v; \
} while (0)
◆ VERTICAL_HALF
#define VERTICAL_HALF |
( |
|
y_start, |
|
|
|
y_end |
|
) |
| |
Value: do { \
for (y = y_start; y < y_end; y++) { \
const int temp1 = (y / blocky) * xblocks4; \
const int temp2 = ((y + yhalf) / blocky) * xblocks4; \
for (x = 0; x <
width; x++) \
if (cmkp[x - cmk_linesize] == 0xff && \
cmkp[x ] == 0xff && \
cmkp[x + cmk_linesize] == 0xff) \
C_ARRAY_ADD(1); \
cmkp += cmk_linesize; \
} \
} while (0)
◆ LOAD_COMB
Value: do { \
if (combs[mid] < 0) { \
if (!gen_frames[mid]) \
fm->prv, fm->src, fm->nxt); \
} \
} while (0)
◆ SLIDING_FRAME_WINDOW
#define SLIDING_FRAME_WINDOW |
( |
|
prv, |
|
|
|
src, |
|
|
|
nxt |
|
) |
| |
Value: do { \
av_frame_free(&prv); \
src = nxt; \
if (!prv) \
if (!prv) \
return 0; \
av_assert0(prv &&
src && nxt); \
} while (0)
◆ fieldmatch_parity
Enumerator |
---|
FM_PARITY_AUTO | |
FM_PARITY_BOTTOM | |
FM_PARITY_TOP | |
Definition at line 46 of file vf_fieldmatch.c.
◆ matching_mode
Enumerator |
---|
MODE_PC | |
MODE_PC_N | |
MODE_PC_U | |
MODE_PC_N_UB | |
MODE_PCN | |
MODE_PCN_UB | |
NB_MODE | |
Definition at line 52 of file vf_fieldmatch.c.
◆ comb_matching_mode
Enumerator |
---|
COMBMATCH_NONE | |
COMBMATCH_SC | |
COMBMATCH_FULL | |
NB_COMBMATCH | |
Definition at line 62 of file vf_fieldmatch.c.
◆ comb_dbg
Enumerator |
---|
COMBDBG_NONE | |
COMBDBG_PCN | |
COMBDBG_PCNUB | |
NB_COMBDBG | |
Definition at line 69 of file vf_fieldmatch.c.
◆ anonymous enum
◆ AVFILTER_DEFINE_CLASS()
AVFILTER_DEFINE_CLASS |
( |
fieldmatch |
| ) |
|
◆ get_width()
◆ get_height()
◆ luma_abs_diff()
static int64_t luma_abs_diff |
( |
const AVFrame * |
f1, |
|
|
const AVFrame * |
f2 |
|
) |
| |
|
static |
◆ fill_buf()
◆ calc_combed_score()
◆ build_abs_diff_mask()
◆ build_diff_map()
◆ get_field_base()
static int get_field_base |
( |
int |
match, |
|
|
int |
field |
|
) |
| |
|
static |
◆ select_frame()
◆ compare_fields()
◆ copy_fields()
◆ create_weave_frame()
◆ checkmm()
◆ filter_frame()
◆ activate()
◆ query_formats()
◆ config_input()
◆ fieldmatch_init()
◆ fieldmatch_uninit()
◆ config_output()
◆ fieldmatch_options
◆ fxo0m
◆ fxo1m
◆ fieldmatch_outputs
◆ ff_vf_fieldmatch
Initial value:= {
.name = "fieldmatch",
.priv_class = &fieldmatch_class,
}
Definition at line 1042 of file vf_fieldmatch.c.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} 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;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in