Browse code

vaapi_encode: Add support for writing arbitrary additional packed headers

Mark Thompson authored on 2016/04/10 00:48:27
Showing 2 changed files
... ...
@@ -293,6 +293,27 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
293 293
         }
294 294
     }
295 295
 
296
+    if (ctx->codec->write_extra_header) {
297
+        for (i = 0;; i++) {
298
+            int type;
299
+            bit_len = 8 * sizeof(data);
300
+            err = ctx->codec->write_extra_header(avctx, pic, i, &type,
301
+                                                 data, &bit_len);
302
+            if (err == AVERROR_EOF)
303
+                break;
304
+            if (err < 0) {
305
+                av_log(avctx, AV_LOG_ERROR, "Failed to write extra "
306
+                       "header %d: %d.\n", i, err);
307
+                goto fail;
308
+            }
309
+
310
+            err = vaapi_encode_make_packed_header(avctx, pic, type,
311
+                                                  data, bit_len);
312
+            if (err < 0)
313
+                goto fail;
314
+        }
315
+    }
316
+
296 317
     av_assert0(pic->nb_slices <= MAX_PICTURE_SLICES);
297 318
     for (i = 0; i < pic->nb_slices; i++) {
298 319
         slice = av_mallocz(sizeof(*slice));
... ...
@@ -215,6 +215,10 @@ typedef struct VAAPIEncodeType {
215 215
                                  VAAPIEncodePicture *pic,
216 216
                                  int index, int *type,
217 217
                                  char *data, size_t *data_len);
218
+    int    (*write_extra_header)(AVCodecContext *avctx,
219
+                                 VAAPIEncodePicture *pic,
220
+                                 int index, int *type,
221
+                                 char *data, size_t *data_len);
218 222
 } VAAPIEncodeType;
219 223
 
220 224