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
65#define ABS(a) (((a) ^ ((a) >> 31)) - ((a) >> 31))
67static int diff_c(
const uint8_t *
a,
const uint8_t *
b, ptrdiff_t
s)
71 for (
i = 0;
i < 4;
i++) {
72 for (j = 0; j < 8; j++)
81static int comb_c(
const uint8_t *
a,
const uint8_t *
b, ptrdiff_t
s)
85 for (
i = 0;
i < 4;
i++) {
86 for (j = 0; j < 8; j++)
87 comb +=
ABS((
a[j] << 1) -
b[j -
s] -
b[j ]) +
88 ABS((
b[j] << 1) -
a[j ] -
a[j +
s]);
96static int var_c(
const uint8_t *
a,
const uint8_t *
b, ptrdiff_t
s)
100 for (
i = 0;
i < 3;
i++) {
101 for (j = 0; j < 8; j++)
102 var +=
ABS(
a[j] -
a[j +
s]);
115 if (!
f->diffs || !
f->combs || !
f->vars) {
135 memset(
f, 0,
sizeof(*
f));
180 int mp =
s->metric_plane;
184 if (
mp + 1 >
s->nb_planes) {
190 s->planeheight[0] =
s->planeheight[3] = inlink->
h;
192 s->planewidth[0] =
s->planewidth[3] = inlink->
w;
194 s->metric_w = (
s->planewidth[
mp] - ((
s->junk_left +
s->junk_right) << 3)) >> 3;
195 s->metric_h = (
s->planeheight[
mp] - ((
s->junk_top +
s->junk_bottom) << 1)) >> 3;
196 s->metric_offset = (
s->junk_left << 3) + (
s->junk_top << 1) *
s->planewidth[
mp];
197 s->metric_length =
s->metric_w *
s->metric_h;
210#if ARCH_X86 && HAVE_X86ASM
246 for (
i = 0;
i <
s->nb_planes;
i++) {
249 if (
s->nb_planes == 1)
261 && !
s->last->buffer->lock[
parity]) {
268 if (
s->buffers[
i].lock[0])
270 if (
s->buffers[
i].lock[1])
281 if (((
parity + 1) & 1) &&
s->buffers[
i].lock[0])
283 if (((
parity + 1) & 2) &&
s->buffers[
i].lock[1])
300 for (
f = begin;
f != end;
f =
f->next)
310 for (
i = 0;
i <
max;
i++) {
324 int i, l, max_l = 0, max_r = 0;
342 for (
i = 0;
i <
s->metric_length;
i++) {
352 if (max_l + max_r < 128)
354 if (max_l > 4 * max_r)
356 if (max_r > 4 * max_l)
362 int i, max_l = 0, max_r = 0, l;
369 if (
f->buffer ==
f->next->next->buffer) {
371 f->next->affinity = 0;
372 f->next->next->affinity = -1;
378 for (
i = 0;
i <
s->metric_length;
i++) {
380 int lv =
f->prev->vars[
i];
381 int rv =
f->next->vars[
i];
382 int lc =
f-> combs[
i] - 2*(v < lv ? v : lv);
383 int rc =
f->next->combs[
i] - 2*(v < rv ? v : rv);
395 if (max_l + max_r < 64)
398 if (max_r > 6 * max_l)
400 else if (max_l > 6 * max_r)
417 for (
i = 0;
i < n - 1;
i++) {
431 if (l == 1 &&
s->strict_breaks < 0)
464 int aff =
s->first->next->affinity;
475 for (
i = 0;
i < n;
i++) {
478 s->first->buffer = 0;
479 s->first =
s->first->next;
511 for (
i = 0;
i <
f->length;
i++)
524 int (*
func)(
const uint8_t *,
const uint8_t *, ptrdiff_t))
526 int mp =
s->metric_plane;
528 int ystep =
s->planewidth[
mp] << 3;
530 int w =
s->metric_w * xstep;
539 memset(dest, 0,
s->metric_length *
sizeof(*dest));
546 for (y = 0; y <
s->metric_h; y++) {
547 for (x = 0; x <
w; x += xstep)
549 a += ystep;
b += ystep;
557 if (
s->head->next ==
s->first) {
586 if (
s->last &&
s->last->parity ==
parity)
605 s->head =
s->head->next;
614 for (
i = 0;
i <
s->nb_planes;
i++) {
619 ss,
s->planewidth[
i] << 1,
620 s->planewidth[
i],
s->planeheight[
i] >> 1);
634 for (
i = 0;
i < 2;
i++) {
670 inlink->
format, inlink->
w, inlink->
h);
717 f->buffer->planes,
s->planewidth,
718 inlink->
format, inlink->
w, inlink->
h);
754 .p.priv_class = &pullup_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static int config_input(AVFilterLink *inlink)
static double mp(int i, double w0, double r)
const FFFilter ff_vf_pullup
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
#define ss(width, name, subs,...)
#define AV_CEIL_RSHIFT(a, b)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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 void av_image_copy2(uint8_t *const dst_data[4], const int dst_linesizes[4], uint8_t *const src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Wrapper around av_image_copy() to workaround the limitation that the conversion from uint8_t * const ...
static av_cold void uninit(AVBitStreamFilterContext *ctx)
int(* func)(AVBPrint *dst, const char *in, const char *arg)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FILTER_PIXFMTS_ARRAY(array)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
#define FF_ARRAY_ELEMS(a)
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
int repeat_pict
Number of fields in this frame which should be repeated, i.e.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
struct PullupField * prev
struct PullupField * next
PullupBuffer * ifields[4]
PullupBuffer * ofields[2]
static AVFormatContext * ctx
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
static void pullup_release_buffer(PullupBuffer *b, int parity)
static int var_c(const uint8_t *a, const uint8_t *b, ptrdiff_t s)
static void pullup_pack_frame(PullupContext *s, PullupFrame *fr)
static int check_field_queue(PullupContext *s)
static int decide_frame_length(PullupContext *s)
static PullupBuffer * pullup_lock_buffer(PullupBuffer *b, int parity)
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))
static int config_input(AVFilterLink *inlink)
static void compute_affinity(PullupContext *s, PullupField *f)
static int diff_c(const uint8_t *a, const uint8_t *b, ptrdiff_t s)
static int comb_c(const uint8_t *a, const uint8_t *b, ptrdiff_t s)
static void pullup_submit_field(PullupContext *s, PullupBuffer *b, int parity)
static PullupBuffer * pullup_get_buffer(PullupContext *s, int parity)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static int find_first_break(PullupField *f, int max)
static const AVFilterPad pullup_inputs[]
static int alloc_buffer(PullupContext *s, PullupBuffer *b)
static void free_field_queue(PullupField *head)
static int queue_length(PullupField *begin, PullupField *end)
static PullupField * make_field_queue(PullupContext *s, int len)
static int alloc_metrics(PullupContext *s, PullupField *f)
static av_cold void uninit(AVFilterContext *ctx)
static void compute_breaks(PullupContext *s, PullupField *f0)
static PullupFrame * pullup_get_frame(PullupContext *s)
static void pullup_release_frame(PullupFrame *f)
static const AVOption pullup_options[]
void ff_pullup_init_x86(PullupContext *s)
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.