lavf: replace AVStream.codec with AVStream.codecpar
authorAnton Khirnov <anton@khirnov.net>
Wed, 18 Jun 2014 18:42:52 +0000 (20:42 +0200)
committerAnton Khirnov <anton@khirnov.net>
Tue, 23 Feb 2016 16:01:58 +0000 (17:01 +0100)
Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.

In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.

There are multiple important problems with this approach:
    - the fields in AVCodecContext are in general one of
        * stream parameters
        * codec options
        * codec state
      However, it's not clear which ones are which. It is consequently
      unclear which fields are a demuxer allowed to set or a muxer allowed to
      read. This leads to erratic behaviour depending on whether decoding or
      encoding is being performed or not (and whether it uses the AVStream
      embedded codec context).
    - various synchronization issues arising from the fact that the same
      context is used by several different APIs (muxers/demuxers,
      parsers, bitstream filters and encoders/decoders) simultaneously, with
      there being no clear rules for who can modify what and the different
      processes being typically delayed with respect to each other.
    - avformat_find_stream_info() making it necessary to support opening
      and closing a single codec context multiple times, thus
      complicating the semantics of freeing various allocated objects in the
      codec context.

Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.

251 files changed:
libavdevice/alsa.c
libavdevice/alsa_dec.c
libavdevice/alsa_enc.c
libavdevice/bktr.c
libavdevice/fbdev.c
libavdevice/jack.c
libavdevice/libcdio.c
libavdevice/libdc1394.c
libavdevice/oss_dec.c
libavdevice/oss_enc.c
libavdevice/pulse.c
libavdevice/sndio_dec.c
libavdevice/sndio_enc.c
libavdevice/v4l2.c
libavdevice/vfwcap.c
libavdevice/x11grab.c
libavdevice/xcbgrab.c
libavformat/4xm.c
libavformat/a64.c
libavformat/aacdec.c
libavformat/adtsenc.c
libavformat/adxdec.c
libavformat/aea.c
libavformat/aiffdec.c
libavformat/aiffenc.c
libavformat/amr.c
libavformat/anm.c
libavformat/apc.c
libavformat/ape.c
libavformat/apetag.c
libavformat/asfdec.c
libavformat/asfenc.c
libavformat/assdec.c
libavformat/assenc.c
libavformat/au.c
libavformat/audiointerleave.c
libavformat/avformat.h
libavformat/avidec.c
libavformat/avienc.c
libavformat/avisynth.c
libavformat/avs.c
libavformat/bethsoftvid.c
libavformat/bfi.c
libavformat/bink.c
libavformat/bmv.c
libavformat/c93.c
libavformat/cafdec.c
libavformat/cdg.c
libavformat/cdxl.c
libavformat/dashenc.c
libavformat/dauddec.c
libavformat/daudenc.c
libavformat/dfa.c
libavformat/dsicin.c
libavformat/dss.c
libavformat/dump.c
libavformat/dv.c
libavformat/dvenc.c
libavformat/dxa.c
libavformat/eacdata.c
libavformat/electronicarts.c
libavformat/ffmetadec.c
libavformat/filmstripdec.c
libavformat/filmstripenc.c
libavformat/flac_picture.c
libavformat/flacdec.c
libavformat/flacenc.c
libavformat/flic.c
libavformat/flvdec.c
libavformat/flvenc.c
libavformat/g722.c
libavformat/g723_1.c
libavformat/gif.c
libavformat/gsmdec.c
libavformat/gxf.c
libavformat/gxfenc.c
libavformat/hdsenc.c
libavformat/hls.c
libavformat/hlsenc.c
libavformat/hnm.c
libavformat/id3v2.c
libavformat/id3v2enc.c
libavformat/idcin.c
libavformat/idroqdec.c
libavformat/iff.c
libavformat/ilbc.c
libavformat/img2dec.c
libavformat/img2enc.c
libavformat/internal.h
libavformat/ipmovie.c
libavformat/isom.c
libavformat/iss.c
libavformat/iv8.c
libavformat/ivfdec.c
libavformat/ivfenc.c
libavformat/jvdec.c
libavformat/latmenc.c
libavformat/lmlm4.c
libavformat/lxfdec.c
libavformat/matroskadec.c
libavformat/matroskaenc.c
libavformat/mm.c
libavformat/mmf.c
libavformat/mov.c
libavformat/mov_chan.c
libavformat/movenc-test.c
libavformat/movenc.c
libavformat/movenc.h
libavformat/movenchint.c
libavformat/mp3dec.c
libavformat/mp3enc.c
libavformat/mpc.c
libavformat/mpc8.c
libavformat/mpeg.c
libavformat/mpegenc.c
libavformat/mpegts.c
libavformat/mpegtsenc.c
libavformat/mpjpegdec.c
libavformat/msnwc_tcp.c
libavformat/mtv.c
libavformat/mux.c
libavformat/mvdec.c
libavformat/mvi.c
libavformat/mxfdec.c
libavformat/mxfenc.c
libavformat/mxg.c
libavformat/ncdec.c
libavformat/nsvdec.c
libavformat/nutdec.c
libavformat/nutenc.c
libavformat/nuv.c
libavformat/oggdec.c
libavformat/oggenc.c
libavformat/oggparsecelt.c
libavformat/oggparsedirac.c
libavformat/oggparseflac.c
libavformat/oggparseogm.c
libavformat/oggparseopus.c
libavformat/oggparseskeleton.c
libavformat/oggparsespeex.c
libavformat/oggparsetheora.c
libavformat/oggparsevorbis.c
libavformat/oggparsevp8.c
libavformat/omadec.c
libavformat/omaenc.c
libavformat/paf.c
libavformat/pcm.c
libavformat/pcmdec.c
libavformat/pmpdec.c
libavformat/psxstr.c
libavformat/pva.c
libavformat/qcp.c
libavformat/r3d.c
libavformat/rawdec.c
libavformat/rawvideodec.c
libavformat/rdt.c
libavformat/riff.h
libavformat/riffdec.c
libavformat/riffenc.c
libavformat/rl2.c
libavformat/rmdec.c
libavformat/rmenc.c
libavformat/rpl.c
libavformat/rsodec.c
libavformat/rsoenc.c
libavformat/rtp.c
libavformat/rtp.h
libavformat/rtpdec.c
libavformat/rtpdec_amr.c
libavformat/rtpdec_asf.c
libavformat/rtpdec_formats.h
libavformat/rtpdec_g726.c
libavformat/rtpdec_h264.c
libavformat/rtpdec_hevc.c
libavformat/rtpdec_ilbc.c
libavformat/rtpdec_latm.c
libavformat/rtpdec_mpeg12.c
libavformat/rtpdec_mpeg4.c
libavformat/rtpdec_qdm2.c
libavformat/rtpdec_qt.c
libavformat/rtpdec_svq3.c
libavformat/rtpdec_xiph.c
libavformat/rtpenc.c
libavformat/rtpenc_aac.c
libavformat/rtpenc_chain.c
libavformat/rtpenc_h264_hevc.c
libavformat/rtpenc_jpeg.c
libavformat/rtpenc_latm.c
libavformat/rtpenc_mpegts.c
libavformat/rtsp.c
libavformat/sapdec.c
libavformat/sauce.c
libavformat/sdp.c
libavformat/segafilm.c
libavformat/segment.c
libavformat/sierravmd.c
libavformat/siff.c
libavformat/smacker.c
libavformat/smjpegdec.c
libavformat/smjpegenc.c
libavformat/smoothstreamingenc.c
libavformat/smush.c
libavformat/sol.c
libavformat/soxdec.c
libavformat/soxenc.c
libavformat/spdifdec.c
libavformat/spdifenc.c
libavformat/srtdec.c
libavformat/swf.h
libavformat/swfdec.c
libavformat/swfenc.c
libavformat/takdec.c
libavformat/thp.c
libavformat/tiertexseq.c
libavformat/tmv.c
libavformat/tta.c
libavformat/tty.c
libavformat/txd.c
libavformat/utils.c
libavformat/vc1test.c
libavformat/vc1testenc.c
libavformat/version.h
libavformat/voc_packet.c
libavformat/vocdec.c
libavformat/vocenc.c
libavformat/vqf.c
libavformat/wavdec.c
libavformat/wavenc.c
libavformat/wc3movie.c
libavformat/westwood_aud.c
libavformat/westwood_vqa.c
libavformat/wtv.c
libavformat/wvdec.c
libavformat/wvenc.c
libavformat/xa.c
libavformat/xmv.c
libavformat/xwma.c
libavformat/yop.c
libavformat/yuv4mpegdec.c
libavformat/yuv4mpegenc.c
tests/ref/fate/iv8-demux
tests/ref/fate/lmlm4-demux
tests/ref/fate/movenc
tests/ref/fate/mxf-demux
tests/ref/fate/nc-demux
tests/ref/fate/wtv-demux
tests/ref/lavf/flv_fmt
tests/ref/vsynth/vsynth1-flashsv
tests/ref/vsynth/vsynth1-flv
tests/ref/vsynth/vsynth2-flashsv
tests/ref/vsynth/vsynth2-flv

index 6d682676023670e47afa8e4113612cf7a2c469e4..d394e4377d17f665762eefa6b1ba9166a1b8f267 100644 (file)
@@ -194,7 +194,7 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
     snd_pcm_t *h;
     snd_pcm_hw_params_t *hw_params;
     snd_pcm_uframes_t buffer_size, period_size;
-    uint64_t layout = ctx->streams[0]->codec->channel_layout;
+    uint64_t layout = ctx->streams[0]->codecpar->channel_layout;
 
     if (ctx->filename[0] == 0) audio_device = "default";
     else                       audio_device = ctx->filename;
index e7819ec18a78d83d7b700d7f0bfff4a127c63446..58bf1dd6a1659d2432c04c828089211c6e78ddf3 100644 (file)
@@ -101,10 +101,10 @@ static av_cold int audio_read_header(AVFormatContext *s1)
     }
 
     /* take real parameters */
-    st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id    = codec_id;
-    st->codec->sample_rate = s->sample_rate;
-    st->codec->channels    = s->channels;
+    st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_id    = codec_id;
+    st->codecpar->sample_rate = s->sample_rate;
+    st->codecpar->channels    = s->channels;
     avpriv_set_pts_info(st, 64, 1, 1000000);  /* 64 bits pts in us */
 
     return 0;
@@ -144,9 +144,9 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
     snd_pcm_htimestamp(s->h, &ts_delay, &timestamp);
     ts_delay += res;
     pkt->pts = timestamp.tv_sec * 1000000LL
-               + (timestamp.tv_nsec * st->codec->sample_rate
-                  - (int64_t)ts_delay * 1000000000LL + st->codec->sample_rate * 500LL)
-               / (st->codec->sample_rate * 1000LL);
+               + (timestamp.tv_nsec * st->codecpar->sample_rate
+                  - (int64_t)ts_delay * 1000000000LL + st->codecpar->sample_rate * 500LL)
+               / (st->codecpar->sample_rate * 1000LL);
 
     pkt->size = res * s->frame_size;
 
index 30c1719203cbb0c67cfb2f963be6f06d886c85d9..3094b5043eb6ab7bf1b983df7d6bbdffa3f19520 100644 (file)
@@ -54,14 +54,14 @@ static av_cold int audio_write_header(AVFormatContext *s1)
     int res;
 
     st = s1->streams[0];
-    sample_rate = st->codec->sample_rate;
-    codec_id    = st->codec->codec_id;
+    sample_rate = st->codecpar->sample_rate;
+    codec_id    = st->codecpar->codec_id;
     res = ff_alsa_open(s1, SND_PCM_STREAM_PLAYBACK, &sample_rate,
-        st->codec->channels, &codec_id);
-    if (sample_rate != st->codec->sample_rate) {
+        st->codecpar->channels, &codec_id);
+    if (sample_rate != st->codecpar->sample_rate) {
         av_log(s1, AV_LOG_ERROR,
                "sample rate %d not available, nearest is %d\n",
-               st->codec->sample_rate, sample_rate);
+               st->codecpar->sample_rate, sample_rate);
         goto fail;
     }
 
index 8042c3801109063197db325277e89f1b23c17541..f76a1636c6d25b6cf7666a970edb581bf5f59965 100644 (file)
@@ -295,13 +295,12 @@ static int grab_read_header(AVFormatContext *s1)
     s->height = height;
     s->per_frame = ((uint64_t)1000000 * framerate.den) / framerate.num;
 
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->pix_fmt = AV_PIX_FMT_YUV420P;
-    st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
-    st->codec->width = width;
-    st->codec->height = height;
-    st->codec->time_base.den = framerate.num;
-    st->codec->time_base.num = framerate.den;
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->format = AV_PIX_FMT_YUV420P;
+    st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
+    st->codecpar->width = width;
+    st->codecpar->height = height;
+    st->avg_frame_rate = framerate;
 
 
     if (bktr_init(s1->filename, width, height, s->standard,
index bdbc83f252f80845481099be63fe3c40cc3aac12..16469c56d3f1f994256d5770e1a965fa0eafd832 100644 (file)
@@ -164,21 +164,21 @@ static av_cold int fbdev_read_header(AVFormatContext *avctx)
         goto fail;
     }
 
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id   = AV_CODEC_ID_RAWVIDEO;
-    st->codec->width      = fbdev->width;
-    st->codec->height     = fbdev->height;
-    st->codec->pix_fmt    = pix_fmt;
-    st->codec->time_base  = (AVRational){fbdev->framerate_q.den, fbdev->framerate_q.num};
-    st->codec->bit_rate   =
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id   = AV_CODEC_ID_RAWVIDEO;
+    st->codecpar->width      = fbdev->width;
+    st->codecpar->height     = fbdev->height;
+    st->codecpar->format     = pix_fmt;
+    st->codecpar->bit_rate   =
         fbdev->width * fbdev->height * fbdev->bytes_per_pixel * av_q2d(fbdev->framerate_q) * 8;
+    st->avg_frame_rate  = fbdev->framerate_q;
 
     av_log(avctx, AV_LOG_INFO,
            "w:%d h:%d bpp:%d pixfmt:%s fps:%d/%d bit_rate:%d\n",
            fbdev->width, fbdev->height, fbdev->varinfo.bits_per_pixel,
            av_get_pix_fmt_name(pix_fmt),
            fbdev->framerate_q.num, fbdev->framerate_q.den,
-           st->codec->bit_rate);
+           st->codecpar->bit_rate);
     return 0;
 
 fail:
index 24c23e8c8415a52c8aad1566b28aac49e14380ff..0b4deee01cf32670318d4a8496670b81b2eabf58 100644 (file)
@@ -254,14 +254,14 @@ static int audio_read_header(AVFormatContext *context)
         return AVERROR(ENOMEM);
     }
 
-    stream->codec->codec_type   = AVMEDIA_TYPE_AUDIO;
+    stream->codecpar->codec_type   = AVMEDIA_TYPE_AUDIO;
 #if HAVE_BIGENDIAN
-    stream->codec->codec_id     = AV_CODEC_ID_PCM_F32BE;
+    stream->codecpar->codec_id     = AV_CODEC_ID_PCM_F32BE;
 #else
-    stream->codec->codec_id     = AV_CODEC_ID_PCM_F32LE;
+    stream->codecpar->codec_id     = AV_CODEC_ID_PCM_F32LE;
 #endif
-    stream->codec->sample_rate  = self->sample_rate;
-    stream->codec->channels     = self->nports;
+    stream->codecpar->sample_rate  = self->sample_rate;
+    stream->codecpar->channels     = self->nports;
 
     avpriv_set_pts_info(stream, 64, 1, 1000000);  /* 64 bits pts in us */
     return 0;
index 06ddb4a7846c16f594ef31a3198b15d2ea453f02..f19ca997b4362514e951eed7e5b6e33f69510978 100644 (file)
@@ -85,19 +85,19 @@ static av_cold int read_header(AVFormatContext *ctx)
     }
     cdio_paranoia_modeset(s->paranoia, s->paranoia_mode);
 
-    st->codec->codec_type      = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_type      = AVMEDIA_TYPE_AUDIO;
     if (s->drive->bigendianp)
-        st->codec->codec_id    = AV_CODEC_ID_PCM_S16BE;
+        st->codecpar->codec_id    = AV_CODEC_ID_PCM_S16BE;
     else
-        st->codec->codec_id    = AV_CODEC_ID_PCM_S16LE;
-    st->codec->sample_rate     = 44100;
-    st->codec->channels        = 2;
+        st->codecpar->codec_id    = AV_CODEC_ID_PCM_S16LE;
+    st->codecpar->sample_rate     = 44100;
+    st->codecpar->channels        = 2;
     if (s->drive->audio_last_sector != CDIO_INVALID_LSN &&
         s->drive->audio_first_sector != CDIO_INVALID_LSN)
         st->duration           = s->drive->audio_last_sector - s->drive->audio_first_sector;
     else if (s->drive->tracks)
         st->duration = s->drive->disc_toc[s->drive->tracks].dwStartSector;
-    avpriv_set_pts_info(st, 64, CDIO_CD_FRAMESIZE_RAW, 2*st->codec->channels*st->codec->sample_rate);
+    avpriv_set_pts_info(st, 64, CDIO_CD_FRAMESIZE_RAW, 2 * st->codecpar->channels * st->codecpar->sample_rate);
 
     for (i = 0; i < s->drive->tracks; i++) {
         char title[16];
index 64c453bd9a7fd61dd48ca5d8befde008a36fbcf1..72e2e8bcc8240fd75bded181d56a8a31cb80eac2 100644 (file)
@@ -170,13 +170,12 @@ static inline int dc1394_read_common(AVFormatContext *c,
         goto out;
     }
     avpriv_set_pts_info(vst, 64, 1, 1000);
-    vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    vst->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
-    vst->codec->time_base.den = framerate.num;
-    vst->codec->time_base.num = framerate.den;
-    vst->codec->width = fmt->width;
-    vst->codec->height = fmt->height;
-    vst->codec->pix_fmt = fmt->pix_fmt;
+    vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    vst->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
+    vst->codecpar->width = fmt->width;
+    vst->codecpar->height = fmt->height;
+    vst->codecpar->format = fmt->pix_fmt;
+    vst->avg_frame_rate = framerate;
 
     /* packet init */
     av_init_packet(&dc1394->packet);
@@ -187,7 +186,7 @@ static inline int dc1394_read_common(AVFormatContext *c,
 
     dc1394->current_frame = 0;
 
-    vst->codec->bit_rate = av_rescale(dc1394->packet.size * 8, fps->frame_rate, 1000);
+    vst->codecpar->bit_rate = av_rescale(dc1394->packet.size * 8, fps->frame_rate, 1000);
     *select_fps = fps;
     *select_fmt = fmt;
 out:
index 24d357110c789569f4581ee690bfddef9da1263c..6f51a306621dd4b689b51da96ae04e2e023d714e 100644 (file)
@@ -61,10 +61,10 @@ static int audio_read_header(AVFormatContext *s1)
     }
 
     /* take real parameters */
-    st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id = s->codec_id;
-    st->codec->sample_rate = s->sample_rate;
-    st->codec->channels = s->channels;
+    st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_id = s->codec_id;
+    st->codecpar->sample_rate = s->sample_rate;
+    st->codecpar->channels = s->channels;
 
     avpriv_set_pts_info(st, 64, 1, 1000000);  /* 64 bits pts in us */
     return 0;
index 2f075589a976b90b0e0a8facddbfe6c1554209e0..eb6432ced047b536d778a27c217d7bd7575db985 100644 (file)
@@ -47,8 +47,8 @@ static int audio_write_header(AVFormatContext *s1)
     int ret;
 
     st = s1->streams[0];
-    s->sample_rate = st->codec->sample_rate;
-    s->channels = st->codec->channels;
+    s->sample_rate = st->codecpar->sample_rate;
+    s->channels = st->codecpar->channels;
     ret = ff_oss_audio_open(s1, 1, s1->filename);
     if (ret < 0) {
         return AVERROR(EIO);
index 0e8bd09e15bd7599cfa059ae4c0b2e188f316b16..c4d939a0d3b699e008ae562792e779283eb77f52 100644 (file)
@@ -107,10 +107,10 @@ static av_cold int pulse_read_header(AVFormatContext *s)
         return AVERROR(EIO);
     }
     /* take real parameters */
-    st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id    = codec_id;
-    st->codec->sample_rate = pd->sample_rate;
-    st->codec->channels    = pd->channels;
+    st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_id    = codec_id;
+    st->codecpar->sample_rate = pd->sample_rate;
+    st->codecpar->channels    = pd->channels;
     avpriv_set_pts_info(st, 64, 1, 1000000);  /* 64 bits pts in us */
 
     pd->pts = AV_NOPTS_VALUE;
index 5d40a7a5e2f74c033a18aa0dc171f6721de75005..a839a6fab2fa86c94f9c81ddc6ae7e85b0b1cddd 100644 (file)
@@ -46,10 +46,10 @@ static av_cold int audio_read_header(AVFormatContext *s1)
         return ret;
 
     /* take real parameters */
-    st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id    = s->codec_id;
-    st->codec->sample_rate = s->sample_rate;
-    st->codec->channels    = s->channels;
+    st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_id    = s->codec_id;
+    st->codecpar->sample_rate = s->sample_rate;
+    st->codecpar->channels    = s->channels;
 
     avpriv_set_pts_info(st, 64, 1, 1000000);  /* 64 bits pts in us */
 
index fad361062b76b4f340560e34cfb080880cd15ed6..97b1827f82a8962c43183bb83cb8ee36716435c1 100644 (file)
@@ -35,8 +35,8 @@ static av_cold int audio_write_header(AVFormatContext *s1)
     int ret;
 
     st             = s1->streams[0];
-    s->sample_rate = st->codec->sample_rate;
-    s->channels    = st->codec->channels;
+    s->sample_rate = st->codecpar->sample_rate;
+    s->channels    = st->codecpar->channels;
 
     ret = ff_sndio_open(s1, 1, s1->filename);
 
index 41dc0a12f8e3c447137225d3dc9fd9f7f2edbb13..46db25dbd3a5271b709f45d0ded3860862f04ec0 100644 (file)
@@ -827,8 +827,8 @@ static int v4l2_read_header(AVFormatContext *s1)
     if ((res = v4l2_set_parameters(s1) < 0))
         return res;
 
-    st->codec->pix_fmt = fmt_v4l2ff(desired_format, codec_id);
-    s->frame_size = av_image_get_buffer_size(st->codec->pix_fmt,
+    st->codecpar->format = fmt_v4l2ff(desired_format, codec_id);
+    s->frame_size = av_image_get_buffer_size(st->codecpar->format,
                                              s->width, s->height, 1);
 
     if ((res = mmap_init(s1)) ||
@@ -839,14 +839,14 @@ static int v4l2_read_header(AVFormatContext *s1)
 
     s->top_field_first = first_field(s->fd);
 
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id = codec_id;
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id = codec_id;
     if (codec_id == AV_CODEC_ID_RAWVIDEO)
-        st->codec->codec_tag =
-            avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
-    st->codec->width = s->width;
-    st->codec->height = s->height;
-    st->codec->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8;
+        st->codecpar->codec_tag =
+            avcodec_pix_fmt_to_codec_tag(st->codecpar->format);
+    st->codecpar->width = s->width;
+    st->codecpar->height = s->height;
+    st->codecpar->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8;
 
     return 0;
 }
index cc73e82bd00dfcb0232714cecbee9fdc74fb01c6..b0b2086883ba63cbfab02737f14840bbddd15bad 100644 (file)
@@ -244,7 +244,7 @@ static int vfw_read_close(AVFormatContext *s)
 static int vfw_read_header(AVFormatContext *s)
 {
     struct vfw_ctx *ctx = s->priv_data;
-    AVCodecContext *codec;
+    AVCodecParameters *par;
     AVStream *st;
     int devnum;
     int bisize;
@@ -373,29 +373,30 @@ static int vfw_read_header(AVFormatContext *s)
     if(!ret)
         goto fail_io;
 
-    codec = st->codec;
-    codec->time_base = (AVRational){framerate_q.den, framerate_q.num};
-    codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    codec->width  = bi->bmiHeader.biWidth;
-    codec->height = bi->bmiHeader.biHeight;
-    codec->pix_fmt = vfw_pixfmt(biCompression, biBitCount);
-    if(codec->pix_fmt == AV_PIX_FMT_NONE) {
-        codec->codec_id = vfw_codecid(biCompression);
-        if(codec->codec_id == AV_CODEC_ID_NONE) {
+    st->avg_frame_rate = framerate_q;
+
+    par = st->codecpar;
+    par->codec_type = AVMEDIA_TYPE_VIDEO;
+    par->width  = bi->bmiHeader.biWidth;
+    par->height = bi->bmiHeader.biHeight;
+    par->format = vfw_pixfmt(biCompression, biBitCount);
+    if (par->format == AV_PIX_FMT_NONE) {
+        par->codec_id = vfw_codecid(biCompression);
+        if (par->codec_id == AV_CODEC_ID_NONE) {
             av_log(s, AV_LOG_ERROR, "Unknown compression type. "
                              "Please report verbose (-v 9) debug information.\n");
             vfw_read_close(s);
             return AVERROR_PATCHWELCOME;
         }
-        codec->bits_per_coded_sample = biBitCount;
+        par->bits_per_coded_sample = biBitCount;
     } else {
-        codec->codec_id = AV_CODEC_ID_RAWVIDEO;
+        par->codec_id = AV_CODEC_ID_RAWVIDEO;
         if(biCompression == BI_RGB) {
-            codec->bits_per_coded_sample = biBitCount;
-            codec->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE);
-            if (codec->extradata) {
-                codec->extradata_size = 9;
-                memcpy(codec->extradata, "BottomUp", 9);
+            par->bits_per_coded_sample = biBitCount;
+            par->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE);
+            if (par->extradata) {
+                par->extradata_size = 9;
+                memcpy(par->extradata, "BottomUp", 9);
             }
         }
     }
index b2721ae8c638faf4343cf4aa6236e174b2019f9d..20b299995e397367306fa9f1df26c08b1f728807 100644 (file)
@@ -347,16 +347,17 @@ static int x11grab_read_header(AVFormatContext *s1)
     x11grab->image      = image;
     x11grab->use_shm    = use_shm;
 
-    ret = pixfmt_from_image(s1, image, &st->codec->pix_fmt);
+    ret = pixfmt_from_image(s1, image, &st->codecpar->format);
     if (ret < 0)
         goto out;
 
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id   = AV_CODEC_ID_RAWVIDEO;
-    st->codec->width      = x11grab->width;
-    st->codec->height     = x11grab->height;
-    st->codec->time_base  = x11grab->time_base;
-    st->codec->bit_rate   = x11grab->frame_size * 1 / av_q2d(x11grab->time_base) * 8;
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id   = AV_CODEC_ID_RAWVIDEO;
+    st->codecpar->width      = x11grab->width;
+    st->codecpar->height     = x11grab->height;
+    st->codecpar->bit_rate   = x11grab->frame_size * 1 / av_q2d(x11grab->time_base) * 8;
+
+    st->avg_frame_rate       = av_inv_q(x11grab->time_base);
 
 out:
     av_free(param);
index 356518ae5fd33c1581327d1ded83642a9bf6345f..9b85c28e24c6791426c9a3fea39aa17765c673ff 100644 (file)
@@ -544,13 +544,12 @@ static int create_stream(AVFormatContext *s)
                                   st->avg_frame_rate.num };
     c->time_frame = av_gettime();
 
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id   = AV_CODEC_ID_RAWVIDEO;
-    st->codec->width      = c->width;
-    st->codec->height     = c->height;
-    st->codec->time_base  = c->time_base;
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id   = AV_CODEC_ID_RAWVIDEO;
+    st->codecpar->width      = c->width;
+    st->codecpar->height     = c->height;
 
-    ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codec->pix_fmt);
+    ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codecpar->format);
 
     free(geo);
 
index 5eaf9851b7b96380d4159553e6b39a79f24f9a8f..6889ca4c377939f6df42611e01605a6d974c441d 100644 (file)
@@ -108,16 +108,16 @@ static int parse_vtrk(AVFormatContext *s,
 
     fourxm->video_stream_index = st->index;
 
-    st->codec->codec_type     = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id       = AV_CODEC_ID_4XM;
+    st->codecpar->codec_type     = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id       = AV_CODEC_ID_4XM;
 
-    st->codec->extradata      = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE);
-    if (!st->codec->extradata)
+    st->codecpar->extradata      = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE);
+    if (!st->codecpar->extradata)
         return AVERROR(ENOMEM);
-    st->codec->extradata_size = 4;
-    AV_WL32(st->codec->extradata, AV_RL32(buf + 16));
-    st->codec->width  = AV_RL32(buf + 36);
-    st->codec->height = AV_RL32(buf + 40);
+    st->codecpar->extradata_size = 4;
+    AV_WL32(st->codecpar->extradata, AV_RL32(buf + 16));
+    st->codecpar->width  = AV_RL32(buf + 36);
+    st->codecpar->height = AV_RL32(buf + 40);
 
     return 0;
 }
@@ -165,23 +165,23 @@ static int parse_strk(AVFormatContext *s,
 
     fourxm->tracks[track].stream_index = st->index;
 
-    st->codec->codec_type            = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_tag             = 0;
-    st->codec->channels              = fourxm->tracks[track].channels;
-    st->codec->sample_rate           = fourxm->tracks[track].sample_rate;
-    st->codec->bits_per_coded_sample = fourxm->tracks[track].bits;
-    st->codec->bit_rate              = st->codec->channels *
-                                       st->codec->sample_rate *
-                                       st->codec->bits_per_coded_sample;
-    st->codec->block_align           = st->codec->channels *
-                                       st->codec->bits_per_coded_sample;
+    st->codecpar->codec_type            = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_tag             = 0;
+    st->codecpar->channels              = fourxm->tracks[track].channels;
+    st->codecpar->sample_rate           = fourxm->tracks[track].sample_rate;
+    st->codecpar->bits_per_coded_sample = fourxm->tracks[track].bits;
+    st->codecpar->bit_rate              = st->codecpar->channels *
+                                          st->codecpar->sample_rate *
+                                          st->codecpar->bits_per_coded_sample;
+    st->codecpar->block_align           = st->codecpar->channels *
+                                          st->codecpar->bits_per_coded_sample;
 
     if (fourxm->tracks[track].adpcm){
-        st->codec->codec_id = AV_CODEC_ID_ADPCM_4XM;
-    } else if (st->codec->bits_per_coded_sample == 8) {
-        st->codec->codec_id = AV_CODEC_ID_PCM_U8;
+        st->codecpar->codec_id = AV_CODEC_ID_ADPCM_4XM;
+    } else if (st->codecpar->bits_per_coded_sample == 8) {
+        st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
     } else
-        st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
+        st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
 
     return 0;
 }
