Commit 9c01cdb9 authored by Vasile Toncu's avatar Vasile Toncu Committed by Paul B Mahol

avfilter/vf_interlace: remove duplicate code with same funcionality

parent 4ac0ff8e
......@@ -234,7 +234,7 @@ OBJS-$(CONFIG_HYSTERESIS_FILTER) += vf_hysteresis.o framesync.o
OBJS-$(CONFIG_IDET_FILTER) += vf_idet.o
OBJS-$(CONFIG_IL_FILTER) += vf_il.o
OBJS-$(CONFIG_INFLATE_FILTER) += vf_neighbor.o
OBJS-$(CONFIG_INTERLACE_FILTER) += vf_interlace.o
OBJS-$(CONFIG_INTERLACE_FILTER) += vf_tinterlace.o
OBJS-$(CONFIG_INTERLEAVE_FILTER) += f_interleave.o
OBJS-$(CONFIG_KERNDEINT_FILTER) += vf_kerndeint.o
OBJS-$(CONFIG_LENSCORRECTION_FILTER) += vf_lenscorrection.o
......
/*
* 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.
*/
/**
* @file
* progressive to interlaced content filter, inspired by heavy debugging of
* tinterlace filter.
*/
#ifndef AVFILTER_INTERLACE_H
#define AVFILTER_INTERLACE_H
#include "libavutil/bswap.h"
#include "libavutil/common.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
enum ScanMode {
MODE_TFF = 0,
MODE_BFF = 1,
};
enum FieldType {
FIELD_UPPER = 0,
FIELD_LOWER = 1,
};
enum VLPFilter {
VLPF_OFF = 0,
VLPF_LIN = 1,
VLPF_CMP = 2,
};
typedef struct InterlaceContext {
const AVClass *class;
enum ScanMode scan; // top or bottom field first scanning
int lowpass; // enable or disable low pass filtering
AVFrame *cur, *next; // the two frames from which the new one is obtained
const AVPixFmtDescriptor *csp;
void (*lowpass_line)(uint8_t *dstp, ptrdiff_t linesize, const uint8_t *srcp,
ptrdiff_t mref, ptrdiff_t pref, int clip_max);
} InterlaceContext;
void ff_interlace_init(InterlaceContext *interlace, int depth);
void ff_interlace_init_x86(InterlaceContext *interlace, int depth);
#endif /* AVFILTER_INTERLACE_H */
This diff is collapsed.
......@@ -59,6 +59,20 @@ static const AVOption tinterlace_options[] = {
AVFILTER_DEFINE_CLASS(tinterlace);
static const AVOption interlace_options[] = {
{ "scan", "scanning mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=MODE_INTERLEAVE_TOP}, 0, MODE_NB-1, FLAGS, "mode"},
{ "tff", "top field first", 0, AV_OPT_TYPE_CONST, {.i64=MODE_INTERLEAVE_TOP}, INT_MIN, INT_MAX, FLAGS, .unit = "mode" },
{ "bff", "bottom field first", 0, AV_OPT_TYPE_CONST, {.i64=MODE_INTERLEAVE_BOTTOM}, INT_MIN, INT_MAX, FLAGS, .unit = "mode"},
{ "lowpass", "set vertical low-pass filter", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = TINTERLACE_FLAG_VLPF}, 0,INT_MAX, 0, "flags" },
{ "off", "disable vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, INT_MIN, INT_MAX, FLAGS, "flags" },
{ "linear", "linear vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = TINTERLACE_FLAG_VLPF}, INT_MIN, INT_MAX, FLAGS, "flags" },
{ "complex", "complex vertical low-pass filter", 0, AV_OPT_TYPE_CONST, {.i64 = TINTERLACE_FLAG_CVLPF},INT_MIN, INT_MAX, FLAGS, "flags" },
{ NULL }
};
AVFILTER_DEFINE_CLASS(interlace);
#define FULL_SCALE_YUVJ_FORMATS \
AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P
......@@ -525,3 +539,15 @@ AVFilter ff_vf_tinterlace = {
.outputs = tinterlace_outputs,
.priv_class = &tinterlace_class,
};
AVFilter ff_vf_interlace = {
.name = "interlace",
.description = NULL_IF_CONFIG_SMALL("Convert progressive video into interlaced."),
.priv_size = sizeof(TInterlaceContext),
.uninit = uninit,
.query_formats = query_formats,
.inputs = tinterlace_inputs,
.outputs = tinterlace_outputs,
.priv_class = &interlace_class,
};
......@@ -9,7 +9,7 @@ OBJS-$(CONFIG_FRAMERATE_FILTER) += x86/vf_framerate_init.o
OBJS-$(CONFIG_HFLIP_FILTER) += x86/vf_hflip_init.o
OBJS-$(CONFIG_HQDN3D_FILTER) += x86/vf_hqdn3d_init.o
OBJS-$(CONFIG_IDET_FILTER) += x86/vf_idet_init.o
OBJS-$(CONFIG_INTERLACE_FILTER) += x86/vf_interlace_init.o
OBJS-$(CONFIG_INTERLACE_FILTER) += x86/vf_tinterlace_init.o
OBJS-$(CONFIG_LIMITER_FILTER) += x86/vf_limiter_init.o
OBJS-$(CONFIG_MASKEDMERGE_FILTER) += x86/vf_maskedmerge_init.o
OBJS-$(CONFIG_NOISE_FILTER) += x86/vf_noise.o
......
/*
* Copyright (C) 2014 Kieran Kunhya <kierank@obe.tv>
*
* 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/internal.h"
#include "libavutil/mem.h"
#include "libavutil/x86/cpu.h"
#include "libavfilter/interlace.h"
void ff_lowpass_line_sse2(uint8_t *dstp, ptrdiff_t linesize,
const uint8_t *srcp, ptrdiff_t mref,
ptrdiff_t pref, int clip_max);
void ff_lowpass_line_avx (uint8_t *dstp, ptrdiff_t linesize,
const uint8_t *srcp, ptrdiff_t mref,
ptrdiff_t pref, int clip_max);
void ff_lowpass_line_avx2 (uint8_t *dstp, ptrdiff_t linesize,
const uint8_t *srcp, ptrdiff_t mref,
ptrdiff_t pref, int clip_max);
void ff_lowpass_line_16_sse2(uint8_t *dstp, ptrdiff_t linesize,
const uint8_t *srcp, ptrdiff_t mref,
ptrdiff_t pref, int clip_max);
void ff_lowpass_line_16_avx (uint8_t *dstp, ptrdiff_t linesize,
const uint8_t *srcp, ptrdiff_t mref,
ptrdiff_t pref, int clip_max);
void ff_lowpass_line_16_avx2 (uint8_t *dstp, ptrdiff_t linesize,
const uint8_t *srcp, ptrdiff_t mref,
ptrdiff_t pref, int clip_max);
void ff_lowpass_line_complex_sse2(uint8_t *dstp, ptrdiff_t linesize,
const uint8_t *srcp, ptrdiff_t mref,
ptrdiff_t pref, int clip_max);
void ff_lowpass_line_complex_12_sse2(uint8_t *dstp, ptrdiff_t linesize,
const uint8_t *srcp, ptrdiff_t mref,
ptrdiff_t pref, int clip_max);
av_cold void ff_interlace_init_x86(InterlaceContext *s, int depth)
{
int cpu_flags = av_get_cpu_flags();
if (depth > 8) {
if (EXTERNAL_SSE2(cpu_flags)) {
if (s->lowpass == VLPF_LIN)
s->lowpass_line = ff_lowpass_line_16_sse2;
else if (s->lowpass == VLPF_CMP)
s->lowpass_line = ff_lowpass_line_complex_12_sse2;
}
if (EXTERNAL_AVX(cpu_flags))
if (s->lowpass == VLPF_LIN)
s->lowpass_line = ff_lowpass_line_16_avx;
if (EXTERNAL_AVX2_FAST(cpu_flags))
if (s->lowpass == VLPF_LIN)
s->lowpass_line = ff_lowpass_line_16_avx2;
} else {
if (EXTERNAL_SSE2(cpu_flags)) {
if (s->lowpass == VLPF_LIN)
s->lowpass_line = ff_lowpass_line_sse2;
else if (s->lowpass == VLPF_CMP)
s->lowpass_line = ff_lowpass_line_complex_sse2;
}
if (EXTERNAL_AVX(cpu_flags))
if (s->lowpass == VLPF_LIN)
s->lowpass_line = ff_lowpass_line_avx;
if (EXTERNAL_AVX2_FAST(cpu_flags))
if (s->lowpass == VLPF_LIN)
s->lowpass_line = ff_lowpass_line_avx2;
}
}
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