Commit 550cb6a8 authored by Huang, Zhengxu's avatar Huang, Zhengxu Committed by Maxym Dmytrychenko

lavf/vf_deinterlace_qsv: Enable the qsv deinterlace vpp

The current qsv deinterlace module does not work at all because MSDK needs user to pass
extra parameters to enable hint functions,such as denoise,deinterlace,composition and so on.

Usage:-hwaccel qsv -r 25 -c:v h264_qsv -i in -vf deinterlace_qsv=bob -b 2M
      -maxrate 3M -c:v h264_qsv -y out.h264
Signed-off-by: 's avatarChaoX A Liu <chaox.a.liu@gmail.com>
Signed-off-by: 's avatarZhengxu Huang <zhengxu.maxwell@gmail.com>
Signed-off-by: 's avatarAndrew Zhang <huazh407@gmail.com>
Change-Id: I9e7ddcf884f2788c2820f6c98affacfb9d8f3287
Signed-off-by: 's avatarMaxym Dmytrychenko <maxim.d33@gmail.com>
parent 2fd6e7d0
...@@ -68,7 +68,9 @@ typedef struct QSVDeintContext { ...@@ -68,7 +68,9 @@ typedef struct QSVDeintContext {
int nb_surface_ptrs; int nb_surface_ptrs;
mfxExtOpaqueSurfaceAlloc opaque_alloc; mfxExtOpaqueSurfaceAlloc opaque_alloc;
mfxExtBuffer *ext_buffers[1]; mfxExtVPPDeinterlacing deint_conf;
mfxExtBuffer *ext_buffers[2];
int num_ext_buffers;
QSVFrame *work_frames; QSVFrame *work_frames;
...@@ -76,6 +78,9 @@ typedef struct QSVDeintContext { ...@@ -76,6 +78,9 @@ typedef struct QSVDeintContext {
int got_output_frame; int got_output_frame;
int eof; int eof;
/* option for Deinterlacing algorithm to be used */
int mode;
} QSVDeintContext; } QSVDeintContext;
static void qsvdeint_uninit(AVFilterContext *ctx) static void qsvdeint_uninit(AVFilterContext *ctx)
...@@ -211,6 +216,12 @@ static int init_out_session(AVFilterContext *ctx) ...@@ -211,6 +216,12 @@ static int init_out_session(AVFilterContext *ctx)
memset(&par, 0, sizeof(par)); memset(&par, 0, sizeof(par));
s->deint_conf.Header.BufferId = MFX_EXTBUFF_VPP_DEINTERLACING;
s->deint_conf.Header.BufferSz = sizeof(s->deint_conf);
s->deint_conf.Mode = s->mode;
s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->deint_conf;
if (opaque) { if (opaque) {
s->surface_ptrs = av_mallocz_array(hw_frames_hwctx->nb_surfaces, s->surface_ptrs = av_mallocz_array(hw_frames_hwctx->nb_surfaces,
sizeof(*s->surface_ptrs)); sizeof(*s->surface_ptrs));
...@@ -229,10 +240,7 @@ static int init_out_session(AVFilterContext *ctx) ...@@ -229,10 +240,7 @@ static int init_out_session(AVFilterContext *ctx)
s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc); s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc);
s->ext_buffers[0] = (mfxExtBuffer*)&s->opaque_alloc; s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->opaque_alloc;
par.ExtParam = s->ext_buffers;
par.NumExtParam = FF_ARRAY_ELEMS(s->ext_buffers);
par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY; par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
} else { } else {
...@@ -260,6 +268,9 @@ static int init_out_session(AVFilterContext *ctx) ...@@ -260,6 +268,9 @@ static int init_out_session(AVFilterContext *ctx)
par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY; par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY;
} }
par.ExtParam = s->ext_buffers;
par.NumExtParam = s->num_ext_buffers;
par.AsyncDepth = 1; // TODO async par.AsyncDepth = 1; // TODO async
par.vpp.In = hw_frames_hwctx->surfaces[0].Info; par.vpp.In = hw_frames_hwctx->surfaces[0].Info;
...@@ -534,6 +545,9 @@ static int qsvdeint_request_frame(AVFilterLink *outlink) ...@@ -534,6 +545,9 @@ static int qsvdeint_request_frame(AVFilterLink *outlink)
#define OFFSET(x) offsetof(QSVDeintContext, x) #define OFFSET(x) offsetof(QSVDeintContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM #define FLAGS AV_OPT_FLAG_VIDEO_PARAM
static const AVOption options[] = { 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"},
{ "advanced", "Motion adaptive algorithm", 0, AV_OPT_TYPE_CONST, {.i64 = MFX_DEINTERLACING_ADVANCED}, MFX_DEINTERLACING_BOB, MFX_DEINTERLACING_ADVANCED, FLAGS, "mode"},
{ NULL }, { NULL },
}; };
......
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