Merge remote-tracking branch 'qatar/master'

* qatar/master:
  vf_interlace: deprecate lowpass option

Conflicts:
	libavfilter/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-02-19 16:16:41 +01:00
commit b14517d3cd
3 changed files with 41 additions and 35 deletions

View File

@ -5278,7 +5278,8 @@ Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code
Simple interlacing filter from progressive contents. This interleaves upper (or Simple interlacing filter from progressive contents. This interleaves upper (or
lower) lines from odd frames with lower (or upper) lines from even frames, lower) lines from odd frames with lower (or upper) lines from even frames,
halving the frame rate and preserving image height. halving the frame rate and preserving image height. A vertical lowpass filter
is always applied in order to avoid twitter effects and reduce moire patterns.
@example @example
Original Original New Frame Original Original New Frame
@ -5298,10 +5299,6 @@ It accepts the following optional parameters:
@item scan @item scan
determines whether the interlaced frame is taken from the even (tff - default) determines whether the interlaced frame is taken from the even (tff - default)
or odd (bff) lines of the progressive frame. or odd (bff) lines of the progressive frame.
@item lowpass
Enable (default) or disable the vertical lowpass filter to avoid twitter
interlacing and reduce moire patterns.
@end table @end table
@section kerndeint @section kerndeint

View File

@ -31,7 +31,7 @@
#define LIBAVFILTER_VERSION_MAJOR 4 #define LIBAVFILTER_VERSION_MAJOR 4
#define LIBAVFILTER_VERSION_MINOR 1 #define LIBAVFILTER_VERSION_MINOR 1
#define LIBAVFILTER_VERSION_MICRO 102 #define LIBAVFILTER_VERSION_MICRO 103
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \ LIBAVFILTER_VERSION_MINOR, \
@ -88,5 +88,8 @@
#ifndef FF_API_NOCONST_GET_NAME #ifndef FF_API_NOCONST_GET_NAME
#define FF_API_NOCONST_GET_NAME (LIBAVFILTER_VERSION_MAJOR < 5) #define FF_API_NOCONST_GET_NAME (LIBAVFILTER_VERSION_MAJOR < 5)
#endif #endif
#ifndef FF_API_INTERLACE_LOWPASS_SET
#define FF_API_INTERLACE_LOWPASS_SET (LIBAVFILTER_VERSION_MAJOR < 5)
#endif
#endif /* AVFILTER_VERSION_H */ #endif /* AVFILTER_VERSION_H */

View File

