[vlc-commits] avcodec: va: get the output video format from the VA module

Steve Lhomme git at videolan.org
Mon Nov 4 12:14:57 CET 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Jul 22 13:25:39 2019 +0200| [9c5c6d212fc60e887579357f86d50537d512c2d3] | committer: Steve Lhomme

avcodec: va: get the output video format from the VA module

Fill the proper i_width/i_height corresponding to the padded decoder surfaces.

We don't need to pass the lavc pixel format anymore

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9c5c6d212fc60e887579357f86d50537d512c2d3
---

 modules/codec/avcodec/d3d11va.c    | 17 +++++++++--------
 modules/codec/avcodec/directx_va.c |  1 -
 modules/codec/avcodec/dxva2.c      | 17 +++++++++--------
 modules/codec/avcodec/va.c         | 11 ++++++-----
 modules/codec/avcodec/va.h         |  8 ++++----
 modules/codec/avcodec/vaapi.c      |  6 +++---
 modules/codec/avcodec/video.c      |  6 +++---
 modules/hw/vdpau/avcodec.c         |  7 ++++---
 8 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 1297068c82..87e427958e 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -61,8 +61,8 @@ struct d3d11va_pic_context
 
 #include "directx_va.h"
 
-static int Open(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *, enum PixelFormat,
-                const es_format_t *, vlc_decoder_device *, vlc_video_context **);
+static int Open(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *,
+                const es_format_t *, vlc_decoder_device *, video_format_t *, vlc_video_context **);
 
 vlc_module_begin()
     set_description(N_("Direct3D11 Video Acceleration"))
@@ -250,15 +250,15 @@ static void Close(vlc_va_t *va)
 static const struct vlc_va_operations ops = { Get, Close, };
 
 static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,
-                enum PixelFormat pix_fmt,
                 const es_format_t *fmt_in, vlc_decoder_device *dec_device,
-                vlc_video_context **vtcx_out)
+                video_format_t *fmt_out, vlc_video_context **vtcx_out)
 {
     int err = VLC_EGENERIC;
 
     ctx->hwaccel_context = NULL;
 
-    if (pix_fmt != AV_PIX_FMT_D3D11VA_VLD)
+    if ( fmt_out->i_chroma != VLC_CODEC_D3D11_OPAQUE &&
+         fmt_out->i_chroma != VLC_CODEC_D3D11_OPAQUE_10B )
         return VLC_EGENERIC;
 
     d3d11_decoder_device_t *d3d11_device = GetD3D11OpaqueDevice( dec_device );
@@ -320,17 +320,17 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *des
         goto error;
     }
 
-    video_format_t fmt_out;
+    video_format_t final_fmt = *fmt_out;
     static const directx_sys_t dx_sys = { DxGetInputList, DxSetupOutput };
     sys->selected_decoder = directx_va_Setup(va, &dx_sys, ctx, desc, fmt_in, isXboxHardware(sys->d3d_dev.d3ddevice),
-                                             &fmt_out, &sys->hw.surface_count);
+                                             &final_fmt, &sys->hw.surface_count);
     if (sys->selected_decoder == NULL)
     {
         err = VLC_EGENERIC;
         goto error;
     }
 
-    err = va_pool_SetupDecoder(va, sys->va_pool, ctx, &fmt_out, sys->hw.surface_count);
+    err = va_pool_SetupDecoder(va, sys->va_pool, ctx, &final_fmt, sys->hw.surface_count);
     if (err != VLC_SUCCESS)
         goto error;
 
@@ -351,6 +351,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *des
     ID3D11DeviceContext_Release(priv->device);
 
     va->ops = &ops;
+    *fmt_out = final_fmt;
     *vtcx_out = sys->vctx;
     return VLC_SUCCESS;
 
diff --git a/modules/codec/avcodec/directx_va.c b/modules/codec/avcodec/directx_va.c
index 61ad7f7986..d7a1e7edea 100644
--- a/modules/codec/avcodec/directx_va.c
+++ b/modules/codec/avcodec/directx_va.c
@@ -335,7 +335,6 @@ const directx_va_mode_t *directx_va_Setup(vlc_va_t *va, const directx_sys_t *dx_
                   surface_width, surface_height,
                   avctx->coded_width, avctx->coded_height);
 
-    *fmt_out = fmt->video;
     fmt_out->i_width  = surface_width;
     fmt_out->i_height = surface_height;
 
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 4a802ef13e..15ec799063 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -48,8 +48,8 @@ struct dxva2_pic_context
 
 #include "directx_va.h"
 
