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
73 #define ABS(a) (((a) ^ ((a) >> 31)) - ((a) >> 31))
79 for (i = 0; i < 4; i++) {
80 for (j = 0; j < 8; j++)
81 diff +=
ABS(a[j] - b[j]);
93 for (i = 0; i < 4; i++) {
94 for (j = 0; j < 8; j++)
95 comb +=
ABS((a[j] << 1) - b[j - s] - b[j ]) +
96 ABS((b[j] << 1) - a[j ] - a[j + s]);
108 for (i = 0; i < 3; i++) {
109 for (j = 0; j < 8; j++)
110 var +=
ABS(a[j] - a[j + s]);
143 memset(f, 0,
sizeof(*f));
162 for (; len > 0; len--) {
228 if ((parity + 1) & 1)
230 if ((parity + 1) & 2)
241 if ((parity + 1) & 1)
243 if ((parity + 1) & 2)
267 if (parity < 2 && s->last && parity != s->
last->
parity
307 for (f = begin; f !=
end; f = f->
next)
317 for (i = 0; i < max; i++) {
331 int i, l, max_l = 0, max_r = 0;
359 if (max_l + max_r < 128)
361 if (max_l > 4 * max_r)
363 if (max_r > 4 * max_l)
369 int i, max_l = 0, max_r = 0, l;
389 int lc = f-> combs[i] - 2*(v < lv ? v : lv);
390 int rc = f->
next->
combs[i] - 2*(v < rv ? v : rv);
402 if (max_l + max_r < 64)
405 if (max_r > 6 * max_l)
407 else if (max_l > 6 * max_r)
424 for (i = 0; i < n - 1; i++) {
482 for (i = 0; i <
n; i++) {
518 for (i = 0; i < f->
length; i++)
554 for (x = 0; x < w; x += xstep)
555 *dest++ =
func(a + x, b + x, stride);
556 a += ystep; b += ystep;
642 for (i = 0; i < 2; i++) {
678 inlink->
format, inlink->
w, inlink->
h);
725 inlink->
format, inlink->
w, inlink->
h);
771 .priv_class = &pullup_class,
static int alloc_metrics(PullupContext *s, PullupField *f)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
static PullupBuffer * pullup_lock_buffer(PullupBuffer *b, int parity)
static const AVOption pullup_options[]
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Main libavfilter public API header.
int h
agreed upon image height
int repeat_pict
When decoding, this signals how much the picture must be delayed.
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)
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)
static av_cold int end(AVCodecContext *avctx)
static av_cold void uninit(AVFilterContext *ctx)
static void compute_breaks(PullupContext *s, PullupField *f0)
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
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.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
PullupBuffer * ifields[4]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#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.
simple assert() macros that are a bit more flexible than ISO C assert().
static void copy_field(PullupContext *s, PullupBuffer *dst, PullupBuffer *src, int parity)
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.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
static void free_field_queue(PullupField *head)
static PullupFrame * pullup_get_frame(PullupContext *s)
int(* var)(const uint8_t *a, const uint8_t *b, ptrdiff_t s)
static const AVFilterPad pullup_inputs[]
static const AVFilterPad outputs[]
static int var_c(const uint8_t *a, const uint8_t *b, ptrdiff_t s)
static int find_first_break(PullupField *f, int max)
static int diff_c(const uint8_t *a, const uint8_t *b, ptrdiff_t s)
int format
agreed upon media format
#define FF_ARRAY_ELEMS(a)
PullupBuffer * ofields[2]
struct PullupField * next
int(* comb)(const uint8_t *a, const uint8_t *b, ptrdiff_t s)
int(* diff)(const uint8_t *a, const uint8_t *b, ptrdiff_t s)
static void compute_affinity(PullupContext *s, PullupField *f)
static const AVFilterPad inputs[]
static int queue_length(PullupField *begin, PullupField *end)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
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
static void pullup_release_frame(PullupFrame *f)
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
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)
const char * name
Filter name.
static const AVFilterPad pullup_outputs[]
static void pullup_release_buffer(PullupBuffer *b, int parity)
struct PullupField * prev
AVFilterLink ** outputs
array of pointers to output links
AVFILTER_DEFINE_CLASS(pullup)
static enum AVPixelFormat pix_fmts[]
static int config_input(AVFilterLink *inlink)
static int alloc_buffer(PullupContext *s, PullupBuffer *b)
void * av_calloc(size_t nmemb, size_t size)
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
static int comb_c(const uint8_t *a, const uint8_t *b, ptrdiff_t s)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
GLint GLenum GLboolean GLsizei stride
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static void pullup_pack_frame(PullupContext *s, PullupFrame *fr)
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
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
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
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)
static void compute_metric(PullupContext *s, int *dest, PullupField *fa, int pa, PullupField *fb, int pb, int(*func)(const uint8_t *, const uint8_t *, ptrdiff_t))
AVPixelFormat
Pixel format.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static PullupField * make_field_queue(PullupContext *s, int len)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_CEIL_RSHIFT(a, b)