Go to the documentation of this file.
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++)
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]);
123 if (!
f->diffs || !
f->combs || !
f->vars) {
143 memset(
f, 0,
sizeof(*
f));
188 int mp =
s->metric_plane;
192 if (mp + 1 >
s->nb_planes) {
198 s->planeheight[0] =
s->planeheight[3] =
inlink->h;
200 s->planewidth[0] =
s->planewidth[3] =
inlink->w;
202 s->metric_w = (
s->planewidth[mp] - ((
s->junk_left +
s->junk_right) << 3)) >> 3;
203 s->metric_h = (
s->planeheight[mp] - ((
s->junk_top +
s->junk_bottom) << 1)) >> 3;
204 s->metric_offset = (
s->junk_left << 3) + (
s->junk_top << 1) *
s->planewidth[mp];
205 s->metric_length =
s->metric_w *
s->metric_h;
253 for (
i = 0;
i <
s->nb_planes;
i++) {
256 if (
s->nb_planes == 1)
267 if (parity < 2 && s->last &&
parity !=
s->last->parity
268 && !
s->last->buffer->lock[
parity]) {
275 if (
s->buffers[
i].lock[0])
277 if (
s->buffers[
i].lock[1])
288 if (((
parity + 1) & 1) &&
s->buffers[
i].lock[0])
290 if (((
parity + 1) & 2) &&
s->buffers[
i].lock[1])
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;
349 for (
i = 0;
i <
s->metric_length;
i++) {
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;
376 if (
f->buffer ==
f->next->next->buffer) {
378 f->next->affinity = 0;
379 f->next->next->affinity = -1;
385 for (
i = 0;
i <
s->metric_length;
i++) {
387 int lv =
f->prev->vars[
i];
388 int rv =
f->next->vars[
i];
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++) {
438 if (l == 1 &&
s->strict_breaks < 0)
471 int aff =
s->first->next->affinity;
482 for (
i = 0;
i < n;
i++) {
485 s->first->buffer = 0;
486 s->first =
s->first->next;
518 for (
i = 0;
i <
f->length;
i++)
533 int mp =
s->metric_plane;
535 int ystep =
s->planewidth[mp] << 3;
536 int stride =
s->planewidth[mp] << 1;
537 int w =
s->metric_w * xstep;
545 if (fa->
buffer ==
fb->buffer && pa == pb) {
546 memset(dest, 0,
s->metric_length *
sizeof(*dest));
550 a = fa->
buffer->
planes[mp] + pa *
s->planewidth[mp] +
s->metric_offset;
551 b =
fb->buffer->planes[mp] + pb *
s->planewidth[mp] +
s->metric_offset;
553 for (y = 0; y <
s->metric_h; y++) {
554 for (x = 0; x <
w; x += xstep)
556 a += ystep;
b += ystep;
564 if (
s->head->next ==
s->first) {
593 if (
s->last &&
s->last->parity ==
parity)
613 s->head =
s->head->next;
622 for (
i = 0;
i <
s->nb_planes;
i++) {
627 ss,
s->planewidth[
i] << 1,
628 s->planewidth[
i],
s->planeheight[
i] >> 1);
642 for (
i = 0;
i < 2;
i++) {
680 p =
in->interlaced_frame ? !
in->top_field_first : 0;
700 if (!
in->repeat_pict)
724 (
const uint8_t**)
f->buffer->planes,
s->planewidth,
771 .priv_class = &pullup_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
int(* func)(AVBPrint *dst, const char *in, const char *arg)
#define AV_LOG_WARNING
Something somehow does not look correct.
AVPixelFormat
Pixel format.
static const AVOption pullup_options[]
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 PullupFrame * pullup_get_frame(PullupContext *s)
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)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
static int config_input(AVFilterLink *inlink)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static int alloc_buffer(PullupContext *s, PullupBuffer *b)
This structure describes decoded (raw) audio or video data.
static const AVFilterPad pullup_outputs[]
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
const char * name
Filter name.
static void pullup_pack_frame(PullupContext *s, PullupFrame *fr)
static int queue_length(PullupField *begin, PullupField *end)
A link between two filters.
static int var_c(const uint8_t *a, const uint8_t *b, ptrdiff_t 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 comb_c(const uint8_t *a, const uint8_t *b, ptrdiff_t s)
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
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))
#define ss(width, name, subs,...)
A filter pad used for either input or output.
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
static const AVFilterPad pullup_inputs[]
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
AVFILTER_DEFINE_CLASS(pullup)
static void pullup_release_buffer(PullupBuffer *b, int parity)
#define AV_CEIL_RSHIFT(a, b)
static PullupBuffer * pullup_lock_buffer(PullupBuffer *b, int parity)
static const AVFilterPad outputs[]
static enum AVPixelFormat pix_fmts[]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
static int check_field_queue(PullupContext *s)
static int decide_frame_length(PullupContext *s)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
PullupBuffer * ifields[4]
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
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
static void pullup_submit_field(PullupContext *s, PullupBuffer *b, int parity)
static int alloc_metrics(PullupContext *s, PullupField *f)
static void compute_breaks(PullupContext *s, PullupField *f0)
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
static void compute_affinity(PullupContext *s, PullupField *f)
int w
agreed upon image width
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
static int find_first_break(PullupField *f, int max)
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
static void copy_field(PullupContext *s, PullupBuffer *dst, PullupBuffer *src, int parity)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static int query_formats(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
const char * name
Pad name.
PullupBuffer * ofields[2]
static void free_field_queue(PullupField *head)
struct PullupField * next
static PullupField * make_field_queue(PullupContext *s, int len)
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
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 h
agreed upon image height
struct PullupField * prev
static int diff_c(const uint8_t *a, const uint8_t *b, ptrdiff_t s)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
void ff_pullup_init_x86(PullupContext *s)
static av_always_inline int diff(const uint32_t a, const uint32_t b)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static void pullup_release_frame(PullupFrame *f)