-static int Open(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *, enum PixelFormat,
-                const es_format_t *, vlc_decoder_device *, vlc_video_context **);
+static int Open(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *,
+                const es_format_t *, vlc_decoder_device *, video_format_t *, vlc_video_context **);
 
 vlc_module_begin()
     set_description(N_("DirectX Video Acceleration (DXVA) 2.0"))
@@ -248,13 +248,13 @@ static void Close(vlc_va_t *va)
 static const struct vlc_va_operations ops = { Get, Close, };
 
 static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,
-                enum PixelFormat pix_fmt,
                 const es_format_t *fmt_in, vlc_decoder_device *dec_device,
-                vlc_video_context **vtcx_out)
+                video_format_t *fmt_out, vlc_video_context **vtcx_out)
 {
     int err = VLC_EGENERIC;
 
-    if (pix_fmt != AV_PIX_FMT_DXVA2_VLD)
+    if ( fmt_out->i_chroma != VLC_CODEC_D3D9_OPAQUE &&
+         fmt_out->i_chroma != VLC_CODEC_D3D9_OPAQUE_10B )
         return VLC_EGENERIC;
 
     d3d9_decoder_device_t *d3d9_decoder = GetD3D9OpaqueDevice( dec_device );
@@ -317,17 +317,17 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *des
         goto error;
     }
 
-    video_format_t fmt_out;
+    video_format_t final_fmt = *fmt_out;
     static const directx_sys_t dx_sys = { DxGetInputList, DxSetupOutput };
     sys->selected_decoder = directx_va_Setup(va, &dx_sys, ctx, desc, fmt_in, 0,
-                                             &fmt_out, &sys->hw.surface_count);
+                                             &final_fmt, &sys->hw.surface_count);
     if (sys->selected_decoder == NULL)
     {
         err = VLC_EGENERIC;
         goto error;
     }
 
-    err = va_pool_SetupDecoder(va, sys->va_pool, ctx, &fmt_out, sys->hw.surface_count);
+    err = va_pool_SetupDecoder(va, sys->va_pool, ctx, &final_fmt, sys->hw.surface_count);
     if (err != VLC_SUCCESS)
         goto error;
 
@@ -342,6 +342,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *des
     octx->format = sys->render;
 
     va->ops = &ops;
+    *fmt_out = final_fmt;
     *vtcx_out = sys->vctx;
     return VLC_SUCCESS;
 
diff --git a/modules/codec/avcodec/va.c b/modules/codec/avcodec/va.c
index e500544fe0..fc3ef3fe8a 100644
--- a/modules/codec/avcodec/va.c
+++ b/modules/codec/avcodec/va.c
@@ -100,20 +100,20 @@ static int vlc_va_Start(void *func, bool forced, va_list ap)
     vlc_va_t *va = va_arg(ap, vlc_va_t *);
     AVCodecContext *ctx = va_arg(ap, AVCodecContext *);
     const AVPixFmtDescriptor *src_desc = va_arg(ap, const AVPixFmtDescriptor *);
-    enum PixelFormat pix_fmt = va_arg(ap, enum PixelFormat);
     const es_format_t *fmt_in = va_arg(ap, const es_format_t *);
     vlc_decoder_device *device = va_arg(ap, vlc_decoder_device *);
+    video_format_t *fmt_out = va_arg(ap, video_format_t *);
     vlc_video_context **vtcx_out = va_arg(ap, vlc_video_context **);
     vlc_va_open open = func;
 
     (void) forced;
