[FFmpeg-devel,2/2] avcodec/hevc: add the dimension constraints when attempting to use DXVA

Submitted by Steve Lhomme on March 22, 2017, 9:41 a.m.

Details

Message ID 20170322094137.8108-2-robux4@gmail.com
State New
Headers show

Commit Message

Steve Lhomme March 22, 2017, 9:41 a.m.
---
 libavcodec/hevc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Hendrik Leppkes March 22, 2017, 12:03 p.m.
On Wed, Mar 22, 2017 at 10:41 AM, Steve Lhomme <robux4@gmail.com> wrote:
> ---
>  libavcodec/hevc.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>

Just to mention it on this ML as well so it doesn't get applied due to
lack of comments - we're still discussing better alternatives for a
generic API to export hardware surface requirements, instead of
littering the actual decoder with this.

- Hendrik

Patch hide | download patch | download mbox

diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 505249e6b5..35e9a273fa 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -328,6 +328,14 @@  static void export_stream_params(AVCodecContext *avctx, const HEVCParamSets *ps,
                   num, den, 1 << 30);
 }
 
+#if CONFIG_HEVC_DXVA2_HWACCEL || CONFIG_HEVC_D3D11VA_HWACCEL
+static void add_dxva_constraints(AVCodecContext *avctx)
+{
+    avctx->coded_width  = FFALIGN(avctx->coded_width,  128);
+    avctx->coded_height = FFALIGN(avctx->coded_height, 128);
+}
+#endif
+
 static int set_sps(HEVCContext *s, const HEVCSPS *sps, enum AVPixelFormat pix_fmt)
 {
     #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + CONFIG_HEVC_D3D11VA_HWACCEL + CONFIG_HEVC_VAAPI_HWACCEL + CONFIG_HEVC_VDPAU_HWACCEL)
@@ -352,9 +360,11 @@  static int set_sps(HEVCContext *s, const HEVCSPS *sps, enum AVPixelFormat pix_fm
     case AV_PIX_FMT_YUVJ420P:
 #if CONFIG_HEVC_DXVA2_HWACCEL
         *fmt++ = AV_PIX_FMT_DXVA2_VLD;
+        add_dxva_constraints(s->avctx);
 #endif
 #if CONFIG_HEVC_D3D11VA_HWACCEL
         *fmt++ = AV_PIX_FMT_D3D11VA_VLD;
+        add_dxva_constraints(s->avctx);
 #endif
 #if CONFIG_HEVC_VAAPI_HWACCEL
         *fmt++ = AV_PIX_FMT_VAAPI;
@@ -366,9 +376,11 @@  static int set_sps(HEVCContext *s, const HEVCSPS *sps, enum AVPixelFormat pix_fm
     case AV_PIX_FMT_YUV420P10:
 #if CONFIG_HEVC_DXVA2_HWACCEL
         *fmt++ = AV_PIX_FMT_DXVA2_VLD;
+        add_dxva_constraints(s->avctx);
 #endif
 #if CONFIG_HEVC_D3D11VA_HWACCEL
         *fmt++ = AV_PIX_FMT_D3D11VA_VLD;
+        add_dxva_constraints(s->avctx);
 #endif
 #if CONFIG_HEVC_VAAPI_HWACCEL
         *fmt++ = AV_PIX_FMT_VAAPI;