[FFmpeg-devel] [PATCH] avformat/matroskaenc: return error if aac extradata changes

Nicolas George george at nsup.org
Sat May 2 18:02:25 EEST 2020


John Stebbins (12020-05-02):
> extradata changing would result in an invalid stream.
> also, as the code was written, rewriting extradata was corrupting the
> track header resulting in an invalid file.

Invalid and undecodable.

> ---
>  libavformat/matroskaenc.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index 784973a951..d6932bdb5b 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -2183,6 +2183,14 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt)
>      case AV_CODEC_ID_AAC:
>          if (side_data_size && (s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live) {
>              int filler, output_sample_rate = 0;
> +            if (par->extradata && par->extradata_size)
> +                if (par->extradata_size != side_data_size ||
> +                    memcmp(par->extradata, side_data, side_data_size)) {
> +                    av_log(s, AV_LOG_ERROR, "Error, AAC extradata changed mid-stream.\n");
> +                    return AVERROR_INPUT_CHANGED;
> +                } else // Already written
> +                    break;
> +

Style nit: do not omit braces on else when the if has them; do not omit
braces on the outer if when the inner if has them. Just my taste and
what I observed in the rest of the code.

>              ret = get_aac_sample_rates(s, side_data, side_data_size, &track->sample_rate,
>                                         &output_sample_rate);
>              if (ret < 0)

Thanks, I think it does the right thing.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200502/2dce5e60/attachment.sig>


More information about the ffmpeg-devel mailing list