History

qsv: restrict OPAQUE memory to MFX_VERSION < 2.0

OPAQUE memory isn't supported for MFX_VERSION >= 2.0[1][2]. This is in preparation for oneVPL support [1] https://spec.oneapi.io/versions/latest/elements/oneVPL/source/VPL_intel_media_sdk.html#msdk-full-name-feature-removals [2] https://github.com/oneapi-src/oneVPL

Haihao Xiang committed 6 years ago

Commit c77149b1 parent 63cda4011 files · +181 −74Browse files

Unified · Split

11 files
  1. libavcodec/qsv.c +4 −0
  2. libavcodec/qsv.h +2 −0
  3. libavcodec/qsv_internal.h +1 −0
  4. libavcodec/qsvdec.c +9 −0
  5. libavcodec/qsvenc.c +21 −0
  6. libavcodec/qsvenc.h +2 −0
  7. libavfilter/qsvvpp.c +25 −1
  8. libavfilter/qsvvpp.h +3 −0
  9. libavfilter/vf_deinterlace_qsv.c +32 −25
  10. libavfilter/vf_scale_qsv.c +41 −33
  11. libavutil/hwcontext_qsv.c +41 −15
libavcodec/qsv.c+4−0
@@ -81,10 +81,14 @@ static const struct { · 80 unmodified lines
81} qsv_iopatterns[] = {81} qsv_iopatterns[] = {
82 {MFX_IOPATTERN_IN_VIDEO_MEMORY, "input is video memory surface" },82 {MFX_IOPATTERN_IN_VIDEO_MEMORY, "input is video memory surface" },
83 {MFX_IOPATTERN_IN_SYSTEM_MEMORY, "input is system memory surface" },83 {MFX_IOPATTERN_IN_SYSTEM_MEMORY, "input is system memory surface" },
84#if QSV_HAVE_OPAQUE
84 {MFX_IOPATTERN_IN_OPAQUE_MEMORY, "input is opaque memory surface" },85 {MFX_IOPATTERN_IN_OPAQUE_MEMORY, "input is opaque memory surface" },
86#endif
85 {MFX_IOPATTERN_OUT_VIDEO_MEMORY, "output is video memory surface" },87 {MFX_IOPATTERN_OUT_VIDEO_MEMORY, "output is video memory surface" },
86 {MFX_IOPATTERN_OUT_SYSTEM_MEMORY, "output is system memory surface" },88 {MFX_IOPATTERN_OUT_SYSTEM_MEMORY, "output is system memory surface" },
89#if QSV_HAVE_OPAQUE
87 {MFX_IOPATTERN_OUT_OPAQUE_MEMORY, "output is opaque memory surface" },90 {MFX_IOPATTERN_OUT_OPAQUE_MEMORY, "output is opaque memory surface" },
91#endif
88};92};
89 93
90int ff_qsv_print_iopattern(void *log_ctx, int mfx_iopattern,94int ff_qsv_print_iopattern(void *log_ctx, int mfx_iopattern,
libavcodec/qsv.h+2−0
@@ -61,6 +61,8 @@ typedef struct AVQSVContext { · 60 unmodified lines
61 * required by the encoder and the user-provided value nb_opaque_surfaces.61 * required by the encoder and the user-provided value nb_opaque_surfaces.
62 * The array of the opaque surfaces will be exported to the caller through62 * The array of the opaque surfaces will be exported to the caller through
63 * the opaque_surfaces field.63 * the opaque_surfaces field.
64 *
65 * The caller must set this field to zero for oneVPL (MFX_VERSION >= 2.0)
64 */66 */
65 int opaque_alloc;67 int opaque_alloc;
66 68
libavcodec/qsv_internal.h+1−0
@@ -66,6 +66,7 @@ · 65 unmodified lines
66 (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR)))66 (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR)))
67 67
68#define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0)68#define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0)
69#define QSV_HAVE_OPAQUE !QSV_ONEVPL
69 70
70typedef struct QSVMid {71typedef struct QSVMid {
71 AVBufferRef *hw_frames_ref;72 AVBufferRef *hw_frames_ref;
libavcodec/qsvdec.c+9−0
@@ -187,7 +187,11 @@ static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession ses · 186 unmodified lines
187 187
188 ret = ff_qsv_init_session_frames(avctx, &q->internal_qs.session,188 ret = ff_qsv_init_session_frames(avctx, &q->internal_qs.session,
189 &q->frames_ctx, q->load_plugins,189 &q->frames_ctx, q->load_plugins,
190#if QSV_HAVE_OPAQUE
190 q->iopattern == MFX_IOPATTERN_OUT_OPAQUE_MEMORY,191 q->iopattern == MFX_IOPATTERN_OUT_OPAQUE_MEMORY,
192#else
193 0,
194#endif
191 q->gpu_copy);195 q->gpu_copy);
192 if (ret < 0) {196 if (ret < 0) {
193 av_buffer_unref(&q->frames_ctx.hw_frames_ctx);197 av_buffer_unref(&q->frames_ctx.hw_frames_ctx);
@@ -300,10 +304,15 @@ static int qsv_decode_preinit(AVCodecContext *avctx, QSVContext *q, enum AVPixel · 106 unmodified lines
300 AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx;304 AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx;
301 305
302 if (!iopattern) {306 if (!iopattern) {
307#if QSV_HAVE_OPAQUE
303 if (frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME)308 if (frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME)
304 iopattern = MFX_IOPATTERN_OUT_OPAQUE_MEMORY;309 iopattern = MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
305 else if (frames_hwctx->frame_type & MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)310 else if (frames_hwctx->frame_type & MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)
306 iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY;311 iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY;
312#else
313 if (frames_hwctx->frame_type & MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET)
314 iopattern = MFX_IOPATTERN_OUT_VIDEO_MEMORY;
315#endif
307 }316 }
308 }317 }
309 318
libavcodec/qsvenc.c+21−0
@@ -1176,6 +1176,7 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) · 1175 unmodified lines
1176 return 0;1176 return 0;
1177}1177}
1178 1178
1179#if QSV_HAVE_OPAQUE
1179static int qsv_init_opaque_alloc(AVCodecContext *avctx, QSVEncContext *q)1180static int qsv_init_opaque_alloc(AVCodecContext *avctx, QSVEncContext *q)
1180{1181{
1181 AVQSVContext *qsv = avctx->hwaccel_context;1182 AVQSVContext *qsv = avctx->hwaccel_context;
@@ -1212,6 +1213,7 @@ static int qsv_init_opaque_alloc(AVCodecContext *avctx, QSVEncContext *q) · 30 unmodified lines
1212 1213
1213 return 0;1214 return 0;
1214}1215}
1216#endif
1215 1217
1216static int qsvenc_init_session(AVCodecContext *avctx, QSVEncContext *q)1218static int qsvenc_init_session(AVCodecContext *avctx, QSVEncContext *q)
1217{1219{
@@ -1227,7 +1229,11 @@ static int qsvenc_init_session(AVCodecContext *avctx, QSVEncContext *q) · 9 unmodified lines
1227 1229
1228 ret = ff_qsv_init_session_frames(avctx, &q->internal_qs.session,1230 ret = ff_qsv_init_session_frames(avctx, &q->internal_qs.session,
1229 &q->frames_ctx, q->load_plugins,1231 &q->frames_ctx, q->load_plugins,
1232#if QSV_HAVE_OPAQUE
1230 q->param.IOPattern == MFX_IOPATTERN_IN_OPAQUE_MEMORY,1233 q->param.IOPattern == MFX_IOPATTERN_IN_OPAQUE_MEMORY,
1234#else
1235 0,
1236#endif
1231 MFX_GPUCOPY_OFF);1237 MFX_GPUCOPY_OFF);
1232 if (ret < 0) {1238 if (ret < 0) {
1233 av_buffer_unref(&q->frames_ctx.hw_frames_ctx);1239 av_buffer_unref(&q->frames_ctx.hw_frames_ctx);
@@ -1279,11 +1285,17 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) · 45 unmodified lines
1279 AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx;1285 AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx;
1280 1286
1281 if (!iopattern) {1287 if (!iopattern) {
1288#if QSV_HAVE_OPAQUE
1282 if (frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME)1289 if (frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME)
1283 iopattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY;1290 iopattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY;
1284 else if (frames_hwctx->frame_type &1291 else if (frames_hwctx->frame_type &
1285 (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET))1292 (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET))
1286 iopattern = MFX_IOPATTERN_IN_VIDEO_MEMORY;1293 iopattern = MFX_IOPATTERN_IN_VIDEO_MEMORY;
1294#else
1295 if (frames_hwctx->frame_type &
1296 (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET))
1297 iopattern = MFX_IOPATTERN_IN_VIDEO_MEMORY;
1298#endif
1287 }1299 }
1288 }1300 }
1289 1301
@@ -1357,9 +1369,16 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) · 67 unmodified lines
1357 "Error querying (IOSurf) the encoding parameters");1369 "Error querying (IOSurf) the encoding parameters");
1358 1370
1359 if (opaque_alloc) {1371 if (opaque_alloc) {
1372#if QSV_HAVE_OPAQUE
1360 ret = qsv_init_opaque_alloc(avctx, q);1373 ret = qsv_init_opaque_alloc(avctx, q);
1361 if (ret < 0)1374 if (ret < 0)
1362 return ret;1375 return ret;
1376#else
1377 av_log(avctx, AV_LOG_ERROR, "User is requesting to allocate OPAQUE surface, "
1378 "however libmfx %d.%d doesn't support OPAQUE memory.\n",
1379 q->ver.Major, q->ver.Minor);
1380 return AVERROR_UNKNOWN;
1381#endif
1363 }1382 }
1364 1383
1365 ret = MFXVideoENCODE_Init(q->session, &q->param);1384 ret = MFXVideoENCODE_Init(q->session, &q->param);
@@ -1913,8 +1932,10 @@ int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q) · 547 unmodified lines
1913 av_fifo_freep2(&q->async_fifo);1932 av_fifo_freep2(&q->async_fifo);
1914 }1933 }
1915 1934
1935#if QSV_HAVE_OPAQUE
1916 av_freep(&q->opaque_surfaces);1936 av_freep(&q->opaque_surfaces);
1917 av_buffer_unref(&q->opaque_alloc_buf);1937 av_buffer_unref(&q->opaque_alloc_buf);
1938#endif
1918 1939
1919 av_freep(&q->extparam);1940 av_freep(&q->extparam);
1920 1941
libavcodec/qsvenc.h+2−0
@@ -137,9 +137,11 @@ typedef struct QSVEncContext { · 136 unmodified lines
137 mfxExtHEVCTiles exthevctiles;137 mfxExtHEVCTiles exthevctiles;
138 mfxExtVP9Param extvp9param;138 mfxExtVP9Param extvp9param;
139 139
140#if QSV_HAVE_OPAQUE
140 mfxExtOpaqueSurfaceAlloc opaque_alloc;141 mfxExtOpaqueSurfaceAlloc opaque_alloc;
141 mfxFrameSurface1 **opaque_surfaces;142 mfxFrameSurface1 **opaque_surfaces;
142 AVBufferRef *opaque_alloc_buf;143 AVBufferRef *opaque_alloc_buf;
144#endif
143 145
144 mfxExtVideoSignalInfo extvsi;146 mfxExtVideoSignalInfo extvsi;
145 147
libavfilter/qsvvpp.c+25−1
@@ -34,7 +34,9 @@ · 33 unmodified lines
34 34
35#define IS_VIDEO_MEMORY(mode) (mode & (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | \35#define IS_VIDEO_MEMORY(mode) (mode & (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | \
36 MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET))36 MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET))
37#if QSV_HAVE_OPAQUE
37#define IS_OPAQUE_MEMORY(mode) (mode & MFX_MEMTYPE_OPAQUE_FRAME)38#define IS_OPAQUE_MEMORY(mode) (mode & MFX_MEMTYPE_OPAQUE_FRAME)
39#endif
38#define IS_SYSTEM_MEMORY(mode) (mode & MFX_MEMTYPE_SYSTEM_MEMORY)40#define IS_SYSTEM_MEMORY(mode) (mode & MFX_MEMTYPE_SYSTEM_MEMORY)
39#define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl))41#define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl))
40 42
@@ -53,10 +55,14 @@ static const struct { · 12 unmodified lines
53} qsv_iopatterns[] = {55} qsv_iopatterns[] = {
54 {MFX_IOPATTERN_IN_VIDEO_MEMORY, "input is video memory surface" },56 {MFX_IOPATTERN_IN_VIDEO_MEMORY, "input is video memory surface" },
55 {MFX_IOPATTERN_IN_SYSTEM_MEMORY, "input is system memory surface" },57 {MFX_IOPATTERN_IN_SYSTEM_MEMORY, "input is system memory surface" },
58#if QSV_HAVE_OPAQUE
56 {MFX_IOPATTERN_IN_OPAQUE_MEMORY, "input is opaque memory surface" },59 {MFX_IOPATTERN_IN_OPAQUE_MEMORY, "input is opaque memory surface" },
60#endif
57 {MFX_IOPATTERN_OUT_VIDEO_MEMORY, "output is video memory surface" },61 {MFX_IOPATTERN_OUT_VIDEO_MEMORY, "output is video memory surface" },
58 {MFX_IOPATTERN_OUT_SYSTEM_MEMORY, "output is system memory surface" },62 {MFX_IOPATTERN_OUT_SYSTEM_MEMORY, "output is system memory surface" },
63#if QSV_HAVE_OPAQUE
59 {MFX_IOPATTERN_OUT_OPAQUE_MEMORY, "output is opaque memory surface" },64 {MFX_IOPATTERN_OUT_OPAQUE_MEMORY, "output is opaque memory surface" },
65#endif
60};66};
61 67
62int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern,68int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern,
@@ -542,9 +548,13 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) · 479 unmodified lines
542 if (!out_frames_ref)548 if (!out_frames_ref)
543 return AVERROR(ENOMEM);549 return AVERROR(ENOMEM);
544 550
551#if QSV_HAVE_OPAQUE
545 s->out_mem_mode = IS_OPAQUE_MEMORY(s->in_mem_mode) ?552 s->out_mem_mode = IS_OPAQUE_MEMORY(s->in_mem_mode) ?
546 MFX_MEMTYPE_OPAQUE_FRAME :553 MFX_MEMTYPE_OPAQUE_FRAME :
547 MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | MFX_MEMTYPE_FROM_VPPOUT;554 MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | MFX_MEMTYPE_FROM_VPPOUT;
555#else
556 s->out_mem_mode = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | MFX_MEMTYPE_FROM_VPPOUT;
557#endif
548 558
549 out_frames_ctx = (AVHWFramesContext *)out_frames_ref->data;559 out_frames_ctx = (AVHWFramesContext *)out_frames_ref->data;
550 out_frames_hwctx = out_frames_ctx->hwctx;560 out_frames_hwctx = out_frames_ctx->hwctx;
@@ -630,6 +640,7 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) · 79 unmodified lines
630 return AVERROR_UNKNOWN;640 return AVERROR_UNKNOWN;
631 }641 }
632 642
643#if QSV_HAVE_OPAQUE
633 if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode)) {644 if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode)) {
634 s->opaque_alloc.In.Surfaces = s->surface_ptrs_in;645 s->opaque_alloc.In.Surfaces = s->surface_ptrs_in;
635 s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs_in;646 s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs_in;
@@ -641,7 +652,9 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) · 5 unmodified lines
641 652
642 s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;653 s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
643 s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc);654 s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc);
644 } else if (IS_VIDEO_MEMORY(s->in_mem_mode) || IS_VIDEO_MEMORY(s->out_mem_mode)) {655 } else
656#endif
657 if (IS_VIDEO_MEMORY(s->in_mem_mode) || IS_VIDEO_MEMORY(s->out_mem_mode)) {
645 mfxFrameAllocator frame_allocator = {658 mfxFrameAllocator frame_allocator = {
646 .pthis = s,659 .pthis = s,
647 .Alloc = frame_alloc,660 .Alloc = frame_alloc,
@@ -713,6 +726,7 @@ int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *p · 65 unmodified lines
713 goto failed;726 goto failed;
714 }727 }
715 728
729#if QSV_HAVE_OPAQUE
716 if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode)) {730 if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode)) {
717 s->nb_ext_buffers = param->num_ext_buf + 1;731 s->nb_ext_buffers = param->num_ext_buf + 1;
718 s->ext_buffers = av_calloc(s->nb_ext_buffers, sizeof(*s->ext_buffers));732 s->ext_buffers = av_calloc(s->nb_ext_buffers, sizeof(*s->ext_buffers));
@@ -730,6 +744,10 @@ int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *p · 11 unmodified lines
730 s->vpp_param.NumExtParam = param->num_ext_buf;744 s->vpp_param.NumExtParam = param->num_ext_buf;
731 s->vpp_param.ExtParam = param->ext_buf;745 s->vpp_param.ExtParam = param->ext_buf;
732 }746 }
747#else
748 s->vpp_param.NumExtParam = param->num_ext_buf;
749 s->vpp_param.ExtParam = param->ext_buf;
750#endif
733 751
734 s->got_frame = 0;752 s->got_frame = 0;
735 753
@@ -747,15 +765,19 @@ int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *p · 11 unmodified lines
747 s->vpp_param.IOPattern |= MFX_IOPATTERN_IN_SYSTEM_MEMORY;765 s->vpp_param.IOPattern |= MFX_IOPATTERN_IN_SYSTEM_MEMORY;
748 else if (IS_VIDEO_MEMORY(s->in_mem_mode))766 else if (IS_VIDEO_MEMORY(s->in_mem_mode))
749 s->vpp_param.IOPattern |= MFX_IOPATTERN_IN_VIDEO_MEMORY;767 s->vpp_param.IOPattern |= MFX_IOPATTERN_IN_VIDEO_MEMORY;
768#if QSV_HAVE_OPAQUE
750 else if (IS_OPAQUE_MEMORY(s->in_mem_mode))769 else if (IS_OPAQUE_MEMORY(s->in_mem_mode))
751 s->vpp_param.IOPattern |= MFX_IOPATTERN_IN_OPAQUE_MEMORY;770 s->vpp_param.IOPattern |= MFX_IOPATTERN_IN_OPAQUE_MEMORY;
771#endif
752 772
753 if (IS_SYSTEM_MEMORY(s->out_mem_mode))773 if (IS_SYSTEM_MEMORY(s->out_mem_mode))
754 s->vpp_param.IOPattern |= MFX_IOPATTERN_OUT_SYSTEM_MEMORY;774 s->vpp_param.IOPattern |= MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
755 else if (IS_VIDEO_MEMORY(s->out_mem_mode))775 else if (IS_VIDEO_MEMORY(s->out_mem_mode))
756 s->vpp_param.IOPattern |= MFX_IOPATTERN_OUT_VIDEO_MEMORY;776 s->vpp_param.IOPattern |= MFX_IOPATTERN_OUT_VIDEO_MEMORY;
777#if QSV_HAVE_OPAQUE
757 else if (IS_OPAQUE_MEMORY(s->out_mem_mode))778 else if (IS_OPAQUE_MEMORY(s->out_mem_mode))
758 s->vpp_param.IOPattern |= MFX_IOPATTERN_OUT_OPAQUE_MEMORY;779 s->vpp_param.IOPattern |= MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
780#endif
759 781
760 /* Print input memory mode */782 /* Print input memory mode */
761 ff_qsvvpp_print_iopattern(avctx, s->vpp_param.IOPattern & 0x0F, "VPP");783 ff_qsvvpp_print_iopattern(avctx, s->vpp_param.IOPattern & 0x0F, "VPP");
@@ -794,7 +816,9 @@ int ff_qsvvpp_free(QSVVPPContext **vpp) · 32 unmodified lines
794 clear_frame_list(&s->out_frame_list);816 clear_frame_list(&s->out_frame_list);
795 av_freep(&s->surface_ptrs_in);817 av_freep(&s->surface_ptrs_in);
796 av_freep(&s->surface_ptrs_out);818 av_freep(&s->surface_ptrs_out);
819#if QSV_HAVE_OPAQUE
797 av_freep(&s->ext_buffers);820 av_freep(&s->ext_buffers);
821#endif
798 av_freep(&s->frame_infos);822 av_freep(&s->frame_infos);
799 av_fifo_freep2(&s->async_fifo);823 av_fifo_freep2(&s->async_fifo);
800 av_freep(vpp);824 av_freep(vpp);
libavfilter/qsvvpp.h+3−0
@@ -41,6 +41,7 @@ · 40 unmodified lines
41 (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR)))41 (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR)))
42 42
43#define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0)43#define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0)
44#define QSV_HAVE_OPAQUE !QSV_ONEVPL
44 45
45typedef struct QSVFrame {46typedef struct QSVFrame {
46 AVFrame *frame;47 AVFrame *frame;
@@ -66,10 +67,12 @@ typedef struct QSVVPPContext { · 19 unmodified lines
66 mfxFrameSurface1 **surface_ptrs_in;67 mfxFrameSurface1 **surface_ptrs_in;
67 mfxFrameSurface1 **surface_ptrs_out;68 mfxFrameSurface1 **surface_ptrs_out;
68 69
70#if QSV_HAVE_OPAQUE
69 /** MFXVPP extern parameters */71 /** MFXVPP extern parameters */
70 mfxExtOpaqueSurfaceAlloc opaque_alloc;72 mfxExtOpaqueSurfaceAlloc opaque_alloc;
71 mfxExtBuffer **ext_buffers;73 mfxExtBuffer **ext_buffers;
72 int nb_ext_buffers;74 int nb_ext_buffers;
75#endif
73 76
74 int got_frame;77 int got_frame;
75 int async_depth;78 int async_depth;
libavfilter/vf_deinterlace_qsv.c+32−25
@@ -62,7 +62,9 @@ typedef struct QSVDeintContext { · 61 unmodified lines
62 mfxFrameSurface1 **surface_ptrs;62 mfxFrameSurface1 **surface_ptrs;
63 int nb_surface_ptrs;63 int nb_surface_ptrs;
64 64
65#if QSV_HAVE_OPAQUE
65 mfxExtOpaqueSurfaceAlloc opaque_alloc;66 mfxExtOpaqueSurfaceAlloc opaque_alloc;
67#endif
66 mfxExtVPPDeinterlacing deint_conf;68 mfxExtVPPDeinterlacing deint_conf;
67 mfxExtBuffer *ext_buffers[2];69 mfxExtBuffer *ext_buffers[2];
68 int num_ext_buffers;70 int num_ext_buffers;
@@ -154,9 +156,7 @@ static int init_out_session(AVFilterContext *ctx) · 85 unmodified lines
154 AVHWFramesContext *hw_frames_ctx = (AVHWFramesContext*)s->hw_frames_ctx->data;156 AVHWFramesContext *hw_frames_ctx = (AVHWFramesContext*)s->hw_frames_ctx->data;
155 AVQSVFramesContext *hw_frames_hwctx = hw_frames_ctx->hwctx;157 AVQSVFramesContext *hw_frames_hwctx = hw_frames_ctx->hwctx;
156 AVQSVDeviceContext *device_hwctx = hw_frames_ctx->device_ctx->hwctx;158 AVQSVDeviceContext *device_hwctx = hw_frames_ctx->device_ctx->hwctx;
157 159 int opaque = 0;
158 int opaque = !!(hw_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME);
159
160 mfxHDL handle = NULL;160 mfxHDL handle = NULL;
161 mfxHandleType handle_type;161 mfxHandleType handle_type;
162 mfxVersion ver;162 mfxVersion ver;
@@ -165,6 +165,9 @@ static int init_out_session(AVFilterContext *ctx) · 2 unmodified lines
165 mfxStatus err;165 mfxStatus err;
166 int i;166 int i;
167 167
168#if QSV_HAVE_OPAQUE
169 opaque = !!(hw_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME);
170#endif
168 /* extract the properties of the "master" session given to us */171 /* extract the properties of the "master" session given to us */
169 err = MFXQueryIMPL(device_hwctx->session, &impl);172 err = MFXQueryIMPL(device_hwctx->session, &impl);
170 if (err == MFX_ERR_NONE)173 if (err == MFX_ERR_NONE)
@@ -223,28 +226,7 @@ static int init_out_session(AVFilterContext *ctx) · 52 unmodified lines
223 226
224 s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->deint_conf;227 s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->deint_conf;
225 228
226 if (opaque) {229 if (!opaque) {
227 s->surface_ptrs = av_calloc(hw_frames_hwctx->nb_surfaces,
228 sizeof(*s->surface_ptrs));
229 if (!s->surface_ptrs)
230 return AVERROR(ENOMEM);
231 for (i = 0; i < hw_frames_hwctx->nb_surfaces; i++)
232 s->surface_ptrs[i] = hw_frames_hwctx->surfaces + i;
233 s->nb_surface_ptrs = hw_frames_hwctx->nb_surfaces;
234
235 s->opaque_alloc.In.Surfaces = s->surface_ptrs;
236 s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs;
237 s->opaque_alloc.In.Type = hw_frames_hwctx->frame_type;
238
239 s->opaque_alloc.Out = s->opaque_alloc.In;
240
241 s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
242 s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc);
243
244 s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->opaque_alloc;
245
246 par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
247 } else {
248 mfxFrameAllocator frame_allocator = {230 mfxFrameAllocator frame_allocator = {
249 .pthis = ctx,231 .pthis = ctx,
250 .Alloc = frame_alloc,232 .Alloc = frame_alloc,
@@ -268,6 +250,31 @@ static int init_out_session(AVFilterContext *ctx) · 17 unmodified lines
268 250
269 par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY;251 par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY;
270 }252 }
253#if QSV_HAVE_OPAQUE
254 else {
255 s->surface_ptrs = av_calloc(hw_frames_hwctx->nb_surfaces,
256 sizeof(*s->surface_ptrs));
257
258 if (!s->surface_ptrs)
259 return AVERROR(ENOMEM);
260 for (i = 0; i < hw_frames_hwctx->nb_surfaces; i++)
261 s->surface_ptrs[i] = hw_frames_hwctx->surfaces + i;
262 s->nb_surface_ptrs = hw_frames_hwctx->nb_surfaces;
263
264 s->opaque_alloc.In.Surfaces = s->surface_ptrs;
265 s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs;
266 s->opaque_alloc.In.Type = hw_frames_hwctx->frame_type;
267
268 s->opaque_alloc.Out = s->opaque_alloc.In;
269
270 s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
271 s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc);
272
273 s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->opaque_alloc;
274
275 par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
276 }
277#endif
271 278
272 par.ExtParam = s->ext_buffers;279 par.ExtParam = s->ext_buffers;
273 par.NumExtParam = s->num_ext_buffers;280 par.NumExtParam = s->num_ext_buffers;
libavfilter/vf_scale_qsv.c+41−33
@@ -89,7 +89,9 @@ typedef struct QSVScaleContext { · 88 unmodified lines
89 mfxFrameSurface1 **surface_ptrs_out;89 mfxFrameSurface1 **surface_ptrs_out;
90 int nb_surface_ptrs_out;90 int nb_surface_ptrs_out;
91 91
92#if QSV_HAVE_OPAQUE
92 mfxExtOpaqueSurfaceAlloc opaque_alloc;93 mfxExtOpaqueSurfaceAlloc opaque_alloc;
94#endif
93 95
94 mfxExtVPPScaling scale_conf;96 mfxExtVPPScaling scale_conf;
95 int mode;97 int mode;
@@ -268,7 +270,7 @@ static int init_out_session(AVFilterContext *ctx) · 172 unmodified lines
268 AVQSVFramesContext *out_frames_hwctx = out_frames_ctx->hwctx;270 AVQSVFramesContext *out_frames_hwctx = out_frames_ctx->hwctx;
269 AVQSVDeviceContext *device_hwctx = in_frames_ctx->device_ctx->hwctx;271 AVQSVDeviceContext *device_hwctx = in_frames_ctx->device_ctx->hwctx;
270 272
271 int opaque = !!(in_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME);273 int opaque = 0;
272 274
273 mfxHDL handle = NULL;275 mfxHDL handle = NULL;
274 mfxHandleType handle_type;276 mfxHandleType handle_type;
@@ -278,6 +280,9 @@ static int init_out_session(AVFilterContext *ctx) · 3 unmodified lines
278 mfxStatus err;280 mfxStatus err;
279 int i;281 int i;
280 282
283#if QSV_HAVE_OPAQUE
284 opaque = !!(in_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME);
285#endif
281 s->num_ext_buf = 0;286 s->num_ext_buf = 0;
282 287
283 /* extract the properties of the "master" session given to us */288 /* extract the properties of the "master" session given to us */
@@ -330,38 +335,7 @@ static int init_out_session(AVFilterContext *ctx) · 46 unmodified lines
330 335
331 memset(&par, 0, sizeof(par));336 memset(&par, 0, sizeof(par));
332 337
333 if (opaque) {338 if (!opaque) {
334 s->surface_ptrs_in = av_calloc(in_frames_hwctx->nb_surfaces,
335 sizeof(*s->surface_ptrs_in));
336 if (!s->surface_ptrs_in)
337 return AVERROR(ENOMEM);
338 for (i = 0; i < in_frames_hwctx->nb_surfaces; i++)
339 s->surface_ptrs_in[i] = in_frames_hwctx->surfaces + i;
340 s->nb_surface_ptrs_in = in_frames_hwctx->nb_surfaces;
341
342 s->surface_ptrs_out = av_calloc(out_frames_hwctx->nb_surfaces,
343 sizeof(*s->surface_ptrs_out));
344 if (!s->surface_ptrs_out)
345 return AVERROR(ENOMEM);
346 for (i = 0; i < out_frames_hwctx->nb_surfaces; i++)
347 s->surface_ptrs_out[i] = out_frames_hwctx->surfaces + i;
348 s->nb_surface_ptrs_out = out_frames_hwctx->nb_surfaces;
349
350 s->opaque_alloc.In.Surfaces = s->surface_ptrs_in;
351 s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs_in;
352 s->opaque_alloc.In.Type = in_frames_hwctx->frame_type;
353
354 s->opaque_alloc.Out.Surfaces = s->surface_ptrs_out;
355 s->opaque_alloc.Out.NumSurface = s->nb_surface_ptrs_out;
356 s->opaque_alloc.Out.Type = out_frames_hwctx->frame_type;
357
358 s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
359 s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc);
360
361 s->ext_buffers[s->num_ext_buf++] = (mfxExtBuffer*)&s->opaque_alloc;
362
363 par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
364 } else {
365 mfxFrameAllocator frame_allocator = {339 mfxFrameAllocator frame_allocator = {
366 .pthis = ctx,340 .pthis = ctx,
367 .Alloc = frame_alloc,341 .Alloc = frame_alloc,
@@ -393,6 +367,40 @@ static int init_out_session(AVFilterContext *ctx) · 25 unmodified lines
393 367
394 par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY;368 par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY;
395 }369 }
370#if QSV_HAVE_OPAQUE
371 else {
372 s->surface_ptrs_in = av_calloc(in_frames_hwctx->nb_surfaces,
373 sizeof(*s->surface_ptrs_in));
374 if (!s->surface_ptrs_in)
375 return AVERROR(ENOMEM);
376 for (i = 0; i < in_frames_hwctx->nb_surfaces; i++)
377 s->surface_ptrs_in[i] = in_frames_hwctx->surfaces + i;
378 s->nb_surface_ptrs_in = in_frames_hwctx->nb_surfaces;
379
380 s->surface_ptrs_out = av_calloc(out_frames_hwctx->nb_surfaces,
381 sizeof(*s->surface_ptrs_out));
382 if (!s->surface_ptrs_out)
383 return AVERROR(ENOMEM);
384 for (i = 0; i < out_frames_hwctx->nb_surfaces; i++)
385 s->surface_ptrs_out[i] = out_frames_hwctx->surfaces + i;
386 s->nb_surface_ptrs_out = out_frames_hwctx->nb_surfaces;
387
388 s->opaque_alloc.In.Surfaces = s->surface_ptrs_in;
389 s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs_in;
390 s->opaque_alloc.In.Type = in_frames_hwctx->frame_type;
391
392 s->opaque_alloc.Out.Surfaces = s->surface_ptrs_out;
393 s->opaque_alloc.Out.NumSurface = s->nb_surface_ptrs_out;
394 s->opaque_alloc.Out.Type = out_frames_hwctx->frame_type;
395
396 s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
397 s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc);
398
399 s->ext_buffers[s->num_ext_buf++] = (mfxExtBuffer*)&s->opaque_alloc;
400
401 par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
402 }
403#endif
396 404
397 memset(&s->scale_conf, 0, sizeof(mfxExtVPPScaling));405 memset(&s->scale_conf, 0, sizeof(mfxExtVPPScaling));
398 s->scale_conf.Header.BufferId = MFX_EXTBUFF_VPP_SCALING;406 s->scale_conf.Header.BufferId = MFX_EXTBUFF_VPP_SCALING;
libavutil/hwcontext_qsv.c+41−15
@@ -55,6 +55,8 @@ · 54 unmodified lines
55 MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))55 MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
56 56
57#define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl))57#define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl))
58#define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0)
59#define QSV_HAVE_OPAQUE !QSV_ONEVPL
58 60
59typedef struct QSVDevicePriv {61typedef struct QSVDevicePriv {
60 AVBufferRef *child_device_ctx;62 AVBufferRef *child_device_ctx;
@@ -86,11 +88,13 @@ typedef struct QSVFramesContext { · 25 unmodified lines
86 88
87 // used in the frame allocator for non-opaque surfaces89 // used in the frame allocator for non-opaque surfaces
88 mfxMemId *mem_ids;90 mfxMemId *mem_ids;
91#if QSV_HAVE_OPAQUE
89 // used in the opaque alloc request for opaque surfaces92 // used in the opaque alloc request for opaque surfaces
90 mfxFrameSurface1 **surface_ptrs;93 mfxFrameSurface1 **surface_ptrs;
91 94
92 mfxExtOpaqueSurfaceAlloc opaque_alloc;95 mfxExtOpaqueSurfaceAlloc opaque_alloc;
93 mfxExtBuffer *ext_buffers[1];96 mfxExtBuffer *ext_buffers[1];
97#endif
94 AVFrame realigned_upload_frame;98 AVFrame realigned_upload_frame;
95 AVFrame realigned_download_frame;99 AVFrame realigned_download_frame;
96} QSVFramesContext;100} QSVFramesContext;
@@ -299,7 +303,9 @@ static void qsv_frames_uninit(AVHWFramesContext *ctx) · 202 unmodified lines
299#endif303#endif
300 304
301 av_freep(&s->mem_ids);305 av_freep(&s->mem_ids);
306#if QSV_HAVE_OPAQUE
302 av_freep(&s->surface_ptrs);307 av_freep(&s->surface_ptrs);
308#endif
303 av_freep(&s->surfaces_internal);309 av_freep(&s->surfaces_internal);
304 av_freep(&s->handle_pairs_internal);310 av_freep(&s->handle_pairs_internal);
305 av_frame_unref(&s->realigned_upload_frame);311 av_frame_unref(&s->realigned_upload_frame);
@@ -535,11 +541,17 @@ static int qsv_init_pool(AVHWFramesContext *ctx, uint32_t fourcc) · 229 unmodified lines
535 return ret;541 return ret;
536 }542 }
537 543
544#if QSV_HAVE_OPAQUE
538 if (!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME)) {545 if (!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME)) {
539 ret = qsv_init_child_ctx(ctx);546 ret = qsv_init_child_ctx(ctx);
540 if (ret < 0)547 if (ret < 0)
541 return ret;548 return ret;
542 }549 }
550#else
551 ret = qsv_init_child_ctx(ctx);
552 if (ret < 0)
553 return ret;
554#endif
543 555
544 ctx->internal->pool_internal = av_buffer_pool_init2(sizeof(mfxFrameSurface1),556 ctx->internal->pool_internal = av_buffer_pool_init2(sizeof(mfxFrameSurface1),
545 ctx, qsv_pool_alloc, NULL);557 ctx, qsv_pool_alloc, NULL);
@@ -610,10 +622,9 @@ static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl) · 64 unmodified lines
610static int qsv_init_internal_session(AVHWFramesContext *ctx,622static int qsv_init_internal_session(AVHWFramesContext *ctx,
611 mfxSession *session, int upload)623 mfxSession *session, int upload)
612{624{
613 QSVFramesContext *s = ctx->internal->priv;
614 AVQSVFramesContext *frames_hwctx = ctx->hwctx;625 AVQSVFramesContext *frames_hwctx = ctx->hwctx;
615 QSVDeviceContext *device_priv = ctx->device_ctx->internal->priv;626 QSVDeviceContext *device_priv = ctx->device_ctx->internal->priv;
616 int opaque = !!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME);627 int opaque = 0;
617 628
618 mfxFrameAllocator frame_allocator = {629 mfxFrameAllocator frame_allocator = {
619 .pthis = ctx,630 .pthis = ctx,
@@ -627,6 +638,11 @@ static int qsv_init_internal_session(AVHWFramesContext *ctx, · 7 unmodified lines
627 mfxVideoParam par;638 mfxVideoParam par;
628 mfxStatus err;639 mfxStatus err;
629 640
641#if QSV_HAVE_OPAQUE
642 QSVFramesContext *s = ctx->internal->priv;
643 opaque = !!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME);
644#endif
645
630 err = MFXInit(device_priv->impl, &device_priv->ver, session);646 err = MFXInit(device_priv->impl, &device_priv->ver, session);
631 if (err != MFX_ERR_NONE) {647 if (err != MFX_ERR_NONE) {
632 av_log(ctx, AV_LOG_ERROR, "Error initializing an internal session\n");648 av_log(ctx, AV_LOG_ERROR, "Error initializing an internal session\n");
@@ -648,15 +664,18 @@ static int qsv_init_internal_session(AVHWFramesContext *ctx, · 15 unmodified lines
648 664
649 memset(&par, 0, sizeof(par));665 memset(&par, 0, sizeof(par));
650 666
651 if (opaque) {667 if (!opaque) {
668 par.IOPattern = upload ? MFX_IOPATTERN_OUT_VIDEO_MEMORY :
669 MFX_IOPATTERN_IN_VIDEO_MEMORY;
670 }
671#if QSV_HAVE_OPAQUE
672 else {
652 par.ExtParam = s->ext_buffers;673 par.ExtParam = s->ext_buffers;
653 par.NumExtParam = FF_ARRAY_ELEMS(s->ext_buffers);674 par.NumExtParam = FF_ARRAY_ELEMS(s->ext_buffers);
654 par.IOPattern = upload ? MFX_IOPATTERN_OUT_OPAQUE_MEMORY :675 par.IOPattern = upload ? MFX_IOPATTERN_OUT_OPAQUE_MEMORY :
655 MFX_IOPATTERN_IN_OPAQUE_MEMORY;676 MFX_IOPATTERN_IN_OPAQUE_MEMORY;
656 } else {
657 par.IOPattern = upload ? MFX_IOPATTERN_OUT_VIDEO_MEMORY :
658 MFX_IOPATTERN_IN_VIDEO_MEMORY;
659 }677 }
678#endif
660 679
661 par.IOPattern |= upload ? MFX_IOPATTERN_IN_SYSTEM_MEMORY :680 par.IOPattern |= upload ? MFX_IOPATTERN_IN_SYSTEM_MEMORY :
662 MFX_IOPATTERN_OUT_SYSTEM_MEMORY;681 MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
@@ -688,11 +707,15 @@ static int qsv_frames_init(AVHWFramesContext *ctx) · 25 unmodified lines
688 QSVFramesContext *s = ctx->internal->priv;707 QSVFramesContext *s = ctx->internal->priv;
689 AVQSVFramesContext *frames_hwctx = ctx->hwctx;708 AVQSVFramesContext *frames_hwctx = ctx->hwctx;
690 709
691 int opaque = !!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME);710 int opaque = 0;
692 711
693 uint32_t fourcc;712 uint32_t fourcc;
694 int i, ret;713 int i, ret;
695 714
715#if QSV_HAVE_OPAQUE
716 opaque = !!(frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME);
717#endif
718
696 fourcc = qsv_fourcc_from_pix_fmt(ctx->sw_format);719 fourcc = qsv_fourcc_from_pix_fmt(ctx->sw_format);
697 if (!fourcc) {720 if (!fourcc) {
698 av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format\n");721 av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format\n");
@@ -707,7 +730,16 @@ static int qsv_frames_init(AVHWFramesContext *ctx) · 8 unmodified lines
707 }730 }
708 }731 }
709 732
710 if (opaque) {733 if (!opaque) {
734 s->mem_ids = av_calloc(frames_hwctx->nb_surfaces, sizeof(*s->mem_ids));
735 if (!s->mem_ids)
736 return AVERROR(ENOMEM);
737
738 for (i = 0; i < frames_hwctx->nb_surfaces; i++)
739 s->mem_ids[i] = frames_hwctx->surfaces[i].Data.MemId;
740 }
741#if QSV_HAVE_OPAQUE
742 else {
711 s->surface_ptrs = av_calloc(frames_hwctx->nb_surfaces,743 s->surface_ptrs = av_calloc(frames_hwctx->nb_surfaces,
712 sizeof(*s->surface_ptrs));744 sizeof(*s->surface_ptrs));
713 if (!s->surface_ptrs)745 if (!s->surface_ptrs)
@@ -726,14 +758,8 @@ static int qsv_frames_init(AVHWFramesContext *ctx) · 12 unmodified lines
726 s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc);758 s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc);
727 759
728 s->ext_buffers[0] = (mfxExtBuffer*)&s->opaque_alloc;760 s->ext_buffers[0] = (mfxExtBuffer*)&s->opaque_alloc;
729 } else {
730 s->mem_ids = av_calloc(frames_hwctx->nb_surfaces, sizeof(*s->mem_ids));
731 if (!s->mem_ids)
732 return AVERROR(ENOMEM);
733
734 for (i = 0; i < frames_hwctx->nb_surfaces; i++)
735 s->mem_ids[i] = frames_hwctx->surfaces[i].Data.MemId;
736 }761 }
762#endif
737 763
738 s->session_download = NULL;764 s->session_download = NULL;
739 s->session_upload = NULL;765 s->session_upload = NULL;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t