Commit 9c774459 authored by Paul B Mahol's avatar Paul B Mahol

avfilter: port pullup filter from libmpcodecs

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent fcb069af
......@@ -24,6 +24,7 @@ version <next>
- changed DTS stream id in lavf mpeg ps muxer from 0x8a to 0x88, to be
more consistent with other muxers.
- adelay filter
- pullup filter ported from libmpcodecs
version 2.0:
......
......@@ -41,6 +41,7 @@ Specifically, the GPL parts of FFmpeg are
- vf_perspective.c
- vf_phase.c
- vf_pp.c
- vf_pullup.c
- vf_sab.c
- vf_smartblur.c
- vf_spp.c
......
......@@ -2221,6 +2221,7 @@ owdenoise_filter_deps="gpl"
pan_filter_deps="swresample"
phase_filter_deps="gpl"
pp_filter_deps="gpl postproc"
pullup_filter_deps="gpl"
removelogo_filter_deps="avcodec avformat swscale"
sab_filter_deps="gpl swscale"
scale_filter_deps="swscale"
......
......@@ -6184,6 +6184,59 @@ On this example the input file being processed is compared with the
reference file @file{ref_movie.mpg}. The PSNR of each individual frame
is stored in @file{stats.log}.
@section pullup
Pulldown reversal (inverse telecine) filter, capable of handling mixed
hard-telecine, 24000/1001 fps progressive, and 30000/1001 fps progressive
content.
The pullup filter is designed to take advantage of future context in making
its decisions. This filter is stateless in the sense that it does not lock
onto a pattern to follow, but it instead looks forward to the following
fields in order to identify matches and rebuild progressive frames.
The filter accepts the following options:
@table @option
@item jl
@item jr
@item jt
@item jb
These options set the amount of "junk" to ignore at the left, right, top, and
bottom of the image, respectively. Left and right are in units of 8 pixels,
while top and bottom are in units of 2 lines.
The default is 8 pixels on each side.
@item sb
Set the strict breaks. Setting this option to 1 will reduce the chances of
filter generating an occasional mismatched frame, but it may also cause an
excessive number of frames to be dropped during high motion sequences.
Conversely, setting it to -1 will make filter match fields more easily.
This may help processing of video where there is slight blurring between
the fields, but may also cause there to be interlaced frames in the output.
Default value is @code{0}.
@item mp
Set the metric plane to use. It accepts the following values:
@table @samp
@item l
Use luma plane.
@item u
Use chroma blue plane.
@item v
Use chroma red plane.
@end table
This option may be set to use chroma plane instead of the default luma plane
for doing filter's computations. This may improve accuracy on very clean
source material, but more likely will decrease accuracy, especially if there
is chroma noise (rainbow effect) or any grayscale video.
The main purpose of setting @option{mp} to a chroma plane is to reduce CPU
load and make pullup usable in realtime on slow machines.
@end table
@section removelogo
Suppress a TV station logo, using an image file to determine which
......
......@@ -173,6 +173,7 @@ OBJS-$(CONFIG_PHASE_FILTER) += vf_phase.o
OBJS-$(CONFIG_PIXDESCTEST_FILTER) += vf_pixdesctest.o
OBJS-$(CONFIG_PP_FILTER) += vf_pp.o
OBJS-$(CONFIG_PSNR_FILTER) += vf_psnr.o dualinput.o
OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o
OBJS-$(CONFIG_REMOVELOGO_FILTER) += bbox.o lswsutils.o lavfutils.o vf_removelogo.o
OBJS-$(CONFIG_ROTATE_FILTER) += vf_rotate.o
OBJS-$(CONFIG_SEPARATEFIELDS_FILTER) += vf_separatefields.o
......
......@@ -168,6 +168,7 @@ void avfilter_register_all(void)
REGISTER_FILTER(PIXDESCTEST, pixdesctest, vf);
REGISTER_FILTER(PP, pp, vf);
REGISTER_FILTER(PSNR, psnr, vf);
REGISTER_FILTER(PULLUP, pullup, vf);
REGISTER_FILTER(REMOVELOGO, removelogo, vf);
REGISTER_FILTER(ROTATE, rotate, vf);
REGISTER_FILTER(SAB, sab, vf);
......
......@@ -30,7 +30,7 @@
#include "libavutil/avutil.h"
#define LIBAVFILTER_VERSION_MAJOR 3
#define LIBAVFILTER_VERSION_MINOR 85
#define LIBAVFILTER_VERSION_MINOR 86
#define LIBAVFILTER_VERSION_MICRO 100
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
......
This diff is collapsed.
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVFILTER_PULLUP_H
#define AVFILTER_PULLUP_H
#include "avfilter.h"
typedef struct PullupBuffer {
int lock[2];
uint8_t *planes[4];
} PullupBuffer;
typedef struct PullupField {
int parity;
PullupBuffer *buffer;
unsigned flags;
int breaks;
int affinity;
int *diffs;
int *combs;
int *vars;
struct PullupField *prev, *next;
} PullupField;
typedef struct PullupFrame {
int lock;
int length;
int parity;
PullupBuffer *ifields[4], *ofields[2];
PullupBuffer *buffer;
} PullupFrame;
typedef struct PullupContext {
const AVClass *class;
int junk_left, junk_right, junk_top, junk_down, junk_bottom;
int metric_plane;
int strict_breaks;
int strict_pairs;
int metric_w, metric_h, metric_length;
int metric_offset;
int nb_planes;
int planewidth[4];
int planeheight[4];
PullupField *first, *last, *head;
PullupBuffer buffers[10];
PullupFrame frame;
int (*diff)(const uint8_t *a, const uint8_t *b, int s);
int (*comb)(const uint8_t *a, const uint8_t *b, int s);
int (*var )(const uint8_t *a, const uint8_t *b, int s);
} PullupContext;
void ff_pullup_init_x86(PullupContext *s);
#endif /* AVFILTER_PULLUP_H */
OBJS-$(CONFIG_GRADFUN_FILTER) += x86/vf_gradfun.o
OBJS-$(CONFIG_HQDN3D_FILTER) += x86/vf_hqdn3d_init.o
OBJS-$(CONFIG_PULLUP_FILTER) += x86/vf_pullup_init.o
OBJS-$(CONFIG_SPP_FILTER) += x86/vf_spp.o
OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume_init.o
OBJS-$(CONFIG_YADIF_FILTER) += x86/vf_yadif_init.o
YASM-OBJS-$(CONFIG_HQDN3D_FILTER) += x86/vf_hqdn3d.o
YASM-OBJS-$(CONFIG_PULLUP_FILTER) += x86/vf_pullup.o
YASM-OBJS-$(CONFIG_VOLUME_FILTER) += x86/af_volume.o
YASM-OBJS-$(CONFIG_YADIF_FILTER) += x86/vf_yadif.o x86/yadif-16.o x86/yadif-10.o
;*****************************************************************************
;* x86-optimized functions for pullup filter
;*
;* This file is part of FFmpeg.
;*
;* FFmpeg is free software; you can redistribute it and/or modify
;* it under the terms of the GNU General Public License as published by
;* the Free Software Foundation; either version 2 of the License, or
;* (at your option) any later version.
;*
;* FFmpeg is distributed in the hope that it will be useful,
;* but WITHOUT ANY WARRANTY; without even the implied warranty of
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;* GNU General Public License for more details.
;*
;* You should have received a copy of the GNU General Public License along
;* with FFmpeg; if not, write to the Free Software Foundation, Inc.,
;* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
;******************************************************************************
%include "libavutil/x86/x86util.asm"
SECTION_TEXT
INIT_MMX mmx
cglobal pullup_filter_diff, 3, 5, 8, first, second, size
mov r3, 4
pxor m4, m4
pxor m7, m7
.loop:
movq m0, [firstq]
movq m2, [firstq]
add firstq, sizeq
movq m1, [secondq]
add secondq, sizeq
psubusb m2, m1
psubusb m1, m0
movq m0, m2
movq m3, m1
punpcklbw m0, m7
punpcklbw m1, m7
punpckhbw m2, m7
punpckhbw m3, m7
paddw m4, m0
paddw m4, m1
paddw m4, m2
paddw m4, m3
dec r3
jnz .loop
movq m3, m4
punpcklwd m4, m7
punpckhwd m3, m7
paddd m3, m4
movd eax, m3
psrlq m3, 32
movd r4, m3
add eax, r4
RET
INIT_MMX mmx
cglobal pullup_filter_comb, 3, 5, 8, first, second, size
mov r3, 4
pxor m6, m6
pxor m7, m7
sub secondq, sizeq
.loop:
movq m0, [secondq]
movq m1, [secondq]
punpcklbw m0, m7
movq m2, [secondq+sizeq]
punpcklbw m1, m7
punpcklbw m2, m7
paddw m0, m0
paddw m1, m2
movq m2, m0
psubusw m0, m1
psubusw m1, m2
paddw m6, m0
paddw m6, m1
movq m0, [firstq]
movq m1, [secondq]
punpckhbw m0, m7
movq m2, [secondq+sizeq]
punpckhbw m1, m7
punpckhbw m2, m7
paddw m0, m0
paddw m1, m2
movq m2, m0
psubusw m0, m1
psubusw m1, m2
paddw m6, m0
paddw m6, m1
movq m0, [secondq+sizeq]
movq m1, [firstq]
punpcklbw m0, m7
movq m2, [firstq+sizeq]
punpcklbw m1, m7
punpcklbw m2, m7
paddw m0, m0
paddw m1, m2
movq m2, m0
psubusw m0, m1
psubusw m1, m2
paddw m6, m0
paddw m6, m1
movq m0, [secondq+sizeq]
movq m1, [firstq]
punpckhbw m0, m7
movq m2, [firstq+sizeq]
punpckhbw m1, m7
punpckhbw m2, m7
paddw m0, m0
paddw m1, m2
movq m2, m0
psubusw m0, m1
psubusw m1, m2
paddw m6, m0
paddw m6, m1
add firstq, sizeq
add secondq, sizeq
dec r3
jnz .loop
movq m5, m6
punpcklwd m6, m7
punpckhwd m5, m7
paddd m5, m6
movd eax, m5
psrlq m5, 32
movd r4, m5
add eax, r4
RET
INIT_MMX mmx
cglobal pullup_filter_var, 3, 5, 8, first, second, size
mov r3, 3
pxor m4, m4
pxor m7, m7
.loop:
movq m0, [firstq]
movq m2, [firstq]
movq m1, [firstq+sizeq]
add firstq, sizeq
psubusb m2, m1
psubusb m1, m0
movq m0, m2
movq m3, m1
punpcklbw m0, m7
punpcklbw m1, m7
punpckhbw m2, m7
punpckhbw m3, m7
paddw m4, m0
paddw m4, m1
paddw m4, m2
paddw m4, m3
dec r3
jnz .loop
movq m3, m4
punpcklwd m4, m7
punpckhwd m3, m7
paddd m3, m4
movd eax, m3
psrlq m3, 32
movd r4, m3
add eax, r4
shl eax, 2
RET
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/mem.h"
#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
#include "libavfilter/vf_pullup.h"
int ff_pullup_filter_diff_mmx(const uint8_t *a, const uint8_t *b, int s);
int ff_pullup_filter_comb_mmx(const uint8_t *a, const uint8_t *b, int s);
int ff_pullup_filter_var_mmx (const uint8_t *a, const uint8_t *b, int s);
av_cold void ff_pullup_init_x86(PullupContext *s)
{
#if HAVE_YASM
int cpu_flags = av_get_cpu_flags();
if (EXTERNAL_MMX(cpu_flags)) {
s->diff = ff_pullup_filter_diff_mmx;
s->comb = ff_pullup_filter_comb_mmx;
s->var = ff_pullup_filter_var_mmx;
}
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment