diff mbox series

[FFmpeg-devel,14/18] lavf: move AVStream.{need_parsing, parser} to AVStreamInternal

Message ID 20201009130430.602-14-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/18] lavf: move AVStream.info to AVStreamInternal | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Anton Khirnov Oct. 9, 2020, 1:04 p.m. UTC
Those are private fields, no reason to have them exposed in a public
header.
---
 libavdevice/v4l2.c           |   2 +-
 libavformat/aacdec.c         |   2 +-
 libavformat/aadec.c          |   6 +-
 libavformat/acm.c            |   2 +-
 libavformat/asfdec_f.c       |  10 ++--
 libavformat/av1dec.c         |   2 +-
 libavformat/avformat.h       |   6 +-
 libavformat/avidec.c         |  16 ++---
 libavformat/dtshddec.c       |   2 +-
 libavformat/electronicarts.c |   2 +-
 libavformat/flacdec.c        |   2 +-
 libavformat/flvdec.c         |   4 +-
 libavformat/gxf.c            |   6 +-
 libavformat/img2dec.c        |   4 +-
 libavformat/internal.h       |   4 ++
 libavformat/ipudec.c         |   2 +-
 libavformat/iv8.c            |   2 +-
 libavformat/ivfdec.c         |   2 +-
 libavformat/lmlm4.c          |   4 +-
 libavformat/loasdec.c        |   2 +-
 libavformat/lxfdec.c         |   2 +-
 libavformat/matroskadec.c    |   6 +-
 libavformat/mgsts.c          |   2 +-
 libavformat/mov.c            |  18 +++---
 libavformat/mp3dec.c         |   2 +-
 libavformat/mpeg.c           |   2 +-
 libavformat/mpegts.c         |  14 ++---
 libavformat/msf.c            |   2 +-
 libavformat/mtv.c            |   2 +-
 libavformat/mxfdec.c         |   8 +--
 libavformat/ncdec.c          |   2 +-
 libavformat/nsvdec.c         |   4 +-
 libavformat/nuv.c            |   2 +-
 libavformat/oggparseflac.c   |   2 +-
 libavformat/oggparseogm.c    |   4 +-
 libavformat/oggparsetheora.c |   2 +-
 libavformat/oggparsevp8.c    |   2 +-
 libavformat/omadec.c         |   2 +-
 libavformat/pva.c            |   4 +-
 libavformat/rawdec.c         |   4 +-
 libavformat/rmdec.c          |   8 +--
 libavformat/rtpdec_asf.c     |   4 +-
 libavformat/rtsp.c           |   2 +-
 libavformat/sdr2.c           |   2 +-
 libavformat/segafilm.c       |   2 +-
 libavformat/swfdec.c         |   2 +-
 libavformat/takdec.c         |   2 +-
 libavformat/ty.c             |   4 +-
 libavformat/utils.c          | 112 +++++++++++++++++------------------
 libavformat/wavdec.c         |   6 +-
 libavformat/wtvdec.c         |   2 +-
 libavformat/xvag.c           |   2 +-
 libavformat/xwma.c           |   2 +-
 53 files changed, 160 insertions(+), 158 deletions(-)

Comments

Andreas Rheinhardt Oct. 9, 2020, 2:36 p.m. UTC | #1
Anton Khirnov:
> Those are private fields, no reason to have them exposed in a public
> header.
> ---
>  libavdevice/v4l2.c           |   2 +-

This is a problem: There is no requirement to update libavdevice at the
same time as libavformat; one might use a newer version of libavformat
together with an older version of libavdevice. This effectively makes
the offsets of all the fields accessed by libavdevice avpriv, regardless
of whether they are in AVStream or AVStreamInternal.

