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: ChaoX A Liu <chaox.a.liu@gmail.com>
Signed-off-by: Zhengxu Huang <zhengxu.maxwell@gmail.com>
Signed-off-by: Andrew Zhang <huazh407@gmail.com>
Change-Id: I9e7ddcf884f2788c2820f6c98affacfb9d8f3287
Signed-off-by: Maxym Dmytrychenko <maxim.d33@gmail.com>
... | ... |
@@ -68,7 +68,9 @@ typedef struct QSVDeintContext { |
68 | 68 |
int nb_surface_ptrs; |
69 | 69 |
|
70 | 70 |
mfxExtOpaqueSurfaceAlloc opaque_alloc; |
71 |
- mfxExtBuffer *ext_buffers[1]; |
|
71 |
+ mfxExtVPPDeinterlacing deint_conf; |
|
72 |
+ mfxExtBuffer *ext_buffers[2]; |
|
73 |
+ int num_ext_buffers; |
|
72 | 74 |
|
73 | 75 |
QSVFrame *work_frames; |
74 | 76 |
|
... | ... |
@@ -76,6 +78,9 @@ typedef struct QSVDeintContext { |
76 | 76 |
|
77 | 77 |
int got_output_frame; |
78 | 78 |
int eof; |
79 |
+ |
|
80 |
+ /* option for Deinterlacing algorithm to be used */ |
|
81 |
+ int mode; |
|
79 | 82 |
} QSVDeintContext; |
80 | 83 |
|
81 | 84 |
static void qsvdeint_uninit(AVFilterContext *ctx) |
... | ... |
@@ -211,6 +216,12 @@ static int init_out_session(AVFilterContext *ctx) |
211 | 211 |
|
212 | 212 |
memset(&par, 0, sizeof(par)); |
213 | 213 |
|
214 |
+ s->deint_conf.Header.BufferId = MFX_EXTBUFF_VPP_DEINTERLACING; |
|
215 |
+ s->deint_conf.Header.BufferSz = sizeof(s->deint_conf); |
|
216 |
+ s->deint_conf.Mode = s->mode; |
|
217 |
+ |
|
218 |
+ s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->deint_conf; |
|
219 |
+ |
|
214 | 220 |
if (opaque) { |
215 | 221 |
s->surface_ptrs = av_mallocz_array(hw_frames_hwctx->nb_surfaces, |
216 | 222 |
sizeof(*s->surface_ptrs)); |
... | ... |
@@ -229,10 +240,7 @@ static int init_out_session(AVFilterContext *ctx) |
229 | 229 |
s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; |
230 | 230 |
s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc); |
231 | 231 |
|
232 |
- s->ext_buffers[0] = (mfxExtBuffer*)&s->opaque_alloc; |
|
233 |
- |
|
234 |
- par.ExtParam = s->ext_buffers; |
|
235 |
- par.NumExtParam = FF_ARRAY_ELEMS(s->ext_buffers); |
|
232 |
+ s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->opaque_alloc; |
|
236 | 233 |
|
237 | 234 |
par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY; |
238 | 235 |
} else { |
... | ... |
@@ -260,6 +268,9 @@ static int init_out_session(AVFilterContext *ctx) |
260 | 260 |
par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY; |
261 | 261 |
} |
262 | 262 |
|
263 |
+ par.ExtParam = s->ext_buffers; |
|
264 |
+ par.NumExtParam = s->num_ext_buffers; |
|
265 |
+ |
|
263 | 266 |
par.AsyncDepth = 1; // TODO async |
264 | 267 |
|
265 | 268 |
par.vpp.In = hw_frames_hwctx->surfaces[0].Info; |
... | ... |
@@ -534,6 +545,9 @@ static int qsvdeint_request_frame(AVFilterLink *outlink) |
534 | 534 |
#define OFFSET(x) offsetof(QSVDeintContext, x) |
535 | 535 |
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM |
536 | 536 |
static const AVOption options[] = { |
537 |
+ { "mode", "set deinterlace mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64 = MFX_DEINTERLACING_ADVANCED}, MFX_DEINTERLACING_BOB, MFX_DEINTERLACING_ADVANCED, FLAGS, "mode"}, |
|
538 |
+ { "bob", "bob algorithm", 0, AV_OPT_TYPE_CONST, {.i64 = MFX_DEINTERLACING_BOB}, MFX_DEINTERLACING_BOB, MFX_DEINTERLACING_ADVANCED, FLAGS, "mode"}, |
|
539 |
+ { "advanced", "Motion adaptive algorithm", 0, AV_OPT_TYPE_CONST, {.i64 = MFX_DEINTERLACING_ADVANCED}, MFX_DEINTERLACING_BOB, MFX_DEINTERLACING_ADVANCED, FLAGS, "mode"}, |
|
537 | 540 |
{ NULL }, |
538 | 541 |
}; |
539 | 542 |
|