summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/ffmpeg/libavfilter/vf_yadif.c
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/ffmpeg/libavfilter/vf_yadif.c')
-rw-r--r--chromium/third_party/ffmpeg/libavfilter/vf_yadif.c143
1 files changed, 43 insertions, 100 deletions
diff --git a/chromium/third_party/ffmpeg/libavfilter/vf_yadif.c b/chromium/third_party/ffmpeg/libavfilter/vf_yadif.c
index 40383a4d06b..70670c3eb9d 100644
--- a/chromium/third_party/ffmpeg/libavfilter/vf_yadif.c
+++ b/chromium/third_party/ffmpeg/libavfilter/vf_yadif.c
@@ -2,19 +2,19 @@
* Copyright (C) 2006-2011 Michael Niedermayer <michaelni@gmx.at>
* 2010 James Darnley <james.darnley@gmail.com>
*
- * 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 free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser 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.
+ * You should have received a copy of the GNU Lesser 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/avassert.h"
@@ -23,15 +23,12 @@
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"
-#include "libavutil/x86/asm.h"
-#include "libavutil/x86/cpu.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
#include "yadif.h"
-
typedef struct ThreadData {
AVFrame *frame;
int plane;
@@ -40,42 +37,13 @@ typedef struct ThreadData {
int tff;
} ThreadData;
-typedef struct YADIFContext {
- const AVClass *class;
-
- enum YADIFMode mode;
- enum YADIFParity parity;
- enum YADIFDeint deint;
-
- int frame_pending;
-
- AVFrame *cur;
- AVFrame *next;
- AVFrame *prev;
- AVFrame *out;
-
- /**
- * Required alignment for filter_line
- */
- void (*filter_line)(void *dst,
- void *prev, void *cur, void *next,
- int w, int prefs, int mrefs, int parity, int mode);
- void (*filter_edges)(void *dst, void *prev, void *cur, void *next,
- int w, int prefs, int mrefs, int parity, int mode);
-
- const AVPixFmtDescriptor *csp;
- int eof;
- uint8_t *temp_line;
- int temp_line_size;
-} YADIFContext;
-
#define CHECK(j)\
- { int score = FFABS(cur[mrefs - 1 + j] - cur[prefs - 1 - j])\
- + FFABS(cur[mrefs + j] - cur[prefs - j])\
- + FFABS(cur[mrefs + 1 + j] - cur[prefs + 1 - j]);\
+ { int score = FFABS(cur[mrefs - 1 + (j)] - cur[prefs - 1 - (j)])\
+ + FFABS(cur[mrefs +(j)] - cur[prefs -(j)])\
+ + FFABS(cur[mrefs + 1 + (j)] - cur[prefs + 1 - (j)]);\
if (score < spatial_score) {\
spatial_score= score;\
- spatial_pred= (cur[mrefs + j] + cur[prefs - j])>>1;\
+ spatial_pred= (cur[mrefs +(j)] + cur[prefs -(j)])>>1;\
/* The is_not_edge argument here controls when the code will enter a branch
* which reads up to and including x-3 and x+3. */
@@ -357,8 +325,9 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
yadif->cur = yadif->next;
yadif->next = frame;
- if (!yadif->cur)
- return 0;
+ if (!yadif->cur &&
+ !(yadif->cur = av_frame_clone(yadif->next)))
+ return AVERROR(ENOMEM);
if (checkstride(yadif, yadif->next, yadif->cur)) {
av_log(ctx, AV_LOG_VERBOSE, "Reallocating frame due to differing stride\n");
@@ -384,9 +353,8 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
return ff_filter_frame(ctx->outputs[0], yadif->out);
}
- if (!yadif->prev &&
- !(yadif->prev = av_frame_clone(yadif->cur)))
- return AVERROR(ENOMEM);
+ if (!yadif->prev)
+ return 0;
yadif->out = ff_get_video_buffer(ctx->outputs[0], link->w, link->h);
if (!yadif->out)
@@ -432,7 +400,7 @@ static int request_frame(AVFilterLink *link)
} else if (ret < 0) {
return ret;
}
- } while (!yadif->cur);
+ } while (!yadif->prev);
return 0;
}
@@ -493,9 +461,6 @@ static int config_props(AVFilterLink *link)
{
AVFilterContext *ctx = link->src;
YADIFContext *s = link->src->priv;
- int cpu_flags = av_get_cpu_flags();
- int bit_depth = (!s->csp) ? 8
- : s->csp->comp[0].depth_minus1 + 1;
link->time_base.num = link->src->inputs[0]->time_base.num;
link->time_base.den = link->src->inputs[0]->time_base.den * 2;
@@ -519,38 +484,9 @@ static int config_props(AVFilterLink *link)
s->filter_edges = filter_edges;
}
-#if HAVE_YASM
- if (bit_depth >= 15) {
- if (EXTERNAL_SSE4(cpu_flags))
- s->filter_line = ff_yadif_filter_line_16bit_sse4;
- else if (EXTERNAL_SSSE3(cpu_flags))
- s->filter_line = ff_yadif_filter_line_16bit_ssse3;
- else if (EXTERNAL_SSE2(cpu_flags))
- s->filter_line = ff_yadif_filter_line_16bit_sse2;
-#if ARCH_X86_32
- else if (EXTERNAL_MMXEXT(cpu_flags))
- s->filter_line = ff_yadif_filter_line_16bit_mmxext;
-#endif /* ARCH_X86_32 */
- } else if ( bit_depth >= 9 && bit_depth <= 14) {
- if (EXTERNAL_SSSE3(cpu_flags))
- s->filter_line = ff_yadif_filter_line_10bit_ssse3;
- else if (EXTERNAL_SSE2(cpu_flags))
- s->filter_line = ff_yadif_filter_line_10bit_sse2;
-#if ARCH_X86_32
- else if (EXTERNAL_MMXEXT(cpu_flags))
- s->filter_line = ff_yadif_filter_line_10bit_mmxext;
-#endif /* ARCH_X86_32 */
- } else {
- if (EXTERNAL_SSSE3(cpu_flags))
- s->filter_line = ff_yadif_filter_line_ssse3;
- else if (EXTERNAL_SSE2(cpu_flags))
- s->filter_line = ff_yadif_filter_line_sse2;
-#if ARCH_X86_32
- else if (EXTERNAL_MMXEXT(cpu_flags))
- s->filter_line = ff_yadif_filter_line_mmxext;
-#endif /* ARCH_X86_32 */
- }
-#endif /* HAVE_YASM */
+ if (ARCH_X86)
+ ff_yadif_init_x86(s);
+
return 0;
}
@@ -581,6 +517,25 @@ static const AVOption yadif_options[] = {
AVFILTER_DEFINE_CLASS(yadif);
+static const AVFilterPad avfilter_vf_yadif_inputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .filter_frame = filter_frame,
+ },
+ { NULL }
+};
+
+static const AVFilterPad avfilter_vf_yadif_outputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .request_frame = request_frame,
+ .config_props = config_props,
+ },
+ { NULL }
+};
+
AVFilter ff_vf_yadif = {
.name = "yadif",
.description = NULL_IF_CONFIG_SMALL("Deinterlace the input image."),
@@ -588,19 +543,7 @@ AVFilter ff_vf_yadif = {
.priv_class = &yadif_class,
.uninit = uninit,
.query_formats = query_formats,
-
- .inputs = (const AVFilterPad[]) {{ .name = "default",
- .type = AVMEDIA_TYPE_VIDEO,
- .filter_frame = filter_frame,
- },
- { .name = NULL}},
-
- .outputs = (const AVFilterPad[]) {{ .name = "default",
- .type = AVMEDIA_TYPE_VIDEO,
- .request_frame = request_frame,
- .config_props = config_props,
- },
- { .name = NULL}},
-
+ .inputs = avfilter_vf_yadif_inputs,
+ .outputs = avfilter_vf_yadif_outputs,
.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
};