-    return open(va, ctx, src_desc, pix_fmt, fmt_in, device, vtcx_out);
+    return open(va, ctx, src_desc, fmt_in, device, fmt_out, vtcx_out);
 }
 
 vlc_va_t *vlc_va_New(vlc_object_t *obj,
                      AVCodecContext *avctx, const AVPixFmtDescriptor *src_desc,
-                     enum PixelFormat pix_fmt, const es_format_t *fmt,
-                     vlc_decoder_device *device, vlc_video_context **vtcx_out)
+                     const es_format_t *fmt_in, vlc_decoder_device *device,
+                     video_format_t *fmt_out, vlc_video_context **vtcx_out)
 {
     struct vlc_va_t *va = vlc_object_create(obj, sizeof (*va));
     if (unlikely(va == NULL))
@@ -121,7 +121,8 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj,
 
 
     if (vlc_module_load(va, "hw decoder", NULL, true,
-                        vlc_va_Start, va, avctx, src_desc, pix_fmt, fmt, device, vtcx_out) == NULL)
+                        vlc_va_Start, va, avctx, src_desc, fmt_in, device,
+                        fmt_out, vtcx_out) == NULL)
     {
         vlc_object_delete(va);
         va = NULL;
diff --git a/modules/codec/avcodec/va.h b/modules/codec/avcodec/va.h
index b10cab7e0b..95d1303f68 100644
--- a/modules/codec/avcodec/va.h
+++ b/modules/codec/avcodec/va.h
@@ -44,8 +44,8 @@ struct vlc_va_t {
 };
 
 typedef int (*vlc_va_open)(vlc_va_t *, AVCodecContext *, const AVPixFmtDescriptor *,
-                           enum PixelFormat,
-                           const es_format_t *, vlc_decoder_device *, vlc_video_context **);
+                           const es_format_t *, vlc_decoder_device *,
+                           video_format_t *, vlc_video_context **);
 
 #define set_va_callback(activate, priority) \
     { \
@@ -71,8 +71,8 @@ vlc_fourcc_t vlc_va_GetChroma(enum PixelFormat hwfmt, enum PixelFormat swfmt);
  * @return a new VLC object on success, NULL on error.
  */
 vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *, const AVPixFmtDescriptor *,
-                     enum PixelFormat, const es_format_t *fmt,
-                     vlc_decoder_device *device, vlc_video_context **vtcx_out);
+                     const es_format_t *fmt, vlc_decoder_device *device,
+                     video_format_t *, vlc_video_context **vtcx_out);
 
 /**
  * Get a hardware video surface for a libavcodec frame.
diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index f058884ba6..daec9b4b4e 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -236,12 +236,12 @@ static void VAAPISetupAVCodecContext(void *opaque, AVCodecContext *avctx)
 }
 
 static int Create(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *desc,
-                  enum PixelFormat pix_fmt,
                   const es_format_t *fmt_in, vlc_decoder_device *dec_device,
-                  vlc_video_context **vtcx_out)
+                  video_format_t *fmt_out, vlc_video_context **vtcx_out)
 {
     VLC_UNUSED(desc);
-    if (pix_fmt != AV_PIX_FMT_VAAPI_VLD || dec_device == NULL ||
+    if ( (fmt_out->i_chroma != VLC_CODEC_VAAPI_420 &&
+          fmt_out->i_chroma != VLC_CODEC_VAAPI_420_10BPP) || dec_device == NULL ||
         dec_device->type != VLC_DECODER_DEVICE_VAAPI)
         return VLC_EGENERIC;
 
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 84bd9df84b..22a5ccec65 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1753,9 +1753,9 @@ no_reuse:
         vlc_mutex_unlock(&p_sys->lock);
 
         vlc_video_context *vctx_out;
-        vlc_va_t *va = vlc_va_New(VLC_OBJECT(p_dec), p_context, src_desc, hwfmt,
-                                  &p_dec->fmt_in,
-                                  init_device, &vctx_out);
+        vlc_va_t *va = vlc_va_New(VLC_OBJECT(p_dec), p_context, src_desc,
+                                  &p_dec->fmt_in, init_device,
+                                  &p_dec->fmt_out.video, &vctx_out);
         if (init_device)
             vlc_decoder_device_Release(init_device);
         vlc_mutex_lock(&p_sys->lock);
diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index dd4c754e3d..a4f1cf96d3 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -157,11 +157,12 @@ const struct vlc_video_context_operations vdpau_vctx_ops = {
 };
 
 static int Open(vlc_va_t *va, AVCodecContext *avctx, const AVPixFmtDescriptor *desc,
-                enum PixelFormat pix_fmt,
                 const es_format_t *fmt_in, vlc_decoder_device *dec_device,
-                vlc_video_context **vtcx_out)
+                video_format_t *fmt_out, vlc_video_context **vtcx_out)
 {
-    if (pix_fmt != AV_PIX_FMT_VDPAU|| dec_device == NULL ||
+    if ( ( fmt_out->i_chroma != VLC_CODEC_VDPAU_VIDEO_420 &&
+           fmt_out->i_chroma != VLC_CODEC_VDPAU_VIDEO_422 &&
+           fmt_out->i_chroma != VLC_CODEC_VDPAU_VIDEO_444 ) ||
         GetVDPAUOpaqueDevice(dec_device) == NULL)
         return VLC_EGENERIC;
 



More information about the vlc-commits mailing list