index c8e8e646b52d7c2b9b257736a907867cf93baffa..fdd6f62750e651b85d3925c6e436b7321fd50510 100644 (file)
@@ -27,7 +27,7 @@
 
 static int a64_write_header(AVFormatContext *s)
 {
-    AVCodecContext *avctx = s->streams[0]->codec;
+    AVCodecParameters *par = s->streams[0]->codecpar;
     uint8_t header[5] = {
         0x00, //load
         0x40, //address
@@ -36,20 +36,20 @@ static int a64_write_header(AVFormatContext *s)
         0x00  //fps in 50/fps;
     };
 
-    if (avctx->extradata_size < 4) {
+    if (par->extradata_size < 4) {
         av_log(s, AV_LOG_ERROR, "Missing extradata\n");
         return AVERROR_INVALIDDATA;
     }
 
-    switch (avctx->codec->id) {
+    switch (par->codec_id) {
     case AV_CODEC_ID_A64_MULTI:
         header[2] = 0x00;
-        header[3] = AV_RB32(avctx->extradata+0);
+        header[3] = AV_RB32(par->extradata+0);
         header[4] = 2;
         break;
     case AV_CODEC_ID_A64_MULTI5:
         header[2] = 0x01;
-        header[3] = AV_RB32(avctx->extradata+0);
+        header[3] = AV_RB32(par->extradata+0);
         header[4] = 3;
         break;
     default:
index 566c3e78b916c9a5a4f15e780c966787fd5672ff..2f207928dbb3a44078d62636f5ebc15d4a7ae4d7 100644 (file)
@@ -82,8 +82,8 @@ static int adts_aac_read_header(AVFormatContext *s)
     if (!st)
         return AVERROR(ENOMEM);
 
-    st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id   = s->iformat->raw_codec_id;
+    st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_id   = s->iformat->raw_codec_id;
     st->need_parsing      = AVSTREAM_PARSE_FULL;
 
     ff_id3v1_read(s);
index 55d7510557fca7bb08ffc29c210e3c2325db38a2..e7c72d8c026ac0b6f3227daf0330cbf8230da31d 100644 (file)
@@ -91,11 +91,11 @@ static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t
 static int adts_write_header(AVFormatContext *s)
 {
     ADTSContext *adts = s->priv_data;
-    AVCodecContext *avc = s->streams[0]->codec;
+    AVCodecParameters *par = s->streams[0]->codecpar;
 
-    if (avc->extradata_size > 0)
-        return adts_decode_extradata(s, adts, avc->extradata,
-                                     avc->extradata_size);
+    if (par->extradata_size > 0)
+        return adts_decode_extradata(s, adts, par->extradata,
+                                     par->extradata_size);
 
     return 0;
 }
index c7bd33ab8be10874b2b168e31372773ac10e5a8a..8162c69a9aa1cc7b5c440bfea715f183339a511c 100644 (file)
@@ -37,10 +37,10 @@ typedef struct ADXDemuxerContext {
 static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
     ADXDemuxerContext *c = s->priv_data;
-    AVCodecContext *avctx = s->streams[0]->codec;
+    AVCodecParameters *par = s->streams[0]->codecpar;
     int ret, size;
 
-    size = BLOCK_SIZE * avctx->channels;
+    size = BLOCK_SIZE * par->channels;
 
     pkt->pos = avio_tell(s->pb);
     pkt->stream_index = 0;
@@ -64,43 +64,43 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)
 static int adx_read_header(AVFormatContext *s)
 {
     ADXDemuxerContext *c = s->priv_data;
-    AVCodecContext *avctx;
+    AVCodecParameters *par;
 
     AVStream *st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
-    avctx = s->streams[0]->codec;
+    par = s->streams[0]->codecpar;
 
     if (avio_rb16(s->pb) != 0x8000)
         return AVERROR_INVALIDDATA;
     c->header_size = avio_rb16(s->pb) + 4;
     avio_seek(s->pb, -4, SEEK_CUR);
 
-    avctx->extradata = av_mallocz(c->header_size + AV_INPUT_BUFFER_PADDING_SIZE);
-    if (!avctx->extradata)
+    par->extradata = av_mallocz(c->header_size + AV_INPUT_BUFFER_PADDING_SIZE);
+    if (!par->extradata)
         return AVERROR(ENOMEM);
-    if (avio_read(s->pb, avctx->extradata, c->header_size) < c->header_size) {
-        av_freep(&avctx->extradata);
+    if (avio_read(s->pb, par->extradata, c->header_size) < c->header_size) {
+        av_freep(&par->extradata);
         return AVERROR(EIO);
     }
-    avctx->extradata_size = c->header_size;
+    par->extradata_size = c->header_size;
 
-    if (avctx->extradata_size < 12) {
+    if (par->extradata_size < 12) {
         av_log(s, AV_LOG_ERROR, "Invalid extradata size.\n");
         return AVERROR_INVALIDDATA;
     }
-    avctx->channels    = AV_RB8(avctx->extradata + 7);
-    avctx->sample_rate = AV_RB32(avctx->extradata + 8);
+    par->channels    = AV_RB8 (par->extradata + 7);
+    par->sample_rate = AV_RB32(par->extradata + 8);
 
-    if (avctx->channels <= 0) {
-        av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", avctx->channels);
+    if (par->channels <= 0) {
+        av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->channels);
         return AVERROR_INVALIDDATA;
     }
 
-    st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id    = s->iformat->raw_codec_id;
+    par->codec_type  = AVMEDIA_TYPE_AUDIO;
+    par->codec_id    = s->iformat->raw_codec_id;
 
-    avpriv_set_pts_info(st, 64, BLOCK_SAMPLES, avctx->sample_rate);
+    avpriv_set_pts_info(st, 64, BLOCK_SAMPLES, par->sample_rate);
 
     return 0;
 }
index c107109cfac0d5a83f522947cb50cff207708b2e..a20bf7ca67ceed3ee1f848a7ede5b954268de747 100644 (file)
@@ -62,29 +62,29 @@ static int aea_read_header(AVFormatContext *s)
 
     /* Parse the amount of channels and skip to pos 2048(0x800) */
     avio_skip(s->pb, 264);
-    st->codec->channels = avio_r8(s->pb);
+    st->codecpar->channels = avio_r8(s->pb);
     avio_skip(s->pb, 1783);
 
 
-    st->codec->codec_type     = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id       = AV_CODEC_ID_ATRAC1;
-    st->codec->sample_rate    = 44100;
-    st->codec->bit_rate       = 292000;
+    st->codecpar->codec_type     = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_id       = AV_CODEC_ID_ATRAC1;
+    st->codecpar->sample_rate    = 44100;
+    st->codecpar->bit_rate       = 292000;
 
-    if (st->codec->channels != 1 && st->codec->channels != 2) {
-        av_log(s,AV_LOG_ERROR,"Channels %d not supported!\n",st->codec->channels);
+    if (st->codecpar->channels != 1 && st->codecpar->channels != 2) {
+        av_log(s, AV_LOG_ERROR, "Channels %d not supported!\n", st->codecpar->channels);
         return AVERROR_INVALIDDATA;
     }
 
-    st->codec->channel_layout = (st->codec->channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
+    st->codecpar->channel_layout = (st->codecpar->channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
 
-    st->codec->block_align = AT1_SU_SIZE * st->codec->channels;
+    st->codecpar->block_align = AT1_SU_SIZE * st->codecpar->channels;
     return 0;
 }
 
 static int aea_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
-    int ret = av_get_packet(s->pb, pkt, s->streams[0]->codec->block_align);
+    int ret = av_get_packet(s->pb, pkt, s->streams[0]->codecpar->block_align);
 
     pkt->stream_index = 0;
     if (ret <= 0)
index fc0b7ebf81a7b9fb00cffd4264e2f85a974167df..e56390937ea84313a9a605ebf0d5de73feda36cc 100644 (file)
@@ -90,7 +90,7 @@ static unsigned int get_aiff_header(AVFormatContext *s, int size,
                                     unsigned version)
 {
     AVIOContext *pb        = s->pb;
-    AVCodecContext *codec  = s->streams[0]->codec;
+    AVCodecParameters *par = s->streams[0]->codecpar;
     AIFFInputContext *aiff = s->priv_data;
     int exp;
     uint64_t val;
@@ -99,30 +99,30 @@ static unsigned int get_aiff_header(AVFormatContext *s, int size,
 
     if (size & 1)
         size++;
-    codec->codec_type = AVMEDIA_TYPE_AUDIO;
-    codec->channels = avio_rb16(pb);
+    par->codec_type = AVMEDIA_TYPE_AUDIO;
+    par->channels = avio_rb16(pb);
     num_frames = avio_rb32(pb);
-    codec->bits_per_coded_sample = avio_rb16(pb);
+    par->bits_per_coded_sample = avio_rb16(pb);
 
     exp = avio_rb16(pb);
     val = avio_rb64(pb);
     sample_rate = ldexp(val, exp - 16383 - 63);
-    codec->sample_rate = sample_rate;
+    par->sample_rate = sample_rate;
     size -= 18;
 
     /* get codec id for AIFF-C */
     if (version == AIFF_C_VERSION1) {
-        codec->codec_tag = avio_rl32(pb);
-        codec->codec_id  = ff_codec_get_id(ff_codec_aiff_tags, codec->codec_tag);
+        par->codec_tag = avio_rl32(pb);
+        par->codec_id  = ff_codec_get_id(ff_codec_aiff_tags, par->codec_tag);
         size -= 4;
     }
 
-    if (version != AIFF_C_VERSION1 || codec->codec_id == AV_CODEC_ID_PCM_S16BE) {
-        codec->codec_id = aiff_codec_get_id(codec->bits_per_coded_sample);
-        codec->bits_per_coded_sample = av_get_bits_per_sample(codec->codec_id);
+    if (version != AIFF_C_VERSION1 || par->codec_id == AV_CODEC_ID_PCM_S16BE) {
+        par->codec_id = aiff_codec_get_id(par->bits_per_coded_sample);
+        par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);
         aiff->block_duration = 1;
     } else {
-        switch (codec->codec_id) {
+        switch (par->codec_id) {
         case AV_CODEC_ID_PCM_F32BE:
         case AV_CODEC_ID_PCM_F64BE:
         case AV_CODEC_ID_PCM_S16LE:
@@ -131,37 +131,37 @@ static unsigned int get_aiff_header(AVFormatContext *s, int size,
             aiff->block_duration = 1;
             break;
         case AV_CODEC_ID_ADPCM_IMA_QT:
-            codec->block_align = 34*codec->channels;
+            par->block_align = 34 * par->channels;
             break;
         case AV_CODEC_ID_MACE3:
-            codec->block_align = 2*codec->channels;
+            par->block_align = 2 * par->channels;
             break;
         case AV_CODEC_ID_ADPCM_G722:
         case AV_CODEC_ID_MACE6:
-            codec->block_align = 1*codec->channels;
+            par->block_align = 1 * par->channels;
             break;
         case AV_CODEC_ID_GSM:
-            codec->block_align = 33;
+            par->block_align = 33;
             break;
         case AV_CODEC_ID_QCELP:
-            codec->block_align = 35;
+            par->block_align = 35;
             break;
         default:
             break;
         }
-        if (codec->block_align > 0)
-            aiff->block_duration = av_get_audio_frame_duration(codec,
-                                                               codec->block_align);
+        if (par->block_align > 0)
+            aiff->block_duration = av_get_audio_frame_duration2(par,
+                                                                par->block_align);
     }
 
     /* Block align needs to be computed in all cases, as the definition
      * is specific to applications -> here we use the WAVE format definition */
-    if (!codec->block_align)
-        codec->block_align = (codec->bits_per_coded_sample * codec->channels) >> 3;
+    if (!par->block_align)
+        par->block_align = (par->bits_per_coded_sample * par->channels) >> 3;
 
     if (aiff->block_duration) {
-        codec->bit_rate = codec->sample_rate * (codec->block_align << 3) /
-                          aiff->block_duration;
+        par->bit_rate = par->sample_rate * (par->block_align << 3) /
+                        aiff->block_duration;
     }
 
     /* Chunk is over */
@@ -249,7 +249,7 @@ static int aiff_read_header(AVFormatContext *s)
             offset = avio_rb32(pb);      /* Offset of sound data */
             avio_rb32(pb);               /* BlockSize... don't care */
             offset += avio_tell(pb);    /* Compute absolute data offset */
-            if (st->codec->block_align)    /* Assume COMM already parsed */
+            if (st->codecpar->block_align)    /* Assume COMM already parsed */
                 goto got_sound;
             if (!pb->seekable) {
                 av_log(s, AV_LOG_ERROR, "file is not seekable\n");
@@ -260,11 +260,11 @@ static int aiff_read_header(AVFormatContext *s)
         case MKTAG('w', 'a', 'v', 'e'):
             if ((uint64_t)size > (1<<30))
                 return -1;
-            st->codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
-            if (!st->codec->extradata)
+            st->codecpar->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
+            if (!st->codecpar->extradata)
                 return AVERROR(ENOMEM);
-            st->codec->extradata_size = size;
-            avio_read(pb, st->codec->extradata, size);
+            st->codecpar->extradata_size = size;
+            avio_read(pb, st->codecpar->extradata, size);
             break;
         default: /* Jump */
             if (size & 1)   /* Always even aligned */
@@ -274,13 +274,13 @@ static int aiff_read_header(AVFormatContext *s)
     }
 
 got_sound:
-    if (!st->codec->block_align) {
+    if (!st->codecpar->block_align) {
         av_log(s, AV_LOG_ERROR, "could not find COMM tag or invalid block_align value\n");
         return -1;
     }
 
     /* Now positioned, get the sound data start and end */
-    avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+    avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
     st->start_time = 0;
     st->duration = st->nb_frames * aiff->block_duration;
 
@@ -306,10 +306,10 @@ static int aiff_read_packet(AVFormatContext *s,
         return AVERROR_EOF;
 
     /* Now for that packet */
-    if (st->codec->block_align >= 33) // GSM, QCLP, IMA4
-        size = st->codec->block_align;
+    if (st->codecpar->block_align >= 33) // GSM, QCLP, IMA4
+        size = st->codecpar->block_align;
     else
-        size = (MAX_SIZE / st->codec->block_align) * st->codec->block_align;
+        size = (MAX_SIZE / st->codecpar->block_align) * st->codecpar->block_align;
     size = FFMIN(max_size, size);
     res = av_get_packet(s->pb, pkt, size);
     if (res < 0)
@@ -317,7 +317,7 @@ static int aiff_read_packet(AVFormatContext *s,
 
     /* Only one stream in an AIFF file */
     pkt->stream_index = 0;
-    pkt->duration     = (res / st->codec->block_align) * aiff->block_duration;
+    pkt->duration     = (res / st->codecpar->block_align) * aiff->block_duration;
     return 0;
 }
 
index aa6810836825a70d97dc29c3ad4689a0b906fe58..6449c00cada7db9e794e93b070580d264a1b3c3b 100644 (file)
@@ -37,14 +37,14 @@ static int aiff_write_header(AVFormatContext *s)
 {
     AIFFOutputContext *aiff = s->priv_data;
     AVIOContext *pb = s->pb;
-    AVCodecContext *enc = s->streams[0]->codec;
+    AVCodecParameters *par = s->streams[0]->codecpar;
     uint64_t sample_rate;
     int aifc = 0;
 
     /* First verify if format is ok */
-    if (!enc->codec_tag)
+    if (!par->codec_tag)
         return -1;
-    if (enc->codec_tag != MKTAG('N','O','N','E'))
+    if (par->codec_tag != MKTAG('N','O','N','E'))
         aifc = 1;
 
     /* FORM AIFF header */
@@ -54,8 +54,8 @@ static int aiff_write_header(AVFormatContext *s)
     ffio_wfourcc(pb, aifc ? "AIFC" : "AIFF");
 
     if (aifc) { // compressed audio
-        enc->bits_per_coded_sample = 16;
-        if (!enc->block_align) {
+        par->bits_per_coded_sample = 16;
+        if (!par->block_align) {
             av_log(s, AV_LOG_ERROR, "block align not set\n");
             return -1;
         }
@@ -68,28 +68,28 @@ static int aiff_write_header(AVFormatContext *s)
     /* Common chunk */
     ffio_wfourcc(pb, "COMM");
     avio_wb32(pb, aifc ? 24 : 18); /* size */
-    avio_wb16(pb, enc->channels);  /* Number of channels */
+    avio_wb16(pb, par->channels);  /* Number of channels */
 
     aiff->frames = avio_tell(pb);
     avio_wb32(pb, 0);              /* Number of frames */
 
-    if (!enc->bits_per_coded_sample)
-        enc->bits_per_coded_sample = av_get_bits_per_sample(enc->codec_id);
-    if (!enc->bits_per_coded_sample) {
+    if (!par->bits_per_coded_sample)
+        par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);
+    if (!par->bits_per_coded_sample) {
         av_log(s, AV_LOG_ERROR, "could not compute bits per sample\n");
         return -1;
     }
-    if (!enc->block_align)
-        enc->block_align = (enc->bits_per_coded_sample * enc->channels) >> 3;
+    if (!par->block_align)
+        par->block_align = (par->bits_per_coded_sample * par->channels) >> 3;
 
-    avio_wb16(pb, enc->bits_per_coded_sample); /* Sample size */
+    avio_wb16(pb, par->bits_per_coded_sample); /* Sample size */
 
-    sample_rate = av_double2int(enc->sample_rate);
+    sample_rate = av_double2int(par->sample_rate);
     avio_wb16(pb, (sample_rate >> 52) + (16383 - 1023));
     avio_wb64(pb, UINT64_C(1) << 63 | sample_rate << 11);
 
     if (aifc) {
-        avio_wl32(pb, enc->codec_tag);
+        avio_wl32(pb, par->codec_tag);
         avio_wb16(pb, 0);
     }
 
@@ -100,7 +100,7 @@ static int aiff_write_header(AVFormatContext *s)
     avio_wb32(pb, 0);                    /* Data offset */
     avio_wb32(pb, 0);                    /* Block-size (block align) */
 
-    avpriv_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate);
+    avpriv_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codecpar->sample_rate);
 
     /* Data is starting here */
     avio_flush(pb);
@@ -119,7 +119,7 @@ static int aiff_write_trailer(AVFormatContext *s)
 {
     AVIOContext *pb = s->pb;
     AIFFOutputContext *aiff = s->priv_data;
-    AVCodecContext *enc = s->streams[0]->codec;
+    AVCodecParameters *par = s->streams[0]->codecpar;
 
     /* Chunks sizes must be even */
     int64_t file_size, end_size;
@@ -136,7 +136,7 @@ static int aiff_write_trailer(AVFormatContext *s)
 
         /* Number of sample frames */
         avio_seek(pb, aiff->frames, SEEK_SET);
-        avio_wb32(pb, (file_size-aiff->ssnd-12)/enc->block_align);
+        avio_wb32(pb, (file_size - aiff->ssnd - 12) / par->block_align);
 
         /* Sound Data chunk size */
         avio_seek(pb, aiff->ssnd, SEEK_SET);
index b57a5685258377f60b2f446197f0c34231cf14fb..580e9339a3e190864a98dbae703cc633a244c010 100644 (file)
@@ -37,13 +37,13 @@ static const char AMRWB_header[] = "#!AMR-WB\n";
 static int amr_write_header(AVFormatContext *s)
 {
     AVIOContext    *pb  = s->pb;
-    AVCodecContext *enc = s->streams[0]->codec;
+    AVCodecParameters *par = s->streams[0]->codecpar;
 
     s->priv_data = NULL;
 
-    if (enc->codec_id == AV_CODEC_ID_AMR_NB) {
+    if (par->codec_id == AV_CODEC_ID_AMR_NB) {
         avio_write(pb, AMR_header,   sizeof(AMR_header)   - 1); /* magic number */
-    } else if (enc->codec_id == AV_CODEC_ID_AMR_WB) {
+    } else if (par->codec_id == AV_CODEC_ID_AMR_WB) {
         avio_write(pb, AMRWB_header, sizeof(AMRWB_header) - 1); /* magic number */
     } else {
         return -1;
@@ -89,25 +89,25 @@ static int amr_read_header(AVFormatContext *s)
             return -1;
         }
 
-        st->codec->codec_tag   = MKTAG('s', 'a', 'w', 'b');
-        st->codec->codec_id    = AV_CODEC_ID_AMR_WB;
-        st->codec->sample_rate = 16000;
+        st->codecpar->codec_tag   = MKTAG('s', 'a', 'w', 'b');
+        st->codecpar->codec_id    = AV_CODEC_ID_AMR_WB;
+        st->codecpar->sample_rate = 16000;
     } else {
-        st->codec->codec_tag   = MKTAG('s', 'a', 'm', 'r');
-        st->codec->codec_id    = AV_CODEC_ID_AMR_NB;
-        st->codec->sample_rate = 8000;
+        st->codecpar->codec_tag   = MKTAG('s', 'a', 'm', 'r');
+        st->codecpar->codec_id    = AV_CODEC_ID_AMR_NB;
+        st->codecpar->sample_rate = 8000;
     }
-    st->codec->channels   = 1;
-    st->codec->channel_layout = AV_CH_LAYOUT_MONO;
-    st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-    avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+    st->codecpar->channels   = 1;
+    st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+    st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+    avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
 
     return 0;
 }
 
 static int amr_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
-    AVCodecContext *enc = s->streams[0]->codec;
+    AVCodecParameters *par = s->streams[0]->codecpar;
     int read, size = 0, toc, mode;
     int64_t pos = avio_tell(s->pb);
 
@@ -119,13 +119,13 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt)
     toc  = avio_r8(s->pb);
     mode = (toc >> 3) & 0x0F;
 
-    if (enc->codec_id == AV_CODEC_ID_AMR_NB) {
+    if (par->codec_id == AV_CODEC_ID_AMR_NB) {
         static const uint8_t packed_size[16] = {
             12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0
         };
 
         size = packed_size[mode] + 1;
-    } else if (enc->codec_id == AV_CODEC_ID_AMR_WB) {
+    } else if (par->codec_id == AV_CODEC_ID_AMR_WB) {
         static const uint8_t packed_size[16] = {
             18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1
         };
@@ -139,12 +139,12 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt)
         return AVERROR(EIO);
 
     /* Both AMR formats have 50 frames per second */
-    s->streams[0]->codec->bit_rate = size*8*50;
+    s->streams[0]->codecpar->bit_rate = size*8*50;
 
     pkt->stream_index = 0;
     pkt->pos          = pos;
     pkt->data[0]      = toc;
-    pkt->duration     = enc->codec_id == AV_CODEC_ID_AMR_NB ? 160 : 320;
+    pkt->duration     = par->codec_id == AV_CODEC_ID_AMR_NB ? 160 : 320;
     read              = avio_read(s->pb, pkt->data + 1, size - 1);
 
     if (read != size - 1) {
index 69a13744f1a4c8f6756c54c52d9fe5933be7689d..2ab6712f267b32cf432191534708d80fa659f2cf 100644 (file)
@@ -100,11 +100,11 @@ static int read_header(AVFormatContext *s)
     st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id   = AV_CODEC_ID_ANM;
-    st->codec->codec_tag  = 0; /* no fourcc */
-    st->codec->width      = avio_rl16(pb);
-    st->codec->height     = avio_rl16(pb);
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id   = AV_CODEC_ID_ANM;
+    st->codecpar->codec_tag  = 0; /* no fourcc */
+    st->codecpar->width      = avio_rl16(pb);
+    st->codecpar->height     = avio_rl16(pb);
     if (avio_r8(pb) != 0)
         goto invalid;
     avio_skip(pb, 1); /* frame rate multiplier info */
@@ -132,12 +132,12 @@ static int read_header(AVFormatContext *s)
     avio_skip(pb, 58);
 
     /* color cycling and palette data */
-    st->codec->extradata_size = 16*8 + 4*256;
-    st->codec->extradata      = av_mallocz(st->codec->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
-    if (!st->codec->extradata) {
+    st->codecpar->extradata_size = 16*8 + 4*256;
+    st->codecpar->extradata      = av_mallocz(st->codecpar->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
+    if (!st->codecpar->extradata) {
         return AVERROR(ENOMEM);
     }
-    ret = avio_read(pb, st->codec->extradata, st->codec->extradata_size);
+    ret = avio_read(pb, st->codecpar->extradata, st->codecpar->extradata_size);
     if (ret < 0)
         return ret;
 
index 58fd9f8771428d4bb62148072aaab695a5b9181a..40ecdf2c5d6ebe514bf5c79de4a4d4d9397488f4 100644 (file)
@@ -45,33 +45,33 @@ static int apc_read_header(AVFormatContext *s)
     if (!st)
         return AVERROR(ENOMEM);
 
-    st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_APC;
+    st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_APC;
 
     avio_rl32(pb); /* number of samples */
-    st->codec->sample_rate = avio_rl32(pb);
+    st->codecpar->sample_rate = avio_rl32(pb);
 
-    st->codec->extradata_size = 2 * 4;
-    st->codec->extradata = av_malloc(st->codec->extradata_size +
-                                     AV_INPUT_BUFFER_PADDING_SIZE);
-    if (!st->codec->extradata)
+    st->codecpar->extradata_size = 2 * 4;
+    st->codecpar->extradata = av_malloc(st->codecpar->extradata_size +
+                                        AV_INPUT_BUFFER_PADDING_SIZE);
+    if (!st->codecpar->extradata)
         return AVERROR(ENOMEM);
 
     /* initial predictor values for adpcm decoder */
-    avio_read(pb, st->codec->extradata, 2 * 4);
+    avio_read(pb, st->codecpar->extradata, 2 * 4);
 
     if (avio_rl32(pb)) {
-        st->codec->channels       = 2;
-        st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
+        st->codecpar->channels       = 2;
+        st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
     } else {
-        st->codec->channels       = 1;
-        st->codec->channel_layout = AV_CH_LAYOUT_MONO;
+        st->codecpar->channels       = 1;
+        st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
     }
 
-    st->codec->bits_per_coded_sample = 4;
-    st->codec->bit_rate = st->codec->bits_per_coded_sample * st->codec->channels
-                          * st->codec->sample_rate;
-    st->codec->block_align = 1;
+    st->codecpar->bits_per_coded_sample = 4;
+    st->codecpar->bit_rate = st->codecpar->bits_per_coded_sample * st->codecpar->channels
+                          * st->codecpar->sample_rate;
+    st->codecpar->block_align = 1;
 
     return 0;
 }
index 09a756da609a2f2258f26389b0a968a90a09544b..bcc1f7aa0786d61f00c3ba323c5c898c32e311d4 100644 (file)
@@ -344,23 +344,23 @@ static int ape_read_header(AVFormatContext * s)
 
     total_blocks = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks;
 
-    st->codec->codec_type      = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id        = AV_CODEC_ID_APE;
-    st->codec->codec_tag       = MKTAG('A', 'P', 'E', ' ');
-    st->codec->channels        = ape->channels;
-    st->codec->sample_rate     = ape->samplerate;
-    st->codec->bits_per_coded_sample = ape->bps;
+    st->codecpar->codec_type      = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_id        = AV_CODEC_ID_APE;
+    st->codecpar->codec_tag       = MKTAG('A', 'P', 'E', ' ');
+    st->codecpar->channels        = ape->channels;
+    st->codecpar->sample_rate     = ape->samplerate;
+    st->codecpar->bits_per_coded_sample = ape->bps;
 
     st->nb_frames = ape->totalframes;
     st->start_time = 0;
     st->duration  = total_blocks / MAC_SUBFRAME_SIZE;
     avpriv_set_pts_info(st, 64, MAC_SUBFRAME_SIZE, ape->samplerate);
 
-    st->codec->extradata = av_malloc(APE_EXTRADATA_SIZE);
-    st->codec->extradata_size = APE_EXTRADATA_SIZE;
-    AV_WL16(st->codec->extradata + 0, ape->fileversion);
-    AV_WL16(st->codec->extradata + 2, ape->compressiontype);
-    AV_WL16(st->codec->extradata + 4, ape->formatflags);
+    st->codecpar->extradata = av_malloc(APE_EXTRADATA_SIZE);
+    st->codecpar->extradata_size = APE_EXTRADATA_SIZE;
+    AV_WL16(st->codecpar->extradata + 0, ape->fileversion);
+    AV_WL16(st->codecpar->extradata + 2, ape->compressiontype);
+    AV_WL16(st->codecpar->extradata + 4, ape->formatflags);
 
     pts = 0;
     for (i = 0; i < ape->totalframes; i++) {
index 5591555377e2b11a4e94b54733bb443cfb4dac68..044bfd8022ee779b01311d2b336077e363fc7f2a 100644 (file)
@@ -87,22 +87,22 @@ static int ape_tag_read_field(AVFormatContext *s)
             }
 
             st->disposition      |= AV_DISPOSITION_ATTACHED_PIC;
-            st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-            st->codec->codec_id   = id;
+            st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+            st->codecpar->codec_id   = id;
 
             st->attached_pic              = pkt;
             st->attached_pic.stream_index = st->index;
             st->attached_pic.flags       |= AV_PKT_FLAG_KEY;
         } else {
-            st->codec->extradata = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE);
-            if (!st->codec->extradata)
+            st->codecpar->extradata = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE);
+            if (!st->codecpar->extradata)
                 return AVERROR(ENOMEM);
-            if (avio_read(pb, st->codec->extradata, size) != size) {
-                av_freep(&st->codec->extradata);
+            if (avio_read(pb, st->codecpar->extradata, size) != size) {
+                av_freep(&st->codecpar->extradata);
                 return AVERROR(EIO);
             }
-            st->codec->extradata_size = size;
-            st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
+            st->codecpar->extradata_size = size;
+            st->codecpar->codec_type = AVMEDIA_TYPE_ATTACHMENT;
         }
     } else {
         value = av_malloc(size+1);
index 85d32668f864e394d97c0bdf74b191482b22f197..e3320e9b6954217fbc35b28b1bc6c0b3ba2554c1 100644 (file)
@@ -431,8 +431,8 @@ static int asf_read_picture(AVFormatContext *s, int len)
     }
 
     st->disposition              |= AV_DISPOSITION_ATTACHED_PIC;
-    st->codec->codec_type         = asf_st->type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id           = id;
+    st->codecpar->codec_type      = asf_st->type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id        = id;
     st->attached_pic              = pkt;
     st->attached_pic.stream_index = asf_st->index = st->index;
     st->attached_pic.flags       |= AV_PKT_FLAG_KEY;
@@ -695,26 +695,26 @@ static int parse_video_info(AVIOContext *pb, AVStream *st)
     uint16_t size;
     unsigned int tag;
 
-    st->codec->width  = avio_rl32(pb);
-    st->codec->height = avio_rl32(pb);
+    st->codecpar->width  = avio_rl32(pb);
+    st->codecpar->height = avio_rl32(pb);
     avio_skip(pb, 1); // skip reserved flags
     size = avio_rl16(pb); // size of the Format Data
     tag  = ff_get_bmp_header(pb, st);
-    st->codec->codec_tag = tag;
-    st->codec->codec_id  = ff_codec_get_id(ff_codec_bmp_tags, tag);
+    st->codecpar->codec_tag = tag;
+    st->codecpar->codec_id  = ff_codec_get_id(ff_codec_bmp_tags, tag);
 
     if (size > BMP_HEADER_SIZE) {
         int ret;
-        st->codec->extradata_size  = size - BMP_HEADER_SIZE;
-        if (!(st->codec->extradata = av_malloc(st->codec->extradata_size +
+        st->codecpar->extradata_size  = size - BMP_HEADER_SIZE;
+        if (!(st->codecpar->extradata = av_malloc(st->codecpar->extradata_size +
                                                AV_INPUT_BUFFER_PADDING_SIZE))) {
-            st->codec->extradata_size = 0;
+            st->codecpar->extradata_size = 0;
             return AVERROR(ENOMEM);
         }
-        memset(st->codec->extradata + st->codec->extradata_size , 0,
+        memset(st->codecpar->extradata + st->codecpar->extradata_size , 0,
                AV_INPUT_BUFFER_PADDING_SIZE);
-        if ((ret = avio_read(pb, st->codec->extradata,
-                             st->codec->extradata_size)) < 0)
+        if ((ret = avio_read(pb, st->codecpar->extradata,
+                             st->codecpar->extradata_size)) < 0)
             return ret;
     }
     return 0;
@@ -773,7 +773,7 @@ static int asf_read_stream_properties(AVFormatContext *s, const GUIDParseTable *
     if (!st)
         return AVERROR(ENOMEM);
     avpriv_set_pts_info(st, 32, 1, 1000); // pts should be dword, in milliseconds
-    st->codec->codec_type = type;
+    st->codecpar->codec_type = type;
     asf->asf_st[asf->nb_streams] = av_mallocz(sizeof(*asf_st));
     if (!asf->asf_st[asf->nb_streams])
         return AVERROR(ENOMEM);
@@ -790,7 +790,7 @@ static int asf_read_stream_properties(AVFormatContext *s, const GUIDParseTable *
     switch (type) {
     case AVMEDIA_TYPE_AUDIO:
         asf_st->type = AVMEDIA_TYPE_AUDIO;
-        if ((ret = ff_get_wav_header(s, pb, st->codec, ts_data_len)) < 0)
+        if ((ret = ff_get_wav_header(s, pb, st->codecpar, ts_data_len)) < 0)
             return ret;
         break;
     case AVMEDIA_TYPE_VIDEO:
@@ -867,7 +867,7 @@ static int asf_read_ext_stream_properties(AVFormatContext *s, const GUIDParseTab
     if (st) {
         st->start_time           = start_time;
         st->duration             = end_time - start_time;
-        st->codec->bit_rate      = bitrate;
+        st->codecpar->bit_rate   = bitrate;
         st->avg_frame_rate.num   = 10000000;
         st->avg_frame_rate.den   = time_per_frame;
     }
index f6608d52923b0ff0f4f7b47978877c5f80171d36..79eb08310b058b06f8f8144b95533cc204f9f162 100644 (file)
@@ -377,7 +377,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
     int header_size, n, extra_size, extra_size2, wav_extra_size, file_time;
     int has_title;
     int metadata_count;
-    AVCodecContext *enc;
+    AVCodecParameters *par;
     int64_t header_offset, cur_pos, hpos;
     int bit_rate;
     int64_t duration;
@@ -396,11 +396,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
 
     bit_rate = 0;
     for (n = 0; n < s->nb_streams; n++) {
-        enc = s->streams[n]->codec;
+        par = s->streams[n]->codecpar;
 
         avpriv_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit pts in ms */
 
-        bit_rate += enc->bit_rate;
+        bit_rate += par->bit_rate;
     }
 
     if (asf->is_streamed) {
@@ -479,11 +479,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
         int64_t es_pos;
         //        ASFStream *stream = &asf->streams[n];
 
-        enc                 = s->streams[n]->codec;
+        par                 = s->streams[n]->codecpar;
         asf->streams[n].num = n + 1;
         asf->streams[n].seq = 0;
 
-        switch (enc->codec_type) {
+        switch (par->codec_type) {
         case AVMEDIA_TYPE_AUDIO:
             wav_extra_size = 0;
             extra_size     = 18 + wav_extra_size;
@@ -491,14 +491,14 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
             break;
         default:
         case AVMEDIA_TYPE_VIDEO:
-            wav_extra_size = enc->extradata_size;
+            wav_extra_size = par->extradata_size;
             extra_size     = 0x33 + wav_extra_size;
             extra_size2    = 0;
             break;
         }
 
         hpos = put_header(pb, &ff_asf_stream_header);
-        if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
+        if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
             put_guid(pb, &ff_asf_audio_stream);
             put_guid(pb, &ff_asf_audio_conceal_spread);
         } else {
@@ -512,9 +512,9 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
         avio_wl16(pb, n + 1); /* stream number */
         avio_wl32(pb, 0); /* ??? */
 
-        if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
+        if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
             /* WAVEFORMATEX header */
-            int wavsize = ff_put_wav_header(pb, enc);
+            int wavsize = ff_put_wav_header(s, pb, par);
 
             if (wavsize < 0)
                 return -1;
@@ -526,23 +526,23 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
             }
             /* ERROR Correction */
             avio_w8(pb, 0x01);
-            if (enc->codec_id == AV_CODEC_ID_ADPCM_G726 || !enc->block_align) {
+            if (par->codec_id == AV_CODEC_ID_ADPCM_G726 || !par->block_align) {
                 avio_wl16(pb, 0x0190);
                 avio_wl16(pb, 0x0190);
             } else {
-                avio_wl16(pb, enc->block_align);
-                avio_wl16(pb, enc->block_align);
+                avio_wl16(pb, par->block_align);
+                avio_wl16(pb, par->block_align);
             }
             avio_wl16(pb, 0x01);
             avio_w8(pb, 0x00);
         } else {
-            avio_wl32(pb, enc->width);
-            avio_wl32(pb, enc->height);
+            avio_wl32(pb, par->width);
+            avio_wl32(pb, par->height);
             avio_w8(pb, 2); /* ??? */
-            avio_wl16(pb, 40 + enc->extradata_size); /* size */
+            avio_wl16(pb, 40 + par->extradata_size); /* size */
 
             /* BITMAPINFOHEADER header */
-            ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 1);
+            ff_put_bmp_header(pb, par, ff_codec_bmp_tags, 1);
         }
         end_header(pb, hpos);
     }
@@ -556,17 +556,17 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
         const AVCodecDescriptor *codec_desc;
         const char *desc;
 
-        enc  = s->streams[n]->codec;
-        codec_desc = avcodec_descriptor_get(enc->codec_id);
+        par  = s->streams[n]->codecpar;
+        codec_desc = avcodec_descriptor_get(par->codec_id);
 
-        if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
+        if (par->codec_type == AVMEDIA_TYPE_AUDIO)
             avio_wl16(pb, 2);
-        else if (enc->codec_type == AVMEDIA_TYPE_VIDEO)
+        else if (par->codec_type == AVMEDIA_TYPE_VIDEO)
             avio_wl16(pb, 1);
         else
             avio_wl16(pb, -1);
 
-        if (enc->codec_id == AV_CODEC_ID_WMAV2)
+        if (par->codec_id == AV_CODEC_ID_WMAV2)
             desc = "Windows Media Audio V8";
         else
             desc = codec_desc ? codec_desc->name : NULL;
@@ -591,14 +591,14 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
         avio_wl16(pb, 0); /* no parameters */
 
         /* id */
-        if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
+        if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
             avio_wl16(pb, 2);
-            avio_wl16(pb, enc->codec_tag);
+            avio_wl16(pb, par->codec_tag);
         } else {
             avio_wl16(pb, 4);
-            avio_wl32(pb, enc->codec_tag);
+            avio_wl32(pb, par->codec_tag);
         }
-        if (!enc->codec_tag)
+        if (!par->codec_tag)
             return -1;
     }
     end_header(pb, hpos);
@@ -813,7 +813,7 @@ static void put_frame(AVFormatContext *s, ASFStream *stream, AVStream *avst,
                         PACKET_HEADER_MIN_SIZE - 1;
 
             if (frag_len1 < payload_len &&
-                avst->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+                avst->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
                 flush_packet(s);
                 continue;
             }
@@ -855,16 +855,16 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
     AVIOContext *pb = s->pb;
     ASFStream *stream;
     int64_t duration;
-    AVCodecContext *codec;
+    AVCodecParameters *par;
     int64_t packet_st, pts;
     int start_sec, i;
     int flags = pkt->flags;
     uint64_t offset = avio_tell(pb);
 
-    codec  = s->streams[pkt->stream_index]->codec;
+    par  = s->streams[pkt->stream_index]->codecpar;
     stream = &asf->streams[pkt->stream_index];
 
-    if (codec->codec_type == AVMEDIA_TYPE_AUDIO)
+    if (par->codec_type == AVMEDIA_TYPE_AUDIO)
         flags &= ~AV_PKT_FLAG_KEY;
 
     pts = (pkt->pts != AV_NOPTS_VALUE) ? pkt->pts : pkt->dts;
index f9f1bdfb9ae0a37e495b3fde816c0e63c00ca895..059cefe0812aef86903a7ca650578f67aa16e993 100644 (file)
@@ -91,11 +91,11 @@ static int read_header(AVFormatContext *s)
     if (!st)
         return -1;
     avpriv_set_pts_info(st, 64, 1, 100);
-    st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
-    st->codec->codec_id   = AV_CODEC_ID_SSA;
+    st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+    st->codecpar->codec_id   = AV_CODEC_ID_SSA;
 
     header_remaining = INT_MAX;
-    dst[0] = &st->codec->extradata;
+    dst[0] = &st->codecpar->extradata;
     dst[1] = &ass->event_buffer;
     while (!pb->eof_reached) {
         uint8_t line[MAX_LINESIZE];
@@ -123,7 +123,7 @@ static int read_header(AVFormatContext *s)
         else
             header_remaining--;
     }
-    st->codec->extradata_size = pos[0];
+    st->codecpar->extradata_size = pos[0];
 
     if (ass->event_count >= UINT_MAX / sizeof(*ass->event))
         goto fail;
@@ -163,7 +163,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
     if (ret < 0)
         return ret;
     pkt->flags |= AV_PKT_FLAG_KEY;
-    pkt->pos    = p - ass->event_buffer + s->streams[0]->codec->extradata_size;
+    pkt->pos    = p - ass->event_buffer + s->streams[0]->codecpar->extradata_size;
     pkt->pts    = pkt->dts = get_pts(p);
     memcpy(pkt->data, p, pkt->size);
 
index 751485dfb5862851075bd8119aef81562219c0a1..c6f9851c3b8d32a2291caa27ca086e9bc8dfcf91 100644 (file)
@@ -28,18 +28,18 @@ typedef struct ASSContext{
 static int write_header(AVFormatContext *s)
 {
     ASSContext *ass = s->priv_data;
-    AVCodecContext *avctx= s->streams[0]->codec;
+    AVCodecParameters *par = s->streams[0]->codecpar;
     uint8_t *last= NULL;
 
-    if(s->nb_streams != 1 || avctx->codec_id != AV_CODEC_ID_SSA){
+    if(s->nb_streams != 1 || par->codec_id != AV_CODEC_ID_SSA){
         av_log(s, AV_LOG_ERROR, "Exactly one ASS/SSA stream is needed.\n");
         return -1;
     }
 
-    while(ass->extra_index < avctx->extradata_size){
-        uint8_t *p  = avctx->extradata + ass->extra_index;
+    while(ass->extra_index < par->extradata_size){
+        uint8_t *p  = par->extradata + ass->extra_index;
         uint8_t *end= strchr(p, '\n');
-        if(!end) end= avctx->extradata + avctx->extradata_size;
+        if(!end) end= par->extradata + par->extradata_size;
         else     end++;
 
         avio_write(s->pb, p, end-p);
@@ -64,10 +64,10 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 static int write_trailer(AVFormatContext *s)
 {
     ASSContext *ass = s->priv_data;
-    AVCodecContext *avctx= s->streams[0]->codec;
+    AVCodecParameters *par = s->streams[0]->codecpar;
 
-    avio_write(s->pb, avctx->extradata      + ass->extra_index,
-                      avctx->extradata_size - ass->extra_index);
+    avio_write(s->pb, par->extradata      + ass->extra_index,
+                      par->extradata_size - ass->extra_index);
 
     return 0;
 }
index e682cbf3058da37b44d15b9aa395454fb52ab938..e30314239fac9a5cf44a6df09f3ef9f824a4cdbe 100644 (file)
@@ -108,13 +108,13 @@ static int au_read_header(AVFormatContext *s)
     st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
-    st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_tag   = id;
-    st->codec->codec_id    = codec;
-    st->codec->channels    = channels;
-    st->codec->sample_rate = rate;
-    st->codec->bit_rate    = channels * rate * bps;
-    st->codec->block_align = channels * bps >> 3;
+    st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_tag   = id;
+    st->codecpar->codec_id    = codec;
+    st->codecpar->channels    = channels;
+    st->codecpar->sample_rate = rate;
+    st->codecpar->bit_rate    = channels * rate * bps;
+    st->codecpar->block_align = channels * bps >> 3;
 
     st->start_time = 0;
     avpriv_set_pts_info(st, 64, 1, rate);
@@ -127,12 +127,12 @@ static int au_read_packet(AVFormatContext *s, AVPacket *pkt)
     int ret;
 
     ret = av_get_packet(s->pb, pkt, BLOCK_SIZE *
-                        s->streams[0]->codec->block_align);
+                        s->streams[0]->codecpar->block_align);
     if (ret < 0)
         return ret;
 
     pkt->stream_index = 0;
-    pkt->duration     = ret / s->streams[0]->codec->block_align;
+    pkt->duration     = ret / s->streams[0]->codecpar->block_align;
 
     return 0;
 }
@@ -157,17 +157,17 @@ AVInputFormat ff_au_demuxer = {
 #define AU_UNKNOWN_SIZE ((uint32_t)(~0))
 
 /* AUDIO_FILE header */
-static int put_au_header(AVIOContext *pb, AVCodecContext *enc)
+static int put_au_header(AVIOContext *pb, AVCodecParameters *par)
 {
-    if (!enc->codec_tag)
+    if (!par->codec_tag)
         return AVERROR(EINVAL);
 
     ffio_wfourcc(pb, ".snd");                   /* magic number */
     avio_wb32(pb, 24);                          /* header size */
     avio_wb32(pb, AU_UNKNOWN_SIZE);             /* data size */
-    avio_wb32(pb, enc->codec_tag);              /* codec ID */
-    avio_wb32(pb, enc->sample_rate);
-    avio_wb32(pb, enc->channels);
+    avio_wb32(pb, par->codec_tag);              /* codec ID */
+    avio_wb32(pb, par->sample_rate);
+    avio_wb32(pb, par->channels);
 
     return 0;
 }
@@ -179,7 +179,7 @@ static int au_write_header(AVFormatContext *s)
 
     s->priv_data = NULL;
 
-    if ((ret = put_au_header(pb, s->streams[0]->codec)) < 0)
+    if ((ret = put_au_header(pb, s->streams[0]->codecpar)) < 0)
         return ret;
 
     avio_flush(pb);
index fd07893b5cdb74c81cddd465fa402a946ce5c837..aa379f675ea182137fb02e1ce5c1356153766061 100644 (file)
@@ -33,7 +33,7 @@ void ff_audio_interleave_close(AVFormatContext *s)
         AVStream *st = s->streams[i];
         AudioInterleaveContext *aic = st->priv_data;
 
-        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
             av_fifo_free(aic->fifo);
     }
 }
@@ -51,9 +51,9 @@ int ff_audio_interleave_init(AVFormatContext *s,
         AVStream *st = s->streams[i];
         AudioInterleaveContext *aic = st->priv_data;
 
-        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
-            aic->sample_size = (st->codec->channels *
-                                av_get_bits_per_sample(st->codec->codec_id)) / 8;
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+            aic->sample_size = (st->codecpar->channels *
+                                av_get_bits_per_sample(st->codecpar->codec_id)) / 8;
             if (!aic->sample_size) {
                 av_log(s, AV_LOG_ERROR, "could not compute sample size\n");
                 return -1;
@@ -106,7 +106,7 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt
     if (pkt) {
         AVStream *st = s->streams[pkt->stream_index];
         AudioInterleaveContext *aic = st->priv_data;
-        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
             unsigned new_size = av_fifo_size(aic->fifo) + pkt->size;
             if (new_size > aic->fifo_size) {
                 if (av_fifo_realloc2(aic->fifo, new_size) < 0)
@@ -126,7 +126,7 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt
 
     for (i = 0; i < s->nb_streams; i++) {
         AVStream *st = s->streams[i];
-        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
             AVPacket new_pkt = { 0 };
             while (interleave_new_audio_packet(s, &new_pkt, i, flush))
                 if ((ret = ff_interleave_add_packet(s, &new_pkt, compare_ts)) < 0)
index b63541d411a7296ba4e240808794a8bc725424fb..6db17f70cf2687985edc6b7815930ed1507b99aa 100644 (file)
@@ -704,18 +704,13 @@ typedef struct AVStream {
      * encoding: set by the user, replaced by libavformat if left unset
      */
     int id;
+#if FF_API_LAVF_AVCTX
     /**
-     * Codec context associated with this stream. Allocated and freed by
-     * libavformat.
-     *
-     * - decoding: The demuxer exports codec information stored in the headers
-     *             here.
-     * - encoding: The user sets codec information, the muxer writes it to the
-     *             output. Mandatory fields as specified in AVCodecContext
-     *             documentation must be set even if this AVCodecContext is
-     *             not actually used for encoding.
+     * @deprecated use the codecpar struct instead
      */
+    attribute_deprecated
     AVCodecContext *codec;
+#endif
     void *priv_data;
 
 #if FF_API_LAVF_FRAC
@@ -818,6 +813,17 @@ typedef struct AVStream {
     int event_flags;
 #define AVSTREAM_EVENT_FLAG_METADATA_UPDATED 0x0001 ///< The call resulted in updated metadata.
 
+    /*
+     * Codec parameters associated with this stream. Allocated and freed by
+     * libavformat in avformat_new_stream() and avformat_free_context()
+     * respectively.
+     *
+     * - demuxing: filled by libavformat on stream creation or in
+     *             avformat_find_stream_info()
+     * - muxing: filled by the caller before avformat_write_header()
+     */
+    AVCodecParameters *codecpar;
+
     /*****************************************************************
      * All fields below this line are not part of the public API. They
      * may not be used outside of libavformat and can be changed and
index 4cebd179191b05284f7775621b9add9dfad50e10..f5705e54364e039f67946a84584eb4d2513d2362 100644 (file)
@@ -487,8 +487,8 @@ static int avi_read_header(AVFormatContext *s)
                     goto fail;
 
                 ast = s->streams[0]->priv_data;
-                av_freep(&s->streams[0]->codec->extradata);
-                av_freep(&s->streams[0]->codec);
+                av_freep(&s->streams[0]->codecpar->extradata);
+                av_freep(&s->streams[0]->codecpar);
                 av_freep(&s->streams[0]->info);
                 av_freep(&s->streams[0]);
                 s->nb_streams = 0;
@@ -606,10 +606,10 @@ static int avi_read_header(AVFormatContext *s)
                 switch (codec_type) {
                 case AVMEDIA_TYPE_VIDEO:
                     if (amv_file_format) {
-                        st->codec->width      = avih_width;
-                        st->codec->height     = avih_height;
-                        st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-                        st->codec->codec_id   = AV_CODEC_ID_AMV;
+                        st->codecpar->width      = avih_width;
+                        st->codecpar->height     = avih_height;
+                        st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+                        st->codecpar->codec_id   = AV_CODEC_ID_AMV;
                         avio_skip(pb, size);
                         break;
                     }
@@ -617,41 +617,41 @@ static int avi_read_header(AVFormatContext *s)
 
                     if (tag1 == MKTAG('D', 'X', 'S', 'B') ||
                         tag1 == MKTAG('D', 'X', 'S', 'A')) {
-                        st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
-                        st->codec->codec_tag  = tag1;
-                        st->codec->codec_id   = AV_CODEC_ID_XSUB;
+                        st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+                        st->codecpar->codec_tag  = tag1;
+                        st->codecpar->codec_id   = AV_CODEC_ID_XSUB;
                         break;
                     }
 
                     if (size > 10 * 4 && size < (1 << 30)) {
-                        st->codec->extradata_size = size - 10 * 4;
-                        st->codec->extradata      = av_malloc(st->codec->extradata_size +
-                                                              AV_INPUT_BUFFER_PADDING_SIZE);
-                        if (!st->codec->extradata) {
-                            st->codec->extradata_size = 0;
+                        st->codecpar->extradata_size = size - 10 * 4;
+                        st->codecpar->extradata      = av_malloc(st->codecpar->extradata_size +
+                                                                 AV_INPUT_BUFFER_PADDING_SIZE);
+                        if (!st->codecpar->extradata) {
+                            st->codecpar->extradata_size = 0;
                             return AVERROR(ENOMEM);
                         }
                         avio_read(pb,
-                                  st->codec->extradata,
-                                  st->codec->extradata_size);
+                                  st->codecpar->extradata,
+                                  st->codecpar->extradata_size);
                     }
 
                     // FIXME: check if the encoder really did this correctly
-                    if (st->codec->extradata_size & 1)
+                    if (st->codecpar->extradata_size & 1)
                         avio_r8(pb);
 
                     /* Extract palette from extradata if bpp <= 8.
                      * This code assumes that extradata contains only palette.
                      * This is true for all paletted codecs implemented in
                      * Libav. */
-                    if (st->codec->extradata_size &&
-                        (st->codec->bits_per_coded_sample <= 8)) {
-                        int pal_size = (1 << st->codec->bits_per_coded_sample) << 2;
+                    if (st->codecpar->extradata_size &&
+                        (st->codecpar->bits_per_coded_sample <= 8)) {
+                        int pal_size = (1 << st->codecpar->bits_per_coded_sample) << 2;
                         const uint8_t *pal_src;
 
-                        pal_size = FFMIN(pal_size, st->codec->extradata_size);
-                        pal_src  = st->codec->extradata +
-                                   st->codec->extradata_size - pal_size;
+                        pal_size = FFMIN(pal_size, st->codecpar->extradata_size);
+                        pal_src  = st->codecpar->extradata +
+                                   st->codecpar->extradata_size - pal_size;
 #if HAVE_BIGENDIAN
                         for (i = 0; i < pal_size / 4; i++)
                             ast->pal[i] = av_bswap32(((uint32_t *)pal_src)[i]);
@@ -663,17 +663,17 @@ static int avi_read_header(AVFormatContext *s)
 
                     print_tag("video", tag1, 0);
 
-                    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-                    st->codec->codec_tag  = tag1;
-                    st->codec->codec_id   = ff_codec_get_id(ff_codec_bmp_tags,
+                    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+                    st->codecpar->codec_tag  = tag1;
+                    st->codecpar->codec_id   = ff_codec_get_id(ff_codec_bmp_tags,
                                                             tag1);
                     /* If codec is not found yet, try with the mov tags. */
-                    if (!st->codec->codec_id) {
+                    if (!st->codecpar->codec_id) {
                         char tag_buf[32];
                         av_get_codec_tag_string(tag_buf, sizeof(tag_buf), tag1);
-                        st->codec->codec_id =
+                        st->codecpar->codec_id =
                             ff_codec_get_id(ff_codec_movvideo_tags, tag1);
-                        if (st->codec->codec_id)
+                        if (st->codecpar->codec_id)
                            av_log(s, AV_LOG_WARNING,
                                   "mov tag found in avi (fourcc %s)\n",
                                   tag_buf);
@@ -682,45 +682,45 @@ static int avi_read_header(AVFormatContext *s)
                      * for generating correct pts. */
                     st->need_parsing = AVSTREAM_PARSE_HEADERS;
 
-                    if (st->codec->codec_id == AV_CODEC_ID_MPEG4 &&
+                    if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4 &&
                         ast->handler == MKTAG('X', 'V', 'I', 'D'))
-                        st->codec->codec_tag = MKTAG('X', 'V', 'I', 'D');
+                        st->codecpar->codec_tag = MKTAG('X', 'V', 'I', 'D');
 
                     // Support "Resolution 1:1" for Avid AVI Codec
                     if (tag1 == MKTAG('A', 'V', 'R', 'n') &&
-                        st->codec->extradata_size >= 31   &&
-                        !memcmp(&st->codec->extradata[28], "1:1", 3))
-                        st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
-
-                    if (st->codec->codec_tag == 0 && st->codec->height > 0 &&
-                        st->codec->extradata_size < 1U << 30) {
-                        st->codec->extradata_size += 9;
-                        if ((ret = av_reallocp(&st->codec->extradata,
-                                               st->codec->extradata_size +
+                        st->codecpar->extradata_size >= 31   &&
+                        !memcmp(&st->codecpar->extradata[28], "1:1", 3))
+                        st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
+
+                    if (st->codecpar->codec_tag == 0 && st->codecpar->height > 0 &&
+                        st->codecpar->extradata_size < 1U << 30) {
+                        st->codecpar->extradata_size += 9;
+                        if ((ret = av_reallocp(&st->codecpar->extradata,
+                                               st->codecpar->extradata_size +
                                                AV_INPUT_BUFFER_PADDING_SIZE)) < 0) {
-                            st->codec->extradata_size = 0;
+                            st->codecpar->extradata_size = 0;
                             return ret;
                         } else
-                            memcpy(st->codec->extradata + st->codec->extradata_size - 9,
+                            memcpy(st->codecpar->extradata + st->codecpar->extradata_size - 9,
                                    "BottomUp", 9);
                     }
-                    st->codec->height = FFABS(st->codec->height);
+                    st->codecpar->height = FFABS(st->codecpar->height);
 
 //                    avio_skip(pb, size - 5 * 4);
                     break;
                 case AVMEDIA_TYPE_AUDIO:
-                    ret = ff_get_wav_header(s, pb, st->codec, size);
+                    ret = ff_get_wav_header(s, pb, st->codecpar, size);
                     if (ret < 0)
                         return ret;
-                    ast->dshow_block_align = st->codec->block_align;
-                    if (ast->sample_size && st->codec->block_align &&
-                        ast->sample_size != st->codec->block_align) {
+                    ast->dshow_block_align = st->codecpar->block_align;
+                    if (ast->sample_size && st->codecpar->block_align &&
+                        ast->sample_size != st->codecpar->block_align) {
                         av_log(s,
                                AV_LOG_WARNING,
                                "sample size (%d) != block align (%d)\n",
                                ast->sample_size,
-                               st->codec->block_align);
-                        ast->sample_size = st->codec->block_align;
+                               st->codecpar->block_align);
+                        ast->sample_size = st->codecpar->block_align;
                     }
                     /* 2-aligned
                      * (fix for Stargate SG-1 - 3x18 - Shades of Grey.avi) */
@@ -732,28 +732,28 @@ static int avi_read_header(AVFormatContext *s)
                     /* ADTS header is in extradata, AAC without header must be
                      * stored as exact frames. Parser not needed and it will
                      * fail. */
-                    if (st->codec->codec_id == AV_CODEC_ID_AAC &&
-                        st->codec->extradata_size)
+                    if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
+                        st->codecpar->extradata_size)
                         st->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")) {
-                        st->codec->codec_id  = AV_CODEC_ID_XAN_DPCM;
-                        st->codec->codec_tag = 0;
+                        st->codecpar->codec_id  = AV_CODEC_ID_XAN_DPCM;
+                        st->codecpar->codec_tag = 0;
                     }
                     if (amv_file_format) {
-                        st->codec->codec_id    = AV_CODEC_ID_ADPCM_IMA_AMV;
+                        st->codecpar->codec_id    = AV_CODEC_ID_ADPCM_IMA_AMV;
                         ast->dshow_block_align = 0;
                     }
                     break;
                 case AVMEDIA_TYPE_SUBTITLE:
-                    st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
-                    st->codec->codec_id   = AV_CODEC_ID_PROBE;
+                    st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+                    st->codecpar->codec_id   = AV_CODEC_ID_PROBE;
                     break;
                 default:
-                    st->codec->codec_type = AVMEDIA_TYPE_DATA;
-                    st->codec->codec_id   = AV_CODEC_ID_NONE;
-                    st->codec->codec_tag  = 0;
+                    st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+                    st->codecpar->codec_id   = AV_CODEC_ID_NONE;
+                    st->codecpar->codec_tag  = 0;
                     avio_skip(pb, size);
                     break;
                 }
@@ -895,8 +895,7 @@ static int read_gab2_sub(AVStream *st, AVPacket *pkt)
         ast->sub_ctx->pb = pb;
         if (!avformat_open_input(&ast->sub_ctx, "", sub_demuxer, NULL)) {
             ff_read_packet(ast->sub_ctx, &ast->sub_pkt);
-            *st->codec = *ast->sub_ctx->streams[0]->codec;
-            ast->sub_ctx->streams[0]->codec->extradata = NULL;
+            avcodec_parameters_copy(st->codecpar, ast->sub_ctx->streams[0]->codecpar);
             time_base = ast->sub_ctx->streams[0]->time_base;
             avpriv_set_pts_info(st, 64, time_base.num, time_base.den);
         }
@@ -1022,8 +1021,8 @@ start_sync:
                 AVIStream *ast1 = st1->priv_data;
                 // workaround for broken small-file-bug402.avi
                 if (d[2] == 'w' && d[3] == 'b' && n == 0 &&
-                    st->codec->codec_type  == AVMEDIA_TYPE_VIDEO &&
-                    st1->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
+                    st->codecpar->codec_type  == AVMEDIA_TYPE_VIDEO &&
+                    st1->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
                     ast->prefix == 'd' * 256 + 'c' &&
                     (d[2] * 256 + d[3] == ast1->prefix ||
                      !ast1->prefix_count)) {
@@ -1230,8 +1229,8 @@ resync:
             pkt->flags |= AV_PKT_FLAG_KEY;
             if (size < 0)
                 av_packet_unref(pkt);
-        } else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE &&
-                   !st->codec->codec_tag && read_gab2_sub(st, pkt)) {
+        } else if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE &&
+                   !st->codecpar->codec_tag && read_gab2_sub(st, pkt)) {
             ast->frame_offset++;
             avi->stream_index = -1;
             ast->remaining    = 0;
@@ -1255,7 +1254,7 @@ resync:
                     size);
             pkt->stream_index = avi->stream_index;
 
-            if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+            if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
                 AVIndexEntry *e;
                 int index;
                 assert(st->index_entries);
@@ -1391,7 +1390,7 @@ static int check_stream_max_drift(AVFormatContext *s)
                 max_dts = FFMAX(max_dts, dts);
                 max_buffer = FFMAX(max_buffer,
                                    av_rescale(dts - min_dts,
-                                              st->codec->bit_rate,
+                                              st->codecpar->bit_rate,
                                               AV_TIME_BASE));
             }
         }
@@ -1555,7 +1554,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
         if (st2->nb_index_entries <= 0)
             continue;
 
-//        assert(st2->codec->block_align);
+//        assert(st2->codecpar->block_align);
         assert((int64_t)st2->time_base.num * ast2->rate ==
                (int64_t)st2->time_base.den * ast2->scale);
         index = av_index_search_timestamp(st2,
index 9c2936af604e55a1d90a43d6318c634380a72f4f..d89fab17e86758b5c62d4de29bf7befe0e0945e0 100644 (file)
@@ -111,21 +111,21 @@ static int avi_write_counters(AVFormatContext *s, int riff_id)
     AVIContext *avi = s->priv_data;
     int n, au_byterate, au_ssize, au_scale, nb_frames = 0;
     int64_t file_size;
-    AVCodecContext *stream;
+    AVCodecParameters *par;
 
     file_size = avio_tell(pb);
     for (n = 0; n < s->nb_streams; n++) {
         AVIStream *avist = s->streams[n]->priv_data;
 
         assert(avist->frames_hdr_strm);
-        stream = s->streams[n]->codec;
+        par = s->streams[n]->codecpar;
         avio_seek(pb, avist->frames_hdr_strm, SEEK_SET);
         ff_parse_specific_params(s->streams[n], &au_byterate, &au_ssize, &au_scale);
         if (au_ssize == 0)
             avio_wl32(pb, avist->packet_count);
         else
             avio_wl32(pb, avist->audio_strm_length / au_ssize);
-        if (stream->codec_type == AVMEDIA_TYPE_VIDEO)
+        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
             nb_frames = FFMAX(nb_frames, avist->packet_count);
     }
     if (riff_id == 1) {
@@ -143,7 +143,7 @@ static int avi_write_header(AVFormatContext *s)
     AVIContext *avi = s->priv_data;
     AVIOContext *pb = s->pb;
     int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale;
-    AVCodecContext *video_enc;
+    AVCodecParameters *video_par;
     AVStream *video_st = NULL;
     int64_t list1, list2, strh, strf;
     AVDictionaryEntry *t = NULL;
@@ -169,12 +169,12 @@ static int avi_write_header(AVFormatContext *s)
     avio_wl32(pb, 14 * 4);
     bitrate = 0;
 
-    video_enc = NULL;
+    video_par = NULL;
     for (n = 0; n < s->nb_streams; n++) {
-        AVCodecContext *codec = s->streams[n]->codec;
-        bitrate += codec->bit_rate;
-        if (codec->codec_type == AVMEDIA_TYPE_VIDEO) {
-            video_enc = codec;
+        AVCodecParameters *par = s->streams[n]->codecpar;
+        bitrate += par->bit_rate;
+        if (par->codec_type == AVMEDIA_TYPE_VIDEO) {
+            video_par = par;
             video_st = s->streams[n];
         }
     }
@@ -198,9 +198,9 @@ static int avi_write_header(AVFormatContext *s)
     avio_wl32(pb, 0); /* initial frame */
     avio_wl32(pb, s->nb_streams); /* nb streams */
     avio_wl32(pb, 1024 * 1024); /* suggested buffer size */
-    if (video_enc) {
-        avio_wl32(pb, video_enc->width);
-        avio_wl32(pb, video_enc->height);
+    if (video_par) {
+        avio_wl32(pb, video_par->width);
+        avio_wl32(pb, video_par->height);
     } else {
         avio_wl32(pb, 0);
         avio_wl32(pb, 0);
@@ -213,18 +213,18 @@ static int avi_write_header(AVFormatContext *s)
     /* stream list */
     for (i = 0; i < n; i++) {
         AVStream *st = s->streams[i];
-        AVCodecContext *enc = st->codec;
+        AVCodecParameters *par = st->codecpar;
         AVIStream *avist = st->priv_data;
         list2 = ff_start_tag(pb, "LIST");
         ffio_wfourcc(pb, "strl");
 
         /* stream generic header */
         strh = ff_start_tag(pb, "strh");
-        switch (enc->codec_type) {
+        switch (par->codec_type) {
         case AVMEDIA_TYPE_SUBTITLE:
             // XSUB subtitles behave like video tracks, other subtitles
             // are not (yet) supported.
-            if (enc->codec_id != AV_CODEC_ID_XSUB) {
+            if (par->codec_id != AV_CODEC_ID_XSUB) {
                 av_log(s, AV_LOG_ERROR,
                        "Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\n");
                 return AVERROR_PATCHWELCOME;
@@ -242,9 +242,9 @@ static int avi_write_header(AVFormatContext *s)
             ffio_wfourcc(pb, "dats");
             break;
         }
-        if (enc->codec_type == AVMEDIA_TYPE_VIDEO ||
-            enc->codec_id == AV_CODEC_ID_XSUB)
-            avio_wl32(pb, enc->codec_tag);
+        if (par->codec_type == AVMEDIA_TYPE_VIDEO ||
+            par->codec_id == AV_CODEC_ID_XSUB)
+            avio_wl32(pb, par->codec_tag);
         else
             avio_wl32(pb, 1);
         avio_wl32(pb, 0); /* flags */
@@ -268,32 +268,32 @@ static int avi_write_header(AVFormatContext *s)
             avio_wl32(pb, 0);  /* length, XXX: filled later */
 
         /* suggested buffer size */ //FIXME set at the end to largest chunk
-        if (enc->codec_type == AVMEDIA_TYPE_VIDEO)
+        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
             avio_wl32(pb, 1024 * 1024);
-        else if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
+        else if (par->codec_type == AVMEDIA_TYPE_AUDIO)
             avio_wl32(pb, 12 * 1024);
         else
             avio_wl32(pb, 0);
         avio_wl32(pb, -1); /* quality */
         avio_wl32(pb, au_ssize); /* sample size */
         avio_wl32(pb, 0);
-        avio_wl16(pb, enc->width);
-        avio_wl16(pb, enc->height);
+        avio_wl16(pb, par->width);
+        avio_wl16(pb, par->height);
         ff_end_tag(pb, strh);
 
-        if (enc->codec_type != AVMEDIA_TYPE_DATA) {
+        if (par->codec_type != AVMEDIA_TYPE_DATA) {
             strf = ff_start_tag(pb, "strf");
-            switch (enc->codec_type) {
+            switch (par->codec_type) {
             case AVMEDIA_TYPE_SUBTITLE:
                 /* XSUB subtitles behave like video tracks, other subtitles
                  * are not (yet) supported. */
-                if (enc->codec_id != AV_CODEC_ID_XSUB)
+                if (par->codec_id != AV_CODEC_ID_XSUB)
                     break;
             case AVMEDIA_TYPE_VIDEO:
-                ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 0);
+                ff_put_bmp_header(pb, par, ff_codec_bmp_tags, 0);
                 break;
             case AVMEDIA_TYPE_AUDIO:
-                if (ff_put_wav_header(pb, enc) < 0)
+                if (ff_put_wav_header(s, pb, par) < 0)
                     return -1;
                 break;
             default:
@@ -320,7 +320,7 @@ static int avi_write_header(AVFormatContext *s)
             avio_w8(pb, 0);     /* bIndexSubType (0 == frame index) */
             avio_w8(pb, 0);     /* bIndexType (0 == AVI_INDEX_OF_INDEXES) */
             avio_wl32(pb, 0);   /* nEntriesInUse (will fill out later on) */
-            ffio_wfourcc(pb, avi_stream2fourcc(tag, i, enc->codec_type));
+            ffio_wfourcc(pb, avi_stream2fourcc(tag, i, par->codec_type));
                                 /* dwChunkId */
             avio_wl64(pb, 0);   /* dwReserved[3] */
             // avio_wl32(pb, 0);   /* Must be 0.    */
@@ -329,13 +329,13 @@ static int avi_write_header(AVFormatContext *s)
             ff_end_tag(pb, avist->indexes.indx_start);
         }
 
-        if (enc->codec_type == AVMEDIA_TYPE_VIDEO   &&
+        if (par->codec_type == AVMEDIA_TYPE_VIDEO   &&
             st->sample_aspect_ratio.num > 0 &&
             st->sample_aspect_ratio.den > 0) {
             int vprp       = ff_start_tag(pb, "vprp");
             AVRational dar = av_mul_q(st->sample_aspect_ratio,
-                                      (AVRational) { enc->width,
-                                                     enc->height });
+                                      (AVRational) { par->width,
+                                                     par->height });
             int num, den;
             av_reduce(&num, &den, dar.num, dar.den, 0xFFFF);
 
@@ -343,18 +343,18 @@ static int avi_write_header(AVFormatContext *s)
             avio_wl32(pb, 0); // video standard = unknown
             // TODO: should be avg_frame_rate
             avio_wl32(pb, lrintf(1.0 / av_q2d(st->time_base)));
-            avio_wl32(pb, enc->width);
-            avio_wl32(pb, enc->height);
+            avio_wl32(pb, par->width);
+            avio_wl32(pb, par->height);
             avio_wl16(pb, den);
             avio_wl16(pb, num);
-            avio_wl32(pb, enc->width);
-            avio_wl32(pb, enc->height);
+            avio_wl32(pb, par->width);
+            avio_wl32(pb, par->height);
             avio_wl32(pb, 1); // progressive FIXME
 
-            avio_wl32(pb, enc->height);
-            avio_wl32(pb, enc->width);
-            avio_wl32(pb, enc->height);
-            avio_wl32(pb, enc->width);
+            avio_wl32(pb, par->height);
+            avio_wl32(pb, par->width);
+            avio_wl32(pb, par->height);
+            avio_wl32(pb, par->width);
             avio_wl32(pb, 0);
             avio_wl32(pb, 0);
 
@@ -412,7 +412,7 @@ static int avi_write_ix(AVFormatContext *s)
         AVIStream *avist = s->streams[i]->priv_data;
         int64_t ix, pos;
 
-        avi_stream2fourcc(tag, i, s->streams[i]->codec->codec_type);
+        avi_stream2fourcc(tag, i, s->streams[i]->codecpar->codec_type);
         ix_tag[3] = '0' + i;
 
         /* Writing AVI OpenDML leaf index chunk */
@@ -489,7 +489,7 @@ static int avi_write_idx1(AVFormatContext *s)
             if (!empty) {
                 avist = s->streams[stream_id]->priv_data;
                 avi_stream2fourcc(tag, stream_id,
-                                  s->streams[stream_id]->codec->codec_type);
+                                  s->streams[stream_id]->codecpar->codec_type);
                 ffio_wfourcc(pb, tag);
                 avio_wl32(pb, ie->flags);
                 avio_wl32(pb, ie->pos);
@@ -513,9 +513,9 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
     AVIContext *avi     = s->priv_data;
     AVIOContext *pb     = s->pb;
     AVIStream *avist    = s->streams[stream_index]->priv_data;
-    AVCodecContext *enc = s->streams[stream_index]->codec;
+    AVCodecParameters *par = s->streams[stream_index]->codecpar;
 
-    while (enc->block_align == 0 && pkt->dts != AV_NOPTS_VALUE &&
+    while (par->block_align == 0 && pkt->dts != AV_NOPTS_VALUE &&
            pkt->dts > avist->packet_count) {
         AVPacket empty_packet;
 
@@ -540,10 +540,10 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
         avi->movi_list = avi_start_new_riff(s, pb, "AVIX", "movi");
     }
 
-    avi_stream2fourcc(tag, stream_index, enc->codec_type);
+    avi_stream2fourcc(tag, stream_index, par->codec_type);
     if (pkt->flags & AV_PKT_FLAG_KEY)
         flags = 0x10;
-    if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
+    if (par->codec_type == AVMEDIA_TYPE_AUDIO)
         avist->audio_strm_length += size;
 
     if (s->pb->seekable) {
@@ -604,15 +604,15 @@ static int avi_write_trailer(AVFormatContext *s)
             avio_skip(pb, 16);
 
             for (n = nb_frames = 0; n < s->nb_streams; n++) {
-                AVCodecContext *stream = s->streams[n]->codec;
+                AVCodecParameters *par = s->streams[n]->codecpar;
                 AVIStream *avist       = s->streams[n]->priv_data;
 
-                if (stream->codec_type == AVMEDIA_TYPE_VIDEO) {
+                if (par->codec_type == AVMEDIA_TYPE_VIDEO) {
                     if (nb_frames < avist->packet_count)
                         nb_frames = avist->packet_count;
                 } else {
-                    if (stream->codec_id == AV_CODEC_ID_MP2 ||
-                        stream->codec_id == AV_CODEC_ID_MP3)
+                    if (par->codec_id == AV_CODEC_ID_MP2 ||
+                        par->codec_id == AV_CODEC_ID_MP3)
                         nb_frames += avist->packet_count;
                 }
             }
index 1a6a73f53ee025465e9c931be05ff6796580fa86..b00f9bc42eb483d50bd6c6936cdb32bab571637f 100644 (file)
@@ -233,10 +233,10 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st)
     AviSynthContext *avs = s->priv_data;
     int planar = 0; // 0: packed, 1: YUV, 2: Y8
 
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id   = AV_CODEC_ID_RAWVIDEO;
-    st->codec->width      = avs->vi->width;
-    st->codec->height     = avs->vi->height;
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id   = AV_CODEC_ID_RAWVIDEO;
+    st->codecpar->width      = avs->vi->width;
+    st->codecpar->height     = avs->vi->height;
 
     st->time_base         = (AVRational) { avs->vi->fps_denominator,
                                            avs->vi->fps_numerator };
@@ -249,38 +249,38 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st)
     switch (avs->vi->pixel_type) {
 #ifdef USING_AVISYNTH
     case AVS_CS_YV24:
-        st->codec->pix_fmt = AV_PIX_FMT_YUV444P;
-        planar             = 1;
+        st->codecpar->format = AV_PIX_FMT_YUV444P;
+        planar               = 1;
         break;
     case AVS_CS_YV16:
-        st->codec->pix_fmt = AV_PIX_FMT_YUV422P;
-        planar             = 1;
+        st->codecpar->format = AV_PIX_FMT_YUV422P;
+        planar               = 1;
         break;
     case AVS_CS_YV411:
-        st->codec->pix_fmt = AV_PIX_FMT_YUV411P;
-        planar             = 1;
+        st->codecpar->format = AV_PIX_FMT_YUV411P;
+        planar               = 1;
         break;
     case AVS_CS_Y8:
-        st->codec->pix_fmt = AV_PIX_FMT_GRAY8;
-        planar             = 2;
+        st->codecpar->format = AV_PIX_FMT_GRAY8;
+        planar               = 2;
         break;
 #endif
     case AVS_CS_BGR24:
-        st->codec->pix_fmt = AV_PIX_FMT_BGR24;
+        st->codecpar->format = AV_PIX_FMT_BGR24;
         break;
     case AVS_CS_BGR32:
-        st->codec->pix_fmt = AV_PIX_FMT_RGB32;
+        st->codecpar->format = AV_PIX_FMT_RGB32;
         break;
     case AVS_CS_YUY2:
-        st->codec->pix_fmt = AV_PIX_FMT_YUYV422;
+        st->codecpar->format = AV_PIX_FMT_YUYV422;
         break;
     case AVS_CS_YV12:
-        st->codec->pix_fmt = AV_PIX_FMT_YUV420P;
-        planar             = 1;
+        st->codecpar->format = AV_PIX_FMT_YUV420P;
+        planar               = 1;
         break;
     case AVS_CS_I420: // Is this even used anywhere?
-        st->codec->pix_fmt = AV_PIX_FMT_YUV420P;
-        planar             = 1;
+        st->codecpar->format = AV_PIX_FMT_YUV420P;
+        planar               = 1;
         break;
     default:
         av_log(s, AV_LOG_ERROR,
@@ -309,28 +309,28 @@ static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st)
 {
     AviSynthContext *avs = s->priv_data;
 
-    st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
-    st->codec->sample_rate = avs->vi->audio_samples_per_second;
-    st->codec->channels    = avs->vi->nchannels;
+    st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->sample_rate = avs->vi->audio_samples_per_second;
+    st->codecpar->channels    = avs->vi->nchannels;
     st->time_base          = (AVRational) { 1,
                                             avs->vi->audio_samples_per_second };
     st->duration           = avs->vi->num_audio_samples;
 
     switch (avs->vi->sample_type) {
     case AVS_SAMPLE_INT8:
-        st->codec->codec_id = AV_CODEC_ID_PCM_U8;
+        st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
         break;
     case AVS_SAMPLE_INT16:
-        st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
+        st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
         break;
     case AVS_SAMPLE_INT24:
-        st->codec->codec_id = AV_CODEC_ID_PCM_S24LE;
+        st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE;
         break;
     case AVS_SAMPLE_INT32:
-        st->codec->codec_id = AV_CODEC_ID_PCM_S32LE;
+        st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE;
         break;
     case AVS_SAMPLE_FLOAT:
-        st->codec->codec_id = AV_CODEC_ID_PCM_F32LE;
+        st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE;
         break;
     default:
         av_log(s, AV_LOG_ERROR,
@@ -639,7 +639,7 @@ static int avisynth_read_packet(AVFormatContext *s, AVPacket *pkt)
     /* If either stream reaches EOF, try to read the other one before
      * giving up. */
     avisynth_next_stream(s, &st, pkt, &discard);
-    if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+    if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
         ret = avisynth_read_packet_video(s, pkt, discard);
         if (ret == AVERROR_EOF && avs_has_audio(avs->vi)) {
             avisynth_next_stream(s, &st, pkt, &discard);
@@ -681,7 +681,7 @@ static int avisynth_read_seek(AVFormatContext *s, int stream_index,
     samplerate = (AVRational) { avs->vi->audio_samples_per_second, 1 };
 
     st = s->streams[stream_index];
-    if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+    if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
         /* AviSynth frame counts are signed int. */
         if ((timestamp >= avs->vi->num_frames) ||
             (timestamp > INT_MAX)              ||
index 74721b63c4b6c014f8e27e7bd0831934fd2c6ad9..c825a3abc4865307baadd04c5842556470c6188f 100644 (file)
@@ -184,11 +184,11 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)
                     avs->st_video = avformat_new_stream(s, NULL);
                     if (!avs->st_video)
                         return AVERROR(ENOMEM);
-                    avs->st_video->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-                    avs->st_video->codec->codec_id = AV_CODEC_ID_AVS;
-                    avs->st_video->codec->width = avs->width;
-                    avs->st_video->codec->height = avs->height;
-                    avs->st_video->codec->bits_per_coded_sample=avs->bits_per_sample;
+                    avs->st_video->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+                    avs->st_video->codecpar->codec_id = AV_CODEC_ID_AVS;
+                    avs->st_video->codecpar->width = avs->width;
+                    avs->st_video->codecpar->height = avs->height;
+                    avs->st_video->codecpar->bits_per_coded_sample=avs->bits_per_sample;
                     avs->st_video->nb_frames = avs->nb_frames;
                     avs->st_video->avg_frame_rate = (AVRational){avs->fps, 1};
                 }
@@ -200,7 +200,7 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)
                     avs->st_audio = avformat_new_stream(s, NULL);
                     if (!avs->st_audio)
                         return AVERROR(ENOMEM);
-                    avs->st_audio->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+                    avs->st_audio->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
                 }
                 avs->remaining_audio_size = size - 4;
                 size = avs_read_audio_packet(s, pkt);
index 135a3c491ae6cc855c3a7142417298d307b70a94..8ed9d4f290c9972f4935b2993b44290e3c342944 100644 (file)
@@ -113,13 +113,13 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
                                   "video packet");
         }
         avpriv_set_pts_info(st, 64, 185, vid->sample_rate);
-        st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-        st->codec->codec_id   = AV_CODEC_ID_BETHSOFTVID;
-        st->codec->width      = vid->width;
-        st->codec->height     = vid->height;
+        st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+        st->codecpar->codec_id   = AV_CODEC_ID_BETHSOFTVID;
+        st->codecpar->width      = vid->width;
+        st->codecpar->height     = vid->height;
     }
     st      = s->streams[vid->video_index];
-    npixels = st->codec->width * st->codec->height;
+    npixels = st->codecpar->width * st->codecpar->height;
 
     vidbuf_start = av_malloc(vidbuf_capacity = BUFFER_PADDING_SIZE);
     if(!vidbuf_start)
@@ -240,13 +240,13 @@ static int vid_read_packet(AVFormatContext *s,
                 if (!st)
                     return AVERROR(ENOMEM);
                 vid->audio_index                 = st->index;
-                st->codec->codec_type            = AVMEDIA_TYPE_AUDIO;
-                st->codec->codec_id              = AV_CODEC_ID_PCM_U8;
-                st->codec->channels              = 1;
-                st->codec->channel_layout        = AV_CH_LAYOUT_MONO;
-                st->codec->bits_per_coded_sample = 8;
-                st->codec->sample_rate           = vid->sample_rate;
-                st->codec->bit_rate              = 8 * st->codec->sample_rate;
+                st->codecpar->codec_type            = AVMEDIA_TYPE_AUDIO;
+                st->codecpar->codec_id              = AV_CODEC_ID_PCM_U8;
+                st->codecpar->channels              = 1;
+                st->codecpar->channel_layout        = AV_CH_LAYOUT_MONO;
+                st->codecpar->bits_per_coded_sample = 8;
+                st->codecpar->sample_rate           = vid->sample_rate;
+                st->codecpar->bit_rate              = 8 * st->codecpar->sample_rate;
                 st->start_time                   = 0;
                 avpriv_set_pts_info(st, 64, 1, vid->sample_rate);
             }
index 19060e760f518820c2924d43bf402ddd23c6e2ff..99371bd4c091355bbfa8953e7b40b2c751a3ceca 100644 (file)
@@ -75,34 +75,34 @@ static int bfi_read_header(AVFormatContext * s)
     avio_rl32(pb);
     fps                    = avio_rl32(pb);
     avio_skip(pb, 12);
-    vstream->codec->width  = avio_rl32(pb);
-    vstream->codec->height = avio_rl32(pb);
+    vstream->codecpar->width  = avio_rl32(pb);
+    vstream->codecpar->height = avio_rl32(pb);
 
     /*Load the palette to extradata */
     avio_skip(pb, 8);
-    vstream->codec->extradata      = av_malloc(768);
-    vstream->codec->extradata_size = 768;
-    avio_read(pb, vstream->codec->extradata,
-               vstream->codec->extradata_size);
+    vstream->codecpar->extradata      = av_malloc(768);
+    vstream->codecpar->extradata_size = 768;
+    avio_read(pb, vstream->codecpar->extradata,
+              vstream->codecpar->extradata_size);
 
-    astream->codec->sample_rate = avio_rl32(pb);
+    astream->codecpar->sample_rate = avio_rl32(pb);
 
     /* Set up the video codec... */
     avpriv_set_pts_info(vstream, 32, 1, fps);
-    vstream->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    vstream->codec->codec_id   = AV_CODEC_ID_BFI;
-    vstream->codec->pix_fmt    = AV_PIX_FMT_PAL8;
+    vstream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    vstream->codecpar->codec_id   = AV_CODEC_ID_BFI;
+    vstream->codecpar->format     = AV_PIX_FMT_PAL8;
 
     /* Set up the audio codec now... */
-    astream->codec->codec_type      = AVMEDIA_TYPE_AUDIO;
-    astream->codec->codec_id        = AV_CODEC_ID_PCM_U8;
-    astream->codec->channels        = 1;
-    astream->codec->channel_layout  = AV_CH_LAYOUT_MONO;
-    astream->codec->bits_per_coded_sample = 8;
-    astream->codec->bit_rate        =
-        astream->codec->sample_rate * astream->codec->bits_per_coded_sample;
+    astream->codecpar->codec_type      = AVMEDIA_TYPE_AUDIO;
+    astream->codecpar->codec_id        = AV_CODEC_ID_PCM_U8;
+    astream->codecpar->channels        = 1;
+    astream->codecpar->channel_layout  = AV_CH_LAYOUT_MONO;
+    astream->codecpar->bits_per_coded_sample = 8;
+    astream->codecpar->bit_rate        =
+        astream->codecpar->sample_rate * astream->codecpar->bits_per_coded_sample;
     avio_seek(pb, chunk_header - 3, SEEK_SET);
-    avpriv_set_pts_info(astream, 64, 1, astream->codec->sample_rate);
+    avpriv_set_pts_info(astream, 64, 1, astream->codecpar->sample_rate);
     return 0;
 }
 
index 608de245d3ee160d80c4de1fffc1b81673da8aec..807e51b3d9860d3919b1e950fd2d0905431fb031 100644 (file)
@@ -86,7 +86,7 @@ static int read_header(AVFormatContext *s)
     if (!vst)
         return AVERROR(ENOMEM);
 
-    vst->codec->codec_tag = avio_rl32(pb);
+    vst->codecpar->codec_tag = avio_rl32(pb);
 
     bink->file_size = avio_rl32(pb) + 8;
     vst->duration   = avio_rl32(pb);
@@ -104,8 +104,8 @@ static int read_header(AVFormatContext *s)
 
     avio_skip(pb, 4);
 
-    vst->codec->width  = avio_rl32(pb);
-    vst->codec->height = avio_rl32(pb);
+    vst->codecpar->width  = avio_rl32(pb);
+    vst->codecpar->height = avio_rl32(pb);
 
     fps_num = avio_rl32(pb);
     fps_den = avio_rl32(pb);
@@ -118,13 +118,13 @@ static int read_header(AVFormatContext *s)
     avpriv_set_pts_info(vst, 64, fps_den, fps_num);
     vst->avg_frame_rate = av_inv_q(vst->time_base);
 
-    vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    vst->codec->codec_id   = AV_CODEC_ID_BINKVIDEO;
-    vst->codec->extradata  = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE);
-    if (!vst->codec->extradata)
+    vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    vst->codecpar->codec_id   = AV_CODEC_ID_BINKVIDEO;
+    vst->codecpar->extradata  = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE);
+    if (!vst->codecpar->extradata)
         return AVERROR(ENOMEM);
-    vst->codec->extradata_size = 4;
-    avio_read(pb, vst->codec->extradata, 4);
+    vst->codecpar->extradata_size = 4;
+    avio_read(pb, vst->codecpar->extradata, 4);
 
     bink->num_audio_tracks = avio_rl32(pb);
 
@@ -142,25 +142,25 @@ static int read_header(AVFormatContext *s)
             ast = avformat_new_stream(s, NULL);
             if (!ast)
                 return AVERROR(ENOMEM);
-            ast->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
-            ast->codec->codec_tag   = 0;
-            ast->codec->sample_rate = avio_rl16(pb);
-            avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
+            ast->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
+            ast->codecpar->codec_tag   = 0;
+            ast->codecpar->sample_rate = avio_rl16(pb);
+            avpriv_set_pts_info(ast, 64, 1, ast->codecpar->sample_rate);
             flags = avio_rl16(pb);
-            ast->codec->codec_id = flags & BINK_AUD_USEDCT ?
+            ast->codecpar->codec_id = flags & BINK_AUD_USEDCT ?
                                    AV_CODEC_ID_BINKAUDIO_DCT : AV_CODEC_ID_BINKAUDIO_RDFT;
             if (flags & BINK_AUD_STEREO) {
-                ast->codec->channels       = 2;
-                ast->codec->channel_layout = AV_CH_LAYOUT_STEREO;
+                ast->codecpar->channels       = 2;
+                ast->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
             } else {
-                ast->codec->channels       = 1;
-                ast->codec->channel_layout = AV_CH_LAYOUT_MONO;
+                ast->codecpar->channels       = 1;
+                ast->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
             }
-            ast->codec->extradata = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE);
-            if (!ast->codec->extradata)
+            ast->codecpar->extradata = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE);
+            if (!ast->codecpar->extradata)
                 return AVERROR(ENOMEM);
-            ast->codec->extradata_size = 4;
-            AV_WL32(ast->codec->extradata, vst->codec->codec_tag);
+            ast->codecpar->extradata_size = 4;
+            AV_WL32(ast->codecpar->extradata, vst->codecpar->codec_tag);
         }
 
         for (i = 0; i < bink->num_audio_tracks; i++)
@@ -242,7 +242,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
                (in bytes). We use this value to calcuate the audio PTS */
             if (pkt->size >= 4)
                 bink->audio_pts[bink->current_track -1] +=
-                    AV_RL32(pkt->data) / (2 * s->streams[bink->current_track]->codec->channels);
+                    AV_RL32(pkt->data) / (2 * s->streams[bink->current_track]->codecpar->channels);
             return 0;
         } else {
             avio_skip(pb, audio_size);
index b5572aff37962fc5f6bcde969f3c7c1534a30ea1..cfb4439edca7aef8732a34b3e363c25ddd9b2f08 100644 (file)
@@ -47,20 +47,20 @@ static int bmv_read_header(AVFormatContext *s)
     st = avformat_new_stream(s, 0);
     if (!st)
         return AVERROR(ENOMEM);
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id   = AV_CODEC_ID_BMV_VIDEO;
-    st->codec->width      = 640;
-    st->codec->height     = 429;
-    st->codec->pix_fmt    = AV_PIX_FMT_PAL8;
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id   = AV_CODEC_ID_BMV_VIDEO;
+    st->codecpar->width      = 640;
+    st->codecpar->height     = 429;
+    st->codecpar->format     = AV_PIX_FMT_PAL8;
     avpriv_set_pts_info(st, 16, 1, 12);
     ast = avformat_new_stream(s, 0);
     if (!ast)
         return AVERROR(ENOMEM);
-    ast->codec->codec_type      = AVMEDIA_TYPE_AUDIO;
-    ast->codec->codec_id        = AV_CODEC_ID_BMV_AUDIO;
-    ast->codec->channels        = 2;
-    ast->codec->channel_layout  = AV_CH_LAYOUT_STEREO;
-    ast->codec->sample_rate     = 22050;
+    ast->codecpar->codec_type      = AVMEDIA_TYPE_AUDIO;
+    ast->codecpar->codec_id        = AV_CODEC_ID_BMV_AUDIO;
+    ast->codecpar->channels        = 2;
+    ast->codecpar->channel_layout  = AV_CH_LAYOUT_STEREO;
+    ast->codecpar->sample_rate     = 22050;
     avpriv_set_pts_info(ast, 16, 1, 22050);
 
     c->get_next  = 1;
index 3ae99fcfc92015406047b6d31c4d692c4f82ccf6..c213b0625545dac57cd3e58e8177762cefbb5549 100644 (file)
@@ -83,10 +83,10 @@ static int read_header(AVFormatContext *s)
     if (!video)
         return AVERROR(ENOMEM);
 
-    video->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    video->codec->codec_id = AV_CODEC_ID_C93;
-    video->codec->width = 320;
-    video->codec->height = 192;
+    video->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    video->codecpar->codec_id = AV_CODEC_ID_C93;
+    video->codecpar->width = 320;
+    video->codecpar->height = 192;
     /* 4:3 320x200 with 8 empty lines */
     video->sample_aspect_ratio = (AVRational) { 5, 6 };
     avpriv_set_pts_info(video, 64, 2, 25);
@@ -120,7 +120,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
                 c93->audio = avformat_new_stream(s, NULL);
                 if (!c93->audio)
                     return AVERROR(ENOMEM);
-                c93->audio->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+                c93->audio->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
             }
             avio_skip(pb, 26); /* VOC header */
             ret = ff_voc_get_packet(s, pkt, c93->audio, datasize - 26);
index 36c39678d17918d5c34e4499b7b369cf445b2d9d..65bdcfc1ef0927cf16626883f35e055b281cd9fd 100644 (file)
@@ -69,29 +69,29 @@ static int read_desc_chunk(AVFormatContext *s)
         return AVERROR(ENOMEM);
 
     /* parse format description */
-    st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
-    st->codec->sample_rate = av_int2double(avio_rb64(pb));
-    st->codec->codec_tag   = avio_rb32(pb);
+    st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->sample_rate = av_int2double(avio_rb64(pb));
+    st->codecpar->codec_tag   = avio_rb32(pb);
     flags = avio_rb32(pb);
     caf->bytes_per_packet  = avio_rb32(pb);
-    st->codec->block_align = caf->bytes_per_packet;
+    st->codecpar->block_align = caf->bytes_per_packet;
     caf->frames_per_packet = avio_rb32(pb);
-    st->codec->channels    = avio_rb32(pb);
-    st->codec->bits_per_coded_sample = avio_rb32(pb);
+    st->codecpar->channels    = avio_rb32(pb);
+    st->codecpar->bits_per_coded_sample = avio_rb32(pb);
 
     /* calculate bit rate for constant size packets */
     if (caf->frames_per_packet > 0 && caf->bytes_per_packet > 0) {
-        st->codec->bit_rate = (uint64_t)st->codec->sample_rate * (uint64_t)caf->bytes_per_packet * 8
-                              / (uint64_t)caf->frames_per_packet;
+        st->codecpar->bit_rate = (uint64_t)st->codecpar->sample_rate * (uint64_t)caf->bytes_per_packet * 8
+                                 / (uint64_t)caf->frames_per_packet;
     } else {
-        st->codec->bit_rate = 0;
+        st->codecpar->bit_rate = 0;
     }
 
     /* determine codec */
-    if (st->codec->codec_tag == MKBETAG('l','p','c','m'))
-        st->codec->codec_id = ff_mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, (flags ^ 0x2) | 0x4);
+    if (st->codecpar->codec_tag == MKBETAG('l','p','c','m'))
+        st->codecpar->codec_id = ff_mov_get_lpcm_codec_id(st->codecpar->bits_per_coded_sample, (flags ^ 0x2) | 0x4);
     else
-        st->codec->codec_id = ff_codec_get_id(ff_codec_caf_tags, st->codec->codec_tag);
+        st->codecpar->codec_id = ff_codec_get_id(ff_codec_caf_tags, st->codecpar->codec_tag);
     return 0;
 }
 
@@ -104,7 +104,7 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
     if (size < 0 || size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
         return -1;
 
-    if (st->codec->codec_id == AV_CODEC_ID_AAC) {
+    if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
         /* The magic cookie format for AAC is an mp4 esds atom.
            The lavc AAC decoder requires the data from the codec specific
            description as extradata input. */
@@ -113,13 +113,13 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
         strt = avio_tell(pb);
         ff_mov_read_esds(s, pb);
         skip = size - (avio_tell(pb) - strt);
-        if (skip < 0 || !st->codec->extradata ||
-            st->codec->codec_id != AV_CODEC_ID_AAC) {
+        if (skip < 0 || !st->codecpar->extradata ||
+            st->codecpar->codec_id != AV_CODEC_ID_AAC) {
             av_log(s, AV_LOG_ERROR, "invalid AAC magic cookie\n");
             return AVERROR_INVALIDDATA;
         }
         avio_skip(pb, skip);
-    } else if (st->codec->codec_id == AV_CODEC_ID_ALAC) {
+    } else if (st->codecpar->codec_id == AV_CODEC_ID_ALAC) {
 #define ALAC_PREAMBLE 12
 #define ALAC_HEADER   36
 #define ALAC_NEW_KUKI 24
@@ -131,8 +131,8 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
         }
         avio_read(pb, preamble, ALAC_PREAMBLE);
 
-        st->codec->extradata = av_mallocz(ALAC_HEADER + AV_INPUT_BUFFER_PADDING_SIZE);
-        if (!st->codec->extradata)
+        st->codecpar->extradata = av_mallocz(ALAC_HEADER + AV_INPUT_BUFFER_PADDING_SIZE);
+        if (!st->codecpar->extradata)
             return AVERROR(ENOMEM);
 
         /* For the old style cookie, we skip 12 bytes, then read 36 bytes.
@@ -142,26 +142,26 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
         if (!memcmp(&preamble[4], "frmaalac", 8)) {
             if (size < ALAC_PREAMBLE + ALAC_HEADER) {
                 av_log(s, AV_LOG_ERROR, "invalid ALAC magic cookie\n");
-                av_freep(&st->codec->extradata);
+                av_freep(&st->codecpar->extradata);
                 return AVERROR_INVALIDDATA;
             }
-            avio_read(pb, st->codec->extradata, ALAC_HEADER);
+            avio_read(pb, st->codecpar->extradata, ALAC_HEADER);
             avio_skip(pb, size - ALAC_PREAMBLE - ALAC_HEADER);
         } else {
-            AV_WB32(st->codec->extradata, 36);
-            memcpy(&st->codec->extradata[4], "alac", 4);
-            AV_WB32(&st->codec->extradata[8], 0);
-            memcpy(&st->codec->extradata[12], preamble, 12);
-            avio_read(pb, &st->codec->extradata[24], ALAC_NEW_KUKI - 12);
+            AV_WB32(st->codecpar->extradata, 36);
+            memcpy(&st->codecpar->extradata[4], "alac", 4);
+            AV_WB32(&st->codecpar->extradata[8], 0);
+            memcpy(&st->codecpar->extradata[12], preamble, 12);
+            avio_read(pb, &st->codecpar->extradata[24], ALAC_NEW_KUKI - 12);
             avio_skip(pb, size - ALAC_NEW_KUKI);
         }
-        st->codec->extradata_size = ALAC_HEADER;
+        st->codecpar->extradata_size = ALAC_HEADER;
     } else {
-        st->codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
-        if (!st->codec->extradata)
+        st->codecpar->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
+        if (!st->codecpar->extradata)
             return AVERROR(ENOMEM);
-        avio_read(pb, st->codec->extradata, size);
-        st->codec->extradata_size = size;
+        avio_read(pb, st->codecpar->extradata, size);
+        st->codecpar->extradata_size = size;
     }
 
     return 0;
@@ -309,7 +309,7 @@ static int read_header(AVFormatContext *s)
         if (caf->data_size > 0)
             st->nb_frames = (caf->data_size / caf->bytes_per_packet) * caf->frames_per_packet;
     } else if (st->nb_index_entries) {
-        st->codec->bit_rate = st->codec->sample_rate * caf->data_size * 8 /
+        st->codecpar->bit_rate = st->codecpar->sample_rate * caf->data_size * 8 /
                               st->duration;
     } else {
         av_log(s, AV_LOG_ERROR, "Missing packet table. It is required when "
@@ -317,7 +317,7 @@ static int read_header(AVFormatContext *s)
         return AVERROR_INVALIDDATA;
     }
 
-    avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+    avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
     st->start_time = 0;
 
     /* position the stream at the start of data */
index 285bfaf35b271a1958d7e9df7558752b7eb0484b..3f11286c30e5f12a183da9585fa2122d59219e77 100644 (file)
@@ -39,8 +39,8 @@ static int read_header(AVFormatContext *s)
     if (!vst)
         return AVERROR(ENOMEM);
 
-    vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    vst->codec->codec_id   = AV_CODEC_ID_CDGRAPHICS;
+    vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    vst->codecpar->codec_id   = AV_CODEC_ID_CDGRAPHICS;
 
     /// 75 sectors/sec * 4 packets/sector = 300 packets/sec
     avpriv_set_pts_info(vst, 32, 1, 300);
index 366da4bf7c72765e885715a9dff44701257bc3a8..26a5f8161ca5473ed7b9735927f641826488509b 100644 (file)
@@ -99,17 +99,17 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
             if (!st)
                 return AVERROR(ENOMEM);
 
-            st->codec->codec_type    = AVMEDIA_TYPE_AUDIO;
-            st->codec->codec_tag     = 0;
-            st->codec->codec_id      = AV_CODEC_ID_PCM_S8;
+            st->codecpar->codec_type    = AVMEDIA_TYPE_AUDIO;
+            st->codecpar->codec_tag     = 0;
+            st->codecpar->codec_id      = AV_CODEC_ID_PCM_S8;
             if (cdxl->header[1] & 0x10) {
-                st->codec->channels       = 2;
-                st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
+                st->codecpar->channels       = 2;
+                st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
             } else {
-                st->codec->channels       = 1;
-                st->codec->channel_layout = AV_CH_LAYOUT_MONO;
+                st->codecpar->channels       = 1;
+                st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
             }
-            st->codec->sample_rate   = cdxl->sample_rate;
+            st->codecpar->sample_rate   = cdxl->sample_rate;
             st->start_time           = 0;
             cdxl->audio_stream_index = st->index;
             avpriv_set_pts_info(st, 64, 1, cdxl->sample_rate);
@@ -128,11 +128,11 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
             if (!st)
                 return AVERROR(ENOMEM);
 
-            st->codec->codec_type    = AVMEDIA_TYPE_VIDEO;
-            st->codec->codec_tag     = 0;
-            st->codec->codec_id      = AV_CODEC_ID_CDXL;
-            st->codec->width         = width;
-            st->codec->height        = height;
+            st->codecpar->codec_type    = AVMEDIA_TYPE_VIDEO;
+            st->codecpar->codec_tag     = 0;
+            st->codecpar->codec_id      = AV_CODEC_ID_CDXL;
+            st->codecpar->width         = width;
+            st->codecpar->height        = height;
             st->start_time           = 0;
             cdxl->video_stream_index = st->index;
             if (cdxl->framerate)
index 8c75d189b0df1d801f86b616a282ac6d9f50056d..9c7e23aa8e56a66f27fa69a83f1f8de753691def 100644 (file)
@@ -105,19 +105,19 @@ static int dash_write(void *opaque, uint8_t *buf, int buf_size)
 }
 
 // RFC 6381
-static void set_codec_str(AVFormatContext *s, AVCodecContext *codec,
+static void set_codec_str(AVFormatContext *s, AVCodecParameters *par,
                           char *str, int size)
 {
     const AVCodecTag *tags[2] = { NULL, NULL };
     uint32_t tag;
-    if (codec->codec_type == AVMEDIA_TYPE_VIDEO)
+    if (par->codec_type == AVMEDIA_TYPE_VIDEO)
         tags[0] = ff_codec_movvideo_tags;
-    else if (codec->codec_type == AVMEDIA_TYPE_AUDIO)
+    else if (par->codec_type == AVMEDIA_TYPE_AUDIO)
         tags[0] = ff_codec_movaudio_tags;
     else
         return;
 
-    tag = av_codec_get_tag(tags, codec->codec_id);
+    tag = av_codec_get_tag(tags, par->codec_id);
     if (!tag)
         return;
     if (size < 5)
@@ -128,17 +128,17 @@ static void set_codec_str(AVFormatContext *s, AVCodecContext *codec,
     if (!strcmp(str, "mp4a") || !strcmp(str, "mp4v")) {
         uint32_t oti;
         tags[0] = ff_mp4_obj_type;
-        oti = av_codec_get_tag(tags, codec->codec_id);
+        oti = av_codec_get_tag(tags, par->codec_id);
         if (oti)
             av_strlcatf(str, size, ".%02x", oti);
         else
             return;
 
         if (tag == MKTAG('m', 'p', '4', 'a')) {
-            if (codec->extradata_size >= 2) {
-                int aot = codec->extradata[0] >> 3;
+            if (par->extradata_size >= 2) {
+                int aot = par->extradata[0] >> 3;
                 if (aot == 31)
-                    aot = ((AV_RB16(codec->extradata) >> 5) & 0x3f) + 32;
+                    aot = ((AV_RB16(par->extradata) >> 5) & 0x3f) + 32;
                 av_strlcatf(str, size, ".%d", aot);
             }
         } else if (tag == MKTAG('m', 'p', '4', 'v')) {
@@ -147,8 +147,8 @@ static void set_codec_str(AVFormatContext *s, AVCodecContext *codec,
         }
     } else if (!strcmp(str, "avc1")) {
         uint8_t *tmpbuf = NULL;
-        uint8_t *extradata = codec->extradata;
-        int extradata_size = codec->extradata_size;
+        uint8_t *extradata = par->extradata;
+        int extradata_size = par->extradata_size;
         if (!extradata_size)
             return;
         if (extradata[0] != 1) {
@@ -506,9 +506,9 @@ static int write_manifest(AVFormatContext *s, int final)
         for (i = 0; i < s->nb_streams; i++) {
             AVStream *st = s->streams[i];
             OutputStream *os = &c->streams[i];
-            if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO)
+            if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
                 continue;
-            avio_printf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"video/mp4\" codecs=\"%s\"%s width=\"%d\" height=\"%d\">\n", i, os->codec_str, os->bandwidth_str, st->codec->width, st->codec->height);
+            avio_printf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"video/mp4\" codecs=\"%s\"%s width=\"%d\" height=\"%d\">\n", i, os->codec_str, os->bandwidth_str, st->codecpar->width, st->codecpar->height);
             output_segment_list(&c->streams[i], out, c);
             avio_printf(out, "\t\t\t</Representation>\n");
         }
@@ -519,10 +519,10 @@ static int write_manifest(AVFormatContext *s, int final)
         for (i = 0; i < s->nb_streams; i++) {
             AVStream *st = s->streams[i];
             OutputStream *os = &c->streams[i];
-            if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO)
+            if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
                 continue;
-            avio_printf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"audio/mp4\" codecs=\"%s\"%s audioSamplingRate=\"%d\">\n", i, os->codec_str, os->bandwidth_str, st->codec->sample_rate);
-            avio_printf(out, "\t\t\t\t<AudioChannelConfiguration schemeIdUri=\"urn:mpeg:dash:23003:3:audio_channel_configuration:2011\" value=\"%d\" />\n", st->codec->channels);
+            avio_printf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"audio/mp4\" codecs=\"%s\"%s audioSamplingRate=\"%d\">\n", i, os->codec_str, os->bandwidth_str, st->codecpar->sample_rate);
+            avio_printf(out, "\t\t\t\t<AudioChannelConfiguration schemeIdUri=\"urn:mpeg:dash:23003:3:audio_channel_configuration:2011\" value=\"%d\" />\n", st->codecpar->channels);
             output_segment_list(&c->streams[i], out, c);
             avio_printf(out, "\t\t\t</Representation>\n");
         }
@@ -581,7 +581,7 @@ static int dash_write_header(AVFormatContext *s)
         AVDictionary *opts = NULL;
         char filename[1024];
 
-        os->bit_rate = s->streams[i]->codec->bit_rate;
+        os->bit_rate = s->streams[i]->codecpar->bit_rate;
         if (os->bit_rate) {
             snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
                      " bandwidth=\"%d\"", os->bit_rate);
@@ -611,7 +611,7 @@ static int dash_write_header(AVFormatContext *s)
             ret = AVERROR(ENOMEM);
             goto fail;
         }
-        avcodec_copy_context(st->codec, s->streams[i]->codec);
+        avcodec_parameters_copy(st->codecpar, s->streams[i]->codecpar);
         st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
         st->time_base = s->streams[i]->time_base;
         ctx->avoid_negative_ts = s->avoid_negative_ts;
@@ -651,12 +651,12 @@ static int dash_write_header(AVFormatContext *s)
         // already before being handed to this muxer, so we don't have mismatches
         // between the MPD and the actual segments.
         s->avoid_negative_ts = ctx->avoid_negative_ts;
-        if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
             c->has_video = 1;
-        else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+        else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
             c->has_audio = 1;
 
-        set_codec_str(s, st->codec, os->codec_str, sizeof(os->codec_str));
+        set_codec_str(s, st->codecpar, os->codec_str, sizeof(os->codec_str));
         os->first_pts = AV_NOPTS_VALUE;
         os->max_pts = AV_NOPTS_VALUE;
         os->last_dts = AV_NOPTS_VALUE;
@@ -745,24 +745,24 @@ static void find_index_range(AVFormatContext *s, const char *full_path,
 }
 
 static int update_stream_extradata(AVFormatContext *s, OutputStream *os,
-                                   AVCodecContext *codec)
+                                   AVCodecParameters *par)
 {
     uint8_t *extradata;
 
-    if (os->ctx->streams[0]->codec->extradata_size || !codec->extradata_size)
+    if (os->ctx->streams[0]->codecpar->extradata_size || !par->extradata_size)
         return 0;
 
-    extradata = av_malloc(codec->extradata_size);
+    extradata = av_malloc(par->extradata_size);
 
     if (!extradata)
         return AVERROR(ENOMEM);
 
-    memcpy(extradata, codec->extradata, codec->extradata_size);
+    memcpy(extradata, par->extradata, par->extradata_size);
 
-    os->ctx->streams[0]->codec->extradata = extradata;
-    os->ctx->streams[0]->codec->extradata_size = codec->extradata_size;
+    os->ctx->streams[0]->codecpar->extradata = extradata;
+    os->ctx->streams[0]->codecpar->extradata_size = par->extradata_size;
 
-    set_codec_str(s, codec, os->codec_str, sizeof(os->codec_str));
+    set_codec_str(s, par, os->codec_str, sizeof(os->codec_str));
 
     return 0;
 }
@@ -788,7 +788,7 @@ static int dash_flush(AVFormatContext *s, int final, int stream)
         // Flush all audio streams as well, in sync with video keyframes,
         // but not the other video streams.
         if (stream >= 0 && i != stream) {
-            if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_AUDIO)
+            if (s->streams[i]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
                 continue;
             // Make sure we don't flush audio streams multiple times, when
             // all video streams are flushed one at a time.
@@ -867,7 +867,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
     int64_t seg_end_duration = (os->segment_index) * (int64_t) c->min_seg_duration;
     int ret;
 
-    ret = update_stream_extradata(s, os, st->codec);
+    ret = update_stream_extradata(s, os, st->codecpar);
     if (ret < 0)
         return ret;
 
@@ -892,7 +892,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
     if (os->first_pts == AV_NOPTS_VALUE)
         os->first_pts = pkt->pts;
 
-    if ((!c->has_video || st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&
+    if ((!c->has_video || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) &&
         pkt->flags & AV_PKT_FLAG_KEY && os->packets_written &&
         av_compare_ts(pkt->pts - os->first_pts, st->time_base,
                       seg_end_duration, AV_TIME_BASE_Q) >= 0) {
index 1855e84aae548b09f169f876b663d56e64bd9346..98f8a5749dac686a929a446a2a939f3ef170f440 100644 (file)
@@ -26,15 +26,15 @@ static int daud_header(AVFormatContext *s) {
     AVStream *st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
-    st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id = AV_CODEC_ID_PCM_S24DAUD;
-    st->codec->codec_tag = MKTAG('d', 'a', 'u', 'd');
-    st->codec->channels = 6;
-    st->codec->channel_layout = AV_CH_LAYOUT_5POINT1;
-    st->codec->sample_rate = 96000;
-    st->codec->bit_rate = 3 * 6 * 96000 * 8;
-    st->codec->block_align = 3 * 6;
-    st->codec->bits_per_coded_sample = 24;
+    st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_id = AV_CODEC_ID_PCM_S24DAUD;
+    st->codecpar->codec_tag = MKTAG('d', 'a', 'u', 'd');
+    st->codecpar->channels = 6;
+    st->codecpar->channel_layout = AV_CH_LAYOUT_5POINT1;
+    st->codecpar->sample_rate = 96000;
+    st->codecpar->bit_rate = 3 * 6 * 96000 * 8;
+    st->codecpar->block_align = 3 * 6;
+    st->codecpar->bits_per_coded_sample = 24;
     return 0;
 }
 
index 416e8953955e826e12a465d7dec370ca39539c47..93608e33191c2f041f8a27e732872b7fecd80e95 100644 (file)
@@ -23,8 +23,8 @@
 
 static int daud_write_header(struct AVFormatContext *s)
 {
-    AVCodecContext *codec = s->streams[0]->codec;
-    if (codec->channels!=6 || codec->sample_rate!=96000)
+    AVCodecParameters *par = s->streams[0]->codecpar;
+    if (par->channels!=6 || par->sample_rate!=96000)
         return -1;
     return 0;
 }
index 03dca4f5c3e53a7adead6d09b02925b040e35785..cecf6b69c25569e79ac7a3f098b30ad52d0a38d8 100644 (file)
@@ -51,10 +51,10 @@ static int dfa_read_header(AVFormatContext *s)
     if (!st)
         return AVERROR(ENOMEM);
 
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id   = AV_CODEC_ID_DFA;
-    st->codec->width      = avio_rl16(pb);
-    st->codec->height     = avio_rl16(pb);
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id   = AV_CODEC_ID_DFA;
+    st->codecpar->width      = avio_rl16(pb);
+    st->codecpar->height     = avio_rl16(pb);
     mspf = avio_rl32(pb);
     if (!mspf) {
         av_log(s, AV_LOG_WARNING, "Zero FPS reported, defaulting to 10\n");
index 612289fd4f0c0d2e0abf09faf0edea52920a7860..fa5943dfe2f99d90139142ac1bf9b7081fff5e30 100644 (file)
@@ -115,11 +115,11 @@ static int cin_read_header(AVFormatContext *s)
 
     avpriv_set_pts_info(st, 32, 1, 12);
     cin->video_stream_index = st->index;
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id = AV_CODEC_ID_DSICINVIDEO;
-    st->codec->codec_tag = 0;  /* no fourcc */
-    st->codec->width = hdr->video_frame_width;
-    st->codec->height = hdr->video_frame_height;
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id = AV_CODEC_ID_DSICINVIDEO;
+    st->codecpar->codec_tag = 0;  /* no fourcc */
+    st->codecpar->width = hdr->video_frame_width;
+    st->codecpar->height = hdr->video_frame_height;
 
     /* initialize the audio decoder stream */
     st = avformat_new_stream(s, NULL);
@@ -128,14 +128,14 @@ static int cin_read_header(AVFormatContext *s)
 
     avpriv_set_pts_info(st, 32, 1, 22050);
     cin->audio_stream_index = st->index;
-    st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id = AV_CODEC_ID_DSICINAUDIO;
-    st->codec->codec_tag = 0;  /* no tag */
-    st->codec->channels = 1;
-    st->codec->channel_layout = AV_CH_LAYOUT_MONO;
-    st->codec->sample_rate = 22050;
-    st->codec->bits_per_coded_sample = 8;
-    st->codec->bit_rate = st->codec->sample_rate * st->codec->bits_per_coded_sample * st->codec->channels;
+    st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_id = AV_CODEC_ID_DSICINAUDIO;
+    st->codecpar->codec_tag = 0;  /* no tag */
+    st->codecpar->channels = 1;
+    st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+    st->codecpar->sample_rate = 22050;
+    st->codecpar->bits_per_coded_sample = 8;
+    st->codecpar->bit_rate = st->codecpar->sample_rate * st->codecpar->bits_per_coded_sample * st->codecpar->channels;
 
     return 0;
 }
index e9610dd1a1f80101b7cf9193e7c75220c75a97e1..a9b2ebf2d88afed12d438cfdedb543e5e2d559c8 100644 (file)
@@ -141,22 +141,22 @@ static int dss_read_header(AVFormatContext *s)
     ctx->audio_codec = avio_r8(pb);
 
     if (ctx->audio_codec == DSS_ACODEC_DSS_SP) {
-        st->codec->codec_id    = AV_CODEC_ID_DSS_SP;
-        st->codec->sample_rate = 12000;
+        st->codecpar->codec_id    = AV_CODEC_ID_DSS_SP;
+        st->codecpar->sample_rate = 12000;
     } else if (ctx->audio_codec == DSS_ACODEC_G723_1) {
-        st->codec->codec_id    = AV_CODEC_ID_G723_1;
-        st->codec->sample_rate = 8000;
+        st->codecpar->codec_id    = AV_CODEC_ID_G723_1;
+        st->codecpar->sample_rate = 8000;
     } else {
         avpriv_request_sample(s, "Support for codec %x in DSS",
                               ctx->audio_codec);
         return AVERROR_PATCHWELCOME;
     }
 
-    st->codec->codec_type     = AVMEDIA_TYPE_AUDIO;
-    st->codec->channel_layout = AV_CH_LAYOUT_MONO;
-    st->codec->channels       = 1;
+    st->codecpar->codec_type     = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+    st->codecpar->channels       = 1;
 
-    avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+    avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
     st->start_time = 0;
 
     /* Jump over header */
index 345d2a95fc1c30f6029b20c3f843eee2b5d69bf8..d7dee9d570e0ad9e0d8c26c3b73c651131357b73 100644 (file)
@@ -400,8 +400,22 @@ static void dump_stream_format(AVFormatContext *ic, int i,
     int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
     AVStream *st = ic->streams[i];
     AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
+    AVCodecContext *avctx;
+    int ret;
+
+    avctx = avcodec_alloc_context3(NULL);
+    if (!avctx)
+        return;
+
+    ret = avcodec_parameters_to_context(avctx, st->codecpar);
+    if (ret < 0) {
+        avcodec_free_context(&avctx);
+        return;
+    }
+
+    avcodec_string(buf, sizeof(buf), avctx, is_output);
+    avcodec_free_context(&avctx);
 
-    avcodec_string(buf, sizeof(buf), st->codec, is_output);
     av_log(NULL, AV_LOG_INFO, "    Stream #%d:%d", index, i);
 
     /* the pid is an important information, so we display it */
@@ -414,31 +428,27 @@ static void dump_stream_format(AVFormatContext *ic, int i,
            st->time_base.num, st->time_base.den);
     av_log(NULL, AV_LOG_INFO, ": %s", buf);
 
-    if (st->sample_aspect_ratio.num && // default
-        av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) {
+    if (st->sample_aspect_ratio.num) {
         AVRational display_aspect_ratio;
         av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
-                  st->codec->width  * st->sample_aspect_ratio.num,
-                  st->codec->height * st->sample_aspect_ratio.den,
+                  st->codecpar->width  * st->sample_aspect_ratio.num,
+                  st->codecpar->height * st->sample_aspect_ratio.den,
                   1024 * 1024);
         av_log(NULL, AV_LOG_INFO, ", PAR %d:%d DAR %d:%d",
                st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
                display_aspect_ratio.num, display_aspect_ratio.den);
     }
 
-    if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+    if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
         int fps = st->avg_frame_rate.den && st->avg_frame_rate.num;
         int tbn = st->time_base.den && st->time_base.num;
-        int tbc = st->codec->time_base.den && st->codec->time_base.num;
 
-        if (fps || tbn || tbc)
+        if (fps || tbn)
             av_log(NULL, AV_LOG_INFO, "\n      ");
         if (fps)
-            print_fps(av_q2d(st->avg_frame_rate), tbn || tbc ? "fps, " : "fps");
+            print_fps(av_q2d(st->avg_frame_rate), tbn ? "fps, " : "fps");
         if (tbn)
-            print_fps(1 / av_q2d(st->time_base), tbc ? "tbn, " : "tbn");
-        if (tbc)
-            print_fps(1 / av_q2d(st->codec->time_base), "tbc");
+            print_fps(1 / av_q2d(st->time_base), "tbn");
     }
 
     if (st->disposition & AV_DISPOSITION_DEFAULT)
index 1ba8698d201399b86d2c2507293e635150a99640..f7df279bdc0a262112c58c1867ebe75527c30597 100644 (file)
@@ -245,8 +245,8 @@ static int dv_extract_audio_info(DVDemuxContext *c, uint8_t *frame)
             if (!c->ast[i])
                 break;
             avpriv_set_pts_info(c->ast[i], 64, 1, 30000);
-            c->ast[i]->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-            c->ast[i]->codec->codec_id   = AV_CODEC_ID_PCM_S16LE;
+            c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+            c->ast[i]->codecpar->codec_id   = AV_CODEC_ID_PCM_S16LE;
 
             av_init_packet(&c->audio_pkt[i]);
             c->audio_pkt[i].size         = 0;
@@ -254,10 +254,10 @@ static int dv_extract_audio_info(DVDemuxContext *c, uint8_t *frame)
             c->audio_pkt[i].stream_index = c->ast[i]->index;
             c->audio_pkt[i].flags       |= AV_PKT_FLAG_KEY;
         }
-        c->ast[i]->codec->sample_rate    = dv_audio_frequency[freq];
-        c->ast[i]->codec->channels       = 2;
-        c->ast[i]->codec->channel_layout = AV_CH_LAYOUT_STEREO;
-        c->ast[i]->codec->bit_rate       = 2 * dv_audio_frequency[freq] * 16;
+        c->ast[i]->codecpar->sample_rate    = dv_audio_frequency[freq];
+        c->ast[i]->codecpar->channels       = 2;
+        c->ast[i]->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+        c->ast[i]->codecpar->bit_rate       = 2 * dv_audio_frequency[freq] * 16;
         c->ast[i]->start_time            = 0;
     }
     c->ach = i;
@@ -268,21 +268,20 @@ static int dv_extract_audio_info(DVDemuxContext *c, uint8_t *frame)
 static int dv_extract_video_info(DVDemuxContext *c, uint8_t *frame)
 {
     const uint8_t *vsc_pack;
-    AVCodecContext *avctx;
     int apt, is16_9;
     int size = 0;
 
     if (c->sys) {
-        avctx = c->vst->codec;
+        AVCodecParameters *par = c->vst->codecpar;
 
         avpriv_set_pts_info(c->vst, 64, c->sys->time_base.num,
                             c->sys->time_base.den);
         c->vst->avg_frame_rate = av_inv_q(c->vst->time_base);
-        if (!avctx->width) {
-            avctx->width  = c->sys->width;
-            avctx->height = c->sys->height;
+        if (!par->width) {
+            par->width  = c->sys->width;
+            par->height = c->sys->height;
         }
-        avctx->pix_fmt = c->sys->pix_fmt;
+        par->format = c->sys->pix_fmt;
 
         /* finding out SAR is a little bit messy */
         vsc_pack = dv_extract_pack(frame, dv_video_control);
@@ -290,9 +289,9 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t *frame)
         is16_9   = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 ||
                                  (!apt && (vsc_pack[2] & 0x07) == 0x07)));
         c->vst->sample_aspect_ratio = c->sys->sar[is16_9];
-        avctx->bit_rate = av_rescale_q(c->sys->frame_size,
-                                       (AVRational) { 8, 1 },
-                                       c->sys->time_base);
+        par->bit_rate = av_rescale_q(c->sys->frame_size,
+                                     (AVRational) { 8, 1 },
+                                     c->sys->time_base);
         size = c->sys->frame_size;
     }
     return size;
@@ -315,9 +314,9 @@ DVDemuxContext *avpriv_dv_init_demux(AVFormatContext *s)
     }
 
     c->fctx                   = s;
-    c->vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    c->vst->codec->codec_id   = AV_CODEC_ID_DVVIDEO;
-    c->vst->codec->bit_rate   = 25000000;
+    c->vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    c->vst->codecpar->codec_id   = AV_CODEC_ID_DVVIDEO;
+    c->vst->codecpar->bit_rate   = 25000000;
     c->vst->start_time        = 0;
 
     return c;
@@ -358,7 +357,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
     for (i = 0; i < c->ach; i++) {
         c->audio_pkt[i].size = size;
         c->audio_pkt[i].pts  = c->abytes * 30000 * 8 /
-                               c->ast[i]->codec->bit_rate;
+                               c->ast[i]->codecpar->bit_rate;
         ppcm[i] = c->audio_buf[i];
     }
     if (c->ach)
@@ -395,8 +394,8 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c,
                                int64_t timestamp, int flags)
 {
     // FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk)
-    const AVDVProfile *sys = av_dv_codec_profile(c->vst->codec->width, c->vst->codec->height,
-                                                 c->vst->codec->pix_fmt);
+    const AVDVProfile *sys = av_dv_codec_profile(c->vst->codecpar->width, c->vst->codecpar->height,
+                                                 c->vst->codecpar->format);
     int64_t offset;
     int64_t size       = avio_size(s->pb) - s->internal->data_offset;
     int64_t max_offset = ((size - 1) / sys->frame_size) * sys->frame_size;
@@ -416,7 +415,7 @@ void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
     c->frames = frame_offset;
     if (c->ach)
         c->abytes = av_rescale_q(c->frames, c->sys->time_base,
-                                 (AVRational) { 8, c->ast[0]->codec->bit_rate });
+                                 (AVRational) { 8, c->ast[0]->codecpar->bit_rate });
 
     c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
     c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
index 106cba4c3457731f030052f571b24aa363cd439c..094ddc90a9765b8d6ba5d14b319bdd01bbfcc36e 100644 (file)
@@ -236,7 +236,8 @@ static void dv_inject_metadata(DVMuxContext *c, uint8_t* frame)
  * The following 3 functions constitute our interface to the world
  */
 
-static int dv_assemble_frame(DVMuxContext *c, AVStream* st,
+static int dv_assemble_frame(AVFormatContext *s,
+                             DVMuxContext *c, AVStream* st,
                              uint8_t* data, int data_size, uint8_t** frame)
 {
     int i, reqasize;
@@ -244,13 +245,13 @@ static int dv_assemble_frame(DVMuxContext *c, AVStream* st,
     *frame = &c->frame_buf[0];
     reqasize = 4 * dv_audio_frame_size(c->sys, c->frames);
 
-    switch (st->codec->codec_type) {
+    switch (st->codecpar->codec_type) {
     case AVMEDIA_TYPE_VIDEO:
         /* FIXME: we have to have more sensible approach than this one */
         if (c->has_video)
-            av_log(st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient audio data or severe sync problem.\n", c->frames);
+            av_log(s, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient audio data or severe sync problem.\n", c->frames);
         if (data_size != c->sys->frame_size) {
-            av_log(st->codec, AV_LOG_ERROR, "Unexpected frame size, %d != %d\n",
+            av_log(s, AV_LOG_ERROR, "Unexpected frame size, %d != %d\n",
                    data_size, c->sys->frame_size);
             return AVERROR(ENOSYS);
         }
@@ -263,7 +264,7 @@ static int dv_assemble_frame(DVMuxContext *c, AVStream* st,
 
           /* FIXME: we have to have more sensible approach than this one */
         if (av_fifo_size(c->audio_data[i]) + data_size >= 100*MAX_AUDIO_FRAME_SIZE)
-            av_log(st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames);
+            av_log(s, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames);
         av_fifo_generic_write(c->audio_data[i], data, data_size, NULL);
 
         /* Let us see if we've got enough audio for one DV frame. */
@@ -310,7 +311,7 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s)
 
     /* We have to sort out where audio and where video stream is */
     for (i=0; i<s->nb_streams; i++) {
-        switch (s->streams[i]->codec->codec_type) {
+        switch (s->streams[i]->codecpar->codec_type) {
         case AVMEDIA_TYPE_VIDEO:
             if (vst) return NULL;
             vst = s->streams[i];
@@ -325,15 +326,15 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s)
     }
 
     /* Some checks -- DV format is very picky about its incoming streams */
-    if (!vst || vst->codec->codec_id != AV_CODEC_ID_DVVIDEO)
+    if (!vst || vst->codecpar->codec_id != AV_CODEC_ID_DVVIDEO)
         goto bail_out;
     for (i=0; i<c->n_ast; i++) {
-        if (c->ast[i] && (c->ast[i]->codec->codec_id    != AV_CODEC_ID_PCM_S16LE ||
-                          c->ast[i]->codec->sample_rate != 48000 ||
-                          c->ast[i]->codec->channels    != 2))
+        if (c->ast[i] && (c->ast[i]->codecpar->codec_id    != AV_CODEC_ID_PCM_S16LE ||
+                          c->ast[i]->codecpar->sample_rate != 48000 ||
+                          c->ast[i]->codecpar->channels    != 2))
             goto bail_out;
     }
-    c->sys = av_dv_codec_profile(vst->codec->width, vst->codec->height, vst->codec->pix_fmt);
+    c->sys = av_dv_codec_profile(vst->codecpar->width, vst->codecpar->height, vst->codecpar->format);
     if (!c->sys)
         goto bail_out;
 
@@ -389,7 +390,7 @@ static int dv_write_packet(struct AVFormatContext *s, AVPacket *pkt)
     uint8_t* frame;
     int fsize;
 
-    fsize = dv_assemble_frame(s->priv_data, s->streams[pkt->stream_index],
+    fsize = dv_assemble_frame(s, s->priv_data, s->streams[pkt->stream_index],
                               pkt->data, pkt->size, &frame);
     if (fsize > 0) {
         avio_write(s->pb, frame, fsize);
index 7d04e7bfaad7c364314e3e924ba78016370ab710..a86b90e7d5deb500b0488c7eca7bb5ba977ab8da 100644 (file)
@@ -106,11 +106,11 @@ static int dxa_read_header(AVFormatContext *s)
         ast = avformat_new_stream(s, NULL);
         if (!ast)
             return -1;
-        ret = ff_get_wav_header(s, pb, ast->codec, fsize);
+        ret = ff_get_wav_header(s, pb, ast->codecpar, fsize);
         if (ret < 0)
             return ret;
-        if (ast->codec->sample_rate > 0)
-            avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
+        if (ast->codecpar->sample_rate > 0)
+            avpriv_set_pts_info(ast, 64, 1, ast->codecpar->sample_rate);
         // find 'data' chunk
         while(avio_tell(pb) < c->vidpos && !pb->eof_reached){
             tag = avio_rl32(pb);
@@ -119,18 +119,18 @@ static int dxa_read_header(AVFormatContext *s)
             avio_skip(pb, fsize);
         }
         c->bpc = (fsize + c->frames - 1) / c->frames;
-        if(ast->codec->block_align)
-            c->bpc = ((c->bpc + ast->codec->block_align - 1) / ast->codec->block_align) * ast->codec->block_align;
+        if(ast->codecpar->block_align)
+            c->bpc = ((c->bpc + ast->codecpar->block_align - 1) / ast->codecpar->block_align) * ast->codecpar->block_align;
         c->bytes_left = fsize;
         c->wavpos = avio_tell(pb);
         avio_seek(pb, c->vidpos, SEEK_SET);
     }
 
     /* now we are ready: build format streams */
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id   = AV_CODEC_ID_DXA;
-    st->codec->width      = w;
-    st->codec->height     = h;
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id   = AV_CODEC_ID_DXA;
+    st->codecpar->width      = w;
+    st->codecpar->height     = h;
     av_reduce(&den, &num, den, num, (1UL<<31)-1);
     avpriv_set_pts_info(st, 33, num, den);
     /* flags & 0x80 means that image is interlaced,
@@ -138,7 +138,7 @@ static int dxa_read_header(AVFormatContext *s)
      * either way set true height
      */
     if(flags & 0xC0){
-        st->codec->height >>= 1;
+        st->codecpar->height >>= 1;
     }
     c->readvid = !c->has_sound;
     c->vidpos  = avio_tell(pb);
index c81dec847d4c3fda7e9fef3e0195246d75ebd4be..d3f27a44c2ad5bbe78962e22a4b453e6e5b30086 100644 (file)
@@ -68,11 +68,11 @@ static int cdata_read_header(AVFormatContext *s)
     st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
-    st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_tag = 0; /* no fourcc */
-    st->codec->codec_id = AV_CODEC_ID_ADPCM_EA_XAS;
-    st->codec->channels = cdata->channels;
-    st->codec->sample_rate = sample_rate;
+    st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_tag = 0; /* no fourcc */
+    st->codecpar->codec_id = AV_CODEC_ID_ADPCM_EA_XAS;
+    st->codecpar->channels = cdata->channels;
+    st->codecpar->sample_rate = sample_rate;
     avpriv_set_pts_info(st, 64, 1, sample_rate);
 
     cdata->audio_pts = 0;
index b3855b69a585d36c6095ee146da2d8222ee3abed..07d1efceacadfe023e674055c45a557db3378673 100644 (file)
@@ -462,11 +462,11 @@ static int ea_read_header(AVFormatContext *s)
         if (!st)
             return AVERROR(ENOMEM);
         ea->video_stream_index = st->index;
-        st->codec->codec_type  = AVMEDIA_TYPE_VIDEO;
-        st->codec->codec_id    = ea->video_codec;
-        st->codec->codec_tag   = 0; /* no fourcc */
-        st->codec->width       = ea->width;
-        st->codec->height      = ea->height;
+        st->codecpar->codec_type  = AVMEDIA_TYPE_VIDEO;
+        st->codecpar->codec_id    = ea->video_codec;
+        st->codecpar->codec_tag   = 0; /* no fourcc */
+        st->codecpar->width       = ea->width;
+        st->codecpar->height      = ea->height;
         avpriv_set_pts_info(st, 33, ea->time_base.num, ea->time_base.den);
         st->avg_frame_rate     = (AVRational) { ea->time_base.den,
                                                 ea->time_base.num };
@@ -497,17 +497,17 @@ static int ea_read_header(AVFormatContext *s)
         if (!st)
             return AVERROR(ENOMEM);
         avpriv_set_pts_info(st, 33, 1, ea->sample_rate);
-        st->codec->codec_type            = AVMEDIA_TYPE_AUDIO;
-        st->codec->codec_id              = ea->audio_codec;
-        st->codec->codec_tag             = 0;   /* no tag */
-        st->codec->channels              = ea->num_channels;
-        st->codec->sample_rate           = ea->sample_rate;
-        st->codec->bits_per_coded_sample = ea->bytes * 8;
-        st->codec->bit_rate              = st->codec->channels *
-                                           st->codec->sample_rate *
-                                           st->codec->bits_per_coded_sample / 4;
-        st->codec->block_align           = st->codec->channels *
-                                           st->codec->bits_per_coded_sample;
+        st->codecpar->codec_type            = AVMEDIA_TYPE_AUDIO;
+        st->codecpar->codec_id              = ea->audio_codec;
+        st->codecpar->codec_tag             = 0;   /* no tag */
+        st->codecpar->channels              = ea->num_channels;
+        st->codecpar->sample_rate           = ea->sample_rate;
+        st->codecpar->bits_per_coded_sample = ea->bytes * 8;
+        st->codecpar->bit_rate              = st->codecpar->channels *
+                                              st->codecpar->sample_rate *
+                                              st->codecpar->bits_per_coded_sample / 4;
+        st->codecpar->block_align           = st->codecpar->channels *
+                                              st->codecpar->bits_per_coded_sample;
         ea->audio_stream_index           = st->index;
         st->start_time                   = 0;
     }
index 7dbf7ed35d056fe75904e52be75d084e75389893..42fc98f4bd2917cb0237c69d4df3600560e31966 100644 (file)
@@ -137,8 +137,8 @@ static int read_header(AVFormatContext *s)
             if (!st)
                 return -1;
 
-            st->codec->codec_type = AVMEDIA_TYPE_DATA;
-            st->codec->codec_id   = AV_CODEC_ID_FFMETADATA;
+            st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+            st->codecpar->codec_id   = AV_CODEC_ID_FFMETADATA;
 
             m = &st->metadata;
         } else if (!memcmp(line, ID_CHAPTER, strlen(ID_CHAPTER))) {
index c82656e72f98b43835021817a4ea8edb9d270f40..b029d8023e93a8d50e7ea0fab89773f818996d0c 100644 (file)
@@ -60,12 +60,12 @@ static int read_header(AVFormatContext *s)
     }
 
     avio_skip(pb, 2);
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id   = AV_CODEC_ID_RAWVIDEO;
-    st->codec->pix_fmt    = AV_PIX_FMT_RGBA;
-    st->codec->codec_tag  = 0; /* no fourcc */
-    st->codec->width      = avio_rb16(pb);
-    st->codec->height     = avio_rb16(pb);
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id   = AV_CODEC_ID_RAWVIDEO;
+    st->codecpar->format     = AV_PIX_FMT_RGBA;
+    st->codecpar->codec_tag  = 0; /* no fourcc */
+    st->codecpar->width      = avio_rb16(pb);
+    st->codecpar->height     = avio_rb16(pb);
     film->leading         = avio_rb16(pb);
     avpriv_set_pts_info(st, 64, 1, avio_rb16(pb));
 
@@ -82,9 +82,9 @@ static int read_packet(AVFormatContext *s,
 
     if (s->pb->eof_reached)
         return AVERROR(EIO);
-    pkt->dts = avio_tell(s->pb) / (st->codec->width * (st->codec->height + film->leading) * 4);
-    pkt->size = av_get_packet(s->pb, pkt, st->codec->width * st->codec->height * 4);
-    avio_skip(s->pb, st->codec->width * (int64_t) film->leading * 4);
+    pkt->dts = avio_tell(s->pb) / (st->codecpar->width * (st->codecpar->height + film->leading) * 4);
+    pkt->size = av_get_packet(s->pb, pkt, st->codecpar->width * st->codecpar->height * 4);
+    avio_skip(s->pb, st->codecpar->width * (int64_t) film->leading * 4);
     if (pkt->size < 0)
         return pkt->size;
     pkt->flags |= AV_PKT_FLAG_KEY;
@@ -94,7 +94,7 @@ static int read_packet(AVFormatContext *s,
 static int read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
 {
     AVStream *st = s->streams[stream_index];
-    if (avio_seek(s->pb, FFMAX(timestamp, 0) * st->codec->width * st->codec->height * 4, SEEK_SET) < 0)
+    if (avio_seek(s->pb, FFMAX(timestamp, 0) * st->codecpar->width * st->codecpar->height * 4, SEEK_SET) < 0)
         return -1;
     return 0;
 }
index 0794b18c507901ed43c37ceeca5cad87e0d10917..5a09691a708164a681112efc1f13173795e6f329 100644 (file)
@@ -35,7 +35,7 @@ typedef struct FilmstripMuxContext {
 
 static int write_header(AVFormatContext *s)
 {
-    if (s->streams[0]->codec->pix_fmt != AV_PIX_FMT_RGBA) {
+    if (s->streams[0]->codecpar->format != AV_PIX_FMT_RGBA) {
         av_log(s, AV_LOG_ERROR, "only AV_PIX_FMT_RGBA is supported\n");
         return AVERROR_INVALIDDATA;
     }
@@ -61,8 +61,8 @@ static int write_trailer(AVFormatContext *s)
     avio_wb32(pb, film->nb_frames);
     avio_wb16(pb, 0);  // packing method
     avio_wb16(pb, 0);  // reserved
-    avio_wb16(pb, st->codec->width);
-    avio_wb16(pb, st->codec->height);
+    avio_wb16(pb, st->codecpar->width);
+    avio_wb16(pb, st->codecpar->height);
     avio_wb16(pb, 0);  // leading
     // TODO: should be avg_frame_rate
     avio_wb16(pb, 1/av_q2d(st->time_base));
index a6b55379f872003e8f25e8234015bd67ae655dcc..1381a28b8064fc8b7ae2d78a08fb157dace9392a 100644 (file)
@@ -131,10 +131,10 @@ int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
     st->attached_pic.flags       |= AV_PKT_FLAG_KEY;
 
     st->disposition      |= AV_DISPOSITION_ATTACHED_PIC;
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id   = id;
-    st->codec->width      = width;
-    st->codec->height     = height;
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id   = id;
+    st->codecpar->width      = width;
+    st->codecpar->height     = height;
     av_dict_set(&st->metadata, "comment", ff_id3v2_picture_types[type], 0);
     if (desc)
         av_dict_set(&st->metadata, "title", desc, AV_DICT_DONT_STRDUP_VAL);
index 494bb095cc5f16b58be7c0f7eb17d0c9020a4a1c..7a75527333e2122aa489bead34d35e63b086ec33 100644 (file)
@@ -36,8 +36,8 @@ static int flac_read_header(AVFormatContext *s)
     AVStream *st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
-    st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id = AV_CODEC_ID_FLAC;
+    st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_id = AV_CODEC_ID_FLAC;
     st->need_parsing = AVSTREAM_PARSE_FULL;
     /* the parameters will be extracted from the compressed bitstream */
 
@@ -88,14 +88,14 @@ static int flac_read_header(AVFormatContext *s)
                 return AVERROR_INVALIDDATA;
             }
             found_streaminfo = 1;
-            st->codec->extradata      = buffer;
-            st->codec->extradata_size = metadata_size;
+            st->codecpar->extradata      = buffer;
+            st->codecpar->extradata_size = metadata_size;
             buffer = NULL;
 
             /* get sample rate and sample count from STREAMINFO header;
              * other parameters will be extracted by the parser */
-            samplerate = AV_RB24(st->codec->extradata + 10) >> 4;
-            samples    = (AV_RB64(st->codec->extradata + 13) >> 24) & ((1ULL << 36) - 1);
+            samplerate = AV_RB24(st->codecpar->extradata + 10) >> 4;
+            samples    = (AV_RB64(st->codecpar->extradata + 13) >> 24) & ((1ULL << 36) - 1);
 
             /* set time base and duration */
             if (samplerate > 0) {
@@ -159,7 +159,7 @@ static int flac_read_header(AVFormatContext *s)
                         av_log(s, AV_LOG_WARNING,
                                "Invalid value of WAVEFORMATEXTENSIBLE_CHANNEL_MASK\n");
                     } else {
-                        st->codec->channel_layout = mask;
+                        st->codecpar->channel_layout = mask;
                         av_dict_set(&s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", NULL, 0);
                     }
                 }
index a686826543d9ae5f8ec43ee34a30d3c1a70f23a6..3cee668afcf16eb2f042ca128820a9b0dc0f40bb 100644 (file)
@@ -77,21 +77,21 @@ static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m,
 static int flac_write_header(struct AVFormatContext *s)
 {
     int ret;
-    AVCodecContext *codec = s->streams[0]->codec;
+    AVCodecParameters *par = s->streams[0]->codecpar;
     FlacMuxerContext *c   = s->priv_data;
 
     if (!c->write_header)
         return 0;
 
-    ret = ff_flac_write_header(s->pb, codec->extradata,
-                               codec->extradata_size, 0);
+    ret = ff_flac_write_header(s->pb, par->extradata,
+                               par->extradata_size, 0);
     if (ret)
         return ret;
 
     /* add the channel layout tag */
-    if (codec->channel_layout &&
-        !(codec->channel_layout & ~0x3ffffULL) &&
-        !ff_flac_is_native_layout(codec->channel_layout)) {
+    if (par->channel_layout &&
+        !(par->channel_layout & ~0x3ffffULL) &&
+        !ff_flac_is_native_layout(par->channel_layout)) {
         AVDictionaryEntry *chmask = av_dict_get(s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK",
                                                 NULL, 0);
 
@@ -100,7 +100,7 @@ static int flac_write_header(struct AVFormatContext *s)
                    "already present, this muxer will not overwrite it.\n");
         } else {
             uint8_t buf[32];
-            snprintf(buf, sizeof(buf), "0x%"PRIx64, codec->channel_layout);
+            snprintf(buf, sizeof(buf), "0x%"PRIx64, par->channel_layout);
             av_dict_set(&s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);
         }
     }
@@ -125,7 +125,7 @@ static int flac_write_trailer(struct AVFormatContext *s)
     int64_t file_size;
     FlacMuxerContext *c = s->priv_data;
     uint8_t *streaminfo = c->streaminfo ? c->streaminfo :
-                                          s->streams[0]->codec->extradata;
+                                          s->streams[0]->codecpar->extradata;
 
     if (!c->write_header || !streaminfo)
         return 0;
index 277e12b20ce450469ef407ad0949c463fac52372..cb88b67521f41fdfbe0cc60c2001a3d6e1a7f905 100644 (file)
@@ -109,25 +109,25 @@ static int flic_read_header(AVFormatContext *s)
     if (!st)
         return AVERROR(ENOMEM);
     flic->video_stream_index = st->index;
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id = AV_CODEC_ID_FLIC;
-    st->codec->codec_tag = 0;  /* no fourcc */
-    st->codec->width = AV_RL16(&header[0x08]);
-    st->codec->height = AV_RL16(&header[0x0A]);
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id = AV_CODEC_ID_FLIC;
+    st->codecpar->codec_tag = 0;  /* no fourcc */
+    st->codecpar->width = AV_RL16(&header[0x08]);
+    st->codecpar->height = AV_RL16(&header[0x0A]);
 
-    if (!st->codec->width || !st->codec->height) {
+    if (!st->codecpar->width || !st->codecpar->height) {
         /* Ugly hack needed for the following sample: */
         /* http://samples.libav.org/fli-flc/fli-bugs/specular.flc */
         av_log(s, AV_LOG_WARNING,
                "File with no specified width/height. Trying 640x480.\n");
-        st->codec->width  = 640;
-        st->codec->height = 480;
+        st->codecpar->width  = 640;
+        st->codecpar->height = 480;
     }
 
     /* send over the whole 128-byte FLIC header */
-    st->codec->extradata_size = FLIC_HEADER_SIZE;
-    st->codec->extradata = av_malloc(FLIC_HEADER_SIZE);
-    memcpy(st->codec->extradata, header, FLIC_HEADER_SIZE);
+    st->codecpar->extradata_size = FLIC_HEADER_SIZE;
+    st->codecpar->extradata = av_malloc(FLIC_HEADER_SIZE);
+    memcpy(st->codecpar->extradata, header, FLIC_HEADER_SIZE);
 
     /* peek at the preamble to detect TFTD videos - they seem to always start with an audio chunk */
     if (avio_read(pb, preamble, FLIC_PREAMBLE_SIZE) != FLIC_PREAMBLE_SIZE) {
@@ -152,22 +152,22 @@ static int flic_read_header(AVFormatContext *s)
         flic->audio_stream_index = ast->index;
 
         /* all audio frames are the same size, so use the size of the first chunk for block_align */
-        ast->codec->block_align = AV_RL32(&preamble[0]);
-        ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-        ast->codec->codec_id = AV_CODEC_ID_PCM_U8;
-        ast->codec->codec_tag = 0;
-        ast->codec->sample_rate = FLIC_TFTD_SAMPLE_RATE;
-        ast->codec->channels = 1;
-        ast->codec->sample_fmt = AV_SAMPLE_FMT_U8;
-        ast->codec->bit_rate = st->codec->sample_rate * 8;
-        ast->codec->bits_per_coded_sample = 8;
-        ast->codec->channel_layout = AV_CH_LAYOUT_MONO;
-        ast->codec->extradata_size = 0;
+        ast->codecpar->block_align = AV_RL32(&preamble[0]);
+        ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+        ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
+        ast->codecpar->codec_tag = 0;
+        ast->codecpar->sample_rate = FLIC_TFTD_SAMPLE_RATE;
+        ast->codecpar->channels = 1;
+        ast->codecpar->format   = AV_SAMPLE_FMT_U8;
+        ast->codecpar->bit_rate = st->codecpar->sample_rate * 8;
+        ast->codecpar->bits_per_coded_sample = 8;
+        ast->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+        ast->codecpar->extradata_size = 0;
 
         /* Since the header information is incorrect we have to figure out the
          * framerate using block_align and the fact that the audio is 22050 Hz.
          * We usually have two cases: 2205 -> 10 fps and 1470 -> 15 fps */
-        avpriv_set_pts_info(st, 64, ast->codec->block_align, FLIC_TFTD_SAMPLE_RATE);
+        avpriv_set_pts_info(st, 64, ast->codecpar->block_align, FLIC_TFTD_SAMPLE_RATE);
         avpriv_set_pts_info(ast, 64, 1, FLIC_TFTD_SAMPLE_RATE);
     } else if (AV_RL16(&header[0x10]) == FLIC_CHUNK_MAGIC_1) {
         avpriv_set_pts_info(st, 64, FLIC_MC_SPEED, 70);
@@ -176,10 +176,10 @@ static int flic_read_header(AVFormatContext *s)
         avio_seek(pb, 12, SEEK_SET);
 
         /* send over abbreviated FLIC header chunk */
-        av_free(st->codec->extradata);
-        st->codec->extradata_size = 12;
-        st->codec->extradata = av_malloc(12);
-        memcpy(st->codec->extradata, header, 12);
+        av_free(st->codecpar->extradata);
+        st->codecpar->extradata_size = 12;
+        st->codecpar->extradata = av_malloc(12);
+        memcpy(st->codecpar->extradata, header, 12);
 
     } else if (magic_number == FLIC_FILE_MAGIC_1) {
         avpriv_set_pts_info(st, 64, speed, 70);
index 8b0d201f80a7b47afed28931c5a43e82fdc55766..a9bead5fda5ee7685d42e3c8de3602be7368944d 100644 (file)
@@ -80,21 +80,21 @@ static AVStream *create_stream(AVFormatContext *s, int codec_type)
     AVStream *st = avformat_new_stream(s, NULL);
     if (!st)
         return NULL;
-    st->codec->codec_type = codec_type;
+    st->codecpar->codec_type = codec_type;
     avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
     return st;
 }
 
-static int flv_same_audio_codec(AVCodecContext *acodec, int flags)
+static int flv_same_audio_codec(AVCodecParameters *apar, int flags)
 {
     int bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
     int flv_codecid           = flags & FLV_AUDIO_CODECID_MASK;
     int codec_id;
 
-    if (!acodec->codec_id && !acodec->codec_tag)
+    if (!apar->codec_id && !apar->codec_tag)
         return 1;
 
-    if (acodec->bits_per_coded_sample != bits_per_coded_sample)
+    if (apar->bits_per_coded_sample != bits_per_coded_sample)
         return 0;
 
     switch (flv_codecid) {
@@ -107,42 +107,42 @@ static int flv_same_audio_codec(AVCodecContext *acodec, int flags)
 #else
                    : AV_CODEC_ID_PCM_S16LE;
 #endif
-        return codec_id == acodec->codec_id;
+        return codec_id == apar->codec_id;
     case FLV_CODECID_PCM_LE:
         codec_id = bits_per_coded_sample == 8
                    ? AV_CODEC_ID_PCM_U8
                    : AV_CODEC_ID_PCM_S16LE;
-        return codec_id == acodec->codec_id;
+        return codec_id == apar->codec_id;
     case FLV_CODECID_AAC:
-        return acodec->codec_id == AV_CODEC_ID_AAC;
+        return apar->codec_id == AV_CODEC_ID_AAC;
     case FLV_CODECID_ADPCM:
-        return acodec->codec_id == AV_CODEC_ID_ADPCM_SWF;
+        return apar->codec_id == AV_CODEC_ID_ADPCM_SWF;
     case FLV_CODECID_SPEEX:
-        return acodec->codec_id == AV_CODEC_ID_SPEEX;
+        return apar->codec_id == AV_CODEC_ID_SPEEX;
     case FLV_CODECID_MP3:
-        return acodec->codec_id == AV_CODEC_ID_MP3;
+        return apar->codec_id == AV_CODEC_ID_MP3;
     case FLV_CODECID_NELLYMOSER_8KHZ_MONO:
     case FLV_CODECID_NELLYMOSER_16KHZ_MONO:
     case FLV_CODECID_NELLYMOSER:
-        return acodec->codec_id == AV_CODEC_ID_NELLYMOSER;
+        return apar->codec_id == AV_CODEC_ID_NELLYMOSER;
     case FLV_CODECID_PCM_MULAW:
-        return acodec->sample_rate == 8000 &&
-               acodec->codec_id    == AV_CODEC_ID_PCM_MULAW;
+        return apar->sample_rate == 8000 &&
+               apar->codec_id    == AV_CODEC_ID_PCM_MULAW;
     case FLV_CODECID_PCM_ALAW:
-        return acodec->sample_rate == 8000 &&
-               acodec->codec_id    == AV_CODEC_ID_PCM_ALAW;
+        return apar->sample_rate == 8000 &&
+               apar->codec_id    == AV_CODEC_ID_PCM_ALAW;
     default:
-        return acodec->codec_tag == (flv_codecid >> FLV_AUDIO_CODECID_OFFSET);
+        return apar->codec_tag == (flv_codecid >> FLV_AUDIO_CODECID_OFFSET);
     }
 }
 
 static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream,
-                                AVCodecContext *acodec, int flv_codecid)
+                                AVCodecParameters *apar, int flv_codecid)
 {
     switch (flv_codecid) {
     // no distinction between S16 and S8 PCM codec flags
     case FLV_CODECID_PCM:
-        acodec->codec_id = acodec->bits_per_coded_sample == 8
+        apar->codec_id = apar->bits_per_coded_sample == 8
                            ? AV_CODEC_ID_PCM_U8
 #if HAVE_BIGENDIAN
                            : AV_CODEC_ID_PCM_S16BE;
@@ -151,113 +151,113 @@ static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream,
 #endif
         break;
     case FLV_CODECID_PCM_LE:
-        acodec->codec_id = acodec->bits_per_coded_sample == 8
+        apar->codec_id = apar->bits_per_coded_sample == 8
                            ? AV_CODEC_ID_PCM_U8
                            : AV_CODEC_ID_PCM_S16LE;
         break;
     case FLV_CODECID_AAC:
-        acodec->codec_id = AV_CODEC_ID_AAC;
+        apar->codec_id = AV_CODEC_ID_AAC;
         break;
     case FLV_CODECID_ADPCM:
-        acodec->codec_id = AV_CODEC_ID_ADPCM_SWF;
+        apar->codec_id = AV_CODEC_ID_ADPCM_SWF;
         break;
     case FLV_CODECID_SPEEX:
-        acodec->codec_id    = AV_CODEC_ID_SPEEX;
-        acodec->sample_rate = 16000;
+        apar->codec_id    = AV_CODEC_ID_SPEEX;
+        apar->sample_rate = 16000;
         break;
     case FLV_CODECID_MP3:
-        acodec->codec_id      = AV_CODEC_ID_MP3;
+        apar->codec_id      = AV_CODEC_ID_MP3;
         astream->need_parsing = AVSTREAM_PARSE_FULL;
         break;
     case FLV_CODECID_NELLYMOSER_8KHZ_MONO:
         // in case metadata does not otherwise declare samplerate
-        acodec->sample_rate = 8000;
-        acodec->codec_id    = AV_CODEC_ID_NELLYMOSER;
+        apar->sample_rate = 8000;
+        apar->codec_id    = AV_CODEC_ID_NELLYMOSER;
         break;
     case FLV_CODECID_NELLYMOSER_16KHZ_MONO:
-        acodec->sample_rate = 16000;
-        acodec->codec_id    = AV_CODEC_ID_NELLYMOSER;
+        apar->sample_rate = 16000;
+        apar->codec_id    = AV_CODEC_ID_NELLYMOSER;
         break;
     case FLV_CODECID_NELLYMOSER:
-        acodec->codec_id = AV_CODEC_ID_NELLYMOSER;
+        apar->codec_id = AV_CODEC_ID_NELLYMOSER;
         break;
     case FLV_CODECID_PCM_MULAW:
-        acodec->sample_rate = 8000;
-        acodec->codec_id    = AV_CODEC_ID_PCM_MULAW;
+        apar->sample_rate = 8000;
+        apar->codec_id    = AV_CODEC_ID_PCM_MULAW;
         break;
     case FLV_CODECID_PCM_ALAW:
-        acodec->sample_rate = 8000;
-        acodec->codec_id    = AV_CODEC_ID_PCM_ALAW;
+        apar->sample_rate = 8000;
+        apar->codec_id    = AV_CODEC_ID_PCM_ALAW;
         break;
     default:
         av_log(s, AV_LOG_INFO, "Unsupported audio codec (%x)\n",
                flv_codecid >> FLV_AUDIO_CODECID_OFFSET);
-        acodec->codec_tag = flv_codecid >> FLV_AUDIO_CODECID_OFFSET;
+        apar->codec_tag = flv_codecid >> FLV_AUDIO_CODECID_OFFSET;
     }
 }
 
-static int flv_same_video_codec(AVCodecContext *vcodec, int flags)
+static int flv_same_video_codec(AVCodecParameters *vpar, int flags)
 {
     int flv_codecid = flags & FLV_VIDEO_CODECID_MASK;
 
-    if (!vcodec->codec_id && !vcodec->codec_tag)
+    if (!vpar->codec_id && !vpar->codec_tag)
         return 1;
 
     switch (flv_codecid) {
     case FLV_CODECID_H263:
-        return vcodec->codec_id == AV_CODEC_ID_FLV1;
+        return vpar->codec_id == AV_CODEC_ID_FLV1;
     case FLV_CODECID_SCREEN:
-        return vcodec->codec_id == AV_CODEC_ID_FLASHSV;
+        return vpar->codec_id == AV_CODEC_ID_FLASHSV;
     case FLV_CODECID_SCREEN2:
-        return vcodec->codec_id == AV_CODEC_ID_FLASHSV2;
+        return vpar->codec_id == AV_CODEC_ID_FLASHSV2;
     case FLV_CODECID_VP6:
-        return vcodec->codec_id == AV_CODEC_ID_VP6F;
+        return vpar->codec_id == AV_CODEC_ID_VP6F;
     case FLV_CODECID_VP6A:
-        return vcodec->codec_id == AV_CODEC_ID_VP6A;
+        return vpar->codec_id == AV_CODEC_ID_VP6A;
     case FLV_CODECID_H264:
-        return vcodec->codec_id == AV_CODEC_ID_H264;
+        return vpar->codec_id == AV_CODEC_ID_H264;
     default:
-        return vcodec->codec_tag == flv_codecid;
+        return vpar->codec_tag == flv_codecid;
     }
 }
 
 static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream,
                                int flv_codecid, int read)
 {
-    AVCodecContext *vcodec = vstream->codec;
+    AVCodecParameters *par = vstream->codecpar;
     switch (flv_codecid) {
     case FLV_CODECID_H263:
-        vcodec->codec_id = AV_CODEC_ID_FLV1;
+        par->codec_id = AV_CODEC_ID_FLV1;
         break;
     case FLV_CODECID_SCREEN:
-        vcodec->codec_id = AV_CODEC_ID_FLASHSV;
+        par->codec_id = AV_CODEC_ID_FLASHSV;
         break;
     case FLV_CODECID_SCREEN2:
-        vcodec->codec_id = AV_CODEC_ID_FLASHSV2;
+        par->codec_id = AV_CODEC_ID_FLASHSV2;
         break;
     case FLV_CODECID_VP6:
-        vcodec->codec_id = AV_CODEC_ID_VP6F;
+        par->codec_id = AV_CODEC_ID_VP6F;
     case FLV_CODECID_VP6A:
         if (flv_codecid == FLV_CODECID_VP6A)
-            vcodec->codec_id = AV_CODEC_ID_VP6A;
+            par->codec_id = AV_CODEC_ID_VP6A;
         if (read) {
-            if (vcodec->extradata_size != 1) {
-                vcodec->extradata = av_malloc(1);
-                if (vcodec->extradata)
-                    vcodec->extradata_size = 1;
+            if (par->extradata_size != 1) {
+                par->extradata = av_malloc(1);
+                if (par->extradata)
+                    par->extradata_size = 1;
             }
-            if (vcodec->extradata)
-                vcodec->extradata[0] = avio_r8(s->pb);
+            if (par->extradata)
+                par->extradata[0] = avio_r8(s->pb);
             else
                 avio_skip(s->pb, 1);
         }
         return 1;     // 1 byte body size adjustment for flv_read_packet()
     case FLV_CODECID_H264:
-        vcodec->codec_id = AV_CODEC_ID_H264;
+        par->codec_id = AV_CODEC_ID_H264;
         return 3;     // not 4, reading packet type will consume one byte
     default:
         av_log(s, AV_LOG_INFO, "Unsupported video codec (%x)\n", flv_codecid);
-        vcodec->codec_tag = flv_codecid;
+        par->codec_tag = flv_codecid;
     }
 
     return 0;
@@ -368,7 +368,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
                             AVStream *vstream, const char *key,
                             int64_t max_pos, int depth)
 {
-    AVCodecContext *acodec, *vcodec;
+    AVCodecParameters *apar, *vpar;
     FLVContext *flv = s->priv_data;
     AVIOContext *ioc;
     AMFDataType amf_type;
@@ -442,43 +442,43 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
     if (key) {
         // stream info doesn't live any deeper than the first object
         if (depth == 1) {
-            acodec = astream ? astream->codec : NULL;
-            vcodec = vstream ? vstream->codec : NULL;
+            apar = astream ? astream->codecpar : NULL;
+            vpar = vstream ? vstream->codecpar : NULL;
 
             if (amf_type == AMF_DATA_TYPE_NUMBER ||
                 amf_type == AMF_DATA_TYPE_BOOL) {
                 if (!strcmp(key, "duration"))
                     s->duration = num_val * AV_TIME_BASE;
-                else if (!strcmp(key, "videodatarate") && vcodec &&
+                else if (!strcmp(key, "videodatarate") && vpar &&
                          0 <= (int)(num_val * 1024.0))
-                    vcodec->bit_rate = num_val * 1024.0;
-                else if (!strcmp(key, "audiodatarate") && acodec &&
+                    vpar->bit_rate = num_val * 1024.0;
+                else if (!strcmp(key, "audiodatarate") && apar &&
                          0 <= (int)(num_val * 1024.0))
-                    acodec->bit_rate = num_val * 1024.0;
+                    apar->bit_rate = num_val * 1024.0;
                 else if (!strcmp(key, "datastream")) {
                     AVStream *st = create_stream(s, AVMEDIA_TYPE_DATA);
                     if (!st)
                         return AVERROR(ENOMEM);
-                    st->codec->codec_id = AV_CODEC_ID_TEXT;
+                    st->codecpar->codec_id = AV_CODEC_ID_TEXT;
                 } else if (flv->trust_metadata) {
-                    if (!strcmp(key, "videocodecid") && vcodec) {
+                    if (!strcmp(key, "videocodecid") && vpar) {
                         flv_set_video_codec(s, vstream, num_val, 0);
-                    } else if (!strcmp(key, "audiocodecid") && acodec) {
+                    } else if (!strcmp(key, "audiocodecid") && apar) {
                         int id = ((int)num_val) << FLV_AUDIO_CODECID_OFFSET;
-                        flv_set_audio_codec(s, astream, acodec, id);
-                    } else if (!strcmp(key, "audiosamplerate") && acodec) {
-                        acodec->sample_rate = num_val;
-                    } else if (!strcmp(key, "audiosamplesize") && acodec) {
-                        acodec->bits_per_coded_sample = num_val;
-                    } else if (!strcmp(key, "stereo") && acodec) {
-                        acodec->channels       = num_val + 1;
-                        acodec->channel_layout = acodec->channels == 2 ?
-                                                 AV_CH_LAYOUT_STEREO :
-                                                 AV_CH_LAYOUT_MONO;
-                    } else if (!strcmp(key, "width") && vcodec) {
-                        vcodec->width = num_val;
-                    } else if (!strcmp(key, "height") && vcodec) {
-                        vcodec->height = num_val;
+                        flv_set_audio_codec(s, astream, apar, id);
+                    } else if (!strcmp(key, "audiosamplerate") && apar) {
+                        apar->sample_rate = num_val;
+                    } else if (!strcmp(key, "audiosamplesize") && apar) {
+                        apar->bits_per_coded_sample = num_val;
+                    } else if (!strcmp(key, "stereo") && apar) {
+                        apar->channels       = num_val + 1;
+                        apar->channel_layout = apar->channels == 2 ?
+                                               AV_CH_LAYOUT_STEREO :
+                                               AV_CH_LAYOUT_MONO;
+                    } else if (!strcmp(key, "width") && vpar) {
+                        vpar->width = num_val;
+                    } else if (!strcmp(key, "height") && vpar) {
+                        vpar->height = num_val;
                     }
                 }
             }
@@ -544,9 +544,9 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
     // the lookup every time it is called.
     for (i = 0; i < s->nb_streams; i++) {
         stream = s->streams[i];
-        if (stream->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+        if (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
             astream = stream;
-        else if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+        else if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
             vstream = stream;
     }
 
@@ -585,12 +585,12 @@ static int flv_read_close(AVFormatContext *s)
 
 static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size)
 {
-    av_free(st->codec->extradata);
-    st->codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
-    if (!st->codec->extradata)
+    av_free(st->codecpar->extradata);
+    st->codecpar->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
+    if (!st->codecpar->extradata)
         return AVERROR(ENOMEM);
-    st->codec->extradata_size = size;
-    avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
+    st->codecpar->extradata_size = size;
+    avio_read(s->pb, st->codecpar->extradata, st->codecpar->extradata_size);
     return 0;
 }
 
@@ -704,7 +704,7 @@ static int flv_data_packet(AVFormatContext *s, AVPacket *pkt,
 
     for (i = 0; i < s->nb_streams; i++) {
         st = s->streams[i];
-        if (st->codec->codec_type == AVMEDIA_TYPE_DATA)
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA)
             break;
     }
 
@@ -712,7 +712,7 @@ static int flv_data_packet(AVFormatContext *s, AVPacket *pkt,
         st = create_stream(s, AVMEDIA_TYPE_DATA);
         if (!st)
             return AVERROR(ENOMEM);
-        st->codec->codec_id = AV_CODEC_ID_TEXT;
+        st->codecpar->codec_id = AV_CODEC_ID_TEXT;
     }
 
     pkt->dts  = dts;
@@ -803,12 +803,12 @@ skip:
         /* now find stream */
         for (i = 0; i < s->nb_streams; i++) {
             st = s->streams[i];
-            if (is_audio && st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
-                if (flv_same_audio_codec(st->codec, flags))
+            if (is_audio && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+                if (flv_same_audio_codec(st->codecpar, flags))
                     break;
             } else if (!is_audio &&
-                       st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
-                if (flv_same_video_codec(st->codec, flags))
+                       st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+                if (flv_same_video_codec(st->codecpar, flags))
                     break;
             }
         }
@@ -866,38 +866,43 @@ skip:
         sample_rate = 44100 << ((flags & FLV_AUDIO_SAMPLERATE_MASK) >>
                                 FLV_AUDIO_SAMPLERATE_OFFSET) >> 3;
         bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
-        if (!st->codec->channels || !st->codec->sample_rate ||
-            !st->codec->bits_per_coded_sample) {
-            st->codec->channels              = channels;
-            st->codec->channel_layout        = channels == 1
+        if (!st->codecpar->channels || !st->codecpar->sample_rate ||
+            !st->codecpar->bits_per_coded_sample) {
+            st->codecpar->channels              = channels;
+            st->codecpar->channel_layout        = channels == 1
                                                ? AV_CH_LAYOUT_MONO
                                                : AV_CH_LAYOUT_STEREO;
-            st->codec->sample_rate           = sample_rate;
-            st->codec->bits_per_coded_sample = bits_per_coded_sample;
+            st->codecpar->sample_rate           = sample_rate;
+            st->codecpar->bits_per_coded_sample = bits_per_coded_sample;
         }
-        if (!st->codec->codec_id) {
-            flv_set_audio_codec(s, st, st->codec,
+        if (!st->codecpar->codec_id) {
+            flv_set_audio_codec(s, st, st->codecpar,
                                 flags & FLV_AUDIO_CODECID_MASK);
             flv->last_sample_rate =
-            sample_rate           = st->codec->sample_rate;
+            sample_rate           = st->codecpar->sample_rate;
             flv->last_channels    =
-            channels              = st->codec->channels;
+            channels              = st->codecpar->channels;
         } else {
-            AVCodecContext ctx;
-            ctx.sample_rate = sample_rate;
-            ctx.bits_per_coded_sample = bits_per_coded_sample;
-            flv_set_audio_codec(s, st, &ctx, flags & FLV_AUDIO_CODECID_MASK);
-            sample_rate = ctx.sample_rate;
+            AVCodecParameters *par = avcodec_parameters_alloc();
+            if (!par) {
+                ret = AVERROR(ENOMEM);
+                goto leave;
+            }
+            par->sample_rate = sample_rate;
+            par->bits_per_coded_sample = bits_per_coded_sample;
+            flv_set_audio_codec(s, st, par, flags & FLV_AUDIO_CODECID_MASK);
+            sample_rate = par->sample_rate;
+            avcodec_parameters_free(&par);
         }
     } else {
         size -= flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK, 1);
     }
 
-    if (st->codec->codec_id == AV_CODEC_ID_AAC ||
-        st->codec->codec_id == AV_CODEC_ID_H264) {
+    if (st->codecpar->codec_id == AV_CODEC_ID_AAC ||
+        st->codecpar->codec_id == AV_CODEC_ID_H264) {
         int type = avio_r8(s->pb);
         size--;
-        if (st->codec->codec_id == AV_CODEC_ID_H264) {
+        if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
             // sign extension
             int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000;
             pts = dts + cts;
@@ -908,7 +913,7 @@ skip:
             }
         }
         if (type == 0) {
-            if (st->codec->extradata) {
+            if (st->codecpar->extradata) {
                 if ((ret = flv_queue_extradata(flv, s->pb, is_audio, size)) < 0)
                     return ret;
                 ret = AVERROR(EAGAIN);
@@ -916,24 +921,24 @@ skip:
             }
             if ((ret = flv_get_extradata(s, st, size)) < 0)
                 return ret;
-            if (st->codec->codec_id == AV_CODEC_ID_AAC) {
+            if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
                 MPEG4AudioConfig cfg;
 
                 /* Workaround for buggy Omnia A/XE encoder */
                 AVDictionaryEntry *t = av_dict_get(s->metadata, "Encoder", NULL, 0);
                 if (t && !strcmp(t->value, "Omnia A/XE"))
-                    st->codec->extradata_size = 2;
+                    st->codecpar->extradata_size = 2;
 
-                avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata,
-                                             st->codec->extradata_size * 8, 1);
-                st->codec->channels       = cfg.channels;
-                st->codec->channel_layout = 0;
+                avpriv_mpeg4audio_get_config(&cfg, st->codecpar->extradata,
+                                             st->codecpar->extradata_size * 8, 1);
+                st->codecpar->channels       = cfg.channels;
+                st->codecpar->channel_layout = 0;
                 if (cfg.ext_sample_rate)
-                    st->codec->sample_rate = cfg.ext_sample_rate;
+                    st->codecpar->sample_rate = cfg.ext_sample_rate;
                 else
-                    st->codec->sample_rate = cfg.sample_rate;
+                    st->codecpar->sample_rate = cfg.sample_rate;
                 av_log(s, AV_LOG_TRACE, "mp4a config channels %d sample rate %d\n",
-                        st->codec->channels, st->codec->sample_rate);
+                       st->codecpar->channels, st->codecpar->sample_rate);
             }
 
             ret = AVERROR(EAGAIN);
index 49c52357e2e9e9a0e212f1ec5e69b928e842b0e3..2dfe3ae867c7f73182d73e85e56c9229407c4fdd 100644 (file)
@@ -61,37 +61,37 @@ typedef struct FLVContext {
     int64_t duration;
     int64_t delay;      ///< first dts delay (needed for AVC & Speex)
 
-    AVCodecContext *audio_enc;
-    AVCodecContext *video_enc;
+    AVCodecParameters *audio_par;
+    AVCodecParameters *video_par;
     double framerate;
-    AVCodecContext *data_enc;
+    AVCodecParameters *data_par;
 } FLVContext;
 
 typedef struct FLVStreamContext {
     int64_t last_ts;    ///< last timestamp for each stream
 } FLVStreamContext;
 
-static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
+static int get_audio_flags(AVFormatContext *s, AVCodecParameters *par)
 {
-    int flags = (enc->bits_per_coded_sample == 16) ? FLV_SAMPLESSIZE_16BIT
+    int flags = (par->bits_per_coded_sample == 16) ? FLV_SAMPLESSIZE_16BIT
                                                    : FLV_SAMPLESSIZE_8BIT;
 
-    if (enc->codec_id == AV_CODEC_ID_AAC) // specs force these parameters
+    if (par->codec_id == AV_CODEC_ID_AAC) // specs force these parameters
         return FLV_CODECID_AAC | FLV_SAMPLERATE_44100HZ |
                FLV_SAMPLESSIZE_16BIT | FLV_STEREO;
-    else if (enc->codec_id == AV_CODEC_ID_SPEEX) {
-        if (enc->sample_rate != 16000) {
+    else if (par->codec_id == AV_CODEC_ID_SPEEX) {
+        if (par->sample_rate != 16000) {
             av_log(s, AV_LOG_ERROR,
                    "flv only supports wideband (16kHz) Speex audio\n");
             return -1;
         }
-        if (enc->channels != 1) {
+        if (par->channels != 1) {
             av_log(s, AV_LOG_ERROR, "flv only supports mono Speex audio\n");
             return -1;
         }
         return FLV_CODECID_SPEEX | FLV_SAMPLERATE_11025HZ | FLV_SAMPLESSIZE_16BIT;
     } else {
-        switch (enc->sample_rate) {
+        switch (par->sample_rate) {
         case 44100:
             flags |= FLV_SAMPLERATE_44100HZ;
             break;
@@ -104,7 +104,7 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
         case 16000: // nellymoser only
         case  8000: // nellymoser only
         case  5512: // not MP3
-            if (enc->codec_id != AV_CODEC_ID_MP3) {
+            if (par->codec_id != AV_CODEC_ID_MP3) {
                 flags |= FLV_SAMPLERATE_SPECIAL;
                 break;
             }
@@ -116,10 +116,10 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
         }
     }
 
-    if (enc->channels > 1)
+    if (par->channels > 1)
         flags |= FLV_STEREO;
 
-    switch (enc->codec_id) {
+    switch (par->codec_id) {
     case AV_CODEC_ID_MP3:
         flags |= FLV_CODECID_MP3    | FLV_SAMPLESSIZE_16BIT;
         break;
@@ -136,9 +136,9 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
         flags |= FLV_CODECID_ADPCM  | FLV_SAMPLESSIZE_16BIT;
         break;
     case AV_CODEC_ID_NELLYMOSER:
-        if (enc->sample_rate == 8000)
+        if (par->sample_rate == 8000)
             flags |= FLV_CODECID_NELLYMOSER_8KHZ_MONO  | FLV_SAMPLESSIZE_16BIT;
-        else if (enc->sample_rate == 16000)
+        else if (par->sample_rate == 16000)
             flags |= FLV_CODECID_NELLYMOSER_16KHZ_MONO | FLV_SAMPLESSIZE_16BIT;
         else
             flags |= FLV_CODECID_NELLYMOSER            | FLV_SAMPLESSIZE_16BIT;
@@ -150,7 +150,7 @@ static int get_audio_flags(AVFormatContext *s, AVCodecContext *enc)
         flags = FLV_CODECID_PCM_ALAW  | FLV_SAMPLERATE_SPECIAL | FLV_SAMPLESSIZE_16BIT;
         break;
     case 0:
-        flags |= enc->codec_tag << 4;
+        flags |= par->codec_tag << 4;
         break;
     default:
         av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n");
@@ -216,9 +216,9 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
     /* mixed array (hash) with size and string/type/data tuples */
     avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
     metadata_count_pos = avio_tell(pb);
-    metadata_count = 4 * !!flv->video_enc +
-                     5 * !!flv->audio_enc +
-                     1 * !!flv->data_enc  +
+    metadata_count = 4 * !!flv->video_par +
+                     5 * !!flv->audio_par +
+                     1 * !!flv->data_par  +
                      2; // +2 for duration and file size
 
     avio_wb32(pb, metadata_count);
@@ -229,15 +229,15 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
     // fill in the guessed duration, it'll be corrected later if incorrect
     put_amf_double(pb, s->duration / AV_TIME_BASE);
 
-    if (flv->video_enc) {
+    if (flv->video_par) {
         put_amf_string(pb, "width");
-        put_amf_double(pb, flv->video_enc->width);
+        put_amf_double(pb, flv->video_par->width);
 
         put_amf_string(pb, "height");
-        put_amf_double(pb, flv->video_enc->height);
+        put_amf_double(pb, flv->video_par->height);
 
         put_amf_string(pb, "videodatarate");
-        put_amf_double(pb, flv->video_enc->bit_rate / 1024.0);
+        put_amf_double(pb, flv->video_par->bit_rate / 1024.0);
 
         if (flv->framerate != 0.0) {
             put_amf_string(pb, "framerate");
@@ -246,27 +246,27 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
         }
 
         put_amf_string(pb, "videocodecid");
-        put_amf_double(pb, flv->video_enc->codec_tag);
+        put_amf_double(pb, flv->video_par->codec_tag);
     }
 
-    if (flv->audio_enc) {
+    if (flv->audio_par) {
         put_amf_string(pb, "audiodatarate");
-        put_amf_double(pb, flv->audio_enc->bit_rate / 1024.0);
+        put_amf_double(pb, flv->audio_par->bit_rate / 1024.0);
 
         put_amf_string(pb, "audiosamplerate");
-        put_amf_double(pb, flv->audio_enc->sample_rate);
+        put_amf_double(pb, flv->audio_par->sample_rate);
 
         put_amf_string(pb, "audiosamplesize");
-        put_amf_double(pb, flv->audio_enc->codec_id == AV_CODEC_ID_PCM_U8 ? 8 : 16);
+        put_amf_double(pb, flv->audio_par->codec_id == AV_CODEC_ID_PCM_U8 ? 8 : 16);
 
         put_amf_string(pb, "stereo");
-        put_amf_bool(pb, flv->audio_enc->channels == 2);
+        put_amf_bool(pb, flv->audio_par->channels == 2);
 
         put_amf_string(pb, "audiocodecid");
-        put_amf_double(pb, flv->audio_enc->codec_tag);
+        put_amf_double(pb, flv->audio_par->codec_tag);
     }
 
-    if (flv->data_enc) {
+    if (flv->data_par) {
         put_amf_string(pb, "datastream");
         put_amf_double(pb, 0.0);
     }
@@ -316,37 +316,37 @@ static int flv_write_header(AVFormatContext *s)
     int64_t data_size;
 
     for (i = 0; i < s->nb_streams; i++) {
-        AVCodecContext *enc = s->streams[i]->codec;
+        AVCodecParameters *par = s->streams[i]->codecpar;
         FLVStreamContext *sc;
-        switch (enc->codec_type) {
+        switch (par->codec_type) {
         case AVMEDIA_TYPE_VIDEO:
             if (s->streams[i]->avg_frame_rate.den &&
                 s->streams[i]->avg_frame_rate.num) {
                 flv->framerate = av_q2d(s->streams[i]->avg_frame_rate);
             }
-            if (flv->video_enc) {
+            if (flv->video_par) {
                 av_log(s, AV_LOG_ERROR,
                        "at most one video stream is supported in flv\n");
                 return AVERROR(EINVAL);
             }
-            flv->video_enc = enc;
-            if (!ff_codec_get_tag(flv_video_codec_ids, enc->codec_id))
-                return unsupported_codec(s, "Video", enc->codec_id);
+            flv->video_par = par;
+            if (!ff_codec_get_tag(flv_video_codec_ids, par->codec_id))
+                return unsupported_codec(s, "Video", par->codec_id);
             break;
         case AVMEDIA_TYPE_AUDIO:
-            if (flv->audio_enc) {
+            if (flv->audio_par) {
                 av_log(s, AV_LOG_ERROR,
                        "at most one audio stream is supported in flv\n");
                 return AVERROR(EINVAL);
             }
-            flv->audio_enc = enc;
-            if (get_audio_flags(s, enc) < 0)
-                return unsupported_codec(s, "Audio", enc->codec_id);
+            flv->audio_par = par;
+            if (get_audio_flags(s, par) < 0)
+                return unsupported_codec(s, "Audio", par->codec_id);
             break;
         case AVMEDIA_TYPE_DATA:
-            if (enc->codec_id != AV_CODEC_ID_TEXT)
-                return unsupported_codec(s, "Data", enc->codec_id);
-            flv->data_enc = enc;
+            if (par->codec_id != AV_CODEC_ID_TEXT)
+                return unsupported_codec(s, "Data", par->codec_id);
+            flv->data_par = par;
             break;
         default:
             av_log(s, AV_LOG_ERROR, "codec not compatible with flv\n");
@@ -365,13 +365,13 @@ static int flv_write_header(AVFormatContext *s)
 
     avio_write(pb, "FLV", 3);
     avio_w8(pb, 1);
-    avio_w8(pb, FLV_HEADER_FLAG_HASAUDIO * !!flv->audio_enc +
-                FLV_HEADER_FLAG_HASVIDEO * !!flv->video_enc);
+    avio_w8(pb, FLV_HEADER_FLAG_HASAUDIO * !!flv->audio_par +
+                FLV_HEADER_FLAG_HASVIDEO * !!flv->video_par);
     avio_wb32(pb, 9);
     avio_wb32(pb, 0);
 
     for (i = 0; i < s->nb_streams; i++)
-        if (s->streams[i]->codec->codec_tag == 5) {
+        if (s->streams[i]->codecpar->codec_tag == 5) {
             avio_w8(pb, 8);     // message type
             avio_wb24(pb, 0);   // include flags
             avio_wb24(pb, 0);   // time stamp
@@ -383,25 +383,25 @@ static int flv_write_header(AVFormatContext *s)
     write_metadata(s, 0);
 
     for (i = 0; i < s->nb_streams; i++) {
-        AVCodecContext *enc = s->streams[i]->codec;
-        if (enc->codec_id == AV_CODEC_ID_AAC || enc->codec_id == AV_CODEC_ID_H264) {
+        AVCodecParameters *par = s->streams[i]->codecpar;
+        if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264) {
             int64_t pos;
-            avio_w8(pb, enc->codec_type == AVMEDIA_TYPE_VIDEO ?
+            avio_w8(pb, par->codec_type == AVMEDIA_TYPE_VIDEO ?
                     FLV_TAG_TYPE_VIDEO : FLV_TAG_TYPE_AUDIO);
             avio_wb24(pb, 0); // size patched later
             avio_wb24(pb, 0); // ts
             avio_w8(pb, 0);   // ts ext
             avio_wb24(pb, 0); // streamid
             pos = avio_tell(pb);
-            if (enc->codec_id == AV_CODEC_ID_AAC) {
-                avio_w8(pb, get_audio_flags(s, enc));
+            if (par->codec_id == AV_CODEC_ID_AAC) {
+                avio_w8(pb, get_audio_flags(s, par));
                 avio_w8(pb, 0); // AAC sequence header
-                avio_write(pb, enc->extradata, enc->extradata_size);
+                avio_write(pb, par->extradata, par->extradata_size);
             } else {
-                avio_w8(pb, enc->codec_tag | FLV_FRAME_KEY); // flags
+                avio_w8(pb, par->codec_tag | FLV_FRAME_KEY); // flags
                 avio_w8(pb, 0); // AVC sequence header
                 avio_wb24(pb, 0); // composition time
-                ff_isom_write_avcc(pb, enc->extradata, enc->extradata_size);
+                ff_isom_write_avcc(pb, par->extradata, par->extradata_size);
             }
             data_size = avio_tell(pb) - pos;
             avio_seek(pb, -data_size - 10, SEEK_CUR);
@@ -424,10 +424,10 @@ static int flv_write_trailer(AVFormatContext *s)
 
     /* Add EOS tag */
     for (i = 0; i < s->nb_streams; i++) {
-        AVCodecContext *enc = s->streams[i]->codec;
+        AVCodecParameters *par = s->streams[i]->codecpar;
         FLVStreamContext *sc = s->streams[i]->priv_data;
-        if (enc->codec_type == AVMEDIA_TYPE_VIDEO &&
-            enc->codec_id == AV_CODEC_ID_H264)
+        if (par->codec_type == AVMEDIA_TYPE_VIDEO &&
+            par->codec_id == AV_CODEC_ID_H264)
             put_avc_eos_tag(pb, sc->last_ts);
     }
 
@@ -450,7 +450,7 @@ static int flv_write_trailer(AVFormatContext *s)
 static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
     AVIOContext *pb      = s->pb;
-    AVCodecContext *enc  = s->streams[pkt->stream_index]->codec;
+    AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
     FLVContext *flv      = s->priv_data;
     FLVStreamContext *sc = s->streams[pkt->stream_index]->priv_data;
     unsigned ts;
@@ -458,10 +458,10 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
     uint8_t *data = NULL;
     int flags = 0, flags_size;
 
-    if (enc->codec_id == AV_CODEC_ID_VP6F || enc->codec_id == AV_CODEC_ID_VP6A ||
-        enc->codec_id == AV_CODEC_ID_AAC)
+    if (par->codec_id == AV_CODEC_ID_VP6F || par->codec_id == AV_CODEC_ID_VP6A ||
+        par->codec_id == AV_CODEC_ID_AAC)
         flags_size = 2;
-    else if (enc->codec_id == AV_CODEC_ID_H264)
+    else if (par->codec_id == AV_CODEC_ID_H264)
         flags_size = 5;
     else
         flags_size = 1;
@@ -482,16 +482,16 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
         s->event_flags &= ~AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
     }
 
-    switch (enc->codec_type) {
+    switch (par->codec_type) {
     case AVMEDIA_TYPE_VIDEO:
         avio_w8(pb, FLV_TAG_TYPE_VIDEO);
 
-        flags = ff_codec_get_tag(flv_video_codec_ids, enc->codec_id);
+        flags = ff_codec_get_tag(flv_video_codec_ids, par->codec_id);
 
         flags |= pkt->flags & AV_PKT_FLAG_KEY ? FLV_FRAME_KEY : FLV_FRAME_INTER;
         break;
     case AVMEDIA_TYPE_AUDIO:
-        flags = get_audio_flags(s, enc);
+        flags = get_audio_flags(s, par);
 
         assert(size);
 
@@ -504,14 +504,14 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
         return AVERROR(EINVAL);
     }
 
-    if (enc->codec_id == AV_CODEC_ID_H264)
+    if (par->codec_id == AV_CODEC_ID_H264)
         /* check if extradata looks like MP4 */
-        if (enc->extradata_size > 0 && *(uint8_t*)enc->extradata != 1)
+        if (par->extradata_size > 0 && *(uint8_t*)par->extradata != 1)
             if (ff_avc_parse_nal_units_buf(pkt->data, &data, &size) < 0)
                 return -1;
 
     /* check Speex packet duration */
-    if (enc->codec_id == AV_CODEC_ID_SPEEX && ts - sc->last_ts > 160)
+    if (par->codec_id == AV_CODEC_ID_SPEEX && ts - sc->last_ts > 160)
         av_log(s, AV_LOG_WARNING, "Warning: Speex stream has more than "
                                   "8 frames per packet. Adobe Flash "
                                   "Player cannot handle this!\n");
@@ -524,7 +524,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
     avio_w8(pb, (ts >> 24) & 0x7F); // timestamps are 32 bits _signed_
     avio_wb24(pb, flv->reserved);
 
-    if (enc->codec_type == AVMEDIA_TYPE_DATA) {
+    if (par->codec_type == AVMEDIA_TYPE_DATA) {
         int data_size;
         int64_t metadata_size_pos = avio_tell(pb);
         avio_w8(pb, AMF_DATA_TYPE_STRING);
@@ -547,15 +547,15 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
         avio_wb32(pb, data_size + 11);
     } else {
         avio_w8(pb,flags);
-        if (enc->codec_id == AV_CODEC_ID_VP6F || enc->codec_id == AV_CODEC_ID_VP6A) {
-            if (enc->extradata_size)
-                avio_w8(pb, enc->extradata[0]);
+        if (par->codec_id == AV_CODEC_ID_VP6F || par->codec_id == AV_CODEC_ID_VP6A) {
+            if (par->extradata_size)
+                avio_w8(pb, par->extradata[0]);
             else
-                avio_w8(pb, ((FFALIGN(enc->width,  16) - enc->width) << 4) |
-                             (FFALIGN(enc->height, 16) - enc->height));
-        } else if (enc->codec_id == AV_CODEC_ID_AAC)
+                avio_w8(pb, ((FFALIGN(par->width,  16) - par->width) << 4) |
+                             (FFALIGN(par->height, 16) - par->height));
+        } else if (par->codec_id == AV_CODEC_ID_AAC)
             avio_w8(pb, 1); // AAC raw
-        else if (enc->codec_id == AV_CODEC_ID_H264) {
+        else if (par->codec_id == AV_CODEC_ID_H264) {
             avio_w8(pb, 1); // AVC NALU
             avio_wb24(pb, pkt->pts - pkt->dts);
         }
index 8052939c79df54e52afb5e07a229239708d86c2e..7e60e4e58c064d171a5f4228ca4c6807c06044b2 100644 (file)
@@ -31,17 +31,17 @@ static int g722_read_header(AVFormatContext *s)
     if (!st)
         return AVERROR(ENOMEM);
 
-    st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id    = AV_CODEC_ID_ADPCM_G722;
-    st->codec->sample_rate = 16000;
-    st->codec->channels    = 1;
+    st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_id    = AV_CODEC_ID_ADPCM_G722;
+    st->codecpar->sample_rate = 16000;
+    st->codecpar->channels    = 1;
 
-    st->codec->bits_per_coded_sample =
-        av_get_bits_per_sample(st->codec->codec_id);
+    st->codecpar->bits_per_coded_sample =
+        av_get_bits_per_sample(st->codecpar->codec_id);
 
-    assert(st->codec->bits_per_coded_sample > 0);
+    assert(st->codecpar->bits_per_coded_sample > 0);
 
-    avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+    avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
     return 0;
 }
 
index 716fbb9dd275ebee79657173c86249b8fd7c1934..9eca3f9bb8ed3e7d4841d2267aaa1338b5c8591d 100644 (file)
@@ -39,13 +39,13 @@ static av_cold int g723_1_init(AVFormatContext *s)
     if (!st)
         return AVERROR(ENOMEM);
 
-    st->codec->codec_type     = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id       = AV_CODEC_ID_G723_1;
-    st->codec->channel_layout = AV_CH_LAYOUT_MONO;
-    st->codec->channels       = 1;
-    st->codec->sample_rate    = 8000;
+    st->codecpar->codec_type     = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_id       = AV_CODEC_ID_G723_1;
+    st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+    st->codecpar->channels       = 1;
+    st->codecpar->sample_rate    = 8000;
 
-    avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+    avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
     st->start_time = 0;
 
     return 0;
index ddec778d829cf6642592adf7958b32c40737917d..e7fa37cfc77d90d9168e05b7dbdad80cf62e7b5c 100644 (file)
@@ -264,7 +264,7 @@ static int gif_write_header(AVFormatContext *s)
 {
     GIFContext *gif = s->priv_data;
     AVIOContext *pb = s->pb;
-    AVCodecContext *enc, *video_enc;
+    AVCodecParameters *par, *video_par;
     int i, width, height /*, rate*/;
 
 /* XXX: do we reject audio streams or just ignore them ?
@@ -274,23 +274,23 @@ static int gif_write_header(AVFormatContext *s)
     gif->time      = 0;
     gif->file_time = 0;
 
-    video_enc = NULL;
+    video_par = NULL;
     for (i = 0; i < s->nb_streams; i++) {
-        enc = s->streams[i]->codec;
-        if (enc->codec_type != AVMEDIA_TYPE_AUDIO)
-            video_enc = enc;
+        par = s->streams[i]->codecpar;
+        if (par->codec_type != AVMEDIA_TYPE_AUDIO)
+            video_par = par;
     }
 
-    if (!video_enc) {
+    if (!video_par) {
         av_free(gif);
         return -1;
     } else {
-        width  = video_enc->width;
-        height = video_enc->height;
+        width  = video_par->width;
+        height = video_par->height;
 //        rate = video_enc->time_base.den;
     }
 
-    if (video_enc->pix_fmt != AV_PIX_FMT_RGB24) {
+    if (video_par->format != AV_PIX_FMT_RGB24) {
         av_log(s, AV_LOG_ERROR,
                "ERROR: gif only handles the rgb24 pixel format. Use -pix_fmt rgb24.\n");
         return AVERROR(EIO);
@@ -302,9 +302,10 @@ static int gif_write_header(AVFormatContext *s)
     return 0;
 }
 
-static int gif_write_video(AVFormatContext *s, AVCodecContext *enc,
+static int gif_write_video(AVFormatContext *s, AVStream *st,
                            const uint8_t *buf, int size)
 {
+    AVCodecParameters *par = st->codecpar;
     AVIOContext *pb = s->pb;
     int jiffies;
 
@@ -319,26 +320,26 @@ static int gif_write_video(AVFormatContext *s, AVCodecContext *enc,
     /* XXX: should use delay, in order to be more accurate */
     /* instead of using the same rounded value each time */
     /* XXX: don't even remember if I really use it for now */
-    jiffies = (70 * enc->time_base.num / enc->time_base.den) - 1;
+    jiffies = (70 * st->time_base.num / st->time_base.den) - 1;
 
     avio_wl16(pb, jiffies);
 
     avio_w8(pb, 0x1f); /* transparent color index */
     avio_w8(pb, 0x00);
 
-    gif_image_write_image(pb, 0, 0, enc->width, enc->height,
-                          buf, enc->width * 3, AV_PIX_FMT_RGB24);
+    gif_image_write_image(pb, 0, 0, par->width, par->height,
+                          buf, par->width * 3, AV_PIX_FMT_RGB24);
 
     return 0;
 }
 
 static int gif_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
-    AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
-    if (codec->codec_type == AVMEDIA_TYPE_AUDIO)
+    AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
+    if (par->codec_type == AVMEDIA_TYPE_AUDIO)
         return 0; /* just ignore audio */
     else
-        return gif_write_video(s, codec, pkt->data, pkt->size);
+        return gif_write_video(s, s->streams[pkt->stream_index], pkt->data, pkt->size);
 }
 
 static int gif_write_trailer(AVFormatContext *s)
index 1bc7eed856bbfed392adb0a1877997e8544252f9..d13327d87970a5374a48cad46d1c6dce00f8908a 100644 (file)
@@ -62,12 +62,12 @@ static int gsm_read_header(AVFormatContext *s)
     if (!st)
         return AVERROR(ENOMEM);
 
-    st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id    = s->iformat->raw_codec_id;
-    st->codec->channels    = 1;
-    st->codec->channel_layout = AV_CH_LAYOUT_MONO;
-    st->codec->sample_rate = c->sample_rate;
-    st->codec->bit_rate    = GSM_BLOCK_SIZE * 8 * c->sample_rate / GSM_BLOCK_SAMPLES;
+    st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_id    = s->iformat->raw_codec_id;
+    st->codecpar->channels    = 1;
+    st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+    st->codecpar->sample_rate = c->sample_rate;
+    st->codecpar->bit_rate    = GSM_BLOCK_SIZE * 8 * c->sample_rate / GSM_BLOCK_SAMPLES;
 
     avpriv_set_pts_info(st, 64, GSM_BLOCK_SAMPLES, GSM_SAMPLE_RATE);
 
index 189584035b21a884e14f7ae3b211e17502250a67..e6ebb27af9a7c5def94631d5585bfd6255921c75 100644 (file)
@@ -92,69 +92,69 @@ static int get_sindex(AVFormatContext *s, int id, int format) {
     switch (format) {
         case 3:
         case 4:
-            st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-            st->codec->codec_id = AV_CODEC_ID_MJPEG;
+            st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+            st->codecpar->codec_id = AV_CODEC_ID_MJPEG;
             break;
         case 13:
         case 15:
-            st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-            st->codec->codec_id = AV_CODEC_ID_DVVIDEO;
+            st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+            st->codecpar->codec_id = AV_CODEC_ID_DVVIDEO;
             break;
         case 14:
         case 16:
-            st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-            st->codec->codec_id = AV_CODEC_ID_DVVIDEO;
+            st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+            st->codecpar->codec_id = AV_CODEC_ID_DVVIDEO;
             break;
         case 11:
         case 12:
         case 20:
-            st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-            st->codec->codec_id = AV_CODEC_ID_MPEG2VIDEO;
+            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.
             break;
         case 22:
         case 23:
-            st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-            st->codec->codec_id = AV_CODEC_ID_MPEG1VIDEO;
+            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.
             break;
         case 9:
-            st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-            st->codec->codec_id = AV_CODEC_ID_PCM_S24LE;
-            st->codec->channels = 1;
-            st->codec->channel_layout = AV_CH_LAYOUT_MONO;
-            st->codec->sample_rate = 48000;
-            st->codec->bit_rate = 3 * 1 * 48000 * 8;
-            st->codec->block_align = 3 * 1;
-            st->codec->bits_per_coded_sample = 24;
+            st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+            st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE;
+            st->codecpar->channels = 1;
+            st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+            st->codecpar->sample_rate = 48000;
+            st->codecpar->bit_rate = 3 * 1 * 48000 * 8;
+            st->codecpar->block_align = 3 * 1;
+            st->codecpar->bits_per_coded_sample = 24;
             break;
         case 10:
-            st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-            st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
-            st->codec->channels = 1;
-            st->codec->channel_layout = AV_CH_LAYOUT_MONO;
-            st->codec->sample_rate = 48000;
-            st->codec->bit_rate = 2 * 1 * 48000 * 8;
-            st->codec->block_align = 2 * 1;
-            st->codec->bits_per_coded_sample = 16;
+            st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+            st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
+            st->codecpar->channels = 1;
+            st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+            st->codecpar->sample_rate = 48000;
+            st->codecpar->bit_rate = 2 * 1 * 48000 * 8;
+            st->codecpar->block_align = 2 * 1;
+            st->codecpar->bits_per_coded_sample = 16;
             break;
         case 17:
-            st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-            st->codec->codec_id = AV_CODEC_ID_AC3;
-            st->codec->channels = 2;
-            st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
-            st->codec->sample_rate = 48000;
+            st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+            st->codecpar->codec_id = AV_CODEC_ID_AC3;
+            st->codecpar->channels = 2;
+            st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+            st->codecpar->sample_rate = 48000;
             break;
         // timecode tracks:
         case 7:
         case 8:
         case 24:
-            st->codec->codec_type = AVMEDIA_TYPE_DATA;
-            st->codec->codec_id = AV_CODEC_ID_NONE;
+            st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+            st->codecpar->codec_id = AV_CODEC_ID_NONE;
             break;
         default:
-            st->codec->codec_type = AVMEDIA_TYPE_UNKNOWN;
-            st->codec->codec_id = AV_CODEC_ID_NONE;
+            st->codecpar->codec_type = AVMEDIA_TYPE_UNKNOWN;
+            st->codecpar->codec_id = AV_CODEC_ID_NONE;
             break;
     }
     return s->nb_streams - 1;
@@ -479,11 +479,11 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
         avio_rb32(pb); // "timeline" field number
         avio_r8(pb); // flags
         avio_r8(pb); // reserved
-        if (st->codec->codec_id == AV_CODEC_ID_PCM_S24LE ||
-            st->codec->codec_id == AV_CODEC_ID_PCM_S16LE) {
+        if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S24LE ||
+            st->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE) {
             int first = field_info >> 16;
             int last  = field_info & 0xffff; // last is exclusive
-            int bps = av_get_bits_per_sample(st->codec->codec_id)>>3;
+            int bps = av_get_bits_per_sample(st->codecpar->codec_id)>>3;
             if (first <= last && last*bps <= pkt_len) {
                 avio_skip(pb, first*bps);
                 skip = pkt_len - last*bps;
@@ -498,7 +498,7 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
         pkt->dts = field_nr;
 
         //set duration manually for DV or else lavf misdetects the frame rate
-        if (st->codec->codec_id == AV_CODEC_ID_DVVIDEO)
+        if (st->codecpar->codec_id == AV_CODEC_ID_DVVIDEO)
             pkt->duration = si->fields_per_frame;
 
         return ret;
index fea1d5d8183cdc6c3bfe6aefa2665e4900d06ac3..22ae315e2df083242c0d53cc34a27d541c396905 100644 (file)
@@ -107,7 +107,7 @@ static int gxf_find_lines_index(AVStream *st)
     int i;
 
     for (i = 0; i < 6; ++i) {
-        if (st->codec->height == gxf_lines_tab[i].height) {
+        if (st->codecpar->height == gxf_lines_tab[i].height) {
             sc->lines_index = gxf_lines_tab[i].index;
             return 0;
         }
@@ -181,18 +181,18 @@ static int gxf_write_mpeg_auxiliary(AVIOContext *pb, AVStream *st)
         if (sc->b_per_i_or_p > 9)
             sc->b_per_i_or_p = 9; /* ensure value won't take more than one char */
     }
-    if (st->codec->height == 512 || st->codec->height == 608)
+    if (st->codecpar->height == 512 || st->codecpar->height == 608)
         starting_line = 7; // VBI
-    else if (st->codec->height == 480)
+    else if (st->codecpar->height == 480)
         starting_line = 20;
     else
         starting_line = 23; // default PAL
 
     size = snprintf(buffer, 1024, "Ver 1\nBr %.6f\nIpg 1\nPpi %d\nBpiop %d\n"
                     "Pix 0\nCf %d\nCg %d\nSl %d\nnl16 %d\nVi 1\nf1 1\n",
-                    (float)st->codec->bit_rate, sc->p_per_gop, sc->b_per_i_or_p,
-                    st->codec->pix_fmt == AV_PIX_FMT_YUV422P ? 2 : 1, sc->first_gop_closed == 1,
-                    starting_line, (st->codec->height + 15) / 16);
+                    (float)st->codecpar->bit_rate, sc->p_per_gop, sc->b_per_i_or_p,
+                    st->codecpar->format  == AV_PIX_FMT_YUV422P ? 2 : 1, sc->first_gop_closed == 1,
+                    starting_line, (st->codecpar->height + 15) / 16);
     avio_w8(pb, TRACK_MPG_AUX);
     avio_w8(pb, size + 1);
     avio_write(pb, (uint8_t *)buffer, size + 1);
@@ -472,7 +472,7 @@ static int gxf_write_umf_media_mpeg(AVIOContext *pb, AVStream *st)
 {
     GXFStreamContext *sc = st->priv_data;
 
-    if (st->codec->pix_fmt == AV_PIX_FMT_YUV422P)
+    if (st->codecpar->format == AV_PIX_FMT_YUV422P)
         avio_wl32(pb, 2);
     else
         avio_wl32(pb, 1); /* default to 420 */
@@ -481,9 +481,9 @@ static int gxf_write_umf_media_mpeg(AVIOContext *pb, AVStream *st)
     avio_wl32(pb, 1); /* I picture per GOP */
     avio_wl32(pb, sc->p_per_gop);
     avio_wl32(pb, sc->b_per_i_or_p);
-    if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO)
+    if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO)
         avio_wl32(pb, 2);
-    else if (st->codec->codec_id == AV_CODEC_ID_MPEG1VIDEO)
+    else if (st->codecpar->codec_id == AV_CODEC_ID_MPEG1VIDEO)
         avio_wl32(pb, 1);
     else
         avio_wl32(pb, 0);
@@ -565,7 +565,7 @@ static int gxf_write_umf_media_description(AVFormatContext *s)
             gxf_write_umf_media_timecode(pb, sc); /* 8 0bytes */
         else {
             AVStream *st = s->streams[i];
-            switch (st->codec->codec_id) {
+            switch (st->codecpar->codec_id) {
             case AV_CODEC_ID_MPEG1VIDEO:
             case AV_CODEC_ID_MPEG2VIDEO:
                 gxf_write_umf_media_mpeg(pb, st);
@@ -646,22 +646,22 @@ static int gxf_write_header(AVFormatContext *s)
             return AVERROR(ENOMEM);
         st->priv_data = sc;
 
-        sc->media_type = ff_codec_get_tag(gxf_media_types, st->codec->codec_id);
-        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
-            if (st->codec->codec_id != AV_CODEC_ID_PCM_S16LE) {
+        sc->media_type = ff_codec_get_tag(gxf_media_types, st->codecpar->codec_id);
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+            if (st->codecpar->codec_id != AV_CODEC_ID_PCM_S16LE) {
                 av_log(s, AV_LOG_ERROR, "only 16 BIT PCM LE allowed for now\n");
                 return -1;
             }
-            if (st->codec->sample_rate != 48000) {
+            if (st->codecpar->sample_rate != 48000) {
                 av_log(s, AV_LOG_ERROR, "only 48000hz sampling rate is allowed\n");
                 return -1;
             }
-            if (st->codec->channels != 1) {
+            if (st->codecpar->channels != 1) {
                 av_log(s, AV_LOG_ERROR, "only mono tracks are allowed\n");
                 return -1;
             }
             sc->track_type = 2;
-            sc->sample_rate = st->codec->sample_rate;
+            sc->sample_rate = st->codecpar->sample_rate;
             avpriv_set_pts_info(st, 64, 1, sc->sample_rate);
             sc->sample_size = 16;
             sc->frame_rate_index = -2;
@@ -670,18 +670,18 @@ static int gxf_write_header(AVFormatContext *s)
             gxf->audio_tracks++;
             gxf->flags |= 0x04000000; /* audio is 16 bit pcm */
             media_info = 'A';
-        } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+        } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
             if (i != 0) {
                 av_log(s, AV_LOG_ERROR, "video stream must be the first track\n");
                 return -1;
             }
             /* FIXME check from time_base ? */
-            if (st->codec->height == 480 || st->codec->height == 512) { /* NTSC or NTSC+VBI */
+            if (st->codecpar->height == 480 || st->codecpar->height == 512) { /* NTSC or NTSC+VBI */
                 sc->frame_rate_index = 5;
                 sc->sample_rate = 60;
                 gxf->flags |= 0x00000080;
                 gxf->time_base = (AVRational){ 1001, 60000 };
-            } else if (st->codec->height == 576 || st->codec->height == 608) { /* PAL or PAL+VBI */
+            } else if (st->codecpar->height == 576 || st->codecpar->height == 608) { /* PAL or PAL+VBI */
                 sc->frame_rate_index = 6;
                 sc->media_type++;
                 sc->sample_rate = 50;
@@ -695,12 +695,12 @@ static int gxf_write_header(AVFormatContext *s)
             avpriv_set_pts_info(st, 64, gxf->time_base.num, gxf->time_base.den);
             if (gxf_find_lines_index(st) < 0)
                 sc->lines_index = -1;
-            sc->sample_size = st->codec->bit_rate;
+            sc->sample_size = st->codecpar->bit_rate;
             sc->fields = 2; /* interlaced */
 
             vsc = sc;
 
-            switch (st->codec->codec_id) {
+            switch (st->codecpar->codec_id) {
             case AV_CODEC_ID_MJPEG:
                 sc->track_type = 1;
                 gxf->flags |= 0x00004000;
@@ -719,7 +719,7 @@ static int gxf_write_header(AVFormatContext *s)
                 media_info = 'M';
                 break;
             case AV_CODEC_ID_DVVIDEO:
-                if (st->codec->pix_fmt == AV_PIX_FMT_YUV422P) {
+                if (st->codecpar->format == AV_PIX_FMT_YUV422P) {
                     sc->media_type += 2;
                     sc->track_type = 6;
                     gxf->flags |= 0x00002000;
@@ -818,7 +818,7 @@ static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
     /* If the video is frame-encoded, the frame numbers shall be represented by
      * even field numbers.
      * see SMPTE360M-2004  6.4.2.1.3 Media field number */
-    if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+    if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
         field_nb = gxf->nb_fields;
     } else {
         field_nb = av_rescale_rnd(pkt->dts, gxf->time_base.den,
@@ -828,10 +828,10 @@ static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
     avio_w8(pb, sc->media_type);
     avio_w8(pb, st->index);
     avio_wb32(pb, field_nb);
-    if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+    if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
         avio_wb16(pb, 0);
         avio_wb16(pb, size / 2);
-    } else if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
+    } else if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
         int frame_type = gxf_parse_mpeg_frame(sc, pkt->data, pkt->size);
         if (frame_type == AV_PICTURE_TYPE_I) {
             avio_w8(pb, 0x0d);
@@ -844,7 +844,7 @@ static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
             sc->pframes++;
         }
         avio_wb24(pb, size);
-    } else if (st->codec->codec_id == AV_CODEC_ID_DVVIDEO) {
+    } else if (st->codecpar->codec_id == AV_CODEC_ID_DVVIDEO) {
         avio_w8(pb, size / 4096);
         avio_wb24(pb, 0);
     } else
@@ -865,15 +865,15 @@ static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)
     int packet_start_offset = avio_tell(pb) / 1024;
 
     gxf_write_packet_header(pb, PKT_MEDIA);
-    if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO && pkt->size % 4) /* MPEG-2 frames must be padded */
+    if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO && pkt->size % 4) /* MPEG-2 frames must be padded */
         padding = 4 - pkt->size % 4;
-    else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+    else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
         padding = GXF_AUDIO_PACKET_SIZE - pkt->size;
     gxf_write_media_preamble(s, pkt, pkt->size + padding);
     avio_write(pb, pkt->data, pkt->size);
     gxf_write_padding(pb, padding);
 
-    if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+    if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
         if (!(gxf->flt_entries_nb % 500)) {
             int err;
             if ((err = av_reallocp_array(&gxf->flt_entries,
@@ -909,7 +909,7 @@ static int gxf_compare_field_nb(AVFormatContext *s, AVPacket *next, AVPacket *cu
     for (i = 0; i < 2; i++) {
         AVStream *st = s->streams[pkt[i]->stream_index];
         sc[i] = st->priv_data;
-        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
             field_nb[i] = av_rescale_rnd(pkt[i]->dts, gxf->time_base.den,
                                          (int64_t)48000*gxf->time_base.num, AV_ROUND_UP);
             field_nb[i] &= ~1; // compare against even field number because audio must be before video
@@ -923,7 +923,7 @@ static int gxf_compare_field_nb(AVFormatContext *s, AVPacket *next, AVPacket *cu
 
 static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
 {
-    if (pkt && s->streams[pkt->stream_index]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+    if (pkt && s->streams[pkt->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
         pkt->duration = 2; // enforce 2 fields
     return ff_audio_rechunk_interleave(s, out, pkt, flush,
                                ff_interleave_packet_per_dts, gxf_compare_field_nb);
index a2710ded40e3896456321f595ad328c6d616f580..e32c36503e5cd2c80a61fc1131adc2e3e090c0ee 100644 (file)
@@ -338,18 +338,18 @@ static int hds_write_header(AVFormatContext *s)
         AVFormatContext *ctx;
         AVStream *st = s->streams[i];
 
-        if (!st->codec->bit_rate) {
+        if (!st->codecpar->bit_rate) {
             av_log(s, AV_LOG_ERROR, "No bit rate set for stream %d\n", i);
             ret = AVERROR(EINVAL);
             goto fail;
         }
-        if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
             if (os->has_video) {
                 c->nb_streams++;
                 os++;
             }
             os->has_video = 1;
-        } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+        } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
             if (os->has_audio) {
                 c->nb_streams++;
                 os++;
@@ -360,7 +360,7 @@ static int hds_write_header(AVFormatContext *s)
             ret = AVERROR(EINVAL);
             goto fail;
         }
-        os->bitrate += s->streams[i]->codec->bit_rate;
+        os->bitrate += s->streams[i]->codecpar->bit_rate;
 
         if (!os->ctx) {
             os->first_stream = i;
@@ -389,8 +389,8 @@ static int hds_write_header(AVFormatContext *s)
             ret = AVERROR(ENOMEM);
             goto fail;
         }
-        avcodec_copy_context(st->codec, s->streams[i]->codec);
-        st->codec->codec_tag = 0;
+        avcodec_parameters_copy(st->codecpar, s->streams[i]->codecpar);
+        st->codecpar->codec_tag = 0;
         st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
         st->time_base = s->streams[i]->time_base;
     }
@@ -517,7 +517,7 @@ static int hds_write_packet(AVFormatContext *s, AVPacket *pkt)
     if (st->first_dts == AV_NOPTS_VALUE)
         st->first_dts = pkt->dts;
 
-    if ((!os->has_video || st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&
+    if ((!os->has_video || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) &&
         av_compare_ts(pkt->dts - st->first_dts, st->time_base,
                       end_dts, AV_TIME_BASE_Q) >= 0 &&
         pkt->flags & AV_PKT_FLAG_KEY && os->packets_written) {
index daee8625afa8eaacae1fd2debd32c87dd54fbd21..8459f122695dc8cb26c2f418f9e52cdc007a8186 100644 (file)
@@ -617,7 +617,7 @@ static int hls_read_header(AVFormatContext *s)
             ff_program_add_stream_index(s, i, stream_offset + j);
             st->id = i;
             avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den);
-            avcodec_copy_context(st->codec, v->ctx->streams[j]->codec);
+            avcodec_parameters_copy(st->codecpar, v->ctx->streams[j]->codecpar);
             if (v->bandwidth)
                 av_dict_set(&st->metadata, "variant_bitrate", bitrate_str,
                                  0);
index 843f37d82c8732b065a905b1a82489880e13ce46..96b780fe37776a5021a70ded1841b85af29d7d0a 100644 (file)
@@ -82,7 +82,7 @@ static int hls_mux_init(AVFormatContext *s)
         AVStream *st;
         if (!(st = avformat_new_stream(oc, NULL)))
             return AVERROR(ENOMEM);
-        avcodec_copy_context(st->codec, s->streams[i]->codec);
+        avcodec_parameters_copy(st->codecpar, s->streams[i]->codecpar);
         st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
         st->time_base = s->streams[i]->time_base;
     }
@@ -220,7 +220,7 @@ static int hls_write_header(AVFormatContext *s)
 
     for (i = 0; i < s->nb_streams; i++)
         hls->has_video +=
-            s->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO;
+            s->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO;
 
     if (hls->has_video > 1)
         av_log(s, AV_LOG_WARNING,
@@ -284,7 +284,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
     }
 
     if (hls->has_video) {
-        can_split = st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
+        can_split = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
                     pkt->flags & AV_PKT_FLAG_KEY;
     }
     if (pkt->pts == AV_NOPTS_VALUE)
index 31fc42e05d2268a10648dc58eb109b2d0a4b6439..8476e51aa6b3baa4f74d4bf3b6d6e089a7c20417 100644 (file)
@@ -108,15 +108,15 @@ static int hnm_read_header(AVFormatContext *s)
     if (!(vst = avformat_new_stream(s, NULL)))
         return AVERROR(ENOMEM);
 
-    vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    vst->codec->codec_id   = AV_CODEC_ID_HNM4_VIDEO;
-    vst->codec->codec_tag  = 0;
-    vst->codec->width      = hnm->width;
-    vst->codec->height     = hnm->height;
-    vst->codec->extradata  = av_mallocz(1);
-
-    vst->codec->extradata_size = 1;
-    memcpy(vst->codec->extradata, &hnm->version, 1);
+    vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    vst->codecpar->codec_id   = AV_CODEC_ID_HNM4_VIDEO;
+    vst->codecpar->codec_tag  = 0;
+    vst->codecpar->width      = hnm->width;
+    vst->codecpar->height     = hnm->height;
+    vst->codecpar->extradata  = av_mallocz(1);
+
+    vst->codecpar->extradata_size = 1;
+    memcpy(vst->codecpar->extradata, &hnm->version, 1);
 
     vst->start_time = 0;
 
index d63d5a11717dbf2003181ec80f1cd57b53c2fd01..5e9825de7d182b0faace282160552d1da2bb0c12 100644 (file)
@@ -761,8 +761,8 @@ int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta **extra_meta)
             return AVERROR(ENOMEM);
 
         st->disposition      |= AV_DISPOSITION_ATTACHED_PIC;
-        st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-        st->codec->codec_id   = apic->id;
+        st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+        st->codecpar->codec_id   = apic->id;
 
         if (apic->description[0])
             av_dict_set(&st->metadata, "title", apic->description, 0);
index 89181c26a00c063822ff43996b0f22824fa908a1..827431aee312fe69c29c51a785f35a45fb7071aa 100644 (file)
@@ -171,7 +171,7 @@ int ff_id3v2_write_apic(AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt)
 
     /* get the mimetype*/
     while (mime->id != AV_CODEC_ID_NONE) {
-        if (mime->id == st->codec->codec_id) {
+        if (mime->id == st->codecpar->codec_id) {
             mimetype = mime->str;
             break;
         }
index 32cba3adbafe6b63a1ac7110b75614d11b6cf673..b7b85c99cf4b36a3138ef7c981839b178309483f 100644 (file)
@@ -189,16 +189,16 @@ static int idcin_read_header(AVFormatContext *s)
     avpriv_set_pts_info(st, 33, 1, IDCIN_FPS);
     st->start_time = 0;
     idcin->video_stream_index = st->index;
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id = AV_CODEC_ID_IDCIN;
-    st->codec->codec_tag = 0;  /* no fourcc */
-    st->codec->width = width;
-    st->codec->height = height;
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id = AV_CODEC_ID_IDCIN;
+    st->codecpar->codec_tag = 0;  /* no fourcc */
+    st->codecpar->width = width;
+    st->codecpar->height = height;
 
     /* load up the Huffman tables into extradata */
-    st->codec->extradata_size = HUFFMAN_TABLE_SIZE;
-    st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
-    ret = avio_read(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE);
+    st->codecpar->extradata_size = HUFFMAN_TABLE_SIZE;
+    st->codecpar->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
+    ret = avio_read(pb, st->codecpar->extradata, HUFFMAN_TABLE_SIZE);
     if (ret < 0) {
         return ret;
     } else if (ret != HUFFMAN_TABLE_SIZE) {
@@ -214,19 +214,19 @@ static int idcin_read_header(AVFormatContext *s)
         avpriv_set_pts_info(st, 63, 1, sample_rate);
         st->start_time = 0;
         idcin->audio_stream_index = st->index;
-        st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-        st->codec->codec_tag = 1;
-        st->codec->channels = channels;
-        st->codec->channel_layout = channels > 1 ? AV_CH_LAYOUT_STEREO :
-                                                   AV_CH_LAYOUT_MONO;
-        st->codec->sample_rate = sample_rate;
-        st->codec->bits_per_coded_sample = bytes_per_sample * 8;
-        st->codec->bit_rate = sample_rate * bytes_per_sample * 8 * channels;
-        st->codec->block_align = idcin->block_align = bytes_per_sample * channels;
+        st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+        st->codecpar->codec_tag = 1;
+        st->codecpar->channels = channels;
+        st->codecpar->channel_layout = channels > 1 ? AV_CH_LAYOUT_STEREO :
+                                                      AV_CH_LAYOUT_MONO;
+        st->codecpar->sample_rate = sample_rate;
+        st->codecpar->bits_per_coded_sample = bytes_per_sample * 8;
+        st->codecpar->bit_rate = sample_rate * bytes_per_sample * 8 * channels;
+        st->codecpar->block_align = idcin->block_align = bytes_per_sample * channels;
         if (bytes_per_sample == 1)
-            st->codec->codec_id = AV_CODEC_ID_PCM_U8;
+            st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
         else
-            st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
+            st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
 
         if (sample_rate % 14 != 0) {
             idcin->audio_chunk_size1 = (sample_rate / 14) *
index 82eff24e945fcb48807c16fcd7e93c2b7b43cf9a..62d81f66584003d8fc95f51f403edc217d243ef0 100644 (file)
@@ -127,14 +127,14 @@ static int roq_read_packet(AVFormatContext *s,
                     return AVERROR(ENOMEM);
                 avpriv_set_pts_info(st, 63, 1, roq->frame_rate);
                 roq->video_stream_index = st->index;
-                st->codec->codec_type   = AVMEDIA_TYPE_VIDEO;
-                st->codec->codec_id     = AV_CODEC_ID_ROQ;
-                st->codec->codec_tag    = 0;  /* no fourcc */
+                st->codecpar->codec_type   = AVMEDIA_TYPE_VIDEO;
+                st->codecpar->codec_id     = AV_CODEC_ID_ROQ;
+                st->codecpar->codec_tag    = 0;  /* no fourcc */
 
                 if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != RoQ_CHUNK_PREAMBLE_SIZE)
                     return AVERROR(EIO);
-                st->codec->width  = roq->width  = AV_RL16(preamble);
-                st->codec->height = roq->height = AV_RL16(preamble + 2);
+                st->codecpar->width  = roq->width  = AV_RL16(preamble);
+                st->codecpar->height = roq->height = AV_RL16(preamble + 2);
                 break;
             }
             /* don't care about this chunk anymore */
@@ -175,22 +175,22 @@ static int roq_read_packet(AVFormatContext *s,
                     return AVERROR(ENOMEM);
                 avpriv_set_pts_info(st, 32, 1, RoQ_AUDIO_SAMPLE_RATE);
                 roq->audio_stream_index = st->index;
-                st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-                st->codec->codec_id = AV_CODEC_ID_ROQ_DPCM;
-                st->codec->codec_tag = 0;  /* no tag */
+                st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+                st->codecpar->codec_id = AV_CODEC_ID_ROQ_DPCM;
+                st->codecpar->codec_tag = 0;  /* no tag */
                 if (chunk_type == RoQ_SOUND_STEREO) {
-                    st->codec->channels       = 2;
-                    st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
+                    st->codecpar->channels       = 2;
+                    st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
                 } else {
-                    st->codec->channels       = 1;
-                    st->codec->channel_layout = AV_CH_LAYOUT_MONO;
+                    st->codecpar->channels       = 1;
+                    st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
                 }
-                roq->audio_channels    = st->codec->channels;
-                st->codec->sample_rate = RoQ_AUDIO_SAMPLE_RATE;
-                st->codec->bits_per_coded_sample = 16;
-                st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
-                    st->codec->bits_per_coded_sample;
-                st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample;
+                roq->audio_channels    = st->codecpar->channels;
+                st->codecpar->sample_rate = RoQ_AUDIO_SAMPLE_RATE;
+                st->codecpar->bits_per_coded_sample = 16;
+                st->codecpar->bit_rate = st->codecpar->channels * st->codecpar->sample_rate *
+                    st->codecpar->bits_per_coded_sample;
+                st->codecpar->block_align = st->codecpar->channels * st->codecpar->bits_per_coded_sample;
             }
         case RoQ_QUAD_VQ:
             if (chunk_type == RoQ_QUAD_VQ) {
index bf092152bd6003fec69142e9bb2a64d4088eb243..d81a1ff56161681ae8fb5556a4bb80e05db3703a 100644 (file)
@@ -122,11 +122,11 @@ static int iff_read_header(AVFormatContext *s)
     if (!st)
         return AVERROR(ENOMEM);
 
-    st->codec->channels = 1;
-    st->codec->channel_layout = AV_CH_LAYOUT_MONO;
+    st->codecpar->channels = 1;
+    st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
     avio_skip(pb, 8);
     // codec_tag used by ByteRun1 decoder to distinguish progressive (PBM) and interlaced (ILBM) content
-    st->codec->codec_tag = avio_rl32(pb);
+    st->codecpar->codec_tag = avio_rl32(pb);
 
     while(!pb->eof_reached) {
         uint64_t orig_pos;
@@ -138,12 +138,12 @@ static int iff_read_header(AVFormatContext *s)
 
         switch(chunk_id) {
         case ID_VHDR:
-            st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+            st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
 
             if (data_size < 14)
                 return AVERROR_INVALIDDATA;
             avio_skip(pb, 12);
-            st->codec->sample_rate = avio_rb16(pb);
+            st->codecpar->sample_rate = avio_rb16(pb);
             if (data_size >= 16) {
                 avio_skip(pb, 1);
                 compression        = avio_r8(pb);
@@ -159,11 +159,11 @@ static int iff_read_header(AVFormatContext *s)
             if (data_size < 4)
                 return AVERROR_INVALIDDATA;
             if (avio_rb32(pb) < 6) {
-                st->codec->channels       = 1;
-                st->codec->channel_layout = AV_CH_LAYOUT_MONO;
+                st->codecpar->channels       = 1;
+                st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
             } else {
-                st->codec->channels       = 2;
-                st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
+                st->codecpar->channels       = 2;
+                st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
             }
             break;
 
@@ -173,22 +173,22 @@ static int iff_read_header(AVFormatContext *s)
                         data_size);
                  return AVERROR_INVALIDDATA;
             }
-            st->codec->extradata_size = data_size;
-            st->codec->extradata      = av_malloc(data_size);
-            if (!st->codec->extradata)
+    &