@ -34,6 +34,7 @@
#include "formats.h" #include "formats.h"
#include "avfilter.h" #include "avfilter.h"
#include "internal.h" #include "internal.h"
#include "version.h"
#include "video.h" #include "video.h"
enum ScanMode { enum ScanMode {
@ -49,7 +50,9 @@ enum FieldType {
typedef struct { typedef struct {
const AVClass *class; const AVClass *class;
enum ScanMode scan; // top or bottom field first scanning enum ScanMode scan; // top or bottom field first scanning
#if FF_API_INTERLACE_LOWPASS_SET
int lowpass; // enable or disable low pass filterning int lowpass; // enable or disable low pass filterning
#endif
AVFrame *cur, *next; // the two frames from which the new one is obtained AVFrame *cur, *next; // the two frames from which the new one is obtained
} InterlaceContext; } InterlaceContext;
@ -62,8 +65,10 @@ static const AVOption interlace_options[] = {
AV_OPT_TYPE_CONST, {.i64 = MODE_TFF }, INT_MIN, INT_MAX, .flags = V, .unit = "scan" }, AV_OPT_TYPE_CONST, {.i64 = MODE_TFF }, INT_MIN, INT_MAX, .flags = V, .unit = "scan" },
{ "bff", "bottom field first", 0, { "bff", "bottom field first", 0,
AV_OPT_TYPE_CONST, {.i64 = MODE_BFF }, INT_MIN, INT_MAX, .flags = V, .unit = "scan" }, AV_OPT_TYPE_CONST, {.i64 = MODE_BFF }, INT_MIN, INT_MAX, .flags = V, .unit = "scan" },
{ "lowpass", "enable vertical low-pass filter", OFFSET(lowpass), #if FF_API_INTERLACE_LOWPASS_SET
{ "lowpass", "(deprecated, this option is always set)", OFFSET(lowpass),
AV_OPT_TYPE_INT, {.i64 = 1 }, 0, 1, .flags = V }, AV_OPT_TYPE_INT, {.i64 = 1 }, 0, 1, .flags = V },
#endif
{ NULL } { NULL }
}; };
@ -96,6 +101,11 @@ static int config_out_props(AVFilterLink *outlink)
AVFilterLink *inlink = outlink->src->inputs[0]; AVFilterLink *inlink = outlink->src->inputs[0];
InterlaceContext *s = ctx->priv; InterlaceContext *s = ctx->priv;
#if FF_API_INTERLACE_LOWPASS_SET
if (!s->lowpass)
av_log(ctx, AV_LOG_WARNING, "This option is deprecated and always set.\n");
#endif
if (inlink->h < 2) { if (inlink->h < 2) {
av_log(ctx, AV_LOG_ERROR, "input video height is too small\n"); av_log(ctx, AV_LOG_ERROR, "input video height is too small\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
@ -110,15 +120,14 @@ static int config_out_props(AVFilterLink *outlink)
outlink->frame_rate.den *= 2; outlink->frame_rate.den *= 2;
outlink->flags |= FF_LINK_FLAG_REQUEST_LOOP; outlink->flags |= FF_LINK_FLAG_REQUEST_LOOP;
av_log(ctx, AV_LOG_VERBOSE, "%s interlacing %s lowpass filter\n", av_log(ctx, AV_LOG_VERBOSE, "%s interlacing\n",
s->scan == MODE_TFF ? "tff" : "bff", (s->lowpass) ? "with" : "without"); s->scan == MODE_TFF ? "tff" : "bff");
return 0; return 0;
} }
static void copy_picture_field(AVFrame *src_frame, AVFrame *dst_frame, static void copy_picture_field(AVFrame *src_frame, AVFrame *dst_frame,
AVFilterLink *inlink, enum FieldType field_type, AVFilterLink *inlink, enum FieldType field_type)
int lowpass)
{ {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
int vsub = desc->log2_chroma_h; int vsub = desc->log2_chroma_h;
@ -129,6 +138,8 @@ static void copy_picture_field(AVFrame *src_frame, AVFrame *dst_frame,
int linesize = av_image_get_linesize(inlink->format, inlink->w, plane); int linesize = av_image_get_linesize(inlink->format, inlink->w, plane);
uint8_t *dstp = dst_frame->data[plane]; uint8_t *dstp = dst_frame->data[plane];
const uint8_t *srcp = src_frame->data[plane]; const uint8_t *srcp = src_frame->data[plane];
int srcp_linesize;
int dstp_linesize;
av_assert0(linesize >= 0); av_assert0(linesize >= 0);
@ -137,9 +148,9 @@ static void copy_picture_field(AVFrame *src_frame, AVFrame *dst_frame,
srcp += src_frame->linesize[plane]; srcp += src_frame->linesize[plane];
if (field_type == FIELD_LOWER) if (field_type == FIELD_LOWER)
dstp += dst_frame->linesize[plane]; dstp += dst_frame->linesize[plane];
if (lowpass) {
int srcp_linesize = src_frame->linesize[plane] * 2; srcp_linesize = src_frame->linesize[plane] * 2;
int dstp_linesize = dst_frame->linesize[plane] * 2; dstp_linesize = dst_frame->linesize[plane] * 2;
for (j = lines; j > 0; j--) { for (j = lines; j > 0; j--) {
const uint8_t *srcp_above = srcp - src_frame->linesize[plane]; const uint8_t *srcp_above = srcp - src_frame->linesize[plane];
const uint8_t *srcp_below = srcp + src_frame->linesize[plane]; const uint8_t *srcp_below = srcp + src_frame->linesize[plane];
@ -156,11 +167,6 @@ static void copy_picture_field(AVFrame *src_frame, AVFrame *dst_frame,
dstp += dstp_linesize; dstp += dstp_linesize;
srcp += srcp_linesize; srcp += srcp_linesize;
} }
} else {
av_image_copy_plane(dstp, dst_frame->linesize[plane] * 2,
srcp, src_frame->linesize[plane] * 2,
linesize, lines);
}
} }
} }
@ -202,11 +208,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
out->pts /= 2; // adjust pts to new framerate out->pts /= 2; // adjust pts to new framerate
/* copy upper/lower field from cur */ /* copy upper/lower field from cur */
copy_picture_field(s->cur, out, inlink, tff ? FIELD_UPPER : FIELD_LOWER, s->lowpass); copy_picture_field(s->cur, out, inlink, tff ? FIELD_UPPER : FIELD_LOWER);
av_frame_free(&s->cur); av_frame_free(&s->cur);
/* copy lower/upper field from next */ /* copy lower/upper field from next */
copy_picture_field(s->next, out, inlink, tff ? FIELD_LOWER : FIELD_UPPER, s->lowpass); copy_picture_field(s->next, out, inlink, tff ? FIELD_LOWER : FIELD_UPPER);
av_frame_free(&s->next); av_frame_free(&s->next);
ret = ff_filter_frame(outlink, out); ret = ff_filter_frame(outlink, out);