/*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * 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.
*
- * Libav is distributed in the hope that it will be useful,
+ * 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
QSVDEINT_MORE_INPUT,
};
-typedef struct QSVFrame {
- AVFrame *frame;
- mfxFrameSurface1 surface;
- int used;
-
- struct QSVFrame *next;
-} QSVFrame;
-
typedef struct QSVDeintContext {
const AVClass *class;
int64_t last_pts;
- int got_output_frame;
int eof;
/* option for Deinterlacing algorithm to be used */
int mode;
} QSVDeintContext;
-static void qsvdeint_uninit(AVFilterContext *ctx)
+static av_cold void qsvdeint_uninit(AVFilterContext *ctx)
{
QSVDeintContext *s = ctx->priv;
QSVFrame *cur;
AV_PIX_FMT_QSV, AV_PIX_FMT_NONE,
};
AVFilterFormats *pix_fmts = ff_make_format_list(pixel_formats);
+ int ret;
- ff_set_common_formats(ctx, pix_fmts);
+ if ((ret = ff_set_common_formats(ctx, pix_fmts)) < 0)
+ return ret;
return 0;
}
}
}
- if (err != MFX_ERR_NONE) {
- av_log(ctx, AV_LOG_ERROR, "Error getting the session handle\n");
+ if (err < 0)
+ return ff_qsvvpp_print_error(ctx, err, "Error getting the session handle");
+ else if (err > 0) {
+ ff_qsvvpp_print_warning(ctx, err, "Warning in getting the session handle");
return AVERROR_UNKNOWN;
}
/* create a "slave" session with those same properties, to be used for
* actual deinterlacing */
err = MFXInit(impl, &ver, &s->session);
- if (err != MFX_ERR_NONE) {
- av_log(ctx, AV_LOG_ERROR, "Error initializing a session for deinterlacing\n");
+ if (err < 0)
+ return ff_qsvvpp_print_error(ctx, err, "Error initializing a session for deinterlacing");
+ else if (err > 0) {
+ ff_qsvvpp_print_warning(ctx, err, "Warning in session initialization");
return AVERROR_UNKNOWN;
}
par.vpp.Out.FrameRateExtD = ctx->outputs[0]->time_base.den;
}
+ /* Print input memory mode */
+ ff_qsvvpp_print_iopattern(ctx, par.IOPattern & 0x0F, "VPP");
+ /* Print output memory mode */
+ ff_qsvvpp_print_iopattern(ctx, par.IOPattern & 0xF0, "VPP");
err = MFXVideoVPP_Init(s->session, &par);
- if (err != MFX_ERR_NONE) {
- av_log(ctx, AV_LOG_ERROR, "Error opening the VPP for deinterlacing: %d\n", err);
+ if (err < 0)
+ return ff_qsvvpp_print_error(ctx, err,
+ "Error opening the VPP for deinterlacing");
+ else if (err > 0) {
+ ff_qsvvpp_print_warning(ctx, err,
+ "Warning in VPP initialization");
return AVERROR_UNKNOWN;
}
while (cur) {
if (!cur->surface.Data.Locked) {
av_frame_free(&cur->frame);
- cur->used = 0;
+ cur->queued = 0;
}
cur = cur->next;
}
frame = s->work_frames;
last = &s->work_frames;
while (frame) {
- if (!frame->used) {
+ if (!frame->queued) {
*f = frame;
return 0;
}
qf->surface.Info.PicStruct = !qf->frame->interlaced_frame ? MFX_PICSTRUCT_PROGRESSIVE :
(qf->frame->top_field_first ? MFX_PICSTRUCT_FIELD_TFF :
MFX_PICSTRUCT_FIELD_BFF);
- if (qf->frame->repeat_pict == 1)
+ if (qf->frame->repeat_pict == 1) {
qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FIELD_REPEATED;
- else if (qf->frame->repeat_pict == 2)
+ qf->surface.Info.PicStruct |= qf->frame->top_field_first ? MFX_PICSTRUCT_FIELD_TFF :
+ MFX_PICSTRUCT_FIELD_BFF;
+ } else if (qf->frame->repeat_pict == 2)
qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_DOUBLING;
else if (qf->frame->repeat_pict == 4)
qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_TRIPLING;
(AVRational){1, 90000});
*surface = &qf->surface;
- qf->used = 1;
+ qf->queued = 1;
return 0;
}
return QSVDEINT_MORE_INPUT;
}
- if ((err < 0 && err != MFX_ERR_MORE_SURFACE) || !sync) {
- av_log(ctx, AV_LOG_ERROR, "Error during deinterlacing: %d\n", err);
+ if (err < 0 && err != MFX_ERR_MORE_SURFACE) {
+ ret = ff_qsvvpp_print_error(ctx, err, "Error during deinterlacing");
+ goto fail;
+ }
+
+ if (!sync) {
+ av_log(ctx, AV_LOG_ERROR, "No sync during deinterlacing\n");
ret = AVERROR_UNKNOWN;
goto fail;
}
err = MFXVideoCORE_SyncOperation(s->session, sync, 1000);
} while (err == MFX_WRN_IN_EXECUTION);
if (err < 0) {
- av_log(ctx, AV_LOG_ERROR, "Error synchronizing the operation: %d\n", err);
- ret = AVERROR_UNKNOWN;
+ ret = ff_qsvvpp_print_error(ctx, err, "Error synchronizing the operation");
goto fail;
}
static int qsvdeint_request_frame(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
- QSVDeintContext *s = ctx->priv;
- int ret = 0;
-
- s->got_output_frame = 0;
- while (ret >= 0 && !s->got_output_frame)
- ret = ff_request_frame(ctx->inputs[0]);
- return ret;
+ return ff_request_frame(ctx->inputs[0]);
}
#define OFFSET(x) offsetof(QSVDeintContext, x)
-#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
static const AVOption options[] = {
{ "mode", "set deinterlace mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64 = MFX_DEINTERLACING_ADVANCED}, MFX_DEINTERLACING_BOB, MFX_DEINTERLACING_ADVANCED, FLAGS, "mode"},
{ "bob", "bob algorithm", 0, AV_OPT_TYPE_CONST, {.i64 = MFX_DEINTERLACING_BOB}, MFX_DEINTERLACING_BOB, MFX_DEINTERLACING_ADVANCED, FLAGS, "mode"},
{ NULL }
};
-AVFilter ff_vf_deinterlace_qsv = {
+const AVFilter ff_vf_deinterlace_qsv = {
.name = "deinterlace_qsv",
.description = NULL_IF_CONFIG_SMALL("QuickSync video deinterlacing"),