aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthieu Bouron <matthieu.bouron@stupeflix.com>2016-06-28 12:25:27 +0200
committerMatthieu Bouron <matthieu.bouron@stupeflix.com>2016-06-29 11:00:42 +0200
commit8fd56690774b7e91ca248e049782db0028c8275e (patch)
treee6b9b962b4fa51224705a8fd420b8e32352f915a
parent25f0ea9ece79ddd11f333acde38849e8c46543f5 (diff)
downloadffmpeg-8fd56690774b7e91ca248e049782db0028c8275e.tar.gz
lavc/mediacodecdec_h264: add missing NAL headers to SPS/PPS buffers
Fixes a regression introduced by 0cd5e281df3f69c1ed8f2a72a5bcbf9691e1b5d5. (cherry picked from commit db0af7250a276700a349766c5412eb48ec630f0a)
-rw-r--r--libavcodec/mediacodecdec_h264.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/libavcodec/mediacodecdec_h264.c b/libavcodec/mediacodecdec_h264.c
index eb63ab5327..0664e4994e 100644
--- a/libavcodec/mediacodecdec_h264.c
+++ b/libavcodec/mediacodecdec_h264.c
@@ -112,8 +112,25 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
}
if (pps && sps) {
- ff_AMediaFormat_setBuffer(format, "csd-0", (void*)sps->data, sps->data_size);
- ff_AMediaFormat_setBuffer(format, "csd-1", (void*)pps->data, pps->data_size);
+ static const uint8_t nal_headers[] = { 0x00, 0x00, 0x00, 0x01 };
+
+ uint8_t *data = NULL;
+ size_t data_size = sizeof(nal_headers) + FFMAX(sps->data_size, pps->data_size);
+
+ data = av_mallocz(data_size);
+ if (!data) {
+ ret = AVERROR(ENOMEM);
+ goto done;
+ }
+
+ memcpy(data, nal_headers, sizeof(nal_headers));
+ memcpy(data + sizeof(nal_headers), sps->data, sps->data_size);
+ ff_AMediaFormat_setBuffer(format, "csd-0", (void*)data, sizeof(nal_headers) + sps->data_size);
+
+ memcpy(data + sizeof(nal_headers), pps->data, pps->data_size);
+ ff_AMediaFormat_setBuffer(format, "csd-1", (void*)data, sizeof(nal_headers) + pps->data_size);
+
+ av_freep(&data);
} else {
av_log(avctx, AV_LOG_ERROR, "Could not extract PPS/SPS from extradata");
ret = AVERROR_INVALIDDATA;