>  libavformat/aacdec.c         |   2 +-
>  libavformat/aadec.c          |   6 +-
>  libavformat/acm.c            |   2 +-
>  libavformat/asfdec_f.c       |  10 ++--
>  libavformat/av1dec.c         |   2 +-
>  libavformat/avformat.h       |   6 +-
>  libavformat/avidec.c         |  16 ++---
>  libavformat/dtshddec.c       |   2 +-
>  libavformat/electronicarts.c |   2 +-
>  libavformat/flacdec.c        |   2 +-
>  libavformat/flvdec.c         |   4 +-
>  libavformat/gxf.c            |   6 +-
>  libavformat/img2dec.c        |   4 +-
>  libavformat/internal.h       |   4 ++
>  libavformat/ipudec.c         |   2 +-
>  libavformat/iv8.c            |   2 +-
>  libavformat/ivfdec.c         |   2 +-
>  libavformat/lmlm4.c          |   4 +-
>  libavformat/loasdec.c        |   2 +-
>  libavformat/lxfdec.c         |   2 +-
>  libavformat/matroskadec.c    |   6 +-
>  libavformat/mgsts.c          |   2 +-
>  libavformat/mov.c            |  18 +++---
>  libavformat/mp3dec.c         |   2 +-
>  libavformat/mpeg.c           |   2 +-
>  libavformat/mpegts.c         |  14 ++---
>  libavformat/msf.c            |   2 +-
>  libavformat/mtv.c            |   2 +-
>  libavformat/mxfdec.c         |   8 +--
>  libavformat/ncdec.c          |   2 +-
>  libavformat/nsvdec.c         |   4 +-
>  libavformat/nuv.c            |   2 +-
>  libavformat/oggparseflac.c   |   2 +-
>  libavformat/oggparseogm.c    |   4 +-
>  libavformat/oggparsetheora.c |   2 +-
>  libavformat/oggparsevp8.c    |   2 +-
>  libavformat/omadec.c         |   2 +-
>  libavformat/pva.c            |   4 +-
>  libavformat/rawdec.c         |   4 +-
>  libavformat/rmdec.c          |   8 +--
>  libavformat/rtpdec_asf.c     |   4 +-
>  libavformat/rtsp.c           |   2 +-
>  libavformat/sdr2.c           |   2 +-
>  libavformat/segafilm.c       |   2 +-
>  libavformat/swfdec.c         |   2 +-
>  libavformat/takdec.c         |   2 +-
>  libavformat/ty.c             |   4 +-
>  libavformat/utils.c          | 112 +++++++++++++++++------------------
>  libavformat/wavdec.c         |   6 +-
>  libavformat/wtvdec.c         |   2 +-
>  libavformat/xvag.c           |   2 +-
>  libavformat/xwma.c           |   2 +-
>  53 files changed, 160 insertions(+), 158 deletions(-)
> 
> diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
> index 365bacd771..960929aec3 100644
> --- a/libavdevice/v4l2.c
> +++ b/libavdevice/v4l2.c
> @@ -961,7 +961,7 @@ static int v4l2_read_header(AVFormatContext *ctx)
>          st->codecpar->codec_tag =
>              avcodec_pix_fmt_to_codec_tag(st->codecpar->format);
>      else if (codec_id == AV_CODEC_ID_H264) {
> -        st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
> +        st->internal->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
>      }
>      if (desired_format == V4L2_PIX_FMT_YVU420)
>          st->codecpar->codec_tag = MKTAG('Y', 'V', '1', '2');
> diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
> index a0aa112a8a..70427e222b 100644
> --- a/libavformat/aacdec.c
> +++ b/libavformat/aacdec.c
> @@ -112,7 +112,7 @@ static int adts_aac_read_header(AVFormatContext *s)
>  
>      st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>      st->codecpar->codec_id   = s->iformat->raw_codec_id;
> -    st->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
> +    st->internal->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
>  
>      ff_id3v1_read(s);
>      if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
> diff --git a/libavformat/aadec.c b/libavformat/aadec.c
> index 63f8176a57..7ada6ab07a 100644
> --- a/libavformat/aadec.c
> +++ b/libavformat/aadec.c
> @@ -182,7 +182,7 @@ static int aa_read_header(AVFormatContext *s)
>      if (!strcmp(codec_name, "mp332")) {
>          st->codecpar->codec_id = AV_CODEC_ID_MP3;
>          st->codecpar->sample_rate = 22050;
> -        st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
> +        st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
>          avpriv_set_pts_info(st, 64, 8, 32000 * TIMEPREC);
>          // encoded audio frame is MP3_FRAME_SIZE bytes (+1 with padding, unlikely)
>      } else if (!strcmp(codec_name, "acelp85")) {
> @@ -191,7 +191,7 @@ static int aa_read_header(AVFormatContext *s)
>          st->codecpar->channels = 1;
>          st->codecpar->sample_rate = 8500;
>          st->codecpar->bit_rate = 8500;
> -        st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
> +        st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
>          avpriv_set_pts_info(st, 64, 8, 8500 * TIMEPREC);
>      } else if (!strcmp(codec_name, "acelp16")) {
>          st->codecpar->codec_id = AV_CODEC_ID_SIPR;
> @@ -199,7 +199,7 @@ static int aa_read_header(AVFormatContext *s)
>          st->codecpar->channels = 1;
>          st->codecpar->sample_rate = 16000;
>          st->codecpar->bit_rate = 16000;
> -        st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
> +        st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
>          avpriv_set_pts_info(st, 64, 8, 16000 * TIMEPREC);
>      }
>  
> diff --git a/libavformat/acm.c b/libavformat/acm.c
> index 5e03cf8bff..91f14e43aa 100644
> --- a/libavformat/acm.c
> +++ b/libavformat/acm.c
> @@ -54,7 +54,7 @@ static int acm_read_header(AVFormatContext *s)
>          return AVERROR_INVALIDDATA;
>      st->start_time         = 0;
>      st->duration           = AV_RL32(st->codecpar->extradata +  4) / st->codecpar->channels;
> -    st->need_parsing       = AVSTREAM_PARSE_FULL_RAW;
> +    st->internal->need_parsing       = AVSTREAM_PARSE_FULL_RAW;
>      avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
>  
>      return 0;
> diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
> index deb7c266ed..402ccaac78 100644
> --- a/libavformat/asfdec_f.c
> +++ b/libavformat/asfdec_f.c
> @@ -483,9 +483,9 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
>              st->codecpar->codec_tag = 0;
>          }
>          if (st->codecpar->codec_id == AV_CODEC_ID_AAC)
> -            st->need_parsing = AVSTREAM_PARSE_NONE;
> +            st->internal->need_parsing = AVSTREAM_PARSE_NONE;
>          else
> -            st->need_parsing = AVSTREAM_PARSE_FULL;
> +            st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>          /* We have to init the frame size at some point .... */
>          pos2 = avio_tell(pb);
>          if (size >= (pos2 + 8 - pos1 + 24)) {
> @@ -542,7 +542,7 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
>          st->codecpar->codec_tag = tag1;
>          st->codecpar->codec_id  = ff_codec_get_id(ff_codec_bmp_tags, tag1);
>          if (tag1 == MKTAG('D', 'V', 'R', ' ')) {
> -            st->need_parsing = AVSTREAM_PARSE_FULL;
> +            st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>              /* issue658 contains wrong w/h and MS even puts a fake seq header
>               * with wrong w/h in extradata while a correct one is in the stream.
>               * maximum lameness */
> @@ -552,9 +552,9 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
>              st->codecpar->extradata_size = 0;
>          }
>          if (st->codecpar->codec_id == AV_CODEC_ID_H264)
> -            st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
> +            st->internal->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
>          if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4)
> -            st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
> +            st->internal->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
>      }
>      pos2 = avio_tell(pb);
>      avio_skip(pb, size - (pos2 - pos1 + 24));
> diff --git a/libavformat/av1dec.c b/libavformat/av1dec.c
> index 10c4560968..ad2837c831 100644
> --- a/libavformat/av1dec.c
> +++ b/libavformat/av1dec.c
> @@ -66,7 +66,7 @@ static int read_header(AVFormatContext *s, const AVRational *framerate, AVBSFCon
>  
>      st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>      st->codecpar->codec_id = AV_CODEC_ID_AV1;
> -    st->need_parsing = AVSTREAM_PARSE_HEADERS;
> +    st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
>  
>      st->internal->avctx->framerate = *framerate;
>      // taken from rawvideo demuxers
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index 9c0b25d37b..b1aab0c8ea 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -1053,12 +1053,10 @@ typedef struct AVStream {
>       */
>      int codec_info_nb_frames;
>  
> -    /* av_read_frame() support */
> -    enum AVStreamParseType need_parsing;

sizeof enum types is compiler-specific IIRC. Compilers may choose a type
smaller than int if all the constants fit into a smaller type. Could
this cause a problem here?

> -    struct AVCodecParserContext *parser;
> -
>  #if LIBAVFORMAT_VERSION_MAJOR < 59
>      // kept for ABI compatibility only, do not access in any way
> +    int          unused8;
> +    void        *unused9;
>      void        *unused7;
>      AVProbeData  unused6;
>      int64_t      unused5[16+1];
> diff --git a/libavformat/avidec.c b/libavformat/avidec.c
> index 80e5563bc6..bcea7f865e 100644
> --- a/libavformat/avidec.c
> +++ b/libavformat/avidec.c
> @@ -815,19 +815,19 @@ static int avi_read_header(AVFormatContext *s)
>  
>                      /* This is needed to get the pict type which is necessary
>                       * for generating correct pts. */
> -                    st->need_parsing = AVSTREAM_PARSE_HEADERS;
> +                    st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
>  
>                      if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4 &&
>                          ast->handler == MKTAG('X', 'V', 'I', 'D'))
>                          st->codecpar->codec_tag = MKTAG('X', 'V', 'I', 'D');
>  
>                      if (st->codecpar->codec_tag == MKTAG('V', 'S', 'S', 'H'))
> -                        st->need_parsing = AVSTREAM_PARSE_FULL;
> +                        st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>                      if (st->codecpar->codec_id == AV_CODEC_ID_RV40)
> -                        st->need_parsing = AVSTREAM_PARSE_NONE;
> +                        st->internal->need_parsing = AVSTREAM_PARSE_NONE;
>                      if (st->codecpar->codec_id == AV_CODEC_ID_HEVC &&
>                          st->codecpar->codec_tag == MKTAG('H', '2', '6', '5'))
> -                        st->need_parsing = AVSTREAM_PARSE_FULL;
> +                        st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>  
>                      if (st->codecpar->codec_tag == 0 && st->codecpar->height > 0 &&
>                          st->codecpar->extradata_size < 1U << 30) {
> @@ -865,16 +865,16 @@ static int avi_read_header(AVFormatContext *s)
>                          avio_skip(pb, 1);
>                      /* Force parsing as several audio frames can be in
>                       * one packet and timestamps refer to packet start. */
> -                    st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
> +                    st->internal->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
>                      /* ADTS header is in extradata, AAC without header must be
>                       * stored as exact frames. Parser not needed and it will
>                       * fail. */
>                      if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
>                          st->codecpar->extradata_size)
> -                        st->need_parsing = AVSTREAM_PARSE_NONE;
> +                        st->internal->need_parsing = AVSTREAM_PARSE_NONE;
>                      // The flac parser does not work with AVSTREAM_PARSE_TIMESTAMPS
>                      if (st->codecpar->codec_id == AV_CODEC_ID_FLAC)
> -                        st->need_parsing = AVSTREAM_PARSE_NONE;
> +                        st->internal->need_parsing = AVSTREAM_PARSE_NONE;
>                      /* AVI files with Xan DPCM audio (wrongly) declare PCM
>                       * audio in the header but have Axan as stream_code_tag. */
>                      if (ast->handler == AV_RL32("Axan")) {
> @@ -1029,7 +1029,7 @@ end_of_header:
>              AVStream *st = s->streams[i];
>              if (   st->codecpar->codec_id == AV_CODEC_ID_MPEG1VIDEO
>                  || st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO)
> -                st->need_parsing = AVSTREAM_PARSE_FULL;
> +                st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>          }
>  
>      for (i = 0; i < s->nb_streams; i++) {
> diff --git a/libavformat/dtshddec.c b/libavformat/dtshddec.c
> index b1eb7ffb2c..deb341cde9 100644
> --- a/libavformat/dtshddec.c
> +++ b/libavformat/dtshddec.c
> @@ -65,7 +65,7 @@ static int dtshd_read_header(AVFormatContext *s)
>          return AVERROR(ENOMEM);
>      st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>      st->codecpar->codec_id   = AV_CODEC_ID_DTS;
> -    st->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
> +    st->internal->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
>  
>      for (;;) {
>          chunk_type = avio_rb64(pb);
> diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c
> index d0f483aaf9..dcfd972f49 100644
> --- a/libavformat/electronicarts.c
> +++ b/libavformat/electronicarts.c
> @@ -503,7 +503,7 @@ static int init_video_stream(AVFormatContext *s, VideoProperties *video)
>      st->codecpar->codec_id    = video->codec;
>      // parsing is necessary to make FFmpeg generate correct timestamps
>      if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO)
> -        st->need_parsing = AVSTREAM_PARSE_HEADERS;
> +        st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
>      st->codecpar->codec_tag   = 0; /* no fourcc */
>      st->codecpar->width       = video->width;
>      st->codecpar->height      = video->height;
> diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
> index 6aca4755a1..e7a418a3b3 100644
> --- a/libavformat/flacdec.c
> +++ b/libavformat/flacdec.c
> @@ -56,7 +56,7 @@ static int flac_read_header(AVFormatContext *s)
>          return AVERROR(ENOMEM);
>      st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>      st->codecpar->codec_id = AV_CODEC_ID_FLAC;
> -    st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
> +    st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
>      /* the parameters will be extracted from the compressed bitstream */
>  
>      /* if fLaC marker is not found, assume there is no header */
> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index 6bddcbb556..30dd9cdcec 100644
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -269,7 +269,7 @@ static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream,
>          break;
>      case FLV_CODECID_MP3:
>          apar->codec_id      = AV_CODEC_ID_MP3;
> -        astream->need_parsing = AVSTREAM_PARSE_FULL;
> +        astream->internal->need_parsing = AVSTREAM_PARSE_FULL;
>          break;
>      case FLV_CODECID_NELLYMOSER_8KHZ_MONO:
>          // in case metadata does not otherwise declare samplerate
> @@ -360,7 +360,7 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream,
>          break;
>      case FLV_CODECID_H264:
>          par->codec_id = AV_CODEC_ID_H264;
> -        vstream->need_parsing = AVSTREAM_PARSE_HEADERS;
> +        vstream->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
>          ret = 3;     // not 4, reading packet type will consume one byte
>          break;
>      case FLV_CODECID_MPEG4:
> diff --git a/libavformat/gxf.c b/libavformat/gxf.c
> index 96b7035386..1409895d3a 100644
> --- a/libavformat/gxf.c
> +++ b/libavformat/gxf.c
> @@ -130,13 +130,13 @@ static int get_sindex(AVFormatContext *s, int id, int format) {
>          case 20:
>              st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>              st->codecpar->codec_id = AV_CODEC_ID_MPEG2VIDEO;
> -            st->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
> +            st->internal->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
>              break;
>          case 22:
>          case 23:
>              st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>              st->codecpar->codec_id = AV_CODEC_ID_MPEG1VIDEO;
> -            st->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
> +            st->internal->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
>              break;
>          case 9:
>              st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
> @@ -169,7 +169,7 @@ static int get_sindex(AVFormatContext *s, int id, int format) {
>          case 29: /* AVCHD */
>              st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>              st->codecpar->codec_id = AV_CODEC_ID_H264;
> -            st->need_parsing = AVSTREAM_PARSE_HEADERS;
> +            st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
>              break;
>          // timecode tracks:
>          case 7:
> diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
> index 3f217d5916..9dc0414efe 100644
> --- a/libavformat/img2dec.c
> +++ b/libavformat/img2dec.c
> @@ -209,7 +209,7 @@ int ff_img_read_header(AVFormatContext *s1)
>          s->is_pipe = 0;
>      else {
>          s->is_pipe       = 1;
> -        st->need_parsing = AVSTREAM_PARSE_FULL;
> +        st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>      }
>  
>      if (s->ts_from_file == 2) {
> @@ -479,7 +479,7 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
>              return AVERROR_EOF;
>          if (s->frame_size > 0) {
>              size[0] = s->frame_size;
> -        } else if (!s1->streams[0]->parser) {
> +        } else if (!s1->streams[0]->internal->parser) {
>              size[0] = avio_size(s1->pb);
>          } else {
>              size[0] = 4096;
> diff --git a/libavformat/internal.h b/libavformat/internal.h
> index 49e82bfbca..496bd46ef0 100644
> --- a/libavformat/internal.h
> +++ b/libavformat/internal.h
> @@ -343,6 +343,10 @@ struct AVStreamInternal {
>       * last packet in packet_buffer for this stream when muxing.
>       */
>      struct AVPacketList *last_in_packet_buffer;
> +
> +    /* av_read_frame() support */
> +    enum AVStreamParseType need_parsing;
> +    struct AVCodecParserContext *parser;
>  };
>  
>  #ifdef __GNUC__
> diff --git a/libavformat/ipudec.c b/libavformat/ipudec.c
> index df53df00d9..281ec66340 100644
> --- a/libavformat/ipudec.c
> +++ b/libavformat/ipudec.c
> @@ -62,7 +62,7 @@ static int ipu_read_header(AVFormatContext *s)
>      st->start_time         = 0;
>      st->duration           =
>      st->nb_frames          = avio_rl32(pb);
> -    st->need_parsing       = AVSTREAM_PARSE_FULL_RAW;
> +    st->internal->need_parsing       = AVSTREAM_PARSE_FULL_RAW;
>      avpriv_set_pts_info(st, 64, 1, 25);
>  
>      return 0;
> diff --git a/libavformat/iv8.c b/libavformat/iv8.c
> index e25f24eeb9..03cfe9baaa 100644
> --- a/libavformat/iv8.c
> +++ b/libavformat/iv8.c
> @@ -47,7 +47,7 @@ static int read_header(AVFormatContext *s)
>  
>      st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>      st->codecpar->codec_id = AV_CODEC_ID_MPEG4;
> -    st->need_parsing = AVSTREAM_PARSE_FULL;
> +    st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>      avpriv_set_pts_info(st, 64, 1, 90000);
>  
>      return 0;
> diff --git a/libavformat/ivfdec.c b/libavformat/ivfdec.c
> index 4a802573e7..8f089f9c42 100644
> --- a/libavformat/ivfdec.c
> +++ b/libavformat/ivfdec.c
> @@ -56,7 +56,7 @@ static int read_header(AVFormatContext *s)
>      st->duration          = avio_rl32(s->pb);
>      avio_skip(s->pb, 4); // unused
>  
> -    st->need_parsing      = AVSTREAM_PARSE_HEADERS;
> +    st->internal->need_parsing      = AVSTREAM_PARSE_HEADERS;
>  
>      if (!time_base.den || !time_base.num) {
>          av_log(s, AV_LOG_ERROR, "Invalid frame rate\n");
> diff --git a/libavformat/lmlm4.c b/libavformat/lmlm4.c
> index 79d703a8fc..c2490c94ec 100644
> --- a/libavformat/lmlm4.c
> +++ b/libavformat/lmlm4.c
> @@ -67,14 +67,14 @@ static int lmlm4_read_header(AVFormatContext *s)
>          return AVERROR(ENOMEM);
>      st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>      st->codecpar->codec_id   = AV_CODEC_ID_MPEG4;
> -    st->need_parsing      = AVSTREAM_PARSE_HEADERS;
> +    st->internal->need_parsing      = AVSTREAM_PARSE_HEADERS;
>      avpriv_set_pts_info(st, 64, 1001, 30000);
>  
>      if (!(st = avformat_new_stream(s, NULL)))
>          return AVERROR(ENOMEM);
>      st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>      st->codecpar->codec_id   = AV_CODEC_ID_MP2;
> -    st->need_parsing      = AVSTREAM_PARSE_HEADERS;
> +    st->internal->need_parsing      = AVSTREAM_PARSE_HEADERS;
>  
>      /* the parameters will be extracted from the compressed bitstream */
>      return 0;
> diff --git a/libavformat/loasdec.c b/libavformat/loasdec.c
> index e166a5928a..b39dbb8a44 100644
> --- a/libavformat/loasdec.c
> +++ b/libavformat/loasdec.c
> @@ -75,7 +75,7 @@ static int loas_read_header(AVFormatContext *s)
>  
>      st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>      st->codecpar->codec_id = s->iformat->raw_codec_id;
> -    st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
> +    st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
>  
>      //LCM of all possible AAC sample rates
>      avpriv_set_pts_info(st, 64, 1, 28224000);
> diff --git a/libavformat/lxfdec.c b/libavformat/lxfdec.c
> index fa84ceea78..526d652f43 100644
> --- a/libavformat/lxfdec.c
> +++ b/libavformat/lxfdec.c
> @@ -260,7 +260,7 @@ static int lxf_read_header(AVFormatContext *s)
>      st->codecpar->bit_rate   = 1000000 * ((video_params >> 14) & 0xFF);
>      st->codecpar->codec_tag  = video_params & 0xF;
>      st->codecpar->codec_id   = ff_codec_get_id(lxf_tags, st->codecpar->codec_tag);
> -    st->need_parsing         = AVSTREAM_PARSE_HEADERS;
> +    st->internal->need_parsing         = AVSTREAM_PARSE_HEADERS;
>  
>      av_log(s, AV_LOG_DEBUG, "record: %x = %i-%02i-%02i\n",
>             record_date, 1900 + (record_date & 0x7F), (record_date >> 7) & 0xF,
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 981e044263..98214e1222 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -2734,7 +2734,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
>                            255);
>              }
>              if (st->codecpar->codec_id != AV_CODEC_ID_HEVC)
> -                st->need_parsing = AVSTREAM_PARSE_HEADERS;
> +                st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
>  
>              if (track->default_duration) {
>                  av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
> @@ -2792,9 +2792,9 @@ static int matroska_parse_tracks(AVFormatContext *s)
>              if (st->codecpar->codec_id == AV_CODEC_ID_MP3 ||
>                  st->codecpar->codec_id == AV_CODEC_ID_MLP ||
>                  st->codecpar->codec_id == AV_CODEC_ID_TRUEHD)
> -                st->need_parsing = AVSTREAM_PARSE_FULL;
> +                st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>              else if (st->codecpar->codec_id != AV_CODEC_ID_AAC)
> -                st->need_parsing = AVSTREAM_PARSE_HEADERS;
> +                st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
>              if (track->codec_delay > 0) {
>                  st->codecpar->initial_padding = av_rescale_q(track->codec_delay,
>                                                               (AVRational){1, 1000000000},
> diff --git a/libavformat/mgsts.c b/libavformat/mgsts.c
> index 415e052725..6b0a748b77 100644
> --- a/libavformat/mgsts.c
> +++ b/libavformat/mgsts.c
> @@ -50,7 +50,7 @@ static int read_header(AVFormatContext *s)
>      if (!st)
>          return AVERROR(ENOMEM);
>  
> -    st->need_parsing = AVSTREAM_PARSE_HEADERS;
> +    st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
>      st->start_time = 0;
>      st->nb_frames  =
>      st->duration   = avio_rb32(pb);
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 57ac212146..a41c358a2a 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -2165,7 +2165,7 @@ static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb,
>              switch (st->codecpar->codec_id) {
>              case AV_CODEC_ID_MP2:
>              case AV_CODEC_ID_MP3:
> -                st->need_parsing = AVSTREAM_PARSE_FULL;
> +                st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>                  break;
>              }
>          }
> @@ -2421,10 +2421,10 @@ static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb,
>      case AV_CODEC_ID_VC1:
>      case AV_CODEC_ID_VP8:
>      case AV_CODEC_ID_VP9:
> -        st->need_parsing = AVSTREAM_PARSE_FULL;
> +        st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>          break;
>      case AV_CODEC_ID_AV1:
> -        st->need_parsing = AVSTREAM_PARSE_HEADERS;
> +        st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
>          break;
>      default:
>          break;
> @@ -2768,8 +2768,8 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>  
>      if (!entries) {
>          sc->keyframe_absent = 1;
> -        if (!st->need_parsing && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
> -            st->need_parsing = AVSTREAM_PARSE_HEADERS;
> +        if (!st->internal->need_parsing && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
> +            st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
>          return 0;
>      }
>      if (sc->keyframes)
> @@ -4312,7 +4312,7 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>          && sc->stts_count > 3
>          && sc->stts_count*10 > st->nb_frames
>          && sc->time_scale == st->codecpar->sample_rate) {
> -            st->need_parsing = AVSTREAM_PARSE_FULL;
> +            st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>      }
>      /* Do not need those anymore. */
>      av_freep(&sc->chunk_offsets);
> @@ -7634,7 +7634,7 @@ static int mov_read_header(AVFormatContext *s)
>              mov->handbrake_version <= 1000000*0 + 1000*10 + 2 &&  // 0.10.2
>              st->codecpar->codec_id == AV_CODEC_ID_MP3) {
>              av_log(s, AV_LOG_VERBOSE, "Forcing full parsing for mp3 stream\n");
> -            st->need_parsing = AVSTREAM_PARSE_FULL;
> +            st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>          }
>      }
>  
> @@ -7940,9 +7940,9 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
>                  sc->has_palette = 0;
>              }
>          }
> -        if (st->codecpar->codec_id == AV_CODEC_ID_MP3 && !st->need_parsing && pkt->size > 4) {
> +        if (st->codecpar->codec_id == AV_CODEC_ID_MP3 && !st->internal->need_parsing && pkt->size > 4) {
>              if (ff_mpa_check_header(AV_RB32(pkt->data)) < 0)
> -                st->need_parsing = AVSTREAM_PARSE_FULL;
> +                st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>          }
>      }
>  
> diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
> index 53f803ef55..fe12cd4fc7 100644
> --- a/libavformat/mp3dec.c
> +++ b/libavformat/mp3dec.c
> @@ -374,7 +374,7 @@ static int mp3_read_header(AVFormatContext *s)
>  
>      st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>      st->codecpar->codec_id = AV_CODEC_ID_MP3;
> -    st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
> +    st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
>      st->start_time = 0;
>  
>      // lcm of all mp3 sample rates
> diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
> index 20d1e10168..c25d76fc60 100644
> --- a/libavformat/mpeg.c
> +++ b/libavformat/mpeg.c
> @@ -623,7 +623,7 @@ skip:
>          st->codecpar->sample_rate = 8000;
>      }
>      st->internal->request_probe     = request_probe;
> -    st->need_parsing      = AVSTREAM_PARSE_FULL;
> +    st->internal->need_parsing      = AVSTREAM_PARSE_FULL;
>  
>  found:
>      if (st->discard >= AVDISCARD_ALL)
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index 7cf14a1d13..6135d05477 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -903,7 +903,7 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
>      st->priv_data         = pes;
>      st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
>      st->codecpar->codec_id   = AV_CODEC_ID_NONE;
> -    st->need_parsing      = AVSTREAM_PARSE_FULL;
> +    st->internal->need_parsing      = AVSTREAM_PARSE_FULL;
>      pes->st          = st;
>      pes->stream_type = stream_type;
>  
> @@ -941,7 +941,7 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
>              sub_st->priv_data         = sub_pes;
>              sub_st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>              sub_st->codecpar->codec_id   = AV_CODEC_ID_AC3;
> -            sub_st->need_parsing      = AVSTREAM_PARSE_FULL;
> +            sub_st->internal->need_parsing      = AVSTREAM_PARSE_FULL;
>              sub_pes->sub_st           = pes->sub_st = sub_st;
>          }
>      }
> @@ -1716,10 +1716,10 @@ static void m4sl_cb(MpegTSFilter *filter, const uint8_t *section,
>              ff_mp4_read_dec_config_descr(s, st, &pb);
>              if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
>                  st->codecpar->extradata_size > 0)
> -                st->need_parsing = 0;
> +                st->internal->need_parsing = 0;
>              if (st->codecpar->codec_id == AV_CODEC_ID_H264 &&
>                  st->codecpar->extradata_size > 0)
> -                st->need_parsing = 0;
> +                st->internal->need_parsing = 0;
>  
>              st->codecpar->codec_type = avcodec_get_type(st->codecpar->codec_id);
>              st->internal->need_context_update = 1;
> @@ -1825,7 +1825,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
>                  ff_mp4_read_dec_config_descr(fc, st, &pb);
>                  if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
>                      st->codecpar->extradata_size > 0) {
> -                    st->need_parsing = 0;
> +                    st->internal->need_parsing = 0;
>                      st->internal->need_context_update = 1;
>                  }
>                  if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4SYSTEMS)
> @@ -1847,7 +1847,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
>              ff_mp4_read_dec_config_descr(fc, st, &pb);
>              if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
>                  st->codecpar->extradata_size > 0) {
> -                st->internal->request_probe = st->need_parsing = 0;
> +                st->internal->request_probe = st->internal->need_parsing = 0;
>                  st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>                  st->internal->need_context_update = 1;
>              }
> @@ -2032,7 +2032,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
>                  } else {
>                      avpriv_request_sample(fc, "Opus in MPEG-TS - channel_config_code > 0x8");
>                  }
> -                st->need_parsing = AVSTREAM_PARSE_FULL;
> +                st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>                  st->internal->need_context_update = 1;
>              }
>          }
> diff --git a/libavformat/msf.c b/libavformat/msf.c
> index 155f488e44..0927af43ff 100644
> --- a/libavformat/msf.c
> +++ b/libavformat/msf.c
> @@ -80,7 +80,7 @@ static int msf_read_header(AVFormatContext *s)
>              AV_WL16(st->codecpar->extradata+8, codec == 4 ? 1 : 0); /* joint stereo (repeat?) */
>              AV_WL16(st->codecpar->extradata+10, 1);
>              st->codecpar->codec_id = AV_CODEC_ID_ATRAC3;    break;
> -    case 7: st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
> +    case 7: st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
>              st->codecpar->codec_id = AV_CODEC_ID_MP3;       break;
>      default:
>              avpriv_request_sample(s, "Codec %d", codec);
> diff --git a/libavformat/mtv.c b/libavformat/mtv.c
> index e731d91077..6526caded2 100644
> --- a/libavformat/mtv.c
> +++ b/libavformat/mtv.c
> @@ -185,7 +185,7 @@ static int mtv_read_header(AVFormatContext *s)
>      st->codecpar->codec_type      = AVMEDIA_TYPE_AUDIO;
>      st->codecpar->codec_id        = AV_CODEC_ID_MP3;
>      st->codecpar->bit_rate        = mtv->audio_br;
> -    st->need_parsing              = AVSTREAM_PARSE_FULL;
> +    st->internal->need_parsing              = AVSTREAM_PARSE_FULL;
>  
>      // Jump over header
>  
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 1f79f3d3cd..f9097a01a0 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -2578,7 +2578,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
>                      }
>                  }
>              }
> -            st->need_parsing = AVSTREAM_PARSE_HEADERS;
> +            st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
>              if (material_track->sequence->origin) {
>                  av_dict_set_int(&st->metadata, "material_track_origin", material_track->sequence->origin, 0);
>              }
> @@ -2643,7 +2643,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
>                  else if (descriptor->bits_per_sample == 32)
>                      st->codecpar->codec_id = AV_CODEC_ID_PCM_S32BE;
>              } else if (st->codecpar->codec_id == AV_CODEC_ID_MP2) {
> -                st->need_parsing = AVSTREAM_PARSE_FULL;
> +                st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>              }
>              st->codecpar->bits_per_coded_sample = av_get_bits_per_sample(st->codecpar->codec_id);
>          } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
> @@ -2677,7 +2677,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
>          }
>          if (st->codecpar->codec_type != AVMEDIA_TYPE_DATA && source_track->wrapping != FrameWrapped) {
>              /* TODO: decode timestamps */
> -            st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
> +            st->internal->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
>          }
>      }
>  
> @@ -3612,7 +3612,7 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
>                  if (next_ofs <= 0) {
>                      // If we have no way to packetize the data, then return it in chunks...
>                      if (klv.next_klv - klv.length == pos && max_data_size > MXF_MAX_CHUNK_SIZE) {
> -                        st->need_parsing = AVSTREAM_PARSE_FULL;
> +                        st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>                          avpriv_request_sample(s, "Huge KLV without proper index in non-frame wrapped essence");
>                      }
>                      size = FFMIN(max_data_size, MXF_MAX_CHUNK_SIZE);
> diff --git a/libavformat/ncdec.c b/libavformat/ncdec.c
> index f2066b485a..b2d033bc6e 100644
> --- a/libavformat/ncdec.c
> +++ b/libavformat/ncdec.c
> @@ -53,7 +53,7 @@ static int nc_read_header(AVFormatContext *s)
>  
>      st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>      st->codecpar->codec_id   = AV_CODEC_ID_MPEG4;
> -    st->need_parsing      = AVSTREAM_PARSE_FULL;
> +    st->internal->need_parsing      = AVSTREAM_PARSE_FULL;
>  
>      avpriv_set_pts_info(st, 64, 1, 100);
>  
> diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c
> index 4fab52ed36..376ed76534 100644
> --- a/libavformat/nsvdec.c
> +++ b/libavformat/nsvdec.c
> @@ -462,7 +462,7 @@ static int nsv_parse_NSVs_header(AVFormatContext *s)
>              st->codecpar->codec_tag = atag;
>              st->codecpar->codec_id = ff_codec_get_id(nsv_codec_audio_tags, atag);
>  
> -            st->need_parsing = AVSTREAM_PARSE_FULL; /* for PCM we will read a chunk later and put correct info */
> +            st->internal->need_parsing = AVSTREAM_PARSE_FULL; /* for PCM we will read a chunk later and put correct info */
>  
>              /* set timebase to common denominator of ms and framerate */
>              avpriv_set_pts_info(st, 64, 1, framerate.num*1000);
> @@ -615,7 +615,7 @@ null_chunk_retry:
>              asize-=4;
>              av_log(s, AV_LOG_TRACE, "NSV RAWAUDIO: bps %d, nchan %d, srate %d\n", bps, channels, samplerate);
>              if (fill_header) {
> -                st[NSV_ST_AUDIO]->need_parsing = AVSTREAM_PARSE_NONE; /* we know everything */
> +                st[NSV_ST_AUDIO]->internal->need_parsing = AVSTREAM_PARSE_NONE; /* we know everything */
>                  if (bps != 16) {
>                      av_log(s, AV_LOG_TRACE, "NSV AUDIO bit/sample != 16 (%d)!!!\n", bps);
>                  }
> diff --git a/libavformat/nuv.c b/libavformat/nuv.c
> index d99770d41d..8ebcdddce4 100644
> --- a/libavformat/nuv.c
> +++ b/libavformat/nuv.c
> @@ -128,7 +128,7 @@ static int get_codec_data(AVFormatContext *s, AVIOContext *pb, AVStream *vst,
>                  }
>                  ast->codecpar->codec_id = id;
>  
> -                ast->need_parsing = AVSTREAM_PARSE_FULL;
> +                ast->internal->need_parsing = AVSTREAM_PARSE_FULL;
>              } else
>                  avio_skip(pb, 4 * 4);
>  
> diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
> index 4e85b05c67..15eeca56aa 100644
> --- a/libavformat/oggparseflac.c
> +++ b/libavformat/oggparseflac.c
> @@ -59,7 +59,7 @@ flac_header (AVFormatContext * s, int idx)
>  
>          st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>          st->codecpar->codec_id = AV_CODEC_ID_FLAC;
> -        st->need_parsing = AVSTREAM_PARSE_HEADERS;
> +        st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
>  
>          if ((ret = ff_alloc_extradata(st->codecpar, FLAC_STREAMINFO_SIZE)) < 0)
>              return ret;
> diff --git a/libavformat/oggparseogm.c b/libavformat/oggparseogm.c
> index 469b229995..a8319b9dfa 100644
> --- a/libavformat/oggparseogm.c
> +++ b/libavformat/oggparseogm.c
> @@ -60,7 +60,7 @@ ogm_header(AVFormatContext *s, int idx)
>              st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag);
>              st->codecpar->codec_tag = tag;
>              if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4)
> -                st->need_parsing = AVSTREAM_PARSE_HEADERS;
> +                st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
>          } else if (bytestream2_peek_byte(&p) == 't') {
>              st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
>              st->codecpar->codec_id = AV_CODEC_ID_TEXT;
> @@ -76,7 +76,7 @@ ogm_header(AVFormatContext *s, int idx)
>              st->codecpar->codec_id = ff_codec_get_id(ff_codec_wav_tags, cid);
>              // our parser completely breaks AAC in Ogg
>              if (st->codecpar->codec_id != AV_CODEC_ID_AAC)
> -                st->need_parsing = AVSTREAM_PARSE_FULL;
> +                st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>          }
>  
>          size        = bytestream2_get_le32(&p);
> diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c
> index d1064e4328..28684f6ea9 100644
> --- a/libavformat/oggparsetheora.c
> +++ b/libavformat/oggparsetheora.c
> @@ -112,7 +112,7 @@ static int theora_header(AVFormatContext *s, int idx)
>  
>          st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>          st->codecpar->codec_id   = AV_CODEC_ID_THEORA;
> -        st->need_parsing      = AVSTREAM_PARSE_HEADERS;
> +        st->internal->need_parsing      = AVSTREAM_PARSE_HEADERS;
>      }
>      break;
>      case 0x81:
> diff --git a/libavformat/oggparsevp8.c b/libavformat/oggparsevp8.c
> index b76ac71cc5..85b3627c9c 100644
> --- a/libavformat/oggparsevp8.c
> +++ b/libavformat/oggparsevp8.c
> @@ -61,7 +61,7 @@ static int vp8_header(AVFormatContext *s, int idx)
>          avpriv_set_pts_info(st, 64, framerate.den, framerate.num);
>          st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>          st->codecpar->codec_id   = AV_CODEC_ID_VP8;
> -        st->need_parsing      = AVSTREAM_PARSE_HEADERS;
> +        st->internal->need_parsing      = AVSTREAM_PARSE_HEADERS;
>          break;
>      case 0x02:
>          if (p[6] != 0x20)
> diff --git a/libavformat/omadec.c b/libavformat/omadec.c
> index 5675d86e75..c4799e9fdc 100644
> --- a/libavformat/omadec.c
> +++ b/libavformat/omadec.c
> @@ -506,7 +506,7 @@ static int oma_read_header(AVFormatContext *s)
>          avpriv_set_pts_info(st, 64, 1, samplerate);
>          break;
>      case OMA_CODECID_MP3:
> -        st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
> +        st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
>          framesize = 1024;
>          break;
>      case OMA_CODECID_LPCM:
> diff --git a/libavformat/pva.c b/libavformat/pva.c
> index 58ec78750c..4d348417c8 100644
> --- a/libavformat/pva.c
> +++ b/libavformat/pva.c
> @@ -61,7 +61,7 @@ static int pva_read_header(AVFormatContext *s) {
>          return AVERROR(ENOMEM);
>      st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>      st->codecpar->codec_id   = AV_CODEC_ID_MPEG2VIDEO;
> -    st->need_parsing      = AVSTREAM_PARSE_FULL;
> +    st->internal->need_parsing      = AVSTREAM_PARSE_FULL;
>      avpriv_set_pts_info(st, 32, 1, 90000);
>      av_add_index_entry(st, 0, 0, 0, 0, AVINDEX_KEYFRAME);
>  
> @@ -69,7 +69,7 @@ static int pva_read_header(AVFormatContext *s) {
>          return AVERROR(ENOMEM);
>      st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>      st->codecpar->codec_id   = AV_CODEC_ID_MP2;
> -    st->need_parsing      = AVSTREAM_PARSE_FULL;
> +    st->internal->need_parsing      = AVSTREAM_PARSE_FULL;
>      avpriv_set_pts_info(st, 33, 1, 90000);
>      av_add_index_entry(st, 0, 0, 0, 0, AVINDEX_KEYFRAME);
>  
> diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
> index 10c37c5cb9..aa5ac23cdc 100644
> --- a/libavformat/rawdec.c
> +++ b/libavformat/rawdec.c
> @@ -60,7 +60,7 @@ int ff_raw_audio_read_header(AVFormatContext *s)
>          return AVERROR(ENOMEM);
>      st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>      st->codecpar->codec_id = s->iformat->raw_codec_id;
> -    st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
> +    st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
>      st->start_time = 0;
>      /* the parameters will be extracted from the compressed bitstream */
>  
> @@ -83,7 +83,7 @@ int ff_raw_video_read_header(AVFormatContext *s)
>  
>      st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>      st->codecpar->codec_id = s->iformat->raw_codec_id;
> -    st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
> +    st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
>  
>      st->internal->avctx->framerate = s1->framerate;
>      avpriv_set_pts_info(st, 64, 1, 1200000);
> diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
> index 72b8dba741..bafd1a2000 100644
> --- a/libavformat/rmdec.c
> +++ b/libavformat/rmdec.c
> @@ -200,7 +200,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
>  
>          switch (st->codecpar->codec_id) {
>          case AV_CODEC_ID_AC3:
> -            st->need_parsing = AVSTREAM_PARSE_FULL;
> +            st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>              break;
>          case AV_CODEC_ID_RA_288:
>              st->codecpar->extradata_size= 0;
> @@ -209,7 +209,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
>              st->codecpar->block_align = coded_framesize;
>              break;
>          case AV_CODEC_ID_COOK:
> -            st->need_parsing = AVSTREAM_PARSE_HEADERS;
> +            st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
>          case AV_CODEC_ID_ATRAC3:
>          case AV_CODEC_ID_SIPR:
>              if (read_all) {
> @@ -233,7 +233,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
>                      return -1;
>                  }
>                  st->codecpar->block_align = ff_sipr_subpk_size[flavor];
> -                st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
> +                st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
>              } else {
>                  if(sub_packet_size <= 0){
>                      av_log(s, AV_LOG_ERROR, "sub_packet_size is invalid\n");
> @@ -386,7 +386,7 @@ int ff_rm_read_mdpr_codecdata(AVFormatContext *s, AVIOContext *pb,
>          avio_skip(pb, 2); // looks like bits per sample
>          avio_skip(pb, 4); // always zero?
>          st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
> -        st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
> +        st->internal->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
>          fps = avio_rb32(pb);
>  
>          if ((ret = rm_read_extradata(s, pb, st->codecpar, codec_data_size - (avio_tell(pb) - codec_pos))) < 0)
> diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c
> index e58f0260f3..3b8d16ec46 100644
> --- a/libavformat/rtpdec_asf.c
> +++ b/libavformat/rtpdec_asf.c
> @@ -167,8 +167,8 @@ static int asfrtp_parse_sdp_line(AVFormatContext *s, int stream_index,
>                  if (s->streams[stream_index]->id == rt->asf_ctx->streams[i]->id) {
>                      avcodec_parameters_copy(s->streams[stream_index]->codecpar,
>                                              rt->asf_ctx->streams[i]->codecpar);
> -                    s->streams[stream_index]->need_parsing =
> -                        rt->asf_ctx->streams[i]->need_parsing;
> +                    s->streams[stream_index]->internal->need_parsing =
> +                        rt->asf_ctx->streams[i]->internal->need_parsing;
>                      avpriv_set_pts_info(s->streams[stream_index], 32, 1, 1000);
>                  }
>             }
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index 2ce09477ed..5d01b91b1e 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -226,7 +226,7 @@ static void init_rtp_handler(const RTPDynamicProtocolHandler *handler,
>          par->codec_id          = handler->codec_id;
>      rtsp_st->dynamic_handler = handler;
>      if (st)
> -        st->need_parsing = handler->need_parsing;
> +        st->internal->need_parsing = handler->need_parsing;
>      if (handler->priv_data_size) {
>          rtsp_st->dynamic_protocol_context = av_mallocz(handler->priv_data_size);
>          if (!rtsp_st->dynamic_protocol_context)
> diff --git a/libavformat/sdr2.c b/libavformat/sdr2.c
> index 3743d59e58..496870bb3b 100644
> --- a/libavformat/sdr2.c
> +++ b/libavformat/sdr2.c
> @@ -51,7 +51,7 @@ static int sdr2_read_header(AVFormatContext *s)
>      st->codecpar->width      = avio_rl32(s->pb);
>      st->codecpar->height     = avio_rl32(s->pb);
>      st->codecpar->codec_id   = AV_CODEC_ID_H264;
> -    st->need_parsing      = AVSTREAM_PARSE_FULL;
> +    st->internal->need_parsing      = AVSTREAM_PARSE_FULL;
>  
>      ast->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
>      ast->codecpar->channels    = 1;
> diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c
> index ce65ac6db0..22362c4561 100644
> --- a/libavformat/segafilm.c
> +++ b/libavformat/segafilm.c
> @@ -180,7 +180,7 @@ static int film_read_header(AVFormatContext *s)
>          if (film->audio_type == AV_CODEC_ID_ADPCM_ADX) {
>              st->codecpar->bits_per_coded_sample = 18 * 8 / 32;
>              st->codecpar->block_align = st->codecpar->channels * 18;
> -            st->need_parsing = AVSTREAM_PARSE_FULL;
> +            st->internal->need_parsing = AVSTREAM_PARSE_FULL;
>          } else {
>              st->codecpar->bits_per_coded_sample = film->audio_bits;
>              st->codecpar->block_align = st->codecpar->channels *
> diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
> index fa11c050cd..8f9b1ab7ce 100644
> --- a/libavformat/swfdec.c
> +++ b/libavformat/swfdec.c
> @@ -203,7 +203,7 @@ static AVStream *create_new_audio_stream(AVFormatContext *s, int id, int info)
>      }
>      ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>      ast->codecpar->codec_id   = ff_codec_get_id(swf_audio_codec_tags, info>>4 & 15);
> -    ast->need_parsing = AVSTREAM_PARSE_FULL;
> +    ast->internal->need_parsing = AVSTREAM_PARSE_FULL;
>      sample_rate_code = info>>2 & 3;
>      sample_size_code = info>>1 & 1;
>      if (!sample_size_code && ast->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE)
> diff --git a/libavformat/takdec.c b/libavformat/takdec.c
> index 6d18b6af21..8929be8f24 100644
> --- a/libavformat/takdec.c
> +++ b/libavformat/takdec.c
> @@ -65,7 +65,7 @@ static int tak_read_header(AVFormatContext *s)
>  
>      st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>      st->codecpar->codec_id   = AV_CODEC_ID_TAK;
> -    st->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
> +    st->internal->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
>  
>      tc->mlast_frame = 0;
>      if (avio_rl32(pb) != MKTAG('t', 'B', 'a', 'K')) {
> diff --git a/libavformat/ty.c b/libavformat/ty.c
> index c8e1067c0e..96af6952e6 100644
> --- a/libavformat/ty.c
> +++ b/libavformat/ty.c
> @@ -308,7 +308,7 @@ static int ty_read_header(AVFormatContext *s)
>          return AVERROR(ENOMEM);
>      st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
>      st->codecpar->codec_id   = AV_CODEC_ID_MPEG2VIDEO;
> -    st->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
> +    st->internal->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
>      avpriv_set_pts_info(st, 64, 1, 90000);
>  
>      ast = avformat_new_stream(s, NULL);
> @@ -318,7 +318,7 @@ static int ty_read_header(AVFormatContext *s)
>  
>      if (ty->audio_type == TIVO_AUDIO_MPEG) {
>          ast->codecpar->codec_id = AV_CODEC_ID_MP2;
> -        ast->need_parsing       = AVSTREAM_PARSE_FULL_RAW;
> +        ast->internal->need_parsing       = AVSTREAM_PARSE_FULL_RAW;
>      } else {
>          ast->codecpar->codec_id = AV_CODEC_ID_AC3;
>      }
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 27b7b62b1a..4d281a9ce8 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -144,7 +144,7 @@ int64_t av_stream_get_end_pts(const AVStream *st)
>  
>  struct AVCodecParserContext *av_stream_get_parser(const AVStream *st)
>  {
> -    return st->parser;
> +    return st->internal->parser;
>  }
>  
>  void av_format_inject_global_side_data(AVFormatContext *s)
> @@ -472,9 +472,9 @@ static int update_stream_avctx(AVFormatContext *s)
>              continue;
>  
>          /* close parser, because it depends on the codec */
> -        if (st->parser && st->internal->avctx->codec_id != st->codecpar->codec_id) {
> -            av_parser_close(st->parser);
> -            st->parser = NULL;
> +        if (st->internal->parser && st->internal->avctx->codec_id != st->codecpar->codec_id) {
> +            av_parser_close(st->internal->parser);
> +            st->internal->parser = NULL;
>          }
>  
>          /* update internal codec context, for the parser */
> @@ -1287,7 +1287,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
>  
>      /* Correct timestamps with byte offset if demuxers only have timestamps
>       * on packet boundaries */
> -    if (pc && st->need_parsing == AVSTREAM_PARSE_TIMESTAMPS && pkt->size) {
> +    if (pc && st->internal->need_parsing == AVSTREAM_PARSE_TIMESTAMPS && pkt->size) {
>          /* this will estimate bitrate based on this frame's duration and size */
>          offset = av_rescale(pc->offset, pkt->duration, pkt->size);
>          if (pkt->pts != AV_NOPTS_VALUE)
> @@ -1404,9 +1404,9 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
>  
>      if (size || flush) {
>          av_init_packet(&out_pkt);
> -    } else if (st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) {
> +    } else if (st->internal->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) {
>          // preserve 0-size sync packets
> -        compute_pkt_fields(s, st, st->parser, pkt, AV_NOPTS_VALUE, AV_NOPTS_VALUE);
> +        compute_pkt_fields(s, st, st->internal->parser, pkt, AV_NOPTS_VALUE, AV_NOPTS_VALUE);
>      }
>  
>      while (size > 0 || (flush && got_output)) {
> @@ -1414,7 +1414,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
>          int64_t next_pts = pkt->pts;
>          int64_t next_dts = pkt->dts;
>  
> -        len = av_parser_parse2(st->parser, st->internal->avctx,
> +        len = av_parser_parse2(st->internal->parser, st->internal->avctx,
>                                 &out_pkt.data, &out_pkt.size, data, size,
>                                 pkt->pts, pkt->dts, pkt->pos);
>  
> @@ -1432,7 +1432,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
>          if (pkt->buf && out_pkt.data == pkt->data) {
>              /* reference pkt->buf only when out_pkt.data is guaranteed to point
>               * to data in it and not in the parser's internal buffer. */
> -            /* XXX: Ensure this is the case with all parsers when st->parser->flags
> +            /* XXX: Ensure this is the case with all parsers when st->internal->parser->flags
>               * is PARSER_FLAG_COMPLETE_FRAMES and check for that instead? */
>              out_pkt.buf = av_buffer_ref(pkt->buf);
>              if (!out_pkt.buf) {
> @@ -1453,11 +1453,11 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
>          }
>  
>          /* set the duration */
> -        out_pkt.duration = (st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) ? pkt->duration : 0;
> +        out_pkt.duration = (st->internal->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) ? pkt->duration : 0;
>          if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
>              if (st->internal->avctx->sample_rate > 0) {
>                  out_pkt.duration =
> -                    av_rescale_q_rnd(st->parser->duration,
> +                    av_rescale_q_rnd(st->internal->parser->duration,
>                                       (AVRational) { 1, st->internal->avctx->sample_rate },
>                                       st->time_base,
>                                       AV_ROUND_DOWN);
> @@ -1465,23 +1465,23 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
>          }
>  
>          out_pkt.stream_index = st->index;
> -        out_pkt.pts          = st->parser->pts;
> -        out_pkt.dts          = st->parser->dts;
> -        out_pkt.pos          = st->parser->pos;
> +        out_pkt.pts          = st->internal->parser->pts;
> +        out_pkt.dts          = st->internal->parser->dts;
> +        out_pkt.pos          = st->internal->parser->pos;
>          out_pkt.flags       |= pkt->flags & AV_PKT_FLAG_DISCARD;
>  
> -        if (st->need_parsing == AVSTREAM_PARSE_FULL_RAW)
> -            out_pkt.pos = st->parser->frame_offset;
> +        if (st->internal->need_parsing == AVSTREAM_PARSE_FULL_RAW)
> +            out_pkt.pos = st->internal->parser->frame_offset;
>  
> -        if (st->parser->key_frame == 1 ||
> -            (st->parser->key_frame == -1 &&
> -             st->parser->pict_type == AV_PICTURE_TYPE_I))
> +        if (st->internal->parser->key_frame == 1 ||
> +            (st->internal->parser->key_frame == -1 &&
> +             st->internal->parser->pict_type == AV_PICTURE_TYPE_I))
>              out_pkt.flags |= AV_PKT_FLAG_KEY;
>  
> -        if (st->parser->key_frame == -1 && st->parser->pict_type ==AV_PICTURE_TYPE_NONE && (pkt->flags&AV_PKT_FLAG_KEY))
> +        if (st->internal->parser->key_frame == -1 && st->internal->parser->pict_type ==AV_PICTURE_TYPE_NONE && (pkt->flags&AV_PKT_FLAG_KEY))
>              out_pkt.flags |= AV_PKT_FLAG_KEY;
>  
> -        compute_pkt_fields(s, st, st->parser, &out_pkt, next_dts, next_pts);
> +        compute_pkt_fields(s, st, st->internal->parser, &out_pkt, next_dts, next_pts);
>  
>          ret = avpriv_packet_list_put(&s->internal->parse_queue,
>                                   &s->internal->parse_queue_end,
> @@ -1494,8 +1494,8 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
>  
>      /* end of the stream => close and free the parser */
>      if (flush) {
> -        av_parser_close(st->parser);
> -        st->parser = NULL;
> +        av_parser_close(st->internal->parser);
> +        st->internal->parser = NULL;
>      }
>  
>  fail:
> @@ -1524,7 +1524,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
>              /* flush the parsers */
>              for (i = 0; i < s->nb_streams; i++) {
>                  st = s->streams[i];
> -                if (st->parser && st->need_parsing)
> +                if (st->internal->parser && st->internal->need_parsing)
>                      parse_packet(s, pkt, st->index, 1);
>              }
>              /* all remaining packets are now in parse_queue =>
> @@ -1543,9 +1543,9 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
>              }
>  
>              /* close parser, because it depends on the codec */
> -            if (st->parser && st->internal->avctx->codec_id != st->codecpar->codec_id) {
> -                av_parser_close(st->parser);
> -                st->parser = NULL;
> +            if (st->internal->parser && st->internal->avctx->codec_id != st->codecpar->codec_id) {
> +                av_parser_close(st->internal->parser);
> +                st->internal->parser = NULL;
>              }
>  
>              ret = avcodec_parameters_to_context(st->internal->avctx, st->codecpar);
> @@ -1586,23 +1586,23 @@ FF_ENABLE_DEPRECATION_WARNINGS
>                     av_ts2str(pkt->dts),
>                     pkt->size, pkt->duration, pkt->flags);
>  
> -        if (st->need_parsing && !st->parser && !(s->flags & AVFMT_FLAG_NOPARSE)) {
> -            st->parser = av_parser_init(st->codecpar->codec_id);
> -            if (!st->parser) {
> +        if (st->internal->need_parsing && !st->internal->parser && !(s->flags & AVFMT_FLAG_NOPARSE)) {
> +            st->internal->parser = av_parser_init(st->codecpar->codec_id);
> +            if (!st->internal->parser) {
>                  av_log(s, AV_LOG_VERBOSE, "parser not found for codec "
>                         "%s, packets or times may be invalid.\n",
>                         avcodec_get_name(st->codecpar->codec_id));
>                  /* no parser available: just output the raw packets */
> -                st->need_parsing = AVSTREAM_PARSE_NONE;
> -            } else if (st->need_parsing == AVSTREAM_PARSE_HEADERS)
> -                st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
> -            else if (st->need_parsing == AVSTREAM_PARSE_FULL_ONCE)
> -                st->parser->flags |= PARSER_FLAG_ONCE;
> -            else if (st->need_parsing == AVSTREAM_PARSE_FULL_RAW)
> -                st->parser->flags |= PARSER_FLAG_USE_CODEC_TS;
> +                st->internal->need_parsing = AVSTREAM_PARSE_NONE;
> +            } else if (st->internal->need_parsing == AVSTREAM_PARSE_HEADERS)
> +                st->internal->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
> +            else if (st->internal->need_parsing == AVSTREAM_PARSE_FULL_ONCE)
> +                st->internal->parser->flags |= PARSER_FLAG_ONCE;
> +            else if (st->internal->need_parsing == AVSTREAM_PARSE_FULL_RAW)
> +                st->internal->parser->flags |= PARSER_FLAG_USE_CODEC_TS;
>          }
>  
> -        if (!st->need_parsing || !st->parser) {
> +        if (!st->internal->need_parsing || !st->internal->parser) {
>              /* no parsing needed: we just output the packet as is */
>              compute_pkt_fields(s, st, NULL, pkt, AV_NOPTS_VALUE, AV_NOPTS_VALUE);
>              if ((s->iformat->flags & AVFMT_GENERIC_INDEX) &&
> @@ -1870,9 +1870,9 @@ void ff_read_frame_flush(AVFormatContext *s)
>      for (i = 0; i < s->nb_streams; i++) {
>          st = s->streams[i];
>  
> -        if (st->parser) {
> -            av_parser_close(st->parser);
> -            st->parser = NULL;
> +        if (st->internal->parser) {
> +            av_parser_close(st->internal->parser);
> +            st->internal->parser = NULL;
>          }
>          st->last_IP_pts = AV_NOPTS_VALUE;
>          st->internal->last_dts_for_order_check = AV_NOPTS_VALUE;
> @@ -2759,9 +2759,9 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
>              av_log(ic, AV_LOG_WARNING,
>                     "start time for stream %d is not set in estimate_timings_from_pts\n", i);
>  
> -        if (st->parser) {
> -            av_parser_close(st->parser);
> -            st->parser = NULL;
> +        if (st->internal->parser) {
> +            av_parser_close(st->internal->parser);
> +            st->internal->parser = NULL;
>          }
>      }
>  
> @@ -2797,7 +2797,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
>                  (st->start_time != AV_NOPTS_VALUE ||
>                   st->first_dts  != AV_NOPTS_VALUE)) {
>                  if (pkt->duration == 0) {
> -                    ff_compute_frame_duration(ic, &num, &den, st, st->parser, pkt);
> +                    ff_compute_frame_duration(ic, &num, &den, st, st->internal->parser, pkt);
>                      if (den && num) {
>                          pkt->duration = av_rescale_rnd(1,
>                                             num * (int64_t) st->time_base.den,
> @@ -3606,15 +3606,15 @@ FF_DISABLE_DEPRECATION_WARNINGS
>  FF_ENABLE_DEPRECATION_WARNINGS
>  #endif
>          // only for the split stuff
> -        if (!st->parser && !(ic->flags & AVFMT_FLAG_NOPARSE) && st->internal->request_probe <= 0) {
> -            st->parser = av_parser_init(st->codecpar->codec_id);
> -            if (st->parser) {
> -                if (st->need_parsing == AVSTREAM_PARSE_HEADERS) {
> -                    st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
> -                } else if (st->need_parsing == AVSTREAM_PARSE_FULL_RAW) {
> -                    st->parser->flags |= PARSER_FLAG_USE_CODEC_TS;
> +        if (!st->internal->parser && !(ic->flags & AVFMT_FLAG_NOPARSE) && st->internal->request_probe <= 0) {
> +            st->internal->parser = av_parser_init(st->codecpar->codec_id);
> +            if (st->internal->parser) {
> +                if (st->internal->need_parsing == AVSTREAM_PARSE_HEADERS) {
> +                    st->internal->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
> +                } else if (st->internal->need_parsing == AVSTREAM_PARSE_FULL_RAW) {
> +                    st->internal->parser->flags |= PARSER_FLAG_USE_CODEC_TS;
>                  }
> -            } else if (st->need_parsing) {
> +            } else if (st->internal->need_parsing) {
>                  av_log(ic, AV_LOG_VERBOSE, "parser not found for codec "
>                         "%s, packets or times may be invalid.\n",
>                         avcodec_get_name(st->codecpar->codec_id));
> @@ -3857,7 +3857,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>                      st->internal->info->codec_info_duration = FFMIN(pkt->pts - st->start_time, st->internal->info->codec_info_duration + pkt->duration);
>                  } else
>                      st->internal->info->codec_info_duration += pkt->duration;
> -                st->internal->info->codec_info_duration_fields += st->parser && st->need_parsing && avctx->ticks_per_frame ==2 ? st->parser->repeat_pict + 1 : 2;
> +                st->internal->info->codec_info_duration_fields += st->internal->parser && st->internal->need_parsing && avctx->ticks_per_frame ==2 ? st->internal->parser->repeat_pict + 1 : 2;
>              }
>          }
>          if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
> @@ -4331,8 +4331,8 @@ static void free_stream(AVStream **pst)
>          av_freep(&st->side_data[i].data);
>      av_freep(&st->side_data);
>  
> -    if (st->parser)
> -        av_parser_close(st->parser);
> +    if (st->internal->parser)
> +        av_parser_close(st->internal->parser);
>  
>      if (st->attached_pic.data)
>          av_packet_unref(&st->attached_pic);
> diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
> index bca186a66f..9b93cfce8e 100644
> --- a/libavformat/wavdec.c
> +++ b/libavformat/wavdec.c
> @@ -175,7 +175,7 @@ static int wav_parse_fmt_tag(AVFormatContext *s, int64_t size, AVStream **st)
>          return ret;
>      handle_stream_probing(*st);
>  
> -    (*st)->need_parsing = AVSTREAM_PARSE_FULL_RAW;
> +    (*st)->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
>  
>      avpriv_set_pts_info(*st, 64, 1, (*st)->codecpar->sample_rate);
>  
> @@ -196,7 +196,7 @@ static int wav_parse_xma2_tag(AVFormatContext *s, int64_t size, AVStream **st)
>  
>      (*st)->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>      (*st)->codecpar->codec_id   = AV_CODEC_ID_XMA2;
> -    (*st)->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
> +    (*st)->internal->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
>  
>      version = avio_r8(pb);
>      if (version != 3 && version != 4)
> @@ -943,7 +943,7 @@ static int w64_read_header(AVFormatContext *s)
>      ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv);
>  
>      handle_stream_probing(st);
> -    st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
> +    st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
>  
>      avio_seek(pb, data_ofs, SEEK_SET);
>  
> diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
> index 83f510b92f..fe665af10c 100644
> --- a/libavformat/wtvdec.c
> +++ b/libavformat/wtvdec.c
> @@ -621,7 +621,7 @@ static AVStream * new_stream(AVFormatContext *s, AVStream *st, int sid, int code
>          st->priv_data = wst;
>      }
>      st->codecpar->codec_type = codec_type;
> -    st->need_parsing      = AVSTREAM_PARSE_FULL;
> +    st->internal->need_parsing      = AVSTREAM_PARSE_FULL;
>      avpriv_set_pts_info(st, 64, 1, 10000000);
>      return st;
>  }
> diff --git a/libavformat/xvag.c b/libavformat/xvag.c
> index e95d84aa3f..b79c89f09e 100644
> --- a/libavformat/xvag.c
> +++ b/libavformat/xvag.c
> @@ -87,7 +87,7 @@ static int xvag_read_header(AVFormatContext *s)
>      if (avio_rb16(s->pb) == 0xFFFB) {
>          st->codecpar->codec_id    = AV_CODEC_ID_MP3;
>          st->codecpar->block_align = 0x1000;
> -        st->need_parsing       = AVSTREAM_PARSE_FULL_RAW;
> +        st->internal->need_parsing       = AVSTREAM_PARSE_FULL_RAW;

There is no need to keep the superfluous whitespace here and in the
other places.

>      }
>  
>      avio_skip(s->pb, -2);
> diff --git a/libavformat/xwma.c b/libavformat/xwma.c
> index 5a57caa841..c5e9db1e72 100644
> --- a/libavformat/xwma.c
> +++ b/libavformat/xwma.c
> @@ -78,7 +78,7 @@ static int xwma_read_header(AVFormatContext *s)
>      ret = ff_get_wav_header(s, pb, st->codecpar, size, 0);
>      if (ret < 0)
>          return ret;
> -    st->need_parsing = AVSTREAM_PARSE_NONE;
> +    st->internal->need_parsing = AVSTREAM_PARSE_NONE;
>  
>      /* XWMA encoder only allows a few channel/sample rate/bitrate combinations,
>       * but some create identical files with fake bitrate (1ch 22050hz at
>
Paul B Mahol Oct. 9, 2020, 6:35 p.m. UTC | #2
On Fri, Oct 09, 2020 at 04:36:27PM +0200, Andreas Rheinhardt wrote:
> Anton Khirnov:
> > Those are private fields, no reason to have them exposed in a public
> > header.
> > ---
> >  libavdevice/v4l2.c           |   2 +-
> 
> This is a problem: There is no requirement to update libavdevice at the
> same time as libavformat; one might use a newer version of libavformat
> together with an older version of libavdevice. This effectively makes
> the offsets of all the fields accessed by libavdevice avpriv, regardless
> of whether they are in AVStream or AVStreamInternal.

Then same can be said for libavcodec and libavformat, thus all my
contributions are thereby declared invalid.
Andreas Rheinhardt Oct. 9, 2020, 7 p.m. UTC | #3
Paul B Mahol:
> On Fri, Oct 09, 2020 at 04:36:27PM +0200, Andreas Rheinhardt wrote:
>> Anton Khirnov:
>>> Those are private fields, no reason to have them exposed in a public
>>> header.
>>> ---
>>>  libavdevice/v4l2.c           |   2 +-
>>
>> This is a problem: There is no requirement to update libavdevice at the
>> same time as libavformat; one might use a newer version of libavformat
>> together with an older version of libavdevice. This effectively makes
>> the offsets of all the fields accessed by libavdevice avpriv, regardless
>> of whether they are in AVStream or AVStreamInternal.
> 
> Then same can be said for libavcodec and libavformat, thus all my
> contributions are thereby declared invalid.

If any of your contributions accesses internal fields of libavcodec in
libavformat or vice versa, then yes. Do they? AFAIK no.
The libavformat/libavdevice situation meanwhile is special, because
libavdevice uses (and is supposed to use) internal fields of another
library and even defines its own instances of objects whose sizes are
not part of ABI/API (namely AVInputFormat and AVOutputFormat). This does
not happen with the other libraries as far as I see.

- Andreas
Anton Khirnov Oct. 11, 2020, 12:12 p.m. UTC | #4
Quoting Andreas Rheinhardt (2020-10-09 16:36:27)
> Anton Khirnov:
> > Those are private fields, no reason to have them exposed in a public
> > header.
> > ---
> >  libavdevice/v4l2.c           |   2 +-
> 
> This is a problem: There is no requirement to update libavdevice at the
> same time as libavformat; one might use a newer version of libavformat
> together with an older version of libavdevice. This effectively makes
> the offsets of all the fields accessed by libavdevice avpriv, regardless
> of whether they are in AVStream or AVStreamInternal.

Right. I wish avdevice was either purged from earth or merged into lavf,
in that order of preference.
Shall I postpone this patch until the bump then?

> > diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> > index 9c0b25d37b..b1aab0c8ea 100644
> > --- a/libavformat/avformat.h
> > +++ b/libavformat/avformat.h
> > @@ -1053,12 +1053,10 @@ typedef struct AVStream {
> >       */
> >      int codec_info_nb_frames;
> >  
> > -    /* av_read_frame() support */
> > -    enum AVStreamParseType need_parsing;
> 
> sizeof enum types is compiler-specific IIRC. Compilers may choose a type
> smaller than int if all the constants fit into a smaller type. Could
> this cause a problem here?

Theoretically, I guess. In practice, probably no.
But changed the type of unused8 to enum AVStreamParseType, just in case.

> 
> There is no need to keep the superfluous whitespace here and in the
> other places.

Ok, fixed locally.
James Almer Oct. 11, 2020, 1:14 p.m. UTC | #5
On 10/11/2020 9:12 AM, Anton Khirnov wrote:
> Quoting Andreas Rheinhardt (2020-10-09 16:36:27)
>> Anton Khirnov:
>>> Those are private fields, no reason to have them exposed in a public
>>> header.
>>> ---
>>>  libavdevice/v4l2.c           |   2 +-
>>
>> This is a problem: There is no requirement to update libavdevice at the
>> same time as libavformat; one might use a newer version of libavformat
>> together with an older version of libavdevice. This effectively makes
>> the offsets of all the fields accessed by libavdevice avpriv, regardless
>> of whether they are in AVStream or AVStreamInternal.
> 
> Right. I wish avdevice was either purged from earth or merged into lavf,

Merging it into lavf is for that matter the only proper way to remove
avdevice_register_all() while also maintaining the ability to select an
outdev in functions like av_guess_format(). So i wouldn't be against it.

> in that order of preference.
> Shall I postpone this patch until the bump then?
> 
>>> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
>>> index 9c0b25d37b..b1aab0c8ea 100644
>>> --- a/libavformat/avformat.h
>>> +++ b/libavformat/avformat.h
>>> @@ -1053,12 +1053,10 @@ typedef struct AVStream {
>>>       */
>>>      int codec_info_nb_frames;
>>>  
>>> -    /* av_read_frame() support */
>>> -    enum AVStreamParseType need_parsing;
>>
>> sizeof enum types is compiler-specific IIRC. Compilers may choose a type
>> smaller than int if all the constants fit into a smaller type. Could
>> this cause a problem here?
> 
> Theoretically, I guess. In practice, probably no.
> But changed the type of unused8 to enum AVStreamParseType, just in case.
> 
>>
>> There is no need to keep the superfluous whitespace here and in the
>> other places.
> 
> Ok, fixed locally.
>
James Almer Oct. 11, 2020, 1:29 p.m. UTC | #6
On 10/11/2020 9:12 AM, Anton Khirnov wrote:
> Quoting Andreas Rheinhardt (2020-10-09 16:36:27)
>> Anton Khirnov:
>>> Those are private fields, no reason to have them exposed in a public
>>> header.
>>> ---
>>>  libavdevice/v4l2.c           |   2 +-
>>
>> This is a problem: There is no requirement to update libavdevice at the
>> same time as libavformat; one might use a newer version of libavformat
>> together with an older version of libavdevice. This effectively makes
>> the offsets of all the fields accessed by libavdevice avpriv, regardless
>> of whether they are in AVStream or AVStreamInternal.
> 
> Right. I wish avdevice was either purged from earth or merged into lavf,
> in that order of preference.
> Shall I postpone this patch until the bump then?

That depends on if we plan to make a last release before the bump or
not. If we do then you should apply it after the branch is cut, and if
not then doing it now is fine, since it will make no difference whatsoever.

> 
>>> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
>>> index 9c0b25d37b..b1aab0c8ea 100644
>>> --- a/libavformat/avformat.h
>>> +++ b/libavformat/avformat.h
>>> @@ -1053,12 +1053,10 @@ typedef struct AVStream {
>>>       */
>>>      int codec_info_nb_frames;
>>>  
>>> -    /* av_read_frame() support */
>>> -    enum AVStreamParseType need_parsing;
>>
>> sizeof enum types is compiler-specific IIRC. Compilers may choose a type
>> smaller than int if all the constants fit into a smaller type. Could
>> this cause a problem here?
> 
> Theoretically, I guess. In practice, probably no.
> But changed the type of unused8 to enum AVStreamParseType, just in case.
> 
>>
>> There is no need to keep the superfluous whitespace here and in the
>> other places.
> 
> Ok, fixed locally.
>
Michael Niedermayer Oct. 11, 2020, 6:28 p.m. UTC | #7
On Sun, Oct 11, 2020 at 10:14:39AM -0300, James Almer wrote:
> On 10/11/2020 9:12 AM, Anton Khirnov wrote:
> > Quoting Andreas Rheinhardt (2020-10-09 16:36:27)
> >> Anton Khirnov:
> >>> Those are private fields, no reason to have them exposed in a public
> >>> header.
> >>> ---
> >>>  libavdevice/v4l2.c           |   2 +-
> >>
> >> This is a problem: There is no requirement to update libavdevice at the
> >> same time as libavformat; one might use a newer version of libavformat
> >> together with an older version of libavdevice. This effectively makes
> >> the offsets of all the fields accessed by libavdevice avpriv, regardless
> >> of whether they are in AVStream or AVStreamInternal.
> > 
> > Right. I wish avdevice was either purged from earth or merged into lavf,
> 
> Merging it into lavf is for that matter the only proper way to remove
> avdevice_register_all() while also maintaining the ability to select an
> outdev in functions like av_guess_format(). So i wouldn't be against it.

The situation with a single API+ABI shared by 2 libs with their own soname
is bad.
lavd either needs an independant API thats designed for devices (which is
probably more a medium to long term effort)
OR
lavd should be merged with lavf (as suggested)
so i agree such a merge seems like the best choice

thx

[...]
Nicolas George Oct. 11, 2020, 6:50 p.m. UTC | #8
Michael Niedermayer (12020-10-11):
> The situation with a single API+ABI shared by 2 libs with their own soname
> is bad.
> lavd either needs an independant API thats designed for devices (which is
> probably more a medium to long term effort)

This would be a terrible idea. Being functionally a part of lavf, with
the same API is an essential feature of lavd: it is what allows users to
use devices with applications that are designed for files. Otherwise,
lavd would only be usable with applications meant for it, i.e. none.

> OR
> lavd should be merged with lavf (as suggested)
> so i agree such a merge seems like the best choice

Regards,
Michael Niedermayer Oct. 11, 2020, 10:26 p.m. UTC | #9
On Sun, Oct 11, 2020 at 08:50:50PM +0200, Nicolas George wrote:
> Michael Niedermayer (12020-10-11):
> > The situation with a single API+ABI shared by 2 libs with their own soname
> > is bad.
> > lavd either needs an independant API thats designed for devices (which is
> > probably more a medium to long term effort)
> 
> This would be a terrible idea. Being functionally a part of lavf, with
> the same API is an essential feature of lavd: it is what allows users to
> use devices with applications that are designed for files. Otherwise,
> lavd would only be usable with applications meant for it, i.e. none.

I dont think that what i suggested leads to what you describe here.

For example
Lets consider a hypothetical lavd with a API/ABI thats designed more towards
devices than (de)muxers.
lavf can depend on lavd and provide each device from lavd as a (de)muxer in
lavf too. That can even be in a 1 to 1 match or a single lavf (de)muxer with
an option to choose which device to map to.

These would maintain the device availability for existing applications.
While it would avoid requireing access to devices through the (de)muxer
interface.
Some people and maybe most people dislike that interface for devices.

I think you too want lavd to be something an author of a simple media
player considers. 
While ATM i think people consider variuous things but skip lavd as it
doesnt feel as an equal to the other choices.

thx

[...]
diff mbox series

Patch

diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 365bacd771..960929aec3 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -961,7 +961,7 @@  static int v4l2_read_header(AVFormatContext *ctx)
         st->codecpar->codec_tag =
             avcodec_pix_fmt_to_codec_tag(st->codecpar->format);
     else if (codec_id == AV_CODEC_ID_H264) {
-        st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
+        st->internal->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
     }
     if (desired_format == V4L2_PIX_FMT_YVU420)
         st->codecpar->codec_tag = MKTAG('Y', 'V', '1', '2');
diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
index a0aa112a8a..70427e222b 100644
--- a/libavformat/aacdec.c
+++ b/libavformat/aacdec.c
@@ -112,7 +112,7 @@  static int adts_aac_read_header(AVFormatContext *s)
 
     st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
     st->codecpar->codec_id   = s->iformat->raw_codec_id;
-    st->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
+    st->internal->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
 
     ff_id3v1_read(s);
     if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
diff --git a/libavformat/aadec.c b/libavformat/aadec.c
index 63f8176a57..7ada6ab07a 100644
--- a/libavformat/aadec.c
+++ b/libavformat/aadec.c
@@ -182,7 +182,7 @@  static int aa_read_header(AVFormatContext *s)
     if (!strcmp(codec_name, "mp332")) {
         st->codecpar->codec_id = AV_CODEC_ID_MP3;
         st->codecpar->sample_rate = 22050;
-        st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+        st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
         avpriv_set_pts_info(st, 64, 8, 32000 * TIMEPREC);
         // encoded audio frame is MP3_FRAME_SIZE bytes (+1 with padding, unlikely)
     } else if (!strcmp(codec_name, "acelp85")) {
@@ -191,7 +191,7 @@  static int aa_read_header(AVFormatContext *s)
         st->codecpar->channels = 1;
         st->codecpar->sample_rate = 8500;
         st->codecpar->bit_rate = 8500;
-        st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+        st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
         avpriv_set_pts_info(st, 64, 8, 8500 * TIMEPREC);
     } else if (!strcmp(codec_name, "acelp16")) {
         st->codecpar->codec_id = AV_CODEC_ID_SIPR;
@@ -199,7 +199,7 @@  static int aa_read_header(AVFormatContext *s)
         st->codecpar->channels = 1;
         st->codecpar->sample_rate = 16000;
         st->codecpar->bit_rate = 16000;
-        st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+        st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
         avpriv_set_pts_info(st, 64, 8, 16000 * TIMEPREC);
     }
 
diff --git a/libavformat/acm.c b/libavformat/acm.c
index 5e03cf8bff..91f14e43aa 100644
--- a/libavformat/acm.c
+++ b/libavformat/acm.c
@@ -54,7 +54,7 @@  static int acm_read_header(AVFormatContext *s)
         return AVERROR_INVALIDDATA;
     st->start_time         = 0;
     st->duration           = AV_RL32(st->codecpar->extradata +  4) / st->codecpar->channels;
-    st->need_parsing       = AVSTREAM_PARSE_FULL_RAW;
+    st->internal->need_parsing       = AVSTREAM_PARSE_FULL_RAW;
     avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
 
     return 0;
diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index deb7c266ed..402ccaac78 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -483,9 +483,9 @@  static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
             st->codecpar->codec_tag = 0;
         }
         if (st->codecpar->codec_id == AV_CODEC_ID_AAC)
-            st->need_parsing = AVSTREAM_PARSE_NONE;
+            st->internal->need_parsing = AVSTREAM_PARSE_NONE;
         else
-            st->need_parsing = AVSTREAM_PARSE_FULL;
+            st->internal->need_parsing = AVSTREAM_PARSE_FULL;
         /* We have to init the frame size at some point .... */
         pos2 = avio_tell(pb);
         if (size >= (pos2 + 8 - pos1 + 24)) {
@@ -542,7 +542,7 @@  static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
         st->codecpar->codec_tag = tag1;
         st->codecpar->codec_id  = ff_codec_get_id(ff_codec_bmp_tags, tag1);
         if (tag1 == MKTAG('D', 'V', 'R', ' ')) {
-            st->need_parsing = AVSTREAM_PARSE_FULL;
+            st->internal->need_parsing = AVSTREAM_PARSE_FULL;
             /* issue658 contains wrong w/h and MS even puts a fake seq header
              * with wrong w/h in extradata while a correct one is in the stream.
              * maximum lameness */
@@ -552,9 +552,9 @@  static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
             st->codecpar->extradata_size = 0;
         }
         if (st->codecpar->codec_id == AV_CODEC_ID_H264)
-            st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
+            st->internal->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
         if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4)
-            st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
+            st->internal->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
     }
     pos2 = avio_tell(pb);
     avio_skip(pb, size - (pos2 - pos1 + 24));
diff --git a/libavformat/av1dec.c b/libavformat/av1dec.c
index 10c4560968..ad2837c831 100644
--- a/libavformat/av1dec.c
+++ b/libavformat/av1dec.c
@@ -66,7 +66,7 @@  static int read_header(AVFormatContext *s, const AVRational *framerate, AVBSFCon
 
     st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codecpar->codec_id = AV_CODEC_ID_AV1;
-    st->need_parsing = AVSTREAM_PARSE_HEADERS;
+    st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
 
     st->internal->avctx->framerate = *framerate;
     // taken from rawvideo demuxers
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 9c0b25d37b..b1aab0c8ea 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1053,12 +1053,10 @@  typedef struct AVStream {
      */
     int codec_info_nb_frames;
 
-    /* av_read_frame() support */
-    enum AVStreamParseType need_parsing;
-    struct AVCodecParserContext *parser;
-
 #if LIBAVFORMAT_VERSION_MAJOR < 59
     // kept for ABI compatibility only, do not access in any way
+    int          unused8;
+    void        *unused9;
     void        *unused7;
     AVProbeData  unused6;
     int64_t      unused5[16+1];
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 80e5563bc6..bcea7f865e 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -815,19 +815,19 @@  static int avi_read_header(AVFormatContext *s)
 
                     /* This is needed to get the pict type which is necessary
                      * for generating correct pts. */
-                    st->need_parsing = AVSTREAM_PARSE_HEADERS;
+                    st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
 
                     if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4 &&
                         ast->handler == MKTAG('X', 'V', 'I', 'D'))
                         st->codecpar->codec_tag = MKTAG('X', 'V', 'I', 'D');
 
                     if (st->codecpar->codec_tag == MKTAG('V', 'S', 'S', 'H'))
-                        st->need_parsing = AVSTREAM_PARSE_FULL;
+                        st->internal->need_parsing = AVSTREAM_PARSE_FULL;
                     if (st->codecpar->codec_id == AV_CODEC_ID_RV40)
-                        st->need_parsing = AVSTREAM_PARSE_NONE;
+                        st->internal->need_parsing = AVSTREAM_PARSE_NONE;
                     if (st->codecpar->codec_id == AV_CODEC_ID_HEVC &&
                         st->codecpar->codec_tag == MKTAG('H', '2', '6', '5'))
-                        st->need_parsing = AVSTREAM_PARSE_FULL;
+                        st->internal->need_parsing = AVSTREAM_PARSE_FULL;
 
                     if (st->codecpar->codec_tag == 0 && st->codecpar->height > 0 &&
                         st->codecpar->extradata_size < 1U << 30) {
@@ -865,16 +865,16 @@  static int avi_read_header(AVFormatContext *s)
                         avio_skip(pb, 1);
                     /* Force parsing as several audio frames can be in
                      * one packet and timestamps refer to packet start. */
-                    st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
+                    st->internal->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
                     /* ADTS header is in extradata, AAC without header must be
                      * stored as exact frames. Parser not needed and it will
                      * fail. */
                     if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
                         st->codecpar->extradata_size)
-                        st->need_parsing = AVSTREAM_PARSE_NONE;
+                        st->internal->need_parsing = AVSTREAM_PARSE_NONE;
                     // The flac parser does not work with AVSTREAM_PARSE_TIMESTAMPS
                     if (st->codecpar->codec_id == AV_CODEC_ID_FLAC)
-                        st->need_parsing = AVSTREAM_PARSE_NONE;
+                        st->internal->need_parsing = AVSTREAM_PARSE_NONE;
                     /* AVI files with Xan DPCM audio (wrongly) declare PCM
                      * audio in the header but have Axan as stream_code_tag. */
                     if (ast->handler == AV_RL32("Axan")) {
@@ -1029,7 +1029,7 @@  end_of_header:
             AVStream *st = s->streams[i];
             if (   st->codecpar->codec_id == AV_CODEC_ID_MPEG1VIDEO
                 || st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO)
-                st->need_parsing = AVSTREAM_PARSE_FULL;
+                st->internal->need_parsing = AVSTREAM_PARSE_FULL;
         }
 
     for (i = 0; i < s->nb_streams; i++) {
diff --git a/libavformat/dtshddec.c b/libavformat/dtshddec.c
index b1eb7ffb2c..deb341cde9 100644
--- a/libavformat/dtshddec.c
+++ b/libavformat/dtshddec.c
@@ -65,7 +65,7 @@  static int dtshd_read_header(AVFormatContext *s)
         return AVERROR(ENOMEM);
     st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
     st->codecpar->codec_id   = AV_CODEC_ID_DTS;
-    st->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
+    st->internal->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
 
     for (;;) {
         chunk_type = avio_rb64(pb);
diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c
index d0f483aaf9..dcfd972f49 100644
--- a/libavformat/electronicarts.c
+++ b/libavformat/electronicarts.c
@@ -503,7 +503,7 @@  static int init_video_stream(AVFormatContext *s, VideoProperties *video)
     st->codecpar->codec_id    = video->codec;
     // parsing is necessary to make FFmpeg generate correct timestamps
     if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO)
-        st->need_parsing = AVSTREAM_PARSE_HEADERS;
+        st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
     st->codecpar->codec_tag   = 0; /* no fourcc */
     st->codecpar->width       = video->width;
     st->codecpar->height      = video->height;
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index 6aca4755a1..e7a418a3b3 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -56,7 +56,7 @@  static int flac_read_header(AVFormatContext *s)
         return AVERROR(ENOMEM);
     st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
     st->codecpar->codec_id = AV_CODEC_ID_FLAC;
-    st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+    st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
     /* the parameters will be extracted from the compressed bitstream */
 
     /* if fLaC marker is not found, assume there is no header */
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 6bddcbb556..30dd9cdcec 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -269,7 +269,7 @@  static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream,
         break;
     case FLV_CODECID_MP3:
         apar->codec_id      = AV_CODEC_ID_MP3;
-        astream->need_parsing = AVSTREAM_PARSE_FULL;
+        astream->internal->need_parsing = AVSTREAM_PARSE_FULL;
         break;
     case FLV_CODECID_NELLYMOSER_8KHZ_MONO:
         // in case metadata does not otherwise declare samplerate
@@ -360,7 +360,7 @@  static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream,
         break;
     case FLV_CODECID_H264:
         par->codec_id = AV_CODEC_ID_H264;
-        vstream->need_parsing = AVSTREAM_PARSE_HEADERS;
+        vstream->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
         ret = 3;     // not 4, reading packet type will consume one byte
         break;
     case FLV_CODECID_MPEG4:
diff --git a/libavformat/gxf.c b/libavformat/gxf.c
index 96b7035386..1409895d3a 100644
--- a/libavformat/gxf.c
+++ b/libavformat/gxf.c
@@ -130,13 +130,13 @@  static int get_sindex(AVFormatContext *s, int id, int format) {
         case 20:
             st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
             st->codecpar->codec_id = AV_CODEC_ID_MPEG2VIDEO;
-            st->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
+            st->internal->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
             break;
         case 22:
         case 23:
             st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
             st->codecpar->codec_id = AV_CODEC_ID_MPEG1VIDEO;
-            st->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
+            st->internal->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
             break;
         case 9:
             st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
@@ -169,7 +169,7 @@  static int get_sindex(AVFormatContext *s, int id, int format) {
         case 29: /* AVCHD */
             st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
             st->codecpar->codec_id = AV_CODEC_ID_H264;
-            st->need_parsing = AVSTREAM_PARSE_HEADERS;
+            st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
             break;
         // timecode tracks:
         case 7:
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 3f217d5916..9dc0414efe 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -209,7 +209,7 @@  int ff_img_read_header(AVFormatContext *s1)
         s->is_pipe = 0;
     else {
         s->is_pipe       = 1;
-        st->need_parsing = AVSTREAM_PARSE_FULL;
+        st->internal->need_parsing = AVSTREAM_PARSE_FULL;
     }
 
     if (s->ts_from_file == 2) {
@@ -479,7 +479,7 @@  int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
             return AVERROR_EOF;
         if (s->frame_size > 0) {
             size[0] = s->frame_size;
-        } else if (!s1->streams[0]->parser) {
+        } else if (!s1->streams[0]->internal->parser) {
             size[0] = avio_size(s1->pb);
         } else {
             size[0] = 4096;
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 49e82bfbca..496bd46ef0 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -343,6 +343,10 @@  struct AVStreamInternal {
      * last packet in packet_buffer for this stream when muxing.
      */
     struct AVPacketList *last_in_packet_buffer;
+
+    /* av_read_frame() support */
+    enum AVStreamParseType need_parsing;
+    struct AVCodecParserContext *parser;
 };
 
 #ifdef __GNUC__
diff --git a/libavformat/ipudec.c b/libavformat/ipudec.c
index df53df00d9..281ec66340 100644
--- a/libavformat/ipudec.c
+++ b/libavformat/ipudec.c
@@ -62,7 +62,7 @@  static int ipu_read_header(AVFormatContext *s)
     st->start_time         = 0;
     st->duration           =
     st->nb_frames          = avio_rl32(pb);
-    st->need_parsing       = AVSTREAM_PARSE_FULL_RAW;
+    st->internal->need_parsing       = AVSTREAM_PARSE_FULL_RAW;
     avpriv_set_pts_info(st, 64, 1, 25);
 
     return 0;
diff --git a/libavformat/iv8.c b/libavformat/iv8.c
index e25f24eeb9..03cfe9baaa 100644
--- a/libavformat/iv8.c
+++ b/libavformat/iv8.c
@@ -47,7 +47,7 @@  static int read_header(AVFormatContext *s)
 
     st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codecpar->codec_id = AV_CODEC_ID_MPEG4;
-    st->need_parsing = AVSTREAM_PARSE_FULL;
+    st->internal->need_parsing = AVSTREAM_PARSE_FULL;
     avpriv_set_pts_info(st, 64, 1, 90000);
 
     return 0;
diff --git a/libavformat/ivfdec.c b/libavformat/ivfdec.c
index 4a802573e7..8f089f9c42 100644
--- a/libavformat/ivfdec.c
+++ b/libavformat/ivfdec.c
@@ -56,7 +56,7 @@  static int read_header(AVFormatContext *s)
     st->duration          = avio_rl32(s->pb);
     avio_skip(s->pb, 4); // unused
 
-    st->need_parsing      = AVSTREAM_PARSE_HEADERS;
+    st->internal->need_parsing      = AVSTREAM_PARSE_HEADERS;
 
     if (!time_base.den || !time_base.num) {
         av_log(s, AV_LOG_ERROR, "Invalid frame rate\n");
diff --git a/libavformat/lmlm4.c b/libavformat/lmlm4.c
index 79d703a8fc..c2490c94ec 100644
--- a/libavformat/lmlm4.c
+++ b/libavformat/lmlm4.c
@@ -67,14 +67,14 @@  static int lmlm4_read_header(AVFormatContext *s)
         return AVERROR(ENOMEM);
     st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codecpar->codec_id   = AV_CODEC_ID_MPEG4;
-    st->need_parsing      = AVSTREAM_PARSE_HEADERS;
+    st->internal->need_parsing      = AVSTREAM_PARSE_HEADERS;
     avpriv_set_pts_info(st, 64, 1001, 30000);
 
     if (!(st = avformat_new_stream(s, NULL)))
         return AVERROR(ENOMEM);
     st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
     st->codecpar->codec_id   = AV_CODEC_ID_MP2;
-    st->need_parsing      = AVSTREAM_PARSE_HEADERS;
+    st->internal->need_parsing      = AVSTREAM_PARSE_HEADERS;
 
     /* the parameters will be extracted from the compressed bitstream */
     return 0;
diff --git a/libavformat/loasdec.c b/libavformat/loasdec.c
index e166a5928a..b39dbb8a44 100644
--- a/libavformat/loasdec.c
+++ b/libavformat/loasdec.c
@@ -75,7 +75,7 @@  static int loas_read_header(AVFormatContext *s)
 
     st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
     st->codecpar->codec_id = s->iformat->raw_codec_id;
-    st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+    st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
 
     //LCM of all possible AAC sample rates
     avpriv_set_pts_info(st, 64, 1, 28224000);
diff --git a/libavformat/lxfdec.c b/libavformat/lxfdec.c
index fa84ceea78..526d652f43 100644
--- a/libavformat/lxfdec.c
+++ b/libavformat/lxfdec.c
@@ -260,7 +260,7 @@  static int lxf_read_header(AVFormatContext *s)
     st->codecpar->bit_rate   = 1000000 * ((video_params >> 14) & 0xFF);
     st->codecpar->codec_tag  = video_params & 0xF;
     st->codecpar->codec_id   = ff_codec_get_id(lxf_tags, st->codecpar->codec_tag);
-    st->need_parsing         = AVSTREAM_PARSE_HEADERS;
+    st->internal->need_parsing         = AVSTREAM_PARSE_HEADERS;
 
     av_log(s, AV_LOG_DEBUG, "record: %x = %i-%02i-%02i\n",
            record_date, 1900 + (record_date & 0x7F), (record_date >> 7) & 0xF,
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 981e044263..98214e1222 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2734,7 +2734,7 @@  static int matroska_parse_tracks(AVFormatContext *s)
                           255);
             }
             if (st->codecpar->codec_id != AV_CODEC_ID_HEVC)
-                st->need_parsing = AVSTREAM_PARSE_HEADERS;
+                st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
 
             if (track->default_duration) {
                 av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
@@ -2792,9 +2792,9 @@  static int matroska_parse_tracks(AVFormatContext *s)
             if (st->codecpar->codec_id == AV_CODEC_ID_MP3 ||
                 st->codecpar->codec_id == AV_CODEC_ID_MLP ||
                 st->codecpar->codec_id == AV_CODEC_ID_TRUEHD)
-                st->need_parsing = AVSTREAM_PARSE_FULL;
+                st->internal->need_parsing = AVSTREAM_PARSE_FULL;
             else if (st->codecpar->codec_id != AV_CODEC_ID_AAC)
-                st->need_parsing = AVSTREAM_PARSE_HEADERS;
+                st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
             if (track->codec_delay > 0) {
                 st->codecpar->initial_padding = av_rescale_q(track->codec_delay,
                                                              (AVRational){1, 1000000000},
diff --git a/libavformat/mgsts.c b/libavformat/mgsts.c
index 415e052725..6b0a748b77 100644
--- a/libavformat/mgsts.c
+++ b/libavformat/mgsts.c
@@ -50,7 +50,7 @@  static int read_header(AVFormatContext *s)
     if (!st)
         return AVERROR(ENOMEM);
 
-    st->need_parsing = AVSTREAM_PARSE_HEADERS;
+    st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
     st->start_time = 0;
     st->nb_frames  =
     st->duration   = avio_rb32(pb);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 57ac212146..a41c358a2a 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2165,7 +2165,7 @@  static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb,
             switch (st->codecpar->codec_id) {
             case AV_CODEC_ID_MP2:
             case AV_CODEC_ID_MP3:
-                st->need_parsing = AVSTREAM_PARSE_FULL;
+                st->internal->need_parsing = AVSTREAM_PARSE_FULL;
                 break;
             }
         }
@@ -2421,10 +2421,10 @@  static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb,
     case AV_CODEC_ID_VC1:
     case AV_CODEC_ID_VP8:
     case AV_CODEC_ID_VP9:
-        st->need_parsing = AVSTREAM_PARSE_FULL;
+        st->internal->need_parsing = AVSTREAM_PARSE_FULL;
         break;
     case AV_CODEC_ID_AV1:
-        st->need_parsing = AVSTREAM_PARSE_HEADERS;
+        st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
         break;
     default:
         break;
@@ -2768,8 +2768,8 @@  static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     if (!entries) {
         sc->keyframe_absent = 1;
-        if (!st->need_parsing && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
-            st->need_parsing = AVSTREAM_PARSE_HEADERS;
+        if (!st->internal->need_parsing && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+            st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
         return 0;
     }
     if (sc->keyframes)
@@ -4312,7 +4312,7 @@  static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         && sc->stts_count > 3
         && sc->stts_count*10 > st->nb_frames
         && sc->time_scale == st->codecpar->sample_rate) {
-            st->need_parsing = AVSTREAM_PARSE_FULL;
+            st->internal->need_parsing = AVSTREAM_PARSE_FULL;
     }
     /* Do not need those anymore. */
     av_freep(&sc->chunk_offsets);
@@ -7634,7 +7634,7 @@  static int mov_read_header(AVFormatContext *s)
             mov->handbrake_version <= 1000000*0 + 1000*10 + 2 &&  // 0.10.2
             st->codecpar->codec_id == AV_CODEC_ID_MP3) {
             av_log(s, AV_LOG_VERBOSE, "Forcing full parsing for mp3 stream\n");
-            st->need_parsing = AVSTREAM_PARSE_FULL;
+            st->internal->need_parsing = AVSTREAM_PARSE_FULL;
         }
     }
 
@@ -7940,9 +7940,9 @@  static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
                 sc->has_palette = 0;
             }
         }
-        if (st->codecpar->codec_id == AV_CODEC_ID_MP3 && !st->need_parsing && pkt->size > 4) {
+        if (st->codecpar->codec_id == AV_CODEC_ID_MP3 && !st->internal->need_parsing && pkt->size > 4) {
             if (ff_mpa_check_header(AV_RB32(pkt->data)) < 0)
-                st->need_parsing = AVSTREAM_PARSE_FULL;
+                st->internal->need_parsing = AVSTREAM_PARSE_FULL;
         }
     }
 
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 53f803ef55..fe12cd4fc7 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -374,7 +374,7 @@  static int mp3_read_header(AVFormatContext *s)
 
     st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
     st->codecpar->codec_id = AV_CODEC_ID_MP3;
-    st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+    st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
     st->start_time = 0;
 
     // lcm of all mp3 sample rates
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 20d1e10168..c25d76fc60 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -623,7 +623,7 @@  skip:
         st->codecpar->sample_rate = 8000;
     }
     st->internal->request_probe     = request_probe;
-    st->need_parsing      = AVSTREAM_PARSE_FULL;
+    st->internal->need_parsing      = AVSTREAM_PARSE_FULL;
 
 found:
     if (st->discard >= AVDISCARD_ALL)
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 7cf14a1d13..6135d05477 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -903,7 +903,7 @@  static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
     st->priv_data         = pes;
     st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
     st->codecpar->codec_id   = AV_CODEC_ID_NONE;
-    st->need_parsing      = AVSTREAM_PARSE_FULL;
+    st->internal->need_parsing      = AVSTREAM_PARSE_FULL;
     pes->st          = st;
     pes->stream_type = stream_type;
 
@@ -941,7 +941,7 @@  static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
             sub_st->priv_data         = sub_pes;
             sub_st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
             sub_st->codecpar->codec_id   = AV_CODEC_ID_AC3;
-            sub_st->need_parsing      = AVSTREAM_PARSE_FULL;
+            sub_st->internal->need_parsing      = AVSTREAM_PARSE_FULL;
             sub_pes->sub_st           = pes->sub_st = sub_st;
         }
     }
@@ -1716,10 +1716,10 @@  static void m4sl_cb(MpegTSFilter *filter, const uint8_t *section,
             ff_mp4_read_dec_config_descr(s, st, &pb);
             if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
                 st->codecpar->extradata_size > 0)
-                st->need_parsing = 0;
+                st->internal->need_parsing = 0;
             if (st->codecpar->codec_id == AV_CODEC_ID_H264 &&
                 st->codecpar->extradata_size > 0)
-                st->need_parsing = 0;
+                st->internal->need_parsing = 0;
 
             st->codecpar->codec_type = avcodec_get_type(st->codecpar->codec_id);
             st->internal->need_context_update = 1;
@@ -1825,7 +1825,7 @@  int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
                 ff_mp4_read_dec_config_descr(fc, st, &pb);
                 if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
                     st->codecpar->extradata_size > 0) {
-                    st->need_parsing = 0;
+                    st->internal->need_parsing = 0;
                     st->internal->need_context_update = 1;
                 }
                 if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4SYSTEMS)
@@ -1847,7 +1847,7 @@  int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
             ff_mp4_read_dec_config_descr(fc, st, &pb);
             if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
                 st->codecpar->extradata_size > 0) {
-                st->internal->request_probe = st->need_parsing = 0;
+                st->internal->request_probe = st->internal->need_parsing = 0;
                 st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
                 st->internal->need_context_update = 1;
             }
@@ -2032,7 +2032,7 @@  int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
                 } else {
                     avpriv_request_sample(fc, "Opus in MPEG-TS - channel_config_code > 0x8");
                 }
-                st->need_parsing = AVSTREAM_PARSE_FULL;
+                st->internal->need_parsing = AVSTREAM_PARSE_FULL;
                 st->internal->need_context_update = 1;
             }
         }
diff --git a/libavformat/msf.c b/libavformat/msf.c
index 155f488e44..0927af43ff 100644
--- a/libavformat/msf.c
+++ b/libavformat/msf.c
@@ -80,7 +80,7 @@  static int msf_read_header(AVFormatContext *s)
             AV_WL16(st->codecpar->extradata+8, codec == 4 ? 1 : 0); /* joint stereo (repeat?) */
             AV_WL16(st->codecpar->extradata+10, 1);
             st->codecpar->codec_id = AV_CODEC_ID_ATRAC3;    break;
-    case 7: st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+    case 7: st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
             st->codecpar->codec_id = AV_CODEC_ID_MP3;       break;
     default:
             avpriv_request_sample(s, "Codec %d", codec);
diff --git a/libavformat/mtv.c b/libavformat/mtv.c
index e731d91077..6526caded2 100644
--- a/libavformat/mtv.c
+++ b/libavformat/mtv.c
@@ -185,7 +185,7 @@  static int mtv_read_header(AVFormatContext *s)
     st->codecpar->codec_type      = AVMEDIA_TYPE_AUDIO;
     st->codecpar->codec_id        = AV_CODEC_ID_MP3;
     st->codecpar->bit_rate        = mtv->audio_br;
-    st->need_parsing              = AVSTREAM_PARSE_FULL;
+    st->internal->need_parsing              = AVSTREAM_PARSE_FULL;
 
     // Jump over header
 
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 1f79f3d3cd..f9097a01a0 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -2578,7 +2578,7 @@  static int mxf_parse_structural_metadata(MXFContext *mxf)
                     }
                 }
             }
-            st->need_parsing = AVSTREAM_PARSE_HEADERS;
+            st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
             if (material_track->sequence->origin) {
                 av_dict_set_int(&st->metadata, "material_track_origin", material_track->sequence->origin, 0);
             }
@@ -2643,7 +2643,7 @@  static int mxf_parse_structural_metadata(MXFContext *mxf)
                 else if (descriptor->bits_per_sample == 32)
                     st->codecpar->codec_id = AV_CODEC_ID_PCM_S32BE;
             } else if (st->codecpar->codec_id == AV_CODEC_ID_MP2) {
-                st->need_parsing = AVSTREAM_PARSE_FULL;
+                st->internal->need_parsing = AVSTREAM_PARSE_FULL;
             }
             st->codecpar->bits_per_coded_sample = av_get_bits_per_sample(st->codecpar->codec_id);
         } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
@@ -2677,7 +2677,7 @@  static int mxf_parse_structural_metadata(MXFContext *mxf)
         }
         if (st->codecpar->codec_type != AVMEDIA_TYPE_DATA && source_track->wrapping != FrameWrapped) {
             /* TODO: decode timestamps */
-            st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
+            st->internal->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
         }
     }
 
@@ -3612,7 +3612,7 @@  static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
                 if (next_ofs <= 0) {
                     // If we have no way to packetize the data, then return it in chunks...
                     if (klv.next_klv - klv.length == pos && max_data_size > MXF_MAX_CHUNK_SIZE) {
-                        st->need_parsing = AVSTREAM_PARSE_FULL;
+                        st->internal->need_parsing = AVSTREAM_PARSE_FULL;
                         avpriv_request_sample(s, "Huge KLV without proper index in non-frame wrapped essence");
                     }
                     size = FFMIN(max_data_size, MXF_MAX_CHUNK_SIZE);
diff --git a/libavformat/ncdec.c b/libavformat/ncdec.c
index f2066b485a..b2d033bc6e 100644
--- a/libavformat/ncdec.c
+++ b/libavformat/ncdec.c
@@ -53,7 +53,7 @@  static int nc_read_header(AVFormatContext *s)
 
     st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codecpar->codec_id   = AV_CODEC_ID_MPEG4;
-    st->need_parsing      = AVSTREAM_PARSE_FULL;
+    st->internal->need_parsing      = AVSTREAM_PARSE_FULL;
 
     avpriv_set_pts_info(st, 64, 1, 100);
 
diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c
index 4fab52ed36..376ed76534 100644
--- a/libavformat/nsvdec.c
+++ b/libavformat/nsvdec.c
@@ -462,7 +462,7 @@  static int nsv_parse_NSVs_header(AVFormatContext *s)
             st->codecpar->codec_tag = atag;
             st->codecpar->codec_id = ff_codec_get_id(nsv_codec_audio_tags, atag);
 
-            st->need_parsing = AVSTREAM_PARSE_FULL; /* for PCM we will read a chunk later and put correct info */
+            st->internal->need_parsing = AVSTREAM_PARSE_FULL; /* for PCM we will read a chunk later and put correct info */
 
             /* set timebase to common denominator of ms and framerate */
             avpriv_set_pts_info(st, 64, 1, framerate.num*1000);
@@ -615,7 +615,7 @@  null_chunk_retry:
             asize-=4;
             av_log(s, AV_LOG_TRACE, "NSV RAWAUDIO: bps %d, nchan %d, srate %d\n", bps, channels, samplerate);
             if (fill_header) {
-                st[NSV_ST_AUDIO]->need_parsing = AVSTREAM_PARSE_NONE; /* we know everything */
+                st[NSV_ST_AUDIO]->internal->need_parsing = AVSTREAM_PARSE_NONE; /* we know everything */
                 if (bps != 16) {
                     av_log(s, AV_LOG_TRACE, "NSV AUDIO bit/sample != 16 (%d)!!!\n", bps);
                 }
diff --git a/libavformat/nuv.c b/libavformat/nuv.c
index d99770d41d..8ebcdddce4 100644
--- a/libavformat/nuv.c
+++ b/libavformat/nuv.c
@@ -128,7 +128,7 @@  static int get_codec_data(AVFormatContext *s, AVIOContext *pb, AVStream *vst,
                 }
                 ast->codecpar->codec_id = id;
 
-                ast->need_parsing = AVSTREAM_PARSE_FULL;
+                ast->internal->need_parsing = AVSTREAM_PARSE_FULL;
             } else
                 avio_skip(pb, 4 * 4);
 
diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
index 4e85b05c67..15eeca56aa 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/oggparseflac.c
@@ -59,7 +59,7 @@  flac_header (AVFormatContext * s, int idx)
 
         st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
         st->codecpar->codec_id = AV_CODEC_ID_FLAC;
-        st->need_parsing = AVSTREAM_PARSE_HEADERS;
+        st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
 
         if ((ret = ff_alloc_extradata(st->codecpar, FLAC_STREAMINFO_SIZE)) < 0)
             return ret;
diff --git a/libavformat/oggparseogm.c b/libavformat/oggparseogm.c
index 469b229995..a8319b9dfa 100644
--- a/libavformat/oggparseogm.c
+++ b/libavformat/oggparseogm.c
@@ -60,7 +60,7 @@  ogm_header(AVFormatContext *s, int idx)
             st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag);
             st->codecpar->codec_tag = tag;
             if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4)
-                st->need_parsing = AVSTREAM_PARSE_HEADERS;
+                st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
         } else if (bytestream2_peek_byte(&p) == 't') {
             st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
             st->codecpar->codec_id = AV_CODEC_ID_TEXT;
@@ -76,7 +76,7 @@  ogm_header(AVFormatContext *s, int idx)
             st->codecpar->codec_id = ff_codec_get_id(ff_codec_wav_tags, cid);
             // our parser completely breaks AAC in Ogg
             if (st->codecpar->codec_id != AV_CODEC_ID_AAC)
-                st->need_parsing = AVSTREAM_PARSE_FULL;
+                st->internal->need_parsing = AVSTREAM_PARSE_FULL;
         }
 
         size        = bytestream2_get_le32(&p);
diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c
index d1064e4328..28684f6ea9 100644
--- a/libavformat/oggparsetheora.c
+++ b/libavformat/oggparsetheora.c
@@ -112,7 +112,7 @@  static int theora_header(AVFormatContext *s, int idx)
 
         st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
         st->codecpar->codec_id   = AV_CODEC_ID_THEORA;
-        st->need_parsing      = AVSTREAM_PARSE_HEADERS;
+        st->internal->need_parsing      = AVSTREAM_PARSE_HEADERS;
     }
     break;
     case 0x81:
diff --git a/libavformat/oggparsevp8.c b/libavformat/oggparsevp8.c
index b76ac71cc5..85b3627c9c 100644
--- a/libavformat/oggparsevp8.c
+++ b/libavformat/oggparsevp8.c
@@ -61,7 +61,7 @@  static int vp8_header(AVFormatContext *s, int idx)
         avpriv_set_pts_info(st, 64, framerate.den, framerate.num);
         st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
         st->codecpar->codec_id   = AV_CODEC_ID_VP8;
-        st->need_parsing      = AVSTREAM_PARSE_HEADERS;
+        st->internal->need_parsing      = AVSTREAM_PARSE_HEADERS;
         break;
     case 0x02:
         if (p[6] != 0x20)
diff --git a/libavformat/omadec.c b/libavformat/omadec.c
index 5675d86e75..c4799e9fdc 100644
--- a/libavformat/omadec.c
+++ b/libavformat/omadec.c
@@ -506,7 +506,7 @@  static int oma_read_header(AVFormatContext *s)
         avpriv_set_pts_info(st, 64, 1, samplerate);
         break;
     case OMA_CODECID_MP3:
-        st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+        st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
         framesize = 1024;
         break;
     case OMA_CODECID_LPCM:
diff --git a/libavformat/pva.c b/libavformat/pva.c
index 58ec78750c..4d348417c8 100644
--- a/libavformat/pva.c
+++ b/libavformat/pva.c
@@ -61,7 +61,7 @@  static int pva_read_header(AVFormatContext *s) {
         return AVERROR(ENOMEM);
     st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codecpar->codec_id   = AV_CODEC_ID_MPEG2VIDEO;
-    st->need_parsing      = AVSTREAM_PARSE_FULL;
+    st->internal->need_parsing      = AVSTREAM_PARSE_FULL;
     avpriv_set_pts_info(st, 32, 1, 90000);
     av_add_index_entry(st, 0, 0, 0, 0, AVINDEX_KEYFRAME);
 
@@ -69,7 +69,7 @@  static int pva_read_header(AVFormatContext *s) {
         return AVERROR(ENOMEM);
     st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
     st->codecpar->codec_id   = AV_CODEC_ID_MP2;
-    st->need_parsing      = AVSTREAM_PARSE_FULL;
+    st->internal->need_parsing      = AVSTREAM_PARSE_FULL;
     avpriv_set_pts_info(st, 33, 1, 90000);
     av_add_index_entry(st, 0, 0, 0, 0, AVINDEX_KEYFRAME);
 
diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
index 10c37c5cb9..aa5ac23cdc 100644
--- a/libavformat/rawdec.c
+++ b/libavformat/rawdec.c
@@ -60,7 +60,7 @@  int ff_raw_audio_read_header(AVFormatContext *s)
         return AVERROR(ENOMEM);
     st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
     st->codecpar->codec_id = s->iformat->raw_codec_id;
-    st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+    st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
     st->start_time = 0;
     /* the parameters will be extracted from the compressed bitstream */
 
@@ -83,7 +83,7 @@  int ff_raw_video_read_header(AVFormatContext *s)
 
     st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codecpar->codec_id = s->iformat->raw_codec_id;
-    st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+    st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
 
     st->internal->avctx->framerate = s1->framerate;
     avpriv_set_pts_info(st, 64, 1, 1200000);
diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index 72b8dba741..bafd1a2000 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -200,7 +200,7 @@  static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
 
         switch (st->codecpar->codec_id) {
         case AV_CODEC_ID_AC3:
-            st->need_parsing = AVSTREAM_PARSE_FULL;
+            st->internal->need_parsing = AVSTREAM_PARSE_FULL;
             break;
         case AV_CODEC_ID_RA_288:
             st->codecpar->extradata_size= 0;
@@ -209,7 +209,7 @@  static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
             st->codecpar->block_align = coded_framesize;
             break;
         case AV_CODEC_ID_COOK:
-            st->need_parsing = AVSTREAM_PARSE_HEADERS;
+            st->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
         case AV_CODEC_ID_ATRAC3:
         case AV_CODEC_ID_SIPR:
             if (read_all) {
@@ -233,7 +233,7 @@  static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
                     return -1;
                 }
                 st->codecpar->block_align = ff_sipr_subpk_size[flavor];
-                st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+                st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
             } else {
                 if(sub_packet_size <= 0){
                     av_log(s, AV_LOG_ERROR, "sub_packet_size is invalid\n");
@@ -386,7 +386,7 @@  int ff_rm_read_mdpr_codecdata(AVFormatContext *s, AVIOContext *pb,
         avio_skip(pb, 2); // looks like bits per sample
         avio_skip(pb, 4); // always zero?
         st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
-        st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
+        st->internal->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
         fps = avio_rb32(pb);
 
         if ((ret = rm_read_extradata(s, pb, st->codecpar, codec_data_size - (avio_tell(pb) - codec_pos))) < 0)
diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c
index e58f0260f3..3b8d16ec46 100644
--- a/libavformat/rtpdec_asf.c
+++ b/libavformat/rtpdec_asf.c
@@ -167,8 +167,8 @@  static int asfrtp_parse_sdp_line(AVFormatContext *s, int stream_index,
                 if (s->streams[stream_index]->id == rt->asf_ctx->streams[i]->id) {
                     avcodec_parameters_copy(s->streams[stream_index]->codecpar,
                                             rt->asf_ctx->streams[i]->codecpar);
-                    s->streams[stream_index]->need_parsing =
-                        rt->asf_ctx->streams[i]->need_parsing;
+                    s->streams[stream_index]->internal->need_parsing =
+                        rt->asf_ctx->streams[i]->internal->need_parsing;
                     avpriv_set_pts_info(s->streams[stream_index], 32, 1, 1000);
                 }
            }
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 2ce09477ed..5d01b91b1e 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -226,7 +226,7 @@  static void init_rtp_handler(const RTPDynamicProtocolHandler *handler,
         par->codec_id          = handler->codec_id;
     rtsp_st->dynamic_handler = handler;
     if (st)
-        st->need_parsing = handler->need_parsing;
+        st->internal->need_parsing = handler->need_parsing;
     if (handler->priv_data_size) {
         rtsp_st->dynamic_protocol_context = av_mallocz(handler->priv_data_size);
         if (!rtsp_st->dynamic_protocol_context)
diff --git a/libavformat/sdr2.c b/libavformat/sdr2.c
index 3743d59e58..496870bb3b 100644
--- a/libavformat/sdr2.c
+++ b/libavformat/sdr2.c
@@ -51,7 +51,7 @@  static int sdr2_read_header(AVFormatContext *s)
     st->codecpar->width      = avio_rl32(s->pb);
     st->codecpar->height     = avio_rl32(s->pb);
     st->codecpar->codec_id   = AV_CODEC_ID_H264;
-    st->need_parsing      = AVSTREAM_PARSE_FULL;
+    st->internal->need_parsing      = AVSTREAM_PARSE_FULL;
 
     ast->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
     ast->codecpar->channels    = 1;
diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c
index ce65ac6db0..22362c4561 100644
--- a/libavformat/segafilm.c
+++ b/libavformat/segafilm.c
@@ -180,7 +180,7 @@  static int film_read_header(AVFormatContext *s)
         if (film->audio_type == AV_CODEC_ID_ADPCM_ADX) {
             st->codecpar->bits_per_coded_sample = 18 * 8 / 32;
             st->codecpar->block_align = st->codecpar->channels * 18;
-            st->need_parsing = AVSTREAM_PARSE_FULL;
+            st->internal->need_parsing = AVSTREAM_PARSE_FULL;
         } else {
             st->codecpar->bits_per_coded_sample = film->audio_bits;
             st->codecpar->block_align = st->codecpar->channels *
diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
index fa11c050cd..8f9b1ab7ce 100644
--- a/libavformat/swfdec.c
+++ b/libavformat/swfdec.c
@@ -203,7 +203,7 @@  static AVStream *create_new_audio_stream(AVFormatContext *s, int id, int info)
     }
     ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
     ast->codecpar->codec_id   = ff_codec_get_id(swf_audio_codec_tags, info>>4 & 15);
-    ast->need_parsing = AVSTREAM_PARSE_FULL;
+    ast->internal->need_parsing = AVSTREAM_PARSE_FULL;
     sample_rate_code = info>>2 & 3;
     sample_size_code = info>>1 & 1;
     if (!sample_size_code && ast->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE)
diff --git a/libavformat/takdec.c b/libavformat/takdec.c
index 6d18b6af21..8929be8f24 100644
--- a/libavformat/takdec.c
+++ b/libavformat/takdec.c
@@ -65,7 +65,7 @@  static int tak_read_header(AVFormatContext *s)
 
     st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
     st->codecpar->codec_id   = AV_CODEC_ID_TAK;
-    st->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
+    st->internal->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
 
     tc->mlast_frame = 0;
     if (avio_rl32(pb) != MKTAG('t', 'B', 'a', 'K')) {
diff --git a/libavformat/ty.c b/libavformat/ty.c
index c8e1067c0e..96af6952e6 100644
--- a/libavformat/ty.c
+++ b/libavformat/ty.c
@@ -308,7 +308,7 @@  static int ty_read_header(AVFormatContext *s)
         return AVERROR(ENOMEM);
     st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codecpar->codec_id   = AV_CODEC_ID_MPEG2VIDEO;
-    st->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
+    st->internal->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
     avpriv_set_pts_info(st, 64, 1, 90000);
 
     ast = avformat_new_stream(s, NULL);
@@ -318,7 +318,7 @@  static int ty_read_header(AVFormatContext *s)
 
     if (ty->audio_type == TIVO_AUDIO_MPEG) {
         ast->codecpar->codec_id = AV_CODEC_ID_MP2;
-        ast->need_parsing       = AVSTREAM_PARSE_FULL_RAW;
+        ast->internal->need_parsing       = AVSTREAM_PARSE_FULL_RAW;
     } else {
         ast->codecpar->codec_id = AV_CODEC_ID_AC3;
     }
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 27b7b62b1a..4d281a9ce8 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -144,7 +144,7 @@  int64_t av_stream_get_end_pts(const AVStream *st)
 
 struct AVCodecParserContext *av_stream_get_parser(const AVStream *st)
 {
-    return st->parser;
+    return st->internal->parser;
 }
 
 void av_format_inject_global_side_data(AVFormatContext *s)
@@ -472,9 +472,9 @@  static int update_stream_avctx(AVFormatContext *s)
             continue;
 
         /* close parser, because it depends on the codec */
-        if (st->parser && st->internal->avctx->codec_id != st->codecpar->codec_id) {
-            av_parser_close(st->parser);
-            st->parser = NULL;
+        if (st->internal->parser && st->internal->avctx->codec_id != st->codecpar->codec_id) {
+            av_parser_close(st->internal->parser);
+            st->internal->parser = NULL;
         }
 
         /* update internal codec context, for the parser */
@@ -1287,7 +1287,7 @@  static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
 
     /* Correct timestamps with byte offset if demuxers only have timestamps
      * on packet boundaries */
-    if (pc && st->need_parsing == AVSTREAM_PARSE_TIMESTAMPS && pkt->size) {
+    if (pc && st->internal->need_parsing == AVSTREAM_PARSE_TIMESTAMPS && pkt->size) {
         /* this will estimate bitrate based on this frame's duration and size */
         offset = av_rescale(pc->offset, pkt->duration, pkt->size);
         if (pkt->pts != AV_NOPTS_VALUE)
@@ -1404,9 +1404,9 @@  static int parse_packet(AVFormatContext *s, AVPacket *pkt,
 
     if (size || flush) {
         av_init_packet(&out_pkt);
-    } else if (st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) {
+    } else if (st->internal->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) {
         // preserve 0-size sync packets
-        compute_pkt_fields(s, st, st->parser, pkt, AV_NOPTS_VALUE, AV_NOPTS_VALUE);
+        compute_pkt_fields(s, st, st->internal->parser, pkt, AV_NOPTS_VALUE, AV_NOPTS_VALUE);
     }
 
     while (size > 0 || (flush && got_output)) {
@@ -1414,7 +1414,7 @@  static int parse_packet(AVFormatContext *s, AVPacket *pkt,
         int64_t next_pts = pkt->pts;
         int64_t next_dts = pkt->dts;
 
-        len = av_parser_parse2(st->parser, st->internal->avctx,
+        len = av_parser_parse2(st->internal->parser, st->internal->avctx,
                                &out_pkt.data, &out_pkt.size, data, size,
                                pkt->pts, pkt->dts, pkt->pos);
 
@@ -1432,7 +1432,7 @@  static int parse_packet(AVFormatContext *s, AVPacket *pkt,
         if (pkt->buf && out_pkt.data == pkt->data) {
             /* reference pkt->buf only when out_pkt.data is guaranteed to point
              * to data in it and not in the parser's internal buffer. */
-            /* XXX: Ensure this is the case with all parsers when st->parser->flags
+            /* XXX: Ensure this is the case with all parsers when st->internal->parser->flags
              * is PARSER_FLAG_COMPLETE_FRAMES and check for that instead? */
             out_pkt.buf = av_buffer_ref(pkt->buf);
             if (!out_pkt.buf) {
@@ -1453,11 +1453,11 @@  static int parse_packet(AVFormatContext *s, AVPacket *pkt,
         }
 
         /* set the duration */
-        out_pkt.duration = (st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) ? pkt->duration : 0;
+        out_pkt.duration = (st->internal->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) ? pkt->duration : 0;
         if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
             if (st->internal->avctx->sample_rate > 0) {
                 out_pkt.duration =
-                    av_rescale_q_rnd(st->parser->duration,
+                    av_rescale_q_rnd(st->internal->parser->duration,
                                      (AVRational) { 1, st->internal->avctx->sample_rate },
                                      st->time_base,
                                      AV_ROUND_DOWN);
@@ -1465,23 +1465,23 @@  static int parse_packet(AVFormatContext *s, AVPacket *pkt,
         }
 
         out_pkt.stream_index = st->index;
-        out_pkt.pts          = st->parser->pts;
-        out_pkt.dts          = st->parser->dts;
-        out_pkt.pos          = st->parser->pos;
+        out_pkt.pts          = st->internal->parser->pts;
+        out_pkt.dts          = st->internal->parser->dts;
+        out_pkt.pos          = st->internal->parser->pos;
         out_pkt.flags       |= pkt->flags & AV_PKT_FLAG_DISCARD;
 
-        if (st->need_parsing == AVSTREAM_PARSE_FULL_RAW)
-            out_pkt.pos = st->parser->frame_offset;
+        if (st->internal->need_parsing == AVSTREAM_PARSE_FULL_RAW)
+            out_pkt.pos = st->internal->parser->frame_offset;
 
-        if (st->parser->key_frame == 1 ||
-            (st->parser->key_frame == -1 &&
-             st->parser->pict_type == AV_PICTURE_TYPE_I))
+        if (st->internal->parser->key_frame == 1 ||
+            (st->internal->parser->key_frame == -1 &&
+             st->internal->parser->pict_type == AV_PICTURE_TYPE_I))
             out_pkt.flags |= AV_PKT_FLAG_KEY;
 
-        if (st->parser->key_frame == -1 && st->parser->pict_type ==AV_PICTURE_TYPE_NONE && (pkt->flags&AV_PKT_FLAG_KEY))
+        if (st->internal->parser->key_frame == -1 && st->internal->parser->pict_type ==AV_PICTURE_TYPE_NONE && (pkt->flags&AV_PKT_FLAG_KEY))
             out_pkt.flags |= AV_PKT_FLAG_KEY;
 
-        compute_pkt_fields(s, st, st->parser, &out_pkt, next_dts, next_pts);
+        compute_pkt_fields(s, st, st->internal->parser, &out_pkt, next_dts, next_pts);
 
         ret = avpriv_packet_list_put(&s->internal->parse_queue,
                                  &s->internal->parse_queue_end,
@@ -1494,8 +1494,8 @@  static int parse_packet(AVFormatContext *s, AVPacket *pkt,
 
     /* end of the stream => close and free the parser */
     if (flush) {
-        av_parser_close(st->parser);
-        st->parser = NULL;
+        av_parser_close(st->internal->parser);
+        st->internal->parser = NULL;
     }
 
 fail:
@@ -1524,7 +1524,7 @@  static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
             /* flush the parsers */
             for (i = 0; i < s->nb_streams; i++) {
                 st = s->streams[i];
-                if (st->parser && st->need_parsing)
+                if (st->internal->parser && st->internal->need_parsing)
                     parse_packet(s, pkt, st->index, 1);
             }
             /* all remaining packets are now in parse_queue =>
@@ -1543,9 +1543,9 @@  static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
             }
 
             /* close parser, because it depends on the codec */
-            if (st->parser && st->internal->avctx->codec_id != st->codecpar->codec_id) {
-                av_parser_close(st->parser);
-                st->parser = NULL;
+            if (st->internal->parser && st->internal->avctx->codec_id != st->codecpar->codec_id) {
+                av_parser_close(st->internal->parser);
+                st->internal->parser = NULL;
             }
 
             ret = avcodec_parameters_to_context(st->internal->avctx, st->codecpar);
@@ -1586,23 +1586,23 @@  FF_ENABLE_DEPRECATION_WARNINGS
                    av_ts2str(pkt->dts),
                    pkt->size, pkt->duration, pkt->flags);
 
-        if (st->need_parsing && !st->parser && !(s->flags & AVFMT_FLAG_NOPARSE)) {
-            st->parser = av_parser_init(st->codecpar->codec_id);
-            if (!st->parser) {
+        if (st->internal->need_parsing && !st->internal->parser && !(s->flags & AVFMT_FLAG_NOPARSE)) {
+            st->internal->parser = av_parser_init(st->codecpar->codec_id);
+            if (!st->internal->parser) {
                 av_log(s, AV_LOG_VERBOSE, "parser not found for codec "
                        "%s, packets or times may be invalid.\n",
                        avcodec_get_name(st->codecpar->codec_id));
                 /* no parser available: just output the raw packets */
-                st->need_parsing = AVSTREAM_PARSE_NONE;
-            } else if (st->need_parsing == AVSTREAM_PARSE_HEADERS)
-                st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
-            else if (st->need_parsing == AVSTREAM_PARSE_FULL_ONCE)
-                st->parser->flags |= PARSER_FLAG_ONCE;
-            else if (st->need_parsing == AVSTREAM_PARSE_FULL_RAW)
-                st->parser->flags |= PARSER_FLAG_USE_CODEC_TS;
+                st->internal->need_parsing = AVSTREAM_PARSE_NONE;
+            } else if (st->internal->need_parsing == AVSTREAM_PARSE_HEADERS)
+                st->internal->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
+            else if (st->internal->need_parsing == AVSTREAM_PARSE_FULL_ONCE)
+                st->internal->parser->flags |= PARSER_FLAG_ONCE;
+            else if (st->internal->need_parsing == AVSTREAM_PARSE_FULL_RAW)
+                st->internal->parser->flags |= PARSER_FLAG_USE_CODEC_TS;
         }
 
-        if (!st->need_parsing || !st->parser) {
+        if (!st->internal->need_parsing || !st->internal->parser) {
             /* no parsing needed: we just output the packet as is */
             compute_pkt_fields(s, st, NULL, pkt, AV_NOPTS_VALUE, AV_NOPTS_VALUE);
             if ((s->iformat->flags & AVFMT_GENERIC_INDEX) &&
@@ -1870,9 +1870,9 @@  void ff_read_frame_flush(AVFormatContext *s)
     for (i = 0; i < s->nb_streams; i++) {
         st = s->streams[i];
 
-        if (st->parser) {
-            av_parser_close(st->parser);
-            st->parser = NULL;
+        if (st->internal->parser) {
+            av_parser_close(st->internal->parser);
+            st->internal->parser = NULL;
         }
         st->last_IP_pts = AV_NOPTS_VALUE;
         st->internal->last_dts_for_order_check = AV_NOPTS_VALUE;
@@ -2759,9 +2759,9 @@  static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
             av_log(ic, AV_LOG_WARNING,
                    "start time for stream %d is not set in estimate_timings_from_pts\n", i);
 
-        if (st->parser) {
-            av_parser_close(st->parser);
-            st->parser = NULL;
+        if (st->internal->parser) {
+            av_parser_close(st->internal->parser);
+            st->internal->parser = NULL;
         }
     }
 
@@ -2797,7 +2797,7 @@  static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
                 (st->start_time != AV_NOPTS_VALUE ||
                  st->first_dts  != AV_NOPTS_VALUE)) {
                 if (pkt->duration == 0) {
-                    ff_compute_frame_duration(ic, &num, &den, st, st->parser, pkt);
+                    ff_compute_frame_duration(ic, &num, &den, st, st->internal->parser, pkt);
                     if (den && num) {
                         pkt->duration = av_rescale_rnd(1,
                                            num * (int64_t) st->time_base.den,
@@ -3606,15 +3606,15 @@  FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
         // only for the split stuff
-        if (!st->parser && !(ic->flags & AVFMT_FLAG_NOPARSE) && st->internal->request_probe <= 0) {
-            st->parser = av_parser_init(st->codecpar->codec_id);
-            if (st->parser) {
-                if (st->need_parsing == AVSTREAM_PARSE_HEADERS) {
-                    st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
-                } else if (st->need_parsing == AVSTREAM_PARSE_FULL_RAW) {
-                    st->parser->flags |= PARSER_FLAG_USE_CODEC_TS;
+        if (!st->internal->parser && !(ic->flags & AVFMT_FLAG_NOPARSE) && st->internal->request_probe <= 0) {
+            st->internal->parser = av_parser_init(st->codecpar->codec_id);
+            if (st->internal->parser) {
+                if (st->internal->need_parsing == AVSTREAM_PARSE_HEADERS) {
+                    st->internal->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
+                } else if (st->internal->need_parsing == AVSTREAM_PARSE_FULL_RAW) {
+                    st->internal->parser->flags |= PARSER_FLAG_USE_CODEC_TS;
                 }
-            } else if (st->need_parsing) {
+            } else if (st->internal->need_parsing) {
                 av_log(ic, AV_LOG_VERBOSE, "parser not found for codec "
                        "%s, packets or times may be invalid.\n",
                        avcodec_get_name(st->codecpar->codec_id));
@@ -3857,7 +3857,7 @@  FF_ENABLE_DEPRECATION_WARNINGS
                     st->internal->info->codec_info_duration = FFMIN(pkt->pts - st->start_time, st->internal->info->codec_info_duration + pkt->duration);
                 } else
                     st->internal->info->codec_info_duration += pkt->duration;
-                st->internal->info->codec_info_duration_fields += st->parser && st->need_parsing && avctx->ticks_per_frame ==2 ? st->parser->repeat_pict + 1 : 2;
+                st->internal->info->codec_info_duration_fields += st->internal->parser && st->internal->need_parsing && avctx->ticks_per_frame ==2 ? st->internal->parser->repeat_pict + 1 : 2;
             }
         }
         if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
@@ -4331,8 +4331,8 @@  static void free_stream(AVStream **pst)
         av_freep(&st->side_data[i].data);
     av_freep(&st->side_data);
 
-    if (st->parser)
-        av_parser_close(st->parser);
+    if (st->internal->parser)
+        av_parser_close(st->internal->parser);
 
     if (st->attached_pic.data)
         av_packet_unref(&st->attached_pic);
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index bca186a66f..9b93cfce8e 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -175,7 +175,7 @@  static int wav_parse_fmt_tag(AVFormatContext *s, int64_t size, AVStream **st)
         return ret;
     handle_stream_probing(*st);
 
-    (*st)->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+    (*st)->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
 
     avpriv_set_pts_info(*st, 64, 1, (*st)->codecpar->sample_rate);
 
@@ -196,7 +196,7 @@  static int wav_parse_xma2_tag(AVFormatContext *s, int64_t size, AVStream **st)
 
     (*st)->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
     (*st)->codecpar->codec_id   = AV_CODEC_ID_XMA2;
-    (*st)->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
+    (*st)->internal->need_parsing         = AVSTREAM_PARSE_FULL_RAW;
 
     version = avio_r8(pb);
     if (version != 3 && version != 4)
@@ -943,7 +943,7 @@  static int w64_read_header(AVFormatContext *s)
     ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv);
 
     handle_stream_probing(st);
-    st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+    st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW;
 
     avio_seek(pb, data_ofs, SEEK_SET);
 
diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index 83f510b92f..fe665af10c 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -621,7 +621,7 @@  static AVStream * new_stream(AVFormatContext *s, AVStream *st, int sid, int code
         st->priv_data = wst;
     }
     st->codecpar->codec_type = codec_type;
-    st->need_parsing      = AVSTREAM_PARSE_FULL;
+    st->internal->need_parsing      = AVSTREAM_PARSE_FULL;
     avpriv_set_pts_info(st, 64, 1, 10000000);
     return st;
 }
diff --git a/libavformat/xvag.c b/libavformat/xvag.c
index e95d84aa3f..b79c89f09e 100644
--- a/libavformat/xvag.c
+++ b/libavformat/xvag.c
@@ -87,7 +87,7 @@  static int xvag_read_header(AVFormatContext *s)
     if (avio_rb16(s->pb) == 0xFFFB) {
         st->codecpar->codec_id    = AV_CODEC_ID_MP3;
         st->codecpar->block_align = 0x1000;
-        st->need_parsing       = AVSTREAM_PARSE_FULL_RAW;
+        st->internal->need_parsing       = AVSTREAM_PARSE_FULL_RAW;
     }
 
     avio_skip(s->pb, -2);
diff --git a/libavformat/xwma.c b/libavformat/xwma.c
index 5a57caa841..c5e9db1e72 100644
--- a/libavformat/xwma.c
+++ b/libavformat/xwma.c
@@ -78,7 +78,7 @@  static int xwma_read_header(AVFormatContext *s)
     ret = ff_get_wav_header(s, pb, st->codecpar, size, 0);
     if (ret < 0)
         return ret;
-    st->need_parsing = AVSTREAM_PARSE_NONE;
+    st->internal->need_parsing = AVSTREAM_PARSE_NONE;
 
     /* XWMA encoder only allows a few channel/sample rate/bitrate combinations,
      * but some create identical files with fake bitrate (1ch 22050hz at