21 #include "libavutil/avassert.h"
22 #include "libavutil/imgutils.h"
23 #include "libavutil/opt.h"
24 #include "libavutil/pixdesc.h"
31 #define F_HAVE_BREAKS 1
32 #define F_HAVE_AFFINITY 2
37 #define OFFSET(x) offsetof(PullupContext, x)
38 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
70 #define ABS(a) (((a) ^ ((a) >> 31)) - ((a) >> 31))
76 for (i = 0; i < 4; i++) {
77 for (j = 0; j < 8; j++)
78 diff +=
ABS(a[j] - b[j]);
90 for (i = 0; i < 4; i++) {
91 for (j = 0; j < 8; j++)
92 comb +=
ABS((a[j] << 1) - b[j - s] - b[j ]) +
93 ABS((b[j] << 1) - a[j ] - a[j + s]);
105 for (i = 0; i < 3; i++) {
106 for (j = 0; j < 8; j++)
107 var +=
ABS(a[j] - a[j + s]);
142 for (; len > 0; len--) {
210 if ((parity + 1) & 1)
212 if ((parity + 1) & 2)
223 if ((parity + 1) & 1)
225 if ((parity + 1) & 2)
247 if (parity < 2 && s->last && parity != s->
last->
parity
287 for (f = begin; f !=
end; f = f->
next)
297 for (i = 0; i <
max; i++) {
311 int i, l, max_l = 0, max_r = 0;
339 if (max_l + max_r < 128)
341 if (max_l > 4 * max_r)
343 if (max_r > 4 * max_l)
349 int i, max_l = 0, max_r = 0, l;
369 int lc = f->
combs[i] - (v + lv) +
ABS(v - lv);
382 if (max_l + max_r < 64)
385 if (max_r > 6 * max_l)
387 else if (max_l > 6 * max_r)
404 for (i = 0; i < n - 1; i++) {
462 for (i = 0; i <
n; i++) {
498 for (i = 0; i < f->
length; i++)
534 for (x = 0; x < w; x += xstep)
535 *dest++ =
func(a + x, b + x, stride);
536 a += ystep; b += ystep;
622 for (i = 0; i < 2; i++) {
658 inlink->
format, inlink->
w, inlink->
h);
705 inlink->
format, inlink->
w, inlink->
h);
763 .priv_class = &pullup_class,
void * av_calloc(size_t nmemb, size_t size) av_malloc_attrib
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
static int alloc_metrics(PullupContext *s, PullupField *f)
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
static PullupBuffer * pullup_lock_buffer(PullupBuffer *b, int parity)
const char * name
Filter name.
static int comb_c(const uint8_t *a, const uint8_t *b, int s)
static const AVOption pullup_options[]
static int var_c(const uint8_t *a, const uint8_t *b, int s)
void * priv
private data for use by the filter
#define AV_LOG_WARNING
Something somehow does not look correct.
static const AVFilterPad outputs[]
int h
agreed upon image height
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int repeat_pict
When decoding, this signals how much the picture must be delayed.
AVFilter avfilter_vf_pullup
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
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.
static void pullup_submit_field(PullupContext *s, PullupBuffer *b, int parity)
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static PullupBuffer * pullup_get_buffer(PullupContext *s, int parity)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static av_cold int end(AVCodecContext *avctx)
static av_cold void uninit(AVFilterContext *ctx)
#define FF_CEIL_RSHIFT(a, b)
static void compute_breaks(PullupContext *s, PullupField *f0)
int interlaced_frame
The content of the picture is interlaced.
void ff_pullup_init_x86(PullupContext *s)
A filter pad used for either input or output.
A link between two filters.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
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){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));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=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);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);ff_audio_convert_init_arm(ac);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_dlog(ac->avr,"%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
unsigned flags
Link processing flags.
Frame requests may need to loop in order to be fulfilled.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
PullupBuffer * ifields[4]
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
int(* comb)(const uint8_t *a, const uint8_t *b, int s)
static void compute_metric(PullupContext *s, int *dest, PullupField *fa, int pa, PullupField *fb, int pb, int(*func)(const uint8_t *, const uint8_t *, int))
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static void copy_field(PullupContext *s, PullupBuffer *dst, PullupBuffer *src, int parity)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
AVPixelFormat
Pixel format.
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
int w
agreed upon image width
#define FF_ARRAY_ELEMS(a)
int(* var)(const uint8_t *a, const uint8_t *b, int s)
static PullupFrame * pullup_get_frame(PullupContext *s)
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int diff_c(const uint8_t *a, const uint8_t *b, int s)
static const AVFilterPad pullup_inputs[]
static int find_first_break(PullupField *f, int max)
int format
agreed upon media format
PullupBuffer * ofields[2]
Main libavfilter public API header.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
AVFilterLink ** outputs
array of pointers to output links
struct PullupField * next
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static void compute_affinity(PullupContext *s, PullupField *f)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
static int queue_length(PullupField *begin, PullupField *end)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static void pullup_release_frame(PullupFrame *f)
static const AVFilterPad inputs[]
static int check_field_queue(PullupContext *s)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
int(* func)(AVBPrint *dst, const char *in, const char *arg)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static const AVFilterPad pullup_outputs[]
static void pullup_release_buffer(PullupBuffer *b, int parity)
AVFilterContext * dst
dest filter
static int config_output(AVFilterLink *outlink)
struct PullupField * prev
static int config_input(AVFilterLink *inlink)
int(* diff)(const uint8_t *a, const uint8_t *b, int s)
static int alloc_buffer(PullupContext *s, PullupBuffer *b)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
static void pullup_pack_frame(PullupContext *s, PullupFrame *fr)
int top_field_first
If the content is interlaced, is top field displayed first.
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){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));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=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);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);ff_audio_convert_init_arm(ac);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_dlog(ac->avr,"%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-> out
#define AVFILTER_DEFINE_CLASS(fname)
static int decide_frame_length(PullupContext *s)
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.
static int query_formats(AVFilterContext *ctx)
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static PullupField * make_field_queue(PullupContext *s, int len)
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...