[FFmpeg-devel] [PATCH] avformat/oggparseogm: sync avctx w/ codecpar

James Almer jamrial at gmail.com
Thu Feb 7 03:57:57 EET 2019


On 2/6/2019 10:13 PM, chcunningham wrote:
> Codec information may change while reading ogg packets. Update the
> stream's internal avctx to match.
> ---
>  libavformat/oggparseogm.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavformat/oggparseogm.c b/libavformat/oggparseogm.c
> index a07453760b..b07a5d55ba 100644
> --- a/libavformat/oggparseogm.c
> +++ b/libavformat/oggparseogm.c
> @@ -114,6 +114,9 @@ ogm_header(AVFormatContext *s, int idx)
>                  bytestream2_get_buffer(&p, st->codecpar->extradata, st->codecpar->extradata_size);
>              }
>          }
> +
> +        // Update internal avctx with changes to codecpar above.
> +        st->internal->need_context_update = 1;
>      } else if (bytestream2_peek_byte(&p) == 3) {
>          bytestream2_skip(&p, 7);
>          if (bytestream2_get_bytes_left(&p) > 1)

Can a valid ogm stream contain more than one header packet? Because the
issue here as far as i can see is that ogm_header() is not validating
the output of ff_codec_get_id() and is happily accepting and propagating
AV_CODEC_ID_NONE as derived from it in a late packet, long after the
parser and everything else was already initialized.

No other ogg module sets st->internal->need_context_update and all of
them may also end up calling the respective header reading function more
than once on invalid files, but unlike the ogm one, all of them hardcode
the codec_id instead of blindly accepting a potentially bogus value
derived from the bitstream.


More information about the ffmpeg-devel mailing list