vaapi_encode: Add support for writing arbitrary additional packed headers
authorMark Thompson <sw@jkqxz.net>
Sat, 9 Apr 2016 15:48:27 +0000 (16:48 +0100)
committerMark Thompson <sw@jkqxz.net>
Thu, 9 Jun 2016 20:15:39 +0000 (21:15 +0100)
libavcodec/vaapi_encode.c
libavcodec/vaapi_encode.h

index 9da55c9..45f5e57 100644 (file)
@@ -293,6 +293,27 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
         }
     }
 
+    if (ctx->codec->write_extra_header) {
+        for (i = 0;; i++) {
+            int type;
+            bit_len = 8 * sizeof(data);
+            err = ctx->codec->write_extra_header(avctx, pic, i, &type,
+                                                 data, &bit_len);
+            if (err == AVERROR_EOF)
+                break;
+            if (err < 0) {
+                av_log(avctx, AV_LOG_ERROR, "Failed to write extra "
+                       "header %d: %d.\n", i, err);
+                goto fail;
+            }
+
+            err = vaapi_encode_make_packed_header(avctx, pic, type,
+                                                  data, bit_len);
+            if (err < 0)
+                goto fail;
+        }
+    }
+
     av_assert0(pic->nb_slices <= MAX_PICTURE_SLICES);
     for (i = 0; i < pic->nb_slices; i++) {
         slice = av_mallocz(sizeof(*slice));
index ec552da..85f3a0c 100644 (file)
@@ -215,6 +215,10 @@ typedef struct VAAPIEncodeType {
                                  VAAPIEncodePicture *pic,
                                  int index, int *type,
                                  char *data, size_t *data_len);
+    int    (*write_extra_header)(AVCodecContext *avctx,
+                                 VAAPIEncodePicture *pic,
+                                 int index, int *type,
+                                 char *data, size_t *data_len);
 } VAAPIEncodeType;