+ avctx->extradata_size = 32;
+
+ avctx->extradata = av_mallocz(avctx->extradata_size +
+ AV_INPUT_BUFFER_PADDING_SIZE);
+
+ if (!avctx->extradata) {
+ av_log(avctx, AV_LOG_ERROR, "Could not allocate extradata.\n");
+ return AVERROR(ENOMEM);
+ }
+
+ bytestream2_init_writer(&pb, avctx->extradata, avctx->extradata_size);
+ bytestream2_put_le32(&pb, MKTAG('M', 'A', 'G', 'Y'));
+ bytestream2_put_le32(&pb, 32);
+ bytestream2_put_byte(&pb, 7);
+ bytestream2_put_byte(&pb, s->format);
+ bytestream2_put_byte(&pb, 12);
+ bytestream2_put_byte(&pb, 0);
+
+ bytestream2_put_byte(&pb, 0);
+ bytestream2_put_byte(&pb, 0);
+ bytestream2_put_byte(&pb, 32);
+ bytestream2_put_byte(&pb, 0);
+
+ bytestream2_put_le32(&pb, avctx->width);
+ bytestream2_put_le32(&pb, avctx->height);
+ bytestream2_put_le32(&pb, avctx->width);
+ bytestream2_put_le32(&pb, avctx->height);
+