[5/5] vaapi_h265: Add main 10 encode support

Message ID abcb8e98-c393-952b-a891-c6aa727e620f@jkqxz.net
State Committed
Headers show

Commit Message

Mark Thompson Sept. 30, 2016, 5:02 p.m.
---
Tested on Kaby Lake.

Actually, in order to work with the current i965 driver va_rt_format needs to be set to VA_RT_FORMAT_YUV420 rather than VA_RT_FORMAT_YUV420_10BPP.  I believe this is a bug, and should be fixed on that side (mesa/gallium on AMD VCE supports Main10 decode with output to 8-bit surfaces, so the cases do need to be distinguished).

 libavcodec/vaapi_encode_h265.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Luca Barbato Sept. 30, 2016, 5:58 p.m. | #1
On 30/09/16 19:02, Mark Thompson wrote:
> ---
> Tested on Kaby Lake.
> 
> Actually, in order to work with the current i965 driver va_rt_format needs to be set to VA_RT_FORMAT_YUV420 rather than VA_RT_FORMAT_YUV420_10BPP.  I believe this is a bug, and should be fixed on that side (mesa/gallium on AMD VCE supports Main10 decode with output to 8-bit surfaces, so the cases do need to be distinguished).
> 
>  libavcodec/vaapi_encode_h265.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 

Sounds proper.

Patch

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index e41194b..78be834 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -803,8 +803,10 @@  static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)

         vseq->seq_fields.bits.chroma_format_idc = 1; // 4:2:0.
         vseq->seq_fields.bits.separate_colour_plane_flag = 0;
-        vseq->seq_fields.bits.bit_depth_luma_minus8 = 0; // 8-bit luma.
-        vseq->seq_fields.bits.bit_depth_chroma_minus8 = 0; // 8-bit chroma.
+        vseq->seq_fields.bits.bit_depth_luma_minus8 =
+            avctx->profile == FF_PROFILE_HEVC_MAIN_10 ? 2 : 0;
+        vseq->seq_fields.bits.bit_depth_chroma_minus8 =
+            avctx->profile == FF_PROFILE_HEVC_MAIN_10 ? 2 : 0;
         // Other misc flags all zero.

         // These have to come from the capabilities of the encoder.  We have
@@ -1231,11 +1233,12 @@  static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx)
     case FF_PROFILE_HEVC_MAIN:
     case FF_PROFILE_UNKNOWN:
         ctx->va_profile = VAProfileHEVCMain;
+        ctx->va_rt_format = VA_RT_FORMAT_YUV420;
         break;
     case FF_PROFILE_HEVC_MAIN_10:
-        av_log(avctx, AV_LOG_ERROR, "H.265 main 10-bit profile "
-               "is not supported.\n");
-        return AVERROR_PATCHWELCOME;
+        ctx->va_profile = VAProfileHEVCMain10;
+        ctx->va_rt_format = VA_RT_FORMAT_YUV420_10BPP;
+        break;
     default:
         av_log(avctx, AV_LOG_ERROR, "Unknown H.265 profile %d.\n",
                avctx->profile);
@@ -1243,9 +1246,6 @@  static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx)
     }
     ctx->va_entrypoint = VAEntrypointEncSlice;

-    // This will be dependent on profile when 10-bit is supported.
-    ctx->va_rt_format = VA_RT_FORMAT_YUV420;
-
     if (avctx->bit_rate > 0)
         ctx->va_rc_mode = VA_RC_CBR;
     else