[FFmpeg-devel,v2,10/11] vaapi_encode_h264: Don't include AUD with slice header

Submitted by Mark Thompson on Jan. 27, 2019, 11:47 p.m.

Details

Message ID 20190127234707.27689-10-sw@jkqxz.net
State New
Headers show

Commit Message

Mark Thompson Jan. 27, 2019, 11:47 p.m.
Always write it as a RawData block, even if there is no SEI as well.
---
 libavcodec/vaapi_encode_h264.c | 40 +++++++++++++++-------------------
 1 file changed, 17 insertions(+), 23 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index fb55eb7779..b65ee4bec0 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -187,13 +187,6 @@  static int vaapi_encode_h264_write_slice_header(AVCodecContext *avctx,
     CodedBitstreamFragment   *au = &priv->current_access_unit;
     int err;
 
-    if (priv->aud_needed) {
-        err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_aud);
-        if (err < 0)
-            goto fail;
-        priv->aud_needed = 0;
-    }
-
     err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_slice);
     if (err < 0)
         goto fail;
@@ -213,16 +206,16 @@  static int vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
     CodedBitstreamFragment   *au = &priv->current_access_unit;
     int err, i;
 
+    if (priv->aud_needed) {
+        err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_aud);
+        if (err < 0)
+            goto fail;
+        priv->aud_needed = 0;
+    }
+
     if (priv->sei_needed) {
         H264RawSEI *sei = &priv->raw_sei;
 
-        if (priv->aud_needed) {
-            err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_aud);
-            if (err < 0)
-                goto fail;
-            priv->aud_needed = 0;
-        }
-
         *sei = (H264RawSEI) {
             .nal_unit_header = {
                 .nal_unit_type = H264_NAL_SEI,
@@ -260,15 +253,6 @@  static int vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
             goto fail;
         priv->sei_needed = 0;
 
-        err = vaapi_encode_h264_write_access_unit(avctx, data, data_len, au);
-        if (err < 0)
-            goto fail;
-
-        ff_cbs_fragment_uninit(priv->cbc, au);
-
-        *type = VAEncPackedHeaderRawData;
-        return 0;
-
 #if !CONFIG_VAAPI_1
     } else if (priv->sei_cbr_workaround_needed) {
         // Insert a zero-length header using the old SEI type.  This is
@@ -285,6 +269,16 @@  static int vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
         return AVERROR_EOF;
     }
 
+
+    err = vaapi_encode_h264_write_access_unit(avctx, data, data_len, au);
+    if (err < 0)
+        goto fail;
+
+    ff_cbs_fragment_uninit(priv->cbc, au);
+
+    *type = VAEncPackedHeaderRawData;
+    return 0;
+
 fail:
     ff_cbs_fragment_uninit(priv->cbc, au);
     return err;