Hi! Attached patch fixes remuxing opus from sdp, reported by Juan Navarro.
Please comment, Carl Eugen
From 957e568e7dd1c2acc0ea29dad122919c8c9e05ce Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos <ceffm...@gmail.com> Date: Fri, 20 Sep 2019 00:29:16 +0200 Subject: [PATCH] lavc/opus: Create extradata if it is missing. Fixes streamcopying from sdp. Reported-by: Juan Navarro, juan dot navarro at gmx dot es --- libavcodec/opus.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libavcodec/opus.c b/libavcodec/opus.c index f74278a7e3..2f1045facb 100644 --- a/libavcodec/opus.c +++ b/libavcodec/opus.c @@ -307,12 +307,16 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx, "Multichannel configuration without extradata.\n"); return AVERROR(EINVAL); } - extradata = opus_default_extradata; - extradata_size = sizeof(opus_default_extradata); - } else { - extradata = avctx->extradata; - extradata_size = avctx->extradata_size; + avctx->extradata = av_malloc(sizeof(opus_default_extradata) + AV_INPUT_BUFFER_PADDING_SIZE); + if (!avctx->extradata) + return AVERROR(ENOMEM); + memcpy(avctx->extradata, opus_default_extradata, sizeof(opus_default_extradata)); + memset(avctx->extradata + sizeof(opus_default_extradata), 0, AV_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata_size = sizeof(opus_default_extradata); + avctx->extradata[9] = avctx->channels; } + extradata = avctx->extradata; + extradata_size = avctx->extradata_size; if (extradata_size < 19) { av_log(avctx, AV_LOG_ERROR, "Invalid extradata size: %d\n", @@ -330,7 +334,7 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx, if (avctx->internal) avctx->internal->skip_samples = avctx->delay; - channels = avctx->extradata ? extradata[9] : (avctx->channels == 1) ? 1 : 2; + channels = extradata[9]; if (!channels) { av_log(avctx, AV_LOG_ERROR, "Zero channel count specified in the extradata\n"); return AVERROR_INVALIDDATA; -- 2.23.0
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".