summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-10 20:58:15 +0100
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-10 20:59:55 +0100
commit6f69f7a8bf6a0d013985578df2ef42ee6b1c7994 (patch)
tree0c2ec8349ff1763d5f48454b8b9f26374dbd80b0
parent60b75186b2c878b6257b43c8fcc0b1356ada218e (diff)
parent9200514ad8717c63f82101dc394f4378854325bf (diff)
Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf': lavf: replace AVStream.codec with AVStream.codecpar This has been a HUGE effort from: - Derek Buitenhuis <derek.buitenhuis@gmail.com> - Hendrik Leppkes <h.leppkes@gmail.com> - wm4 <nfxjfg@googlemail.com> - Clément Bœsch <clement@stupeflix.com> - James Almer <jamrial@gmail.com> - Michael Niedermayer <michael@niedermayer.cc> - Rostislav Pehlivanov <atomnuker@gmail.com> Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
-rw-r--r--ffmpeg.c9
-rw-r--r--ffserver.c4
-rw-r--r--libavdevice/alsa.c2
-rw-r--r--libavdevice/alsa_dec.c10
-rw-r--r--libavdevice/alsa_enc.c14
-rw-r--r--libavdevice/bktr.c14
-rw-r--r--libavdevice/dshow.c49
-rw-r--r--libavdevice/fbdev_dec.c16
-rw-r--r--libavdevice/fbdev_enc.c12
-rw-r--r--libavdevice/gdigrab.c9
-rw-r--r--libavdevice/jack.c10
-rw-r--r--libavdevice/lavfi.c32
-rw-r--r--libavdevice/libcdio.c12
-rw-r--r--libavdevice/libdc1394.c15
-rw-r--r--libavdevice/openal-dec.c12
-rw-r--r--libavdevice/opengl_enc.c16
-rw-r--r--libavdevice/oss_dec.c8
-rw-r--r--libavdevice/oss_enc.c4
-rw-r--r--libavdevice/pulse_audio_dec.c8
-rw-r--r--libavdevice/pulse_audio_enc.c25
-rw-r--r--libavdevice/sdl.c32
-rw-r--r--libavdevice/sndio_dec.c8
-rw-r--r--libavdevice/sndio_enc.c4
-rw-r--r--libavdevice/v4l2.c22
-rw-r--r--libavdevice/v4l2enc.c18
-rw-r--r--libavdevice/vfwcap.c35
-rw-r--r--libavdevice/x11grab.c17
-rw-r--r--libavdevice/xcbgrab.c11
-rw-r--r--libavdevice/xv.c38
-rw-r--r--libavformat/3dostr.c20
-rw-r--r--libavformat/4xm.c44
-rw-r--r--libavformat/a64.c10
-rw-r--r--libavformat/aacdec.c6
-rw-r--r--libavformat/aadec.c22
-rw-r--r--libavformat/acm.c20
-rw-r--r--libavformat/act.c22
-rw-r--r--libavformat/adp.c14
-rw-r--r--libavformat/ads.c28
-rw-r--r--libavformat/adtsenc.c8
-rw-r--r--libavformat/adxdec.c30
-rw-r--r--libavformat/aea.c20
-rw-r--r--libavformat/afc.c16
-rw-r--r--libavformat/aiffdec.c90
-rw-r--r--libavformat/aiffenc.c50
-rw-r--r--libavformat/aixdec.c12
-rw-r--r--libavformat/amr.c36
-rw-r--r--libavformat/anm.c18
-rw-r--r--libavformat/apc.c24
-rw-r--r--libavformat/ape.c20
-rw-r--r--libavformat/apetag.c8
-rw-r--r--libavformat/apngdec.c66
-rw-r--r--libavformat/apngenc.c18
-rw-r--r--libavformat/aqtitledec.c4
-rw-r--r--libavformat/asfdec_f.c72
-rw-r--r--libavformat/asfdec_o.c30
-rw-r--r--libavformat/asfenc.c82
-rw-r--r--libavformat/assdec.c6
-rw-r--r--libavformat/assenc.c22
-rw-r--r--libavformat/astdec.c26
-rw-r--r--libavformat/astenc.c22
-rw-r--r--libavformat/au.c30
-rw-r--r--libavformat/audiointerleave.c12
-rw-r--r--libavformat/avformat.h24
-rw-r--r--libavformat/avidec.c179
-rw-r--r--libavformat/avienc.c160
-rw-r--r--libavformat/avisynth.c60
-rw-r--r--libavformat/avr.c18
-rw-r--r--libavformat/avs.c12
-rw-r--r--libavformat/bethsoftvid.c24
-rw-r--r--libavformat/bfi.c42
-rw-r--r--libavformat/bink.c40
-rw-r--r--libavformat/bintext.c86
-rw-r--r--libavformat/bit.c18
-rw-r--r--libavformat/bmv.c20
-rw-r--r--libavformat/boadec.c12
-rw-r--r--libavformat/brstm.c60
-rw-r--r--libavformat/c93.c10
-rw-r--r--libavformat/cafdec.c64
-rw-r--r--libavformat/cafenc.c50
-rw-r--r--libavformat/cdg.c4
-rw-r--r--libavformat/cdxl.c26
-rw-r--r--libavformat/chromaprint.c6
-rw-r--r--libavformat/cinedec.c34
-rw-r--r--libavformat/concatdec.c70
-rw-r--r--libavformat/dashenc.c62
-rw-r--r--libavformat/dauddec.c18
-rw-r--r--libavformat/daudenc.c4
-rw-r--r--libavformat/dcstr.c22
-rw-r--r--libavformat/dfa.c12
-rw-r--r--libavformat/dsfdec.c22
-rw-r--r--libavformat/dsicin.c26
-rw-r--r--libavformat/dss.c20
-rw-r--r--libavformat/dtshddec.c6
-rw-r--r--libavformat/dump.c47
-rw-r--r--libavformat/dv.c28
-rw-r--r--libavformat/dvenc.c47
-rw-r--r--libavformat/dxa.c20
-rw-r--r--libavformat/eacdata.c12
-rw-r--r--libavformat/electronicarts.c34
-rw-r--r--libavformat/epafdec.c16
-rw-r--r--libavformat/ffmdec.c19
-rw-r--r--libavformat/ffmetadec.c4
-rw-r--r--libavformat/filmstripdec.c22
-rw-r--r--libavformat/filmstripenc.c6
-rw-r--r--libavformat/flac_picture.c8
-rw-r--r--libavformat/flacdec.c18
-rw-r--r--libavformat/flacenc.c18
-rw-r--r--libavformat/flic.c48
-rw-r--r--libavformat/flvdec.c278
-rw-r--r--libavformat/flvenc.c190
-rw-r--r--libavformat/framecrcenc.c8
-rw-r--r--libavformat/frmdec.c20
-rw-r--r--libavformat/fsb.c94
-rw-r--r--libavformat/g722.c16
-rw-r--r--libavformat/g723_1.c12
-rw-r--r--libavformat/g729dec.c18
-rw-r--r--libavformat/genh.c84
-rw-r--r--libavformat/gif.c28
-rw-r--r--libavformat/gifdec.c8
-rw-r--r--libavformat/gsmdec.c12
-rw-r--r--libavformat/gxf.c82
-rw-r--r--libavformat/gxfenc.c66
-rw-r--r--libavformat/hdsenc.c14
-rw-r--r--libavformat/hls.c4
-rw-r--r--libavformat/hlsenc.c18
-rw-r--r--libavformat/hnm.c18
-rw-r--r--libavformat/icodec.c26
-rw-r--r--libavformat/icoenc.c46
-rw-r--r--libavformat/id3v2.c6
-rw-r--r--libavformat/id3v2enc.c2
-rw-r--r--libavformat/idcin.c34
-rw-r--r--libavformat/idroqdec.c36
-rw-r--r--libavformat/idroqenc.c13
-rw-r--r--libavformat/iff.c160
-rw-r--r--libavformat/ilbc.c36
-rw-r--r--libavformat/img2dec.c46
-rw-r--r--libavformat/img2enc.c16
-rw-r--r--libavformat/internal.h22
-rw-r--r--libavformat/ipmovie.c36
-rw-r--r--libavformat/ircamdec.c16
-rw-r--r--libavformat/ircamenc.c8
-rw-r--r--libavformat/isom.c38
-rw-r--r--libavformat/iss.c30
-rw-r--r--libavformat/iv8.c4
-rw-r--r--libavformat/ivfdec.c10
-rw-r--r--libavformat/ivfenc.c16
-rw-r--r--libavformat/jacosubdec.c6
-rw-r--r--libavformat/jacosubenc.c6
-rw-r--r--libavformat/jvdec.c24
-rw-r--r--libavformat/latmenc.c24
-rw-r--r--libavformat/libgme.c8
-rw-r--r--libavformat/libmodplug.c16
-rw-r--r--libavformat/libnut.c60
-rw-r--r--libavformat/lmlm4.c8
-rw-r--r--libavformat/loasdec.c4
-rw-r--r--libavformat/lrcdec.c4
-rw-r--r--libavformat/lrcenc.c8
-rw-r--r--libavformat/lvfdec.c26
-rw-r--r--libavformat/lxfdec.c34
-rw-r--r--libavformat/matroskadec.c141
-rw-r--r--libavformat/matroskaenc.c302
-rw-r--r--libavformat/mgsts.c12
-rw-r--r--libavformat/microdvddec.c12
-rw-r--r--libavformat/microdvdenc.c12
-rw-r--r--libavformat/mlvdec.c50
-rw-r--r--libavformat/mm.c22
-rw-r--r--libavformat/mmf.c28
-rw-r--r--libavformat/mov.c488
-rw-r--r--libavformat/mov_chan.c4
-rw-r--r--libavformat/movenc-test.c36
-rw-r--r--libavformat/movenc.c866
-rw-r--r--libavformat/movenc.h2
-rw-r--r--libavformat/movenchint.c12
-rw-r--r--libavformat/mp3dec.c6
-rw-r--r--libavformat/mp3enc.c22
-rw-r--r--libavformat/mpc.c16
-rw-r--r--libavformat/mpc8.c16
-rw-r--r--libavformat/mpeg.c24
-rw-r--r--libavformat/mpegenc.c36
-rw-r--r--libavformat/mpegts.c170
-rw-r--r--libavformat/mpegtsenc.c153
-rw-r--r--libavformat/mpjpegdec.c4
-rw-r--r--libavformat/mpl2dec.c4
-rw-r--r--libavformat/mpsubdec.c4
-rw-r--r--libavformat/msf.c30
-rw-r--r--libavformat/msnwc_tcp.c10
-rw-r--r--libavformat/mtv.c22
-rw-r--r--libavformat/musx.c92
-rw-r--r--libavformat/mux.c147
-rw-r--r--libavformat/mvdec.c74
-rw-r--r--libavformat/mvi.c34
-rw-r--r--libavformat/mxfdec.c134
-rw-r--r--libavformat/mxfenc.c130
-rw-r--r--libavformat/mxg.c18
-rw-r--r--libavformat/ncdec.c4
-rw-r--r--libavformat/nistspheredec.c32
-rw-r--r--libavformat/nsvdec.c26
-rw-r--r--libavformat/nutdec.c46
-rw-r--r--libavformat/nutenc.c86
-rw-r--r--libavformat/nuv.c66
-rw-r--r--libavformat/oggdec.c4
-rw-r--r--libavformat/oggenc.c80
-rw-r--r--libavformat/oggparsecelt.c14
-rw-r--r--libavformat/oggparsedaala.c24
-rw-r--r--libavformat/oggparsedirac.c30
-rw-r--r--libavformat/oggparseflac.c33
-rw-r--r--libavformat/oggparseogm.c56
-rw-r--r--libavformat/oggparseopus.c20
-rw-r--r--libavformat/oggparseskeleton.c2
-rw-r--r--libavformat/oggparsespeex.c20
-rw-r--r--libavformat/oggparsetheora.c28
-rw-r--r--libavformat/oggparsevorbis.c24
-rw-r--r--libavformat/oggparsevp8.c8
-rw-r--r--libavformat/omadec.c50
-rw-r--r--libavformat/omaenc.c28
-rw-r--r--libavformat/paf.c22
-rw-r--r--libavformat/pcm.c10
-rw-r--r--libavformat/pcmdec.c20
-rw-r--r--libavformat/pjsdec.c4
-rw-r--r--libavformat/pmpdec.c20
-rw-r--r--libavformat/psxstr.c34
-rw-r--r--libavformat/pva.c8
-rw-r--r--libavformat/pvfdec.c14
-rw-r--r--libavformat/qcp.c18
-rw-r--r--libavformat/r3d.c26
-rw-r--r--libavformat/rawdec.c16
-rw-r--r--libavformat/rawenc.c4
-rw-r--r--libavformat/rawutils.c20
-rw-r--r--libavformat/rawvideodec.c14
-rw-r--r--libavformat/rdt.c8
-rw-r--r--libavformat/realtextdec.c10
-rw-r--r--libavformat/redspark.c34
-rw-r--r--libavformat/riff.h6
-rw-r--r--libavformat/riffdec.c94
-rw-r--r--libavformat/riffenc.c174
-rw-r--r--libavformat/rl2.c36
-rw-r--r--libavformat/rmdec.c118
-rw-r--r--libavformat/rmenc.c50
-rw-r--r--libavformat/rpl.c72
-rw-r--r--libavformat/rsd.c90
-rw-r--r--libavformat/rsodec.c14
-rw-r--r--libavformat/rsoenc.c14
-rw-r--r--libavformat/rtp.c28
-rw-r--r--libavformat/rtp.h8
-rw-r--r--libavformat/rtpdec.c6
-rw-r--r--libavformat/rtpdec_amr.c8
-rw-r--r--libavformat/rtpdec_asf.c6
-rw-r--r--libavformat/rtpdec_formats.h2
-rw-r--r--libavformat/rtpdec_g726.c6
-rw-r--r--libavformat/rtpdec_h264.c20
-rw-r--r--libavformat/rtpdec_hevc.c30
-rw-r--r--libavformat/rtpdec_ilbc.c6
-rw-r--r--libavformat/rtpdec_latm.c8
-rw-r--r--libavformat/rtpdec_mpeg12.c2
-rw-r--r--libavformat/rtpdec_mpeg4.c14
-rw-r--r--libavformat/rtpdec_qdm2.c24
-rw-r--r--libavformat/rtpdec_qt.c4
-rw-r--r--libavformat/rtpdec_svq3.c14
-rw-r--r--libavformat/rtpdec_xiph.c35
-rw-r--r--libavformat/rtpenc.c44
-rw-r--r--libavformat/rtpenc_aac.c2
-rw-r--r--libavformat/rtpenc_chain.c4
-rw-r--r--libavformat/rtpenc_h264_hevc.c4
-rw-r--r--libavformat/rtpenc_jpeg.c16
-rw-r--r--libavformat/rtpenc_latm.c2
-rw-r--r--libavformat/rtpenc_mpegts.c4
-rw-r--r--libavformat/rtsp.c68
-rw-r--r--libavformat/samidec.c6
-rw-r--r--libavformat/sapdec.c4
-rw-r--r--libavformat/sauce.c8
-rw-r--r--libavformat/sbgdec.c26
-rw-r--r--libavformat/sdp.c181
-rw-r--r--libavformat/sdr2.c16
-rw-r--r--libavformat/segafilm.c38
-rw-r--r--libavformat/segment.c22
-rw-r--r--libavformat/sierravmd.c54
-rw-r--r--libavformat/siff.c28
-rw-r--r--libavformat/smacker.c58
-rw-r--r--libavformat/smjpegdec.c28
-rw-r--r--libavformat/smjpegenc.c26
-rw-r--r--libavformat/smoothstreamingenc.c42
-rw-r--r--libavformat/smush.c28
-rw-r--r--libavformat/sol.c14
-rw-r--r--libavformat/soxdec.c28
-rw-r--r--libavformat/soxenc.c18
-rw-r--r--libavformat/spdifdec.c10
-rw-r--r--libavformat/spdifenc.c2
-rw-r--r--libavformat/srtdec.c4
-rw-r--r--libavformat/srtenc.c8
-rw-r--r--libavformat/stldec.c4
-rw-r--r--libavformat/subviewer1dec.c4
-rw-r--r--libavformat/subviewerdec.c8
-rw-r--r--libavformat/supdec.c4
-rw-r--r--libavformat/svag.c24
-rw-r--r--libavformat/swf.h2
-rw-r--r--libavformat/swfdec.c58
-rw-r--r--libavformat/swfenc.c94
-rw-r--r--libavformat/takdec.c20
-rw-r--r--libavformat/tedcaptionsdec.c4
-rw-r--r--libavformat/tee.c6
-rw-r--r--libavformat/thp.c23
-rw-r--r--libavformat/tiertexseq.c28
-rw-r--r--libavformat/tmv.c40
-rw-r--r--libavformat/tta.c14
-rw-r--r--libavformat/tty.c10
-rw-r--r--libavformat/txd.c4
-rw-r--r--libavformat/uncodedframecrcenc.c2
-rw-r--r--libavformat/utils.c615
-rw-r--r--libavformat/v210.c16
-rw-r--r--libavformat/vag.c24
-rw-r--r--libavformat/vc1test.c10
-rw-r--r--libavformat/vc1testenc.c10
-rw-r--r--libavformat/version.h3
-rw-r--r--libavformat/vivo.c30
-rw-r--r--libavformat/voc_packet.c36
-rw-r--r--libavformat/vocdec.c25
-rw-r--r--libavformat/vocenc.c30
-rw-r--r--libavformat/vpk.c30
-rw-r--r--libavformat/vplayerdec.c4
-rw-r--r--libavformat/vqf.c42
-rw-r--r--libavformat/wavdec.c82
-rw-r--r--libavformat/wavenc.c52
-rw-r--r--libavformat/wc3movie.c30
-rw-r--r--libavformat/webm_chunk.c6
-rw-r--r--libavformat/webmdashenc.c62
-rw-r--r--libavformat/webpenc.c10
-rw-r--r--libavformat/webvttdec.c4
-rw-r--r--libavformat/webvttenc.c4
-rw-r--r--libavformat/westwood_aud.c22
-rw-r--r--libavformat/westwood_vqa.c36
-rw-r--r--libavformat/wtvdec.c54
-rw-r--r--libavformat/wtvenc.c58
-rw-r--r--libavformat/wvdec.c12
-rw-r--r--libavformat/wvedec.c14
-rw-r--r--libavformat/wvenc.c2
-rw-r--r--libavformat/xa.c18
-rw-r--r--libavformat/xmv.c105
-rw-r--r--libavformat/xvag.c28
-rw-r--r--libavformat/xwma.c58
-rw-r--r--libavformat/yop.c40
-rw-r--r--libavformat/yuv4mpegdec.c16
-rw-r--r--libavformat/yuv4mpegenc.c39
-rw-r--r--tests/api/api-band-test.c9
-rw-r--r--tests/api/api-h264-test.c9
-rw-r--r--tests/api/api-seek-test.c9
-rw-r--r--tests/fate/vpx.mak4
-rw-r--r--tests/ref/fate/concat-demuxer-extended-lavf-mxf2
-rw-r--r--tests/ref/fate/concat-demuxer-extended-lavf-mxf_d102
-rw-r--r--tests/ref/fate/concat-demuxer-simple1-lavf-mxf2
-rw-r--r--tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d102
-rw-r--r--tests/ref/fate/concat-demuxer-simple2-lavf-ts2
-rw-r--r--tests/ref/fate/ffprobe_compact4
-rw-r--r--tests/ref/fate/ffprobe_csv4
-rw-r--r--tests/ref/fate/ffprobe_default4
-rw-r--r--tests/ref/fate/ffprobe_flat4
-rw-r--r--tests/ref/fate/ffprobe_ini4
-rw-r--r--tests/ref/fate/ffprobe_json4
-rw-r--r--tests/ref/fate/ffprobe_xml4
-rw-r--r--tests/ref/fate/movenc38
-rw-r--r--tests/ref/fate/xmv-demux28
-rw-r--r--tests/ref/lavf/ffm2
-rw-r--r--tests/ref/seek/lavf-voc12
362 files changed, 6555 insertions, 6079 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 9a14294768..adc3ff7800 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -696,6 +696,15 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
}
if (pkt->size == 0 && pkt->side_data_elems == 0)
return;
+ if (!ost->st->codecpar->extradata && avctx->extradata) {
+ ost->st->codecpar->extradata = av_malloc(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+ if (!ost->st->codecpar->extradata) {
+ av_log(NULL, AV_LOG_ERROR, "Could not allocate extradata buffer to copy parser data.\n");
+ exit_program(1);
+ }
+ ost->st->codecpar->extradata_size = avctx->extradata_size;
+ memcpy(ost->st->codecpar->extradata, avctx->extradata, avctx->extradata_size);
+ }
if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
if (pkt->dts != AV_NOPTS_VALUE &&
diff --git a/ffserver.c b/ffserver.c
index 5821870d2c..b5bd8f833b 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -2996,6 +2996,8 @@ static int prepare_sdp_description(FFServerStream *stream, uint8_t **pbuffer,
for(i = 0; i < stream->nb_streams; i++) {
avc->streams[i] = &avs[i];
avc->streams[i]->codec = stream->streams[i]->codec;
+ avcodec_parameters_from_context(stream->streams[i]->codecpar, stream->streams[i]->codec);
+ avc->streams[i]->codecpar = stream->streams[i]->codecpar;
}
*pbuffer = av_mallocz(2048);
if (!*pbuffer)
@@ -3536,6 +3538,8 @@ static AVStream *add_av_stream1(FFServerStream *stream,
fst->priv_data = av_mallocz(sizeof(FeedData));
fst->internal = av_mallocz(sizeof(*fst->internal));
+ fst->internal->avctx = avcodec_alloc_context3(NULL);
+ fst->codecpar = avcodec_parameters_alloc();
fst->index = stream->nb_streams;
avpriv_set_pts_info(fst, 33, 1, 90000);
fst->sample_aspect_ratio = codec->sample_aspect_ratio;
diff --git a/libavdevice/alsa.c b/libavdevice/alsa.c
index 75ac444993..8d27913a1a 100644
--- a/libavdevice/alsa.c
+++ b/libavdevice/alsa.c
@@ -175,7 +175,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;
diff --git a/libavdevice/alsa_dec.c b/libavdevice/alsa_dec.c
index 71a6ef4f4e..c50ce71506 100644
--- a/libavdevice/alsa_dec.c
+++ b/libavdevice/alsa_dec.c
@@ -79,11 +79,11 @@ 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->codec->frame_size = s->frame_size;
+ 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;
+ st->codecpar->frame_size = s->frame_size;
avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
/* microseconds instead of seconds, MHz instead of Hz */
s->timefilter = ff_timefilter_new(1000000.0 / s->sample_rate,
diff --git a/libavdevice/alsa_enc.c b/libavdevice/alsa_enc.c
index 10289a91a3..bddc61f4aa 100644
--- a/libavdevice/alsa_enc.c
+++ b/libavdevice/alsa_enc.c
@@ -55,20 +55,20 @@ static av_cold int audio_write_header(AVFormatContext *s1)
enum AVCodecID codec_id;
int res;
- if (s1->nb_streams != 1 || s1->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO) {
+ if (s1->nb_streams != 1 || s1->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) {
av_log(s1, AV_LOG_ERROR, "Only a single audio stream is supported.\n");
return AVERROR(EINVAL);
}
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;
}
avpriv_set_pts_info(st, 64, 1, sample_rate);
@@ -124,7 +124,7 @@ static int audio_write_frame(AVFormatContext *s1, int stream_index,
/* ff_alsa_open() should have accepted only supported formats */
if ((flags & AV_WRITE_UNCODED_FRAME_QUERY))
- return av_sample_fmt_is_planar(s1->streams[stream_index]->codec->sample_fmt) ?
+ return av_sample_fmt_is_planar(s1->streams[stream_index]->codecpar->format) ?
AVERROR(EINVAL) : 0;
/* set only used fields */
pkt.data = (*frame)->data[0];
diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c
index c8a8953267..2902425b4d 100644
--- a/libavdevice/bktr.c
+++ b/libavdevice/bktr.c
@@ -286,14 +286,12 @@ static int grab_read_header(AVFormatContext *s1)
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 = s->width;
- st->codec->height = s->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 = s->width;
+ st->codecpar->height = s->height;
+ st->avg_frame_rate = framerate;
if (bktr_init(s1->filename, s->width, s->height, s->standard,
&s->video_fd, &s->tuner_fd, -1, 0.0) < 0) {
diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index f56c165539..678861da4b 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -918,7 +918,7 @@ dshow_add_device(AVFormatContext *avctx,
{
struct dshow_ctx *ctx = avctx->priv_data;
AM_MEDIA_TYPE type;
- AVCodecContext *codec;
+ AVCodecParameters *par;
AVStream *st;
int ret = AVERROR(EIO);
@@ -933,7 +933,7 @@ dshow_add_device(AVFormatContext *avctx,
libAVPin_ConnectionMediaType(ctx->capture_pin[devtype], &type);
- codec = st->codec;
+ par = st->codecpar;
if (devtype == VideoDevice) {
BITMAPINFOHEADER *bih = NULL;
AVRational time_base;
@@ -952,33 +952,34 @@ dshow_add_device(AVFormatContext *avctx,
goto error;
}
- codec->time_base = time_base;
- codec->codec_type = AVMEDIA_TYPE_VIDEO;
- codec->width = bih->biWidth;
- codec->height = bih->biHeight;
- codec->codec_tag = bih->biCompression;
- codec->pix_fmt = dshow_pixfmt(bih->biCompression, bih->biBitCount);
+ st->avg_frame_rate = av_inv_q(time_base);
+
+ par->codec_type = AVMEDIA_TYPE_VIDEO;
+ par->width = bih->biWidth;
+ par->height = bih->biHeight;
+ par->codec_tag = bih->biCompression;
+ par->format = dshow_pixfmt(bih->biCompression, bih->biBitCount);
if (bih->biCompression == MKTAG('H', 'D', 'Y', 'C')) {
av_log(avctx, AV_LOG_DEBUG, "attempt to use full range for HDYC...\n");
- codec->color_range = AVCOL_RANGE_MPEG; // just in case it needs this...
+ par->color_range = AVCOL_RANGE_MPEG; // just in case it needs this...
}
- if (codec->pix_fmt == AV_PIX_FMT_NONE) {
+ if (par->format == AV_PIX_FMT_NONE) {
const AVCodecTag *const tags[] = { avformat_get_riff_video_tags(), NULL };
- codec->codec_id = av_codec_get_id(tags, bih->biCompression);
- if (codec->codec_id == AV_CODEC_ID_NONE) {
+ par->codec_id = av_codec_get_id(tags, bih->biCompression);
+ if (par->codec_id == AV_CODEC_ID_NONE) {
av_log(avctx, AV_LOG_ERROR, "Unknown compression type. "
"Please report type 0x%X.\n", (int) bih->biCompression);
return AVERROR_PATCHWELCOME;
}
- codec->bits_per_coded_sample = bih->biBitCount;
+ par->bits_per_coded_sample = bih->biBitCount;
} else {
- codec->codec_id = AV_CODEC_ID_RAWVIDEO;
+ par->codec_id = AV_CODEC_ID_RAWVIDEO;
if (bih->biCompression == BI_RGB || bih->biCompression == BI_BITFIELDS) {
- codec->bits_per_coded_sample = bih->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 = bih->biBitCount;
+ par->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (par->extradata) {
+ par->extradata_size = 9;
+ memcpy(par->extradata, "BottomUp", 9);
}
}
}
@@ -993,11 +994,11 @@ dshow_add_device(AVFormatContext *avctx,
goto error;
}
- codec->codec_type = AVMEDIA_TYPE_AUDIO;
- codec->sample_fmt = sample_fmt_bits_per_sample(fx->wBitsPerSample);
- codec->codec_id = waveform_codec_id(codec->sample_fmt);
- codec->sample_rate = fx->nSamplesPerSec;
- codec->channels = fx->nChannels;
+ par->codec_type = AVMEDIA_TYPE_AUDIO;
+ par->format = sample_fmt_bits_per_sample(fx->wBitsPerSample);
+ par->codec_id = waveform_codec_id(par->format);
+ par->sample_rate = fx->nSamplesPerSec;
+ par->channels = fx->nChannels;
}
avpriv_set_pts_info(st, 64, 1, 10000000);
diff --git a/libavdevice/fbdev_dec.c b/libavdevice/fbdev_dec.c
index e9a3639391..1505b2557d 100644
--- a/libavdevice/fbdev_dec.c
+++ b/libavdevice/fbdev_dec.c
@@ -126,13 +126,13 @@ 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 = av_inv_q(fbdev->framerate_q);
- 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->avg_frame_rate = fbdev->framerate_q;
+ st->codecpar->bit_rate =
fbdev->width * fbdev->height * fbdev->bytes_per_pixel * av_q2d(fbdev->framerate_q) * 8;
av_log(avctx, AV_LOG_INFO,
@@ -140,7 +140,7 @@ static av_cold int fbdev_read_header(AVFormatContext *avctx)
fbdev->width, fbdev->height, fbdev->varinfo.bits_per_pixel,
av_get_pix_fmt_name(pix_fmt),
fbdev->framerate_q.num, fbdev->framerate_q.den,
- (int64_t)st->codec->bit_rate);
+ (int64_t)st->codecpar->bit_rate);
return 0;
fail:
diff --git a/libavdevice/fbdev_enc.c b/libavdevice/fbdev_enc.c
index 28efc7131b..b4e5f84975 100644
--- a/libavdevice/fbdev_enc.c
+++ b/libavdevice/fbdev_enc.c
@@ -48,7 +48,7 @@ static av_cold int fbdev_write_header(AVFormatContext *h)
int ret, flags = O_RDWR;
const char* device;
- if (h->nb_streams != 1 || h->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO) {
+ if (h->nb_streams != 1 || h->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) {
av_log(fbdev, AV_LOG_ERROR, "Only a single video stream is supported.\n");
return AVERROR(EINVAL);
}
@@ -105,11 +105,11 @@ static int fbdev_write_packet(AVFormatContext *h, AVPacket *pkt)
enum AVPixelFormat fb_pix_fmt;
int disp_height;
int bytes_to_copy;
- AVCodecContext *codec_ctx = h->streams[0]->codec;
- enum AVPixelFormat video_pix_fmt = codec_ctx->pix_fmt;
- int video_width = codec_ctx->width;
- int video_height = codec_ctx->height;
- int bytes_per_pixel = ((codec_ctx->bits_per_coded_sample + 7) >> 3);
+ AVCodecParameters *par = h->streams[0]->codecpar;
+ enum AVPixelFormat video_pix_fmt = par->format;
+ int video_width = par->width;
+ int video_height = par->height;
+ int bytes_per_pixel = ((par->bits_per_coded_sample + 7) >> 3);
int src_line_size = video_width * bytes_per_pixel;
int i;
diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
index 7db587cd97..4239ffae11 100644
--- a/libavdevice/gdigrab.c
+++ b/libavdevice/gdigrab.c
@@ -403,10 +403,11 @@ gdigrab_read_header(AVFormatContext *s1)
}
}
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_BMP;
- st->codec->time_base = gdigrab->time_base;
- st->codec->bit_rate = (gdigrab->header_size + gdigrab->frame_size) * 1/av_q2d(gdigrab->time_base) * 8;
+ st->avg_frame_rate = av_inv_q(gdigrab->time_base);
+
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_BMP;
+ st->codecpar->bit_rate = (gdigrab->header_size + gdigrab->frame_size) * 1/av_q2d(gdigrab->time_base) * 8;
return 0;
diff --git a/libavdevice/jack.c b/libavdevice/jack.c
index 545548423d..34e21527a7 100644
--- a/libavdevice/jack.c
+++ b/libavdevice/jack.c
@@ -262,14 +262,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;
diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index 8e9e67d3c2..a52d4730e5 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -108,8 +108,8 @@ static int create_subcc_streams(AVFormatContext *avctx)
lavfi->sink_stream_subcc_map[sink_idx] = avctx->nb_streams;
if (!(st = avformat_new_stream(avctx, NULL)))
return AVERROR(ENOMEM);
- st->codec->codec_id = AV_CODEC_ID_EIA_608;
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_EIA_608;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
} else {
lavfi->sink_stream_subcc_map[sink_idx] = -1;
}
@@ -314,28 +314,28 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
for (i = 0; i < lavfi->nb_sinks; i++) {
AVFilterLink *link = lavfi->sinks[lavfi->stream_sink_map[i]]->inputs[0];
AVStream *st = avctx->streams[i];
- st->codec->codec_type = link->type;
+ st->codecpar->codec_type = link->type;
avpriv_set_pts_info(st, 64, link->time_base.num, link->time_base.den);
if (link->type == AVMEDIA_TYPE_VIDEO) {
- st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
- st->codec->pix_fmt = link->format;
- st->codec->time_base = link->time_base;
- st->codec->width = link->w;
- st->codec->height = link->h;
+ st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
+ st->codecpar->format = link->format;
+ st->avg_frame_rate = av_inv_q(link->time_base);
+ st->codecpar->width = link->w;
+ st->codecpar->height = link->h;
st ->sample_aspect_ratio =
- st->codec->sample_aspect_ratio = link->sample_aspect_ratio;
+ st->codecpar->sample_aspect_ratio = link->sample_aspect_ratio;
avctx->probesize = FFMAX(avctx->probesize,
link->w * link->h *
av_get_padded_bits_per_pixel(av_pix_fmt_desc_get(link->format)) *
30);
} else if (link->type == AVMEDIA_TYPE_AUDIO) {
- st->codec->codec_id = av_get_pcm_codec(link->format, -1);
- st->codec->channels = avfilter_link_get_channels(link);
- st->codec->sample_fmt = link->format;
- st->codec->sample_rate = link->sample_rate;
- st->codec->time_base = link->time_base;
- st->codec->channel_layout = link->channel_layout;
- if (st->codec->codec_id == AV_CODEC_ID_NONE)
+ st->codecpar->codec_id = av_get_pcm_codec(link->format, -1);
+ st->codecpar->channels = avfilter_link_get_channels(link);
+ st->codecpar->format = link->format;
+ st->codecpar->sample_rate = link->sample_rate;
+ st->avg_frame_rate = av_inv_q(link->time_base);
+ st->codecpar->channel_layout = link->channel_layout;
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE)
av_log(avctx, AV_LOG_ERROR,
"Could not find PCM codec for sample format %s.\n",
av_get_sample_fmt_name(link->format));
diff --git a/libavdevice/libcdio.c b/libavdevice/libcdio.c
index 9e9b0d86f3..f6d4fce256 100644
--- a/libavdevice/libcdio.c
+++ b/libavdevice/libcdio.c
@@ -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];
diff --git a/libavdevice/libdc1394.c b/libavdevice/libdc1394.c
index dcdca6064f..43fa232922 100644
--- a/libavdevice/libdc1394.c
+++ b/libavdevice/libdc1394.c
@@ -171,13 +171,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);
@@ -188,7 +187,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:
diff --git a/libavdevice/openal-dec.c b/libavdevice/openal-dec.c
index e4daf53250..0647952f9c 100644
--- a/libavdevice/openal-dec.c
+++ b/libavdevice/openal-dec.c
@@ -128,7 +128,7 @@ static int read_header(AVFormatContext *ctx)
int error = 0;
const char *error_msg;
AVStream *st = NULL;
- AVCodecContext *codec = NULL;
+ AVCodecParameters *par = NULL;
if (ad->list_devices) {
print_al_capture_devices(ctx);
@@ -156,11 +156,11 @@ static int read_header(AVFormatContext *ctx)
avpriv_set_pts_info(st, 64, 1, 1000000);
/* Set codec parameters */
- codec = st->codec;
- codec->codec_type = AVMEDIA_TYPE_AUDIO;
- codec->sample_rate = ad->sample_rate;
- codec->channels = get_al_format_info(ad->sample_format)->channels;
- codec->codec_id = get_al_format_info(ad->sample_format)->codec_id;
+ par = st->codecpar;
+ par->codec_type = AVMEDIA_TYPE_AUDIO;
+ par->sample_rate = ad->sample_rate;
+ par->channels = get_al_format_info(ad->sample_format)->channels;
+ par->codec_id = get_al_format_info(ad->sample_format)->codec_id;
/* This is needed to read the audio data */
ad->sample_step = (av_get_bits_per_sample(get_al_format_info(ad->sample_format)->codec_id) *
diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c
index ba8d36abff..1dbbb80f44 100644
--- a/libavdevice/opengl_enc.c
+++ b/libavdevice/opengl_enc.c
@@ -678,11 +678,11 @@ static void opengl_compute_display_area(AVFormatContext *s)
AVRational sar, dar; /* sample and display aspect ratios */
OpenGLContext *opengl = s->priv_data;
AVStream *st = s->streams[0];
- AVCodecContext *encctx = st->codec;
+ AVCodecParameters *par = st->codecpar;
/* compute overlay width and height from the codec context information */
sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 };
- dar = av_mul_q(sar, (AVRational){ encctx->width, encctx->height });
+ dar = av_mul_q(sar, (AVRational){ par->width, par->height });
/* we suppose the screen has a 1/1 sample aspect ratio */
/* fit in the window */
@@ -1065,15 +1065,15 @@ static av_cold int opengl_write_header(AVFormatContext *h)
int ret;
if (h->nb_streams != 1 ||
- h->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO ||
- h->streams[0]->codec->codec_id != AV_CODEC_ID_RAWVIDEO) {
+ h->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
+ h->streams[0]->codecpar->codec_id != AV_CODEC_ID_RAWVIDEO) {
av_log(opengl, AV_LOG_ERROR, "Only a single video stream is supported.\n");
return AVERROR(EINVAL);
}
st = h->streams[0];
- opengl->width = st->codec->width;
- opengl->height = st->codec->height;
- opengl->pix_fmt = st->codec->pix_fmt;
+ opengl->width = st->codecpar->width;
+ opengl->height = st->codecpar->height;
+ opengl->pix_fmt = st->codecpar->format;
if (!opengl->window_width)
opengl->window_width = opengl->width;
if (!opengl->window_height)
@@ -1200,7 +1200,7 @@ static uint8_t* opengl_get_plane_pointer(OpenGLContext *opengl, AVPacket *pkt, i
static int opengl_draw(AVFormatContext *h, void *input, int repaint, int is_pkt)
{
OpenGLContext *opengl = h->priv_data;
- enum AVPixelFormat pix_fmt = h->streams[0]->codec->pix_fmt;
+ enum AVPixelFormat pix_fmt = h->streams[0]->codecpar->format;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int ret;
diff --git a/libavdevice/oss_dec.c b/libavdevice/oss_dec.c
index 3a9a20a233..9f748f2bc3 100644
--- a/libavdevice/oss_dec.c
+++ b/libavdevice/oss_dec.c
@@ -63,10 +63,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;
diff --git a/libavdevice/oss_enc.c b/libavdevice/oss_enc.c
index 3781eb54e5..2268b4cfe4 100644
--- a/libavdevice/oss_enc.c
+++ b/libavdevice/oss_enc.c
@@ -49,8 +49,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);
diff --git a/libavdevice/pulse_audio_dec.c b/libavdevice/pulse_audio_dec.c
index aa0800b40b..95a1d6ecfa 100644
--- a/libavdevice/pulse_audio_dec.c
+++ b/libavdevice/pulse_audio_dec.c
@@ -242,10 +242,10 @@ static av_cold int pulse_read_header(AVFormatContext *s)
pa_threaded_mainloop_unlock(pd->mainloop);
/* 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->timefilter = ff_timefilter_new(1000000.0 / pd->sample_rate,
diff --git a/libavdevice/pulse_audio_enc.c b/libavdevice/pulse_audio_enc.c
index b419a38d46..6fb634ee2b 100644
--- a/libavdevice/pulse_audio_enc.c
+++ b/libavdevice/pulse_audio_enc.c
@@ -452,7 +452,7 @@ static av_cold int pulse_write_header(AVFormatContext *h)
PA_STREAM_AUTO_TIMING_UPDATE |
PA_STREAM_NOT_MONOTONIC;
- if (h->nb_streams != 1 || h->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO) {
+ if (h->nb_streams != 1 || h->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) {
av_log(s, AV_LOG_ERROR, "Only a single audio stream is supported.\n");
return AVERROR(EINVAL);
}
@@ -468,8 +468,8 @@ static av_cold int pulse_write_header(AVFormatContext *h)
if (s->buffer_duration) {
int64_t bytes = s->buffer_duration;
- bytes *= st->codec->channels * st->codec->sample_rate *
- av_get_bytes_per_sample(st->codec->sample_fmt);
+ bytes *= st->codecpar->channels * st->codecpar->sample_rate *
+ av_get_bytes_per_sample(st->codecpar->format);
bytes /= 1000;
buffer_attributes.tlength = FFMAX(s->buffer_size, av_clip64(bytes, 0, UINT32_MAX - 1));
av_log(s, AV_LOG_DEBUG,
@@ -483,9 +483,9 @@ static av_cold int pulse_write_header(AVFormatContext *h)
if (s->minreq)
buffer_attributes.minreq = s->minreq;
- sample_spec.format = ff_codec_id_to_pulse_format(st->codec->codec_id);
- sample_spec.rate = st->codec->sample_rate;
- sample_spec.channels = st->codec->channels;
+ sample_spec.format = ff_codec_id_to_pulse_format(st->codecpar->codec_id);
+ sample_spec.rate = st->codecpar->sample_rate;
+ sample_spec.channels = st->codecpar->channels;
if (!pa_sample_spec_valid(&sample_spec)) {
av_log(s, AV_LOG_ERROR, "Invalid sample spec.\n");
return AVERROR(EINVAL);
@@ -494,10 +494,10 @@ static av_cold int pulse_write_header(AVFormatContext *h)
if (sample_spec.channels == 1) {
channel_map.channels = 1;
channel_map.map[0] = PA_CHANNEL_POSITION_MONO;
- } else if (st->codec->channel_layout) {
- if (av_get_channel_layout_nb_channels(st->codec->channel_layout) != st->codec->channels)
+ } else if (st->codecpar->channel_layout) {
+ if (av_get_channel_layout_nb_channels(st->codecpar->channel_layout) != st->codecpar->channels)
return AVERROR(EINVAL);
- pulse_map_channels_to_pulse(st->codec->channel_layout, &channel_map);
+ pulse_map_channels_to_pulse(st->codecpar->channel_layout, &channel_map);
/* Unknown channel is present in channel_layout, let PulseAudio use its default. */
if (channel_map.channels != sample_spec.channels) {
av_log(s, AV_LOG_WARNING, "Unknown channel. Using defaul channel map.\n");
@@ -637,9 +637,8 @@ static int pulse_write_packet(AVFormatContext *h, AVPacket *pkt)
s->timestamp += pkt->duration;
} else {
AVStream *st = h->streams[0];
- AVCodecContext *codec_ctx = st->codec;
- AVRational r = { 1, codec_ctx->sample_rate };
- int64_t samples = pkt->size / (av_get_bytes_per_sample(codec_ctx->sample_fmt) * codec_ctx->channels);
+ AVRational r = { 1, st->codecpar->sample_rate };
+ int64_t samples = pkt->size / (av_get_bytes_per_sample(st->codecpar->format) * st->codecpar->channels);
s->timestamp += av_rescale_q(samples, r, st->time_base);
}
@@ -678,7 +677,7 @@ static int pulse_write_frame(AVFormatContext *h, int stream_index,
/* Planar formats are not supported yet. */
if (flags & AV_WRITE_UNCODED_FRAME_QUERY)
- return av_sample_fmt_is_planar(h->streams[stream_index]->codec->sample_fmt) ?
+ return av_sample_fmt_is_planar(h->streams[stream_index]->codecpar->format) ?
AVERROR(EINVAL) : 0;
pkt.data = (*frame)->data[0];
diff --git a/libavdevice/sdl.c b/libavdevice/sdl.c
index 4cccfe528a..432275004c 100644
--- a/libavdevice/sdl.c
+++ b/libavdevice/sdl.c
@@ -94,12 +94,12 @@ static void compute_overlay_rect(AVFormatContext *s)
AVRational sar, dar; /* sample and display aspect ratios */
SDLContext *sdl = s->priv_data;
AVStream *st = s->streams[0];
- AVCodecContext *encctx = st->codec;
+ AVCodecParameters *par = st->codecpar;
SDL_Rect *overlay_rect = &sdl->overlay_rect;
/* compute overlay width and height from the codec context information */
sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 };
- dar = av_mul_q(sar, (AVRational){ encctx->width, encctx->height });
+ dar = av_mul_q(sar, (AVRational){ par->width, par->height });
/* we suppose the screen has a 1/1 sample aspect ratio */
if (sdl->window_width && sdl->window_height) {
@@ -115,10 +115,10 @@ static void compute_overlay_rect(AVFormatContext *s)
}
} else {
if (sar.num > sar.den) {
- overlay_rect->w = encctx->width;
+ overlay_rect->w = par->width;
overlay_rect->h = av_rescale(overlay_rect->w, dar.den, dar.num);
} else {
- overlay_rect->h = encctx->height;
+ overlay_rect->h = par->height;
overlay_rect->w = av_rescale(overlay_rect->h, dar.num, dar.den);
}
sdl->window_width = overlay_rect->w;
@@ -137,7 +137,7 @@ static int event_thread(void *arg)
SDLContext *sdl = s->priv_data;
int flags = SDL_BASE_FLAGS | (sdl->window_fullscreen ? SDL_FULLSCREEN : 0);
AVStream *st = s->streams[0];
- AVCodecContext *encctx = st->codec;
+ AVCodecParameters *par = st->codecpar;
/* initialization */
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
@@ -155,19 +155,19 @@ static int event_thread(void *arg)
goto init_end;
}
- sdl->overlay = SDL_CreateYUVOverlay(encctx->width, encctx->height,
+ sdl->overlay = SDL_CreateYUVOverlay(par->width, par->height,
sdl->overlay_fmt, sdl->surface);
- if (!sdl->overlay || sdl->overlay->pitches[0] < encctx->width) {
+ if (!sdl->overlay || sdl->overlay->pitches[0] < par->width) {
av_log(s, AV_LOG_ERROR,
"SDL does not support an overlay with size of %dx%d pixels\n",
- encctx->width, encctx->height);
+ par->width, par->height);
sdl->init_ret = AVERROR(EINVAL);
goto init_end;
}
sdl->init_ret = 0;
av_log(s, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s -> w:%d h:%d\n",
- encctx->width, encctx->height, av_get_pix_fmt_name(encctx->pix_fmt),
+ par->width, par->height, av_get_pix_fmt_name(par->format),
sdl->overlay_rect.w, sdl->overlay_rect.h);
init_end:
@@ -234,7 +234,7 @@ static int sdl_write_header(AVFormatContext *s)
{
SDLContext *sdl = s->priv_data;
AVStream *st = s->streams[0];
- AVCodecContext *encctx = st->codec;
+ AVCodecParameters *par = st->codecpar;
int i, ret;
if (!sdl->window_title)
@@ -251,15 +251,15 @@ static int sdl_write_header(AVFormatContext *s)
}
if ( s->nb_streams > 1
- || encctx->codec_type != AVMEDIA_TYPE_VIDEO
- || encctx->codec_id != AV_CODEC_ID_RAWVIDEO) {
+ || par->codec_type != AVMEDIA_TYPE_VIDEO
+ || par->codec_id != AV_CODEC_ID_RAWVIDEO) {
av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n");
ret = AVERROR(EINVAL);
goto fail;
}
for (i = 0; sdl_overlay_pix_fmt_map[i].pix_fmt != AV_PIX_FMT_NONE; i++) {
- if (sdl_overlay_pix_fmt_map[i].pix_fmt == encctx->pix_fmt) {
+ if (sdl_overlay_pix_fmt_map[i].pix_fmt == par->format) {
sdl->overlay_fmt = sdl_overlay_pix_fmt_map[i].overlay_fmt;
break;
}
@@ -268,7 +268,7 @@ static int sdl_write_header(AVFormatContext *s)
if (!sdl->overlay_fmt) {
av_log(s, AV_LOG_ERROR,
"Unsupported pixel format '%s', choose one of yuv420p, yuyv422, or uyvy422\n",
- av_get_pix_fmt_name(encctx->pix_fmt));
+ av_get_pix_fmt_name(par->format));
ret = AVERROR(EINVAL);
goto fail;
}
@@ -315,7 +315,7 @@ fail:
static int sdl_write_packet(AVFormatContext *s, AVPacket *pkt)
{
SDLContext *sdl = s->priv_data;
- AVCodecContext *encctx = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
uint8_t *data[4];
int linesize[4];
int i;
@@ -324,7 +324,7 @@ static int sdl_write_packet(AVFormatContext *s, AVPacket *pkt)
sdl_write_trailer(s);
return AVERROR(EIO);
}
- av_image_fill_arrays(data, linesize, pkt->data, encctx->pix_fmt, encctx->width, encctx->height, 1);
+ av_image_fill_arrays(data, linesize, pkt->data, par->format, par->width, par->height, 1);
SDL_LockMutex(sdl->mutex);
SDL_FillRect(sdl->surface, &sdl->surface->clip_rect,
diff --git a/libavdevice/sndio_dec.c b/libavdevice/sndio_dec.c
index 6f1160e0f0..2d13232bf1 100644
--- a/libavdevice/sndio_dec.c
+++ b/libavdevice/sndio_dec.c
@@ -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 */
diff --git a/libavdevice/sndio_enc.c b/libavdevice/sndio_enc.c
index 52b9060ef6..47f500d71e 100644
--- a/libavdevice/sndio_enc.c
+++ b/libavdevice/sndio_enc.c
@@ -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);
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 383033e738..103fb105f2 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -938,8 +938,8 @@ static int v4l2_read_header(AVFormatContext *ctx)
if ((res = v4l2_set_parameters(ctx)) < 0)
goto fail;
- st->codec->pix_fmt = ff_fmt_v4l2ff(desired_format, codec_id);
- s->frame_size = av_image_get_buffer_size(st->codec->pix_fmt,
+ st->codecpar->format = ff_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(ctx)) ||
@@ -948,22 +948,22 @@ static int v4l2_read_header(AVFormatContext *ctx)
s->top_field_first = first_field(s);
- 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->codecpar->codec_tag =
+ avcodec_pix_fmt_to_codec_tag(st->codecpar->format);
else if (codec_id == AV_CODEC_ID_H264) {
st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
}
if (desired_format == V4L2_PIX_FMT_YVU420)
- st->codec->codec_tag = MKTAG('Y', 'V', '1', '2');
+ st->codecpar->codec_tag = MKTAG('Y', 'V', '1', '2');
else if (desired_format == V4L2_PIX_FMT_YVU410)
- st->codec->codec_tag = MKTAG('Y', 'V', 'U', '9');
- st->codec->width = s->width;
- st->codec->height = s->height;
+ st->codecpar->codec_tag = MKTAG('Y', 'V', 'U', '9');
+ st->codecpar->width = s->width;
+ st->codecpar->height = s->height;
if (st->avg_frame_rate.den)
- st->codec->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8;
+ st->codecpar->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8;
return 0;
diff --git a/libavdevice/v4l2enc.c b/libavdevice/v4l2enc.c
index ac4068cbd4..faf6e07f86 100644
--- a/libavdevice/v4l2enc.c
+++ b/libavdevice/v4l2enc.c
@@ -33,7 +33,7 @@ static av_cold int write_header(AVFormatContext *s1)
.type = V4L2_BUF_TYPE_VIDEO_OUTPUT
};
V4L2Context *s = s1->priv_data;
- AVCodecContext *enc_ctx;
+ AVCodecParameters *par;
uint32_t v4l2_pixfmt;
if (s1->flags & AVFMT_FLAG_NONBLOCK)
@@ -47,19 +47,19 @@ static av_cold int write_header(AVFormatContext *s1)
}
if (s1->nb_streams != 1 ||
- s1->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO ||
- s1->streams[0]->codec->codec_id != AV_CODEC_ID_RAWVIDEO) {
+ s1->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
+ s1->streams[0]->codecpar->codec_id != AV_CODEC_ID_RAWVIDEO) {
av_log(s1, AV_LOG_ERROR,
"V4L2 output device supports only a single raw video stream\n");
return AVERROR(EINVAL);
}
- enc_ctx = s1->streams[0]->codec;
+ par = s1->streams[0]->codecpar;
- v4l2_pixfmt = ff_fmt_ff2v4l(enc_ctx->pix_fmt, AV_CODEC_ID_RAWVIDEO);
+ v4l2_pixfmt = ff_fmt_ff2v4l(par->format, AV_CODEC_ID_RAWVIDEO);
if (!v4l2_pixfmt) { // XXX: try to force them one by one?
av_log(s1, AV_LOG_ERROR, "Unknown V4L2 pixel format equivalent for %s\n",
- av_get_pix_fmt_name(enc_ctx->pix_fmt));
+ av_get_pix_fmt_name(par->format));
return AVERROR(EINVAL);
}
@@ -69,10 +69,10 @@ static av_cold int write_header(AVFormatContext *s1)
return res;
}
- fmt.fmt.pix.width = enc_ctx->width;
- fmt.fmt.pix.height = enc_ctx->height;
+ fmt.fmt.pix.width = par->width;
+ fmt.fmt.pix.height = par->height;
fmt.fmt.pix.pixelformat = v4l2_pixfmt;
- fmt.fmt.pix.sizeimage = av_image_get_buffer_size(enc_ctx->pix_fmt, enc_ctx->width, enc_ctx->height, 1);
+ fmt.fmt.pix.sizeimage = av_image_get_buffer_size(par->format, par->width, par->height, 1);
if (ioctl(s->fd, VIDIOC_S_FMT, &fmt) < 0) {
res = AVERROR(errno);
diff --git a/libavdevice/vfwcap.c b/libavdevice/vfwcap.c
index e1f8b86699..2dcf5aa2ed 100644
--- a/libavdevice/vfwcap.c
+++ b/libavdevice/vfwcap.c
@@ -245,7 +245,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;
@@ -377,29 +377,30 @@ static int vfw_read_header(AVFormatContext *s)
if(!ret)
goto fail;
- codec = st->codec;
- codec->time_base = av_inv_q(framerate_q);
- 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);
}
}
}
diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
index 9dc3472187..a78e7a47a6 100644
--- a/libavdevice/x11grab.c
+++ b/libavdevice/x11grab.c
@@ -355,11 +355,11 @@ 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;
- if (st->codec->pix_fmt == AV_PIX_FMT_PAL8) {
+ if (st->codecpar->format == AV_PIX_FMT_PAL8) {
color_map = DefaultColormap(dpy, screen);
for (i = 0; i < 256; ++i)
color[i].pixel = i;
@@ -372,12 +372,13 @@ static int x11grab_read_header(AVFormatContext *s1)
}
- 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(dpyname);
diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
index 2da7ec7d4f..9da46c8e0d 100644
--- a/libavdevice/xcbgrab.c
+++ b/libavdevice/xcbgrab.c
@@ -548,13 +548,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);
diff --git a/libavdevice/xv.c b/libavdevice/xv.c
index 64cddeb068..185de7569e 100644
--- a/libavdevice/xv.c
+++ b/libavdevice/xv.c
@@ -109,22 +109,22 @@ static int xv_write_header(AVFormatContext *s)
XColor fgcolor;
XWindowAttributes window_attrs;
int num_formats = 0, j, tag, ret;
- AVCodecContext *encctx = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
if ( s->nb_streams > 1
- || encctx->codec_type != AVMEDIA_TYPE_VIDEO
- || encctx->codec_id != AV_CODEC_ID_RAWVIDEO) {
+ || par->codec_type != AVMEDIA_TYPE_VIDEO
+ || par->codec_id != AV_CODEC_ID_RAWVIDEO) {
av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n");
return AVERROR(EINVAL);
}
- if (!(tag = xv_get_tag_from_format(encctx->pix_fmt))) {
+ if (!(tag = xv_get_tag_from_format(par->format))) {
av_log(s, AV_LOG_ERROR,
"Unsupported pixel format '%s', only yuv420p, uyvy422, yuyv422 are currently supported\n",
- av_get_pix_fmt_name(encctx->pix_fmt));
+ av_get_pix_fmt_name(par->format));
return AVERROR_PATCHWELCOME;
}
- xv->image_format = encctx->pix_fmt;
+ xv->image_format = par->format;
xv->display = XOpenDisplay(xv->display_name);
if (!xv->display) {
@@ -132,12 +132,12 @@ static int xv_write_header(AVFormatContext *s)
return AVERROR(EINVAL);
}
- xv->image_width = encctx->width;
- xv->image_height = encctx->height;
+ xv->image_width = par->width;
+ xv->image_height = par->height;
if (!xv->window_width && !xv->window_height) {
- AVRational sar = encctx->sample_aspect_ratio;
- xv->window_width = encctx->width;
- xv->window_height = encctx->height;
+ AVRational sar = par->sample_aspect_ratio;
+ xv->window_width = par->width;
+ xv->window_height = par->height;
if (sar.num) {
if (sar.num > sar.den)
xv->window_width = av_rescale(xv->window_width, sar.num, sar.den);
@@ -189,14 +189,14 @@ static int xv_write_header(AVFormatContext *s)
if (j >= num_formats) {
av_log(s, AV_LOG_ERROR,
"Device does not support pixel format %s, aborting\n",
- av_get_pix_fmt_name(encctx->pix_fmt));
+ av_get_pix_fmt_name(par->format));
ret = AVERROR(EINVAL);
goto fail;
}
xv->gc = XCreateGC(xv->display, xv->window, 0, 0);
- xv->image_width = encctx->width;
- xv->image_height = encctx->height;
+ xv->image_width = par->width;
+ xv->image_height = par->height;
xv->yuv_image = XvShmCreateImage(xv->display, xv->xv_port, tag, 0,
xv->image_width, xv->image_height, &xv->yuv_shminfo);
xv->yuv_shminfo.shmid = shmget(IPC_PRIVATE, xv->yuv_image->data_size,
@@ -228,11 +228,11 @@ static void compute_display_area(AVFormatContext *s)
XVContext *xv = s->priv_data;
AVRational sar, dar; /* sample and display aspect ratios */
AVStream *st = s->streams[0];
- AVCodecContext *encctx = st->codec;
+ AVCodecParameters *par = st->codecpar;
/* compute overlay width and height from the codec context information */
sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 };
- dar = av_mul_q(sar, (AVRational){ encctx->width, encctx->height });
+ dar = av_mul_q(sar, (AVRational){ par->width, par->height });
/* we suppose the screen has a 1/1 sample aspect ratio */
/* fit in the window */
@@ -321,12 +321,12 @@ static int write_picture(AVFormatContext *s, uint8_t *input_data[4],
static int xv_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- AVCodecContext *ctx = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
uint8_t *data[4];
int linesize[4];
- av_image_fill_arrays(data, linesize, pkt->data, ctx->pix_fmt,
- ctx->width, ctx->height, 1);
+ av_image_fill_arrays(data, linesize, pkt->data, par->format,
+ par->width, par->height, 1);
return write_picture(s, data, linesize);
}
diff --git a/libavformat/3dostr.c b/libavformat/3dostr.c
index 5325a03f90..3668e5f613 100644
--- a/libavformat/3dostr.c
+++ b/libavformat/3dostr.c
@@ -61,17 +61,17 @@ static int threedostr_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->sample_rate = avio_rb32(s->pb);
- st->codec->channels = avio_rb32(s->pb);
- if (st->codec->channels <= 0)
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->sample_rate = avio_rb32(s->pb);
+ st->codecpar->channels = avio_rb32(s->pb);
+ if (st->codecpar->channels <= 0)
return AVERROR_INVALIDDATA;
codec = avio_rl32(s->pb);
avio_skip(s->pb, 4);
if (ctrl_size == 20 || ctrl_size == 3 || ctrl_size == -1)
- st->duration = (avio_rb32(s->pb) - 1) / st->codec->channels;
+ st->duration = (avio_rb32(s->pb) - 1) / st->codecpar->channels;
else
- st->duration = avio_rb32(s->pb) * 16 / st->codec->channels;
+ st->duration = avio_rb32(s->pb) * 16 / st->codecpar->channels;
size -= 56;
found_shdr = 1;
break;
@@ -95,15 +95,15 @@ static int threedostr_read_header(AVFormatContext *s)
switch (codec) {
case MKTAG('S','D','X','2'):
- st->codec->codec_id = AV_CODEC_ID_SDX2_DPCM;
- st->codec->block_align = 1 * st->codec->channels;
+ st->codecpar->codec_id = AV_CODEC_ID_SDX2_DPCM;
+ st->codecpar->block_align = 1 * st->codecpar->channels;
break;
default:
avpriv_request_sample(s, "codec %X", codec);
return AVERROR_PATCHWELCOME;
}
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
@@ -142,7 +142,7 @@ static int threedostr_read_packet(AVFormatContext *s, AVPacket *pkt)
ret = av_get_packet(s->pb, pkt, size);
pkt->pos = pos;
pkt->stream_index = 0;
- pkt->duration = size / st->codec->channels;
+ pkt->duration = size / st->codecpar->channels;
size = 0;
found_ssmp = 1;
break;
diff --git a/libavformat/4xm.c b/libavformat/4xm.c
index 70f0def3ed..2f2f6a6afc 100644
--- a/libavformat/4xm.c
+++ b/libavformat/4xm.c
@@ -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;
}
@@ -173,23 +173,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;
}
diff --git a/libavformat/a64.c b/libavformat/a64.c
index a7f93a27b1..2a0489dae4 100644
--- a/libavformat/a64.c
+++ b/libavformat/a64.c
@@ -26,7 +26,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
@@ -35,20 +35,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:
diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
index 1b98e1ddb5..aa2375690d 100644
--- a/libavformat/aacdec.c
+++ b/libavformat/aacdec.c
@@ -84,9 +84,9 @@ 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->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = s->iformat->raw_codec_id;
+ st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
ff_id3v1_read(s);
if (s->pb->seekable &&
diff --git a/libavformat/aadec.c b/libavformat/aadec.c
index 266a8e85ac..cf5f3d107a 100644
--- a/libavformat/aadec.c
+++ b/libavformat/aadec.c
@@ -173,22 +173,22 @@ static int aa_read_header(AVFormatContext *s)
av_freep(&c->tea_ctx);
return AVERROR(ENOMEM);
}
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
if (!strcmp(codec_name, "mp332")) {
- st->codec->codec_id = AV_CODEC_ID_MP3;
- st->codec->sample_rate = 22050;
+ st->codecpar->codec_id = AV_CODEC_ID_MP3;
+ st->codecpar->sample_rate = 22050;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
st->start_time = 0;
} else if (!strcmp(codec_name, "acelp85")) {
- st->codec->codec_id = AV_CODEC_ID_SIPR;
- st->codec->block_align = 19;
- st->codec->channels = 1;
- st->codec->sample_rate = 8500;
+ st->codecpar->codec_id = AV_CODEC_ID_SIPR;
+ st->codecpar->block_align = 19;
+ st->codecpar->channels = 1;
+ st->codecpar->sample_rate = 8500;
} else if (!strcmp(codec_name, "acelp16")) {
- st->codec->codec_id = AV_CODEC_ID_SIPR;
- st->codec->block_align = 20;
- st->codec->channels = 1;
- st->codec->sample_rate = 16000;
+ st->codecpar->codec_id = AV_CODEC_ID_SIPR;
+ st->codecpar->block_align = 20;
+ st->codecpar->channels = 1;
+ st->codecpar->sample_rate = 16000;
}
/* determine, and jump to audio start offset */
diff --git a/libavformat/acm.c b/libavformat/acm.c
index afcafa8d7a..08dd9282fa 100644
--- a/libavformat/acm.c
+++ b/libavformat/acm.c
@@ -41,24 +41,24 @@ static int acm_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_INTERPLAY_ACM;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_INTERPLAY_ACM;
- ff_alloc_extradata(st->codec, 14);
- if (!st->codec->extradata)
+ ff_alloc_extradata(st->codecpar, 14);
+ if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
- ret = avio_read(s->pb, st->codec->extradata, 14);
+ ret = avio_read(s->pb, st->codecpar->extradata, 14);
if (ret < 10)
return ret < 0 ? ret : AVERROR_EOF;
- st->codec->channels = AV_RL16(st->codec->extradata + 8);
- st->codec->sample_rate = AV_RL16(st->codec->extradata + 10);
- if (st->codec->channels <= 0 || st->codec->sample_rate <= 0)
+ st->codecpar->channels = AV_RL16(st->codecpar->extradata + 8);
+ st->codecpar->sample_rate = AV_RL16(st->codecpar->extradata + 10);
+ if (st->codecpar->channels <= 0 || st->codecpar->sample_rate <= 0)
return AVERROR_INVALIDDATA;
st->start_time = 0;
- st->duration = AV_RL32(st->codec->extradata + 4) / st->codec->channels;
+ st->duration = AV_RL32(st->codecpar->extradata + 4) / st->codecpar->channels;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
diff --git a/libavformat/act.c b/libavformat/act.c
index 35aacbc459..fe67411787 100644
--- a/libavformat/act.c
+++ b/libavformat/act.c
@@ -75,29 +75,29 @@ static int read_header(AVFormatContext *s)
avio_skip(pb, 16);
size=avio_rl32(pb);
- ff_get_wav_header(s, pb, st->codec, size, 0);
+ ff_get_wav_header(s, pb, st->codecpar, size, 0);
/*
8000Hz (Fine-rec) file format has 10 bytes long
packets with 10ms of sound data in them
*/
- if (st->codec->sample_rate != 8000) {
- av_log(s, AV_LOG_ERROR, "Sample rate %d is not supported.\n", st->codec->sample_rate);
+ if (st->codecpar->sample_rate != 8000) {
+ av_log(s, AV_LOG_ERROR, "Sample rate %d is not supported.\n", st->codecpar->sample_rate);
return AVERROR_INVALIDDATA;
}
- st->codec->frame_size=80;
- st->codec->channels=1;
+ st->codecpar->frame_size=80;
+ st->codecpar->channels=1;
avpriv_set_pts_info(st, 64, 1, 100);
- st->codec->codec_id=AV_CODEC_ID_G729;
+ st->codecpar->codec_id=AV_CODEC_ID_G729;
avio_seek(pb, 257, SEEK_SET);
msec=avio_rl16(pb);
sec=avio_r8(pb);
min=avio_rl32(pb);
- st->duration = av_rescale(1000*(min*60+sec)+msec, st->codec->sample_rate, 1000 * st->codec->frame_size);
+ st->duration = av_rescale(1000*(min*60+sec)+msec, st->codecpar->sample_rate, 1000 * st->codecpar->frame_size);
ctx->bytes_left_in_chunk=CHUNK_SIZE;
@@ -113,10 +113,10 @@ static int read_packet(AVFormatContext *s,
ACTContext *ctx = s->priv_data;
AVIOContext *pb = s->pb;
int ret;
- int frame_size=s->streams[0]->codec->sample_rate==8000?10:22;
+ int frame_size=s->streams[0]->codecpar->sample_rate==8000?10:22;
- if(s->streams[0]->codec->sample_rate==8000)
+ if(s->streams[0]->codecpar->sample_rate==8000)
ret=av_new_packet(pkt, 10);
else
ret=av_new_packet(pkt, 11);
@@ -124,7 +124,7 @@ static int read_packet(AVFormatContext *s,
if(ret)
return ret;
- if(s->streams[0]->codec->sample_rate==4400 && !ctx->second_packet)
+ if(s->streams[0]->codecpar->sample_rate==4400 && !ctx->second_packet)
{
ret = avio_read(pb, ctx->audio_buffer, frame_size);
@@ -147,7 +147,7 @@ static int read_packet(AVFormatContext *s,
ctx->second_packet=1;
}
- else if(s->streams[0]->codec->sample_rate==4400 && ctx->second_packet)
+ else if(s->streams[0]->codecpar->sample_rate==4400 && ctx->second_packet)
{
pkt->data[0]=ctx->audio_buffer[5];
pkt->data[1]=ctx->audio_buffer[17];
diff --git a/libavformat/adp.c b/libavformat/adp.c
index f53375aea0..9ab2ec4566 100644
--- a/libavformat/adp.c
+++ b/libavformat/adp.c
@@ -53,16 +53,16 @@ static int adp_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_ADPCM_DTK;
- st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
- st->codec->channels = 2;
- st->codec->sample_rate = 48000;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_DTK;
+ st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+ st->codecpar->channels = 2;
+ st->codecpar->sample_rate = 48000;
st->start_time = 0;
if (s->pb->seekable)
- st->duration = av_get_audio_frame_duration(st->codec, avio_size(s->pb));
+ st->duration = av_get_audio_frame_duration2(st->codecpar, avio_size(s->pb));
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
diff --git a/libavformat/ads.c b/libavformat/ads.c
index bda2673bad..73ea7c7d54 100644
--- a/libavformat/ads.c
+++ b/libavformat/ads.c
@@ -42,39 +42,39 @@ static int ads_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avio_skip(s->pb, 8);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
codec = avio_rl32(s->pb);
- st->codec->sample_rate = avio_rl32(s->pb);
- if (st->codec->sample_rate <= 0)
+ st->codecpar->sample_rate = avio_rl32(s->pb);
+ if (st->codecpar->sample_rate <= 0)
return AVERROR_INVALIDDATA;
- st->codec->channels = avio_rl32(s->pb);
- if (st->codec->channels <= 0)
+ st->codecpar->channels = avio_rl32(s->pb);
+ if (st->codecpar->channels <= 0)
return AVERROR_INVALIDDATA;
align = avio_rl32(s->pb);
- if (align <= 0 || align > INT_MAX / st->codec->channels)
+ if (align <= 0 || align > INT_MAX / st->codecpar->channels)
return AVERROR_INVALIDDATA;
if (codec == 1)
- st->codec->codec_id = AV_CODEC_ID_PCM_S16LE_PLANAR;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE_PLANAR;
else
- st->codec->codec_id = AV_CODEC_ID_ADPCM_PSX;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX;
- st->codec->block_align = st->codec->channels * align;
+ st->codecpar->block_align = st->codecpar->channels * align;
avio_skip(s->pb, 12);
size = avio_rl32(s->pb);
- if (st->codec->codec_id == AV_CODEC_ID_ADPCM_PSX)
- st->duration = (size - 0x40) / 16 / st->codec->channels * 28;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_PSX)
+ st->duration = (size - 0x40) / 16 / st->codecpar->channels * 28;
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
static int ads_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- AVCodecContext *codec = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
int ret;
- ret = av_get_packet(s->pb, pkt, codec->block_align);
+ ret = av_get_packet(s->pb, pkt, par->block_align);
pkt->stream_index = 0;
return ret;
}
diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c
index 242d7383f0..5e006dd38f 100644
--- a/libavformat/adtsenc.c
+++ b/libavformat/adtsenc.c
@@ -97,13 +97,13 @@ static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, const ui
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 (adts->id3v2tag)
ff_id3v2_write_simple(s, 4, ID3v2_DEFAULT_MAGIC);
- 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;
}
diff --git a/libavformat/adxdec.c b/libavformat/adxdec.c
index 05cef0b07c..fd096702c9 100644
--- a/libavformat/adxdec.c
+++ b/libavformat/adxdec.c
@@ -50,15 +50,15 @@ static int adx_probe(AVProbeData *p)
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;
- 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;
}
- size = BLOCK_SIZE * avctx->channels;
+ size = BLOCK_SIZE * par->channels;
pkt->pos = avio_tell(s->pb);
pkt->stream_index = 0;
@@ -82,37 +82,37 @@ 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);
- if (ff_get_extradata(avctx, s->pb, c->header_size) < 0)
+ if (ff_get_extradata(par, s->pb, c->header_size) < 0)
return AVERROR(ENOMEM);
- 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;
}
diff --git a/libavformat/aea.c b/libavformat/aea.c
index db415c9543..f4f1363f9b 100644
--- a/libavformat/aea.c
+++ b/libavformat/aea.c
@@ -67,29 +67,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)
diff --git a/libavformat/afc.c b/libavformat/afc.c
index 8dbd232fc1..542cb168fc 100644
--- a/libavformat/afc.c
+++ b/libavformat/afc.c
@@ -35,20 +35,20 @@ static int afc_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_id = AV_CODEC_ID_ADPCM_AFC;
- st->codec->channels = 2;
- st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_AFC;
+ st->codecpar->channels = 2;
+ st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
- if (ff_alloc_extradata(st->codec, 1))
+ if (ff_alloc_extradata(st->codecpar, 1))
return AVERROR(ENOMEM);
- st->codec->extradata[0] = 8 * st->codec->channels;
+ st->codecpar->extradata[0] = 8 * st->codecpar->channels;
c->data_end = avio_rb32(s->pb) + 32LL;
st->duration = avio_rb32(s->pb);
- st->codec->sample_rate = avio_rb16(s->pb);
+ st->codecpar->sample_rate = avio_rb16(s->pb);
avio_skip(s->pb, 22);
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index 34b266d31e..bb5299c06f 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -95,7 +95,7 @@ static 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;
@@ -104,10 +104,10 @@ static 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) - 16383 - 63;
val = avio_rb64(pb);
@@ -119,29 +119,29 @@ static int get_aiff_header(AVFormatContext *s, int size,
sample_rate = val << exp;
else
sample_rate = (val + (1ULL<<(-exp-1))) >> -exp;
- codec->sample_rate = sample_rate;
+ par->sample_rate = sample_rate;
size -= 18;
/* get codec id for AIFF-C */
if (size < 4) {
version = AIFF;
} else 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);
- if (codec->codec_id == AV_CODEC_ID_NONE) {
+ par->codec_tag = avio_rl32(pb);
+ par->codec_id = ff_codec_get_id(ff_codec_aiff_tags, par->codec_tag);
+ if (par->codec_id == AV_CODEC_ID_NONE) {
char tag[32];
- av_get_codec_tag_string(tag, sizeof(tag), codec->codec_tag);
+ av_get_codec_tag_string(tag, sizeof(tag), par->codec_tag);
avpriv_request_sample(s, "unknown or unsupported codec tag: %s", 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:
@@ -150,39 +150,39 @@ static 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_G726LE:
- codec->bits_per_coded_sample = 5;
+ par->bits_per_coded_sample = 5;
case AV_CODEC_ID_ADPCM_IMA_WS:
case AV_CODEC_ID_ADPCM_G722:
case AV_CODEC_ID_MACE6:
case AV_CODEC_ID_SDX2_DPCM:
- 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;
default:
aiff->block_duration = 1;
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 = (av_get_bits_per_sample(codec->codec_id) * codec->channels) >> 3;
+ if (!par->block_align)
+ par->block_align = (av_get_bits_per_sample(par->codec_id) * 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 */
@@ -238,7 +238,7 @@ static int aiff_read_header(AVFormatContext *s)
/* parse different chunks */
size = get_tag(pb, &tag);
- if (size == AVERROR_EOF && offset > 0 && st->codec->block_align) {
+ if (size == AVERROR_EOF && offset > 0 && st->codecpar->block_align) {
av_log(s, AV_LOG_WARNING, "header parser hit EOF\n");
goto got_sound;
}
@@ -288,7 +288,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 && !pb->seekable) /* Assume COMM already parsed */
+ if (st->codecpar->block_align && !pb->seekable) /* Assume COMM already parsed */
goto got_sound;
if (!pb->seekable) {
av_log(s, AV_LOG_ERROR, "file is not seekable\n");
@@ -299,26 +299,26 @@ static int aiff_read_header(AVFormatContext *s)
case MKTAG('w', 'a', 'v', 'e'):
if ((uint64_t)size > (1<<30))
return -1;
- if (ff_get_extradata(st->codec, pb, size) < 0)
+ if (ff_get_extradata(st->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
- if (st->codec->codec_id == AV_CODEC_ID_QDM2 && size>=12*4 && !st->codec->block_align) {
- st->codec->block_align = AV_RB32(st->codec->extradata+11*4);
- aiff->block_duration = AV_RB32(st->codec->extradata+9*4);
- } else if (st->codec->codec_id == AV_CODEC_ID_QCELP) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_QDM2 && size>=12*4 && !st->codecpar->block_align) {
+ st->codecpar->block_align = AV_RB32(st->codecpar->extradata+11*4);
+ aiff->block_duration = AV_RB32(st->codecpar->extradata+9*4);
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_QCELP) {
char rate = 0;
if (size >= 25)
- rate = st->codec->extradata[24];
+ rate = st->codecpar->extradata[24];
switch (rate) {
case 'H': // RATE_HALF
- st->codec->block_align = 17;
+ st->codecpar->block_align = 17;
break;
case 'F': // RATE_FULL
default:
- st->codec->block_align = 35;
+ st->codecpar->block_align = 35;
}
aiff->block_duration = 160;
- st->codec->bit_rate = st->codec->sample_rate * (st->codec->block_align << 3) /
- aiff->block_duration;
+ st->codecpar->bit_rate = st->codecpar->sample_rate * (st->codecpar->block_align << 3) /
+ aiff->block_duration;
}
break;
case MKTAG('C','H','A','N'):
@@ -326,7 +326,7 @@ static int aiff_read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
break;
case 0:
- if (offset > 0 && st->codec->block_align) // COMM && SSND
+ if (offset > 0 && st->codecpar->block_align) // COMM && SSND
goto got_sound;
default: /* Jump */
if (size & 1) /* Always even aligned */
@@ -336,13 +336,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;
@@ -368,26 +368,26 @@ static int aiff_read_packet(AVFormatContext *s,
return AVERROR_EOF;
/* Now for that packet */
- switch (st->codec->codec_id) {
+ switch (st->codecpar->codec_id) {
case AV_CODEC_ID_ADPCM_IMA_QT:
case AV_CODEC_ID_GSM:
case AV_CODEC_ID_QDM2:
case AV_CODEC_ID_QCELP:
- size = st->codec->block_align;
+ size = st->codecpar->block_align;
break;
default:
- 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)
return res;
- if (size >= st->codec->block_align)
+ if (size >= st->codecpar->block_align)
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
/* 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;
}
diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index 25dc5e6284..d876997f9b 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -102,16 +102,16 @@ static int aiff_write_header(AVFormatContext *s)
{
AIFFOutputContext *aiff = s->priv_data;
AVIOContext *pb = s->pb;
- AVCodecContext *enc;
+ AVCodecParameters *par;
uint64_t sample_rate;
int i, aifc = 0;
aiff->audio_stream_idx = -1;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
- if (aiff->audio_stream_idx < 0 && st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (aiff->audio_stream_idx < 0 && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
aiff->audio_stream_idx = i;
- } else if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO) {
+ } else if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) {
av_log(s, AV_LOG_ERROR, "AIFF allows only one audio stream and a picture.\n");
return AVERROR(EINVAL);
}
@@ -121,12 +121,12 @@ static int aiff_write_header(AVFormatContext *s)
return AVERROR(EINVAL);
}
- enc = s->streams[aiff->audio_stream_idx]->codec;
+ par = s->streams[aiff->audio_stream_idx]->codecpar;
/* 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 */
@@ -136,7 +136,7 @@ static int aiff_write_header(AVFormatContext *s)
ffio_wfourcc(pb, aifc ? "AIFC" : "AIFF");
if (aifc) { // compressed audio
- if (!enc->block_align) {
+ if (!par->block_align) {
av_log(s, AV_LOG_ERROR, "block align not set\n");
return -1;
}
@@ -146,10 +146,10 @@ static int aiff_write_header(AVFormatContext *s)
avio_wb32(pb, 0xA2805140);
}
- if (enc->channels > 2 && enc->channel_layout) {
+ if (par->channels > 2 && par->channel_layout) {
ffio_wfourcc(pb, "CHAN");
avio_wb32(pb, 12);
- ff_mov_write_chan(pb, enc->channel_layout);
+ ff_mov_write_chan(pb, par->channel_layout);
}
put_meta(s, "title", MKTAG('N', 'A', 'M', 'E'));
@@ -160,35 +160,35 @@ 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);
}
- if (enc->codec_tag == MKTAG('Q','D','M','2') && enc->extradata_size) {
+ if (par->codec_tag == MKTAG('Q','D','M','2') && par->extradata_size) {
ffio_wfourcc(pb, "wave");
- avio_wb32(pb, enc->extradata_size);
- avio_write(pb, enc->extradata, enc->extradata_size);
+ avio_wb32(pb, par->extradata_size);
+ avio_write(pb, par->extradata, par->extradata_size);
}
/* Sound data chunk */
@@ -199,7 +199,7 @@ static int aiff_write_header(AVFormatContext *s)
avio_wb32(pb, 0); /* Block-size (block align) */
avpriv_set_pts_info(s->streams[aiff->audio_stream_idx], 64, 1,
- s->streams[aiff->audio_stream_idx]->codec->sample_rate);
+ s->streams[aiff->audio_stream_idx]->codecpar->sample_rate);
/* Data is starting here */
avio_flush(pb);
@@ -217,7 +217,7 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt)
int ret;
AVPacketList *pict_list, *last;
- if (s->streams[pkt->stream_index]->codec->codec_type != AVMEDIA_TYPE_VIDEO)
+ if (s->streams[pkt->stream_index]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
return 0;
/* warn only once for each stream */
@@ -256,7 +256,7 @@ static int aiff_write_trailer(AVFormatContext *s)
AVIOContext *pb = s->pb;
AIFFOutputContext *aiff = s->priv_data;
AVPacketList *pict_list = aiff->pict_list;
- AVCodecContext *enc = s->streams[aiff->audio_stream_idx]->codec;
+ AVCodecParameters *par = s->streams[aiff->audio_stream_idx]->codecpar;
/* Chunks sizes must be even */
int64_t file_size, end_size;
@@ -269,7 +269,7 @@ static int aiff_write_trailer(AVFormatContext *s)
if (s->pb->seekable) {
/* 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);
diff --git a/libavformat/aixdec.c b/libavformat/aixdec.c
index 83395581a4..5f40d6bdcf 100644
--- a/libavformat/aixdec.c
+++ b/libavformat/aixdec.c
@@ -61,11 +61,11 @@ static int aix_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_ADPCM_ADX;
- st->codec->sample_rate = avio_rb32(s->pb);
- st->codec->channels = avio_r8(s->pb);
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_ADX;
+ st->codecpar->sample_rate = avio_rb32(s->pb);
+ st->codecpar->channels = avio_r8(s->pb);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
avio_skip(s->pb, 3);
}
@@ -77,7 +77,7 @@ static int aix_read_header(AVFormatContext *s)
if (size <= 8)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 8);
- ff_get_extradata(s->streams[i]->codec, s->pb, size - 8);
+ ff_get_extradata(s->streams[i]->codecpar, s->pb, size - 8);
}
return 0;
diff --git a/libavformat/amr.c b/libavformat/amr.c
index 137df110ef..c113e92191 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -42,13 +42,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;
@@ -94,25 +94,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);
AMRContext *amr = s->priv_data;
@@ -125,13 +125,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
};
@@ -145,13 +145,13 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt)
if (amr->cumulated_size < UINT64_MAX - size) {
amr->cumulated_size += size;
/* Both AMR formats have 50 frames per second */
- s->streams[0]->codec->bit_rate = amr->cumulated_size / ++amr->block_count * 8 * 50;
+ s->streams[0]->codecpar->bit_rate = amr->cumulated_size / ++amr->block_count * 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) {
diff --git a/libavformat/anm.c b/libavformat/anm.c
index 23200474bd..b31757ab0a 100644
--- a/libavformat/anm.c
+++ b/libavformat/anm.c
@@ -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;
diff --git a/libavformat/apc.c b/libavformat/apc.c
index 21bb514cd0..64c1c6db3e 100644
--- a/libavformat/apc.c
+++ b/libavformat/apc.c
@@ -46,28 +46,28 @@ 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);
/* initial predictor values for adpcm decoder */
- if (ff_get_extradata(st->codec, pb, 2 * 4) < 0)
+ if (ff_get_extradata(st->codecpar, pb, 2 * 4) < 0)
return AVERROR(ENOMEM);
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;
}
diff --git a/libavformat/ape.c b/libavformat/ape.c
index 3e819728cc..061f32866f 100644
--- a/libavformat/ape.c
+++ b/libavformat/ape.c
@@ -348,23 +348,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;
avpriv_set_pts_info(st, 64, 1, ape->samplerate);
- if (ff_alloc_extradata(st->codec, APE_EXTRADATA_SIZE))
+ if (ff_alloc_extradata(st->codecpar, APE_EXTRADATA_SIZE))
return AVERROR(ENOMEM);
- AV_WL16(st->codec->extradata + 0, ape->fileversion);
- AV_WL16(st->codec->extradata + 2, ape->compressiontype);
- AV_WL16(st->codec->extradata + 4, ape->formatflags);
+ 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++) {
diff --git a/libavformat/apetag.c b/libavformat/apetag.c
index 9d415b8b3e..53e076fb8b 100644
--- a/libavformat/apetag.c
+++ b/libavformat/apetag.c
@@ -89,16 +89,16 @@ 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 {
- if (ff_get_extradata(st->codec, s->pb, size) < 0)
+ if (ff_get_extradata(st->codecpar, s->pb, size) < 0)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
+ st->codecpar->codec_type = AVMEDIA_TYPE_ATTACHMENT;
}
} else {
value = av_malloc(size+1);
diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
index c6403a191d..bb17896ee5 100644
--- a/libavformat/apngdec.c
+++ b/libavformat/apngdec.c
@@ -122,9 +122,9 @@ end:
return AVPROBE_SCORE_MAX;
}
-static int append_extradata(AVCodecContext *s, AVIOContext *pb, int len)
+static int append_extradata(AVCodecParameters *par, AVIOContext *pb, int len)
{
- int previous_size = s->extradata_size;
+ int previous_size = par->extradata_size;
int new_size, ret;
uint8_t *new_extradata;
@@ -132,13 +132,13 @@ static int append_extradata(AVCodecContext *s, AVIOContext *pb, int len)
return AVERROR_INVALIDDATA;
new_size = previous_size + len;
- new_extradata = av_realloc(s->extradata, new_size + AV_INPUT_BUFFER_PADDING_SIZE);
+ new_extradata = av_realloc(par->extradata, new_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!new_extradata)
return AVERROR(ENOMEM);
- s->extradata = new_extradata;
- s->extradata_size = new_size;
+ par->extradata = new_extradata;
+ par->extradata_size = new_size;
- if ((ret = avio_read(pb, s->extradata + previous_size, len)) < 0)
+ if ((ret = avio_read(pb, par->extradata + previous_size, len)) < 0)
return ret;
return previous_size;
@@ -170,23 +170,23 @@ static int apng_read_header(AVFormatContext *s)
/* set the timebase to something large enough (1/100,000 of second)
* to hopefully cope with all sane frame durations */
avpriv_set_pts_info(st, 64, 1, 100000);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_APNG;
- st->codec->width = avio_rb32(pb);
- st->codec->height = avio_rb32(pb);
- if ((ret = av_image_check_size(st->codec->width, st->codec->height, 0, s)) < 0)
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_APNG;
+ st->codecpar->width = avio_rb32(pb);
+ st->codecpar->height = avio_rb32(pb);
+ if ((ret = av_image_check_size(st->codecpar->width, st->codecpar->height, 0, s)) < 0)
return ret;
/* extradata will contain every chunk up to the first fcTL (excluded) */
- st->codec->extradata = av_malloc(len + 12 + AV_INPUT_BUFFER_PADDING_SIZE);
- if (!st->codec->extradata)
+ st->codecpar->extradata = av_malloc(len + 12 + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
- st->codec->extradata_size = len + 12;
- AV_WB32(st->codec->extradata, len);
- AV_WL32(st->codec->extradata+4, tag);
- AV_WB32(st->codec->extradata+8, st->codec->width);
- AV_WB32(st->codec->extradata+12, st->codec->height);
- if ((ret = avio_read(pb, st->codec->extradata+16, 9)) < 0)
+ st->codecpar->extradata_size = len + 12;
+ AV_WB32(st->codecpar->extradata, len);
+ AV_WL32(st->codecpar->extradata+4, tag);
+ AV_WB32(st->codecpar->extradata+8, st->codecpar->width);
+ AV_WB32(st->codecpar->extradata+12, st->codecpar->height);
+ if ((ret = avio_read(pb, st->codecpar->extradata+16, 9)) < 0)
goto fail;
while (!avio_feof(pb)) {
@@ -218,11 +218,11 @@ static int apng_read_header(AVFormatContext *s)
switch (tag) {
case MKTAG('a', 'c', 'T', 'L'):
if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 ||
- (ret = append_extradata(st->codec, pb, len + 12)) < 0)
+ (ret = append_extradata(st->codecpar, pb, len + 12)) < 0)
goto fail;
acTL_found = 1;
- ctx->num_frames = AV_RB32(st->codec->extradata + ret + 8);
- ctx->num_play = AV_RB32(st->codec->extradata + ret + 12);
+ ctx->num_frames = AV_RB32(st->codecpar->extradata + ret + 8);
+ ctx->num_play = AV_RB32(st->codecpar->extradata + ret + 12);
av_log(s, AV_LOG_DEBUG, "num_frames: %"PRIu32", num_play: %"PRIu32"\n",
ctx->num_frames, ctx->num_play);
break;
@@ -236,15 +236,15 @@ static int apng_read_header(AVFormatContext *s)
return 0;
default:
if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 ||
- (ret = append_extradata(st->codec, pb, len + 12)) < 0)
+ (ret = append_extradata(st->codecpar, pb, len + 12)) < 0)
goto fail;
}
}
fail:
- if (st->codec->extradata_size) {
- av_freep(&st->codec->extradata);
- st->codec->extradata_size = 0;
+ if (st->codecpar->extradata_size) {
+ av_freep(&st->codecpar->extradata);
+ st->codecpar->extradata_size = 0;
}
return ret;
}
@@ -298,15 +298,15 @@ static int decode_fctl_chunk(AVFormatContext *s, APNGDemuxContext *ctx, AVPacket
dispose_op,
blend_op);
- if (width != s->streams[0]->codec->width ||
- height != s->streams[0]->codec->height ||
+ if (width != s->streams[0]->codecpar->width ||
+ height != s->streams[0]->codecpar->height ||
x_offset != 0 ||
y_offset != 0) {
if (sequence_number == 0 ||
- x_offset >= s->streams[0]->codec->width ||
- width > s->streams[0]->codec->width - x_offset ||
- y_offset >= s->streams[0]->codec->height ||
- height > s->streams[0]->codec->height - y_offset)
+ x_offset >= s->streams[0]->codecpar->width ||
+ width > s->streams[0]->codecpar->width - x_offset ||
+ y_offset >= s->streams[0]->codecpar->height ||
+ height > s->streams[0]->codecpar->height - y_offset)
return AVERROR_INVALIDDATA;
ctx->is_key_frame = 0;
} else {
@@ -400,7 +400,7 @@ static int apng_read_packet(AVFormatContext *s, AVPacket *pkt)
avio_seek(pb, -8, SEEK_CUR);
return AVERROR_EOF;
}
- if ((ret = avio_seek(pb, s->streams[0]->codec->extradata_size + 8, SEEK_SET)) < 0)
+ if ((ret = avio_seek(pb, s->streams[0]->codecpar->extradata_size + 8, SEEK_SET)) < 0)
return ret;
return 0;
default:
diff --git a/libavformat/apngenc.c b/libavformat/apngenc.c
index 4326a7cd3b..e25df2eb5e 100644
--- a/libavformat/apngenc.c
+++ b/libavformat/apngenc.c
@@ -80,8 +80,8 @@ static int apng_write_header(AVFormatContext *format_context)
APNGMuxContext *apng = format_context->priv_data;
if (format_context->nb_streams != 1 ||
- format_context->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO ||
- format_context->streams[0]->codec->codec_id != AV_CODEC_ID_APNG) {
+ format_context->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
+ format_context->streams[0]->codecpar->codec_id != AV_CODEC_ID_APNG) {
av_log(format_context, AV_LOG_ERROR,
"APNG muxer supports only a single video APNG stream.\n");
return AVERROR(EINVAL);
@@ -106,7 +106,7 @@ static void flush_packet(AVFormatContext *format_context, AVPacket *packet)
APNGMuxContext *apng = format_context->priv_data;
AVIOContext *io_context = format_context->pb;
AVStream *codec_stream = format_context->streams[0];
- AVCodecContext *codec_context = codec_stream->codec;
+ AVCodecParameters *codec_par = codec_stream->codecpar;
av_assert0(apng->prev_packet);
@@ -117,13 +117,13 @@ static void flush_packet(AVFormatContext *format_context, AVPacket *packet)
av_log(format_context, AV_LOG_INFO, "Only a single frame so saving as a normal PNG.\n");
// Write normal PNG headers without acTL chunk
- existing_acTL_chunk = apng_find_chunk(MKBETAG('a', 'c', 'T', 'L'), codec_context->extradata, codec_context->extradata_size);
+ existing_acTL_chunk = apng_find_chunk(MKBETAG('a', 'c', 'T', 'L'), codec_par->extradata, codec_par->extradata_size);
if (existing_acTL_chunk) {
uint8_t *chunk_after_acTL = existing_acTL_chunk + AV_RB32(existing_acTL_chunk) + 12;
- avio_write(io_context, codec_context->extradata, existing_acTL_chunk - codec_context->extradata);
- avio_write(io_context, chunk_after_acTL, codec_context->extradata + codec_context->extradata_size - chunk_after_acTL);
+ avio_write(io_context, codec_par->extradata, existing_acTL_chunk - codec_par->extradata);
+ avio_write(io_context, chunk_after_acTL, codec_par->extradata + codec_par->extradata_size - chunk_after_acTL);
} else {
- avio_write(io_context, codec_context->extradata, codec_context->extradata_size);
+ avio_write(io_context, codec_par->extradata, codec_par->extradata_size);
}
// Write frame data without fcTL chunk
@@ -142,9 +142,9 @@ static void flush_packet(AVFormatContext *format_context, AVPacket *packet)
uint8_t *existing_acTL_chunk;
// Write normal PNG headers
- avio_write(io_context, codec_context->extradata, codec_context->extradata_size);
+ avio_write(io_context, codec_par->extradata, codec_par->extradata_size);
- existing_acTL_chunk = apng_find_chunk(MKBETAG('a', 'c', 'T', 'L'), codec_context->extradata, codec_context->extradata_size);
+ existing_acTL_chunk = apng_find_chunk(MKBETAG('a', 'c', 'T', 'L'), codec_par->extradata, codec_par->extradata_size);
if (!existing_acTL_chunk) {
uint8_t buf[8];
// Write animation control header
diff --git a/libavformat/aqtitledec.c b/libavformat/aqtitledec.c
index 7c864c8e10..f0e840b0f7 100644
--- a/libavformat/aqtitledec.c
+++ b/libavformat/aqtitledec.c
@@ -58,8 +58,8 @@ static int aqt_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, aqt->frame_rate.den, aqt->frame_rate.num);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_TEXT;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_TEXT;
while (!avio_feof(s->pb)) {
char line[4096];
diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index 711341328d..2c81b138f2 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -281,8 +281,8 @@ static int asf_read_picture(AVFormatContext *s, int len)
goto fail;
}
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;
@@ -436,7 +436,7 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
type = AVMEDIA_TYPE_VIDEO;
} else if (!ff_guidcmp(&g, &ff_asf_jfif_media)) {
type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_MJPEG;
+ st->codecpar->codec_id = AV_CODEC_ID_MJPEG;
} else if (!ff_guidcmp(&g, &ff_asf_command_stream)) {
type = AVMEDIA_TYPE_DATA;
} else if (!ff_guidcmp(&g, &ff_asf_ext_stream_embed_stream_header)) {
@@ -470,18 +470,18 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
}
}
- st->codec->codec_type = type;
+ st->codecpar->codec_type = type;
if (type == AVMEDIA_TYPE_AUDIO) {
- int ret = ff_get_wav_header(s, pb, st->codec, type_specific_size, 0);
+ int ret = ff_get_wav_header(s, pb, st->codecpar, type_specific_size, 0);
if (ret < 0)
return ret;
if (is_dvr_ms_audio) {
// codec_id and codec_tag are unreliable in dvr_ms
// files. Set them later by probing stream.
st->request_probe = 1;
- st->codec->codec_tag = 0;
+ st->codecpar->codec_tag = 0;
}
- if (st->codec->codec_id == AV_CODEC_ID_AAC)
+ if (st->codecpar->codec_id == AV_CODEC_ID_AAC)
st->need_parsing = AVSTREAM_PARSE_NONE;
else
st->need_parsing = AVSTREAM_PARSE_FULL;
@@ -507,52 +507,52 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
avio_r8(pb);
avio_rl16(pb); /* size */
sizeX = avio_rl32(pb); /* size */
- st->codec->width = avio_rl32(pb);
- st->codec->height = avio_rl32(pb);
+ st->codecpar->width = avio_rl32(pb);
+ st->codecpar->height = avio_rl32(pb);
/* not available for asf */
avio_rl16(pb); /* panes */
- st->codec->bits_per_coded_sample = avio_rl16(pb); /* depth */
+ st->codecpar->bits_per_coded_sample = avio_rl16(pb); /* depth */
tag1 = avio_rl32(pb);
avio_skip(pb, 20);
if (sizeX > 40) {
- st->codec->extradata_size = ffio_limit(pb, sizeX - 40);
- st->codec->extradata = av_mallocz(st->codec->extradata_size +
+ st->codecpar->extradata_size = ffio_limit(pb, sizeX - 40);
+ st->codecpar->extradata = av_mallocz(st->codecpar->extradata_size +
AV_INPUT_BUFFER_PADDING_SIZE);
- if (!st->codec->extradata)
+ if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
- avio_read(pb, st->codec->extradata, st->codec->extradata_size);
+ avio_read(pb, st->codecpar->extradata, st->codecpar->extradata_size);
}
/* Extract palette from extradata if bpp <= 8 */
/* This code assumes that extradata contains only palette */
/* This is true for all paletted codecs implemented in libavcodec */
- if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) {
+ if (st->codecpar->extradata_size && (st->codecpar->bits_per_coded_sample <= 8)) {
#if HAVE_BIGENDIAN
int i;
- for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE) / 4; i++)
- asf_st->palette[i] = av_bswap32(((uint32_t *)st->codec->extradata)[i]);
+ for (i = 0; i < FFMIN(st->codecpar->extradata_size, AVPALETTE_SIZE) / 4; i++)
+ asf_st->palette[i] = av_bswap32(((uint32_t *)st->codecpar->extradata)[i]);
#else
- memcpy(asf_st->palette, st->codec->extradata,
- FFMIN(st->codec->extradata_size, AVPALETTE_SIZE));
+ memcpy(asf_st->palette, st->codecpar->extradata,
+ FFMIN(st->codecpar->extradata_size, AVPALETTE_SIZE));
#endif
asf_st->palette_changed = 1;
}
- st->codec->codec_tag = tag1;
- st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag1);
+ st->codecpar->codec_tag = tag1;
+ st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag1);
if (tag1 == MKTAG('D', 'V', 'R', ' ')) {
st->need_parsing = AVSTREAM_PARSE_FULL;
/* issue658 contains wrong w/h and MS even puts a fake seq header
* with wrong w/h in extradata while a correct one is in the stream.
* maximum lameness */
- st->codec->width =
- st->codec->height = 0;
- av_freep(&st->codec->extradata);
- st->codec->extradata_size = 0;
+ st->codecpar->width =
+ st->codecpar->height = 0;
+ av_freep(&st->codecpar->extradata);
+ st->codecpar->extradata_size = 0;
}
- if (st->codec->codec_id == AV_CODEC_ID_H264)
+ if (st->codecpar->codec_id == AV_CODEC_ID_H264)
st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
- if (st->codec->codec_id == AV_CODEC_ID_MPEG4)
+ if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4)
st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
}
pos2 = avio_tell(pb);
@@ -890,21 +890,21 @@ static int asf_read_header(AVFormatContext *s)
int stream_num = asf->asfid2avid[i];
if (stream_num >= 0) {
AVStream *st = s->streams[stream_num];
- if (!st->codec->bit_rate)
- st->codec->bit_rate = asf->stream_bitrates[i];
+ if (!st->codecpar->bit_rate)
+ st->codecpar->bit_rate = asf->stream_bitrates[i];
if (asf->dar[i].num > 0 && asf->dar[i].den > 0) {
av_reduce(&st->sample_aspect_ratio.num,
&st->sample_aspect_ratio.den,
asf->dar[i].num, asf->dar[i].den, INT_MAX);
} else if ((asf->dar[0].num > 0) && (asf->dar[0].den > 0) &&
// Use ASF container value if the stream doesn't set AR.
- (st->codec->codec_type == AVMEDIA_TYPE_VIDEO))
+ (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO))
av_reduce(&st->sample_aspect_ratio.num,
&st->sample_aspect_ratio.den,
asf->dar[0].num, asf->dar[0].den, INT_MAX);
- av_log(s, AV_LOG_TRACE, "i=%d, st->codec->codec_type:%d, asf->dar %d:%d sar=%d:%d\n",
- i, st->codec->codec_type, asf->dar[i].num, asf->dar[i].den,
+ av_log(s, AV_LOG_TRACE, "i=%d, st->codecpar->codec_type:%d, asf->dar %d:%d sar=%d:%d\n",
+ i, st->codecpar->codec_type, asf->dar[i].num, asf->dar[i].den,
st->sample_aspect_ratio.num, st->sample_aspect_ratio.den);
// copy and convert language codes to the frontend
@@ -1316,9 +1316,9 @@ static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
av_log(asf, AV_LOG_TRACE, "new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n",
asf->stream_index, asf->packet_key_frame,
asf_st->pkt.flags & AV_PKT_FLAG_KEY,
- s->streams[asf->stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO,
+ s->streams[asf->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO,
asf_st->packet_obj_size);
- if (s->streams[asf->stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+ if (s->streams[asf->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
asf->packet_key_frame = 1;
if (asf->packet_key_frame)
asf_st->pkt.flags |= AV_PKT_FLAG_KEY;
@@ -1371,7 +1371,7 @@ static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
/* test if whole packet is read */
if (asf_st->frag_offset == asf_st->pkt.size) {
// workaround for macroshit radio DVR-MS files
- if (s->streams[asf->stream_index]->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO &&
+ if (s->streams[asf->stream_index]->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO &&
asf_st->pkt.size > 100) {
int i;
for (i = 0; i < asf_st->pkt.size && !asf_st->pkt.data[i]; i++)
@@ -1492,7 +1492,7 @@ static void skip_to_key(AVFormatContext *s)
for (i = 0; i < 128; i++) {
int j = asf->asfid2avid[i];
ASFStream *asf_st = &asf->streams[i];
- if (j < 0 || s->streams[j]->codec->codec_type != AVMEDIA_TYPE_VIDEO)
+ if (j < 0 || s->streams[j]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
continue;
asf_st->skip_to_key = 1;
diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c
index 2320c661cd..1c564a8339 100644
--- a/libavformat/asfdec_o.c
+++ b/libavformat/asfdec_o.c
@@ -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, NULL);
- 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)) < 0)
+ if ((ret = ff_get_wav_header(s, pb, st->codecpar, ts_data_len, 0)) < 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;
}
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 66551ea373..cfa4fadc07 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -392,7 +392,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
int header_size, n, extra_size, extra_size2, wav_extra_size;
int has_title, has_aspect_ratio = 0;
int metadata_count;
- AVCodecContext *enc;
+ AVCodecParameters *par;
int64_t header_offset, cur_pos, hpos;
int bit_rate;
int64_t duration;
@@ -419,14 +419,14 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
bit_rate = 0;
for (n = 0; n < s->nb_streams; n++) {
AVDictionaryEntry *entry;
- 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;
- if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
- && enc->sample_aspect_ratio.num > 0
- && enc->sample_aspect_ratio.den > 0)
+ bit_rate += par->bit_rate;
+ if ( par->codec_type == AVMEDIA_TYPE_VIDEO
+ && par->sample_aspect_ratio.num > 0
+ && par->sample_aspect_ratio.den > 0)
has_aspect_ratio++;
entry = av_dict_get(s->streams[n]->metadata, "language", NULL, 0);
@@ -445,7 +445,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
asf->streams[n].stream_language_index = asf->nb_languages;
asf->nb_languages++;
}
- if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO)
audio_language_counts[asf->streams[n].stream_language_index]++;
}
} else {
@@ -509,7 +509,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
if (audio_language_counts[i]) {
avio_wl16(pb, audio_language_counts[i]);
for (n = 0; n < s->nb_streams; n++)
- if (asf->streams[n].stream_language_index == i && s->streams[n]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+ if (asf->streams[n].stream_language_index == i && s->streams[n]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
avio_wl16(pb, n + 1);
}
}
@@ -523,10 +523,10 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
es_pos = put_header(pb, &ff_asf_extended_stream_properties_object);
avio_wl64(pb, 0); /* start time */
avio_wl64(pb, 0); /* end time */
- avio_wl32(pb, s->streams[n]->codec->bit_rate); /* data bitrate bps */
+ avio_wl32(pb, s->streams[n]->codecpar->bit_rate); /* data bitrate bps */
avio_wl32(pb, 5000); /* buffer size ms */
avio_wl32(pb, 0); /* initial buffer fullness */
- avio_wl32(pb, s->streams[n]->codec->bit_rate); /* peak data bitrate */
+ avio_wl32(pb, s->streams[n]->codecpar->bit_rate); /* peak data bitrate */
avio_wl32(pb, 5000); /* maximum buffer size ms */
avio_wl32(pb, 0); /* max initial buffer fullness */
avio_wl32(pb, 0); /* max object size */
@@ -544,11 +544,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
hpos2 = put_header(pb, &ff_asf_metadata_header);
avio_wl16(pb, 2 * has_aspect_ratio);
for (n = 0; n < s->nb_streams; n++) {
- enc = s->streams[n]->codec;
- if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
- && enc->sample_aspect_ratio.num > 0
- && enc->sample_aspect_ratio.den > 0) {
- AVRational sar = enc->sample_aspect_ratio;
+ par = s->streams[n]->codecpar;
+ if ( par->codec_type == AVMEDIA_TYPE_VIDEO
+ && par->sample_aspect_ratio.num > 0
+ && par->sample_aspect_ratio.den > 0) {
+ AVRational sar = par->sample_aspect_ratio;
avio_wl16(pb, 0);
// the stream number is set like this below
avio_wl16(pb, n + 1);
@@ -620,11 +620,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 = 1;
- switch (enc->codec_type) {
+ switch (par->codec_type) {
case AVMEDIA_TYPE_AUDIO:
wav_extra_size = 0;
extra_size = 18 + wav_extra_size;
@@ -632,14 +632,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) {
ff_put_guid(pb, &ff_asf_audio_stream);
ff_put_guid(pb, &ff_asf_audio_conceal_spread);
} else {
@@ -653,9 +653,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, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
+ int wavsize = ff_put_wav_header(s, pb, par, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
if (wavsize < 0)
return -1;
@@ -667,23 +667,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, 0);
+ ff_put_bmp_header(pb, par, ff_codec_bmp_tags, 1, 0);
}
end_header(pb, hpos);
}
@@ -697,17 +697,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;
@@ -732,14 +732,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);
@@ -963,7 +963,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;
}
@@ -1053,7 +1053,7 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
ASFStream *stream;
- AVCodecContext *codec;
+ AVCodecParameters *par;
uint32_t packet_number;
int64_t pts;
int start_sec;
@@ -1061,10 +1061,10 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
int ret;
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;
diff --git a/libavformat/assdec.c b/libavformat/assdec.c
index 21148b60f9..d89c14e5b8 100644
--- a/libavformat/assdec.c
+++ b/libavformat/assdec.c
@@ -121,8 +121,8 @@ static int ass_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 100);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_ASS;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_ASS;
av_bprint_init(&header, 0, AV_BPRINT_SIZE_UNLIMITED);
av_bprint_init(&line, 0, AV_BPRINT_SIZE_UNLIMITED);
@@ -153,7 +153,7 @@ static int ass_read_header(AVFormatContext *s)
sub->duration = duration;
}
- res = avpriv_bprint_to_extradata(st->codec, &header);
+ res = ff_bprint_to_codecpar_extradata(st->codecpar, &header);
if (res < 0)
goto end;
diff --git a/libavformat/assenc.c b/libavformat/assenc.c
index 9a107aab7c..d50f18feb1 100644
--- a/libavformat/assenc.c
+++ b/libavformat/assenc.c
@@ -46,16 +46,16 @@ 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;
- if (s->nb_streams != 1 || avctx->codec_id != AV_CODEC_ID_ASS) {
+ if (s->nb_streams != 1 || par->codec_id != AV_CODEC_ID_ASS) {
av_log(s, AV_LOG_ERROR, "Exactly one ASS/SSA stream is needed.\n");
return AVERROR(EINVAL);
}
avpriv_set_pts_info(s->streams[0], 64, 1, 100);
- if (avctx->extradata_size > 0) {
- size_t header_size = avctx->extradata_size;
- uint8_t *trailer = strstr(avctx->extradata, "\n[Events]");
+ if (par->extradata_size > 0) {
+ size_t header_size = par->extradata_size;
+ uint8_t *trailer = strstr(par->extradata, "\n[Events]");
if (trailer)
trailer = strstr(trailer, "Format:");
@@ -63,17 +63,17 @@ static int write_header(AVFormatContext *s)
trailer = strstr(trailer, "\n");
if (trailer++) {
- header_size = (trailer - avctx->extradata);
- ass->trailer_size = avctx->extradata_size - header_size;
+ header_size = (trailer - par->extradata);
+ ass->trailer_size = par->extradata_size - header_size;
if (ass->trailer_size)
ass->trailer = trailer;
}
- avio_write(s->pb, avctx->extradata, header_size);
- if (avctx->extradata[header_size - 1] != '\n')
+ avio_write(s->pb, par->extradata, header_size);
+ if (par->extradata[header_size - 1] != '\n')
avio_write(s->pb, "\r\n", 2);
- ass->ssa_mode = !strstr(avctx->extradata, "\n[V4+ Styles]");
- if (!strstr(avctx->extradata, "\n[Events]"))
+ ass->ssa_mode = !strstr(par->extradata, "\n[V4+ Styles]");
+ if (!strstr(par->extradata, "\n[Events]"))
avio_printf(s->pb, "[Events]\r\nFormat: %s, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\r\n",
ass->ssa_mode ? "Marked" : "Layer");
}
diff --git a/libavformat/astdec.c b/libavformat/astdec.c
index 92c208d044..f3ca721ccf 100644
--- a/libavformat/astdec.c
+++ b/libavformat/astdec.c
@@ -48,8 +48,8 @@ static int ast_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avio_skip(s->pb, 8);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = ff_codec_get_id(ff_codec_ast_tags, avio_rb16(s->pb));
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = ff_codec_get_id(ff_codec_ast_tags, avio_rb16(s->pb));
depth = avio_rb16(s->pb);
if (depth != 16) {
@@ -57,23 +57,23 @@ static int ast_read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
- st->codec->channels = avio_rb16(s->pb);
- if (!st->codec->channels)
+ st->codecpar->channels = avio_rb16(s->pb);
+ if (!st->codecpar->channels)
return AVERROR_INVALIDDATA;
- if (st->codec->channels == 2)
- st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
- else if (st->codec->channels == 4)
- st->codec->channel_layout = AV_CH_LAYOUT_4POINT0;
+ if (st->codecpar->channels == 2)
+ st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+ else if (st->codecpar->channels == 4)
+ st->codecpar->channel_layout = AV_CH_LAYOUT_4POINT0;
avio_skip(s->pb, 2);
- st->codec->sample_rate = avio_rb32(s->pb);
- if (st->codec->sample_rate <= 0)
+ st->codecpar->sample_rate = avio_rb32(s->pb);
+ if (st->codecpar->sample_rate <= 0)
return AVERROR_INVALIDDATA;
st->start_time = 0;
st->duration = avio_rb32(s->pb);
avio_skip(s->pb, 40);
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
@@ -90,10 +90,10 @@ static int ast_read_packet(AVFormatContext *s, AVPacket *pkt)
pos = avio_tell(s->pb);
type = avio_rl32(s->pb);
size = avio_rb32(s->pb);
- if (size > INT_MAX / s->streams[0]->codec->channels)
+ if (size > INT_MAX / s->streams[0]->codecpar->channels)
return AVERROR_INVALIDDATA;
- size *= s->streams[0]->codec->channels;
+ size *= s->streams[0]->codecpar->channels;
if ((ret = avio_skip(s->pb, 24)) < 0) // padding
return ret;
diff --git a/libavformat/astenc.c b/libavformat/astenc.c
index cf7a12c95d..11f8717495 100644
--- a/libavformat/astenc.c
+++ b/libavformat/astenc.c
@@ -37,7 +37,7 @@ typedef struct ASTMuxContext {
#define CHECK_LOOP(type) \
if (ast->loop ## type > 0) { \
- ast->loop ## type = av_rescale_rnd(ast->loop ## type, enc->sample_rate, 1000, AV_ROUND_DOWN); \
+ ast->loop ## type = av_rescale_rnd(ast->loop ## type, par->sample_rate, 1000, AV_ROUND_DOWN); \
if (ast->loop ## type < 0 || ast->loop ## type > UINT_MAX) { \
av_log(s, AV_LOG_ERROR, "Invalid loop" #type " value\n"); \
return AVERROR(EINVAL); \
@@ -48,22 +48,22 @@ static int ast_write_header(AVFormatContext *s)
{
ASTMuxContext *ast = s->priv_data;
AVIOContext *pb = s->pb;
- AVCodecContext *enc;
+ AVCodecParameters *par;
unsigned int codec_tag;
if (s->nb_streams == 1) {
- enc = s->streams[0]->codec;
+ par = s->streams[0]->codecpar;
} else {
av_log(s, AV_LOG_ERROR, "only one stream is supported\n");
return AVERROR(EINVAL);
}
- if (enc->codec_id == AV_CODEC_ID_ADPCM_AFC) {
+ if (par->codec_id == AV_CODEC_ID_ADPCM_AFC) {
av_log(s, AV_LOG_ERROR, "muxing ADPCM AFC is not implemented\n");
return AVERROR_PATCHWELCOME;
}
- codec_tag = ff_codec_get_tag(ff_codec_ast_tags, enc->codec_id);
+ codec_tag = ff_codec_get_tag(ff_codec_ast_tags, par->codec_id);
if (!codec_tag) {
av_log(s, AV_LOG_ERROR, "unsupported codec\n");
return AVERROR(EINVAL);
@@ -84,9 +84,9 @@ static int ast_write_header(AVFormatContext *s)
avio_wb32(pb, 0); /* File size minus header */
avio_wb16(pb, codec_tag);
avio_wb16(pb, 16); /* Bit depth */
- avio_wb16(pb, enc->channels);
+ avio_wb16(pb, par->channels);
avio_wb16(pb, 0); /* Loop flag */
- avio_wb32(pb, enc->sample_rate);
+ avio_wb32(pb, par->sample_rate);
ast->samples = avio_tell(pb);
avio_wb32(pb, 0); /* Number of samples */
@@ -110,8 +110,8 @@ static int ast_write_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIOContext *pb = s->pb;
ASTMuxContext *ast = s->priv_data;
- AVCodecContext *enc = s->streams[0]->codec;
- int size = pkt->size / enc->channels;
+ AVCodecParameters *par = s->streams[0]->codecpar;
+ int size = pkt->size / par->channels;
if (s->streams[0]->nb_frames == 0)
ast->fbs = size;
@@ -133,9 +133,9 @@ static int ast_write_trailer(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
ASTMuxContext *ast = s->priv_data;
- AVCodecContext *enc = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
int64_t file_size = avio_tell(pb);
- int64_t samples = (file_size - 64 - (32 * s->streams[0]->nb_frames)) / enc->block_align; /* PCM_S16BE_PLANAR */
+ int64_t samples = (file_size - 64 - (32 * s->streams[0]->nb_frames)) / par->block_align; /* PCM_S16BE_PLANAR */
av_log(s, AV_LOG_DEBUG, "total samples: %"PRId64"\n", samples);
diff --git a/libavformat/au.c b/libavformat/au.c
index 53702bcb42..67af2bfb89 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -132,16 +132,16 @@ 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->bits_per_coded_sample = bps;
- st->codec->bit_rate = channels * rate * bps;
- st->codec->block_align = FFMAX(bps * st->codec->channels / 8, 1);
+ 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->bits_per_coded_sample = bps;
+ st->codecpar->bit_rate = channels * rate * bps;
+ st->codecpar->block_align = FFMAX(bps * st->codecpar->channels / 8, 1);
if (data_size != AU_UNKNOWN_SIZE)
- st->duration = (((int64_t)data_size)<<3) / (st->codec->channels * (int64_t)bps);
+ st->duration = (((int64_t)data_size)<<3) / (st->codecpar->channels * (int64_t)bps);
st->start_time = 0;
avpriv_set_pts_info(st, 64, 1, rate);
@@ -168,15 +168,15 @@ AVInputFormat ff_au_demuxer = {
static int au_write_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
- AVCodecContext *enc = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
if (s->nb_streams != 1) {
av_log(s, AV_LOG_ERROR, "only one stream is supported\n");
return AVERROR(EINVAL);
}
- enc->codec_tag = ff_codec_get_tag(codec_au_tags, enc->codec_id);
- if (!enc->codec_tag) {
+ par->codec_tag = ff_codec_get_tag(codec_au_tags, par->codec_id);
+ if (!par->codec_tag) {
av_log(s, AV_LOG_ERROR, "unsupported codec\n");
return AVERROR(EINVAL);
}
@@ -184,9 +184,9 @@ static int au_write_header(AVFormatContext *s)
ffio_wfourcc(pb, ".snd"); /* magic number */
avio_wb32(pb, AU_HEADER_SIZE); /* 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);
avio_wb64(pb, 0); /* annotation field */
avio_flush(pb);
diff --git a/libavformat/audiointerleave.c b/libavformat/audiointerleave.c
index 6d1401d721..6d4954befe 100644
--- a/libavformat/audiointerleave.c
+++ b/libavformat/audiointerleave.c
@@ -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_freep(&aic->fifo);
}
}
@@ -55,9 +55,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 AVERROR(EINVAL);
@@ -111,7 +111,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)
@@ -131,7 +131,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 ((ret = interleave_new_audio_packet(s, &new_pkt, i, flush)) > 0) {
if ((ret = ff_interleave_add_packet(s, &new_pkt, compare_ts)) < 0)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 5e918a04c3..02113f5c7b 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -872,18 +872,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
@@ -990,6 +985,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
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 8ce07ab310..87c9bd4951 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -385,11 +385,11 @@ static void avi_read_nikon(AVFormatContext *s, uint64_t end)
}
}
-static int avi_extract_stream_metadata(AVStream *st)
+static int avi_extract_stream_metadata(AVFormatContext *s, AVStream *st)
{
GetByteContext gb;
- uint8_t *data = st->codec->extradata;
- int data_size = st->codec->extradata_size;
+ uint8_t *data = st->codecpar->extradata;
+ int data_size = st->codecpar->extradata_size;
int tag, offset;
if (!data || data_size < 8) {
@@ -408,13 +408,13 @@ static int avi_extract_stream_metadata(AVStream *st)
bytestream2_init(&gb, data + offset, data_size - offset);
// decode EXIF tags from IFD, AVI is always little-endian
- return avpriv_exif_decode_ifd(st->codec, &gb, 1, 0, &st->metadata);
+ return avpriv_exif_decode_ifd(s, &gb, 1, 0, &st->metadata);
break;
case MKTAG('C', 'A', 'S', 'I'):
- avpriv_request_sample(st->codec, "RIFF stream data tag type CASI (%u)", tag);
+ avpriv_request_sample(s, "RIFF stream data tag type CASI (%u)", tag);
break;
case MKTAG('Z', 'o', 'r', 'a'):
- avpriv_request_sample(st->codec, "RIFF stream data tag type Zora (%u)", tag);
+ avpriv_request_sample(s, "RIFF stream data tag type Zora (%u)", tag);
break;
default:
break;
@@ -456,12 +456,12 @@ static int calculate_bitrate(AVFormatContext *s)
for (j = 0; j < st->nb_index_entries; j++)
len += st->index_entries[j].size;
- if (st->nb_index_entries < 2 || st->codec->bit_rate > 0)
+ if (st->nb_index_entries < 2 || st->codecpar->bit_rate > 0)
continue;
duration = st->index_entries[j-1].timestamp - st->index_entries[0].timestamp;
bitrate = av_rescale(8*len, st->time_base.den, duration * st->time_base.num);
if (bitrate <= INT_MAX && bitrate > 0) {
- st->codec->bit_rate = bitrate;
+ st->codecpar->bit_rate = bitrate;
}
}
return 1;
@@ -603,8 +603,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);
if (s->streams[0]->info)
av_freep(&s->streams[0]->info->duration_error);
av_freep(&s->streams[0]->info);
@@ -733,17 +733,17 @@ static int avi_read_header(AVFormatContext *s)
if (cur_pos < list_end)
size = FFMIN(size, list_end - cur_pos);
st = s->streams[stream_index];
- if (st->codec->codec_type != AVMEDIA_TYPE_UNKNOWN) {
+ if (st->codecpar->codec_type != AVMEDIA_TYPE_UNKNOWN) {
avio_skip(pb, size);
break;
}
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;
}
@@ -751,40 +751,40 @@ 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) && size < avi->fsize) {
if (esize == size-1 && (esize&1)) {
- st->codec->extradata_size = esize - 10 * 4;
+ st->codecpar->extradata_size = esize - 10 * 4;
} else
- st->codec->extradata_size = size - 10 * 4;
- if (ff_get_extradata(st->codec, pb, st->codec->extradata_size) < 0)
+ st->codecpar->extradata_size = size - 10 * 4;
+ if (ff_get_extradata(st->codecpar, pb, st->codecpar->extradata_size) < 0)
return AVERROR(ENOMEM);
}
// 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
* FFmpeg. */
- 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;
/* Exclude the "BottomUp" field from the palette */
- if (pal_src - st->codec->extradata >= 9 &&
- !memcmp(st->codec->extradata + st->codec->extradata_size - 9, "BottomUp", 9))
+ if (pal_src - st->codecpar->extradata >= 9 &&
+ !memcmp(st->codecpar->extradata + st->codecpar->extradata_size - 9, "BottomUp", 9))
pal_src -= 9;
for (i = 0; i < pal_size / 4; i++)
ast->pal[i] = 0xFFU<<24 | AV_RL32(pal_src+4*i);
@@ -793,17 +793,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);
@@ -812,44 +812,44 @@ 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');
- if (st->codec->codec_tag == MKTAG('V', 'S', 'S', 'H'))
+ if (st->codecpar->codec_tag == MKTAG('V', 'S', 'S', 'H'))
st->need_parsing = AVSTREAM_PARSE_FULL;
- if (st->codec->codec_id == AV_CODEC_ID_RV40)
+ if (st->codecpar->codec_id == AV_CODEC_ID_RV40)
st->need_parsing = AVSTREAM_PARSE_NONE;
- 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 +
+ 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, 0);
+ ret = ff_get_wav_header(s, pb, st->codecpar, size, 0);
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) */
@@ -861,45 +861,45 @@ 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;
// The flac parser does not work with AVSTREAM_PARSE_TIMESTAMPS
- if (st->codec->codec_id == AV_CODEC_ID_FLAC)
+ if (st->codecpar->codec_id == AV_CODEC_ID_FLAC)
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;
ast->dshow_block_align = 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;
}
- if ((st->codec->codec_id == AV_CODEC_ID_AAC ||
- st->codec->codec_id == AV_CODEC_ID_FLAC ||
- st->codec->codec_id == AV_CODEC_ID_MP2 ) && ast->dshow_block_align <= 4 && ast->dshow_block_align) {
+ if ((st->codecpar->codec_id == AV_CODEC_ID_AAC ||
+ st->codecpar->codec_id == AV_CODEC_ID_FLAC ||
+ st->codecpar->codec_id == AV_CODEC_ID_MP2 ) && ast->dshow_block_align <= 4 && ast->dshow_block_align) {
av_log(s, AV_LOG_DEBUG, "overriding invalid dshow_block_align of %d\n", ast->dshow_block_align);
ast->dshow_block_align = 0;
}
- if (st->codec->codec_id == AV_CODEC_ID_AAC && ast->dshow_block_align == 1024 && ast->sample_size == 1024 ||
- st->codec->codec_id == AV_CODEC_ID_AAC && ast->dshow_block_align == 4096 && ast->sample_size == 4096 ||
- st->codec->codec_id == AV_CODEC_ID_MP3 && ast->dshow_block_align == 1152 && ast->sample_size == 1152) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_AAC && ast->dshow_block_align == 1024 && ast->sample_size == 1024 ||
+ st->codecpar->codec_id == AV_CODEC_ID_AAC && ast->dshow_block_align == 4096 && ast->sample_size == 4096 ||
+ st->codecpar->codec_id == AV_CODEC_ID_MP3 && ast->dshow_block_align == 1152 && ast->sample_size == 1152) {
av_log(s, AV_LOG_DEBUG, "overriding sample_size\n");
ast->sample_size = 0;
}
break;
case AVMEDIA_TYPE_SUBTITLE:
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->request_probe= 1;
avio_skip(pb, size);
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;
}
@@ -907,8 +907,8 @@ static int avi_read_header(AVFormatContext *s)
break;
case MKTAG('s', 't', 'r', 'd'):
if (stream_index >= (unsigned)s->nb_streams
- || s->streams[stream_index]->codec->extradata_size
- || s->streams[stream_index]->codec->codec_tag == MKTAG('H','2','6','4')) {
+ || s->streams[stream_index]->codecpar->extradata_size
+ || s->streams[stream_index]->codecpar->codec_tag == MKTAG('H','2','6','4')) {
avio_skip(pb, size);
} else {
uint64_t cur_pos = avio_tell(pb);
@@ -917,14 +917,14 @@ static int avi_read_header(AVFormatContext *s)
st = s->streams[stream_index];
if (size<(1<<30)) {
- if (ff_get_extradata(st->codec, pb, size) < 0)
+ if (ff_get_extradata(st->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
}
- if (st->codec->extradata_size & 1) //FIXME check if the encoder really did this correctly
+ if (st->codecpar->extradata_size & 1) //FIXME check if the encoder really did this correctly
avio_r8(pb);
- ret = avi_extract_stream_metadata(st);
+ ret = avi_extract_stream_metadata(s, st);
if (ret < 0) {
av_log(s, AV_LOG_WARNING, "could not decoding EXIF data in stream header.\n");
}
@@ -1014,8 +1014,8 @@ fail:
if (dict_entry && !strcmp(dict_entry->value, "PotEncoder"))
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
- if ( st->codec->codec_id == AV_CODEC_ID_MPEG1VIDEO
- || st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO)
+ if ( st->codecpar->codec_id == AV_CODEC_ID_MPEG1VIDEO
+ || st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO)
st->need_parsing = AVSTREAM_PARSE_FULL;
}
@@ -1094,8 +1094,7 @@ static int read_gab2_sub(AVFormatContext *s, AVStream *st, AVPacket *pkt)
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);
}
@@ -1232,8 +1231,8 @@ start_sync:
// 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)
) {
@@ -1443,8 +1442,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(s, st, pkt)) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE &&
+ !st->codecpar->codec_tag && read_gab2_sub(s, st, pkt)) {
ast->frame_offset++;
avi->stream_index = -1;
ast->remaining = 0;
@@ -1468,7 +1467,7 @@ resync:
size);
pkt->stream_index = avi->stream_index;
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->index_entries) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->index_entries) {
AVIndexEntry *e;
int index;
@@ -1479,7 +1478,7 @@ resync:
if (index == st->nb_index_entries-1) {
int key=1;
uint32_t state=-1;
- if (st->codec->codec_id == AV_CODEC_ID_MPEG4) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4) {
const uint8_t *ptr = pkt->data, *end = ptr + FFMIN(size, 256);
while (ptr < end) {
ptr = avpriv_find_start_code(ptr, end, &state);
@@ -1557,7 +1556,7 @@ static int avi_read_idx1(AVFormatContext *s, int size)
avi->stream_index = -1;
avio_seek(pb, idx1_pos, SEEK_SET);
- if (s->nb_streams == 1 && s->streams[0]->codec->codec_tag == AV_RL32("MMES")) {
+ if (s->nb_streams == 1 && s->streams[0]->codecpar->codec_tag == AV_RL32("MMES")) {
first_packet_pos = 0;
data_offset = avi->movi_list;
}
@@ -1661,7 +1660,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));
}
}
@@ -1847,7 +1846,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
if (st2->nb_index_entries <= 0)
continue;
-// av_assert1(st2->codec->block_align);
+// av_assert1(st2->codecpar->block_align);
av_assert0(fabs(av_q2d(st2->time_base) - ast2->scale / (double)ast2->rate) < av_q2d(st2->time_base) * 0.00000001);
index = av_index_search_timestamp(st2,
av_rescale_q(timestamp,
@@ -1856,7 +1855,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
FFMAX(ast2->sample_size, 1),
flags |
AVSEEK_FLAG_BACKWARD |
- (st2->codec->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
+ (st2->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
if (index < 0)
index = 0;
ast2->seek_pos = st2->index_entries[index].pos;
@@ -1872,7 +1871,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
index = av_index_search_timestamp(
st2,
av_rescale_q(timestamp, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1),
- flags | AVSEEK_FLAG_BACKWARD | (st2->codec->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
+ flags | AVSEEK_FLAG_BACKWARD | (st2->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
if (index < 0)
index = 0;
while (!avi->non_interleaved && index>0 && st2->index_entries[index-1].pos >= pos_min)
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 7a7abb8718..c908c21e4f 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -180,21 +180,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;
av_assert0(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) {
@@ -211,7 +211,7 @@ static void write_odml_master(AVFormatContext *s, int stream_index)
{
AVIOContext *pb = s->pb;
AVStream *st = s->streams[stream_index];
- AVCodecContext *enc = st->codec;
+ AVCodecParameters *par = st->codecpar;
AVIStream *avist = st->priv_data;
unsigned char tag[5];
int j;
@@ -225,7 +225,7 @@ static void write_odml_master(AVFormatContext *s, int stream_index)
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, stream_index, enc->codec_type));
+ ffio_wfourcc(pb, avi_stream2fourcc(tag, stream_index, par->codec_type));
/* dwChunkId */
avio_wl64(pb, 0); /* dwReserved[3] */
avio_wl32(pb, 0); /* Must be 0. */
@@ -239,7 +239,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;
@@ -266,12 +266,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];
}
}
@@ -295,9 +295,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);
@@ -310,18 +310,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;
@@ -339,9 +339,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);
avist->strh_flags_offset = avio_tell(pb);
@@ -352,14 +352,14 @@ static int avi_write_header(AVFormatContext *s)
ff_parse_specific_params(st, &au_byterate, &au_ssize, &au_scale);
- if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
- && enc->codec_id != AV_CODEC_ID_XSUB
+ if ( par->codec_type == AVMEDIA_TYPE_VIDEO
+ && par->codec_id != AV_CODEC_ID_XSUB
&& au_byterate > 1000LL*au_scale) {
au_byterate = 600;
au_scale = 1;
}
avpriv_set_pts_info(st, 64, au_scale, au_byterate);
- if (enc->codec_id == AV_CODEC_ID_XSUB)
+ if (par->codec_id == AV_CODEC_ID_XSUB)
au_scale = au_byterate = 0;
avio_wl32(pb, au_scale); /* scale */
@@ -375,57 +375,57 @@ static int avi_write_header(AVFormatContext *s)
avio_wl32(pb, 0); /* length, XXX: filled later */
/* suggested buffer size, is set to largest chunk size in avi_write_trailer */
- 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) {
int ret, flags;
enum AVPixelFormat pix_fmt;
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:
/* WMP expects RGB 5:5:5 rawvideo in avi to have bpp set to 16. */
- if ( !enc->codec_tag
- && enc->codec_id == AV_CODEC_ID_RAWVIDEO
- && enc->pix_fmt == AV_PIX_FMT_RGB555LE
- && enc->bits_per_coded_sample == 15)
- enc->bits_per_coded_sample = 16;
+ if ( !par->codec_tag
+ && par->codec_id == AV_CODEC_ID_RAWVIDEO
+ && par->format == AV_PIX_FMT_RGB555LE
+ && par->bits_per_coded_sample == 15)
+ par->bits_per_coded_sample = 16;
avist->pal_offset = avio_tell(pb) + 40;
- ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 0, 0);
+ ff_put_bmp_header(pb, par, ff_codec_bmp_tags, 0, 0);
pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
- enc->bits_per_coded_sample);
- if ( !enc->codec_tag
- && enc->codec_id == AV_CODEC_ID_RAWVIDEO
- && enc->pix_fmt != pix_fmt
- && enc->pix_fmt != AV_PIX_FMT_NONE)
+ par->bits_per_coded_sample);
+ if ( !par->codec_tag
+ && par->codec_id == AV_CODEC_ID_RAWVIDEO
+ && par->format != pix_fmt
+ && par->format != AV_PIX_FMT_NONE)
av_log(s, AV_LOG_ERROR, "%s rawvideo cannot be written to avi, output file will be unreadable\n",
- av_get_pix_fmt_name(enc->pix_fmt));
+ av_get_pix_fmt_name(par->format));
break;
case AVMEDIA_TYPE_AUDIO:
flags = (avi->write_channel_mask == 0) ? FF_PUT_WAV_HEADER_SKIP_CHANNELMASK : 0;
- if ((ret = ff_put_wav_header(pb, enc, flags)) < 0)
+ if ((ret = ff_put_wav_header(s, pb, par, flags)) < 0)
return ret;
break;
default:
av_log(s, AV_LOG_ERROR,
"Invalid or not supported codec type '%s' found in the input\n",
- (char *)av_x_if_null(av_get_media_type_string(enc->codec_type), "?"));
+ (char *)av_x_if_null(av_get_media_type_string(par->codec_type), "?"));
return AVERROR(EINVAL);
}
ff_end_tag(pb, strf);
@@ -433,7 +433,7 @@ static int avi_write_header(AVFormatContext *s)
ff_riff_write_info_tag(s->pb, "strn", t->value);
t = NULL;
}
- if (enc->codec_id == AV_CODEC_ID_XSUB
+ if (par->codec_id == AV_CODEC_ID_XSUB
&& (t = av_dict_get(s->streams[i]->metadata, "language", NULL, 0))) {
const char* langstr = av_convert_lang_to(t->value, AV_LANG_ISO639_1);
t = NULL;
@@ -451,13 +451,13 @@ static int avi_write_header(AVFormatContext *s)
write_odml_master(s, i);
}
- 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);
@@ -465,18 +465,18 @@ static int avi_write_header(AVFormatContext *s)
avio_wl32(pb, 0); // video standard = unknown
// TODO: should be avg_frame_rate
avio_wl32(pb, (2LL*st->time_base.den + st->time_base.num - 1) / (2LL * st->time_base.num));
- 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);
@@ -544,7 +544,7 @@ static void update_odml_entry(AVFormatContext *s, int stream_index, int64_t ix,
avio_wl64(pb, ix); /* qwOffset */
avio_wl32(pb, size); /* dwSize */
ff_parse_specific_params(s->streams[stream_index], &au_byterate, &au_ssize, &au_scale);
- if (s->streams[stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO && au_ssize > 0) {
+ if (s->streams[stream_index]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && au_ssize > 0) {
uint32_t audio_segm_size = (avist->audio_strm_length - avist->indexes.audio_strm_offset);
if ((audio_segm_size % au_ssize > 0) && !avist->sample_requested) {
avpriv_request_sample(s, "OpenDML index duration for audio packets with partial frames");
@@ -586,7 +586,7 @@ static int avi_write_ix(AVFormatContext *s)
AVIStream *avist = s->streams[i]->priv_data;
int64_t ix;
- 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 */
@@ -654,7 +654,7 @@ static int avi_write_idx1(AVFormatContext *s)
ffio_wfourcc(pb, ie->tag);
else {
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);
@@ -673,11 +673,11 @@ static int avi_write_idx1(AVFormatContext *s)
static int write_skip_frames(AVFormatContext *s, int stream_index, int64_t dts)
{
AVIStream *avist = s->streams[stream_index]->priv_data;
- AVCodecContext *enc = s->streams[stream_index]->codec;
+ AVCodecParameters *par = s->streams[stream_index]->codecpar;
ff_dlog(s, "dts:%s packet_count:%d stream_index:%d\n", av_ts2str(dts), avist->packet_count, stream_index);
- while (enc->block_align == 0 && dts != AV_NOPTS_VALUE &&
- dts > avist->packet_count && enc->codec_id != AV_CODEC_ID_XSUB && avist->packet_count) {
+ while (par->block_align == 0 && dts != AV_NOPTS_VALUE &&
+ dts > avist->packet_count && par->codec_id != AV_CODEC_ID_XSUB && avist->packet_count) {
AVPacket empty_packet;
if (dts - avist->packet_count > 60000) {
@@ -699,10 +699,10 @@ static int write_skip_frames(AVFormatContext *s, int stream_index, int64_t dts)
static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
{
const int stream_index = pkt->stream_index;
- AVCodecContext *enc = s->streams[stream_index]->codec;
+ AVCodecParameters *par = s->streams[stream_index]->codecpar;
int ret;
- if (enc->codec_id == AV_CODEC_ID_H264 && enc->codec_tag == MKTAG('H','2','6','4') && pkt->size) {
+ if (par->codec_id == AV_CODEC_ID_H264 && par->codec_tag == MKTAG('H','2','6','4') && pkt->size) {
ret = ff_check_h264_startcode(s, s->streams[stream_index], pkt);
if (ret < 0)
return ret;
@@ -714,27 +714,27 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
if (!pkt->size)
return avi_write_packet_internal(s, pkt); /* Passthrough */
- if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (par->codec_type == AVMEDIA_TYPE_VIDEO) {
AVIStream *avist = s->streams[stream_index]->priv_data;
AVIOContext *pb = s->pb;
AVPacket *opkt = pkt;
- if (enc->codec_id == AV_CODEC_ID_RAWVIDEO && enc->codec_tag == 0) {
- int64_t bpc = enc->bits_per_coded_sample != 15 ? enc->bits_per_coded_sample : 16;
- int expected_stride = ((enc->width * bpc + 31) >> 5)*4;
- ret = ff_reshuffle_raw_rgb(s, &pkt, enc, expected_stride);
+ if (par->codec_id == AV_CODEC_ID_RAWVIDEO && par->codec_tag == 0) {
+ int64_t bpc = par->bits_per_coded_sample != 15 ? par->bits_per_coded_sample : 16;
+ int expected_stride = ((par->width * bpc + 31) >> 5)*4;
+ ret = ff_reshuffle_raw_rgb(s, &pkt, par, expected_stride);
if (ret < 0)
return ret;
} else
ret = 0;
- if (enc->pix_fmt == AV_PIX_FMT_PAL8) {
+ if (par->format == AV_PIX_FMT_PAL8) {
int ret2 = ff_get_packet_palette(s, opkt, ret, avist->palette);
if (ret2 < 0)
return ret2;
if (ret2) {
- int pal_size = 1 << enc->bits_per_coded_sample;
+ int pal_size = 1 << par->bits_per_coded_sample;
int pc_tag, i;
- av_assert0(enc->bits_per_coded_sample >= 0 && enc->bits_per_coded_sample <= 8);
+ av_assert0(par->bits_per_coded_sample >= 0 && par->bits_per_coded_sample <= 8);
if (pb->seekable && avist->pal_offset) {
int64_t cur_offset = avio_tell(pb);
@@ -749,7 +749,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
}
if (memcmp(avist->palette, avist->old_palette, pal_size * 4)) {
unsigned char tag[5];
- avi_stream2fourcc(tag, stream_index, enc->codec_type);
+ avi_stream2fourcc(tag, stream_index, par->codec_type);
tag[2] = 'p'; tag[3] = 'c';
if (s->pb->seekable) {
int ret;
@@ -797,7 +797,7 @@ static int avi_write_packet_internal(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;
if (pkt->dts != AV_NOPTS_VALUE)
avist->last_dts = pkt->dts + pkt->duration;
@@ -817,10 +817,10 @@ static int avi_write_packet_internal(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) {
@@ -868,15 +868,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;
}
}
diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
index 45641c0fc1..13a4cf9ab0 100644
--- a/libavformat/avisynth.c
+++ b/libavformat/avisynth.c
@@ -232,10 +232,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->avg_frame_rate = (AVRational) { avs->vi->fps_numerator,
avs->vi->fps_denominator };
@@ -247,38 +247,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,
@@ -307,27 +307,27 @@ 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->duration = avs->vi->num_audio_samples;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->sample_rate = avs->vi->audio_samples_per_second;
+ st->codecpar->channels = avs->vi->nchannels;
+ st->duration = avs->vi->num_audio_samples;
avpriv_set_pts_info(st, 64, 1, avs->vi->audio_samples_per_second);
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,
@@ -636,7 +636,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);
@@ -678,7 +678,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) ||
diff --git a/libavformat/avr.c b/libavformat/avr.c
index a33134eed5..294160e024 100644
--- a/libavformat/avr.c
+++ b/libavformat/avr.c
@@ -46,22 +46,22 @@ static int avr_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
avio_skip(s->pb, 4); // magic
avio_skip(s->pb, 8); // sample_name
chan = avio_rb16(s->pb);
if (!chan) {
- st->codec->channels = 1;
+ st->codecpar->channels = 1;
} else if (chan == 0xFFFFu) {
- st->codec->channels = 2;
+ st->codecpar->channels = 2;
} else {
avpriv_request_sample(s, "chan %d", chan);
return AVERROR_PATCHWELCOME;
}
- st->codec->bits_per_coded_sample = bps = avio_rb16(s->pb);
+ st->codecpar->bits_per_coded_sample = bps = avio_rb16(s->pb);
sign = avio_rb16(s->pb);
@@ -69,21 +69,21 @@ static int avr_read_header(AVFormatContext *s)
avio_skip(s->pb, 2); // midi
avio_skip(s->pb, 1); // replay speed
- st->codec->sample_rate = avio_rb24(s->pb);
+ st->codecpar->sample_rate = avio_rb24(s->pb);
avio_skip(s->pb, 4 * 3);
avio_skip(s->pb, 2 * 3);
avio_skip(s->pb, 20);
avio_skip(s->pb, 64);
- st->codec->codec_id = ff_get_pcm_codec_id(bps, 0, 1, sign);
- if (st->codec->codec_id == AV_CODEC_ID_NONE) {
+ st->codecpar->codec_id = ff_get_pcm_codec_id(bps, 0, 1, sign);
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE) {
avpriv_request_sample(s, "Bps %d and sign %d", bps, sign);
return AVERROR_PATCHWELCOME;
}
- st->codec->block_align = bps * st->codec->channels / 8;
+ st->codecpar->block_align = bps * st->codecpar->channels / 8;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
diff --git a/libavformat/avs.c b/libavformat/avs.c
index b264b55ed1..763ba63f64 100644
--- a/libavformat/avs.c
+++ b/libavformat/avs.c
@@ -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;
#if FF_API_R_FRAME_RATE
avs->st_video->r_frame_rate =
@@ -203,7 +203,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);
diff --git a/libavformat/bethsoftvid.c b/libavformat/bethsoftvid.c
index 40a425271d..f516806d91 100644
--- a/libavformat/bethsoftvid.c
+++ b/libavformat/bethsoftvid.c
@@ -116,13 +116,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)
@@ -245,13 +245,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);
}
diff --git a/libavformat/bfi.c b/libavformat/bfi.c
index cc7f4948c9..568363dd91 100644
--- a/libavformat/bfi.c
+++ b/libavformat/bfi.c
@@ -75,38 +75,38 @@ 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);
- if (!vstream->codec->extradata)
+ vstream->codecpar->extradata = av_malloc(768);
+ if (!vstream->codecpar->extradata)
return AVERROR(ENOMEM);
- vstream->codec->extradata_size = 768;
- avio_read(pb, vstream->codec->extradata,
- vstream->codec->extradata_size);
+ 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->nb_frames =
- vstream->duration = bfi->nframes;
+ vstream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vstream->codecpar->codec_id = AV_CODEC_ID_BFI;
+ vstream->codecpar->format = AV_PIX_FMT_PAL8;
+ vstream->nb_frames =
+ vstream->duration = bfi->nframes;
/* 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;
}
diff --git a/libavformat/bink.c b/libavformat/bink.c
index 332edbb7d9..56dbf9e1c1 100644
--- a/libavformat/bink.c
+++ b/libavformat/bink.c
@@ -89,7 +89,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);
@@ -107,8 +107,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);
@@ -121,15 +121,15 @@ 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->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_id = AV_CODEC_ID_BINKVIDEO;
- if ((vst->codec->codec_tag & 0xFFFFFF) == MKTAG('K', 'B', '2', 0)) {
+ if ((vst->codecpar->codec_tag & 0xFFFFFF) == MKTAG('K', 'B', '2', 0)) {
av_log(s, AV_LOG_WARNING, "Bink 2 video is not implemented\n");
- vst->codec->codec_id = AV_CODEC_ID_NONE;
+ vst->codecpar->codec_id = AV_CODEC_ID_NONE;
}
- if (ff_get_extradata(vst->codec, pb, 4) < 0)
+ if (ff_get_extradata(vst->codecpar, pb, 4) < 0)
return AVERROR(ENOMEM);
bink->num_audio_tracks = avio_rl32(pb);
@@ -148,23 +148,23 @@ 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;
}
- if (ff_alloc_extradata(ast->codec, 4))
+ if (ff_alloc_extradata(ast->codecpar, 4))
return AVERROR(ENOMEM);
- AV_WL32(ast->codec->extradata, vst->codec->codec_tag);
+ AV_WL32(ast->codecpar->extradata, vst->codecpar->codec_tag);
}
for (i = 0; i < bink->num_audio_tracks; i++)
@@ -250,7 +250,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);
diff --git a/libavformat/bintext.c b/libavformat/bintext.c
index 217ea49247..3a24c811ef 100644
--- a/libavformat/bintext.c
+++ b/libavformat/bintext.c
@@ -54,12 +54,12 @@ static AVStream * init_stream(AVFormatContext *s)
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return NULL;
- st->codec->codec_tag = 0;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_tag = 0;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
if (!bin->width) {
- st->codec->width = (80<<3);
- st->codec->height = (25<<4);
+ st->codecpar->width = (80<<3);
+ st->codecpar->height = (25<<4);
}
avpriv_set_pts_info(st, 60, bin->framerate.den, bin->framerate.num);
@@ -74,9 +74,9 @@ static AVStream * init_stream(AVFormatContext *s)
/**
* Given filesize and width, calculate height (assume font_height of 16)
*/
-static void calculate_height(AVCodecContext *avctx, uint64_t fsize)
+static void calculate_height(AVCodecParameters *par, uint64_t fsize)
{
- avctx->height = (fsize / ((avctx->width>>3)*2)) << 4;
+ par->height = (fsize / ((par->width>>3)*2)) << 4;
}
#endif
@@ -119,11 +119,11 @@ static int next_tag_read(AVFormatContext *avctx, uint64_t *fsize)
return 0;
}
-static void predict_width(AVCodecContext *avctx, uint64_t fsize, int got_width)
+static void predict_width(AVCodecParameters *par, uint64_t fsize, int got_width)
{
/** attempt to guess width */
if (!got_width)
- avctx->width = fsize > 4000 ? (160<<3) : (80<<3);
+ par->width = fsize > 4000 ? (160<<3) : (80<<3);
}
static int bintext_read_header(AVFormatContext *s)
@@ -134,12 +134,12 @@ static int bintext_read_header(AVFormatContext *s)
AVStream *st = init_stream(s);
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_id = AV_CODEC_ID_BINTEXT;
+ st->codecpar->codec_id = AV_CODEC_ID_BINTEXT;
- if (ff_alloc_extradata(st->codec, 2))
+ if (ff_alloc_extradata(st->codecpar, 2))
return AVERROR(ENOMEM);
- st->codec->extradata[0] = 16;
- st->codec->extradata[1] = 0;
+ st->codecpar->extradata[0] = 16;
+ st->codecpar->extradata[1] = 0;
if (pb->seekable) {
int got_width = 0;
@@ -147,8 +147,8 @@ static int bintext_read_header(AVFormatContext *s)
if (ff_sauce_read(s, &bin->fsize, &got_width, 0) < 0)
next_tag_read(s, &bin->fsize);
if (!bin->width) {
- predict_width(st->codec, bin->fsize, got_width);
- calculate_height(st->codec, bin->fsize);
+ predict_width(st->codecpar, bin->fsize, got_width);
+ calculate_height(st->codecpar, bin->fsize);
}
avio_seek(pb, 0, SEEK_SET);
}
@@ -179,30 +179,30 @@ static int xbin_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avio_skip(pb, 5);
- st->codec->width = avio_rl16(pb)<<3;
- st->codec->height = avio_rl16(pb);
+ st->codecpar->width = avio_rl16(pb)<<3;
+ st->codecpar->height = avio_rl16(pb);
fontheight = avio_r8(pb);
- st->codec->height *= fontheight;
+ st->codecpar->height *= fontheight;
flags = avio_r8(pb);
- st->codec->extradata_size = 2;
+ st->codecpar->extradata_size = 2;
if ((flags & BINTEXT_PALETTE))
- st->codec->extradata_size += 48;
+ st->codecpar->extradata_size += 48;
if ((flags & BINTEXT_FONT))
- st->codec->extradata_size += fontheight * (flags & 0x10 ? 512 : 256);
- st->codec->codec_id = flags & 4 ? AV_CODEC_ID_XBIN : AV_CODEC_ID_BINTEXT;
+ st->codecpar->extradata_size += fontheight * (flags & 0x10 ? 512 : 256);
+ st->codecpar->codec_id = flags & 4 ? AV_CODEC_ID_XBIN : AV_CODEC_ID_BINTEXT;
- if (ff_alloc_extradata(st->codec, st->codec->extradata_size))
+ if (ff_alloc_extradata(st->codecpar, st->codecpar->extradata_size))
return AVERROR(ENOMEM);
- st->codec->extradata[0] = fontheight;
- st->codec->extradata[1] = flags;
- if (avio_read(pb, st->codec->extradata + 2, st->codec->extradata_size - 2) < 0)
+ st->codecpar->extradata[0] = fontheight;
+ st->codecpar->extradata[1] = flags;
+ if (avio_read(pb, st->codecpar->extradata + 2, st->codecpar->extradata_size - 2) < 0)
return AVERROR(EIO);
if (pb->seekable) {
- bin->fsize = avio_size(pb) - 9 - st->codec->extradata_size;
+ bin->fsize = avio_size(pb) - 9 - st->codecpar->extradata_size;
ff_sauce_read(s, &bin->fsize, NULL, 0);
- avio_seek(pb, 9 + st->codec->extradata_size, SEEK_SET);
+ avio_seek(pb, 9 + st->codecpar->extradata_size, SEEK_SET);
}
return 0;
@@ -222,28 +222,28 @@ static int adf_read_header(AVFormatContext *s)
st = init_stream(s);
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_id = AV_CODEC_ID_BINTEXT;
+ st->codecpar->codec_id = AV_CODEC_ID_BINTEXT;
- if (ff_alloc_extradata(st->codec, 2 + 48 + 4096))
+ if (ff_alloc_extradata(st->codecpar, 2 + 48 + 4096))
return AVERROR(ENOMEM);
- st->codec->extradata[0] = 16;
- st->codec->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;
+ st->codecpar->extradata[0] = 16;
+ st->codecpar->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;
- if (avio_read(pb, st->codec->extradata + 2, 24) < 0)
+ if (avio_read(pb, st->codecpar->extradata + 2, 24) < 0)
return AVERROR(EIO);
avio_skip(pb, 144);
- if (avio_read(pb, st->codec->extradata + 2 + 24, 24) < 0)
+ if (avio_read(pb, st->codecpar->extradata + 2 + 24, 24) < 0)
return AVERROR(EIO);
- if (avio_read(pb, st->codec->extradata + 2 + 48, 4096) < 0)
+ if (avio_read(pb, st->codecpar->extradata + 2 + 48, 4096) < 0)
return AVERROR(EIO);
if (pb->seekable) {
int got_width = 0;
bin->fsize = avio_size(pb) - 1 - 192 - 4096;
- st->codec->width = 80<<3;
+ st->codecpar->width = 80<<3;
ff_sauce_read(s, &bin->fsize, &got_width, 0);
if (!bin->width)
- calculate_height(st->codec, bin->fsize);
+ calculate_height(st->codecpar, bin->fsize);
avio_seek(pb, 1 + 192 + 4096, SEEK_SET);
}
return 0;
@@ -277,24 +277,24 @@ static int idf_read_header(AVFormatContext *s)
st = init_stream(s);
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_id = AV_CODEC_ID_IDF;
+ st->codecpar->codec_id = AV_CODEC_ID_IDF;
- if (ff_alloc_extradata(st->codec, 2 + 48 + 4096))
+ if (ff_alloc_extradata(st->codecpar, 2 + 48 + 4096))
return AVERROR(ENOMEM);
- st->codec->extradata[0] = 16;
- st->codec->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;
+ st->codecpar->extradata[0] = 16;
+ st->codecpar->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;
avio_seek(pb, avio_size(pb) - 4096 - 48, SEEK_SET);
- if (avio_read(pb, st->codec->extradata + 2 + 48, 4096) < 0)
+ if (avio_read(pb, st->codecpar->extradata + 2 + 48, 4096) < 0)
return AVERROR(EIO);
- if (avio_read(pb, st->codec->extradata + 2, 48) < 0)
+ if (avio_read(pb, st->codecpar->extradata + 2, 48) < 0)
return AVERROR(EIO);
bin->fsize = avio_size(pb) - 12 - 4096 - 48;
ff_sauce_read(s, &bin->fsize, &got_width, 0);
if (!bin->width)
- calculate_height(st->codec, bin->fsize);
+ calculate_height(st->codecpar, bin->fsize);
avio_seek(pb, 12, SEEK_SET);
return 0;
}
diff --git a/libavformat/bit.c b/libavformat/bit.c
index 138d2feadb..c3f2fdfbe3 100644
--- a/libavformat/bit.c
+++ b/libavformat/bit.c
@@ -55,11 +55,11 @@ static int read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id=AV_CODEC_ID_G729;
- st->codec->sample_rate=8000;
- st->codec->block_align = 16;
- st->codec->channels=1;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id=AV_CODEC_ID_G729;
+ st->codecpar->sample_rate=8000;
+ st->codecpar->block_align = 16;
+ st->codecpar->channels=1;
avpriv_set_pts_info(st, 64, 1, 100);
return 0;
@@ -117,16 +117,16 @@ AVInputFormat ff_bit_demuxer = {
#if CONFIG_MUXERS
static int write_header(AVFormatContext *s)
{
- AVCodecContext *enc = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
- if ((enc->codec_id != AV_CODEC_ID_G729) || enc->channels != 1) {
+ if ((par->codec_id != AV_CODEC_ID_G729) || par->channels != 1) {
av_log(s, AV_LOG_ERROR,
"only codec g729 with 1 channel is supported by this format\n");
return AVERROR(EINVAL);
}
- enc->bits_per_coded_sample = 16;
- enc->block_align = (enc->bits_per_coded_sample * enc->channels) >> 3;
+ par->bits_per_coded_sample = 16;
+ par->block_align = (par->bits_per_coded_sample * par->channels) >> 3;
return 0;
}
diff --git a/libavformat/bmv.c b/libavformat/bmv.c
index f7a6068af3..c9580a29fd 100644
--- a/libavformat/bmv.c
+++ b/libavformat/bmv.c
@@ -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;
diff --git a/libavformat/boadec.c b/libavformat/boadec.c
index be003e59c1..ac2a33b3f0 100644
--- a/libavformat/boadec.c
+++ b/libavformat/boadec.c
@@ -46,16 +46,16 @@ static int read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_ADPCM_MS;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_MS;
avio_rl32(s->pb);
avio_rl32(s->pb);
- st->codec->sample_rate = avio_rl32(s->pb);
- st->codec->channels = avio_rl32(s->pb);
+ st->codecpar->sample_rate = avio_rl32(s->pb);
+ st->codecpar->channels = avio_rl32(s->pb);
s->internal->data_offset = avio_rl32(s->pb);
avio_r8(s->pb);
- st->codec->block_align = st->codec->channels * avio_rl32(s->pb);
+ st->codecpar->block_align = st->codecpar->channels * avio_rl32(s->pb);
avio_seek(s->pb, s->internal->data_offset, SEEK_SET);
@@ -66,7 +66,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVStream *st = s->streams[0];
- return av_get_packet(s->pb, pkt, st->codec->block_align);
+ return av_get_packet(s->pb, pkt, st->codecpar->block_align);
}
AVInputFormat ff_boa_demuxer = {
diff --git a/libavformat/brstm.c b/libavformat/brstm.c
index 6fd44f168d..2e1cada158 100644
--- a/libavformat/brstm.c
+++ b/libavformat/brstm.c
@@ -99,7 +99,7 @@ static int read_header(AVFormatContext *s)
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
avio_skip(s->pb, 4);
@@ -197,15 +197,15 @@ static int read_header(AVFormatContext *s)
}
loop = avio_r8(s->pb); // loop flag
- st->codec->codec_id = codec;
- st->codec->channels = avio_r8(s->pb);
- if (!st->codec->channels)
+ st->codecpar->codec_id = codec;
+ st->codecpar->channels = avio_r8(s->pb);
+ if (!st->codecpar->channels)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 1); // padding
- st->codec->sample_rate = bfstm ? read32(s) : read16(s);
- if (st->codec->sample_rate <= 0)
+ st->codecpar->sample_rate = bfstm ? read32(s) : read16(s);
+ if (st->codecpar->sample_rate <= 0)
return AVERROR_INVALIDDATA;
if (!bfstm)
@@ -214,7 +214,7 @@ static int read_header(AVFormatContext *s)
if (loop) {
if (av_dict_set_int(&s->metadata, "loop_start",
av_rescale(read32(s), AV_TIME_BASE,
- st->codec->sample_rate),
+ st->codecpar->sample_rate),
0) < 0)
return AVERROR(ENOMEM);
} else {
@@ -223,7 +223,7 @@ static int read_header(AVFormatContext *s)
st->start_time = 0;
st->duration = read32(s);
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
if (!bfstm)
start = read32(s);
@@ -235,14 +235,14 @@ static int read_header(AVFormatContext *s)
}
b->block_size = read32(s);
- if (b->block_size > UINT32_MAX / st->codec->channels)
+ if (b->block_size > UINT32_MAX / st->codecpar->channels)
return AVERROR_INVALIDDATA;
b->samples_per_block = read32(s);
b->last_block_used_bytes = read32(s);
b->last_block_samples = read32(s);
b->last_block_size = read32(s);
- if (b->last_block_size > UINT32_MAX / st->codec->channels)
+ if (b->last_block_size > UINT32_MAX / st->codecpar->channels)
return AVERROR_INVALIDDATA;
if (b->last_block_used_bytes > b->last_block_size)
return AVERROR_INVALIDDATA;
@@ -255,16 +255,16 @@ static int read_header(AVFormatContext *s)
if (!bfstm)
toffset = read32(s) + 16LL;
else
- toffset = toffset + read32(s) + st->codec->channels * 8 - 8;
+ toffset = toffset + read32(s) + st->codecpar->channels * 8 - 8;
if (toffset > size)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, pos + toffset - avio_tell(s->pb));
- b->table = av_mallocz(32 * st->codec->channels);
+ b->table = av_mallocz(32 * st->codecpar->channels);
if (!b->table)
return AVERROR(ENOMEM);
- for (ch = 0; ch < st->codec->channels; ch++) {
+ for (ch = 0; ch < st->codecpar->channels; ch++) {
if (avio_read(s->pb, b->table + ch * 32, 32) != 32) {
ret = AVERROR_INVALIDDATA;
goto fail;
@@ -295,7 +295,7 @@ static int read_header(AVFormatContext *s)
codec != AV_CODEC_ID_ADPCM_THP_LE)
goto skip;
- asize = b->block_count * st->codec->channels * 4;
+ asize = b->block_count * st->codecpar->channels * 4;
if (size < asize) {
ret = AVERROR_INVALIDDATA;
goto fail;
@@ -357,7 +357,7 @@ fail:
static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
- AVCodecContext *codec = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
BRSTMDemuxContext *b = s->priv_data;
uint32_t samples, size, skip = 0;
int ret, i;
@@ -385,8 +385,8 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR_EOF;
}
- if (codec->codec_id == AV_CODEC_ID_ADPCM_THP ||
- codec->codec_id == AV_CODEC_ID_ADPCM_THP_LE) {
+ if (par->codec_id == AV_CODEC_ID_ADPCM_THP ||
+ par->codec_id == AV_CODEC_ID_ADPCM_THP_LE) {
uint8_t *dst;
if (!b->adpc) {
@@ -394,30 +394,30 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR_INVALIDDATA;
}
if (!b->table) {
- b->table = av_mallocz(32 * codec->channels);
+ b->table = av_mallocz(32 * par->channels);
if (!b->table)
return AVERROR(ENOMEM);
}
if (size > (INT_MAX - 32 - 4) ||
- (32 + 4 + size) > (INT_MAX / codec->channels) ||
- (32 + 4 + size) * codec->channels > INT_MAX - 8)
+ (32 + 4 + size) > (INT_MAX / par->channels) ||
+ (32 + 4 + size) * par->channels > INT_MAX - 8)
return AVERROR_INVALIDDATA;
- if (av_new_packet(pkt, 8 + (32 + 4 + size) * codec->channels) < 0)
+ if (av_new_packet(pkt, 8 + (32 + 4 + size) * par->channels) < 0)
return AVERROR(ENOMEM);
dst = pkt->data;
- if (codec->codec_id == AV_CODEC_ID_ADPCM_THP_LE) {
- bytestream_put_le32(&dst, size * codec->channels);
+ if (par->codec_id == AV_CODEC_ID_ADPCM_THP_LE) {
+ bytestream_put_le32(&dst, size * par->channels);
bytestream_put_le32(&dst, samples);
} else {
- bytestream_put_be32(&dst, size * codec->channels);
+ bytestream_put_be32(&dst, size * par->channels);
bytestream_put_be32(&dst, samples);
}
- bytestream_put_buffer(&dst, b->table, 32 * codec->channels);
- bytestream_put_buffer(&dst, b->adpc + 4 * codec->channels *
- (b->current_block - 1), 4 * codec->channels);
+ bytestream_put_buffer(&dst, b->table, 32 * par->channels);
+ bytestream_put_buffer(&dst, b->adpc + 4 * par->channels *
+ (b->current_block - 1), 4 * par->channels);
- for (i = 0; i < codec->channels; i++) {
+ for (i = 0; i < par->channels; i++) {
ret = avio_read(s->pb, dst, size);
dst += size;
avio_skip(s->pb, skip);
@@ -428,7 +428,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
}
pkt->duration = samples;
} else {
- size *= codec->channels;
+ size *= par->channels;
ret = av_get_packet(s->pb, pkt, size);
}
@@ -449,7 +449,7 @@ static int read_seek(AVFormatContext *s, int stream_index,
timestamp /= b->samples_per_block;
ret = avio_seek(s->pb, b->data_start + timestamp * b->block_size *
- st->codec->channels, SEEK_SET);
+ st->codecpar->channels, SEEK_SET);
if (ret < 0)
return ret;
diff --git a/libavformat/c93.c b/libavformat/c93.c
index 20ae9c4932..b1a245a3cf 100644
--- a/libavformat/c93.c
+++ b/libavformat/c93.c
@@ -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);
diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c
index bfbbb02627..91b50c8199 100644
--- a/libavformat/cafdec.c
+++ b/libavformat/cafdec.c
@@ -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_rl32(pb);
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->sample_rate = av_int2double(avio_rb64(pb));
+ st->codecpar->codec_tag = avio_rl32(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 == MKTAG('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 == MKTAG('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
@@ -134,8 +134,8 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
return AVERROR_INVALIDDATA;
}
- av_freep(&st->codec->extradata);
- if (ff_alloc_extradata(st->codec, ALAC_HEADER))
+ av_freep(&st->codecpar->extradata);
+ if (ff_alloc_extradata(st->codecpar, ALAC_HEADER))
return AVERROR(ENOMEM);
/* For the old style cookie, we skip 12 bytes, then read 36 bytes.
@@ -145,30 +145,30 @@ 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;
}
- if (avio_read(pb, st->codec->extradata, ALAC_HEADER) != ALAC_HEADER) {
+ if (avio_read(pb, st->codecpar->extradata, ALAC_HEADER) != ALAC_HEADER) {
av_log(s, AV_LOG_ERROR, "failed to read kuki header\n");
- av_freep(&st->codec->extradata);
+ av_freep(&st->codecpar->extradata);
return AVERROR_INVALIDDATA;
}
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);
- if (avio_read(pb, &st->codec->extradata[24], ALAC_NEW_KUKI - 12) != 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);
+ if (avio_read(pb, &st->codecpar->extradata[24], ALAC_NEW_KUKI - 12) != ALAC_NEW_KUKI - 12) {
av_log(s, AV_LOG_ERROR, "failed to read new kuki header\n");
- av_freep(&st->codec->extradata);
+ av_freep(&st->codecpar->extradata);
return AVERROR_INVALIDDATA;
}
avio_skip(pb, size - ALAC_NEW_KUKI);
}
} else {
- av_freep(&st->codec->extradata);
- if (ff_get_extradata(st->codec, pb, size) < 0)
+ av_freep(&st->codecpar->extradata);
+ if (ff_get_extradata(st->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
}
@@ -323,15 +323,15 @@ 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->duration > 0) {
- st->codec->bit_rate = st->codec->sample_rate * caf->data_size * 8 /
- st->duration;
+ 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 "
"block size or frame size are variable.\n");
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 */
diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
index 0b2f649463..f2d7ec90b1 100644
--- a/libavformat/cafenc.c
+++ b/libavformat/cafenc.c
@@ -102,19 +102,19 @@ static uint32_t samples_per_packet(enum AVCodecID codec_id, int channels, int bl
static int caf_write_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
- AVCodecContext *enc = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
CAFContext *caf = s->priv_data;
AVDictionaryEntry *t = NULL;
- unsigned int codec_tag = ff_codec_get_tag(ff_codec_caf_tags, enc->codec_id);
+ unsigned int codec_tag = ff_codec_get_tag(ff_codec_caf_tags, par->codec_id);
int64_t chunk_size = 0;
- int frame_size = enc->frame_size;
+ int frame_size = par->frame_size;
if (s->nb_streams != 1) {
av_log(s, AV_LOG_ERROR, "CAF files have exactly one stream\n");
return AVERROR(EINVAL);
}
- switch (enc->codec_id) {
+ switch (par->codec_id) {
case AV_CODEC_ID_AAC:
av_log(s, AV_LOG_ERROR, "muxing codec currently unsupported\n");
return AVERROR_PATCHWELCOME;
@@ -125,13 +125,13 @@ static int caf_write_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
- if (!enc->block_align && !pb->seekable) {
+ if (!par->block_align && !pb->seekable) {
av_log(s, AV_LOG_ERROR, "Muxing variable packet size not supported on non seekable output\n");
return AVERROR_INVALIDDATA;
}
- if (enc->codec_id != AV_CODEC_ID_MP3 || frame_size != 576)
- frame_size = samples_per_packet(enc->codec_id, enc->channels, enc->block_align);
+ if (par->codec_id != AV_CODEC_ID_MP3 || frame_size != 576)
+ frame_size = samples_per_packet(par->codec_id, par->channels, par->block_align);
ffio_wfourcc(pb, "caff"); //< mFileType
avio_wb16(pb, 1); //< mFileVersion
@@ -139,26 +139,26 @@ static int caf_write_header(AVFormatContext *s)
ffio_wfourcc(pb, "desc"); //< Audio Description chunk
avio_wb64(pb, 32); //< mChunkSize
- avio_wb64(pb, av_double2int(enc->sample_rate)); //< mSampleRate
+ avio_wb64(pb, av_double2int(par->sample_rate)); //< mSampleRate
avio_wl32(pb, codec_tag); //< mFormatID
- avio_wb32(pb, codec_flags(enc->codec_id)); //< mFormatFlags
- avio_wb32(pb, enc->block_align); //< mBytesPerPacket
+ avio_wb32(pb, codec_flags(par->codec_id)); //< mFormatFlags
+ avio_wb32(pb, par->block_align); //< mBytesPerPacket
avio_wb32(pb, frame_size); //< mFramesPerPacket
- avio_wb32(pb, enc->channels); //< mChannelsPerFrame
- avio_wb32(pb, av_get_bits_per_sample(enc->codec_id)); //< mBitsPerChannel
+ avio_wb32(pb, par->channels); //< mChannelsPerFrame
+ avio_wb32(pb, av_get_bits_per_sample(par->codec_id)); //< mBitsPerChannel
- if (enc->channel_layout) {
+ if (par->channel_layout) {
ffio_wfourcc(pb, "chan");
avio_wb64(pb, 12);
- ff_mov_write_chan(pb, enc->channel_layout);
+ ff_mov_write_chan(pb, par->channel_layout);
}
- if (enc->codec_id == AV_CODEC_ID_ALAC) {
+ if (par->codec_id == AV_CODEC_ID_ALAC) {
ffio_wfourcc(pb, "kuki");
- avio_wb64(pb, 12 + enc->extradata_size);
+ avio_wb64(pb, 12 + par->extradata_size);
avio_write(pb, "\0\0\0\14frmaalac", 12);
- avio_write(pb, enc->extradata, enc->extradata_size);
- } else if (enc->codec_id == AV_CODEC_ID_AMR_NB) {
+ avio_write(pb, par->extradata, par->extradata_size);
+ } else if (par->codec_id == AV_CODEC_ID_AMR_NB) {
ffio_wfourcc(pb, "kuki");
avio_wb64(pb, 29);
avio_write(pb, "\0\0\0\14frmasamr", 12);
@@ -169,10 +169,10 @@ static int caf_write_header(AVFormatContext *s)
avio_wb16(pb, 0x81FF); /* Mode set (all modes for AMR_NB) */
avio_w8(pb, 0x00); /* Mode change period (no restriction) */
avio_w8(pb, 0x01); /* Frames per sample */
- } else if (enc->codec_id == AV_CODEC_ID_QDM2) {
+ } else if (par->codec_id == AV_CODEC_ID_QDM2) {
ffio_wfourcc(pb, "kuki");
- avio_wb64(pb, enc->extradata_size);
- avio_write(pb, enc->extradata, enc->extradata_size);
+ avio_wb64(pb, par->extradata_size);
+ avio_write(pb, par->extradata, par->extradata_size);
}
ff_standardize_creation_time(s);
@@ -204,7 +204,7 @@ static int caf_write_packet(AVFormatContext *s, AVPacket *pkt)
CAFContext *caf = s->priv_data;
avio_write(s->pb, pkt->data, pkt->size);
- if (!s->streams[0]->codec->block_align) {
+ if (!s->streams[0]->codecpar->block_align) {
void *pkt_sizes = caf->pkt_sizes;
int i, alloc_size = caf->size_entries_used + 5;
if (alloc_size < 0) {
@@ -233,7 +233,7 @@ static int caf_write_trailer(AVFormatContext *s)
{
CAFContext *caf = s->priv_data;
AVIOContext *pb = s->pb;
- AVCodecContext *enc = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
if (pb->seekable) {
int64_t file_size = avio_tell(pb);
@@ -241,11 +241,11 @@ static int caf_write_trailer(AVFormatContext *s)
avio_seek(pb, caf->data, SEEK_SET);
avio_wb64(pb, file_size - caf->data - 8);
avio_seek(pb, file_size, SEEK_SET);
- if (!enc->block_align) {
+ if (!par->block_align) {
ffio_wfourcc(pb, "pakt");
avio_wb64(pb, caf->size_entries_used + 24);
avio_wb64(pb, caf->packets); ///< mNumberPackets
- avio_wb64(pb, caf->packets * samples_per_packet(enc->codec_id, enc->channels, enc->block_align)); ///< mNumberValidFrames
+ avio_wb64(pb, caf->packets * samples_per_packet(par->codec_id, par->channels, par->block_align)); ///< mNumberValidFrames
avio_wb32(pb, 0); ///< mPrimingFrames
avio_wb32(pb, 0); ///< mRemainderFrames
avio_write(pb, caf->pkt_sizes, caf->size_entries_used);
diff --git a/libavformat/cdg.c b/libavformat/cdg.c
index b1f137ff33..05cac6e528 100644
--- a/libavformat/cdg.c
+++ b/libavformat/cdg.c
@@ -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);
diff --git a/libavformat/cdxl.c b/libavformat/cdxl.c
index 0b8b199ce9..94a063c813 100644
--- a/libavformat/cdxl.c
+++ b/libavformat/cdxl.c
@@ -150,17 +150,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);
@@ -179,11 +179,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;
if (audio_size + video_size && cdxl->filesize > 0) {
frames = cdxl->filesize / (audio_size + video_size);
diff --git a/libavformat/chromaprint.c b/libavformat/chromaprint.c
index 4d67f43499..8c9a6c0111 100644
--- a/libavformat/chromaprint.c
+++ b/libavformat/chromaprint.c
@@ -85,17 +85,17 @@ static int write_header(AVFormatContext *s)
st = s->streams[0];
- if (st->codec->channels > 2) {
+ if (st->codecpar->channels > 2) {
av_log(s, AV_LOG_ERROR, "Only up to 2 channels are supported\n");
goto fail;
}
- if (st->codec->sample_rate < 1000) {
+ if (st->codecpar->sample_rate < 1000) {
av_log(s, AV_LOG_ERROR, "Sampling rate must be at least 1000\n");
goto fail;
}
- if (!chromaprint_start(cpr->ctx, st->codec->sample_rate, st->codec->channels)) {
+ if (!chromaprint_start(cpr->ctx, st->codecpar->sample_rate, st->codecpar->channels)) {
av_log(s, AV_LOG_ERROR, "Failed to start chromaprint\n");
goto fail;
}
diff --git a/libavformat/cinedec.c b/libavformat/cinedec.c
index 318408436f..0efedda1a3 100644
--- a/libavformat/cinedec.c
+++ b/libavformat/cinedec.c
@@ -101,9 +101,9 @@ static int cine_read_header(AVFormatContext *avctx)
st = avformat_new_stream(avctx, NULL);
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
- st->codec->codec_tag = 0;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
+ st->codecpar->codec_tag = 0;
/* CINEFILEHEADER structure */
avio_skip(pb, 4); // Type, Headersize
@@ -127,8 +127,8 @@ static int cine_read_header(AVFormatContext *avctx)
/* BITMAPINFOHEADER structure */
avio_seek(pb, offImageHeader, SEEK_SET);
avio_skip(pb, 4); //biSize
- st->codec->width = avio_rl32(pb);
- st->codec->height = avio_rl32(pb);
+ st->codecpar->width = avio_rl32(pb);
+ st->codecpar->height = avio_rl32(pb);
if (avio_rl16(pb) != 1) // biPlanes
return AVERROR_INVALIDDATA;
@@ -144,7 +144,7 @@ static int cine_read_header(AVFormatContext *avctx)
vflip = 0;
break;
case 0x100: /* BI_PACKED */
- st->codec->codec_tag = MKTAG('B', 'I', 'T', 0);
+ st->codecpar->codec_tag = MKTAG('B', 'I', 'T', 0);
vflip = 1;
break;
default:
@@ -167,8 +167,8 @@ static int cine_read_header(AVFormatContext *avctx)
avio_skip(pb, 616); // Binning .. bFlipH
if (!avio_rl32(pb) ^ vflip) {
- st->codec->extradata = av_strdup("BottomUp");
- st->codec->extradata_size = 9;
+ st->codecpar->extradata = av_strdup("BottomUp");
+ st->codecpar->extradata_size = 9;
}
avio_skip(pb, 4); // Grid
@@ -193,17 +193,17 @@ static int cine_read_header(AVFormatContext *avctx)
set_metadata_float(&st->metadata, "wbgain[0].b", av_int2float(avio_rl32(pb)), 1);
avio_skip(pb, 36); // WBGain[1].. WBView
- st->codec->bits_per_coded_sample = avio_rl32(pb);
+ st->codecpar->bits_per_coded_sample = avio_rl32(pb);
if (compression == CC_RGB) {
if (biBitCount == 8) {
- st->codec->pix_fmt = AV_PIX_FMT_GRAY8;
+ st->codecpar->format = AV_PIX_FMT_GRAY8;
} else if (biBitCount == 16) {
- st->codec->pix_fmt = AV_PIX_FMT_GRAY16LE;
+ st->codecpar->format = AV_PIX_FMT_GRAY16LE;
} else if (biBitCount == 24) {
- st->codec->pix_fmt = AV_PIX_FMT_BGR24;
+ st->codecpar->format = AV_PIX_FMT_BGR24;
} else if (biBitCount == 48) {
- st->codec->pix_fmt = AV_PIX_FMT_BGR48LE;
+ st->codecpar->format = AV_PIX_FMT_BGR48LE;
} else {
avpriv_request_sample(avctx, "unsupported biBitCount %i", biBitCount);
return AVERROR_INVALIDDATA;
@@ -212,9 +212,9 @@ static int cine_read_header(AVFormatContext *avctx)
switch (CFA & 0xFFFFFF) {
case CFA_BAYER:
if (biBitCount == 8) {
- st->codec->pix_fmt = AV_PIX_FMT_BAYER_GBRG8;
+ st->codecpar->format = AV_PIX_FMT_BAYER_GBRG8;
} else if (biBitCount == 16) {
- st->codec->pix_fmt = AV_PIX_FMT_BAYER_GBRG16LE;
+ st->codecpar->format = AV_PIX_FMT_BAYER_GBRG16LE;
} else {
avpriv_request_sample(avctx, "unsupported biBitCount %i", biBitCount);
return AVERROR_INVALIDDATA;
@@ -222,9 +222,9 @@ static int cine_read_header(AVFormatContext *avctx)
break;
case CFA_BAYERFLIP:
if (biBitCount == 8) {
- st->codec->pix_fmt = AV_PIX_FMT_BAYER_RGGB8;
+ st->codecpar->format = AV_PIX_FMT_BAYER_RGGB8;
} else if (biBitCount == 16) {
- st->codec->pix_fmt = AV_PIX_FMT_BAYER_RGGB16LE;
+ st->codecpar->format = AV_PIX_FMT_BAYER_RGGB16LE;
} else {
avpriv_request_sample(avctx, "unsupported biBitCount %i", biBitCount);
return AVERROR_INVALIDDATA;
diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index 20a37e022a..50d6689413 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -35,6 +35,7 @@ typedef enum ConcatMatchMode {
typedef struct ConcatStream {
AVBitStreamFilterContext *bsf;
+ AVCodecContext *avctx;
int out_stream_index;
} ConcatStream;
@@ -164,19 +165,28 @@ static int copy_stream_props(AVStream *st, AVStream *source_st)
{
int ret;
- if (st->codec->codec_id || !source_st->codec->codec_id) {
- if (st->codec->extradata_size < source_st->codec->extradata_size) {
- ret = ff_alloc_extradata(st->codec,
- source_st->codec->extradata_size);
+ if (st->codecpar->codec_id || !source_st->codecpar->codec_id) {
+ if (st->codecpar->extradata_size < source_st->codecpar->extradata_size) {
+ if (st->codecpar->extradata) {
+ av_freep(&st->codecpar->extradata);
+ st->codecpar->extradata_size = 0;
+ }
+ ret = ff_alloc_extradata(st->codecpar,
+ source_st->codecpar->extradata_size);
if (ret < 0)
return ret;
}
- memcpy(st->codec->extradata, source_st->codec->extradata,
- source_st->codec->extradata_size);
+ memcpy(st->codecpar->extradata, source_st->codecpar->extradata,
+ source_st->codecpar->extradata_size);
return 0;
}
- if ((ret = avcodec_copy_context(st->codec, source_st->codec)) < 0)
+ if ((ret = avcodec_parameters_copy(st->codecpar, source_st->codecpar)) < 0)
return ret;
+ /* We don't want to carry around MP4-style extradata, since we are usoign a bsf anyway. */
+ if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
+ av_freep(&st->codecpar->extradata);
+ st->codecpar->extradata_size = 0;
+ }
st->r_frame_rate = source_st->r_frame_rate;
st->avg_frame_rate = source_st->avg_frame_rate;
st->time_base = source_st->time_base;
@@ -192,9 +202,10 @@ static int detect_stream_specific(AVFormatContext *avf, int idx)
AVStream *st = cat->avf->streams[idx];
ConcatStream *cs = &cat->cur_file->streams[idx];
AVBitStreamFilterContext *bsf;
+ int ret;
- if (cat->auto_convert && st->codec->codec_id == AV_CODEC_ID_H264 &&
- (st->codec->extradata_size < 4 || AV_RB32(st->codec->extradata) != 1)) {
+ if (cat->auto_convert && st->codecpar->codec_id == AV_CODEC_ID_H264 &&
+ (st->codecpar->extradata_size < 4 || AV_RB32(st->codecpar->extradata) != 1)) {
av_log(cat->avf, AV_LOG_INFO,
"Auto-inserting h264_mp4toannexb bitstream filter\n");
if (!(bsf = av_bitstream_filter_init("h264_mp4toannexb"))) {
@@ -203,6 +214,17 @@ static int detect_stream_specific(AVFormatContext *avf, int idx)
return AVERROR_BSF_NOT_FOUND;
}
cs->bsf = bsf;
+
+ cs->avctx = avcodec_alloc_context3(NULL);
+ if (!cs->avctx)
+ return AVERROR(ENOMEM);
+
+ ret = avcodec_parameters_to_context(cs->avctx, st->codecpar);
+ if (ret < 0) {
+ avcodec_free_context(&cs->avctx);
+ return ret;
+ }
+
}
return 0;
}
@@ -338,15 +360,21 @@ static int open_file(AVFormatContext *avf, unsigned fileno)
static int concat_read_close(AVFormatContext *avf)
{
ConcatContext *cat = avf->priv_data;
- unsigned i;
+ unsigned i, j;
- if (cat->avf)
- avformat_close_input(&cat->avf);
for (i = 0; i < cat->nb_files; i++) {
av_freep(&cat->files[i].url);
+ for (j = 0; j < cat->avf->nb_streams; j++) {
+ if (cat->files[i].streams[j].avctx)
+ avcodec_free_context(&cat->files[i].streams[j].avctx);
+ if (cat->files[i].streams[j].bsf)
+ av_bitstream_filter_close(cat->files[i].streams[j].bsf);
+ }
av_freep(&cat->files[i].streams);
av_dict_free(&cat->files[i].metadata);
}
+ if (cat->avf)
+ avformat_close_input(&cat->avf);
av_freep(&cat->files);
return 0;
}
@@ -499,7 +527,8 @@ static int filter_packet(AVFormatContext *avf, ConcatStream *cs, AVPacket *pkt)
av_assert0(cs->out_stream_index >= 0);
for (bsf = cs->bsf; bsf; bsf = bsf->next) {
pkt2 = *pkt;
- ret = av_bitstream_filter_filter(bsf, st->codec, NULL,
+
+ ret = av_bitstream_filter_filter(bsf, cs->avctx, NULL,
&pkt2.data, &pkt2.size,
pkt->data, pkt->size,
!!(pkt->flags & AV_PKT_FLAG_KEY));
@@ -507,6 +536,21 @@ static int filter_packet(AVFormatContext *avf, ConcatStream *cs, AVPacket *pkt)
av_packet_unref(pkt);
return ret;
}
+
+ if (cs->avctx->extradata_size > st->codecpar->extradata_size) {
+ int eret;
+ if (st->codecpar->extradata)
+ av_freep(&st->codecpar->extradata);
+
+ eret = ff_alloc_extradata(st->codecpar, cs->avctx->extradata_size);
+ if (eret < 0) {
+ av_packet_unref(pkt);
+ return AVERROR(ENOMEM);
+ }
+ st->codecpar->extradata_size = cs->avctx->extradata_size;
+ memcpy(st->codecpar->extradata, cs->avctx->extradata, cs->avctx->extradata_size);
+ }
+
av_assert0(pkt2.buf);
if (ret == 0 && pkt2.data != pkt->data) {
if ((ret = av_copy_packet(&pkt2, pkt)) < 0) {
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 931d32d145..8ddf0f36e6 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -109,19 +109,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)
@@ -132,17 +132,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')) {
@@ -151,8 +151,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) {
@@ -515,10 +515,10 @@ static int write_manifest(AVFormatContext *s, int final)
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\"", 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\"", i, os->codec_str, os->bandwidth_str, st->codecpar->width, st->codecpar->height);
if (st->avg_frame_rate.num)
avio_printf(out, " frameRate=\"%d/%d\"", st->avg_frame_rate.num, st->avg_frame_rate.den);
avio_printf(out, ">\n");
@@ -534,11 +534,11 @@ static int write_manifest(AVFormatContext *s, int final)
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");
}
@@ -598,9 +598,7 @@ static int dash_write_header(AVFormatContext *s)
AVDictionary *opts = NULL;
char filename[1024];
- os->bit_rate = s->streams[i]->codec->bit_rate ?
- s->streams[i]->codec->bit_rate :
- s->streams[i]->codec->rc_max_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);
@@ -630,7 +628,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;
@@ -670,7 +668,7 @@ 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) {
AVRational avg_frame_rate = s->streams[i]->avg_frame_rate;
if (avg_frame_rate.num > 0) {
if (av_cmp_q(avg_frame_rate, c->min_frame_rate) < 0)
@@ -681,11 +679,11 @@ static int dash_write_header(AVFormatContext *s)
c->ambiguous_frame_rate = 1;
}
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;
@@ -774,24 +772,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;
}
@@ -817,7 +815,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.
@@ -896,7 +894,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;
@@ -921,7 +919,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) {
diff --git a/libavformat/dauddec.c b/libavformat/dauddec.c
index f6e7491985..69196b0a1a 100644
--- a/libavformat/dauddec.c
+++ b/libavformat/dauddec.c
@@ -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;
}
diff --git a/libavformat/daudenc.c b/libavformat/daudenc.c
index 99b18d35aa..15a5afdfc9 100644
--- a/libavformat/daudenc.c
+++ b/libavformat/daudenc.c
@@ -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;
}
diff --git a/libavformat/dcstr.c b/libavformat/dcstr.c
index 2ae61dec85..69fae417e8 100644
--- a/libavformat/dcstr.c
+++ b/libavformat/dcstr.c
@@ -39,35 +39,35 @@ static int dcstr_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->channels = avio_rl32(s->pb);
- st->codec->sample_rate = avio_rl32(s->pb);
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->channels = avio_rl32(s->pb);
+ st->codecpar->sample_rate = avio_rl32(s->pb);
codec = avio_rl32(s->pb);
align = avio_rl32(s->pb);
avio_skip(s->pb, 4);
st->duration = avio_rl32(s->pb);
- st->codec->channels *= avio_rl32(s->pb);
- if (!align || align > INT_MAX / st->codec->channels)
+ st->codecpar->channels *= avio_rl32(s->pb);
+ if (!align || align > INT_MAX / st->codecpar->channels)
return AVERROR_INVALIDDATA;
- st->codec->block_align = align * st->codec->channels;
+ st->codecpar->block_align = align * st->codecpar->channels;
switch (codec) {
- case 4: st->codec->codec_id = AV_CODEC_ID_ADPCM_AICA; break;
- case 16: st->codec->codec_id = AV_CODEC_ID_PCM_S16LE_PLANAR; break;
+ case 4: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_AICA; break;
+ case 16: st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE_PLANAR; break;
default: avpriv_request_sample(s, "codec %X", codec);
return AVERROR_PATCHWELCOME;
}
avio_skip(s->pb, 0x800 - avio_tell(s->pb));
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
static int dcstr_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- AVCodecContext *codec = s->streams[0]->codec;
- return av_get_packet(s->pb, pkt, codec->block_align);
+ AVCodecParameters *par = s->streams[0]->codecpar;
+ return av_get_packet(s->pb, pkt, par->block_align);
}
AVInputFormat ff_dcstr_demuxer = {
diff --git a/libavformat/dfa.c b/libavformat/dfa.c
index b16672ccde..9858ee7941 100644
--- a/libavformat/dfa.c
+++ b/libavformat/dfa.c
@@ -56,10 +56,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");
@@ -69,9 +69,9 @@ static int dfa_read_header(AVFormatContext *s)
avio_skip(pb, 128 - 16); // padding
st->duration = frames;
- if (ff_alloc_extradata(st->codec, 2))
+ if (ff_alloc_extradata(st->codecpar, 2))
return AVERROR(ENOMEM);
- AV_WL16(st->codec->extradata, version);
+ AV_WL16(st->codecpar->extradata, version);
if (version == 0x100)
st->sample_aspect_ratio = (AVRational){2, 1};
diff --git a/libavformat/dsfdec.c b/libavformat/dsfdec.c
index ae198b2e93..beb2fbf5aa 100644
--- a/libavformat/dsfdec.c
+++ b/libavformat/dsfdec.c
@@ -99,29 +99,29 @@ static int dsf_read_header(AVFormatContext *s)
channel_type = avio_rl32(pb);
if (channel_type < FF_ARRAY_ELEMS(dsf_channel_layout))
- st->codec->channel_layout = dsf_channel_layout[channel_type];
- if (!st->codec->channel_layout)
+ st->codecpar->channel_layout = dsf_channel_layout[channel_type];
+ if (!st->codecpar->channel_layout)
avpriv_request_sample(s, "channel type %i", channel_type);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->channels = avio_rl32(pb);
- st->codec->sample_rate = avio_rl32(pb) / 8;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->channels = avio_rl32(pb);
+ st->codecpar->sample_rate = avio_rl32(pb) / 8;
switch(avio_rl32(pb)) {
- case 1: st->codec->codec_id = AV_CODEC_ID_DSD_LSBF_PLANAR; break;
- case 8: st->codec->codec_id = AV_CODEC_ID_DSD_MSBF_PLANAR; break;
+ case 1: st->codecpar->codec_id = AV_CODEC_ID_DSD_LSBF_PLANAR; break;
+ case 8: st->codecpar->codec_id = AV_CODEC_ID_DSD_MSBF_PLANAR; break;
default:
avpriv_request_sample(s, "unknown most significant bit");
return AVERROR_INVALIDDATA;
}
avio_skip(pb, 8);
- st->codec->block_align = avio_rl32(pb);
- if (st->codec->block_align > INT_MAX / st->codec->channels) {
+ st->codecpar->block_align = avio_rl32(pb);
+ if (st->codecpar->block_align > INT_MAX / st->codecpar->channels) {
avpriv_request_sample(s, "block_align overflow");
return AVERROR_INVALIDDATA;
}
- st->codec->block_align *= st->codec->channels;
+ st->codecpar->block_align *= st->codecpar->channels;
avio_skip(pb, 4);
/* data chunk */
@@ -145,7 +145,7 @@ static int dsf_read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR_EOF;
pkt->stream_index = 0;
- return av_get_packet(pb, pkt, FFMIN(dsf->data_end - pos, st->codec->block_align));
+ return av_get_packet(pb, pkt, FFMIN(dsf->data_end - pos, st->codecpar->block_align));
}
AVInputFormat ff_dsf_demuxer = {
diff --git a/libavformat/dsicin.c b/libavformat/dsicin.c
index 6ba8c28c7e..bd4f3ad03a 100644
--- a/libavformat/dsicin.c
+++ b/libavformat/dsicin.c
@@ -116,11 +116,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);
@@ -129,14 +129,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;
}
diff --git a/libavformat/dss.c b/libavformat/dss.c
index bf7a1a4eaf..2f7f20d134 100644
--- a/libavformat/dss.c
+++ b/libavformat/dss.c
@@ -144,22 +144,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 = 11025;
+ st->codecpar->codec_id = AV_CODEC_ID_DSS_SP;
+ st->codecpar->sample_rate = 11025;
} 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 */
@@ -235,7 +235,7 @@ static int dss_sp_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->duration = 264;
pkt->pos = pos;
pkt->stream_index = 0;
- s->bit_rate = 8LL * ctx->packet_size * st->codec->sample_rate * 512 / (506 * pkt->duration);
+ s->bit_rate = 8LL * ctx->packet_size * st->codecpar->sample_rate * 512 / (506 * pkt->duration);
if (ctx->counter < 0) {
int size2 = ctx->counter + read_size;
@@ -299,7 +299,7 @@ static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->data[0] = byte;
offset = 1;
pkt->duration = 240;
- s->bit_rate = 8LL * size * st->codec->sample_rate * 512 / (506 * pkt->duration);
+ s->bit_rate = 8LL * size * st->codecpar->sample_rate * 512 / (506 * pkt->duration);
pkt->stream_index = 0;
diff --git a/libavformat/dtshddec.c b/libavformat/dtshddec.c
index 0fd0304703..f3af096f3a 100644
--- a/libavformat/dtshddec.c
+++ b/libavformat/dtshddec.c
@@ -60,9 +60,9 @@ static int dtshd_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_id = AV_CODEC_ID_DTS;
- st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_DTS;
+ st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
while (!avio_feof(pb)) {
chunk_type = avio_rb64(pb);
diff --git a/libavformat/dump.c b/libavformat/dump.c
index 86bb82da13..3d117f6fdf 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -440,14 +440,24 @@ static void dump_stream_format(AVFormatContext *ic, int i,
AVStream *st = ic->streams[i];
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
char *separator = ic->dump_separator;
- char **codec_separator = av_opt_ptr(st->codec->av_class, st->codec, "dump_separator");
- int use_format_separator = !*codec_separator;
-
- if (use_format_separator)
- *codec_separator = av_strdup(separator);
- avcodec_string(buf, sizeof(buf), st->codec, is_output);
- if (use_format_separator)
- av_freep(codec_separator);
+ 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;
+ }
+
+ if (separator)
+ av_opt_set(avctx, "dump_separator", separator, 0);
+ avcodec_string(buf, sizeof(buf), avctx, is_output);
+ avcodec_free_context(&avctx);
+
av_log(NULL, AV_LOG_INFO, " Stream #%d:%d", index, i);
/* the pid is an important information, so we display it */
@@ -460,35 +470,32 @@ 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 &&
+ av_cmp_q(st->sample_aspect_ratio, st->codecpar->sample_aspect_ratio)) {
AVRational display_aspect_ratio;
av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
- st->codec->width * (int64_t)st->sample_aspect_ratio.num,
- st->codec->height * (int64_t)st->sample_aspect_ratio.den,
+ st->codecpar->width * (int64_t)st->sample_aspect_ratio.num,
+ st->codecpar->height * (int64_t)st->sample_aspect_ratio.den,
1024 * 1024);
av_log(NULL, AV_LOG_INFO, ", SAR %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 tbr = st->r_frame_rate.den && st->r_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 || tbr || tbn || tbc)
+ if (fps || tbr || tbn)
av_log(NULL, AV_LOG_INFO, "%s", separator);
if (fps)
- print_fps(av_q2d(st->avg_frame_rate), tbr || tbn || tbc ? "fps, " : "fps");
+ print_fps(av_q2d(st->avg_frame_rate), tbr || tbn ? "fps, " : "fps");
if (tbr)
- print_fps(av_q2d(st->r_frame_rate), tbn || tbc ? "tbr, " : "tbr");
+ print_fps(av_q2d(st->r_frame_rate), tbn ? "tbr, " : "tbr");
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)
diff --git a/libavformat/dv.c b/libavformat/dv.c
index b41d123996..c689d9b100 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -259,8 +259,8 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 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;
@@ -268,10 +268,10 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 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;
@@ -282,10 +282,10 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame)
static int dv_extract_video_info(DVDemuxContext *c, const uint8_t *frame)
{
const uint8_t *vsc_pack;
- AVCodecContext *avctx;
+ AVCodecParameters *par;
int apt, is16_9;
- avctx = c->vst->codec;
+ par = c->vst->codecpar;
avpriv_set_pts_info(c->vst, 64, c->sys->time_base.num,
c->sys->time_base.den);
@@ -297,7 +297,7 @@ static int dv_extract_video_info(DVDemuxContext *c, const 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,
+ par->bit_rate = av_rescale_q(c->sys->frame_size,
(AVRational) { 8, 1 },
c->sys->time_base);
return c->sys->frame_size;
@@ -336,9 +336,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;
@@ -380,7 +380,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
c->audio_pkt[i].pos = pos;
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)
@@ -439,7 +439,7 @@ void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
if (c->ach) {
if (c->sys) {
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 });
} else
av_log(c->fctx, AV_LOG_ERROR, "cannot adjust audio bytes\n");
}
diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index 6cefe8be40..7ff2b729a0 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -105,13 +105,13 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu
case dv_audio_source: /* AAUX source pack */
va_start(ap, buf);
channel = va_arg(ap, int);
- if (c->ast[channel]->codec->sample_rate == 44100) {
+ if (c->ast[channel]->codecpar->sample_rate == 44100) {
audio_type = 1;
- } else if (c->ast[channel]->codec->sample_rate == 32000)
+ } else if (c->ast[channel]->codecpar->sample_rate == 32000)
audio_type = 2;
buf[1] = (1 << 7) | /* locked mode -- SMPTE only supports locked mode */
(1 << 6) | /* reserved -- always 1 */
- (dv_audio_frame_size(c->sys, c->frames, c->ast[channel]->codec->sample_rate) -
+ (dv_audio_frame_size(c->sys, c->frames, c->ast[channel]->codecpar->sample_rate) -
c->sys->audio_min_samples[audio_type]);
/* # of samples */
buf[2] = (0 << 7) | /* multi-stereo */
@@ -186,7 +186,7 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu
static void dv_inject_audio(DVMuxContext *c, int channel, uint8_t* frame_ptr)
{
int i, j, d, of, size;
- size = 4 * dv_audio_frame_size(c->sys, c->frames, c->ast[channel]->codec->sample_rate);
+ size = 4 * dv_audio_frame_size(c->sys, c->frames, c->ast[channel]->codecpar->sample_rate);
frame_ptr += channel * c->sys->difseg_size * 150 * 80;
for (i = 0; i < c->sys->difseg_size; i++) {
frame_ptr += 6 * 80; /* skip DIF segment header */
@@ -238,20 +238,21 @@ 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;
*frame = &c->frame_buf[0];
- 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);
}
@@ -264,10 +265,10 @@ 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);
- reqasize = 4 * dv_audio_frame_size(c->sys, c->frames, st->codec->sample_rate);
+ reqasize = 4 * dv_audio_frame_size(c->sys, c->frames, st->codecpar->sample_rate);
/* Let us see if we've got enough audio for one DV frame. */
c->has_audio |= ((reqasize <= av_fifo_size(c->audio_data[i])) << i);
@@ -283,7 +284,7 @@ static int dv_assemble_frame(DVMuxContext *c, AVStream* st,
c->has_audio = 0;
for (i=0; i < c->n_ast; i++) {
dv_inject_audio(c, i, *frame);
- reqasize = 4 * dv_audio_frame_size(c->sys, c->frames, c->ast[i]->codec->sample_rate);
+ reqasize = 4 * dv_audio_frame_size(c->sys, c->frames, c->ast[i]->codecpar->sample_rate);
av_fifo_drain(c->audio_data[i], reqasize);
c->has_audio |= ((reqasize <= av_fifo_size(c->audio_data[i])) << i);
}
@@ -313,7 +314,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];
@@ -328,28 +329,28 @@ 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]) {
- if(c->ast[i]->codec->codec_id != AV_CODEC_ID_PCM_S16LE ||
- c->ast[i]->codec->channels != 2)
+ if(c->ast[i]->codecpar->codec_id != AV_CODEC_ID_PCM_S16LE ||
+ c->ast[i]->codecpar->channels != 2)
goto bail_out;
- if (c->ast[i]->codec->sample_rate != 48000 &&
- c->ast[i]->codec->sample_rate != 44100 &&
- c->ast[i]->codec->sample_rate != 32000 )
+ if (c->ast[i]->codecpar->sample_rate != 48000 &&
+ c->ast[i]->codecpar->sample_rate != 44100 &&
+ c->ast[i]->codecpar->sample_rate != 32000 )
goto bail_out;
}
}
- c->sys = av_dv_codec_profile2(vst->codec->width, vst->codec->height,
- vst->codec->pix_fmt, vst->codec->time_base);
+ c->sys = av_dv_codec_profile2(vst->codecpar->width, vst->codecpar->height,
+ vst->codecpar->format, vst->time_base);
if (!c->sys)
goto bail_out;
if ((c->sys->time_base.den != 25 && c->sys->time_base.den != 50) || c->sys->time_base.num != 1) {
- if (c->ast[0] && c->ast[0]->codec->sample_rate != 48000)
+ if (c->ast[0] && c->ast[0]->codecpar->sample_rate != 48000)
goto bail_out;
- if (c->ast[1] && c->ast[1]->codec->sample_rate != 48000)
+ if (c->ast[1] && c->ast[1]->codecpar->sample_rate != 48000)
goto bail_out;
}
@@ -420,7 +421,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);
diff --git a/libavformat/dxa.c b/libavformat/dxa.c
index 1a5822aab8..162838c135 100644
--- a/libavformat/dxa.c
+++ b/libavformat/dxa.c
@@ -106,11 +106,11 @@ static int dxa_read_header(AVFormatContext *s)
ast = avformat_new_stream(s, NULL);
if (!ast)
return AVERROR(ENOMEM);
- ret = ff_get_wav_header(s, pb, ast->codec, fsize, 0);
+ ret = ff_get_wav_header(s, pb, ast->codecpar, fsize, 0);
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 && !avio_feof(pb)){
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);
diff --git a/libavformat/eacdata.c b/libavformat/eacdata.c
index 165ff1af99..97eb66e36d 100644
--- a/libavformat/eacdata.c
+++ b/libavformat/eacdata.c
@@ -70,12 +70,12 @@ 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->channel_layout = channel_layout;
- 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->channel_layout = channel_layout;
+ st->codecpar->sample_rate = sample_rate;
avpriv_set_pts_info(st, 64, 1, sample_rate);
cdata->audio_pts = 0;
diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c
index 8601782afa..b27da65801 100644
--- a/libavformat/electronicarts.c
+++ b/libavformat/electronicarts.c
@@ -499,14 +499,14 @@ static int init_video_stream(AVFormatContext *s, VideoProperties *video)
if (!st)
return AVERROR(ENOMEM);
video->stream_index = st->index;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = video->codec;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = video->codec;
// parsing is necessary to make FFmpeg generate correct timestamps
- if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO)
+ if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO)
st->need_parsing = AVSTREAM_PARSE_HEADERS;
- st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = video->width;
- st->codec->height = video->height;
+ st->codecpar->codec_tag = 0; /* no fourcc */
+ st->codecpar->width = video->width;
+ st->codecpar->height = video->height;
st->duration = st->nb_frames = video->nb_frames;
if (video->time_base.num)
avpriv_set_pts_info(st, 64, video->time_base.num, video->time_base.den);
@@ -551,17 +551,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;
}
diff --git a/libavformat/epafdec.c b/libavformat/epafdec.c
index c737892325..29190fff72 100644
--- a/libavformat/epafdec.c
+++ b/libavformat/epafdec.c
@@ -66,15 +66,15 @@ static int epaf_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->channels = channels;
- st->codec->sample_rate = sample_rate;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->channels = channels;
+ st->codecpar->sample_rate = sample_rate;
switch (codec) {
case 0:
- st->codec->codec_id = le ? AV_CODEC_ID_PCM_S16LE : AV_CODEC_ID_PCM_S16BE;
+ st->codecpar->codec_id = le ? AV_CODEC_ID_PCM_S16LE : AV_CODEC_ID_PCM_S16BE;
break;
case 2:
- st->codec->codec_id = AV_CODEC_ID_PCM_S8;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S8;
break;
case 1:
avpriv_request_sample(s, "24-bit Paris PCM format");
@@ -82,10 +82,10 @@ static int epaf_read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
- st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id);
- st->codec->block_align = st->codec->bits_per_coded_sample * st->codec->channels / 8;
+ st->codecpar->bits_per_coded_sample = av_get_bits_per_sample(st->codecpar->codec_id);
+ st->codecpar->block_align = st->codecpar->bits_per_coded_sample * st->codecpar->channels / 8;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
if (avio_skip(s->pb, 2024) < 0)
return AVERROR_INVALIDDATA;
diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index 257319bd06..53a9f1fca9 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -283,7 +283,7 @@ static int ffm2_read_header(AVFormatContext *s)
AVIOContext *pb = s->pb;
AVCodecContext *codec;
const AVCodecDescriptor *codec_desc;
- int ret;
+ int ret, i;
int f_main = 0, f_cprv = -1, f_stvi = -1, f_stau = -1;
AVCodec *enc;
char *buffer;
@@ -356,8 +356,12 @@ static int ffm2_read_header(AVFormatContext *s)
codec->flags2 = avio_rb32(pb);
codec->debug = avio_rb32(pb);
if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
- if (ff_get_extradata(codec, pb, avio_rb32(pb)) < 0)
+ int size = avio_rb32(pb);
+ codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!codec->extradata)
return AVERROR(ENOMEM);
+ codec->extradata_size = size;
+ avio_read(pb, codec->extradata, size);
}
break;
case MKBETAG('S', 'T', 'V', 'I'):
@@ -476,6 +480,9 @@ static int ffm2_read_header(AVFormatContext *s)
avio_seek(pb, next, SEEK_SET);
}
+ for (i = 0; i < s->nb_streams; i++)
+ avcodec_parameters_from_context(s->streams[i]->codecpar, s->streams[i]->codec);
+
/* get until end of block reached */
while ((avio_tell(pb) % ffm->packet_size) != 0 && !pb->eof_reached)
avio_r8(pb);
@@ -617,9 +624,15 @@ static int ffm_read_header(AVFormatContext *s)
goto fail;
}
if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
- if (ff_get_extradata(codec, pb, avio_rb32(pb)) < 0)
+ int size = avio_rb32(pb);
+ codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!codec->extradata)
return AVERROR(ENOMEM);
+ codec->extradata_size = size;
+ avio_read(pb, codec->extradata, size);
}
+
+ avcodec_parameters_from_context(st->codecpar, codec);
}
/* get until end of block reached */
diff --git a/libavformat/ffmetadec.c b/libavformat/ffmetadec.c
index e226406932..3290b3b7bc 100644
--- a/libavformat/ffmetadec.c
+++ b/libavformat/ffmetadec.c
@@ -139,8 +139,8 @@ static int read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- 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))) {
diff --git a/libavformat/filmstripdec.c b/libavformat/filmstripdec.c
index cdbb93b11a..414e276bfe 100644
--- a/libavformat/filmstripdec.c
+++ b/libavformat/filmstripdec.c
@@ -60,15 +60,15 @@ 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);
- if (st->codec->width * 4LL * st->codec->height >= INT_MAX) {
+ if (st->codecpar->width * 4LL * st->codecpar->height >= INT_MAX) {
av_log(s, AV_LOG_ERROR, "dimensions too large\n");
return AVERROR_PATCHWELCOME;
}
@@ -88,9 +88,9 @@ static int read_packet(AVFormatContext *s,
if (avio_feof(s->pb))
return AVERROR(EIO);
- pkt->dts = avio_tell(s->pb) / (st->codec->width * (int64_t)(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 * (int64_t)(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;
@@ -100,7 +100,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;
}
diff --git a/libavformat/filmstripenc.c b/libavformat/filmstripenc.c
index 9e2c71082f..8ead696360 100644
--- a/libavformat/filmstripenc.c
+++ b/libavformat/filmstripenc.c
@@ -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, st->time_base.den / st->time_base.num);
diff --git a/libavformat/flac_picture.c b/libavformat/flac_picture.c
index 7bd98258e4..a3217f02a6 100644
--- a/libavformat/flac_picture.c
+++ b/libavformat/flac_picture.c
@@ -132,10 +132,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);
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index eb92216c45..19f10629c5 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -52,8 +52,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_RAW;
/* the parameters will be extracted from the compressed bitstream */
@@ -102,14 +102,14 @@ static int flac_read_header(AVFormatContext *s)
RETURN_ERROR(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) {
@@ -189,7 +189,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);
}
}
@@ -248,7 +248,7 @@ static av_unused int64_t flac_read_timestamp(AVFormatContext *s, int stream_inde
return AV_NOPTS_VALUE;
av_init_packet(&pkt);
- parser = av_parser_init(st->codec->codec_id);
+ parser = av_parser_init(st->codecpar->codec_id);
if (!parser){
return AV_NOPTS_VALUE;
}
@@ -263,7 +263,7 @@ static av_unused int64_t flac_read_timestamp(AVFormatContext *s, int stream_inde
break;
}
av_init_packet(&out_pkt);
- av_parser_parse2(parser, st->codec,
+ av_parser_parse2(parser, st->internal->avctx,
&out_pkt.data, &out_pkt.size, pkt.data, pkt.size,
pkt.pts, pkt.dts, *ppos);
diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index 321af50e6a..89b21e9e23 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -78,7 +78,7 @@ static int flac_write_header(struct AVFormatContext *s)
{
int ret;
int padding = s->metadata_header_padding;
- AVCodecContext *codec = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
FlacMuxerContext *c = s->priv_data;
if (!c->write_header)
@@ -88,7 +88,7 @@ static int flac_write_header(struct AVFormatContext *s)
av_log(s, AV_LOG_ERROR, "only one stream is supported\n");
return AVERROR(EINVAL);
}
- if (codec->codec_id != AV_CODEC_ID_FLAC) {
+ if (par->codec_id != AV_CODEC_ID_FLAC) {
av_log(s, AV_LOG_ERROR, "unsupported codec\n");
return AVERROR(EINVAL);
}
@@ -99,15 +99,15 @@ static int flac_write_header(struct AVFormatContext *s)
* size of a metadata block so we must clip this value to 2^24-1. */
padding = av_clip_uintp2(padding, 24);
- 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);
@@ -116,7 +116,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);
}
}
@@ -142,7 +142,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;
diff --git a/libavformat/flic.c b/libavformat/flic.c
index 30de35158f..343b88852d 100644
--- a/libavformat/flic.c
+++ b/libavformat/flic.c
@@ -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.mplayerhq.hu/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 */
- if (ff_alloc_extradata(st->codec, FLIC_HEADER_SIZE))
+ if (ff_alloc_extradata(st->codecpar, FLIC_HEADER_SIZE))
return AVERROR(ENOMEM);
- memcpy(st->codec->extradata, header, 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,21 +152,21 @@ 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->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->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);
@@ -175,10 +175,10 @@ static int flic_read_header(AVFormatContext *s)
avio_seek(pb, 12, SEEK_SET);
/* send over abbreviated FLIC header chunk */
- av_freep(&st->codec->extradata);
- if (ff_alloc_extradata(st->codec, 12))
+ av_freep(&st->codecpar->extradata);
+ if (ff_alloc_extradata(st->codecpar, 12))
return AVERROR(ENOMEM);
- memcpy(st->codec->extradata, header, 12);
+ memcpy(st->codecpar->extradata, header, 12);
} else if (magic_number == FLIC_FILE_MAGIC_1) {
avpriv_set_pts_info(st, 64, speed, 70);
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 5090ac2157..04f20db1a5 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -97,26 +97,26 @@ 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;
if (s->nb_streams>=3 ||( s->nb_streams==2
- && s->streams[0]->codec->codec_type != AVMEDIA_TYPE_SUBTITLE
- && s->streams[1]->codec->codec_type != AVMEDIA_TYPE_SUBTITLE))
+ && s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE
+ && s->streams[1]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE))
s->ctx_flags &= ~AVFMTCTX_NOHEADER;
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) {
@@ -129,42 +129,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;
@@ -173,118 +173,118 @@ 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:
avpriv_request_sample(s, "Audio codec (%x)",
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_REALH263:
- vcodec->codec_id = AV_CODEC_ID_H263;
+ par->codec_id = AV_CODEC_ID_H263;
break; // Really mean it this time
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) {
- ff_alloc_extradata(vcodec, 1);
+ if (par->extradata_size != 1) {
+ ff_alloc_extradata(par, 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;
vstream->need_parsing = AVSTREAM_PARSE_HEADERS;
return 3; // not 4, reading packet type will consume one byte
case FLV_CODECID_MPEG4:
- vcodec->codec_id = AV_CODEC_ID_MPEG4;
+ par->codec_id = AV_CODEC_ID_MPEG4;
return 3;
default:
avpriv_request_sample(s, "Video codec (%x)", flv_codecid);
- vcodec->codec_tag = flv_codecid;
+ par->codec_tag = flv_codecid;
}
return 0;
@@ -393,7 +393,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;
@@ -477,8 +477,8 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
}
if (key) {
- acodec = astream ? astream->codec : NULL;
- vcodec = vstream ? vstream->codec : NULL;
+ apar = astream ? astream->codecpar : NULL;
+ vpar = vstream ? vstream->codecpar : NULL;
// stream info doesn't live any deeper than the first object
if (depth == 1) {
@@ -486,36 +486,36 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
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_SUBTITLE);
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;
}
}
}
@@ -533,8 +533,8 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
}
if (amf_type == AMF_DATA_TYPE_OBJECT && s->nb_streams == 1 &&
- ((!acodec && !strcmp(key, "audiocodecid")) ||
- (!vcodec && !strcmp(key, "videocodecid"))))
+ ((!apar && !strcmp(key, "audiocodecid")) ||
+ (!vpar && !strcmp(key, "videocodecid"))))
s->ctx_flags &= ~AVFMTCTX_NOHEADER; //If there is either audio/video missing, codecid will be an empty object
if (!strcmp(key, "duration") ||
@@ -612,11 +612,11 @@ 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_VIDEO)
+ if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
vstream = stream;
- else if (stream->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+ else if (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
astream = stream;
- else if (stream->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)
+ else if (stream->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
dstream = stream;
}
@@ -629,23 +629,14 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
static int flv_read_header(AVFormatContext *s)
{
- int offset, flags;
FLVContext *flv = s->priv_data;
+ int offset;
avio_skip(s->pb, 4);
- flags = avio_r8(s->pb);
+ avio_r8(s->pb); // flags
s->ctx_flags |= AVFMTCTX_NOHEADER;
- if (flags & FLV_HEADER_FLAG_HASVIDEO)
- if (!create_stream(s, AVMEDIA_TYPE_VIDEO))
- return AVERROR(ENOMEM);
- if (flags & FLV_HEADER_FLAG_HASAUDIO)
- if (!create_stream(s, AVMEDIA_TYPE_AUDIO))
- return AVERROR(ENOMEM);
- // Flag doesn't indicate whether or not there is script-data present. Must
- // create that stream if it's encountered.
-
offset = avio_rb32(s->pb);
avio_seek(s->pb, offset, SEEK_SET);
avio_skip(s->pb, 4);
@@ -667,8 +658,8 @@ static int flv_read_close(AVFormatContext *s)
static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size)
{
- av_freep(&st->codec->extradata);
- if (ff_get_extradata(st->codec, s->pb, size) < 0)
+ av_freep(&st->codecpar->extradata);
+ if (ff_get_extradata(st->codecpar, s->pb, size) < 0)
return AVERROR(ENOMEM);
return 0;
}
@@ -786,7 +777,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_SUBTITLE)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
break;
}
@@ -794,7 +785,7 @@ static int flv_data_packet(AVFormatContext *s, AVPacket *pkt,
st = create_stream(s, AVMEDIA_TYPE_SUBTITLE);
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_id = AV_CODEC_ID_TEXT;
+ st->codecpar->codec_id = AV_CODEC_ID_TEXT;
}
pkt->dts = dts;
@@ -945,15 +936,15 @@ skip:
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
if (stream_type == FLV_STREAM_TYPE_AUDIO) {
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
- (s->audio_codec_id || flv_same_audio_codec(st->codec, flags)))
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
+ (s->audio_codec_id || flv_same_audio_codec(st->codecpar, flags)))
break;
} else if (stream_type == FLV_STREAM_TYPE_VIDEO) {
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
- (s->video_codec_id || flv_same_video_codec(st->codec, flags)))
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
+ (s->video_codec_id || flv_same_video_codec(st->codecpar, flags)))
break;
} else if (stream_type == FLV_STREAM_TYPE_DATA) {
- if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
break;
}
}
@@ -1019,41 +1010,46 @@ retry_duration:
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 = {0};
- 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 if (stream_type == FLV_STREAM_TYPE_VIDEO) {
size -= flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK, 1);
} else if (stream_type == FLV_STREAM_TYPE_DATA) {
- st->codec->codec_id = AV_CODEC_ID_TEXT;
+ st->codecpar->codec_id = AV_CODEC_ID_TEXT;
}
- if (st->codec->codec_id == AV_CODEC_ID_AAC ||
- st->codec->codec_id == AV_CODEC_ID_H264 ||
- st->codec->codec_id == AV_CODEC_ID_MPEG4) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_AAC ||
+ st->codecpar->codec_id == AV_CODEC_ID_H264 ||
+ st->codecpar->codec_id == AV_CODEC_ID_MPEG4) {
int type = avio_r8(s->pb);
size--;
- if (st->codec->codec_id == AV_CODEC_ID_H264 || st->codec->codec_id == AV_CODEC_ID_MPEG4) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4) {
// sign extension
int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000;
pts = dts + cts;
@@ -1068,11 +1064,11 @@ retry_duration:
dts = pts = AV_NOPTS_VALUE;
}
}
- if (type == 0 && (!st->codec->extradata || st->codec->codec_id == AV_CODEC_ID_AAC ||
- st->codec->codec_id == AV_CODEC_ID_H264)) {
+ if (type == 0 && (!st->codecpar->extradata || st->codecpar->codec_id == AV_CODEC_ID_AAC ||
+ st->codecpar->codec_id == AV_CODEC_ID_H264)) {
AVDictionaryEntry *t;
- if (st->codec->extradata) {
+ if (st->codecpar->extradata) {
if ((ret = flv_queue_extradata(flv, s->pb, stream_type, size)) < 0)
return ret;
ret = FFERROR_REDO;
@@ -1083,22 +1079,22 @@ retry_duration:
/* Workaround for buggy Omnia A/XE encoder */
t = av_dict_get(s->metadata, "Encoder", NULL, 0);
- if (st->codec->codec_id == AV_CODEC_ID_AAC && t && !strcmp(t->value, "Omnia A/XE"))
- st->codec->extradata_size = 2;
+ if (st->codecpar->codec_id == AV_CODEC_ID_AAC && t && !strcmp(t->value, "Omnia A/XE"))
+ st->codecpar->extradata_size = 2;
- if (st->codec->codec_id == AV_CODEC_ID_AAC && 0) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_AAC && 0) {
MPEG4AudioConfig cfg;
- if (avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata,
- st->codec->extradata_size * 8, 1) >= 0) {
- st->codec->channels = cfg.channels;
- st->codec->channel_layout = 0;
+ if (avpriv_mpeg4audio_get_config(&cfg, st->codecpar->extradata,
+ st->codecpar->extradata_size * 8, 1) >= 0) {
+ 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);
}
}
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index ab71d41df7..d62ff70933 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -68,10 +68,10 @@ 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;
int flags;
} FLVContext;
@@ -80,27 +80,27 @@ 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 AVERROR(EINVAL);
}
- if (enc->channels != 1) {
+ if (par->channels != 1) {
av_log(s, AV_LOG_ERROR, "FLV only supports mono Speex audio\n");
return AVERROR(EINVAL);
}
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;
@@ -113,22 +113,22 @@ 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;
}
default:
av_log(s, AV_LOG_ERROR,
"FLV does not support sample rate %d, "
- "choose from (44100, 22050, 11025)\n", enc->sample_rate);
+ "choose from (44100, 22050, 11025)\n", par->sample_rate);
return AVERROR(EINVAL);
}
}
- 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;
@@ -145,9 +145,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;
@@ -159,11 +159,11 @@ 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, "Audio codec '%s' not compatible with FLV\n",
- avcodec_get_name(enc->codec_id));
+ avcodec_get_name(par->codec_id));
return AVERROR(EINVAL);
}
@@ -226,9 +226,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);
@@ -239,15 +239,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");
@@ -256,27 +256,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);
}
@@ -351,68 +351,68 @@ 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);
- if (enc->codec_id == AV_CODEC_ID_MPEG4 ||
- enc->codec_id == AV_CODEC_ID_H263) {
+ if (par->codec_id == AV_CODEC_ID_MPEG4 ||
+ par->codec_id == AV_CODEC_ID_H263) {
int error = s->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL;
av_log(s, error ? AV_LOG_ERROR : AV_LOG_WARNING,
- "Codec %s is not supported in the official FLV specification,\n", avcodec_get_name(enc->codec_id));
+ "Codec %s is not supported in the official FLV specification,\n", avcodec_get_name(par->codec_id));
if (error) {
av_log(s, AV_LOG_ERROR,
"use vstrict=-1 / -strict -1 to use it anyway.\n");
return AVERROR(EINVAL);
}
- } else if (enc->codec_id == AV_CODEC_ID_VP6) {
+ } else if (par->codec_id == AV_CODEC_ID_VP6) {
av_log(s, AV_LOG_WARNING,
"Muxing VP6 in flv will produce flipped video on playback.\n");
}
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);
- if (enc->codec_id == AV_CODEC_ID_PCM_S16BE)
+ flv->audio_par = par;
+ if (get_audio_flags(s, par) < 0)
+ return unsupported_codec(s, "Audio", par->codec_id);
+ if (par->codec_id == AV_CODEC_ID_PCM_S16BE)
av_log(s, AV_LOG_WARNING,
"16-bit big-endian audio in flv is valid but most likely unplayable (hardware dependent); use s16le\n");
break;
case AVMEDIA_TYPE_DATA:
- if (enc->codec_id != AV_CODEC_ID_TEXT && enc->codec_id != AV_CODEC_ID_NONE)
- return unsupported_codec(s, "Data", enc->codec_id);
- flv->data_enc = enc;
+ if (par->codec_id != AV_CODEC_ID_TEXT && par->codec_id != AV_CODEC_ID_NONE)
+ return unsupported_codec(s, "Data", par->codec_id);
+ flv->data_par = par;
break;
case AVMEDIA_TYPE_SUBTITLE:
- if (enc->codec_id != AV_CODEC_ID_TEXT) {
+ if (par->codec_id != AV_CODEC_ID_TEXT) {
av_log(s, AV_LOG_ERROR, "Subtitle codec '%s' for stream %d is not compatible with FLV\n",
- avcodec_get_name(enc->codec_id), i);
+ avcodec_get_name(par->codec_id), i);
return AVERROR_INVALIDDATA;
}
- flv->data_enc = enc;
+ flv->data_par = par;
break;
default:
av_log(s, AV_LOG_ERROR, "Codec type '%s' for stream %d is not compatible with FLV\n",
- av_get_media_type_string(enc->codec_type), i);
+ av_get_media_type_string(par->codec_type), i);
return AVERROR(EINVAL);
}
avpriv_set_pts_info(s->streams[i], 32, 1, 1000); /* 32 bit pts in ms */
@@ -428,13 +428,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
@@ -446,32 +446,32 @@ 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 || enc->codec_id == AV_CODEC_ID_MPEG4) {
+ AVCodecParameters *par = s->streams[i]->codecpar;
+ if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4) {
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
- if (!enc->extradata_size && flv->flags & 1) {
+ if (!par->extradata_size && flv->flags & 1) {
PutBitContext pbc;
int samplerate_index;
- int channels = flv->audio_enc->channels - (flv->audio_enc->channels == 8 ? 1 : 0);
+ int channels = flv->audio_par->channels - (flv->audio_par->channels == 8 ? 1 : 0);
uint8_t data[2];
for (samplerate_index = 0; samplerate_index < 16; samplerate_index++)
- if (flv->audio_enc->sample_rate == mpeg4audio_sample_rates[samplerate_index])
+ if (flv->audio_par->sample_rate == mpeg4audio_sample_rates[samplerate_index])
break;
init_put_bits(&pbc, data, sizeof(data));
- put_bits(&pbc, 5, flv->audio_enc->profile + 1); //profile
+ put_bits(&pbc, 5, flv->audio_par->profile + 1); //profile
put_bits(&pbc, 4, samplerate_index); //sample rate index
put_bits(&pbc, 4, channels);
put_bits(&pbc, 1, 0); //frame length - 1024 samples
@@ -484,12 +484,12 @@ static int flv_write_header(AVFormatContext *s)
av_log(s, AV_LOG_WARNING, "AAC sequence header: %02x %02x.\n", data[0], data[1]);
}
- 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);
@@ -512,10 +512,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 || enc->codec_id == AV_CODEC_ID_MPEG4))
+ if (par->codec_type == AVMEDIA_TYPE_VIDEO &&
+ (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4))
put_avc_eos_tag(pb, sc->last_ts);
}
@@ -538,7 +538,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;
@@ -546,10 +546,10 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
uint8_t *data = NULL;
int flags = -1, flags_size, ret;
- if (enc->codec_id == AV_CODEC_ID_VP6F || enc->codec_id == AV_CODEC_ID_VP6A ||
- enc->codec_id == AV_CODEC_ID_VP6 || 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_VP6 || par->codec_id == AV_CODEC_ID_AAC)
flags_size = 2;
- else if (enc->codec_id == AV_CODEC_ID_H264 || enc->codec_id == AV_CODEC_ID_MPEG4)
+ else if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4)
flags_size = 5;
else
flags_size = 1;
@@ -570,16 +570,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);
av_assert0(size);
@@ -593,12 +593,12 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(EINVAL);
}
- if (enc->codec_id == AV_CODEC_ID_H264 || enc->codec_id == AV_CODEC_ID_MPEG4) {
+ if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4) {
/* check if extradata looks like mp4 formatted */
- if (enc->extradata_size > 0 && *(uint8_t*)enc->extradata != 1)
+ if (par->extradata_size > 0 && *(uint8_t*)par->extradata != 1)
if ((ret = ff_avc_parse_nal_units_buf(pkt->data, &data, &size)) < 0)
return ret;
- } else if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 &&
+ } else if (par->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 &&
(AV_RB16(pkt->data) & 0xfff0) == 0xfff0) {
if (!s->streams[pkt->stream_index]->nb_frames) {
av_log(s, AV_LOG_ERROR, "Malformed AAC bitstream detected: "
@@ -610,7 +610,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
}
/* 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");
@@ -629,11 +629,11 @@ 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 ||
- enc->codec_type == AVMEDIA_TYPE_SUBTITLE ) {
+ if (par->codec_type == AVMEDIA_TYPE_DATA ||
+ par->codec_type == AVMEDIA_TYPE_SUBTITLE ) {
int data_size;
int64_t metadata_size_pos = avio_tell(pb);
- if (enc->codec_id == AV_CODEC_ID_TEXT) {
+ if (par->codec_id == AV_CODEC_ID_TEXT) {
// legacy FFmpeg magic?
avio_w8(pb, AMF_DATA_TYPE_STRING);
put_amf_string(pb, "onTextData");
@@ -660,17 +660,17 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
} else {
av_assert1(flags>=0);
avio_w8(pb,flags);
- if (enc->codec_id == AV_CODEC_ID_VP6)
+ if (par->codec_id == AV_CODEC_ID_VP6)
avio_w8(pb,0);
- 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 || enc->codec_id == AV_CODEC_ID_MPEG4) {
+ else if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4) {
avio_w8(pb, 1); // AVC NALU
avio_wb24(pb, pkt->pts - pkt->dts);
}
diff --git a/libavformat/framecrcenc.c b/libavformat/framecrcenc.c
index eacbc457b1..91bcdcd99e 100644
--- a/libavformat/framecrcenc.c
+++ b/libavformat/framecrcenc.c
@@ -31,11 +31,11 @@ static int framecrc_write_header(struct AVFormatContext *s)
int i;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
- AVCodecContext *avctx = st->codec;
- if (avctx->extradata) {
- uint32_t crc = av_adler32_update(0, avctx->extradata, avctx->extradata_size);
+ AVCodecParameters *par = st->codecpar;
+ if (par->extradata) {
+ uint32_t crc = av_adler32_update(0, par->extradata, par->extradata_size);
avio_printf(s->pb, "#extradata %d: %8d, 0x%08"PRIx32"\n",
- i, avctx->extradata_size, crc);
+ i, par->extradata_size, crc);
}
}
diff --git a/libavformat/frmdec.c b/libavformat/frmdec.c
index 260afbc588..2f6b726427 100644
--- a/libavformat/frmdec.c
+++ b/libavformat/frmdec.c
@@ -58,30 +58,30 @@ static int frm_read_header(AVFormatContext *avctx)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
avio_skip(pb, 3);
- st->codec->pix_fmt = avpriv_find_pix_fmt(frm_pix_fmt_tags, avio_r8(pb));
- if (!st->codec->pix_fmt)
+ st->codecpar->format = avpriv_find_pix_fmt(frm_pix_fmt_tags, avio_r8(pb));
+ if (!st->codecpar->format)
return AVERROR_INVALIDDATA;
- st->codec->codec_tag = 0;
- st->codec->width = avio_rl16(pb);
- st->codec->height = avio_rl16(pb);
+ st->codecpar->codec_tag = 0;
+ st->codecpar->width = avio_rl16(pb);
+ st->codecpar->height = avio_rl16(pb);
return 0;
}
static int frm_read_packet(AVFormatContext *avctx, AVPacket *pkt)
{
FrmContext *s = avctx->priv_data;
- AVCodecContext *stc = avctx->streams[0]->codec;
+ AVCodecParameters *par = avctx->streams[0]->codecpar;
int packet_size, ret;
if (s->count)
return AVERROR_EOF;
- packet_size = av_image_get_buffer_size(stc->pix_fmt, stc->width, stc->height, 1);
+ packet_size = av_image_get_buffer_size(par->format, par->width, par->height, 1);
if (packet_size < 0)
return AVERROR_INVALIDDATA;
@@ -89,7 +89,7 @@ static int frm_read_packet(AVFormatContext *avctx, AVPacket *pkt)
if (ret < 0)
return ret;
- if (stc->pix_fmt == AV_PIX_FMT_BGRA) {
+ if (par->format == AV_PIX_FMT_BGRA) {
int i;
for (i = 3; i + 1 <= pkt->size; i += 4)
pkt->data[i] = 0xFF - pkt->data[i];
diff --git a/libavformat/fsb.c b/libavformat/fsb.c
index 2837c1919d..4f59576e35 100644
--- a/libavformat/fsb.c
+++ b/libavformat/fsb.c
@@ -39,7 +39,7 @@ static int fsb_read_header(AVFormatContext *s)
AVIOContext *pb = s->pb;
unsigned format, version, c;
int64_t offset;
- AVCodecContext *codec;
+ AVCodecParameters *par;
AVStream *st = avformat_new_stream(s, NULL);
avio_skip(pb, 3); // "FSB"
@@ -53,9 +53,9 @@ static int fsb_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- codec = st->codec;
- codec->codec_type = AVMEDIA_TYPE_AUDIO;
- codec->codec_tag = 0;
+ par = st->codecpar;
+ par->codec_type = AVMEDIA_TYPE_AUDIO;
+ par->codec_tag = 0;
if (version == 3) {
offset = avio_rl32(pb) + 0x18;
@@ -63,35 +63,35 @@ static int fsb_read_header(AVFormatContext *s)
st->duration = avio_rl32(pb);
avio_skip(pb, 12);
format = avio_rl32(pb);
- codec->sample_rate = avio_rl32(pb);
- if (codec->sample_rate <= 0)
+ par->sample_rate = avio_rl32(pb);
+ if (par->sample_rate <= 0)
return AVERROR_INVALIDDATA;
avio_skip(pb, 6);
- codec->channels = avio_rl16(pb);
- if (!codec->channels)
+ par->channels = avio_rl16(pb);
+ if (!par->channels)
return AVERROR_INVALIDDATA;
if (format & 0x00000100) {
- codec->codec_id = AV_CODEC_ID_PCM_S16LE;
- codec->block_align = 4096 * codec->channels;
+ par->codec_id = AV_CODEC_ID_PCM_S16LE;
+ par->block_align = 4096 * par->channels;
} else if (format & 0x00400000) {
- codec->bits_per_coded_sample = 4;
- codec->codec_id = AV_CODEC_ID_ADPCM_IMA_WAV;
- codec->block_align = 36 * codec->channels;
+ par->bits_per_coded_sample = 4;
+ par->codec_id = AV_CODEC_ID_ADPCM_IMA_WAV;
+ par->block_align = 36 * par->channels;
} else if (format & 0x00800000) {
- codec->codec_id = AV_CODEC_ID_ADPCM_PSX;
- codec->block_align = 16 * codec->channels;
+ par->codec_id = AV_CODEC_ID_ADPCM_PSX;
+ par->block_align = 16 * par->channels;
} else if (format & 0x02000000) {
- codec->codec_id = AV_CODEC_ID_ADPCM_THP;
- codec->block_align = 8 * codec->channels;
- if (codec->channels > INT_MAX / 32)
+ par->codec_id = AV_CODEC_ID_ADPCM_THP;
+ par->block_align = 8 * par->channels;
+ if (par->channels > INT_MAX / 32)
return AVERROR_INVALIDDATA;
- ff_alloc_extradata(codec, 32 * codec->channels);
- if (!codec->extradata)
+ ff_alloc_extradata(par, 32 * par->channels);
+ if (!par->extradata)
return AVERROR(ENOMEM);
avio_seek(pb, 0x68, SEEK_SET);
- for (c = 0; c < codec->channels; c++) {
- avio_read(pb, codec->extradata + 32 * c, 32);
+ for (c = 0; c < par->channels; c++) {
+ avio_read(pb, par->extradata + 32 * c, 32);
avio_skip(pb, 14);
}
} else {
@@ -109,45 +109,45 @@ static int fsb_read_header(AVFormatContext *s)
case 0x00001005:
case 0x40001081:
case 0x40200001:
- codec->codec_id = AV_CODEC_ID_XMA2;
+ par->codec_id = AV_CODEC_ID_XMA2;
break;
case 0x40000802:
- codec->codec_id = AV_CODEC_ID_ADPCM_THP;
+ par->codec_id = AV_CODEC_ID_ADPCM_THP;
break;
default:
avpriv_request_sample(s, "format 0x%X", format);
return AVERROR_PATCHWELCOME;
}
- codec->sample_rate = avio_rl32(pb);
- if (codec->sample_rate <= 0)
+ par->sample_rate = avio_rl32(pb);
+ if (par->sample_rate <= 0)
return AVERROR_INVALIDDATA;
avio_skip(pb, 6);
- codec->channels = avio_rl16(pb);
- if (!codec->channels)
+ par->channels = avio_rl16(pb);
+ if (!par->channels)
return AVERROR_INVALIDDATA;
- switch (codec->codec_id) {
+ switch (par->codec_id) {
case AV_CODEC_ID_XMA2:
- ff_alloc_extradata(codec, 34);
- if (!codec->extradata)
+ ff_alloc_extradata(par, 34);
+ if (!par->extradata)
return AVERROR(ENOMEM);
- memset(codec->extradata, 0, 34);
- codec->block_align = 2048;
+ memset(par->extradata, 0, 34);
+ par->block_align = 2048;
break;
case AV_CODEC_ID_ADPCM_THP:
- if (codec->channels > INT_MAX / 32)
+ if (par->channels > INT_MAX / 32)
return AVERROR_INVALIDDATA;
- ff_alloc_extradata(codec, 32 * codec->channels);
- if (!codec->extradata)
+ ff_alloc_extradata(par, 32 * par->channels);
+ if (!par->extradata)
return AVERROR(ENOMEM);
avio_seek(pb, 0x80, SEEK_SET);
- for (c = 0; c < codec->channels; c++) {
- avio_read(pb, codec->extradata + 32 * c, 32);
+ for (c = 0; c < par->channels; c++) {
+ avio_read(pb, par->extradata + 32 * c, 32);
avio_skip(pb, 14);
}
- codec->block_align = 8 * codec->channels;
+ par->block_align = 8 * par->channels;
break;
}
} else {
@@ -157,14 +157,14 @@ static int fsb_read_header(AVFormatContext *s)
avio_skip(pb, offset - avio_tell(pb));
s->internal->data_offset = avio_tell(pb);
- avpriv_set_pts_info(st, 64, 1, codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, par->sample_rate);
return 0;
}
static int fsb_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- AVCodecContext *codec = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
int64_t pos;
int ret;
@@ -172,25 +172,25 @@ static int fsb_read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR_EOF;
pos = avio_tell(s->pb);
- if (codec->codec_id == AV_CODEC_ID_ADPCM_THP &&
- codec->channels > 1) {
+ if (par->codec_id == AV_CODEC_ID_ADPCM_THP &&
+ par->channels > 1) {
int i, ch;
- ret = av_new_packet(pkt, codec->block_align);
+ ret = av_new_packet(pkt, par->block_align);
if (ret < 0)
return ret;
for (i = 0; i < 4; i++) {
- for (ch = 0; ch < codec->channels; ch++) {
+ for (ch = 0; ch < par->channels; ch++) {
pkt->data[ch * 8 + i * 2 + 0] = avio_r8(s->pb);
pkt->data[ch * 8 + i * 2 + 1] = avio_r8(s->pb);
}
}
ret = 0;
} else {
- ret = av_get_packet(s->pb, pkt, codec->block_align);
+ ret = av_get_packet(s->pb, pkt, par->block_align);
}
- if (codec->codec_id == AV_CODEC_ID_XMA2 && pkt->size >= 1)
+ if (par->codec_id == AV_CODEC_ID_XMA2 && pkt->size >= 1)
pkt->duration = (pkt->data[0] >> 2) * 512;
pkt->pos = pos;
diff --git a/libavformat/g722.c b/libavformat/g722.c
index 1a87c7d28c..2feec01211 100644
--- a/libavformat/g722.c
+++ b/libavformat/g722.c
@@ -32,17 +32,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);
- av_assert0(st->codec->bits_per_coded_sample > 0);
+ av_assert0(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;
}
diff --git a/libavformat/g723_1.c b/libavformat/g723_1.c
index 661e7bd399..27c8c3951b 100644
--- a/libavformat/g723_1.c
+++ b/libavformat/g723_1.c
@@ -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;
diff --git a/libavformat/g729dec.c b/libavformat/g729dec.c
index 349a014340..ee855d22d9 100644
--- a/libavformat/g729dec.c
+++ b/libavformat/g729dec.c
@@ -38,10 +38,10 @@ static int g729_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_G729;
- st->codec->sample_rate = 8000;
- st->codec->channels = 1;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_G729;
+ st->codecpar->sample_rate = 8000;
+ st->codecpar->channels = 1;
if (s1 && s1->bit_rate) {
s->bit_rate = s1->bit_rate;
@@ -53,28 +53,28 @@ static int g729_read_header(AVFormatContext *s)
}
if (s->bit_rate == 6400) {
- st->codec->block_align = 8;
+ st->codecpar->block_align = 8;
} else if (s->bit_rate == 8000) {
- st->codec->block_align = 10;
+ st->codecpar->block_align = 10;
} else {
av_log(s, AV_LOG_ERROR, "Only 8000 b/s and 6400 b/s bitrates are supported. Provided: %"PRId64" b/s\n", (int64_t)s->bit_rate);
return AVERROR_INVALIDDATA;
}
- avpriv_set_pts_info(st, st->codec->block_align << 3, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, st->codecpar->block_align << 3, 1, st->codecpar->sample_rate);
return 0;
}
static int g729_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret;
- ret = av_get_packet(s->pb, pkt, s->streams[0]->codec->block_align);
+ ret = av_get_packet(s->pb, pkt, s->streams[0]->codecpar->block_align);
pkt->stream_index = 0;
if (ret < 0)
return ret;
- pkt->dts = pkt->pts = pkt->pos / s->streams[0]->codec->block_align;
+ pkt->dts = pkt->pts = pkt->pos / s->streams[0]->codecpar->block_align;
return ret;
}
diff --git a/libavformat/genh.c b/libavformat/genh.c
index cb1a02f277..b683e026d1 100644
--- a/libavformat/genh.c
+++ b/libavformat/genh.c
@@ -52,50 +52,50 @@ static int genh_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->channels = avio_rl32(s->pb);
- if (st->codec->channels <= 0)
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->channels = avio_rl32(s->pb);
+ if (st->codecpar->channels <= 0)
return AVERROR_INVALIDDATA;
- if (st->codec->channels == 1)
- st->codec->channel_layout = AV_CH_LAYOUT_MONO;
- else if (st->codec->channels == 2)
- st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
+ if (st->codecpar->channels == 1)
+ st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+ else if (st->codecpar->channels == 2)
+ st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
align =
c->interleave_size = avio_rl32(s->pb);
- if (align < 0 || align > INT_MAX / st->codec->channels)
+ if (align < 0 || align > INT_MAX / st->codecpar->channels)
return AVERROR_INVALIDDATA;
- st->codec->block_align = align * st->codec->channels;
- st->codec->sample_rate = avio_rl32(s->pb);
+ st->codecpar->block_align = align * st->codecpar->channels;
+ st->codecpar->sample_rate = avio_rl32(s->pb);
avio_skip(s->pb, 4);
st->duration = avio_rl32(s->pb);
codec = avio_rl32(s->pb);
switch (codec) {
- case 0: st->codec->codec_id = AV_CODEC_ID_ADPCM_PSX; break;
+ case 0: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX; break;
case 1:
- case 11: st->codec->bits_per_coded_sample = 4;
- st->codec->block_align = 36 * st->codec->channels;
- st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_WAV; break;
- case 2: st->codec->codec_id = AV_CODEC_ID_ADPCM_DTK; break;
- case 3: st->codec->codec_id = st->codec->block_align > 0 ?
+ case 11: st->codecpar->bits_per_coded_sample = 4;
+ st->codecpar->block_align = 36 * st->codecpar->channels;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_WAV; break;
+ case 2: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_DTK; break;
+ case 3: st->codecpar->codec_id = st->codecpar->block_align > 0 ?
AV_CODEC_ID_PCM_S16BE_PLANAR :
AV_CODEC_ID_PCM_S16BE; break;
- case 4: st->codec->codec_id = st->codec->block_align > 0 ?
+ case 4: st->codecpar->codec_id = st->codecpar->block_align > 0 ?
AV_CODEC_ID_PCM_S16LE_PLANAR :
AV_CODEC_ID_PCM_S16LE; break;
- case 5: st->codec->codec_id = st->codec->block_align > 0 ?
+ case 5: st->codecpar->codec_id = st->codecpar->block_align > 0 ?
AV_CODEC_ID_PCM_S8_PLANAR :
AV_CODEC_ID_PCM_S8; break;
- case 6: st->codec->codec_id = AV_CODEC_ID_SDX2_DPCM; break;
- case 7: ret = ff_alloc_extradata(st->codec, 2);
+ case 6: st->codecpar->codec_id = AV_CODEC_ID_SDX2_DPCM; break;
+ case 7: ret = ff_alloc_extradata(st->codecpar, 2);
if (ret < 0)
return ret;
- AV_WL16(st->codec->extradata, 3);
- st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_WS; break;
- case 10: st->codec->codec_id = AV_CODEC_ID_ADPCM_AICA; break;
- case 12: st->codec->codec_id = AV_CODEC_ID_ADPCM_THP; break;
- case 13: st->codec->codec_id = AV_CODEC_ID_PCM_U8; break;
- case 17: st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_QT; break;
+ AV_WL16(st->codecpar->extradata, 3);
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_WS; break;
+ case 10: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_AICA; break;
+ case 12: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_THP; break;
+ case 13: st->codecpar->codec_id = AV_CODEC_ID_PCM_U8; break;
+ case 17: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_QT; break;
default:
avpriv_request_sample(s, "codec %d", codec);
return AVERROR_PATCHWELCOME;
@@ -117,25 +117,25 @@ static int genh_read_header(AVFormatContext *s)
coef_splitted[0] = avio_rl32(s->pb);
coef_splitted[1] = avio_rl32(s->pb);
- if (st->codec->codec_id == AV_CODEC_ID_ADPCM_THP) {
- if (st->codec->channels > 2) {
- avpriv_request_sample(s, "channels %d>2", st->codec->channels);
+ if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_THP) {
+ if (st->codecpar->channels > 2) {
+ avpriv_request_sample(s, "channels %d>2", st->codecpar->channels);
return AVERROR_PATCHWELCOME;
}
- ff_alloc_extradata(st->codec, 32 * st->codec->channels);
- for (ch = 0; ch < st->codec->channels; ch++) {
+ ff_alloc_extradata(st->codecpar, 32 * st->codecpar->channels);
+ for (ch = 0; ch < st->codecpar->channels; ch++) {
if (coef_type & 1) {
avpriv_request_sample(s, "coef_type & 1");
return AVERROR_PATCHWELCOME;
} else {
avio_seek(s->pb, coef[ch], SEEK_SET);
- avio_read(s->pb, st->codec->extradata + 32 * ch, 32);
+ avio_read(s->pb, st->codecpar->extradata + 32 * ch, 32);
}
}
if (c->dsp_int_type == 1) {
- st->codec->block_align = 8 * st->codec->channels;
+ st->codecpar->block_align = 8 * st->codecpar->channels;
if (c->interleave_size != 1 &&
c->interleave_size != 2 &&
c->interleave_size != 4)
@@ -145,38 +145,38 @@ static int genh_read_header(AVFormatContext *s)
avio_skip(s->pb, start_offset - avio_tell(s->pb));
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
static int genh_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- AVCodecContext *codec = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
GENHDemuxContext *c = s->priv_data;
int ret;
- if (c->dsp_int_type == 1 && codec->codec_id == AV_CODEC_ID_ADPCM_THP &&
- codec->channels > 1) {
+ if (c->dsp_int_type == 1 && par->codec_id == AV_CODEC_ID_ADPCM_THP &&
+ par->channels > 1) {
int i, ch;
if (avio_feof(s->pb))
return AVERROR_EOF;
- ret = av_new_packet(pkt, 8 * codec->channels);
+ ret = av_new_packet(pkt, 8 * par->channels);
if (ret < 0)
return ret;
for (i = 0; i < 8 / c->interleave_size; i++) {
- for (ch = 0; ch < codec->channels; ch++) {
+ for (ch = 0; ch < par->channels; ch++) {
pkt->data[ch * 8 + i*c->interleave_size+0] = avio_r8(s->pb);
pkt->data[ch * 8 + i*c->interleave_size+1] = avio_r8(s->pb);
}
}
ret = 0;
- } else if (codec->codec_id == AV_CODEC_ID_SDX2_DPCM) {
- ret = av_get_packet(s->pb, pkt, codec->block_align * 1024);
+ } else if (par->codec_id == AV_CODEC_ID_SDX2_DPCM) {
+ ret = av_get_packet(s->pb, pkt, par->block_align * 1024);
} else {
- ret = av_get_packet(s->pb, pkt, codec->block_align ? codec->block_align : 1024 * codec->channels);
+ ret = av_get_packet(s->pb, pkt, par->block_align ? par->block_align : 1024 * par->channels);
}
pkt->stream_index = 0;
diff --git a/libavformat/gif.c b/libavformat/gif.c
index 6537e557d6..91cd40db5c 100644
--- a/libavformat/gif.c
+++ b/libavformat/gif.c
@@ -50,12 +50,12 @@ static int get_palette_transparency_index(const uint32_t *palette)
return smallest_alpha < 128 ? transparent_color_index : -1;
}
-static int gif_image_write_header(AVIOContext *pb, const AVCodecContext *avctx,
+static int gif_image_write_header(AVIOContext *pb, AVStream *st,
int loop_count, uint32_t *palette)
{
int i;
int64_t aspect = 0;
- const AVRational sar = avctx->sample_aspect_ratio;
+ const AVRational sar = st->sample_aspect_ratio;
if (sar.num > 0 && sar.den > 0) {
aspect = sar.num * 64LL / sar.den - 15;
@@ -65,8 +65,8 @@ static int gif_image_write_header(AVIOContext *pb, const AVCodecContext *avctx,
avio_write(pb, "GIF", 3);
avio_write(pb, "89a", 3);
- avio_wl16(pb, avctx->width);
- avio_wl16(pb, avctx->height);
+ avio_wl16(pb, st->codecpar->width);
+ avio_wl16(pb, st->codecpar->height);
if (palette) {
const int bcid = get_palette_transparency_index(palette);
@@ -112,26 +112,26 @@ typedef struct GIFContext {
static int gif_write_header(AVFormatContext *s)
{
GIFContext *gif = s->priv_data;
- AVCodecContext *video_enc;
+ AVCodecParameters *video_par;
uint32_t palette[AVPALETTE_COUNT];
if (s->nb_streams != 1 ||
- s->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO ||
- s->streams[0]->codec->codec_id != AV_CODEC_ID_GIF) {
+ s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
+ s->streams[0]->codecpar->codec_id != AV_CODEC_ID_GIF) {
av_log(s, AV_LOG_ERROR,
"GIF muxer supports only a single video GIF stream.\n");
return AVERROR(EINVAL);
}
- video_enc = s->streams[0]->codec;
+ video_par = s->streams[0]->codecpar;
avpriv_set_pts_info(s->streams[0], 64, 1, 100);
- if (avpriv_set_systematic_pal2(palette, video_enc->pix_fmt) < 0) {
- av_assert0(video_enc->pix_fmt == AV_PIX_FMT_PAL8);
+ if (avpriv_set_systematic_pal2(palette, video_par->format) < 0) {
+ av_assert0(video_par->format == AV_PIX_FMT_PAL8);
/* delay header writing: we wait for the first palette to put it
* globally */
} else {
- gif_image_write_header(s->pb, video_enc, gif->loop, palette);
+ gif_image_write_header(s->pb, s->streams[0], gif->loop, palette);
}
return 0;
@@ -183,7 +183,7 @@ static int flush_packet(AVFormatContext *s, AVPacket *new)
static int gif_write_packet(AVFormatContext *s, AVPacket *pkt)
{
GIFContext *gif = s->priv_data;
- const AVCodecContext *video_enc = s->streams[0]->codec;
+ AVStream *video_st = s->streams[0];
if (!gif->prev_pkt) {
gif->prev_pkt = av_malloc(sizeof(*gif->prev_pkt));
@@ -191,7 +191,7 @@ static int gif_write_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(ENOMEM);
/* Write the first palette as global palette */
- if (video_enc->pix_fmt == AV_PIX_FMT_PAL8) {
+ if (video_st->codecpar->format == AV_PIX_FMT_PAL8) {
int size;
void *palette = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, &size);
@@ -203,7 +203,7 @@ static int gif_write_packet(AVFormatContext *s, AVPacket *pkt)
av_log(s, AV_LOG_ERROR, "Invalid palette extradata\n");
return AVERROR_INVALIDDATA;
}
- gif_image_write_header(s->pb, video_enc, gif->loop, palette);
+ gif_image_write_header(s->pb, video_st, gif->loop, palette);
}
return av_copy_packet(gif->prev_pkt, pkt);
diff --git a/libavformat/gifdec.c b/libavformat/gifdec.c
index 48bd603dd0..8993ca615c 100644
--- a/libavformat/gifdec.c
+++ b/libavformat/gifdec.c
@@ -118,10 +118,10 @@ static int gif_read_header(AVFormatContext *s)
/* GIF format operates with time in "hundredths of second",
* therefore timebase is 1/100 */
avpriv_set_pts_info(st, 64, 1, 100);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_GIF;
- st->codec->width = width;
- st->codec->height = height;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_GIF;
+ st->codecpar->width = width;
+ st->codecpar->height = height;
/* jump to start because gif decoder needs header data too */
if (avio_seek(pb, 0, SEEK_SET) != 0)
diff --git a/libavformat/gsmdec.c b/libavformat/gsmdec.c
index 267ad6fe87..1627106a22 100644
--- a/libavformat/gsmdec.c
+++ b/libavformat/gsmdec.c
@@ -78,12 +78,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);
diff --git a/libavformat/gxf.c b/libavformat/gxf.c
index d9b629d7de..399f745bc7 100644
--- a/libavformat/gxf.c
+++ b/libavformat/gxf.c
@@ -114,77 +114,77 @@ 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 14:
case 15:
case 16:
case 25:
- 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;
case 26: /* AVCi50 / AVCi100 (AVC Intra) */
case 29: /* AVCHD */
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_H264;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_H264;
st->need_parsing = AVSTREAM_PARSE_HEADERS;
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;
case 30:
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_DNXHD;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_DNXHD;
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;
@@ -532,11 +532,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;
@@ -551,7 +551,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;
diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c
index 8229fe9500..0a40ded2bd 100644
--- a/libavformat/gxfenc.c
+++ b/libavformat/gxfenc.c
@@ -124,7 +124,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;
}
@@ -198,18 +198,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, sizeof(buffer), "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);
av_assert0(size < sizeof(buffer));
avio_w8(pb, TRACK_MPG_AUX);
avio_w8(pb, size + 1);
@@ -223,7 +223,7 @@ static int gxf_write_dv_auxiliary(AVIOContext *pb, AVStream *st)
avio_w8(pb, TRACK_AUX);
avio_w8(pb, 8);
- if (st->codec->pix_fmt == AV_PIX_FMT_YUV420P)
+ if (st->codecpar->format == AV_PIX_FMT_YUV420P)
track_aux_data |= 0x01; /* marks stream as DVCAM instead of DVPRO */
track_aux_data |= 0x40000000; /* aux data is valid */
avio_wl64(pb, track_aux_data);
@@ -520,7 +520,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 */
@@ -529,9 +529,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);
@@ -556,7 +556,7 @@ static int gxf_write_umf_media_dv(AVIOContext *pb, GXFStreamContext *sc, AVStrea
{
int dv_umf_data = 0;
- if (st->codec->pix_fmt == AV_PIX_FMT_YUV420P)
+ if (st->codecpar->format == AV_PIX_FMT_YUV420P)
dv_umf_data |= 0x20; /* marks as DVCAM instead of DVPRO */
avio_wl32(pb, dv_umf_data);
avio_wl32(pb, 0);
@@ -620,7 +620,7 @@ static int gxf_write_umf_media_description(AVFormatContext *s)
gxf_write_umf_media_timecode(pb, gxf->tc.drop);
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);
@@ -722,22 +722,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;
@@ -746,18 +746,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;
@@ -773,12 +773,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;
@@ -797,7 +797,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;
@@ -903,7 +903,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,
@@ -913,10 +913,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);
@@ -929,7 +929,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
@@ -951,15 +951,15 @@ static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)
int ret;
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,
@@ -997,7 +997,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
@@ -1011,7 +1011,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);
diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c
index 3e6e821a82..e56b3c4dc1 100644
--- a/libavformat/hdsenc.c
+++ b/libavformat/hdsenc.c
@@ -340,18 +340,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++;
@@ -362,7 +362,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;
@@ -391,8 +391,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;
}
@@ -519,7 +519,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) {
diff --git a/libavformat/hls.c b/libavformat/hls.c
index fb87954316..7953e825bb 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1384,7 +1384,7 @@ static void add_metadata_from_renditions(AVFormatContext *s, struct playlist *pl
for (i = 0; i < pls->ctx->nb_streams; i++) {
AVStream *st = s->streams[pls->stream_offset + i];
- if (st->codec->codec_type != type)
+ if (st->codecpar->codec_type != type)
continue;
for (; rend_idx < pls->n_renditions; rend_idx++) {
@@ -1659,7 +1659,7 @@ static int hls_read_header(AVFormatContext *s)
}
st->id = i;
- avcodec_copy_context(st->codec, pls->ctx->streams[j]->codec);
+ avcodec_parameters_copy(st->codecpar, pls->ctx->streams[j]->codecpar);
if (pls->is_id3_timestamped) /* custom timestamps via id3 */
avpriv_set_pts_info(st, 33, 1, MPEG_TIME_BASE);
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index fd36b213fd..a9fa5d8aef 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -296,14 +296,14 @@ static int hls_mux_init(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
AVStream *st;
AVFormatContext *loc;
- if (s->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE)
+ if (s->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
loc = vtt_oc;
else
loc = oc;
if (!(st = avformat_new_stream(loc, 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;
}
@@ -659,9 +659,9 @@ 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;
hls->has_subtitle +=
- s->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE;
+ s->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE;
}
if (hls->has_video > 1)
@@ -763,7 +763,7 @@ static int hls_write_header(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
AVStream *inner_st;
AVStream *outer_st = s->streams[i];
- if (outer_st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE)
+ if (outer_st->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
inner_st = hls->avf->streams[i];
else if (hls->vtt_avf)
inner_st = hls->vtt_avf->streams[0];
@@ -799,7 +799,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
int ret, can_split = 1;
int stream_index = 0;
- if( st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE ) {
+ if( st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE ) {
oc = hls->vtt_avf;
stream_index = 0;
} else {
@@ -812,9 +812,9 @@ 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;
- is_ref_pkt = st->codec->codec_type == AVMEDIA_TYPE_VIDEO;
+ is_ref_pkt = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO;
}
if (pkt->pts == AV_NOPTS_VALUE)
is_ref_pkt = can_split = 0;
@@ -853,7 +853,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
if (ret < 0)
return ret;
- if( st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE )
+ if( st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE )
oc = hls->vtt_avf;
else
oc = hls->avf;
diff --git a/libavformat/hnm.c b/libavformat/hnm.c
index 8bd8097bf7..24d4e808a5 100644
--- a/libavformat/hnm.c
+++ b/libavformat/hnm.c
@@ -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;
diff --git a/libavformat/icodec.c b/libavformat/icodec.c
index 17acfb4b2f..8019a35f44 100644
--- a/libavformat/icodec.c
+++ b/libavformat/icodec.c
@@ -99,9 +99,9 @@ static int read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->width = avio_r8(pb);
- st->codec->height = avio_r8(pb);
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->width = avio_r8(pb);
+ st->codecpar->height = avio_r8(pb);
ico->images[i].nb_pal = avio_r8(pb);
if (ico->images[i].nb_pal == 255)
ico->images[i].nb_pal = 0;
@@ -117,20 +117,20 @@ static int read_header(AVFormatContext *s)
codec = avio_rl32(pb);
switch (codec) {
case MKTAG(0x89, 'P', 'N', 'G'):
- st->codec->codec_id = AV_CODEC_ID_PNG;
- st->codec->width = 0;
- st->codec->height = 0;
+ st->codecpar->codec_id = AV_CODEC_ID_PNG;
+ st->codecpar->width = 0;
+ st->codecpar->height = 0;
break;
case 40:
if (ico->images[i].size < 40)
return AVERROR_INVALIDDATA;
- st->codec->codec_id = AV_CODEC_ID_BMP;
+ st->codecpar->codec_id = AV_CODEC_ID_BMP;
tmp = avio_rl32(pb);
if (tmp)
- st->codec->width = tmp;
+ st->codecpar->width = tmp;
tmp = avio_rl32(pb);
if (tmp)
- st->codec->height = tmp / 2;
+ st->codecpar->height = tmp / 2;
break;
default:
avpriv_request_sample(s, "codec %d", codec);
@@ -157,7 +157,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
if ((ret = avio_seek(pb, image->offset, SEEK_SET)) < 0)
return ret;
- if (s->streams[ico->current_image]->codec->codec_id == AV_CODEC_ID_PNG) {
+ if (s->streams[ico->current_image]->codecpar->codec_id == AV_CODEC_ID_PNG) {
if ((ret = av_get_packet(pb, pkt, image->size)) < 0)
return ret;
} else {
@@ -177,13 +177,13 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
if ((ret = avio_read(pb, buf, image->size)) < 0)
return ret;
- st->codec->bits_per_coded_sample = AV_RL16(buf + 14);
+ st->codecpar->bits_per_coded_sample = AV_RL16(buf + 14);
if (AV_RL32(buf + 32))
image->nb_pal = AV_RL32(buf + 32);
- if (st->codec->bits_per_coded_sample <= 8 && !image->nb_pal) {
- image->nb_pal = 1 << st->codec->bits_per_coded_sample;
+ if (st->codecpar->bits_per_coded_sample <= 8 && !image->nb_pal) {
+ image->nb_pal = 1 << st->codecpar->bits_per_coded_sample;
AV_WL32(buf + 32, image->nb_pal);
}
diff --git a/libavformat/icoenc.c b/libavformat/icoenc.c
index 53d4420f37..a7ada19fcd 100644
--- a/libavformat/icoenc.c
+++ b/libavformat/icoenc.c
@@ -42,33 +42,33 @@ typedef struct {
IcoImage *images;
} IcoMuxContext;
-static int ico_check_attributes(AVFormatContext *s, const AVCodecContext *c)
+static int ico_check_attributes(AVFormatContext *s, const AVCodecParameters *p)
{
- if (c->codec_id == AV_CODEC_ID_BMP) {
- if (c->pix_fmt == AV_PIX_FMT_PAL8 && AV_PIX_FMT_RGB32 != AV_PIX_FMT_BGRA) {
+ if (p->codec_id == AV_CODEC_ID_BMP) {
+ if (p->format == AV_PIX_FMT_PAL8 && AV_PIX_FMT_RGB32 != AV_PIX_FMT_BGRA) {
av_log(s, AV_LOG_ERROR, "Wrong endianness for bmp pixel format\n");
return AVERROR(EINVAL);
- } else if (c->pix_fmt != AV_PIX_FMT_PAL8 &&
- c->pix_fmt != AV_PIX_FMT_RGB555LE &&
- c->pix_fmt != AV_PIX_FMT_BGR24 &&
- c->pix_fmt != AV_PIX_FMT_BGRA) {
+ } else if (p->format != AV_PIX_FMT_PAL8 &&
+ p->format != AV_PIX_FMT_RGB555LE &&
+ p->format != AV_PIX_FMT_BGR24 &&
+ p->format != AV_PIX_FMT_BGRA) {
av_log(s, AV_LOG_ERROR, "BMP must be 1bit, 4bit, 8bit, 16bit, 24bit, or 32bit\n");
return AVERROR(EINVAL);
}
- } else if (c->codec_id == AV_CODEC_ID_PNG) {
- if (c->pix_fmt != AV_PIX_FMT_RGBA) {
+ } else if (p->codec_id == AV_CODEC_ID_PNG) {
+ if (p->format != AV_PIX_FMT_RGBA) {
av_log(s, AV_LOG_ERROR, "PNG in ico requires pixel format to be rgba\n");
return AVERROR(EINVAL);
}
} else {
- const AVCodecDescriptor *codesc = avcodec_descriptor_get(c->codec_id);
+ const AVCodecDescriptor *codesc = avcodec_descriptor_get(p->codec_id);
av_log(s, AV_LOG_ERROR, "Unsupported codec %s\n", codesc ? codesc->name : "");
return AVERROR(EINVAL);
}
- if (c->width > 256 ||
- c->height > 256) {
- av_log(s, AV_LOG_ERROR, "Unsupported dimensions %dx%d (dimensions cannot exceed 256x256)\n", c->width, c->height);
+ if (p->width > 256 ||
+ p->height > 256) {
+ av_log(s, AV_LOG_ERROR, "Unsupported dimensions %dx%d (dimensions cannot exceed 256x256)\n", p->width, p->height);
return AVERROR(EINVAL);
}
@@ -95,7 +95,7 @@ static int ico_write_header(AVFormatContext *s)
avio_skip(pb, 2); // skip the number of images
for (i = 0; i < s->nb_streams; i++) {
- if (ret = ico_check_attributes(s, s->streams[i]->codec))
+ if (ret = ico_check_attributes(s, s->streams[i]->codecpar))
return ret;
// Fill in later when writing trailer...
@@ -116,7 +116,7 @@ static int ico_write_packet(AVFormatContext *s, AVPacket *pkt)
IcoMuxContext *ico = s->priv_data;
IcoImage *image;
AVIOContext *pb = s->pb;
- AVCodecContext *c = s->streams[pkt->stream_index]->codec;
+ AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
int i;
if (ico->current_image >= ico->nb_images) {
@@ -127,11 +127,11 @@ static int ico_write_packet(AVFormatContext *s, AVPacket *pkt)
image = &ico->images[ico->current_image++];
image->offset = avio_tell(pb);
- image->width = (c->width == 256) ? 0 : c->width;
- image->height = (c->height == 256) ? 0 : c->height;
+ image->width = (par->width == 256) ? 0 : par->width;
+ image->height = (par->height == 256) ? 0 : par->height;
- if (c->codec_id == AV_CODEC_ID_PNG) {
- image->bits = c->bits_per_coded_sample;
+ if (par->codec_id == AV_CODEC_ID_PNG) {
+ image->bits = par->bits_per_coded_sample;
image->size = pkt->size;
avio_write(pb, pkt->data, pkt->size);
@@ -142,13 +142,13 @@ static int ico_write_packet(AVFormatContext *s, AVPacket *pkt)
}
image->bits = AV_RL16(pkt->data + 28); // allows things like 1bit and 4bit images to be preserved
- image->size = pkt->size - 14 + c->height * (c->width + 7) / 8;
+ image->size = pkt->size - 14 + par->height * (par->width + 7) / 8;
avio_write(pb, pkt->data + 14, 8); // Skip the BITMAPFILEHEADER header
avio_wl32(pb, AV_RL32(pkt->data + 22) * 2); // rewrite height as 2 * height
avio_write(pb, pkt->data + 26, pkt->size - 26);
- for (i = 0; i < c->height * (c->width + 7) / 8; ++i)
+ for (i = 0; i < par->height * (par->width + 7) / 8; ++i)
avio_w8(pb, 0x00); // Write bitmask (opaque)
}
@@ -169,8 +169,8 @@ static int ico_write_trailer(AVFormatContext *s)
avio_w8(pb, ico->images[i].width);
avio_w8(pb, ico->images[i].height);
- if (s->streams[i]->codec->codec_id == AV_CODEC_ID_BMP &&
- s->streams[i]->codec->pix_fmt == AV_PIX_FMT_PAL8) {
+ if (s->streams[i]->codecpar->codec_id == AV_CODEC_ID_BMP &&
+ s->streams[i]->codecpar->format == AV_PIX_FMT_PAL8) {
avio_w8(pb, (ico->images[i].bits >= 8) ? 0 : 1 << ico->images[i].bits);
} else {
avio_w8(pb, 0);
diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index addf937afd..46b939432a 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -1091,11 +1091,11 @@ 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 (AV_RB64(apic->buf->data) == 0x89504e470d0a1a0a)
- st->codec->codec_id = AV_CODEC_ID_PNG;
+ st->codecpar->codec_id = AV_CODEC_ID_PNG;
if (apic->description[0])
av_dict_set(&st->metadata, "title", apic->description, 0);
diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c
index e4ccdf9fb3..781974128b 100644
--- a/libavformat/id3v2enc.c
+++ b/libavformat/id3v2enc.c
@@ -269,7 +269,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;
}
diff --git a/libavformat/idcin.c b/libavformat/idcin.c
index 10afed6fa4..bfc2051d9d 100644
--- a/libavformat/idcin.c
+++ b/libavformat/idcin.c
@@ -198,14 +198,14 @@ 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 */
- if ((ret = ff_get_extradata(st->codec, pb, HUFFMAN_TABLE_SIZE)) < 0)
+ if ((ret = ff_get_extradata(st->codecpar, pb, HUFFMAN_TABLE_SIZE)) < 0)
return ret;
if (idcin->audio_present) {
@@ -216,19 +216,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) *
diff --git a/libavformat/idroqdec.c b/libavformat/idroqdec.c
index 76bb3924b1..fe8d5c6fe3 100644
--- a/libavformat/idroqdec.c
+++ b/libavformat/idroqdec.c
@@ -130,14 +130,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 */
@@ -178,22 +178,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) {
diff --git a/libavformat/idroqenc.c b/libavformat/idroqenc.c
index 28a3aba9d4..8122efef83 100644
--- a/libavformat/idroqenc.c
+++ b/libavformat/idroqenc.c
@@ -29,25 +29,24 @@ static int roq_write_header(struct AVFormatContext *s)
0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, /* fps: */ 0x1E, 0x00
};
int n;
- AVCodecContext *avctx;
// set the actual fps
for(n=0;n<s->nb_streams;n++) {
- if ((avctx=s->streams[n]->codec)->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (s->streams[n]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
unsigned int fps;
- if (avctx->time_base.num != 1) {
- av_log(avctx, AV_LOG_ERROR, "Frame rate must be integer\n");
+ if (s->streams[n]->avg_frame_rate.den != 1) {
+ av_log(s, AV_LOG_ERROR, "Frame rate must be integer\n");
return AVERROR(EINVAL);
}
- if ((fps=avctx->time_base.den) > 255) {
- av_log(avctx, AV_LOG_ERROR, "Frame rate may not exceed 255fps\n");
+ if ((fps=s->streams[n]->avg_frame_rate.num) > 255) {
+ av_log(s, AV_LOG_ERROR, "Frame rate may not exceed 255fps\n");
return AVERROR(EINVAL);
}
if (fps != 30) {
- av_log(avctx, AV_LOG_WARNING, "For vintage compatibility fps must be 30\n");
+ av_log(s, AV_LOG_WARNING, "For vintage compatibility fps must be 30\n");
}
header[6] = fps;
diff --git a/libavformat/iff.c b/libavformat/iff.c
index 2889083151..4f1158161d 100644
--- a/libavformat/iff.c
+++ b/libavformat/iff.c
@@ -262,21 +262,21 @@ static int parse_dsd_prop(AVFormatContext *s, AVStream *st, uint64_t eof)
case MKTAG('C','H','N','L'):
if (size < 2)
return AVERROR_INVALIDDATA;
- st->codec->channels = avio_rb16(pb);
- if (size < 2 + st->codec->channels * 4)
+ st->codecpar->channels = avio_rb16(pb);
+ if (size < 2 + st->codecpar->channels * 4)
return AVERROR_INVALIDDATA;
- st->codec->channel_layout = 0;
- if (st->codec->channels > FF_ARRAY_ELEMS(dsd_layout)) {
+ st->codecpar->channel_layout = 0;
+ if (st->codecpar->channels > FF_ARRAY_ELEMS(dsd_layout)) {
avpriv_request_sample(s, "channel layout");
break;
}
- for (i = 0; i < st->codec->channels; i++)
+ for (i = 0; i < st->codecpar->channels; i++)
dsd_layout[i] = avio_rl32(pb);
for (i = 0; i < FF_ARRAY_ELEMS(dsd_channel_layout); i++) {
const DSDLayoutDesc * d = &dsd_channel_layout[i];
- if (av_get_channel_layout_nb_channels(d->layout) == st->codec->channels &&
- !memcmp(d->dsd_layout, dsd_layout, st->codec->channels * sizeof(uint32_t))) {
- st->codec->channel_layout = d->layout;
+ if (av_get_channel_layout_nb_channels(d->layout) == st->codecpar->channels &&
+ !memcmp(d->dsd_layout, dsd_layout, st->codecpar->channels * sizeof(uint32_t))) {
+ st->codecpar->channel_layout = d->layout;
break;
}
}
@@ -286,8 +286,8 @@ static int parse_dsd_prop(AVFormatContext *s, AVStream *st, uint64_t eof)
if (size < 4)
return AVERROR_INVALIDDATA;
tag = avio_rl32(pb);
- st->codec->codec_id = ff_codec_get_id(dsd_codec_tags, tag);
- if (!st->codec->codec_id) {
+ st->codecpar->codec_id = ff_codec_get_id(dsd_codec_tags, tag);
+ if (!st->codecpar->codec_id) {
av_log(s, AV_LOG_ERROR, "'%c%c%c%c' compression is not supported\n",
tag&0xFF, (tag>>8)&0xFF, (tag>>16)&0xFF, (tag>>24)&0xFF);
return AVERROR_PATCHWELCOME;
@@ -297,7 +297,7 @@ static int parse_dsd_prop(AVFormatContext *s, AVStream *st, uint64_t eof)
case MKTAG('F','S',' ',' '):
if (size < 4)
return AVERROR_INVALIDDATA;
- st->codec->sample_rate = avio_rb32(pb) / 8;
+ st->codecpar->sample_rate = avio_rb32(pb) / 8;
break;
case MKTAG('I','D','3',' '):
@@ -323,8 +323,8 @@ static int parse_dsd_prop(AVFormatContext *s, AVStream *st, uint64_t eof)
config = avio_rb16(pb);
if (config != 0xFFFF) {
if (config < FF_ARRAY_ELEMS(dsd_loudspeaker_config))
- st->codec->channel_layout = dsd_loudspeaker_config[config];
- if (!st->codec->channel_layout)
+ st->codecpar->channel_layout = dsd_loudspeaker_config[config];
+ if (!st->codecpar->channel_layout)
avpriv_request_sample(s, "loudspeaker configuration %d", config);
}
break;
@@ -360,15 +360,15 @@ 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;
iff->is_64bit = avio_rl32(pb) == ID_FRM8;
avio_skip(pb, iff->is_64bit ? 8 : 4);
// codec_tag used by ByteRun1 decoder to distinguish progressive (PBM) and interlaced (ILBM) content
- st->codec->codec_tag = avio_rl32(pb);
- if (st->codec->codec_tag == ID_ANIM) {
+ st->codecpar->codec_tag = avio_rl32(pb);
+ if (st->codecpar->codec_tag == ID_ANIM) {
avio_skip(pb, 8);
- st->codec->codec_tag = avio_rl32(pb);
+ st->codecpar->codec_tag = avio_rl32(pb);
}
iff->bitmap_compression = -1;
iff->svx8_compression = -1;
@@ -386,12 +386,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);
iff->svx8_compression = avio_r8(pb);
@@ -399,7 +399,7 @@ static int iff_read_header(AVFormatContext *s)
break;
case ID_MHDR:
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
if (data_size < 32)
return AVERROR_INVALIDDATA;
@@ -411,13 +411,13 @@ static int iff_read_header(AVFormatContext *s)
if (!den)
return AVERROR_INVALIDDATA;
avio_skip(pb, 2);
- st->codec->sample_rate = num / den;
- st->codec->channels = avio_rb16(pb);
+ st->codecpar->sample_rate = num / den;
+ st->codecpar->channels = avio_rb16(pb);
iff->maud_compression = avio_rb16(pb);
- if (st->codec->channels == 1)
- st->codec->channel_layout = AV_CH_LAYOUT_MONO;
- else if (st->codec->channels == 2)
- st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
+ if (st->codecpar->channels == 1)
+ st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+ else if (st->codecpar->channels == 2)
+ st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
break;
case ID_ABIT:
@@ -434,11 +434,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;
@@ -454,22 +454,22 @@ static int iff_read_header(AVFormatContext *s)
data_size);
return AVERROR_INVALIDDATA;
}
- st->codec->extradata_size = data_size + IFF_EXTRA_VIDEO_SIZE;
- st->codec->extradata = av_malloc(data_size + IFF_EXTRA_VIDEO_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
- if (!st->codec->extradata)
+ st->codecpar->extradata_size = data_size + IFF_EXTRA_VIDEO_SIZE;
+ st->codecpar->extradata = av_malloc(data_size + IFF_EXTRA_VIDEO_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
- if (avio_read(pb, st->codec->extradata + IFF_EXTRA_VIDEO_SIZE, data_size) < 0)
+ if (avio_read(pb, st->codecpar->extradata + IFF_EXTRA_VIDEO_SIZE, data_size) < 0)
return AVERROR(EIO);
break;
case ID_BMHD:
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
if (data_size <= 8)
return AVERROR_INVALIDDATA;
- st->codec->width = avio_rb16(pb);
- st->codec->height = avio_rb16(pb);
+ st->codecpar->width = avio_rb16(pb);
+ st->codecpar->height = avio_rb16(pb);
avio_skip(pb, 4); // x, y offset
- st->codec->bits_per_coded_sample = avio_r8(pb);
+ st->codecpar->bits_per_coded_sample = avio_r8(pb);
if (data_size >= 10)
masking = avio_r8(pb);
if (data_size >= 11)
@@ -490,15 +490,15 @@ static int iff_read_header(AVFormatContext *s)
if ((fmt_size = avio_read(pb, fmt, sizeof(fmt))) < 0)
return fmt_size;
if (fmt_size == sizeof(deep_rgb24) && !memcmp(fmt, deep_rgb24, sizeof(deep_rgb24)))
- st->codec->pix_fmt = AV_PIX_FMT_RGB24;
+ st->codecpar->format = AV_PIX_FMT_RGB24;
else if (fmt_size == sizeof(deep_rgba) && !memcmp(fmt, deep_rgba, sizeof(deep_rgba)))
- st->codec->pix_fmt = AV_PIX_FMT_RGBA;
+ st->codecpar->format = AV_PIX_FMT_RGBA;
else if (fmt_size == sizeof(deep_bgra) && !memcmp(fmt, deep_bgra, sizeof(deep_bgra)))
- st->codec->pix_fmt = AV_PIX_FMT_BGRA;
+ st->codecpar->format = AV_PIX_FMT_BGRA;
else if (fmt_size == sizeof(deep_argb) && !memcmp(fmt, deep_argb, sizeof(deep_argb)))
- st->codec->pix_fmt = AV_PIX_FMT_ARGB;
+ st->codecpar->format = AV_PIX_FMT_ARGB;
else if (fmt_size == sizeof(deep_abgr) && !memcmp(fmt, deep_abgr, sizeof(deep_abgr)))
- st->codec->pix_fmt = AV_PIX_FMT_ABGR;
+ st->codecpar->format = AV_PIX_FMT_ABGR;
else {
avpriv_request_sample(s, "color format %.16s", fmt);
return AVERROR_PATCHWELCOME;
@@ -506,22 +506,22 @@ static int iff_read_header(AVFormatContext *s)
break;
case ID_DGBL:
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
if (data_size < 8)
return AVERROR_INVALIDDATA;
- st->codec->width = avio_rb16(pb);
- st->codec->height = avio_rb16(pb);
+ st->codecpar->width = avio_rb16(pb);
+ st->codecpar->height = avio_rb16(pb);
iff->bitmap_compression = avio_rb16(pb);
st->sample_aspect_ratio.num = avio_r8(pb);
st->sample_aspect_ratio.den = avio_r8(pb);
- st->codec->bits_per_coded_sample = 24;
+ st->codecpar->bits_per_coded_sample = 24;
break;
case ID_DLOC:
if (data_size < 4)
return AVERROR_INVALIDDATA;
- st->codec->width = avio_rb16(pb);
- st->codec->height = avio_rb16(pb);
+ st->codecpar->width = avio_rb16(pb);
+ st->codecpar->height = avio_rb16(pb);
break;
case ID_TVDC:
@@ -545,7 +545,7 @@ static int iff_read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
version = avio_rb32(pb);
av_log(s, AV_LOG_DEBUG, "DSIFF v%d.%d.%d.%d\n",version >> 24, (version >> 16) & 0xFF, (version >> 8) & 0xFF, version & 0xFF);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
break;
case MKTAG('D','I','I','N'):
@@ -628,35 +628,35 @@ static int iff_read_header(AVFormatContext *s)
avio_seek(pb, iff->body_pos, SEEK_SET);
- switch(st->codec->codec_type) {
+ switch(st->codecpar->codec_type) {
case AVMEDIA_TYPE_AUDIO:
- avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 32, 1, st->codecpar->sample_rate);
- if (st->codec->codec_tag == ID_16SV)
- st->codec->codec_id = AV_CODEC_ID_PCM_S16BE_PLANAR;
- else if (st->codec->codec_tag == ID_MAUD) {
+ if (st->codecpar->codec_tag == ID_16SV)
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE_PLANAR;
+ else if (st->codecpar->codec_tag == ID_MAUD) {
if (iff->maud_bits == 8 && !iff->maud_compression) {
- st->codec->codec_id = AV_CODEC_ID_PCM_U8;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
} else if (iff->maud_bits == 16 && !iff->maud_compression) {
- st->codec->codec_id = AV_CODEC_ID_PCM_S16BE;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE;
} else if (iff->maud_bits == 8 && iff->maud_compression == 2) {
- st->codec->codec_id = AV_CODEC_ID_PCM_ALAW;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_ALAW;
} else if (iff->maud_bits == 8 && iff->maud_compression == 3) {
- st->codec->codec_id = AV_CODEC_ID_PCM_MULAW;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_MULAW;
} else {
avpriv_request_sample(s, "compression %d and bit depth %d", iff->maud_compression, iff->maud_bits);
return AVERROR_PATCHWELCOME;
}
- } else if (st->codec->codec_tag != ID_DSD) {
+ } else if (st->codecpar->codec_tag != ID_DSD) {
switch (iff->svx8_compression) {
case COMP_NONE:
- st->codec->codec_id = AV_CODEC_ID_PCM_S8_PLANAR;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S8_PLANAR;
break;
case COMP_FIB:
- st->codec->codec_id = AV_CODEC_ID_8SVX_FIB;
+ st->codecpar->codec_id = AV_CODEC_ID_8SVX_FIB;
break;
case COMP_EXP:
- st->codec->codec_id = AV_CODEC_ID_8SVX_EXP;
+ st->codecpar->codec_id = AV_CODEC_ID_8SVX_EXP;
break;
default:
av_log(s, AV_LOG_ERROR,
@@ -665,29 +665,29 @@ static int iff_read_header(AVFormatContext *s)
}
}
- st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id);
- 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->bits_per_coded_sample = av_get_bits_per_sample(st->codecpar->codec_id);
+ 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;
break;
case AVMEDIA_TYPE_VIDEO:
- iff->bpp = st->codec->bits_per_coded_sample;
+ iff->bpp = st->codecpar->bits_per_coded_sample;
if ((screenmode & 0x800 /* Hold And Modify */) && iff->bpp <= 8) {
iff->ham = iff->bpp > 6 ? 6 : 4;
- st->codec->bits_per_coded_sample = 24;
+ st->codecpar->bits_per_coded_sample = 24;
}
iff->flags = (screenmode & 0x80 /* Extra HalfBrite */) && iff->bpp <= 8;
iff->masking = masking;
iff->transparency = transparency;
- if (!st->codec->extradata) {
- st->codec->extradata_size = IFF_EXTRA_VIDEO_SIZE;
- st->codec->extradata = av_malloc(IFF_EXTRA_VIDEO_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
- if (!st->codec->extradata)
+ if (!st->codecpar->extradata) {
+ st->codecpar->extradata_size = IFF_EXTRA_VIDEO_SIZE;
+ st->codecpar->extradata = av_malloc(IFF_EXTRA_VIDEO_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
}
- av_assert0(st->codec->extradata_size >= IFF_EXTRA_VIDEO_SIZE);
- buf = st->codec->extradata;
+ av_assert0(st->codecpar->extradata_size >= IFF_EXTRA_VIDEO_SIZE);
+ buf = st->codecpar->extradata;
bytestream_put_be16(&buf, IFF_EXTRA_VIDEO_SIZE);
bytestream_put_byte(&buf, iff->bitmap_compression);
bytestream_put_byte(&buf, iff->bpp);
@@ -696,7 +696,7 @@ static int iff_read_header(AVFormatContext *s)
bytestream_put_be16(&buf, iff->transparency);
bytestream_put_byte(&buf, iff->masking);
bytestream_put_buffer(&buf, iff->tvdc, sizeof(iff->tvdc));
- st->codec->codec_id = AV_CODEC_ID_IFF_ILBM;
+ st->codecpar->codec_id = AV_CODEC_ID_IFF_ILBM;
break;
default:
return -1;
@@ -717,15 +717,15 @@ static int iff_read_packet(AVFormatContext *s,
if (pos >= iff->body_end)
return AVERROR_EOF;
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- if (st->codec->codec_tag == ID_DSD || st->codec->codec_tag == ID_MAUD) {
- ret = av_get_packet(pb, pkt, FFMIN(iff->body_end - pos, 1024 * st->codec->block_align));
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (st->codecpar->codec_tag == ID_DSD || st->codecpar->codec_tag == ID_MAUD) {
+ ret = av_get_packet(pb, pkt, FFMIN(iff->body_end - pos, 1024 * st->codecpar->block_align));
} else {
if (iff->body_size > INT_MAX)
return AVERROR_INVALIDDATA;
ret = av_get_packet(pb, pkt, iff->body_size);
}
- } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
uint8_t *buf;
if (iff->body_size > INT_MAX - 2)
diff --git a/libavformat/ilbc.c b/libavformat/ilbc.c
index ebee2fb0fa..50e3c3cc76 100644
--- a/libavformat/ilbc.c
+++ b/libavformat/ilbc.c
@@ -28,22 +28,22 @@ static const char mode30_header[] = "#!iLBC30\n";
static int ilbc_write_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
- AVCodecContext *enc;
+ AVCodecParameters *par;
if (s->nb_streams != 1) {
av_log(s, AV_LOG_ERROR, "Unsupported number of streams\n");
return AVERROR(EINVAL);
}
- enc = s->streams[0]->codec;
+ par = s->streams[0]->codecpar;
- if (enc->codec_id != AV_CODEC_ID_ILBC) {
+ if (par->codec_id != AV_CODEC_ID_ILBC) {
av_log(s, AV_LOG_ERROR, "Unsupported codec\n");
return AVERROR(EINVAL);
}
- if (enc->block_align == 50) {
+ if (par->block_align == 50) {
avio_write(pb, mode30_header, sizeof(mode30_header) - 1);
- } else if (enc->block_align == 38) {
+ } else if (par->block_align == 38) {
avio_write(pb, mode20_header, sizeof(mode20_header) - 1);
} else {
av_log(s, AV_LOG_ERROR, "Unsupported mode\n");
@@ -79,18 +79,18 @@ static int ilbc_read_header(AVFormatContext *s)
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_id = AV_CODEC_ID_ILBC;
- st->codec->sample_rate = 8000;
- st->codec->channels = 1;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_ILBC;
+ st->codecpar->sample_rate = 8000;
+ st->codecpar->channels = 1;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->start_time = 0;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
if (!memcmp(header, mode20_header, sizeof(mode20_header) - 1)) {
- st->codec->block_align = 38;
- st->codec->bit_rate = 15200;
+ st->codecpar->block_align = 38;
+ st->codecpar->bit_rate = 15200;
} else if (!memcmp(header, mode30_header, sizeof(mode30_header) - 1)) {
- st->codec->block_align = 50;
- st->codec->bit_rate = 13333;
+ st->codecpar->block_align = 50;
+ st->codecpar->bit_rate = 13333;
} else {
av_log(s, AV_LOG_ERROR, "Unrecognized iLBC file header\n");
return AVERROR_INVALIDDATA;
@@ -102,16 +102,16 @@ static int ilbc_read_header(AVFormatContext *s)
static int ilbc_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
- AVCodecContext *enc = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
int ret;
- if ((ret = av_new_packet(pkt, enc->block_align)) < 0)
+ if ((ret = av_new_packet(pkt, par->block_align)) < 0)
return ret;
pkt->stream_index = 0;
pkt->pos = avio_tell(s->pb);
- pkt->duration = enc->block_align == 38 ? 160 : 240;
- if ((ret = avio_read(s->pb, pkt->data, enc->block_align)) != enc->block_align) {
+ pkt->duration = par->block_align == 38 ? 160 : 240;
+ if ((ret = avio_read(s->pb, pkt->data, par->block_align)) != par->block_align) {
av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR(EIO);
}
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 6864374897..8dfb8138ad 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -221,8 +221,8 @@ int ff_img_read_header(AVFormatContext *s1)
avpriv_set_pts_info(st, 64, s->framerate.den, s->framerate.num);
if (s->width && s->height) {
- st->codec->width = s->width;
- st->codec->height = s->height;
+ st->codecpar->width = s->width;
+ st->codecpar->height = s->height;
}
if (!s->is_pipe) {
@@ -307,18 +307,18 @@ int ff_img_read_header(AVFormatContext *s1)
}
if (s1->video_codec_id) {
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = s1->video_codec_id;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = s1->video_codec_id;
} else if (s1->audio_codec_id) {
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = s1->audio_codec_id;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = s1->audio_codec_id;
} else if (s1->iformat->raw_codec_id) {
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = s1->iformat->raw_codec_id;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = s1->iformat->raw_codec_id;
} else {
const char *str = strrchr(s->path, '.');
s->split_planes = str && !av_strcasecmp(str + 1, "y");
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
if (s1->pb) {
int probe_buffer_size = 2048;
uint8_t *probe_buffer = av_realloc(NULL, probe_buffer_size + AVPROBE_PADDING_SIZE);
@@ -346,7 +346,7 @@ int ff_img_read_header(AVFormatContext *s1)
!fmt->raw_codec_id)
continue;
if (fmt->read_probe(&pd) > 0) {
- st->codec->codec_id = fmt->raw_codec_id;
+ st->codecpar->codec_id = fmt->raw_codec_id;
break;
}
}
@@ -355,16 +355,16 @@ int ff_img_read_header(AVFormatContext *s1)
} else
ffio_rewind_with_probe_data(s1->pb, &probe_buffer, probe_buffer_size);
}
- if (st->codec->codec_id == AV_CODEC_ID_NONE)
- st->codec->codec_id = ff_guess_image2_codec(s->path);
- if (st->codec->codec_id == AV_CODEC_ID_LJPEG)
- st->codec->codec_id = AV_CODEC_ID_MJPEG;
- if (st->codec->codec_id == AV_CODEC_ID_ALIAS_PIX) // we cannot distingiush this from BRENDER_PIX
- st->codec->codec_id = AV_CODEC_ID_NONE;
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE)
+ st->codecpar->codec_id = ff_guess_image2_codec(s->path);
+ if (st->codecpar->codec_id == AV_CODEC_ID_LJPEG)
+ st->codecpar->codec_id = AV_CODEC_ID_MJPEG;
+ if (st->codecpar->codec_id == AV_CODEC_ID_ALIAS_PIX) // we cannot distingiush this from BRENDER_PIX
+ st->codecpar->codec_id = AV_CODEC_ID_NONE;
}
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
pix_fmt != AV_PIX_FMT_NONE)
- st->codec->pix_fmt = pix_fmt;
+ st->codecpar->format = pix_fmt;
return 0;
}
@@ -377,7 +377,7 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
int i, res;
int size[3] = { 0 }, ret[3] = { 0 };
AVIOContext *f[3] = { NULL };
- AVCodecContext *codec = s1->streams[0]->codec;
+ AVCodecParameters *par = s1->streams[0]->codecpar;
if (!s->is_pipe) {
/* loop over input */
@@ -418,7 +418,7 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
filename[strlen(filename) - 1] = 'U' + i;
}
- if (codec->codec_id == AV_CODEC_ID_NONE) {
+ if (par->codec_id == AV_CODEC_ID_NONE) {
AVProbeData pd = { 0 };
AVInputFormat *ifmt;
uint8_t header[PROBE_BUF_MIN + AVPROBE_PADDING_SIZE];
@@ -436,11 +436,11 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
ifmt = av_probe_input_format3(&pd, 1, &score);
if (ifmt && ifmt->read_packet == ff_img_read_packet && ifmt->raw_codec_id)
- codec->codec_id = ifmt->raw_codec_id;
+ par->codec_id = ifmt->raw_codec_id;
}
- if (codec->codec_id == AV_CODEC_ID_RAWVIDEO && !codec->width)
- infer_size(&codec->width, &codec->height, size[0]);
+ if (par->codec_id == AV_CODEC_ID_RAWVIDEO && !par->width)
+ infer_size(&par->width, &par->height, size[0]);
} else {
f[0] = s1->pb;
if (avio_feof(f[0]) && s->loop && s->is_pipe)
diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index ebbac2bf7b..32c68e4d10 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -50,7 +50,7 @@ static int write_header(AVFormatContext *s)
{
VideoMuxData *img = s->priv_data;
AVStream *st = s->streams[0];
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(st->codec->pix_fmt);
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(st->codecpar->format);
av_strlcpy(img->path, s->filename, sizeof(img->path));
@@ -60,9 +60,9 @@ static int write_header(AVFormatContext *s)
else
img->is_pipe = 1;
- if (st->codec->codec_id == AV_CODEC_ID_GIF) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_GIF) {
img->muxer = "gif";
- } else if (st->codec->codec_id == AV_CODEC_ID_RAWVIDEO) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) {
const char *str = strrchr(img->path, '.');
img->split_planes = str
&& !av_strcasecmp(str + 1, "y")
@@ -80,8 +80,8 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
VideoMuxData *img = s->priv_data;
AVIOContext *pb[4];
char filename[1024];
- AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(codec->pix_fmt);
+ AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(par->format);
int i;
int nb_renames = 0;
@@ -123,8 +123,8 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
}
if (img->split_planes) {
- int ysize = codec->width * codec->height;
- int usize = AV_CEIL_RSHIFT(codec->width, desc->log2_chroma_w) * AV_CEIL_RSHIFT(codec->height, desc->log2_chroma_h);
+ int ysize = par->width * par->height;
+ int usize = AV_CEIL_RSHIFT(par->width, desc->log2_chroma_w) * AV_CEIL_RSHIFT(par->height, desc->log2_chroma_h);
if (desc->comp[0].depth >= 9) {
ysize *= 2;
usize *= 2;
@@ -159,7 +159,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
fmt->pb = pb[0];
if ((ret = av_copy_packet(&pkt2, pkt)) < 0 ||
(ret = av_dup_packet(&pkt2)) < 0 ||
- (ret = avcodec_copy_context(st->codec, s->streams[0]->codec)) < 0 ||
+ (ret = avcodec_parameters_copy(st->codecpar, s->streams[0]->codecpar)) < 0 ||
(ret = avformat_write_header(fmt, NULL)) < 0 ||
(ret = av_interleaved_write_frame(fmt, &pkt2)) < 0 ||
(ret = av_write_trailer(fmt)) < 0) {
diff --git a/libavformat/internal.h b/libavformat/internal.h
index cd390ddf70..1719deb219 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -144,6 +144,22 @@ struct AVStreamInternal {
* Whether or not check_bitstream should still be run on each packet
*/
int bitstream_checked;
+
+ /**
+ * The codec context used by avformat_find_stream_info, the parser, etc.
+ */
+ AVCodecContext *avctx;
+ /**
+ * 1 if avctx has been initialized with the values from the codec parameters
+ */
+ int avctx_inited;
+
+ enum AVCodecID orig_codec_id;
+
+ /**
+ * Whether the internal avctx needs to be updated from codecpar (after a late change to codecpar)
+ */
+ int need_context_update;
};
#ifdef __GNUC__
@@ -497,7 +513,7 @@ static inline int ff_rename(const char *oldpath, const char *newpath, void *logc
* @param size size of extradata
* @return 0 if OK, AVERROR_xxx on error
*/
-int ff_alloc_extradata(AVCodecContext *avctx, int size);
+int ff_alloc_extradata(AVCodecParameters *par, int size);
/**
* Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end
@@ -506,7 +522,7 @@ int ff_alloc_extradata(AVCodecContext *avctx, int size);
* @param size size of extradata
* @return >= 0 if OK, AVERROR_xxx on error
*/
-int ff_get_extradata(AVCodecContext *avctx, AVIOContext *pb, int size);
+int ff_get_extradata(AVCodecParameters *par, AVIOContext *pb, int size);
/**
* add frame for rfps calculation.
@@ -581,7 +597,7 @@ int ff_standardize_creation_time(AVFormatContext *s);
* non-zero if a new packet was allocated and ppkt has to be freed
* CONTAINS_PAL if in addition to a new packet the old contained a palette
*/
-int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecContext *enc, int expected_stride);
+int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecParameters *par, int expected_stride);
/**
* Retrieves the palette from a packet, either from side data, or
diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c
index bc5d8ccb62..bb34aae749 100644
--- a/libavformat/ipmovie.c
+++ b/libavformat/ipmovie.c
@@ -221,19 +221,19 @@ static int init_audio(AVFormatContext *s)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 32, 1, ipmovie->audio_sample_rate);
ipmovie->audio_stream_index = st->index;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = ipmovie->audio_type;
- st->codec->codec_tag = 0; /* no tag */
- st->codec->channels = ipmovie->audio_channels;
- st->codec->channel_layout = st->codec->channels == 1 ? AV_CH_LAYOUT_MONO :
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = ipmovie->audio_type;
+ st->codecpar->codec_tag = 0; /* no tag */
+ st->codecpar->channels = ipmovie->audio_channels;
+ st->codecpar->channel_layout = st->codecpar->channels == 1 ? AV_CH_LAYOUT_MONO :
AV_CH_LAYOUT_STEREO;
- st->codec->sample_rate = ipmovie->audio_sample_rate;
- st->codec->bits_per_coded_sample = ipmovie->audio_bits;
- st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
- st->codec->bits_per_coded_sample;
- if (st->codec->codec_id == AV_CODEC_ID_INTERPLAY_DPCM)
- st->codec->bit_rate /= 2;
- st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample;
+ st->codecpar->sample_rate = ipmovie->audio_sample_rate;
+ st->codecpar->bits_per_coded_sample = ipmovie->audio_bits;
+ st->codecpar->bit_rate = st->codecpar->channels * st->codecpar->sample_rate *
+ st->codecpar->bits_per_coded_sample;
+ if (st->codecpar->codec_id == AV_CODEC_ID_INTERPLAY_DPCM)
+ st->codecpar->bit_rate /= 2;
+ st->codecpar->block_align = st->codecpar->channels * st->codecpar->bits_per_coded_sample;
return 0;
}
@@ -623,12 +623,12 @@ static int ipmovie_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 63, 1, 1000000);
ipmovie->video_stream_index = st->index;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_INTERPLAY_VIDEO;
- st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = ipmovie->video_width;
- st->codec->height = ipmovie->video_height;
- st->codec->bits_per_coded_sample = ipmovie->video_bpp;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_INTERPLAY_VIDEO;
+ st->codecpar->codec_tag = 0; /* no fourcc */
+ st->codecpar->width = ipmovie->video_width;
+ st->codecpar->height = ipmovie->video_height;
+ st->codecpar->bits_per_coded_sample = ipmovie->video_bpp;
if (ipmovie->audio_type) {
return init_audio(s);
diff --git a/libavformat/ircamdec.c b/libavformat/ircamdec.c
index f9533ec4a5..59f3a49411 100644
--- a/libavformat/ircamdec.c
+++ b/libavformat/ircamdec.c
@@ -85,19 +85,19 @@ static int ircam_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->channels = channels;
- st->codec->sample_rate = sample_rate;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->channels = channels;
+ st->codecpar->sample_rate = sample_rate;
- st->codec->codec_id = ff_codec_get_id(tags, tag);
- if (st->codec->codec_id == AV_CODEC_ID_NONE) {
+ st->codecpar->codec_id = ff_codec_get_id(tags, tag);
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE) {
av_log(s, AV_LOG_ERROR, "unknown tag %X\n", tag);
return AVERROR_INVALIDDATA;
}
- st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id);
- st->codec->block_align = st->codec->bits_per_coded_sample * st->codec->channels / 8;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ st->codecpar->bits_per_coded_sample = av_get_bits_per_sample(st->codecpar->codec_id);
+ st->codecpar->block_align = st->codecpar->bits_per_coded_sample * st->codecpar->channels / 8;
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
avio_skip(s->pb, 1008);
return 0;
diff --git a/libavformat/ircamenc.c b/libavformat/ircamenc.c
index 1a829d4c08..323ecb37ee 100644
--- a/libavformat/ircamenc.c
+++ b/libavformat/ircamenc.c
@@ -28,7 +28,7 @@
static int ircam_write_header(AVFormatContext *s)
{
- AVCodecContext *codec = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
uint32_t tag;
if (s->nb_streams != 1) {
@@ -36,15 +36,15 @@ static int ircam_write_header(AVFormatContext *s)
return AVERROR(EINVAL);
}
- tag = ff_codec_get_tag(ff_codec_ircam_le_tags, codec->codec_id);
+ tag = ff_codec_get_tag(ff_codec_ircam_le_tags, par->codec_id);
if (!tag) {
av_log(s, AV_LOG_ERROR, "unsupported codec\n");
return AVERROR(EINVAL);
}
avio_wl32(s->pb, 0x0001A364);
- avio_wl32(s->pb, av_q2intfloat((AVRational){codec->sample_rate, 1}));
- avio_wl32(s->pb, codec->channels);
+ avio_wl32(s->pb, av_q2intfloat((AVRational){par->sample_rate, 1}));
+ avio_wl32(s->pb, par->channels);
avio_wl32(s->pb, tag);
ffio_fill(s->pb, 0, 1008);
return 0;
diff --git a/libavformat/isom.c b/libavformat/isom.c
index 2ca126585f..d8a330c0b2 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -465,47 +465,43 @@ int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext
avio_r8(pb); /* stream type */
avio_rb24(pb); /* buffer size db */
- if(avcodec_is_open(st->codec)) {
- av_log(fc, AV_LOG_DEBUG, "codec open in read_dec_config_descr\n");
- return -1;
- }
-
v = avio_rb32(pb);
- if (v < INT32_MAX)
- st->codec->rc_max_rate = v;
+ // TODO: fix this
+ //if (v < INT32_MAX)
+ // st->codecpar->rc_max_rate = v;
- st->codec->bit_rate = avio_rb32(pb); /* avg bitrate */
+ st->codecpar->bit_rate = avio_rb32(pb); /* avg bitrate */
codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id);
if (codec_id)
- st->codec->codec_id= codec_id;
+ st->codecpar->codec_id = codec_id;
av_log(fc, AV_LOG_TRACE, "esds object type id 0x%02x\n", object_type_id);
len = ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4DecSpecificDescrTag) {
av_log(fc, AV_LOG_TRACE, "Specific MPEG4 header len=%d\n", len);
if (!len || (uint64_t)len > (1<<30))
return -1;
- av_free(st->codec->extradata);
- if ((ret = ff_get_extradata(st->codec, pb, len)) < 0)
+ av_free(st->codecpar->extradata);
+ if ((ret = ff_get_extradata(st->codecpar, pb, len)) < 0)
return ret;
- if (st->codec->codec_id == AV_CODEC_ID_AAC) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
MPEG4AudioConfig cfg = {0};
- avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata,
- st->codec->extradata_size * 8, 1);
- st->codec->channels = cfg.channels;
+ avpriv_mpeg4audio_get_config(&cfg, st->codecpar->extradata,
+ st->codecpar->extradata_size * 8, 1);
+ st->codecpar->channels = cfg.channels;
if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4
- st->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];
+ st->codecpar->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];
else 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(fc, AV_LOG_TRACE, "mp4a config channels %d obj %d ext obj %d "
- "sample rate %d ext sample rate %d\n", st->codec->channels,
+ "sample rate %d ext sample rate %d\n", st->codecpar->channels,
cfg.object_type, cfg.ext_object_type,
cfg.sample_rate, cfg.ext_sample_rate);
- if (!(st->codec->codec_id = ff_codec_get_id(mp4_audio_types,
+ if (!(st->codecpar->codec_id = ff_codec_get_id(mp4_audio_types,
cfg.object_type)))
- st->codec->codec_id = AV_CODEC_ID_AAC;
+ st->codecpar->codec_id = AV_CODEC_ID_AAC;
}
}
return 0;
diff --git a/libavformat/iss.c b/libavformat/iss.c
index fbde505a2d..95b35dc78a 100644
--- a/libavformat/iss.c
+++ b/libavformat/iss.c
@@ -107,23 +107,23 @@ static av_cold int iss_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_id = AV_CODEC_ID_ADPCM_IMA_ISS;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_ISS;
if (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;
}
- st->codec->sample_rate = 44100;
+ st->codecpar->sample_rate = 44100;
if(rate_divisor > 0)
- st->codec->sample_rate /= rate_divisor;
- st->codec->bits_per_coded_sample = 4;
- st->codec->bit_rate = st->codec->channels * st->codec->sample_rate
- * st->codec->bits_per_coded_sample;
- st->codec->block_align = iss->packet_size;
- avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate);
+ st->codecpar->sample_rate /= rate_divisor;
+ st->codecpar->bits_per_coded_sample = 4;
+ st->codecpar->bit_rate = st->codecpar->channels * st->codecpar->sample_rate
+ * st->codecpar->bits_per_coded_sample;
+ st->codecpar->block_align = iss->packet_size;
+ avpriv_set_pts_info(st, 32, 1, st->codecpar->sample_rate);
return 0;
}
@@ -138,8 +138,8 @@ static int iss_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->stream_index = 0;
pkt->pts = avio_tell(s->pb) - iss->sample_start_pos;
- if(s->streams[0]->codec->channels > 0)
- pkt->pts /= s->streams[0]->codec->channels*2;
+ if(s->streams[0]->codecpar->channels > 0)
+ pkt->pts /= s->streams[0]->codecpar->channels*2;
return 0;
}
diff --git a/libavformat/iv8.c b/libavformat/iv8.c
index f1e351cbb6..077d905b4b 100644
--- a/libavformat/iv8.c
+++ b/libavformat/iv8.c
@@ -45,8 +45,8 @@ static int read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_MPEG4;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_MPEG4;
st->need_parsing = AVSTREAM_PARSE_FULL;
avpriv_set_pts_info(st, 64, 1, 90000);
diff --git a/libavformat/ivfdec.c b/libavformat/ivfdec.c
index c0fdafbf02..197c099bc3 100644
--- a/libavformat/ivfdec.c
+++ b/libavformat/ivfdec.c
@@ -46,11 +46,11 @@ static int read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_tag = avio_rl32(s->pb);
- st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, st->codec->codec_tag);
- st->codec->width = avio_rl16(s->pb);
- st->codec->height = avio_rl16(s->pb);
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_tag = avio_rl32(s->pb);
+ st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, st->codecpar->codec_tag);
+ st->codecpar->width = avio_rl16(s->pb);
+ st->codecpar->height = avio_rl16(s->pb);
time_base.den = avio_rl32(s->pb);
time_base.num = avio_rl32(s->pb);
st->duration = avio_rl64(s->pb);
diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
index 490b0a921a..5dbcd97611 100644
--- a/libavformat/ivfenc.c
+++ b/libavformat/ivfenc.c
@@ -28,25 +28,25 @@ typedef struct IVFEncContext {
static int ivf_write_header(AVFormatContext *s)
{
- AVCodecContext *ctx;
+ AVCodecParameters *par;
AVIOContext *pb = s->pb;
if (s->nb_streams != 1) {
av_log(s, AV_LOG_ERROR, "Format supports only exactly one video stream\n");
return AVERROR(EINVAL);
}
- ctx = s->streams[0]->codec;
- if (ctx->codec_type != AVMEDIA_TYPE_VIDEO ||
- !(ctx->codec_id == AV_CODEC_ID_VP8 || ctx->codec_id == AV_CODEC_ID_VP9)) {
+ par = s->streams[0]->codecpar;
+ if (par->codec_type != AVMEDIA_TYPE_VIDEO ||
+ !(par->codec_id == AV_CODEC_ID_VP8 || par->codec_id == AV_CODEC_ID_VP9)) {
av_log(s, AV_LOG_ERROR, "Currently only VP8 and VP9 are supported!\n");
return AVERROR(EINVAL);
}
avio_write(pb, "DKIF", 4);
avio_wl16(pb, 0); // version
avio_wl16(pb, 32); // header length
- avio_wl32(pb, ctx->codec_tag ? ctx->codec_tag : ctx->codec_id == AV_CODEC_ID_VP9 ? AV_RL32("VP90") : AV_RL32("VP80"));
- avio_wl16(pb, ctx->width);
- avio_wl16(pb, ctx->height);
+ avio_wl32(pb, par->codec_tag ? par->codec_tag : par->codec_id == AV_CODEC_ID_VP9 ? AV_RL32("VP90") : AV_RL32("VP80"));
+ avio_wl16(pb, par->width);
+ avio_wl16(pb, par->height);
avio_wl32(pb, s->streams[0]->time_base.den);
avio_wl32(pb, s->streams[0]->time_base.num);
avio_wl64(pb, 0xFFFFFFFFFFFFFFFFULL);
@@ -91,7 +91,7 @@ static int ivf_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
int ret = 1;
AVStream *st = s->streams[pkt->stream_index];
- if (st->codec->codec_id == AV_CODEC_ID_VP9)
+ if (st->codecpar->codec_id == AV_CODEC_ID_VP9)
ret = ff_stream_add_bitstream_filter(st, "vp9_superframe", NULL);
return ret;
diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c
index 0436a9328d..520c435cc5 100644
--- a/libavformat/jacosubdec.c
+++ b/libavformat/jacosubdec.c
@@ -167,8 +167,8 @@ static int jacosub_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 100);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_JACOSUB;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_JACOSUB;
jacosub->timeres = 30;
@@ -230,7 +230,7 @@ static int jacosub_read_header(AVFormatContext *s)
}
/* general/essential directives in the extradata */
- ret = avpriv_bprint_to_extradata(st->codec, &header);
+ ret = ff_bprint_to_codecpar_extradata(st->codecpar, &header);
if (ret < 0)
goto fail;
diff --git a/libavformat/jacosubenc.c b/libavformat/jacosubenc.c
index a11e45a4aa..0954f5f058 100644
--- a/libavformat/jacosubenc.c
+++ b/libavformat/jacosubenc.c
@@ -21,10 +21,10 @@
static int jacosub_write_header(AVFormatContext *s)
{
- const AVCodecContext *avctx = s->streams[0]->codec;
+ const AVCodecParameters *par = s->streams[0]->codecpar;
- if (avctx->extradata_size) {
- avio_write(s->pb, avctx->extradata, avctx->extradata_size - 1);
+ if (par->extradata_size) {
+ avio_write(s->pb, par->extradata, par->extradata_size - 1);
avio_flush(s->pb);
}
return 0;
diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c
index a31c7236ff..b2c067fb99 100644
--- a/libavformat/jvdec.c
+++ b/libavformat/jvdec.c
@@ -85,11 +85,11 @@ static int read_header(AVFormatContext *s)
if (!ast || !vst)
return AVERROR(ENOMEM);
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_id = AV_CODEC_ID_JV;
- vst->codec->codec_tag = 0; /* no fourcc */
- vst->codec->width = avio_rl16(pb);
- vst->codec->height = avio_rl16(pb);
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_id = AV_CODEC_ID_JV;
+ vst->codecpar->codec_tag = 0; /* no fourcc */
+ vst->codecpar->width = avio_rl16(pb);
+ vst->codecpar->height = avio_rl16(pb);
vst->duration =
vst->nb_frames =
ast->nb_index_entries = avio_rl16(pb);
@@ -97,13 +97,13 @@ static int read_header(AVFormatContext *s)
avio_skip(pb, 4);
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- ast->codec->codec_id = AV_CODEC_ID_PCM_U8;
- ast->codec->codec_tag = 0; /* no fourcc */
- ast->codec->sample_rate = avio_rl16(pb);
- ast->codec->channels = 1;
- ast->codec->channel_layout = AV_CH_LAYOUT_MONO;
- avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
+ ast->codecpar->codec_tag = 0; /* no fourcc */
+ ast->codecpar->sample_rate = avio_rl16(pb);
+ ast->codecpar->channels = 1;
+ ast->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+ avpriv_set_pts_info(ast, 64, 1, ast->codecpar->sample_rate);
avio_skip(pb, 10);
diff --git a/libavformat/latmenc.c b/libavformat/latmenc.c
index 9713b1b8ec..43ca4821cb 100644
--- a/libavformat/latmenc.c
+++ b/libavformat/latmenc.c
@@ -85,13 +85,13 @@ static int latm_decode_extradata(LATMContext *ctx, uint8_t *buf, int size)
static int latm_write_header(AVFormatContext *s)
{
LATMContext *ctx = s->priv_data;
- AVCodecContext *avctx = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
- if (avctx->codec_id == AV_CODEC_ID_AAC_LATM)
+ if (par->codec_id == AV_CODEC_ID_AAC_LATM)
return 0;
- if (avctx->extradata_size > 0 &&
- latm_decode_extradata(ctx, avctx->extradata, avctx->extradata_size) < 0)
+ if (par->extradata_size > 0 &&
+ latm_decode_extradata(ctx, par->extradata, par->extradata_size) < 0)
return AVERROR_INVALIDDATA;
return 0;
@@ -100,7 +100,7 @@ static int latm_write_header(AVFormatContext *s)
static void latm_write_frame_header(AVFormatContext *s, PutBitContext *bs)
{
LATMContext *ctx = s->priv_data;
- AVCodecContext *avctx = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
int header_size;
/* AudioMuxElement */
@@ -116,16 +116,16 @@ static void latm_write_frame_header(AVFormatContext *s, PutBitContext *bs)
/* AudioSpecificConfig */
if (ctx->object_type == AOT_ALS) {
- header_size = avctx->extradata_size-(ctx->off >> 3);
- avpriv_copy_bits(bs, &avctx->extradata[ctx->off >> 3], header_size);
+ header_size = par->extradata_size-(ctx->off >> 3);
+ avpriv_copy_bits(bs, &par->extradata[ctx->off >> 3], header_size);
} else {
// + 3 assumes not scalable and dependsOnCoreCoder == 0,
// see decode_ga_specific_config in libavcodec/aacdec.c
- avpriv_copy_bits(bs, avctx->extradata, ctx->off + 3);
+ avpriv_copy_bits(bs, par->extradata, ctx->off + 3);
if (!ctx->channel_conf) {
GetBitContext gb;
- int ret = init_get_bits8(&gb, avctx->extradata, avctx->extradata_size);
+ int ret = init_get_bits8(&gb, par->extradata, par->extradata_size);
av_assert0(ret >= 0); // extradata size has been checked already, so this should not fail
skip_bits_long(&gb, ctx->off + 3);
avpriv_copy_pce_data(bs, &gb);
@@ -151,10 +151,10 @@ static int latm_write_packet(AVFormatContext *s, AVPacket *pkt)
int i, len;
uint8_t loas_header[] = "\x56\xe0\x00";
- if (s->streams[0]->codec->codec_id == AV_CODEC_ID_AAC_LATM)
+ if (s->streams[0]->codecpar->codec_id == AV_CODEC_ID_AAC_LATM)
return ff_raw_write_packet(s, pkt);
- if (!s->streams[0]->codec->extradata) {
+ if (!s->streams[0]->codecpar->extradata) {
if(pkt->size > 2 && pkt->data[0] == 0x56 && (pkt->data[1] >> 4) == 0xe &&
(AV_RB16(pkt->data + 1) & 0x1FFF) + 3 == pkt->size)
return ff_raw_write_packet(s, pkt);
@@ -218,7 +218,7 @@ static int latm_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
int ret = 1;
AVStream *st = s->streams[pkt->stream_index];
- if (st->codec->codec_id == AV_CODEC_ID_AAC) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
if (pkt->size > 2 && (AV_RB16(pkt->data) & 0xfff0) == 0xfff0)
ret = ff_stream_add_bitstream_filter(st, "aac_adtstoasc", NULL);
}
diff --git a/libavformat/libgme.c b/libavformat/libgme.c
index 276477b308..228273dc90 100644
--- a/libavformat/libgme.c
+++ b/libavformat/libgme.c
@@ -126,10 +126,10 @@ static int read_header_gme(AVFormatContext *s)
avpriv_set_pts_info(st, 64, 1, 1000);
if (st->duration > 0)
st->duration = gme->info->length;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE);
- st->codec->channels = 2;
- st->codec->sample_rate = gme->sample_rate;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE);
+ st->codecpar->channels = 2;
+ st->codecpar->sample_rate = gme->sample_rate;
return 0;
}
diff --git a/libavformat/libmodplug.c b/libavformat/libmodplug.c
index 75699e89b4..f18c610c46 100644
--- a/libavformat/libmodplug.c
+++ b/libavformat/libmodplug.c
@@ -224,10 +224,10 @@ static int modplug_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 1000);
st->duration = ModPlug_GetLength(modplug->f);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
- st->codec->channels = settings.mChannels;
- st->codec->sample_rate = settings.mFrequency;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
+ st->codecpar->channels = settings.mChannels;
+ st->codecpar->sample_rate = settings.mFrequency;
// timebase = 1/1000, 2ch 16bits 44.1kHz-> 2*2*44100
modplug->ts_per_packet = 1000*AUDIO_PKT_SIZE / (4*44100.);
@@ -238,10 +238,10 @@ static int modplug_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avpriv_set_pts_info(vst, 64, 1, 1000);
vst->duration = st->duration;
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_id = AV_CODEC_ID_XBIN;
- vst->codec->width = modplug->w << 3;
- vst->codec->height = modplug->h << 3;
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_id = AV_CODEC_ID_XBIN;
+ vst->codecpar->width = modplug->w << 3;
+ vst->codecpar->height = modplug->h << 3;
modplug->linesize = modplug->w * 3;
modplug->fsize = modplug->linesize * modplug->h;
}
diff --git a/libavformat/libnut.c b/libavformat/libnut.c
index 92623ed452..48f0928622 100644
--- a/libavformat/libnut.c
+++ b/libavformat/libnut.c
@@ -75,19 +75,19 @@ static int nut_write_header(AVFormatContext * avf) {
return AVERROR(ENOMEM);
for (i = 0; i < avf->nb_streams; i++) {
- AVCodecContext * codec = avf->streams[i]->codec;
+ AVCodecParameters *par = avf->streams[i]->codecpar;
int j;
int fourcc = 0;
int num, denom, ssize;
- s[i].type = codec->codec_type == AVMEDIA_TYPE_VIDEO ? NUT_VIDEO_CLASS : NUT_AUDIO_CLASS;
+ s[i].type = par->codec_type == AVMEDIA_TYPE_VIDEO ? NUT_VIDEO_CLASS : NUT_AUDIO_CLASS;
- if (codec->codec_tag) fourcc = codec->codec_tag;
- else fourcc = ff_codec_get_tag(nut_tags, codec->codec_id);
+ if (par->codec_tag) fourcc = par->codec_tag;
+ else fourcc = ff_codec_get_tag(nut_tags, par->codec_id);
if (!fourcc) {
- if (codec->codec_type == AVMEDIA_TYPE_VIDEO) fourcc = ff_codec_get_tag(ff_codec_bmp_tags, codec->codec_id);
- if (codec->codec_type == AVMEDIA_TYPE_AUDIO) fourcc = ff_codec_get_tag(ff_codec_wav_tags, codec->codec_id);
+ if (par->codec_type == AVMEDIA_TYPE_VIDEO) fourcc = ff_codec_get_tag(ff_codec_bmp_tags, par->codec_id);
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO) fourcc = ff_codec_get_tag(ff_codec_wav_tags, par->codec_id);
}
s[i].fourcc_len = 4;
@@ -101,20 +101,20 @@ static int nut_write_header(AVFormatContext * avf) {
s[i].time_base.den = num;
s[i].fixed_fps = 0;
- s[i].decode_delay = codec->has_b_frames;
- s[i].codec_specific_len = codec->extradata_size;
- s[i].codec_specific = codec->extradata;
+ s[i].decode_delay = par->video_delay;
+ s[i].codec_specific_len = par->extradata_size;
+ s[i].codec_specific = par->extradata;
- if (codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- s[i].width = codec->width;
- s[i].height = codec->height;
+ if (par->codec_type == AVMEDIA_TYPE_VIDEO) {
+ s[i].width = par->width;
+ s[i].height = par->height;
s[i].sample_width = 0;
s[i].sample_height = 0;
s[i].colorspace_type = 0;
} else {
- s[i].samplerate_num = codec->sample_rate;
+ s[i].samplerate_num = par->sample_rate;
s[i].samplerate_denom = 1;
- s[i].channel_count = codec->channels;
+ s[i].channel_count = par->channels;
}
}
@@ -226,45 +226,45 @@ static int nut_read_header(AVFormatContext * avf) {
if (!st)
return AVERROR(ENOMEM);
- for (j = 0; j < s[i].fourcc_len && j < 8; j++) st->codec->codec_tag |= s[i].fourcc[j]<<(j*8);
+ for (j = 0; j < s[i].fourcc_len && j < 8; j++) st->codecpar->codec_tag |= s[i].fourcc[j]<<(j*8);
- st->codec->has_b_frames = s[i].decode_delay;
+ st->codecpar->video_delay = s[i].decode_delay;
- st->codec->extradata_size = s[i].codec_specific_len;
- if (st->codec->extradata_size) {
- if(ff_alloc_extradata(st->codec, st->codec->extradata_size)){
+ st->codecpar->extradata_size = s[i].codec_specific_len;
+ if (st->codecpar->extradata_size) {
+ if(ff_alloc_extradata(st->codecpar, st->codecpar->extradata_size)){
nut_demuxer_uninit(nut);
priv->nut = NULL;
return AVERROR(ENOMEM);
}
- memcpy(st->codec->extradata, s[i].codec_specific, st->codec->extradata_size);
+ memcpy(st->codecpar->extradata, s[i].codec_specific, st->codecpar->extradata_size);
}
avpriv_set_pts_info(avf->streams[i], 60, s[i].time_base.num, s[i].time_base.den);
st->start_time = 0;
st->duration = s[i].max_pts;
- st->codec->codec_id = ff_codec_get_id(nut_tags, st->codec->codec_tag);
+ st->codecpar->codec_id = ff_codec_get_id(nut_tags, st->codecpar->codec_tag);
switch(s[i].type) {
case NUT_AUDIO_CLASS:
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- if (st->codec->codec_id == AV_CODEC_ID_NONE) st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags, st->codec->codec_tag);
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE) st->codecpar->codec_id = ff_codec_get_id(ff_codec_wav_tags, st->codecpar->codec_tag);
- st->codec->channels = s[i].channel_count;
- st->codec->sample_rate = s[i].samplerate_num / s[i].samplerate_denom;
+ st->codecpar->channels = s[i].channel_count;
+ st->codecpar->sample_rate = s[i].samplerate_num / s[i].samplerate_denom;
break;
case NUT_VIDEO_CLASS:
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- if (st->codec->codec_id == AV_CODEC_ID_NONE) st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, st->codec->codec_tag);
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE) st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, st->codecpar->codec_tag);
- st->codec->width = s[i].width;
- st->codec->height = s[i].height;
+ st->codecpar->width = s[i].width;
+ st->codecpar->height = s[i].height;
st->sample_aspect_ratio.num = s[i].sample_width;
st->sample_aspect_ratio.den = s[i].sample_height;
break;
}
- if (st->codec->codec_id == AV_CODEC_ID_NONE) av_log(avf, AV_LOG_ERROR, "Unknown codec?!\n");
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE) av_log(avf, AV_LOG_ERROR, "Unknown codec?!\n");
}
return 0;
diff --git a/libavformat/lmlm4.c b/libavformat/lmlm4.c
index 899f449634..d0cf8feb03 100644
--- a/libavformat/lmlm4.c
+++ b/libavformat/lmlm4.c
@@ -65,15 +65,15 @@ static int lmlm4_read_header(AVFormatContext *s)
if (!(st = avformat_new_stream(s, NULL)))
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_MPEG4;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_MPEG4;
st->need_parsing = AVSTREAM_PARSE_HEADERS;
avpriv_set_pts_info(st, 64, 1001, 30000);
if (!(st = avformat_new_stream(s, NULL)))
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_MP2;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_MP2;
st->need_parsing = AVSTREAM_PARSE_HEADERS;
/* the parameters will be extracted from the compressed bitstream */
diff --git a/libavformat/loasdec.c b/libavformat/loasdec.c
index c41809be00..70440559d2 100644
--- a/libavformat/loasdec.c
+++ b/libavformat/loasdec.c
@@ -73,8 +73,8 @@ static int loas_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_RAW;
//LCM of all possible AAC sample rates
diff --git a/libavformat/lrcdec.c b/libavformat/lrcdec.c
index d3655fccd5..12f74b22a0 100644
--- a/libavformat/lrcdec.c
+++ b/libavformat/lrcdec.c
@@ -165,8 +165,8 @@ static int lrc_read_header(AVFormatContext *s)
}
avpriv_set_pts_info(st, 64, 1, 1000);
lrc->ts_offset = 0;
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_TEXT;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_TEXT;
av_bprint_init(&line, 0, AV_BPRINT_SIZE_UNLIMITED);
while(!avio_feof(s->pb)) {
diff --git a/libavformat/lrcenc.c b/libavformat/lrcenc.c
index 74268cc681..c5fda64738 100644
--- a/libavformat/lrcenc.c
+++ b/libavformat/lrcenc.c
@@ -39,15 +39,15 @@ static int lrc_write_header(AVFormatContext *s)
const AVDictionaryEntry *metadata_item;
if(s->nb_streams != 1 ||
- s->streams[0]->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) {
+ s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) {
av_log(s, AV_LOG_ERROR,
"LRC supports only a single subtitle stream.\n");
return AVERROR(EINVAL);
}
- if(s->streams[0]->codec->codec_id != AV_CODEC_ID_SUBRIP &&
- s->streams[0]->codec->codec_id != AV_CODEC_ID_TEXT) {
+ if(s->streams[0]->codecpar->codec_id != AV_CODEC_ID_SUBRIP &&
+ s->streams[0]->codecpar->codec_id != AV_CODEC_ID_TEXT) {
av_log(s, AV_LOG_ERROR, "Unsupported subtitle codec: %s\n",
- avcodec_get_name(s->streams[0]->codec->codec_id));
+ avcodec_get_name(s->streams[0]->codecpar->codec_id));
return AVERROR(EINVAL);
}
avpriv_set_pts_info(s->streams[0], 64, 1, 100);
diff --git a/libavformat/lvfdec.c b/libavformat/lvfdec.c
index 81aec599ba..b8af25609f 100644
--- a/libavformat/lvfdec.c
+++ b/libavformat/lvfdec.c
@@ -62,14 +62,14 @@ static int lvf_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
avio_skip(s->pb, 4);
- st->codec->width = avio_rl32(s->pb);
- st->codec->height = avio_rl32(s->pb);
+ st->codecpar->width = avio_rl32(s->pb);
+ st->codecpar->height = avio_rl32(s->pb);
avio_skip(s->pb, 4);
- st->codec->codec_tag = avio_rl32(s->pb);
- st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags,
- st->codec->codec_tag);
+ st->codecpar->codec_tag = avio_rl32(s->pb);
+ st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags,
+ st->codecpar->codec_tag);
avpriv_set_pts_info(st, 32, 1, 1000);
break;
case MKTAG('0', '1', 'f', 'm'):
@@ -77,14 +77,14 @@ static int lvf_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_tag = avio_rl16(s->pb);
- st->codec->channels = avio_rl16(s->pb);
- st->codec->sample_rate = avio_rl16(s->pb);
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_tag = avio_rl16(s->pb);
+ st->codecpar->channels = avio_rl16(s->pb);
+ st->codecpar->sample_rate = avio_rl16(s->pb);
avio_skip(s->pb, 8);
- st->codec->bits_per_coded_sample = avio_r8(s->pb);
- st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags,
- st->codec->codec_tag);
+ st->codecpar->bits_per_coded_sample = avio_r8(s->pb);
+ st->codecpar->codec_id = ff_codec_get_id(ff_codec_wav_tags,
+ st->codecpar->codec_tag);
avpriv_set_pts_info(st, 32, 1, 1000);
break;
case 0:
diff --git a/libavformat/lxfdec.c b/libavformat/lxfdec.c
index c00b4bdea5..99e56f243f 100644
--- a/libavformat/lxfdec.c
+++ b/libavformat/lxfdec.c
@@ -178,25 +178,25 @@ static int get_packet_header(AVFormatContext *s)
//set codec based on specified audio bitdepth
//we only support tightly packed 16-, 20-, 24- and 32-bit PCM at the moment
- st->codec->bits_per_coded_sample = (audio_format >> 6) & 0x3F;
+ st->codecpar->bits_per_coded_sample = (audio_format >> 6) & 0x3F;
- if (st->codec->bits_per_coded_sample != (audio_format & 0x3F)) {
+ if (st->codecpar->bits_per_coded_sample != (audio_format & 0x3F)) {
av_log(s, AV_LOG_WARNING, "only tightly packed PCM currently supported\n");
return AVERROR_PATCHWELCOME;
}
- switch (st->codec->bits_per_coded_sample) {
- case 16: st->codec->codec_id = AV_CODEC_ID_PCM_S16LE_PLANAR; break;
- case 20: st->codec->codec_id = AV_CODEC_ID_PCM_LXF; break;
- case 24: st->codec->codec_id = AV_CODEC_ID_PCM_S24LE_PLANAR; break;
- case 32: st->codec->codec_id = AV_CODEC_ID_PCM_S32LE_PLANAR; break;
+ switch (st->codecpar->bits_per_coded_sample) {
+ case 16: st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE_PLANAR; break;
+ case 20: st->codecpar->codec_id = AV_CODEC_ID_PCM_LXF; break;
+ case 24: st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE_PLANAR; break;
+ case 32: st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE_PLANAR; break;
default:
av_log(s, AV_LOG_WARNING,
"only 16-, 20-, 24- and 32-bit PCM currently supported\n");
return AVERROR_PATCHWELCOME;
}
- samples = track_size * 8 / st->codec->bits_per_coded_sample;
+ samples = track_size * 8 / st->codecpar->bits_per_coded_sample;
//use audio packet size to determine video standard
//for NTSC we have one 8008-sample audio frame per five video frames
@@ -257,11 +257,11 @@ static int lxf_read_header(AVFormatContext *s)
expiration_date = AV_RL16(&header_data[58]);
disk_params = AV_RL32(&header_data[116]);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->bit_rate = 1000000 * ((video_params >> 14) & 0xFF);
- st->codec->codec_tag = video_params & 0xF;
- st->codec->codec_id = ff_codec_get_id(lxf_tags, st->codec->codec_tag);
- st->need_parsing = AVSTREAM_PARSE_HEADERS;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->bit_rate = 1000000 * ((video_params >> 14) & 0xFF);
+ st->codecpar->codec_tag = video_params & 0xF;
+ st->codecpar->codec_id = ff_codec_get_id(lxf_tags, st->codecpar->codec_tag);
+ st->need_parsing = AVSTREAM_PARSE_HEADERS;
av_log(s, AV_LOG_DEBUG, "record: %x = %i-%02i-%02i\n",
record_date, 1900 + (record_date & 0x7F), (record_date >> 7) & 0xF,
@@ -278,11 +278,11 @@ static int lxf_read_header(AVFormatContext *s)
if (!(st = avformat_new_stream(s, NULL)))
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->sample_rate = LXF_SAMPLERATE;
- st->codec->channels = lxf->channels;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->sample_rate = LXF_SAMPLERATE;
+ st->codecpar->channels = lxf->channels;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
}
avio_skip(s->pb, lxf->extended_size);
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 28bb77b4ae..fa301a7900 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1737,7 +1737,7 @@ static int matroska_parse_flac(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_free(&dict);
}
@@ -1785,14 +1785,14 @@ static int mkv_parse_video_color(AVStream *st, const MatroskaTrack *track) {
const int has_mastering_luminance = mastering_meta->max_luminance > 0;
if (track->video.color.matrix_coefficients != AVCOL_SPC_RESERVED)
- st->codec->colorspace = track->video.color.matrix_coefficients;
+ st->codecpar->color_space = track->video.color.matrix_coefficients;
if (track->video.color.primaries != AVCOL_PRI_RESERVED)
- st->codec->color_primaries = track->video.color.primaries;
+ st->codecpar->color_primaries = track->video.color.primaries;
if (track->video.color.transfer_characteristics != AVCOL_TRC_RESERVED)
- st->codec->color_trc = track->video.color.transfer_characteristics;
+ st->codecpar->color_trc = track->video.color.transfer_characteristics;
if (track->video.color.range != AVCOL_RANGE_UNSPECIFIED &&
track->video.color.range <= AVCOL_RANGE_JPEG)
- st->codec->color_range = track->video.color.range;
+ st->codecpar->color_range = track->video.color.range;
if (has_mastering_primaries || has_mastering_luminance) {
// Use similar rationals as other standards.
@@ -2009,11 +2009,11 @@ static int matroska_parse_tracks(AVFormatContext *s)
ffio_init_context(&b, track->codec_priv.data,
track->codec_priv.size,
0, NULL, NULL, NULL, NULL);
- ret = ff_get_wav_header(s, &b, st->codec, track->codec_priv.size, 0);
+ ret = ff_get_wav_header(s, &b, st->codecpar, track->codec_priv.size, 0);
if (ret < 0)
return ret;
- codec_id = st->codec->codec_id;
- fourcc = st->codec->codec_tag;
+ codec_id = st->codecpar->codec_id;
+ fourcc = st->codecpar->codec_tag;
extradata_offset = FFMIN(track->codec_priv.size, 18);
} else if (!strcmp(track->codec_id, "A_QUICKTIME")
/* Normally 36, but allow noncompliant private data */
@@ -2185,15 +2185,15 @@ static int matroska_parse_tracks(AVFormatContext *s)
if (!track->audio.buf)
return AVERROR(ENOMEM);
if (codec_id == AV_CODEC_ID_RA_288) {
- st->codec->block_align = track->audio.coded_framesize;
+ st->codecpar->block_align = track->audio.coded_framesize;
track->codec_priv.size = 0;
} else {
if (codec_id == AV_CODEC_ID_SIPR && flavor < 4) {
static const int sipr_bit_rate[4] = { 6504, 8496, 5000, 16000 };
track->audio.sub_packet_size = ff_sipr_subpk_size[flavor];
- st->codec->bit_rate = sipr_bit_rate[flavor];
+ st->codecpar->bit_rate = sipr_bit_rate[flavor];
}
- st->codec->block_align = track->audio.sub_packet_size;
+ st->codecpar->block_align = track->audio.sub_packet_size;
extradata_offset = 78;
}
} else if (codec_id == AV_CODEC_ID_FLAC && track->codec_priv.size) {
@@ -2219,7 +2219,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
(AVRational){ 1, 1000000000 },
st->time_base);
- st->codec->codec_id = codec_id;
+ st->codecpar->codec_id = codec_id;
if (strcmp(track->language, "und"))
av_dict_set(&st->metadata, "language", track->language, 0);
@@ -2230,14 +2230,14 @@ static int matroska_parse_tracks(AVFormatContext *s)
if (track->flag_forced)
st->disposition |= AV_DISPOSITION_FORCED;
- if (!st->codec->extradata) {
+ if (!st->codecpar->extradata) {
if (extradata) {
- st->codec->extradata = extradata;
- st->codec->extradata_size = extradata_size;
+ st->codecpar->extradata = extradata;
+ st->codecpar->extradata_size = extradata_size;
} else if (track->codec_priv.data && track->codec_priv.size > 0) {
- if (ff_alloc_extradata(st->codec, track->codec_priv.size))
+ if (ff_alloc_extradata(st->codecpar, track->codec_priv.size))
return AVERROR(ENOMEM);
- memcpy(st->codec->extradata,
+ memcpy(st->codecpar->extradata,
track->codec_priv.data + extradata_offset,
track->codec_priv.size);
}
@@ -2248,22 +2248,22 @@ static int matroska_parse_tracks(AVFormatContext *s)
int display_width_mul = 1;
int display_height_mul = 1;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_tag = fourcc;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_tag = fourcc;
if (bit_depth >= 0)
- st->codec->bits_per_coded_sample = bit_depth;
- st->codec->width = track->video.pixel_width;
- st->codec->height = track->video.pixel_height;
+ st->codecpar->bits_per_coded_sample = bit_depth;
+ st->codecpar->width = track->video.pixel_width;
+ st->codecpar->height = track->video.pixel_height;
if (track->video.stereo_mode && track->video.stereo_mode < MATROSKA_VIDEO_STEREOMODE_TYPE_NB)
mkv_stereo_mode_display_mul(track->video.stereo_mode, &display_width_mul, &display_height_mul);
av_reduce(&st->sample_aspect_ratio.num,
&st->sample_aspect_ratio.den,
- st->codec->height * track->video.display_width * display_width_mul,
- st->codec->width * track->video.display_height * display_height_mul,
+ st->codecpar->height * track->video.display_width * display_width_mul,
+ st->codecpar->width * track->video.display_height * display_height_mul,
255);
- if (st->codec->codec_id != AV_CODEC_ID_HEVC)
+ if (st->codecpar->codec_id != AV_CODEC_ID_HEVC)
st->need_parsing = AVSTREAM_PARSE_HEADERS;
if (track->default_duration) {
@@ -2312,29 +2312,28 @@ static int matroska_parse_tracks(AVFormatContext *s)
return ret;
}
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_tag = fourcc;
- st->codec->sample_rate = track->audio.out_samplerate;
- st->codec->channels = track->audio.channels;
- if (!st->codec->bits_per_coded_sample)
- st->codec->bits_per_coded_sample = track->audio.bitdepth;
- if (st->codec->codec_id == AV_CODEC_ID_MP3)
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_tag = fourcc;
+ st->codecpar->sample_rate = track->audio.out_samplerate;
+ st->codecpar->channels = track->audio.channels;
+ if (!st->codecpar->bits_per_coded_sample)
+ st->codecpar->bits_per_coded_sample = track->audio.bitdepth;
+ if (st->codecpar->codec_id == AV_CODEC_ID_MP3)
st->need_parsing = AVSTREAM_PARSE_FULL;
- else if (st->codec->codec_id != AV_CODEC_ID_AAC)
+ else if (st->codecpar->codec_id != AV_CODEC_ID_AAC)
st->need_parsing = AVSTREAM_PARSE_HEADERS;
if (track->codec_delay > 0) {
- st->codec->delay = av_rescale_q(track->codec_delay,
- st->time_base,
- (AVRational){1, st->codec->sample_rate});
+ st->codecpar->initial_padding = av_rescale_q(track->codec_delay,
+ st->time_base,
+ (AVRational){1, st->codecpar->sample_rate});
}
if (track->seek_preroll > 0) {
- av_codec_set_seek_preroll(st->codec,
- av_rescale_q(track->seek_preroll,
- (AVRational){1, 1000000000},
- (AVRational){1, st->codec->sample_rate}));
+ st->codecpar->seek_preroll = av_rescale_q(track->seek_preroll,
+ (AVRational){1, 1000000000},
+ (AVRational){1, st->codecpar->sample_rate});
}
} else if (codec_id == AV_CODEC_ID_WEBVTT) {
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
if (!strcmp(track->codec_id, "D_WEBVTT/CAPTIONS")) {
st->disposition |= AV_DISPOSITION_CAPTIONS;
@@ -2344,8 +2343,8 @@ static int matroska_parse_tracks(AVFormatContext *s)
st->disposition |= AV_DISPOSITION_METADATA;
}
} else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) {
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- if (st->codec->codec_id == AV_CODEC_ID_ASS)
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ if (st->codecpar->codec_id == AV_CODEC_ID_ASS)
matroska->contains_ssa = 1;
}
}
@@ -2441,21 +2440,21 @@ static int matroska_read_header(AVFormatContext *s)
break;
av_dict_set(&st->metadata, "filename", attachments[j].filename, 0);
av_dict_set(&st->metadata, "mimetype", attachments[j].mime, 0);
- st->codec->codec_id = AV_CODEC_ID_NONE;
+ st->codecpar->codec_id = AV_CODEC_ID_NONE;
for (i = 0; ff_mkv_image_mime_tags[i].id != AV_CODEC_ID_NONE; i++) {
if (!strncmp(ff_mkv_image_mime_tags[i].str, attachments[j].mime,
strlen(ff_mkv_image_mime_tags[i].str))) {
- st->codec->codec_id = ff_mkv_image_mime_tags[i].id;
+ st->codecpar->codec_id = ff_mkv_image_mime_tags[i].id;
break;
}
}
attachments[j].stream = st;
- if (st->codec->codec_id != AV_CODEC_ID_NONE) {
- st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ if (st->codecpar->codec_id != AV_CODEC_ID_NONE) {
+ st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
av_init_packet(&st->attached_pic);
if ((res = av_new_packet(&st->attached_pic, attachments[j].bin.size)) < 0)
@@ -2464,16 +2463,16 @@ static int matroska_read_header(AVFormatContext *s)
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
} else {
- st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
- if (ff_alloc_extradata(st->codec, attachments[j].bin.size))
+ st->codecpar->codec_type = AVMEDIA_TYPE_ATTACHMENT;
+ if (ff_alloc_extradata(st->codecpar, attachments[j].bin.size))
break;
- memcpy(st->codec->extradata, attachments[j].bin.data,
+ memcpy(st->codecpar->extradata, attachments[j].bin.data,
attachments[j].bin.size);
for (i = 0; ff_mkv_mime_tags[i].id != AV_CODEC_ID_NONE; i++) {
if (!strncmp(ff_mkv_mime_tags[i].str, attachments[j].mime,
strlen(ff_mkv_mime_tags[i].str))) {
- st->codec->codec_id = ff_mkv_mime_tags[i].id;
+ st->codecpar->codec_id = ff_mkv_mime_tags[i].id;
break;
}
}
@@ -2677,7 +2676,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
uint8_t *data, int size, uint64_t timecode,
int64_t pos)
{
- int a = st->codec->block_align;
+ int a = st->codecpar->block_align;
int sps = track->audio.sub_packet_size;
int cfs = track->audio.coded_framesize;
int h = track->audio.sub_packet_h;
@@ -2688,7 +2687,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
if (!track->audio.pkt_cnt) {
if (track->audio.sub_packet_cnt == 0)
track->audio.buf_timecode = timecode;
- if (st->codec->codec_id == AV_CODEC_ID_RA_288) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_RA_288) {
if (size < cfs * h / 2) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Corrupt int4 RM-style audio packet size\n");
@@ -2697,7 +2696,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
for (x = 0; x < h / 2; x++)
memcpy(track->audio.buf + x * 2 * w + y * cfs,
data + x * cfs, cfs);
- } else if (st->codec->codec_id == AV_CODEC_ID_SIPR) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_SIPR) {
if (size < w) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Corrupt sipr RM-style audio packet size\n");
@@ -2717,7 +2716,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
}
if (++track->audio.sub_packet_cnt >= h) {
- if (st->codec->codec_id == AV_CODEC_ID_SIPR)
+ if (st->codecpar->codec_id == AV_CODEC_ID_SIPR)
ff_rm_reorder_sipr_data(track->audio.buf, h, w);
track->audio.sub_packet_cnt = 0;
track->audio.pkt_cnt = h * w / a;
@@ -2759,10 +2758,10 @@ static int matroska_parse_wavpack(MatroskaTrack *track, uint8_t *src,
uint16_t ver;
int ret, offset = 0;
- if (srclen < 12 || track->stream->codec->extradata_size < 2)
+ if (srclen < 12 || track->stream->codecpar->extradata_size < 2)
return AVERROR_INVALIDDATA;
- ver = AV_RL16(track->stream->codec->extradata);
+ ver = AV_RL16(track->stream->codecpar->extradata);
samples = AV_RL32(src);
src += 4;
@@ -2964,7 +2963,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
return res;
}
- if (st->codec->codec_id == AV_CODEC_ID_WAVPACK) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_WAVPACK) {
uint8_t *wv_data;
res = matroska_parse_wavpack(track, pkt_data, &wv_data, &pkt_size);
if (res < 0) {
@@ -2977,7 +2976,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
pkt_data = wv_data;
}
- if (st->codec->codec_id == AV_CODEC_ID_PRORES &&
+ if (st->codecpar->codec_id == AV_CODEC_ID_PRORES &&
AV_RB32(&data[4]) != MKBETAG('i', 'c', 'p', 'f'))
offset = 8;
@@ -2994,7 +2993,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
goto fail;
}
- if (st->codec->codec_id == AV_CODEC_ID_PRORES && offset == 8) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_PRORES && offset == 8) {
uint8_t *buf = pkt->data;
bytestream_put_be32(&buf, pkt_size);
bytestream_put_be32(&buf, MKBETAG('i', 'c', 'p', 'f'));
@@ -3033,7 +3032,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
AV_WL32(side_data, 0);
AV_WL32(side_data + 4, av_rescale_q(discard_padding,
(AVRational){1, 1000000000},
- (AVRational){1, st->codec->sample_rate}));
+ (AVRational){1, st->codecpar->sample_rate}));
}
if (track->ms_compat)
@@ -3045,7 +3044,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
#if FF_API_CONVERGENCE_DURATION
FF_DISABLE_DEPRECATION_WARNINGS
- if (st->codec->codec_id == AV_CODEC_ID_SUBRIP) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_SUBRIP) {
pkt->convergence_duration = lace_duration;
}
FF_ENABLE_DEPRECATION_WARNINGS
@@ -3135,8 +3134,8 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
if (track->audio.samplerate == 8000) {
// If this is needed for more codecs, then add them here
- if (st->codec->codec_id == AV_CODEC_ID_AC3) {
- if (track->audio.samplerate != st->codec->sample_rate || !st->codec->frame_size)
+ if (st->codecpar->codec_id == AV_CODEC_ID_AC3) {
+ if (track->audio.samplerate != st->codecpar->sample_rate || !st->codecpar->frame_size)
trust_default_duration = 0;
}
}
@@ -3156,18 +3155,18 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
break;
}
- if ((st->codec->codec_id == AV_CODEC_ID_RA_288 ||
- st->codec->codec_id == AV_CODEC_ID_COOK ||
- st->codec->codec_id == AV_CODEC_ID_SIPR ||
- st->codec->codec_id == AV_CODEC_ID_ATRAC3) &&
- st->codec->block_align && track->audio.sub_packet_size) {
+ if ((st->codecpar->codec_id == AV_CODEC_ID_RA_288 ||
+ st->codecpar->codec_id == AV_CODEC_ID_COOK ||
+ st->codecpar->codec_id == AV_CODEC_ID_SIPR ||
+ st->codecpar->codec_id == AV_CODEC_ID_ATRAC3) &&
+ st->codecpar->block_align && track->audio.sub_packet_size) {
res = matroska_parse_rm_audio(matroska, track, st, data,
lace_size[n],
timecode, pos);
if (res)
goto end;
- } else if (st->codec->codec_id == AV_CODEC_ID_WEBVTT) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_WEBVTT) {
res = matroska_parse_webvtt(matroska, track, st,
data, lace_size[n],
timecode, lace_duration,
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 0546686d8e..2be0629309 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -486,7 +486,7 @@ static int64_t mkv_write_cues(AVFormatContext *s, mkv_cues *cues, mkv_track *tra
for (j = 0; j < cues->num_entries - i && entry[j].pts == pts; j++) {
int tracknum = entry[j].stream_idx;
av_assert0(tracknum>=0 && tracknum<num_tracks);
- if (tracks[tracknum].has_cue && s->streams[tracknum]->codec->codec_type != AVMEDIA_TYPE_SUBTITLE)
+ if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
continue;
tracks[tracknum].has_cue = 1;
ctp_nb ++;
@@ -502,7 +502,7 @@ static int64_t mkv_write_cues(AVFormatContext *s, mkv_cues *cues, mkv_track *tra
for (j = 0; j < cues->num_entries - i && entry[j].pts == pts; j++) {
int tracknum = entry[j].stream_idx;
av_assert0(tracknum>=0 && tracknum<num_tracks);
- if (tracks[tracknum].has_cue && s->streams[tracknum]->codec->codec_type != AVMEDIA_TYPE_SUBTITLE)
+ if (tracks[tracknum].has_cue && s->streams[tracknum]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
continue;
tracks[tracknum].has_cue = 1;
track_positions = start_ebml_master(pb, MATROSKA_ID_CUETRACKPOSITION, MAX_CUETRACKPOS_SIZE);
@@ -521,19 +521,19 @@ static int64_t mkv_write_cues(AVFormatContext *s, mkv_cues *cues, mkv_track *tra
return currentpos;
}
-static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, AVCodecContext *codec)
+static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par)
{
const uint8_t *header_start[3];
int header_len[3];
int first_header_size;
int j;
- if (codec->codec_id == AV_CODEC_ID_VORBIS)
+ if (par->codec_id == AV_CODEC_ID_VORBIS)
first_header_size = 30;
else
first_header_size = 42;
- if (avpriv_split_xiph_headers(codec->extradata, codec->extradata_size,
+ if (avpriv_split_xiph_headers(par->extradata, par->extradata_size,
first_header_size, header_start, header_len) < 0) {
av_log(s, AV_LOG_ERROR, "Extradata corrupt.\n");
return -1;
@@ -549,22 +549,22 @@ static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, AVCodecContex
return 0;
}
-static int put_wv_codecpriv(AVIOContext *pb, AVCodecContext *codec)
+static int put_wv_codecpriv(AVIOContext *pb, AVCodecParameters *par)
{
- if (codec->extradata && codec->extradata_size == 2)
- avio_write(pb, codec->extradata, 2);
+ if (par->extradata && par->extradata_size == 2)
+ avio_write(pb, par->extradata, 2);
else
avio_wl16(pb, 0x403); // fallback to the version mentioned in matroska specs
return 0;
}
static int put_flac_codecpriv(AVFormatContext *s,
- AVIOContext *pb, AVCodecContext *codec)
+ AVIOContext *pb, AVCodecParameters *par)
{
- int write_comment = (codec->channel_layout &&
- !(codec->channel_layout & ~0x3ffffULL) &&
- !ff_flac_is_native_layout(codec->channel_layout));
- int ret = ff_flac_write_header(pb, codec->extradata, codec->extradata_size,
+ int write_comment = (par->channel_layout &&
+ !(par->channel_layout & ~0x3ffffULL) &&
+ !ff_flac_is_native_layout(par->channel_layout));
+ int ret = ff_flac_write_header(pb, par->extradata, par->extradata_size,
!write_comment);
if (ret < 0)
@@ -577,7 +577,7 @@ static int put_flac_codecpriv(AVFormatContext *s,
uint8_t buf[32], *data, *p;
int64_t len;
- snprintf(buf, sizeof(buf), "0x%"PRIx64, codec->channel_layout);
+ snprintf(buf, sizeof(buf), "0x%"PRIx64, par->channel_layout);
av_dict_set(&dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);
len = ff_vorbiscomment_length(dict, vendor);
@@ -605,13 +605,13 @@ static int put_flac_codecpriv(AVFormatContext *s,
return 0;
}
-static int get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec,
+static int get_aac_sample_rates(AVFormatContext *s, AVCodecParameters *par,
int *sample_rate, int *output_sample_rate)
{
MPEG4AudioConfig mp4ac;
- if (avpriv_mpeg4audio_get_config(&mp4ac, codec->extradata,
- codec->extradata_size * 8, 1) < 0) {
+ if (avpriv_mpeg4audio_get_config(&mp4ac, par->extradata,
+ par->extradata_size * 8, 1) < 0) {
av_log(s, AV_LOG_ERROR,
"Error parsing AAC extradata, unable to determine samplerate.\n");
return AVERROR(EINVAL);
@@ -623,48 +623,48 @@ static int get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec,
}
static int mkv_write_native_codecprivate(AVFormatContext *s,
- AVCodecContext *codec,
+ AVCodecParameters *par,
AVIOContext *dyn_cp)
{
- switch (codec->codec_id) {
+ switch (par->codec_id) {
case AV_CODEC_ID_VORBIS:
case AV_CODEC_ID_THEORA:
- return put_xiph_codecpriv(s, dyn_cp, codec);
+ return put_xiph_codecpriv(s, dyn_cp, par);
case AV_CODEC_ID_FLAC:
- return put_flac_codecpriv(s, dyn_cp, codec);
+ return put_flac_codecpriv(s, dyn_cp, par);
case AV_CODEC_ID_WAVPACK:
- return put_wv_codecpriv(dyn_cp, codec);
+ return put_wv_codecpriv(dyn_cp, par);
case AV_CODEC_ID_H264:
- return ff_isom_write_avcc(dyn_cp, codec->extradata,
- codec->extradata_size);
+ return ff_isom_write_avcc(dyn_cp, par->extradata,
+ par->extradata_size);
case AV_CODEC_ID_HEVC:
- ff_isom_write_hvcc(dyn_cp, codec->extradata,
- codec->extradata_size, 0);
+ ff_isom_write_hvcc(dyn_cp, par->extradata,
+ par->extradata_size, 0);
return 0;
case AV_CODEC_ID_ALAC:
- if (codec->extradata_size < 36) {
+ if (par->extradata_size < 36) {
av_log(s, AV_LOG_ERROR,
"Invalid extradata found, ALAC expects a 36-byte "
"QuickTime atom.");
return AVERROR_INVALIDDATA;
} else
- avio_write(dyn_cp, codec->extradata + 12,
- codec->extradata_size - 12);
+ avio_write(dyn_cp, par->extradata + 12,
+ par->extradata_size - 12);
break;
default:
- if (codec->codec_id == AV_CODEC_ID_PRORES &&
- ff_codec_get_id(ff_codec_movvideo_tags, codec->codec_tag) == AV_CODEC_ID_PRORES) {
- avio_wl32(dyn_cp, codec->codec_tag);
- } else if (codec->extradata_size && codec->codec_id != AV_CODEC_ID_TTA)
- avio_write(dyn_cp, codec->extradata, codec->extradata_size);
+ if (par->codec_id == AV_CODEC_ID_PRORES &&
+ ff_codec_get_id(ff_codec_movvideo_tags, par->codec_tag) == AV_CODEC_ID_PRORES) {
+ avio_wl32(dyn_cp, par->codec_tag);
+ } else if (par->extradata_size && par->codec_id != AV_CODEC_ID_TTA)
+ avio_write(dyn_cp, par->extradata, par->extradata_size);
}
return 0;
}
static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb,
- AVCodecContext *codec, int native_id,
- int qt_id)
+ AVCodecParameters *par,
+ int native_id, int qt_id)
{
AVIOContext *dyn_cp;
uint8_t *codecpriv;
@@ -675,52 +675,52 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb,
return ret;
if (native_id) {
- ret = mkv_write_native_codecprivate(s, codec, dyn_cp);
- } else if (codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ ret = mkv_write_native_codecprivate(s, par, dyn_cp);
+ } else if (par->codec_type == AVMEDIA_TYPE_VIDEO) {
if (qt_id) {
- if (!codec->codec_tag)
- codec->codec_tag = ff_codec_get_tag(ff_codec_movvideo_tags,
- codec->codec_id);
- if (codec->extradata_size) {
- if ( ff_codec_get_id(ff_codec_movvideo_tags, codec->codec_tag) == codec->codec_id
- && ff_codec_get_id(ff_codec_movvideo_tags, AV_RL32(codec->extradata + 4)) != codec->codec_id
+ if (!par->codec_tag)
+ par->codec_tag = ff_codec_get_tag(ff_codec_movvideo_tags,
+ par->codec_id);
+ if (par->extradata_size) {
+ if ( ff_codec_get_id(ff_codec_movvideo_tags, par->codec_tag) == par->codec_id
+ && ff_codec_get_id(ff_codec_movvideo_tags, AV_RL32(par->extradata + 4)) != par->codec_id
) {
int i;
- avio_wb32(dyn_cp, 0x5a + codec->extradata_size);
- avio_wl32(dyn_cp, codec->codec_tag);
+ avio_wb32(dyn_cp, 0x5a + par->extradata_size);
+ avio_wl32(dyn_cp, par->codec_tag);
for(i = 0; i < 0x5a - 8; i++)
avio_w8(dyn_cp, 0);
}
- avio_write(dyn_cp, codec->extradata, codec->extradata_size);
+ avio_write(dyn_cp, par->extradata, par->extradata_size);
}
} else {
- if (!ff_codec_get_tag(ff_codec_bmp_tags, codec->codec_id))
+ if (!ff_codec_get_tag(ff_codec_bmp_tags, par->codec_id))
av_log(s, AV_LOG_WARNING, "codec %s is not supported by this format\n",
- avcodec_get_name(codec->codec_id));
+ avcodec_get_name(par->codec_id));
- if (!codec->codec_tag)
- codec->codec_tag = ff_codec_get_tag(ff_codec_bmp_tags,
- codec->codec_id);
- if (!codec->codec_tag && codec->codec_id != AV_CODEC_ID_RAWVIDEO) {
+ if (!par->codec_tag)
+ par->codec_tag = ff_codec_get_tag(ff_codec_bmp_tags,
+ par->codec_id);
+ if (!par->codec_tag && par->codec_id != AV_CODEC_ID_RAWVIDEO) {
av_log(s, AV_LOG_ERROR, "No bmp codec tag found for codec %s\n",
- avcodec_get_name(codec->codec_id));
+ avcodec_get_name(par->codec_id));
ret = AVERROR(EINVAL);
}
- ff_put_bmp_header(dyn_cp, codec, ff_codec_bmp_tags, 0, 0);
+ ff_put_bmp_header(dyn_cp, par, ff_codec_bmp_tags, 0, 0);
}
- } else if (codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ } else if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
unsigned int tag;
- tag = ff_codec_get_tag(ff_codec_wav_tags, codec->codec_id);
+ tag = ff_codec_get_tag(ff_codec_wav_tags, par->codec_id);
if (!tag) {
av_log(s, AV_LOG_ERROR, "No wav codec tag found for codec %s\n",
- avcodec_get_name(codec->codec_id));
+ avcodec_get_name(par->codec_id));
ret = AVERROR(EINVAL);
}
- if (!codec->codec_tag)
- codec->codec_tag = tag;
+ if (!par->codec_tag)
+ par->codec_tag = tag;
- ff_put_wav_header(dyn_cp, codec, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
+ ff_put_wav_header(s, dyn_cp, par, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
}
codecpriv_size = avio_close_dyn_buf(dyn_cp, &codecpriv);
@@ -731,28 +731,28 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb,
return ret;
}
-static int mkv_write_video_color(AVIOContext *pb, AVCodecContext *codec, AVStream *st) {
+static int mkv_write_video_color(AVIOContext *pb, AVCodecParameters *par, AVStream *st) {
int side_data_size = 0;
const uint8_t *side_data = av_stream_get_side_data(
st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, &side_data_size);
ebml_master colorinfo = start_ebml_master(pb, MATROSKA_ID_VIDEOCOLOR, 0);
- if (codec->color_trc != AVCOL_TRC_UNSPECIFIED &&
- codec->color_trc < AVCOL_TRC_NB) {
+ if (par->color_trc != AVCOL_TRC_UNSPECIFIED &&
+ par->color_trc < AVCOL_TRC_NB) {
put_ebml_uint(pb, MATROSKA_ID_VIDEOCOLORTRANSFERCHARACTERISTICS,
- codec->color_trc);
+ par->color_trc);
}
- if (codec->colorspace != AVCOL_SPC_UNSPECIFIED &&
- codec->colorspace < AVCOL_SPC_NB) {
- put_ebml_uint(pb, MATROSKA_ID_VIDEOCOLORMATRIXCOEFF, codec->colorspace);
+ if (par->color_space != AVCOL_SPC_UNSPECIFIED &&
+ par->color_space < AVCOL_SPC_NB) {
+ put_ebml_uint(pb, MATROSKA_ID_VIDEOCOLORMATRIXCOEFF, par->color_space);
}
- if (codec->color_primaries != AVCOL_PRI_UNSPECIFIED &&
- codec->color_primaries < AVCOL_PRI_NB) {
- put_ebml_uint(pb, MATROSKA_ID_VIDEOCOLORPRIMARIES, codec->color_primaries);
+ if (par->color_primaries != AVCOL_PRI_UNSPECIFIED &&
+ par->color_primaries < AVCOL_PRI_NB) {
+ put_ebml_uint(pb, MATROSKA_ID_VIDEOCOLORPRIMARIES, par->color_primaries);
}
- if (codec->color_range != AVCOL_RANGE_UNSPECIFIED &&
- codec->color_range < AVCOL_RANGE_NB) {
- put_ebml_uint(pb, MATROSKA_ID_VIDEOCOLORRANGE, codec->color_range);
+ if (par->color_range != AVCOL_RANGE_UNSPECIFIED &&
+ par->color_range < AVCOL_RANGE_NB) {
+ put_ebml_uint(pb, MATROSKA_ID_VIDEOCOLORRANGE, par->color_range);
}
if (side_data_size == sizeof(AVMasteringDisplayMetadata)) {
ebml_master meta_element = start_ebml_master(
@@ -892,34 +892,34 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
int i, AVIOContext *pb, int default_stream_exists)
{
AVStream *st = s->streams[i];
- AVCodecContext *codec = st->codec;
+ AVCodecParameters *par = st->codecpar;
ebml_master subinfo, track;
int native_id = 0;
int qt_id = 0;
- int bit_depth = av_get_bits_per_sample(codec->codec_id);
- int sample_rate = codec->sample_rate;
+ int bit_depth = av_get_bits_per_sample(par->codec_id);
+ int sample_rate = par->sample_rate;
int output_sample_rate = 0;
int display_width_div = 1;
int display_height_div = 1;
int j, ret;
AVDictionaryEntry *tag;
- if (codec->codec_type == AVMEDIA_TYPE_ATTACHMENT) {
+ if (par->codec_type == AVMEDIA_TYPE_ATTACHMENT) {
mkv->have_attachments = 1;
return 0;
}
- if (!bit_depth && codec->codec_id != AV_CODEC_ID_ADPCM_G726) {
- if (codec->bits_per_raw_sample)
- bit_depth = codec->bits_per_raw_sample;
+ if (!bit_depth && par->codec_id != AV_CODEC_ID_ADPCM_G726) {
+ if (par->bits_per_coded_sample)
+ bit_depth = par->bits_per_coded_sample;
else
- bit_depth = av_get_bytes_per_sample(codec->sample_fmt) << 3;
+ bit_depth = av_get_bytes_per_sample(par->format) << 3;
}
if (!bit_depth)
- bit_depth = codec->bits_per_coded_sample;
+ bit_depth = par->bits_per_coded_sample;
- if (codec->codec_id == AV_CODEC_ID_AAC) {
- ret = get_aac_sample_rates(s, codec, &sample_rate, &output_sample_rate);
+ if (par->codec_id == AV_CODEC_ID_AAC) {
+ ret = get_aac_sample_rates(s, par, &sample_rate, &output_sample_rate);
if (ret < 0)
return ret;
}
@@ -934,7 +934,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
if ((tag = av_dict_get(st->metadata, "title", NULL, 0)))
put_ebml_string(pb, MATROSKA_ID_TRACKNAME, tag->value);
tag = av_dict_get(st->metadata, "language", NULL, 0);
- if (mkv->mode != MODE_WEBM || codec->codec_id != AV_CODEC_ID_WEBVTT) {
+ if (mkv->mode != MODE_WEBM || par->codec_id != AV_CODEC_ID_WEBVTT) {
put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, tag && tag->value ? tag->value:"und");
} else if (tag && tag->value) {
put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, tag->value);
@@ -948,7 +948,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
if (st->disposition & AV_DISPOSITION_FORCED)
put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGFORCED, 1);
- if (mkv->mode == MODE_WEBM && codec->codec_id == AV_CODEC_ID_WEBVTT) {
+ if (mkv->mode == MODE_WEBM && par->codec_id == AV_CODEC_ID_WEBVTT) {
const char *codec_id;
if (st->disposition & AV_DISPOSITION_CAPTIONS) {
codec_id = "D_WEBVTT/CAPTIONS";
@@ -968,13 +968,13 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
// look for a codec ID string specific to mkv to use,
// if none are found, use AVI codes
for (j = 0; ff_mkv_codec_tags[j].id != AV_CODEC_ID_NONE; j++) {
- if (ff_mkv_codec_tags[j].id == codec->codec_id) {
+ if (ff_mkv_codec_tags[j].id == par->codec_id) {
put_ebml_string(pb, MATROSKA_ID_CODECID, ff_mkv_codec_tags[j].str);
native_id = 1;
break;
}
}
- if (codec->codec_id == AV_CODEC_ID_RAWVIDEO && !codec->codec_tag) {
+ if (par->codec_id == AV_CODEC_ID_RAWVIDEO && !par->codec_tag) {
if (mkv->allow_raw_vfw) {
native_id = 0;
} else {
@@ -985,50 +985,50 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
}
}
- if (codec->codec_type == AVMEDIA_TYPE_AUDIO && codec->initial_padding && codec->codec_id == AV_CODEC_ID_OPUS) {
- int64_t codecdelay = av_rescale_q(codec->initial_padding,
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO && par->initial_padding && par->codec_id == AV_CODEC_ID_OPUS) {
+ int64_t codecdelay = av_rescale_q(par->initial_padding,
(AVRational){ 1, 48000 },
(AVRational){ 1, 1000000000 });
if (codecdelay < 0) {
av_log(s, AV_LOG_ERROR, "Initial padding is invalid\n");
return AVERROR(EINVAL);
}
-// mkv->tracks[i].ts_offset = av_rescale_q(codec->initial_padding,
-// (AVRational){ 1, codec->sample_rate },
+// mkv->tracks[i].ts_offset = av_rescale_q(par->initial_padding,
+// (AVRational){ 1, par->sample_rate },
// st->time_base);
put_ebml_uint(pb, MATROSKA_ID_CODECDELAY, codecdelay);
}
- if (codec->codec_id == AV_CODEC_ID_OPUS) {
+ if (par->codec_id == AV_CODEC_ID_OPUS) {
put_ebml_uint(pb, MATROSKA_ID_SEEKPREROLL, OPUS_SEEK_PREROLL);
}
- if (mkv->mode == MODE_WEBM && !(codec->codec_id == AV_CODEC_ID_VP8 ||
- codec->codec_id == AV_CODEC_ID_VP9 ||
- codec->codec_id == AV_CODEC_ID_OPUS ||
- codec->codec_id == AV_CODEC_ID_VORBIS ||
- codec->codec_id == AV_CODEC_ID_WEBVTT)) {
+ if (mkv->mode == MODE_WEBM && !(par->codec_id == AV_CODEC_ID_VP8 ||
+ par->codec_id == AV_CODEC_ID_VP9 ||
+ par->codec_id == AV_CODEC_ID_OPUS ||
+ par->codec_id == AV_CODEC_ID_VORBIS ||
+ par->codec_id == AV_CODEC_ID_WEBVTT)) {
av_log(s, AV_LOG_ERROR,
"Only VP8 or VP9 video and Vorbis or Opus audio and WebVTT subtitles are supported for WebM.\n");
return AVERROR(EINVAL);
}
- switch (codec->codec_type) {
+ switch (par->codec_type) {
case AVMEDIA_TYPE_VIDEO:
put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_VIDEO);
if( st->avg_frame_rate.num > 0 && st->avg_frame_rate.den > 0
- && av_cmp_q(av_inv_q(st->avg_frame_rate), codec->time_base) > 0)
+ && av_cmp_q(av_inv_q(st->avg_frame_rate), st->time_base) > 0)
put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, 1000000000LL * st->avg_frame_rate.den / st->avg_frame_rate.num);
else
- put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, 1000000000LL * codec->time_base.num / codec->time_base.den);
+ put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, 1000000000LL * st->time_base.num / st->time_base.den);
if (!native_id &&
- ff_codec_get_tag(ff_codec_movvideo_tags, codec->codec_id) &&
- ((!ff_codec_get_tag(ff_codec_bmp_tags, codec->codec_id) && codec->codec_id != AV_CODEC_ID_RAWVIDEO) ||
- codec->codec_id == AV_CODEC_ID_SVQ1 ||
- codec->codec_id == AV_CODEC_ID_SVQ3 ||
- codec->codec_id == AV_CODEC_ID_CINEPAK))
+ ff_codec_get_tag(ff_codec_movvideo_tags, par->codec_id) &&
+ ((!ff_codec_get_tag(ff_codec_bmp_tags, par->codec_id) && par->codec_id != AV_CODEC_ID_RAWVIDEO) ||
+ par->codec_id == AV_CODEC_ID_SVQ1 ||
+ par->codec_id == AV_CODEC_ID_SVQ3 ||
+ par->codec_id == AV_CODEC_ID_CINEPAK))
qt_id = 1;
if (qt_id)
@@ -1042,8 +1042,8 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKVIDEO, 0);
// XXX: interlace flag?
- put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELWIDTH , codec->width);
- put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELHEIGHT, codec->height);
+ put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELWIDTH , par->width);
+ put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELHEIGHT, par->height);
// check both side data and metadata for stereo information,
// write the result to the bitstream if any is found
@@ -1055,31 +1055,31 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
if (((tag = av_dict_get(st->metadata, "alpha_mode", NULL, 0)) && atoi(tag->value)) ||
((tag = av_dict_get( s->metadata, "alpha_mode", NULL, 0)) && atoi(tag->value)) ||
- (codec->pix_fmt == AV_PIX_FMT_YUVA420P)) {
+ (par->format == AV_PIX_FMT_YUVA420P)) {
put_ebml_uint(pb, MATROSKA_ID_VIDEOALPHAMODE, 1);
}
// write DisplayWidth and DisplayHeight, they contain the size of
// a single source view and/or the display aspect ratio
if (st->sample_aspect_ratio.num) {
- int64_t d_width = av_rescale(codec->width, st->sample_aspect_ratio.num, st->sample_aspect_ratio.den);
+ int64_t d_width = av_rescale(par->width, st->sample_aspect_ratio.num, st->sample_aspect_ratio.den);
if (d_width > INT_MAX) {
av_log(s, AV_LOG_ERROR, "Overflow in display width\n");
return AVERROR(EINVAL);
}
put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH , d_width / display_width_div);
- put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYHEIGHT, codec->height / display_height_div);
+ put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYHEIGHT, par->height / display_height_div);
} else if (display_width_div != 1 || display_height_div != 1) {
- put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH , codec->width / display_width_div);
- put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYHEIGHT, codec->height / display_height_div);
+ put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH , par->width / display_width_div);
+ put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYHEIGHT, par->height / display_height_div);
}
- if (codec->codec_id == AV_CODEC_ID_RAWVIDEO) {
- uint32_t color_space = av_le2ne32(codec->codec_tag);
+ if (par->codec_id == AV_CODEC_ID_RAWVIDEO) {
+ uint32_t color_space = av_le2ne32(par->codec_tag);
put_ebml_binary(pb, MATROSKA_ID_VIDEOCOLORSPACE, &color_space, sizeof(color_space));
}
if (s->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
- mkv_write_video_color(pb, codec, st);
+ mkv_write_video_color(pb, par, st);
}
end_ebml_master(pb, subinfo);
break;
@@ -1092,7 +1092,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
put_ebml_string(pb, MATROSKA_ID_CODECID, "A_MS/ACM");
subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKAUDIO, 0);
- put_ebml_uint (pb, MATROSKA_ID_AUDIOCHANNELS , codec->channels);
+ put_ebml_uint (pb, MATROSKA_ID_AUDIOCHANNELS , par->channels);
put_ebml_float (pb, MATROSKA_ID_AUDIOSAMPLINGFREQ, sample_rate);
if (output_sample_rate)
put_ebml_float(pb, MATROSKA_ID_AUDIOOUTSAMPLINGFREQ, output_sample_rate);
@@ -1103,11 +1103,11 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
case AVMEDIA_TYPE_SUBTITLE:
if (!native_id) {
- av_log(s, AV_LOG_ERROR, "Subtitle codec %d is not supported.\n", codec->codec_id);
+ av_log(s, AV_LOG_ERROR, "Subtitle codec %d is not supported.\n", par->codec_id);
return AVERROR(ENOSYS);
}
- if (mkv->mode != MODE_WEBM || codec->codec_id != AV_CODEC_ID_WEBVTT)
+ if (mkv->mode != MODE_WEBM || par->codec_id != AV_CODEC_ID_WEBVTT)
native_id = MATROSKA_TRACK_TYPE_SUBTITLE;
put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, native_id);
@@ -1117,8 +1117,8 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
return AVERROR(EINVAL);
}
- if (mkv->mode != MODE_WEBM || codec->codec_id != AV_CODEC_ID_WEBVTT) {
- ret = mkv_write_codecprivate(s, pb, codec, native_id, qt_id);
+ if (mkv->mode != MODE_WEBM || par->codec_id != AV_CODEC_ID_WEBVTT) {
+ ret = mkv_write_codecprivate(s, pb, par, native_id, qt_id);
if (ret < 0)
return ret;
}
@@ -1383,7 +1383,7 @@ static int mkv_write_attachments(AVFormatContext *s)
const char *mimetype = NULL;
uint64_t fileuid;
- if (st->codec->codec_type != AVMEDIA_TYPE_ATTACHMENT)
+ if (st->codecpar->codec_type != AVMEDIA_TYPE_ATTACHMENT)
continue;
attached_file = start_ebml_master(pb, MATROSKA_ID_ATTACHEDFILE, 0);
@@ -1397,15 +1397,15 @@ static int mkv_write_attachments(AVFormatContext *s)
put_ebml_string(pb, MATROSKA_ID_FILENAME, t->value);
if (t = av_dict_get(st->metadata, "mimetype", NULL, 0))
mimetype = t->value;
- else if (st->codec->codec_id != AV_CODEC_ID_NONE ) {
+ else if (st->codecpar->codec_id != AV_CODEC_ID_NONE ) {
int i;
for (i = 0; ff_mkv_mime_tags[i].id != AV_CODEC_ID_NONE; i++)
- if (ff_mkv_mime_tags[i].id == st->codec->codec_id) {
+ if (ff_mkv_mime_tags[i].id == st->codecpar->codec_id) {
mimetype = ff_mkv_mime_tags[i].str;
break;
}
for (i = 0; ff_mkv_image_mime_tags[i].id != AV_CODEC_ID_NONE; i++)
- if (ff_mkv_image_mime_tags[i].id == st->codec->codec_id) {
+ if (ff_mkv_image_mime_tags[i].id == st->codecpar->codec_id) {
mimetype = ff_mkv_image_mime_tags[i].str;
break;
}
@@ -1422,7 +1422,7 @@ static int mkv_write_attachments(AVFormatContext *s)
if (!sha)
return AVERROR(ENOMEM);
av_sha_init(sha, 160);
- av_sha_update(sha, st->codec->extradata, st->codec->extradata_size);
+ av_sha_update(sha, st->codecpar->extradata, st->codecpar->extradata_size);
av_sha_final(sha, digest);
av_free(sha);
fileuid = AV_RL64(digest);
@@ -1433,7 +1433,7 @@ static int mkv_write_attachments(AVFormatContext *s)
fileuid, i);
put_ebml_string(pb, MATROSKA_ID_FILEMIMETYPE, mimetype);
- put_ebml_binary(pb, MATROSKA_ID_FILEDATA, st->codec->extradata, st->codec->extradata_size);
+ put_ebml_binary(pb, MATROSKA_ID_FILEDATA, st->codecpar->extradata, st->codecpar->extradata_size);
put_ebml_uint(pb, MATROSKA_ID_FILEUID, fileuid);
end_ebml_master(pb, attached_file);
}
@@ -1462,18 +1462,18 @@ static int mkv_write_header(AVFormatContext *s)
version = 4;
for (i = 0; i < s->nb_streams; i++) {
- if (s->streams[i]->codec->codec_id == AV_CODEC_ID_ATRAC3 ||
- s->streams[i]->codec->codec_id == AV_CODEC_ID_COOK ||
- s->streams[i]->codec->codec_id == AV_CODEC_ID_RA_288 ||
- s->streams[i]->codec->codec_id == AV_CODEC_ID_SIPR ||
- s->streams[i]->codec->codec_id == AV_CODEC_ID_RV10 ||
- s->streams[i]->codec->codec_id == AV_CODEC_ID_RV20) {
+ if (s->streams[i]->codecpar->codec_id == AV_CODEC_ID_ATRAC3 ||
+ s->streams[i]->codecpar->codec_id == AV_CODEC_ID_COOK ||
+ s->streams[i]->codecpar->codec_id == AV_CODEC_ID_RA_288 ||
+ s->streams[i]->codecpar->codec_id == AV_CODEC_ID_SIPR ||
+ s->streams[i]->codecpar->codec_id == AV_CODEC_ID_RV10 ||
+ s->streams[i]->codecpar->codec_id == AV_CODEC_ID_RV20) {
av_log(s, AV_LOG_ERROR,
"The Matroska muxer does not yet support muxing %s\n",
- avcodec_get_name(s->streams[i]->codec->codec_id));
+ avcodec_get_name(s->streams[i]->codecpar->codec_id));
return AVERROR_PATCHWELCOME;
}
- if (s->streams[i]->codec->codec_id == AV_CODEC_ID_OPUS ||
+ if (s->streams[i]->codecpar->codec_id == AV_CODEC_ID_OPUS ||
av_dict_get(s->streams[i]->metadata, "stereo_mode", NULL, 0) ||
av_dict_get(s->streams[i]->metadata, "alpha_mode", NULL, 0))
version = 4;
@@ -1684,7 +1684,7 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
unsigned int blockid, AVPacket *pkt, int keyframe)
{
MatroskaMuxContext *mkv = s->priv_data;
- AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
+ AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
uint8_t *data = NULL, *side_data = NULL;
int offset = 0, size = pkt->size, side_data_size = 0;
int64_t ts = mkv->tracks[pkt->stream_index].write_dts ? pkt->dts : pkt->pts;
@@ -1697,14 +1697,14 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
"pts %" PRId64 ", dts %" PRId64 ", duration %" PRId64 ", keyframe %d\n",
avio_tell(pb), pkt->size, pkt->pts, pkt->dts, pkt->duration,
keyframe != 0);
- if (codec->codec_id == AV_CODEC_ID_H264 && codec->extradata_size > 0 &&
- (AV_RB24(codec->extradata) == 1 || AV_RB32(codec->extradata) == 1))
+ if (par->codec_id == AV_CODEC_ID_H264 && par->extradata_size > 0 &&
+ (AV_RB24(par->extradata) == 1 || AV_RB32(par->extradata) == 1))
ff_avc_parse_nal_units_buf(pkt->data, &data, &size);
- else if (codec->codec_id == AV_CODEC_ID_HEVC && codec->extradata_size > 6 &&
- (AV_RB24(codec->extradata) == 1 || AV_RB32(codec->extradata) == 1))
+ else if (par->codec_id == AV_CODEC_ID_HEVC && par->extradata_size > 6 &&
+ (AV_RB24(par->extradata) == 1 || AV_RB32(par->extradata) == 1))
/* extradata is Annex B, assume the bitstream is too and convert it */
ff_hevc_annexb2mp4_buf(pkt->data, &data, &size, 0, NULL);
- else if (codec->codec_id == AV_CODEC_ID_WAVPACK) {
+ else if (par->codec_id == AV_CODEC_ID_WAVPACK) {
int ret = mkv_strip_wavpack(pkt->data, &data, &size);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Error stripping a WavPack packet.\n");
@@ -1713,7 +1713,7 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
} else
data = pkt->data;
- if (codec->codec_id == AV_CODEC_ID_PRORES && size >= 8) {
+ if (par->codec_id == AV_CODEC_ID_PRORES && size >= 8) {
/* Matroska specification requires to remove the first QuickTime atom
*/
size -= 8;
@@ -1726,7 +1726,7 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
if (side_data && side_data_size >= 10) {
discard_padding = av_rescale_q(AV_RL32(side_data + 4),
- (AVRational){1, codec->sample_rate},
+ (AVRational){1, par->sample_rate},
(AVRational){1, 1000000000});
}
@@ -1858,7 +1858,7 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt, int add_
{
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *pb = s->pb;
- AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
+ AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
int keyframe = !!(pkt->flags & AV_PKT_FLAG_KEY);
int duration = pkt->duration;
int ret;
@@ -1900,14 +1900,14 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt, int add_
relative_packet_pos = avio_tell(s->pb) - mkv->cluster.pos;
- if (codec->codec_type != AVMEDIA_TYPE_SUBTITLE) {
+ if (par->codec_type != AVMEDIA_TYPE_SUBTITLE) {
mkv_write_block(s, pb, MATROSKA_ID_SIMPLEBLOCK, pkt, keyframe);
- if (s->pb->seekable && (codec->codec_type == AVMEDIA_TYPE_VIDEO && keyframe || add_cue)) {
+ if (s->pb->seekable && (par->codec_type == AVMEDIA_TYPE_VIDEO && keyframe || add_cue)) {
ret = mkv_add_cuepoint(mkv->cues, pkt->stream_index, dash_tracknum, ts, mkv->cluster_pos, relative_packet_pos, -1);
if (ret < 0) return ret;
}
} else {
- if (codec->codec_id == AV_CODEC_ID_WEBVTT) {
+ if (par->codec_id == AV_CODEC_ID_WEBVTT) {
duration = mkv_write_vtt_blocks(s, pb, pkt);
} else {
ebml_master blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP,
@@ -1947,7 +1947,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
{
MatroskaMuxContext *mkv = s->priv_data;
- int codec_type = s->streams[pkt->stream_index]->codec->codec_type;
+ int codec_type = s->streams[pkt->stream_index]->codecpar->codec_type;
int keyframe = !!(pkt->flags & AV_PKT_FLAG_KEY);
int cluster_size;
int64_t cluster_time;
@@ -2183,10 +2183,10 @@ static int mkv_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
int ret = 1;
AVStream *st = s->streams[pkt->stream_index];
- if (st->codec->codec_id == AV_CODEC_ID_AAC) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
if (pkt->size > 2 && (AV_RB16(pkt->data) & 0xfff0) == 0xfff0)
ret = ff_stream_add_bitstream_filter(st, "aac_adtstoasc", NULL);
- } else if (st->codec->codec_id == AV_CODEC_ID_VP9) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_VP9) {
ret = ff_stream_add_bitstream_filter(st, "vp9_superframe", NULL);
}
diff --git a/libavformat/mgsts.c b/libavformat/mgsts.c
index 8cbc9521d6..0720de8d86 100644
--- a/libavformat/mgsts.c
+++ b/libavformat/mgsts.c
@@ -55,13 +55,13 @@ static int read_header(AVFormatContext *s)
st->nb_frames =
st->duration = avio_rb32(pb);
fps = av_d2q(av_int2float(avio_rb32(pb)), INT_MAX);
- st->codec->width = avio_rb32(pb);
- st->codec->height = avio_rb32(pb);
+ st->codecpar->width = avio_rb32(pb);
+ st->codecpar->height = avio_rb32(pb);
avio_skip(pb, 12);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_tag = avio_rb32(pb);
- st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags,
- st->codec->codec_tag);
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_tag = avio_rb32(pb);
+ st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags,
+ st->codecpar->codec_tag);
avpriv_set_pts_info(st, 64, fps.den, fps.num);
avio_skip(pb, 20);
diff --git a/libavformat/microdvddec.c b/libavformat/microdvddec.c
index 727ff947e7..c2f1ac45cd 100644
--- a/libavformat/microdvddec.c
+++ b/libavformat/microdvddec.c
@@ -114,11 +114,11 @@ static int microdvd_read_header(AVFormatContext *s)
has_real_fps = 1;
continue;
}
- if (!st->codec->extradata && sscanf(line, "{DEFAULT}{}%c", &c) == 1) {
- st->codec->extradata = av_strdup(line + 11);
- if (!st->codec->extradata)
+ if (!st->codecpar->extradata && sscanf(line, "{DEFAULT}{}%c", &c) == 1) {
+ st->codecpar->extradata = av_strdup(line + 11);
+ if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
- st->codec->extradata_size = strlen(st->codec->extradata) + 1;
+ st->codecpar->extradata_size = strlen(st->codecpar->extradata) + 1;
continue;
}
}
@@ -150,8 +150,8 @@ static int microdvd_read_header(AVFormatContext *s)
pts_info = microdvd->frame_rate;
}
avpriv_set_pts_info(st, 64, pts_info.den, pts_info.num);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_MICRODVD;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_MICRODVD;
return 0;
}
diff --git a/libavformat/microdvdenc.c b/libavformat/microdvdenc.c
index 4d8438437b..04f475b645 100644
--- a/libavformat/microdvdenc.c
+++ b/libavformat/microdvdenc.c
@@ -25,21 +25,21 @@
static int microdvd_write_header(struct AVFormatContext *s)
{
- AVCodecContext *avctx = s->streams[0]->codec;
- AVRational tb = avctx->time_base;
+ AVCodecParameters *par = s->streams[0]->codecpar;
+ AVRational framerate = s->streams[0]->avg_frame_rate;
- if (s->nb_streams != 1 || avctx->codec_id != AV_CODEC_ID_MICRODVD) {
+ if (s->nb_streams != 1 || par->codec_id != AV_CODEC_ID_MICRODVD) {
av_log(s, AV_LOG_ERROR, "Exactly one MicroDVD stream is needed.\n");
return -1;
}
- if (avctx->extradata && avctx->extradata_size > 0) {
+ if (par->extradata && par->extradata_size > 0) {
avio_write(s->pb, "{DEFAULT}{}", 11);
- avio_write(s->pb, avctx->extradata, avctx->extradata_size);
+ avio_write(s->pb, par->extradata, par->extradata_size);
avio_flush(s->pb);
}
- avpriv_set_pts_info(s->streams[0], 64, tb.num, tb.den);
+ avpriv_set_pts_info(s->streams[0], 64, framerate.num, framerate.den);
return 0;
}
diff --git a/libavformat/mlvdec.c b/libavformat/mlvdec.c
index 288b2a1010..665b28d4f8 100644
--- a/libavformat/mlvdec.c
+++ b/libavformat/mlvdec.c
@@ -130,32 +130,32 @@ static int scan_file(AVFormatContext *avctx, AVStream *vst, AVStream *ast, int f
break;
size -= 16;
if (vst && type == MKTAG('R','A','W','I') && size >= 164) {
- vst->codec->width = avio_rl16(pb);
- vst->codec->height = avio_rl16(pb);
- ret = av_image_check_size(vst->codec->width, vst->codec->height, 0, avctx);
+ vst->codecpar->width = avio_rl16(pb);
+ vst->codecpar->height = avio_rl16(pb);
+ ret = av_image_check_size(vst->codecpar->width, vst->codecpar->height, 0, avctx);
if (ret < 0)
return ret;
if (avio_rl32(pb) != 1)
avpriv_request_sample(avctx, "raw api version");
avio_skip(pb, 20); // pointer, width, height, pitch, frame_size
- vst->codec->bits_per_coded_sample = avio_rl32(pb);
- if (vst->codec->bits_per_coded_sample < 0 ||
- vst->codec->bits_per_coded_sample > (INT_MAX - 7) / (vst->codec->width * vst->codec->height)) {
+ vst->codecpar->bits_per_coded_sample = avio_rl32(pb);
+ if (vst->codecpar->bits_per_coded_sample < 0 ||
+ vst->codecpar->bits_per_coded_sample > (INT_MAX - 7) / (vst->codecpar->width * vst->codecpar->height)) {
av_log(avctx, AV_LOG_ERROR,
"invalid bits_per_coded_sample %d (size: %dx%d)\n",
- vst->codec->bits_per_coded_sample,
- vst->codec->width, vst->codec->height);
+ vst->codecpar->bits_per_coded_sample,
+ vst->codecpar->width, vst->codecpar->height);
return AVERROR_INVALIDDATA;
}
avio_skip(pb, 8 + 16 + 24); // black_level, white_level, xywh, active_area, exposure_bias
if (avio_rl32(pb) != 0x2010100) /* RGGB */
avpriv_request_sample(avctx, "cfa_pattern");
avio_skip(pb, 80); // calibration_illuminant1, color_matrix1, dynamic_range
- vst->codec->pix_fmt = AV_PIX_FMT_BAYER_RGGB16LE;
- vst->codec->codec_tag = MKTAG('B', 'I', 'T', 16);
+ vst->codecpar->format = AV_PIX_FMT_BAYER_RGGB16LE;
+ vst->codecpar->codec_tag = MKTAG('B', 'I', 'T', 16);
size -= 164;
} else if (ast && type == MKTAG('W', 'A', 'V', 'I') && size >= 16) {
- ret = ff_get_wav_header(avctx, pb, ast->codec, 16, 0);
+ ret = ff_get_wav_header(avctx, pb, ast->codecpar, 16, 0);
if (ret < 0)
return ret;
size -= 16;
@@ -286,23 +286,23 @@ static int read_header(AVFormatContext *avctx)
vst->nb_frames = nb_video_frames;
if ((mlv->class[0] & (MLV_CLASS_FLAG_DELTA|MLV_CLASS_FLAG_LZMA)))
avpriv_request_sample(avctx, "compression");
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
switch (mlv->class[0] & ~(MLV_CLASS_FLAG_DELTA|MLV_CLASS_FLAG_LZMA)) {
case MLV_VIDEO_CLASS_RAW:
- vst->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
+ vst->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
break;
case MLV_VIDEO_CLASS_YUV:
- vst->codec->pix_fmt = AV_PIX_FMT_YUV420P;
- vst->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
- vst->codec->codec_tag = 0;
+ vst->codecpar->format = AV_PIX_FMT_YUV420P;
+ vst->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
+ vst->codecpar->codec_tag = 0;
break;
case MLV_VIDEO_CLASS_JPEG:
- vst->codec->codec_id = AV_CODEC_ID_MJPEG;
- vst->codec->codec_tag = 0;
+ vst->codecpar->codec_id = AV_CODEC_ID_MJPEG;
+ vst->codecpar->codec_tag = 0;
break;
case MLV_VIDEO_CLASS_H264:
- vst->codec->codec_id = AV_CODEC_ID_H264;
- vst->codec->codec_tag = 0;
+ vst->codecpar->codec_id = AV_CODEC_ID_H264;
+ vst->codecpar->codec_tag = 0;
break;
default:
avpriv_request_sample(avctx, "unknown video class");
@@ -320,8 +320,8 @@ static int read_header(AVFormatContext *avctx)
if ((mlv->class[1] & ~MLV_CLASS_FLAG_LZMA) != MLV_AUDIO_CLASS_WAV)
avpriv_request_sample(avctx, "unknown audio class");
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- avpriv_set_pts_info(ast, 33, 1, ast->codec->sample_rate);
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ avpriv_set_pts_info(ast, 33, 1, ast->codecpar->sample_rate);
}
if (vst) {
@@ -413,15 +413,15 @@ static int read_packet(AVFormatContext *avctx, AVPacket *pkt)
if (size < 16)
return AVERROR_INVALIDDATA;
avio_skip(pb, 12); //timestamp, frameNumber
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
avio_skip(pb, 8); // cropPosX, cropPosY, panPosX, panPosY
space = avio_rl32(pb);
avio_skip(pb, space);
if ((mlv->class[st->id] & (MLV_CLASS_FLAG_DELTA|MLV_CLASS_FLAG_LZMA))) {
ret = AVERROR_PATCHWELCOME;
- } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- ret = av_get_packet(pb, pkt, (st->codec->width * st->codec->height * st->codec->bits_per_coded_sample + 7) >> 3);
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+ ret = av_get_packet(pb, pkt, (st->codecpar->width * st->codecpar->height * st->codecpar->bits_per_coded_sample + 7) >> 3);
} else { // AVMEDIA_TYPE_AUDIO
if (space > UINT_MAX - 24 || size < (24 + space))
return AVERROR_INVALIDDATA;
diff --git a/libavformat/mm.c b/libavformat/mm.c
index 81ae1a510e..8a1382e03c 100644
--- a/libavformat/mm.c
+++ b/libavformat/mm.c
@@ -109,11 +109,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_MMVIDEO;
- 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_MMVIDEO;
+ st->codecpar->codec_tag = 0; /* no fourcc */
+ st->codecpar->width = width;
+ st->codecpar->height = height;
avpriv_set_pts_info(st, 64, 1, frame_rate);
/* audio stream */
@@ -121,12 +121,12 @@ static int 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_PCM_U8;
- st->codec->channels = 1;
- st->codec->channel_layout = AV_CH_LAYOUT_MONO;
- st->codec->sample_rate = 8000;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_tag = 0; /* no fourcc */
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
+ st->codecpar->channels = 1;
+ st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+ st->codecpar->sample_rate = 8000;
avpriv_set_pts_info(st, 64, 1, 8000); /* 8000 hz */
}
diff --git a/libavformat/mmf.c b/libavformat/mmf.c
index c2acec91eb..b8a9cad32e 100644
--- a/libavformat/mmf.c
+++ b/libavformat/mmf.c
@@ -73,14 +73,14 @@ static int mmf_write_header(AVFormatContext *s)
"VN:Lavf," :
"VN:"LIBAVFORMAT_IDENT",";
- rate = mmf_rate_code(s->streams[0]->codec->sample_rate);
+ rate = mmf_rate_code(s->streams[0]->codecpar->sample_rate);
if (rate < 0) {
av_log(s, AV_LOG_ERROR, "Unsupported sample rate %d, supported are 4000, 8000, 11025, 22050 and 44100\n",
- s->streams[0]->codec->sample_rate);
+ s->streams[0]->codecpar->sample_rate);
return AVERROR(EINVAL);
}
- mmf->stereo = s->streams[0]->codec->channels > 1;
+ mmf->stereo = s->streams[0]->codecpar->channels > 1;
if (mmf->stereo &&
s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
av_log(s, AV_LOG_ERROR, "Yamaha SMAF stereo is experimental, "
@@ -121,7 +121,7 @@ static int mmf_write_header(AVFormatContext *s)
mmf->awapos = ff_start_tag(pb, "Awa\x01");
- 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);
avio_flush(pb);
@@ -162,7 +162,7 @@ static int mmf_write_trailer(AVFormatContext *s)
/* "play wav" */
avio_w8(pb, 0); /* start time */
avio_w8(pb, (mmf->stereo << 6) | 1); /* (channel << 6) | wavenum */
- gatetime = size * 500 / s->streams[0]->codec->sample_rate;
+ gatetime = size * 500 / s->streams[0]->codecpar->sample_rate;
put_varlength(pb, gatetime); /* duration */
/* "nop" */
@@ -262,16 +262,16 @@ static int mmf_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_ADPCM_YAMAHA;
- st->codec->sample_rate = rate;
- st->codec->channels = (params >> 7) + 1;
- st->codec->channel_layout = params >> 7 ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
- st->codec->bits_per_coded_sample = 4;
- st->codec->bit_rate = st->codec->sample_rate *
- st->codec->bits_per_coded_sample;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_YAMAHA;
+ st->codecpar->sample_rate = rate;
+ st->codecpar->channels = (params >> 7) + 1;
+ st->codecpar->channel_layout = params >> 7 ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
+ st->codecpar->bits_per_coded_sample = 4;
+ st->codecpar->bit_rate = st->codecpar->sample_rate *
+ st->codecpar->bits_per_coded_sample;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 3fa8fcc2f6..06c15fba6d 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -209,8 +209,8 @@ static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len)
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = id;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = id;
return 0;
}
@@ -660,13 +660,13 @@ static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
st = c->fc->streams[c->fc->nb_streams-1];
if (type == MKTAG('v','i','d','e'))
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
else if (type == MKTAG('s','o','u','n'))
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
else if (type == MKTAG('m','1','a',' '))
- st->codec->codec_id = AV_CODEC_ID_MP2;
+ st->codecpar->codec_id = AV_CODEC_ID_MP2;
else if ((type == MKTAG('s','u','b','p')) || (type == MKTAG('c','l','c','p')))
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
avio_rb32(pb); /* component manufacture */
avio_rb32(pb); /* component flags */
@@ -740,15 +740,19 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
bsmod = (ac3info >> 14) & 0x7;
acmod = (ac3info >> 11) & 0x7;
lfeon = (ac3info >> 10) & 0x1;
- st->codec->channels = ((int[]){2,1,2,3,3,4,4,5})[acmod] + lfeon;
- st->codec->channel_layout = avpriv_ac3_channel_layout_tab[acmod];
+ st->codecpar->channels = ((int[]){2,1,2,3,3,4,4,5})[acmod] + lfeon;
+ st->codecpar->channel_layout = avpriv_ac3_channel_layout_tab[acmod];
if (lfeon)
- st->codec->channel_layout |= AV_CH_LOW_FREQUENCY;
+ st->codecpar->channel_layout |= AV_CH_LOW_FREQUENCY;
*ast = bsmod;
- if (st->codec->channels > 1 && bsmod == 0x7)
+ if (st->codecpar->channels > 1 && bsmod == 0x7)
*ast = AV_AUDIO_SERVICE_TYPE_KARAOKE;
+#if FF_API_LAVF_AVCTX
+ FF_DISABLE_DEPRECATION_WARNINGS
st->codec->audio_service_type = *ast;
+ FF_ENABLE_DEPRECATION_WARNINGS
+#endif
return 0;
}
@@ -776,15 +780,19 @@ static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
bsmod = (eac3info >> 12) & 0x1f;
acmod = (eac3info >> 9) & 0x7;
lfeon = (eac3info >> 8) & 0x1;
- st->codec->channel_layout = avpriv_ac3_channel_layout_tab[acmod];
+ st->codecpar->channel_layout = avpriv_ac3_channel_layout_tab[acmod];
if (lfeon)
- st->codec->channel_layout |= AV_CH_LOW_FREQUENCY;
- st->codec->channels = av_get_channel_layout_nb_channels(st->codec->channel_layout);
+ st->codecpar->channel_layout |= AV_CH_LOW_FREQUENCY;
+ st->codecpar->channels = av_get_channel_layout_nb_channels(st->codecpar->channel_layout);
*ast = bsmod;
- if (st->codec->channels > 1 && bsmod == 0x7)
+ if (st->codecpar->channels > 1 && bsmod == 0x7)
*ast = AV_AUDIO_SERVICE_TYPE_KARAOKE;
+#if FF_API_LAVF_AVCTX
+ FF_DISABLE_DEPRECATION_WARNINGS
st->codec->audio_service_type = *ast;
+ FF_ENABLE_DEPRECATION_WARNINGS
+#endif
return 0;
}
@@ -814,15 +822,15 @@ static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
}
st = c->fc->streams[c->fc->nb_streams-1];
- st->codec->sample_rate = get_bits_long(&gb, 32);
+ st->codecpar->sample_rate = get_bits_long(&gb, 32);
skip_bits_long(&gb, 32); /* max bitrate */
- st->codec->bit_rate = get_bits_long(&gb, 32);
- st->codec->bits_per_coded_sample = get_bits(&gb, 8);
+ st->codecpar->bit_rate = get_bits_long(&gb, 32);
+ st->codecpar->bits_per_coded_sample = get_bits(&gb, 8);
frame_duration_code = get_bits(&gb, 2);
skip_bits(&gb, 30); /* various fields */
channel_layout_code = get_bits(&gb, 16);
- st->codec->frame_size =
+ st->codecpar->frame_size =
(frame_duration_code == 0) ? 512 :
(frame_duration_code == 1) ? 1024 :
(frame_duration_code == 2) ? 2048 :
@@ -831,7 +839,7 @@ static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (channel_layout_code > 0xff) {
av_log(c->fc, AV_LOG_WARNING, "Unsupported DTS audio channel layout");
}
- st->codec->channel_layout =
+ st->codecpar->channel_layout =
((channel_layout_code & 0x1) ? AV_CH_FRONT_CENTER : 0) |
((channel_layout_code & 0x2) ? AV_CH_FRONT_LEFT : 0) |
((channel_layout_code & 0x2) ? AV_CH_FRONT_RIGHT : 0) |
@@ -839,7 +847,7 @@ static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
((channel_layout_code & 0x4) ? AV_CH_SIDE_RIGHT : 0) |
((channel_layout_code & 0x8) ? AV_CH_LOW_FREQUENCY : 0);
- st->codec->channels = av_get_channel_layout_nb_channels(st->codec->channel_layout);
+ st->codecpar->channels = av_get_channel_layout_nb_channels(st->codecpar->channel_layout);
return 0;
}
@@ -872,7 +880,7 @@ static int mov_read_wfex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
- if ((ret = ff_get_wav_header(c->fc, pb, st->codec, atom.size, 0)) < 0)
+ if ((ret = ff_get_wav_header(c->fc, pb, st->codecpar, atom.size, 0)) < 0)
av_log(c->fc, AV_LOG_WARNING, "get_wav_header failed\n");
return ret;
@@ -1217,18 +1225,18 @@ static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom)
little_endian = avio_rb16(pb) & 0xFF;
av_log(c->fc, AV_LOG_TRACE, "enda %d\n", little_endian);
if (little_endian == 1) {
- switch (st->codec->codec_id) {
+ switch (st->codecpar->codec_id) {
case AV_CODEC_ID_PCM_S24BE:
- st->codec->codec_id = AV_CODEC_ID_PCM_S24LE;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE;
break;
case AV_CODEC_ID_PCM_S32BE:
- st->codec->codec_id = AV_CODEC_ID_PCM_S32LE;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE;
break;
case AV_CODEC_ID_PCM_F32BE:
- st->codec->codec_id = AV_CODEC_ID_PCM_F32LE;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE;
break;
case AV_CODEC_ID_PCM_F64BE:
- st->codec->codec_id = AV_CODEC_ID_PCM_F64LE;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_F64LE;
break;
default:
break;
@@ -1270,9 +1278,9 @@ static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
uint8_t color_range = avio_r8(pb) >> 7;
av_log(c->fc, AV_LOG_TRACE, " full %"PRIu8"", color_range);
if (color_range)
- st->codec->color_range = AVCOL_RANGE_JPEG;
+ st->codecpar->color_range = AVCOL_RANGE_JPEG;
else
- st->codec->color_range = AVCOL_RANGE_MPEG;
+ st->codecpar->color_range = AVCOL_RANGE_MPEG;
/* 14496-12 references JPEG XR specs (rather than the more complete
* 23001-8) so some adjusting is required */
if (color_primaries >= AVCOL_PRI_FILM)
@@ -1283,26 +1291,26 @@ static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
color_trc = AVCOL_TRC_UNSPECIFIED;
if (color_matrix >= AVCOL_SPC_BT2020_NCL)
color_matrix = AVCOL_SPC_UNSPECIFIED;
- st->codec->color_primaries = color_primaries;
- st->codec->color_trc = color_trc;
- st->codec->colorspace = color_matrix;
+ st->codecpar->color_primaries = color_primaries;
+ st->codecpar->color_trc = color_trc;
+ st->codecpar->color_space = color_matrix;
} else if (!strncmp(color_parameter_type, "nclc", 4)) {
/* color primaries, Table 4-4 */
switch (color_primaries) {
- case 1: st->codec->color_primaries = AVCOL_PRI_BT709; break;
- case 5: st->codec->color_primaries = AVCOL_PRI_SMPTE170M; break;
- case 6: st->codec->color_primaries = AVCOL_PRI_SMPTE240M; break;
+ case 1: st->codecpar->color_primaries = AVCOL_PRI_BT709; break;
+ case 5: st->codecpar->color_primaries = AVCOL_PRI_SMPTE170M; break;
+ case 6: st->codecpar->color_primaries = AVCOL_PRI_SMPTE240M; break;
}
/* color transfer, Table 4-5 */
switch (color_trc) {
- case 1: st->codec->color_trc = AVCOL_TRC_BT709; break;
- case 7: st->codec->color_trc = AVCOL_TRC_SMPTE240M; break;
+ case 1: st->codecpar->color_trc = AVCOL_TRC_BT709; break;
+ case 7: st->codecpar->color_trc = AVCOL_TRC_SMPTE240M; break;
}
/* color matrix, Table 4-6 */
switch (color_matrix) {
- case 1: st->codec->colorspace = AVCOL_SPC_BT709; break;
- case 6: st->codec->colorspace = AVCOL_SPC_BT470BG; break;
- case 7: st->codec->colorspace = AVCOL_SPC_SMPTE240M; break;
+ case 1: st->codecpar->color_space = AVCOL_SPC_BT709; break;
+ case 6: st->codecpar->color_space = AVCOL_SPC_BT470BG; break;
+ case 7: st->codecpar->color_space = AVCOL_SPC_SMPTE240M; break;
}
}
av_log(c->fc, AV_LOG_TRACE, "\n");
@@ -1339,28 +1347,28 @@ static int mov_read_fiel(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (decoded_field_order == AV_FIELD_UNKNOWN && mov_field_order) {
av_log(NULL, AV_LOG_ERROR, "Unknown MOV field order 0x%04x\n", mov_field_order);
}
- st->codec->field_order = decoded_field_order;
+ st->codecpar->field_order = decoded_field_order;
return 0;
}
-static int mov_realloc_extradata(AVCodecContext *codec, MOVAtom atom)
+static int mov_realloc_extradata(AVCodecParameters *par, MOVAtom atom)
{
int err = 0;
- uint64_t size = (uint64_t)codec->extradata_size + atom.size + 8 + AV_INPUT_BUFFER_PADDING_SIZE;
+ uint64_t size = (uint64_t)par->extradata_size + atom.size + 8 + AV_INPUT_BUFFER_PADDING_SIZE;
if (size > INT_MAX || (uint64_t)atom.size > INT_MAX)
return AVERROR_INVALIDDATA;
- if ((err = av_reallocp(&codec->extradata, size)) < 0) {
- codec->extradata_size = 0;
+ if ((err = av_reallocp(&par->extradata, size)) < 0) {
+ par->extradata_size = 0;
return err;
}
- codec->extradata_size = size - AV_INPUT_BUFFER_PADDING_SIZE;
+ par->extradata_size = size - AV_INPUT_BUFFER_PADDING_SIZE;
return 0;
}
/* Read a whole atom into the extradata return the size of the atom read, possibly truncated if != atom.size */
static int64_t mov_read_atom_into_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom,
- AVCodecContext *codec, uint8_t *buf)
+ AVCodecParameters *par, uint8_t *buf)
{
int64_t result = atom.size;
int err;
@@ -1369,11 +1377,11 @@ static int64_t mov_read_atom_into_extradata(MOVContext *c, AVIOContext *pb, MOVA
AV_WL32(buf + 4, atom.type);
err = ffio_read_size(pb, buf + 8, atom.size);
if (err < 0) {
- codec->extradata_size -= atom.size;
+ par->extradata_size -= atom.size;
return err;
} else if (err < atom.size) {
av_log(c->fc, AV_LOG_WARNING, "truncated extradata\n");
- codec->extradata_size -= atom.size - err;
+ par->extradata_size -= atom.size - err;
result = err;
}
memset(buf + 8 + err, 0, AV_INPUT_BUFFER_PADDING_SIZE);
@@ -1392,15 +1400,15 @@ static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom,
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
- if (st->codec->codec_id != codec_id)
+ if (st->codecpar->codec_id != codec_id)
return 0; /* unexpected codec_id - don't mess with extradata */
- original_size = st->codec->extradata_size;
- err = mov_realloc_extradata(st->codec, atom);
+ original_size = st->codecpar->extradata_size;
+ err = mov_realloc_extradata(st->codecpar, atom);
if (err)
return err;
- err = mov_read_atom_into_extradata(c, pb, atom, st->codec, st->codec->extradata + original_size);
+ err = mov_read_atom_into_extradata(c, pb, atom, st->codecpar, st->codecpar->extradata + original_size);
if (err < 0)
return err;
return 0; // Note: this is the original behavior to ignore truncation.
@@ -1440,10 +1448,10 @@ static int mov_read_targa_y216(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int ret = mov_read_extradata(c, pb, atom, AV_CODEC_ID_TARGA_Y216);
if (!ret && c->fc->nb_streams >= 1) {
- AVCodecContext *avctx = c->fc->streams[c->fc->nb_streams-1]->codec;
- if (avctx->extradata_size >= 40) {
- avctx->height = AV_RB16(&avctx->extradata[36]);
- avctx->width = AV_RB16(&avctx->extradata[38]);
+ AVCodecParameters *par = c->fc->streams[c->fc->nb_streams-1]->codecpar;
+ if (par->extradata_size >= 40) {
+ par->height = AV_RB16(&par->extradata[36]);
+ par->width = AV_RB16(&par->extradata[38]);
}
}
return ret;
@@ -1452,16 +1460,16 @@ static int mov_read_targa_y216(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_ares(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
if (c->fc->nb_streams >= 1) {
- AVCodecContext *codec = c->fc->streams[c->fc->nb_streams-1]->codec;
- if (codec->codec_tag == MKTAG('A', 'V', 'i', 'n') &&
- codec->codec_id == AV_CODEC_ID_H264 &&
+ AVCodecParameters *par = c->fc->streams[c->fc->nb_streams-1]->codecpar;
+ if (par->codec_tag == MKTAG('A', 'V', 'i', 'n') &&
+ par->codec_id == AV_CODEC_ID_H264 &&
atom.size > 11) {
avio_skip(pb, 10);
/* For AVID AVCI50, force width of 1440 to be able to select the correct SPS and PPS */
if (avio_rb16(pb) == 0xd4d)
- codec->width = 1440;
+ par->width = 1440;
return 0;
- } else if (codec->codec_tag == MKTAG('A', 'V', 'd', '1') &&
+ } else if (par->codec_tag == MKTAG('A', 'V', 'd', '1') &&
atom.size >= 24) {
int num, den;
avio_skip(pb, 12);
@@ -1492,28 +1500,28 @@ static int mov_read_aclr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int length = 0;
uint64_t original_size;
if (c->fc->nb_streams >= 1) {
- AVCodecContext *codec = c->fc->streams[c->fc->nb_streams-1]->codec;
- if (codec->codec_id == AV_CODEC_ID_H264)
+ AVCodecParameters *par = c->fc->streams[c->fc->nb_streams-1]->codecpar;
+ if (par->codec_id == AV_CODEC_ID_H264)
return 0;
if (atom.size == 16) {
- original_size = codec->extradata_size;
- ret = mov_realloc_extradata(codec, atom);
+ original_size = par->extradata_size;
+ ret = mov_realloc_extradata(par, atom);
if (!ret) {
- length = mov_read_atom_into_extradata(c, pb, atom, codec, codec->extradata + original_size);
+ length = mov_read_atom_into_extradata(c, pb, atom, par, par->extradata + original_size);
if (length == atom.size) {
- const uint8_t range_value = codec->extradata[original_size + 19];
+ const uint8_t range_value = par->extradata[original_size + 19];
switch (range_value) {
case 1:
- codec->color_range = AVCOL_RANGE_MPEG;
+ par->color_range = AVCOL_RANGE_MPEG;
break;
case 2:
- codec->color_range = AVCOL_RANGE_JPEG;
+ par->color_range = AVCOL_RANGE_JPEG;
break;
default:
av_log(c, AV_LOG_WARNING, "ignored unknown aclr value (%d)\n", range_value);
break;
}
- ff_dlog(c, "color_range: %d\n", codec->color_range);
+ ff_dlog(c, "color_range: %d\n", par->color_range);
} else {
/* For some reason the whole atom was not added to the extradata */
av_log(c, AV_LOG_ERROR, "aclr not decoded - incomplete atom\n");
@@ -1546,16 +1554,16 @@ static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if ((uint64_t)atom.size > (1<<30))
return AVERROR_INVALIDDATA;
- if (st->codec->codec_id == AV_CODEC_ID_QDM2 ||
- st->codec->codec_id == AV_CODEC_ID_QDMC ||
- st->codec->codec_id == AV_CODEC_ID_SPEEX) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_QDM2 ||
+ st->codecpar->codec_id == AV_CODEC_ID_QDMC ||
+ st->codecpar->codec_id == AV_CODEC_ID_SPEEX) {
// pass all frma atom to codec, needed at least for QDMC and QDM2
- av_freep(&st->codec->extradata);
- ret = ff_get_extradata(st->codec, pb, atom.size);
+ av_freep(&st->codecpar->extradata);
+ ret = ff_get_extradata(st->codecpar, pb, atom.size);
if (ret < 0)
return ret;
} else if (atom.size > 8) { /* to read frma, esds atoms */
- if (st->codec->codec_id == AV_CODEC_ID_ALAC && atom.size >= 24) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_ALAC && atom.size >= 24) {
uint64_t buffer;
ret = ffio_ensure_seekback(pb, 8);
if (ret < 0)
@@ -1567,16 +1575,16 @@ static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
&& buffer >> 32 >= 8) {
avio_skip(pb, -8);
atom.size += 8;
- } else if (!st->codec->extradata_size) {
+ } else if (!st->codecpar->extradata_size) {
#define ALAC_EXTRADATA_SIZE 36
- st->codec->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
- if (!st->codec->extradata)
+ st->codecpar->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
- st->codec->extradata_size = ALAC_EXTRADATA_SIZE;
- AV_WB32(st->codec->extradata , ALAC_EXTRADATA_SIZE);
- AV_WB32(st->codec->extradata + 4, MKTAG('a','l','a','c'));
- AV_WB64(st->codec->extradata + 12, buffer);
- avio_read(pb, st->codec->extradata + 20, 16);
+ st->codecpar->extradata_size = ALAC_EXTRADATA_SIZE;
+ AV_WB32(st->codecpar->extradata , ALAC_EXTRADATA_SIZE);
+ AV_WB32(st->codecpar->extradata + 4, MKTAG('a','l','a','c'));
+ AV_WB64(st->codecpar->extradata + 12, buffer);
+ avio_read(pb, st->codecpar->extradata + 20, 16);
avio_skip(pb, atom.size - 24);
return 0;
}
@@ -1613,12 +1621,12 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (type == MKTAG('f','i','e','l') && size == atom.size)
return mov_read_default(c, pb, atom);
}
- if (st->codec->extradata_size > 1 && st->codec->extradata) {
+ if (st->codecpar->extradata_size > 1 && st->codecpar->extradata) {
av_log(c, AV_LOG_WARNING, "ignoring multiple glbl\n");
return 0;
}
- av_freep(&st->codec->extradata);
- ret = ff_get_extradata(st->codec, pb, atom.size);
+ av_freep(&st->codecpar->extradata);
+ ret = ff_get_extradata(st->codecpar, pb, atom.size);
if (ret < 0)
return ret;
@@ -1643,8 +1651,8 @@ static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
avio_seek(pb, 6, SEEK_CUR);
- av_freep(&st->codec->extradata);
- ret = ff_get_extradata(st->codec, pb, atom.size - 7);
+ av_freep(&st->codecpar->extradata);
+ ret = ff_get_extradata(st->codecpar, pb, atom.size - 7);
if (ret < 0)
return ret;
@@ -1671,8 +1679,8 @@ static int mov_read_strf(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return AVERROR_INVALIDDATA;
avio_skip(pb, 40);
- av_freep(&st->codec->extradata);
- ret = ff_get_extradata(st->codec, pb, atom.size - 40);
+ av_freep(&st->codecpar->extradata);
+ ret = ff_get_extradata(st->codecpar, pb, atom.size - 40);
if (ret < 0)
return ret;
@@ -1747,26 +1755,26 @@ static int mov_codec_id(AVStream *st, uint32_t format)
(format & 0xFFFF) == 'T' + ('S' << 8)))
id = ff_codec_get_id(ff_codec_wav_tags, av_bswap32(format) & 0xFFFF);
- if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO && id > 0) {
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- } else if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO &&
+ if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO && id > 0) {
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ } else if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO &&
/* skip old asf mpeg4 tag */
format && format != MKTAG('m','p','4','s')) {
id = ff_codec_get_id(ff_codec_movvideo_tags, format);
if (id <= 0)
id = ff_codec_get_id(ff_codec_bmp_tags, format);
if (id > 0)
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- else if (st->codec->codec_type == AVMEDIA_TYPE_DATA ||
- (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE &&
- st->codec->codec_id == AV_CODEC_ID_NONE)) {
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA ||
+ (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE &&
+ st->codecpar->codec_id == AV_CODEC_ID_NONE)) {
id = ff_codec_get_id(ff_codec_movsubtitle_tags, format);
if (id > 0)
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
}
}
- st->codec->codec_tag = format;
+ st->codecpar->codec_tag = format;
return id;
}
@@ -1788,8 +1796,8 @@ static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb,
avio_rb32(pb); /* temporal quality */
avio_rb32(pb); /* spatial quality */
- st->codec->width = avio_rb16(pb); /* width */
- st->codec->height = avio_rb16(pb); /* height */
+ st->codecpar->width = avio_rb16(pb); /* width */
+ st->codecpar->height = avio_rb16(pb); /* height */
avio_rb32(pb); /* horiz resolution */
avio_rb32(pb); /* vert resolution */
@@ -1808,21 +1816,21 @@ static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb,
/* codec_tag YV12 triggers an UV swap in rawdec.c */
if (!memcmp(codec_name, "Planar Y'CbCr 8-bit 4:2:0", 25)) {
- st->codec->codec_tag = MKTAG('I', '4', '2', '0');
- st->codec->width &= ~1;
- st->codec->height &= ~1;
+ st->codecpar->codec_tag = MKTAG('I', '4', '2', '0');
+ st->codecpar->width &= ~1;
+ st->codecpar->height &= ~1;
}
/* Flash Media Server uses tag H263 with Sorenson Spark */
- if (st->codec->codec_tag == MKTAG('H','2','6','3') &&
+ if (st->codecpar->codec_tag == MKTAG('H','2','6','3') &&
!memcmp(codec_name, "Sorenson H263", 13))
- st->codec->codec_id = AV_CODEC_ID_FLV1;
+ st->codecpar->codec_id = AV_CODEC_ID_FLV1;
- st->codec->bits_per_coded_sample = avio_rb16(pb); /* depth */
+ st->codecpar->bits_per_coded_sample = avio_rb16(pb); /* depth */
avio_seek(pb, stsd_start, SEEK_SET);
- if (ff_get_qtpalette(st->codec->codec_id, pb, sc->palette)) {
- st->codec->bits_per_coded_sample &= 0x1F;
+ if (ff_get_qtpalette(st->codecpar->codec_id, pb, sc->palette)) {
+ st->codecpar->bits_per_coded_sample &= 0x1F;
sc->has_palette = 1;
}
}
@@ -1837,14 +1845,14 @@ static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb,
avio_rb16(pb); /* revision level */
avio_rb32(pb); /* vendor */
- st->codec->channels = avio_rb16(pb); /* channel count */
- st->codec->bits_per_coded_sample = avio_rb16(pb); /* sample size */
- av_log(c->fc, AV_LOG_TRACE, "audio channels %d\n", st->codec->channels);
+ st->codecpar->channels = avio_rb16(pb); /* channel count */
+ st->codecpar->bits_per_coded_sample = avio_rb16(pb); /* sample size */
+ av_log(c->fc, AV_LOG_TRACE, "audio channels %d\n", st->codecpar->channels);
sc->audio_cid = avio_rb16(pb);
avio_rb16(pb); /* packet size = 0 */
- st->codec->sample_rate = ((avio_rb32(pb) >> 16));
+ st->codecpar->sample_rate = ((avio_rb32(pb) >> 16));
// Read QT version 1 fields. In version 0 these do not exist.
av_log(c->fc, AV_LOG_TRACE, "version =%d, isom =%d\n", version, c->isom);
@@ -1858,22 +1866,22 @@ static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb,
avio_rb32(pb); /* bytes per sample */
} else if (version == 2) {
avio_rb32(pb); /* sizeof struct only */
- st->codec->sample_rate = av_int2double(avio_rb64(pb));
- st->codec->channels = avio_rb32(pb);
+ st->codecpar->sample_rate = av_int2double(avio_rb64(pb));
+ st->codecpar->channels = avio_rb32(pb);
avio_rb32(pb); /* always 0x7F000000 */
- st->codec->bits_per_coded_sample = avio_rb32(pb);
+ st->codecpar->bits_per_coded_sample = avio_rb32(pb);
flags = avio_rb32(pb); /* lpcm format specific flag */
sc->bytes_per_frame = avio_rb32(pb);
sc->samples_per_frame = avio_rb32(pb);
- if (st->codec->codec_tag == MKTAG('l','p','c','m'))
- st->codec->codec_id =
- ff_mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample,
+ if (st->codecpar->codec_tag == MKTAG('l','p','c','m'))
+ st->codecpar->codec_id =
+ ff_mov_get_lpcm_codec_id(st->codecpar->bits_per_coded_sample,
flags);
}
if (version == 0 || (version == 1 && sc->audio_cid != -2)) {
/* can't correctly handle variable sized packet as audio unit */
- switch (st->codec->codec_id) {
+ switch (st->codecpar->codec_id) {
case AV_CODEC_ID_MP2:
case AV_CODEC_ID_MP3:
st->need_parsing = AVSTREAM_PARSE_FULL;
@@ -1883,43 +1891,43 @@ static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb,
}
if (sc->format == 0) {
- if (st->codec->bits_per_coded_sample == 8)
- st->codec->codec_id = mov_codec_id(st, MKTAG('r','a','w',' '));
- else if (st->codec->bits_per_coded_sample == 16)
- st->codec->codec_id = mov_codec_id(st, MKTAG('t','w','o','s'));
+ if (st->codecpar->bits_per_coded_sample == 8)
+ st->codecpar->codec_id = mov_codec_id(st, MKTAG('r','a','w',' '));
+ else if (st->codecpar->bits_per_coded_sample == 16)
+ st->codecpar->codec_id = mov_codec_id(st, MKTAG('t','w','o','s'));
}
- switch (st->codec->codec_id) {
+ switch (st->codecpar->codec_id) {
case AV_CODEC_ID_PCM_S8:
case AV_CODEC_ID_PCM_U8:
- if (st->codec->bits_per_coded_sample == 16)
- st->codec->codec_id = AV_CODEC_ID_PCM_S16BE;
+ if (st->codecpar->bits_per_coded_sample == 16)
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE;
break;
case AV_CODEC_ID_PCM_S16LE:
case AV_CODEC_ID_PCM_S16BE:
- if (st->codec->bits_per_coded_sample == 8)
- st->codec->codec_id = AV_CODEC_ID_PCM_S8;
- else if (st->codec->bits_per_coded_sample == 24)
- st->codec->codec_id =
- st->codec->codec_id == AV_CODEC_ID_PCM_S16BE ?
+ if (st->codecpar->bits_per_coded_sample == 8)
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S8;
+ else if (st->codecpar->bits_per_coded_sample == 24)
+ st->codecpar->codec_id =
+ st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE ?
AV_CODEC_ID_PCM_S24BE : AV_CODEC_ID_PCM_S24LE;
- else if (st->codec->bits_per_coded_sample == 32)
- st->codec->codec_id =
- st->codec->codec_id == AV_CODEC_ID_PCM_S16BE ?
+ else if (st->codecpar->bits_per_coded_sample == 32)
+ st->codecpar->codec_id =
+ st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE ?
AV_CODEC_ID_PCM_S32BE : AV_CODEC_ID_PCM_S32LE;
break;
/* set values for old format before stsd version 1 appeared */
case AV_CODEC_ID_MACE3:
sc->samples_per_frame = 6;
- sc->bytes_per_frame = 2 * st->codec->channels;
+ sc->bytes_per_frame = 2 * st->codecpar->channels;
break;
case AV_CODEC_ID_MACE6:
sc->samples_per_frame = 6;
- sc->bytes_per_frame = 1 * st->codec->channels;
+ sc->bytes_per_frame = 1 * st->codecpar->channels;
break;
case AV_CODEC_ID_ADPCM_IMA_QT:
sc->samples_per_frame = 64;
- sc->bytes_per_frame = 34 * st->codec->channels;
+ sc->bytes_per_frame = 34 * st->codecpar->channels;
break;
case AV_CODEC_ID_GSM:
sc->samples_per_frame = 160;
@@ -1929,10 +1937,10 @@ static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb,
break;
}
- bits_per_sample = av_get_bits_per_sample(st->codec->codec_id);
+ bits_per_sample = av_get_bits_per_sample(st->codecpar->codec_id);
if (bits_per_sample) {
- st->codec->bits_per_coded_sample = bits_per_sample;
- sc->sample_size = (bits_per_sample >> 3) * st->codec->channels;
+ st->codecpar->bits_per_coded_sample = bits_per_sample;
+ sc->sample_size = (bits_per_sample >> 3) * st->codecpar->channels;
}
}
@@ -1944,10 +1952,10 @@ static void mov_parse_stsd_subtitle(MOVContext *c, AVIOContext *pb,
// color, fonts, and default styles, so fake an atom to read it
MOVAtom fake_atom = { .size = size };
// mp4s contains a regular esds atom
- if (st->codec->codec_tag != AV_RL32("mp4s"))
+ if (st->codecpar->codec_tag != AV_RL32("mp4s"))
mov_read_glbl(c, pb, fake_atom);
- st->codec->width = sc->width;
- st->codec->height = sc->height;
+ st->codecpar->width = sc->width;
+ st->codecpar->height = sc->height;
}
static uint32_t yuv_to_rgba(uint32_t ycbcr)
@@ -1969,15 +1977,15 @@ static uint32_t yuv_to_rgba(uint32_t ycbcr)
static int mov_rewrite_dvd_sub_extradata(AVStream *st)
{
char buf[256] = {0};
- uint8_t *src = st->codec->extradata;
+ uint8_t *src = st->codecpar->extradata;
int i;
- if (st->codec->extradata_size != 64)
+ if (st->codecpar->extradata_size != 64)
return 0;
- if (st->codec->width > 0 && st->codec->height > 0)
+ if (st->codecpar->width > 0 && st->codecpar->height > 0)
snprintf(buf, sizeof(buf), "size: %dx%d\n",
- st->codec->width, st->codec->height);
+ st->codecpar->width, st->codecpar->height);
av_strlcat(buf, "palette: ", sizeof(buf));
for (i = 0; i < 16; i++) {
@@ -1990,13 +1998,13 @@ static int mov_rewrite_dvd_sub_extradata(AVStream *st)
if (av_strlcat(buf, "\n", sizeof(buf)) >= sizeof(buf))
return 0;
- av_freep(&st->codec->extradata);
- st->codec->extradata_size = 0;
- st->codec->extradata = av_mallocz(strlen(buf) + AV_INPUT_BUFFER_PADDING_SIZE);
- if (!st->codec->extradata)
+ av_freep(&st->codecpar->extradata);
+ st->codecpar->extradata_size = 0;
+ st->codecpar->extradata = av_mallocz(strlen(buf) + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
- st->codec->extradata_size = strlen(buf);
- memcpy(st->codec->extradata, buf, st->codec->extradata_size);
+ st->codecpar->extradata_size = strlen(buf);
+ memcpy(st->codecpar->extradata, buf, st->codecpar->extradata_size);
return 0;
}
@@ -2007,39 +2015,48 @@ static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb,
{
int ret;
- if (st->codec->codec_tag == MKTAG('t','m','c','d')) {
+ if (st->codecpar->codec_tag == MKTAG('t','m','c','d')) {
if ((int)size != size)
return AVERROR(ENOMEM);
- ret = ff_get_extradata(st->codec, pb, size);
+ ret = ff_get_extradata(st->codecpar, pb, size);
if (ret < 0)
return ret;
if (size > 16) {
MOVStreamContext *tmcd_ctx = st->priv_data;
int val;
- val = AV_RB32(st->codec->extradata + 4);
+ val = AV_RB32(st->codecpar->extradata + 4);
tmcd_ctx->tmcd_flags = val;
- if (val & 1)
- st->codec->flags2 |= AV_CODEC_FLAG2_DROP_FRAME_TIMECODE;
- st->codec->time_base.den = st->codec->extradata[16]; /* number of frame */
- st->codec->time_base.num = 1;
+ st->avg_frame_rate.num = st->codecpar->extradata[16]; /* number of frame */
+ st->avg_frame_rate.den = 1;
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+ st->codec->time_base = av_inv_q(st->avg_frame_rate);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
/* adjust for per frame dur in counter mode */
if (tmcd_ctx->tmcd_flags & 0x0008) {
- int timescale = AV_RB32(st->codec->extradata + 8);
- int framedur = AV_RB32(st->codec->extradata + 12);
+ int timescale = AV_RB32(st->codecpar->extradata + 8);
+ int framedur = AV_RB32(st->codecpar->extradata + 12);
+ st->avg_frame_rate.num *= timescale;
+ st->avg_frame_rate.den *= framedur;
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
st->codec->time_base.den *= timescale;
st->codec->time_base.num *= framedur;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
}
if (size > 30) {
- uint32_t len = AV_RB32(st->codec->extradata + 18); /* name atom length */
- uint32_t format = AV_RB32(st->codec->extradata + 22);
+ uint32_t len = AV_RB32(st->codecpar->extradata + 18); /* name atom length */
+ uint32_t format = AV_RB32(st->codecpar->extradata + 22);
if (format == AV_RB32("name") && (int64_t)size >= (int64_t)len + 18) {
- uint16_t str_size = AV_RB16(st->codec->extradata + 26); /* string length */
+ uint16_t str_size = AV_RB16(st->codecpar->extradata + 26); /* string length */
if (str_size > 0 && size >= (int)str_size + 26) {
char *reel_name = av_malloc(str_size + 1);
if (!reel_name)
return AVERROR(ENOMEM);
- memcpy(reel_name, st->codec->extradata + 30, str_size);
+ memcpy(reel_name, st->codecpar->extradata + 30, str_size);
reel_name[str_size] = 0; /* Add null terminator */
/* don't add reel_name if emtpy string */
if (*reel_name == 0) {
@@ -2061,12 +2078,12 @@ static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb,
static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb,
AVStream *st, MOVStreamContext *sc)
{
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
- !st->codec->sample_rate && sc->time_scale > 1)
- st->codec->sample_rate = sc->time_scale;
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
+ !st->codecpar->sample_rate && sc->time_scale > 1)
+ st->codecpar->sample_rate = sc->time_scale;
/* special codec parameters handling */
- switch (st->codec->codec_id) {
+ switch (st->codecpar->codec_id) {
#if CONFIG_DV_DEMUXER
case AV_CODEC_ID_DVAUDIO:
c->dv_fctx = avformat_alloc_context();
@@ -2080,33 +2097,33 @@ static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb,
return AVERROR(ENOMEM);
}
sc->dv_audio_container = 1;
- st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
break;
#endif
/* no ifdef since parameters are always those */
case AV_CODEC_ID_QCELP:
- st->codec->channels = 1;
+ st->codecpar->channels = 1;
// force sample rate for qcelp when not stored in mov
- if (st->codec->codec_tag != MKTAG('Q','c','l','p'))
- st->codec->sample_rate = 8000;
+ if (st->codecpar->codec_tag != MKTAG('Q','c','l','p'))
+ st->codecpar->sample_rate = 8000;
// FIXME: Why is the following needed for some files?
sc->samples_per_frame = 160;
if (!sc->bytes_per_frame)
sc->bytes_per_frame = 35;
break;
case AV_CODEC_ID_AMR_NB:
- st->codec->channels = 1;
+ st->codecpar->channels = 1;
/* force sample rate for amr, stsd in 3gp does not store sample rate */
- st->codec->sample_rate = 8000;
+ st->codecpar->sample_rate = 8000;
break;
case AV_CODEC_ID_AMR_WB:
- st->codec->channels = 1;
- st->codec->sample_rate = 16000;
+ st->codecpar->channels = 1;
+ st->codecpar->sample_rate = 16000;
break;
case AV_CODEC_ID_MP2:
case AV_CODEC_ID_MP3:
/* force type after stsd for m1a hdlr */
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
break;
case AV_CODEC_ID_GSM:
case AV_CODEC_ID_ADPCM_MS:
@@ -2115,12 +2132,12 @@ static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb,
case AV_CODEC_ID_MACE3:
case AV_CODEC_ID_MACE6:
case AV_CODEC_ID_QDM2:
- st->codec->block_align = sc->bytes_per_frame;
+ st->codecpar->block_align = sc->bytes_per_frame;
break;
case AV_CODEC_ID_ALAC:
- if (st->codec->extradata_size == 36) {
- st->codec->channels = AV_RB8 (st->codec->extradata + 21);
- st->codec->sample_rate = AV_RB32(st->codec->extradata + 32);
+ if (st->codecpar->extradata_size == 36) {
+ st->codecpar->channels = AV_RB8 (st->codecpar->extradata + 21);
+ st->codecpar->sample_rate = AV_RB32(st->codecpar->extradata + 32);
}
break;
case AV_CODEC_ID_AC3:
@@ -2194,11 +2211,11 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
return AVERROR_INVALIDDATA;
}
- if (mov_skip_multiple_stsd(c, pb, st->codec->codec_tag, format,
+ if (mov_skip_multiple_stsd(c, pb, st->codecpar->codec_tag, format,
size - (avio_tell(pb) - start_pos)))
continue;
- sc->pseudo_stream_id = st->codec->codec_tag ? -1 : pseudo_stream_id;
+ sc->pseudo_stream_id = st->codecpar->codec_tag ? -1 : pseudo_stream_id;
sc->dref_id= dref_id;
sc->format = format;
@@ -2207,16 +2224,16 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
av_log(c->fc, AV_LOG_TRACE,
"size=%"PRId64" 4CC= %c%c%c%c/0x%08x codec_type=%d\n", size,
(format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,
- (format >> 24) & 0xff, format, st->codec->codec_type);
+ (format >> 24) & 0xff, format, st->codecpar->codec_type);
- if (st->codec->codec_type==AVMEDIA_TYPE_VIDEO) {
- st->codec->codec_id = id;
+ if (st->codecpar->codec_type==AVMEDIA_TYPE_VIDEO) {
+ st->codecpar->codec_id = id;
mov_parse_stsd_video(c, pb, st, sc);
- } else if (st->codec->codec_type==AVMEDIA_TYPE_AUDIO) {
- st->codec->codec_id = id;
+ } else if (st->codecpar->codec_type==AVMEDIA_TYPE_AUDIO) {
+ st->codecpar->codec_id = id;
mov_parse_stsd_audio(c, pb, st, sc);
- } else if (st->codec->codec_type==AVMEDIA_TYPE_SUBTITLE){
- st->codec->codec_id = id;
+ } else if (st->codecpar->codec_type==AVMEDIA_TYPE_SUBTITLE){
+ st->codecpar->codec_id = id;
mov_parse_stsd_subtitle(c, pb, st, sc,
size - (avio_tell(pb) - start_pos));
} else {
@@ -2349,7 +2366,7 @@ static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (!entries)
{
sc->keyframe_absent = 1;
- if (!st->need_parsing && st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+ if (!st->need_parsing && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
st->need_parsing = AVSTREAM_PARSE_HEADERS;
return 0;
}
@@ -2685,16 +2702,16 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
/* more than 16 frames delay, dts are likely wrong
this happens with files created by iMovie */
sc->wrong_dts = 1;
- st->codec->has_b_frames = 1;
+ st->codecpar->video_delay = 1;
}
}
- if (!unsupported && st->codec->codec_id == AV_CODEC_ID_AAC && start_time > 0)
+ if (!unsupported && st->codecpar->codec_id == AV_CODEC_ID_AAC && start_time > 0)
sc->start_pad = start_time;
}
/* only use old uncompressed audio chunk demuxing when stts specifies it */
- if (!(st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
+ if (!(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
sc->stts_count == 1 && sc->stts_data[0].duration == 1)) {
unsigned int current_sample = 0;
unsigned int stts_sample = 0;
@@ -2766,7 +2783,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
if (sc->keyframe_absent
&& !sc->stps_count
&& !rap_group_present
- && (st->codec->codec_type == AVMEDIA_TYPE_AUDIO || (i==0 && j==0)))
+ && (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || (i==0 && j==0)))
keyframe = 1;
if (keyframe)
distance = 0;
@@ -2782,7 +2799,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
av_log(mov->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", "
"size %d, distance %d, keyframe %d\n", st->index, current_sample,
current_offset, current_dts, sample_size, distance, keyframe);
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->nb_index_entries < 100)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->nb_index_entries < 100)
ff_rfps_add_frame(mov->fc, st, current_dts);
}
@@ -2819,7 +2836,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
}
}
if (st->duration > 0)
- st->codec->bit_rate = stream_size*8*sc->time_scale/st->duration;
+ st->codecpar->bit_rate = stream_size*8*sc->time_scale/st->duration;
} else {
unsigned chunk_samples, total = 0;
@@ -3040,7 +3057,7 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (!sc) return AVERROR(ENOMEM);
st->priv_data = sc;
- st->codec->codec_type = AVMEDIA_TYPE_DATA;
+ st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
sc->ffindex = st->index;
c->trak_index = st->index;
@@ -3086,12 +3103,12 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
sc->pb_is_copied = 1;
}
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- if (!st->sample_aspect_ratio.num && st->codec->width && st->codec->height &&
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (!st->sample_aspect_ratio.num && st->codecpar->width && st->codecpar->height &&
sc->height && sc->width &&
- (st->codec->width != sc->width || st->codec->height != sc->height)) {
- st->sample_aspect_ratio = av_d2q(((double)st->codec->height * sc->width) /
- ((double)st->codec->width * sc->height), INT_MAX);
+ (st->codecpar->width != sc->width || st->codecpar->height != sc->height)) {
+ st->sample_aspect_ratio = av_d2q(((double)st->codecpar->height * sc->width) /
+ ((double)st->codecpar->width * sc->height), INT_MAX);
}
#if FF_API_R_FRAME_RATE
@@ -3102,14 +3119,14 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
}
// done for ai5q, ai52, ai55, ai1q, ai12 and ai15.
- if (!st->codec->extradata_size && st->codec->codec_id == AV_CODEC_ID_H264 &&
- TAG_IS_AVCI(st->codec->codec_tag)) {
+ if (!st->codecpar->extradata_size && st->codecpar->codec_id == AV_CODEC_ID_H264 &&
+ TAG_IS_AVCI(st->codecpar->codec_tag)) {
ret = ff_generate_avci_extradata(st);
if (ret < 0)
return ret;
}
- switch (st->codec->codec_id) {
+ switch (st->codecpar->codec_id) {
#if CONFIG_H261_DECODER
case AV_CODEC_ID_H261:
#endif
@@ -3119,16 +3136,16 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#if CONFIG_MPEG4_DECODER
case AV_CODEC_ID_MPEG4:
#endif
- st->codec->width = 0; /* let decoder init width/height */
- st->codec->height= 0;
+ st->codecpar->width = 0; /* let decoder init width/height */
+ st->codecpar->height= 0;
break;
}
// If the duration of the mp3 packets is not constant, then they could need a parser
- if (st->codec->codec_id == AV_CODEC_ID_MP3
+ if (st->codecpar->codec_id == AV_CODEC_ID_MP3
&& sc->stts_count > 3
&& sc->stts_count*10 > st->nb_frames
- && sc->time_scale == st->codec->sample_rate) {
+ && sc->time_scale == st->codecpar->sample_rate) {
st->need_parsing = AVSTREAM_PARSE_FULL;
}
/* Do not need those anymore. */
@@ -3613,7 +3630,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
frag->time = AV_NOPTS_VALUE;
}
sc->ctts_count++;
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
keyframe = 1;
else
keyframe =
@@ -4004,15 +4021,15 @@ static int mov_read_frma(MOVContext *c, AVIOContext *pb, MOVAtom atom)
case MKTAG('e','n','c','v'): // encrypted video
case MKTAG('e','n','c','a'): // encrypted audio
id = mov_codec_id(st, format);
- if (st->codec->codec_id != AV_CODEC_ID_NONE &&
- st->codec->codec_id != id) {
+ if (st->codecpar->codec_id != AV_CODEC_ID_NONE &&
+ st->codecpar->codec_id != id) {
av_log(c->fc, AV_LOG_WARNING,
"ignoring 'frma' atom of '%.4s', stream has codec id %d\n",
- (char*)&format, st->codec->codec_id);
+ (char*)&format, st->codecpar->codec_id);
break;
}
- st->codec->codec_id = id;
+ st->codecpar->codec_id = id;
sc->format = format;
break;
@@ -4597,8 +4614,7 @@ static int parse_timecode_in_framenum_format(AVFormatContext *s, AVStream *st,
{
AVTimecode tc;
char buf[AV_TIMECODE_STR_SIZE];
- AVRational rate = {st->codec->time_base.den,
- st->codec->time_base.num};
+ AVRational rate = st->avg_frame_rate;
int ret = av_timecode_init(&tc, rate, flags, 0, s);
if (ret < 0)
return ret;
@@ -4710,7 +4726,7 @@ static int tmcd_is_referenced(AVFormatContext *s, int tmcd_id)
AVStream *st = s->streams[i];
MOVStreamContext *sc = st->priv_data;
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
sc->timecode_track == tmcd_id)
return 1;
}
@@ -4725,7 +4741,7 @@ static void export_orphan_timecode(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
- if (st->codec->codec_tag == MKTAG('t','m','c','d') &&
+ if (st->codecpar->codec_tag == MKTAG('t','m','c','d') &&
!tmcd_is_referenced(s, i + 1)) {
AVDictionaryEntry *tcr = av_dict_get(st->metadata, "timecode", NULL, 0);
if (tcr) {
@@ -4885,7 +4901,7 @@ static int mov_read_header(AVFormatContext *s)
if (mov->chapter_track > 0 && !mov->ignore_chapters)
mov_read_chapters(s);
for (i = 0; i < s->nb_streams; i++)
- if (s->streams[i]->codec->codec_tag == AV_RL32("tmcd"))
+ if (s->streams[i]->codecpar->codec_tag == AV_RL32("tmcd"))
mov_read_timecode_track(s, s->streams[i]);
}
@@ -4914,25 +4930,25 @@ static int mov_read_header(AVFormatContext *s)
AVStream *st = s->streams[i];
MOVStreamContext *sc = st->priv_data;
fix_timescale(mov, sc);
- if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->codec_id == AV_CODEC_ID_AAC) {
+ if(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->codec_id == AV_CODEC_ID_AAC) {
st->skip_samples = sc->start_pad;
}
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && sc->nb_frames_for_fps > 0 && sc->duration_for_fps > 0)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && sc->nb_frames_for_fps > 0 && sc->duration_for_fps > 0)
av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
sc->time_scale*(int64_t)sc->nb_frames_for_fps, sc->duration_for_fps, INT_MAX);
- if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
- if (st->codec->width <= 0 || st->codec->height <= 0) {
- st->codec->width = sc->width;
- st->codec->height = sc->height;
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ if (st->codecpar->width <= 0 || st->codecpar->height <= 0) {
+ st->codecpar->width = sc->width;
+ st->codecpar->height = sc->height;
}
- if (st->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_DVD_SUBTITLE) {
if ((err = mov_rewrite_dvd_sub_extradata(st)) < 0)
return err;
}
}
if (mov->handbrake_version &&
mov->handbrake_version <= 1000000*0 + 1000*10 + 2 && // 0.10.2
- st->codec->codec_id == AV_CODEC_ID_MP3
+ st->codecpar->codec_id == AV_CODEC_ID_MP3
) {
av_log(s, AV_LOG_VERBOSE, "Forcing full parsing for mp3 stream\n");
st->need_parsing = AVSTREAM_PARSE_FULL;
@@ -4944,7 +4960,7 @@ static int mov_read_header(AVFormatContext *s)
AVStream *st = s->streams[i];
MOVStreamContext *sc = st->priv_data;
if (st->duration > 0)
- st->codec->bit_rate = sc->data_size * 8 * sc->time_scale / st->duration;
+ st->codecpar->bit_rate = sc->data_size * 8 * sc->time_scale / st->duration;
}
}
@@ -4953,7 +4969,7 @@ static int mov_read_header(AVFormatContext *s)
AVStream *st = s->streams[i];
MOVStreamContext *sc = st->priv_data;
if (sc->duration_for_fps > 0) {
- st->codec->bit_rate = sc->data_size * 8 * sc->time_scale /
+ st->codecpar->bit_rate = sc->data_size * 8 * sc->time_scale /
sc->duration_for_fps;
}
}
@@ -4961,7 +4977,7 @@ static int mov_read_header(AVFormatContext *s)
for (i = 0; i < mov->bitrates_count && i < s->nb_streams; i++) {
if (mov->bitrates[i]) {
- s->streams[i]->codec->bit_rate = mov->bitrates[i];
+ s->streams[i]->codecpar->bit_rate = mov->bitrates[i];
}
}
@@ -4971,7 +4987,7 @@ static int mov_read_header(AVFormatContext *s)
AVStream *st = s->streams[i];
MOVStreamContext *sc = st->priv_data;
- switch (st->codec->codec_type) {
+ switch (st->codecpar->codec_type) {
case AVMEDIA_TYPE_AUDIO:
err = ff_replaygain_export(st, s->metadata);
if (err < 0) {
diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
index cba07c51e5..dc8bf8dccc 100644
--- a/libavformat/mov_chan.c
+++ b/libavformat/mov_chan.c
@@ -588,9 +588,9 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st,
}
if (layout_tag == 0) {
if (label_mask)
- st->codec->channel_layout = label_mask;
+ st->codecpar->channel_layout = label_mask;
} else
- st->codec->channel_layout = ff_mov_get_channel_layout(layout_tag, bitmap);
+ st->codecpar->channel_layout = ff_mov_get_channel_layout(layout_tag, bitmap);
avio_skip(pb, size - 12);
return 0;
diff --git a/libavformat/movenc-test.c b/libavformat/movenc-test.c
index 8c69c767a7..e7928a6c6a 100644
--- a/libavformat/movenc-test.c
+++ b/libavformat/movenc-test.c
@@ -159,33 +159,33 @@ static void init_fps(int bf, int audio_preroll, int fps)
st = avformat_new_stream(ctx, NULL);
if (!st)
exit(1);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_H264;
- st->codec->width = 640;
- st->codec->height = 480;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_H264;
+ st->codecpar->width = 640;
+ st->codecpar->height = 480;
st->time_base.num = 1;
st->time_base.den = 30;
- st->codec->extradata_size = sizeof(h264_extradata);
- st->codec->extradata = av_mallocz(st->codec->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
- if (!st->codec->extradata)
+ st->codecpar->extradata_size = sizeof(h264_extradata);
+ st->codecpar->extradata = av_mallocz(st->codecpar->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!st->codecpar->extradata)
exit(1);
- memcpy(st->codec->extradata, h264_extradata, sizeof(h264_extradata));
+ memcpy(st->codecpar->extradata, h264_extradata, sizeof(h264_extradata));
video_st = st;
st = avformat_new_stream(ctx, NULL);
if (!st)
exit(1);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_AAC;
- st->codec->sample_rate = 44100;
- st->codec->channels = 2;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_AAC;
+ st->codecpar->sample_rate = 44100;
+ st->codecpar->channels = 2;
st->time_base.num = 1;
st->time_base.den = 44100;
- st->codec->extradata_size = sizeof(aac_extradata);
- st->codec->extradata = av_mallocz(st->codec->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
- if (!st->codec->extradata)
+ st->codecpar->extradata_size = sizeof(aac_extradata);
+ st->codecpar->extradata = av_mallocz(st->codecpar->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!st->codecpar->extradata)
exit(1);
- memcpy(st->codec->extradata, aac_extradata, sizeof(aac_extradata));
+ memcpy(st->codecpar->extradata, aac_extradata, sizeof(aac_extradata));
audio_st = st;
if (avformat_write_header(ctx, &opts) < 0)
@@ -195,9 +195,9 @@ static void init_fps(int bf, int audio_preroll, int fps)
frames = 0;
gop_size = 30;
duration = video_st->time_base.den / fps;
- audio_duration = 1024LL * audio_st->time_base.den / audio_st->codec->sample_rate;
+ audio_duration = 1024LL * audio_st->time_base.den / audio_st->codecpar->sample_rate;
if (audio_preroll)
- audio_preroll = 2048LL * audio_st->time_base.den / audio_st->codec->sample_rate;
+ audio_preroll = 2048LL * audio_st->time_base.den / audio_st->codecpar->sample_rate;
bframes = bf;
video_dts = bframes ? -duration : 0;
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index efaac36ba6..5acb9aff12 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -370,7 +370,7 @@ static int handle_eac3(MOVMuxContext *mov, AVPacket *pkt, MOVTrack *track)
if (hdr->substreamid == info->num_ind_sub + 1) {
//info->num_ind_sub++;
- avpriv_request_sample(track->enc, "Multiple independent substreams");
+ avpriv_request_sample(track->par, "Multiple independent substreams");
return AVERROR_PATCHWELCOME;
} else if (hdr->substreamid < info->num_ind_sub ||
hdr->substreamid == 0 && info->substream[0].bsid) {
@@ -513,8 +513,8 @@ end:
*/
static int mov_write_extradata_tag(AVIOContext *pb, MOVTrack *track)
{
- avio_write(pb, track->enc->extradata, track->enc->extradata_size);
- return track->enc->extradata_size;
+ avio_write(pb, track->par->extradata, track->par->extradata_size);
+ return track->par->extradata_size;
}
static int mov_write_enda_tag(AVIOContext *pb)
@@ -573,18 +573,18 @@ static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic
put_descr(pb, 0x04, 13 + decoder_specific_info_len);
// Object type indication
- if ((track->enc->codec_id == AV_CODEC_ID_MP2 ||
- track->enc->codec_id == AV_CODEC_ID_MP3) &&
- track->enc->sample_rate > 24000)
+ if ((track->par->codec_id == AV_CODEC_ID_MP2 ||
+ track->par->codec_id == AV_CODEC_ID_MP3) &&
+ track->par->sample_rate > 24000)
avio_w8(pb, 0x6B); // 11172-3
else
- avio_w8(pb, ff_codec_get_tag(ff_mp4_obj_type, track->enc->codec_id));
+ avio_w8(pb, ff_codec_get_tag(ff_mp4_obj_type, track->par->codec_id));
// the following fields is made of 6 bits to identify the streamtype (4 for video, 5 for audio)
// plus 1 bit to indicate upstream and 1 bit set to 1 (reserved)
- if (track->enc->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
+ if (track->par->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
avio_w8(pb, (0x38 << 2) | 1); // flags (= NeroSubpicStream)
- else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
+ else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO)
avio_w8(pb, 0x15); // flags (= Audiostream)
else
avio_w8(pb, 0x11); // flags (= Visualstream)
@@ -595,7 +595,7 @@ static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic
avio_wb24(pb, props ? props->buffer_size / 8 : 0); // Buffersize DB
avg_bitrate = compute_avg_bitrate(track);
- avio_wb32(pb, props ? FFMAX3(props->max_bitrate, props->avg_bitrate, avg_bitrate) : FFMAX(track->enc->bit_rate, avg_bitrate)); // maxbitrate (FIXME should be max rate in any 1 sec window)
+ avio_wb32(pb, props ? FFMAX3(props->max_bitrate, props->avg_bitrate, avg_bitrate) : FFMAX(track->par->bit_rate, avg_bitrate)); // maxbitrate (FIXME should be max rate in any 1 sec window)
avio_wb32(pb, avg_bitrate);
if (track->vos_len) {
@@ -626,39 +626,39 @@ static int mov_pcm_be_gt16(enum AVCodecID codec_id)
codec_id == AV_CODEC_ID_PCM_F64BE;
}
-static int mov_write_ms_tag(AVIOContext *pb, MOVTrack *track)
+static int mov_write_ms_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track)
{
int ret;
int64_t pos = avio_tell(pb);
avio_wb32(pb, 0);
avio_wl32(pb, track->tag); // store it byteswapped
- track->enc->codec_tag = av_bswap16(track->tag >> 16);
- if ((ret = ff_put_wav_header(pb, track->enc, 0)) < 0)
+ track->par->codec_tag = av_bswap16(track->tag >> 16);
+ if ((ret = ff_put_wav_header(s, pb, track->par, 0)) < 0)
return ret;
return update_size(pb, pos);
}
-static int mov_write_wfex_tag(AVIOContext *pb, MOVTrack *track)
+static int mov_write_wfex_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track)
{
int ret;
int64_t pos = avio_tell(pb);
avio_wb32(pb, 0);
ffio_wfourcc(pb, "wfex");
- if ((ret = ff_put_wav_header(pb, track->enc, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX)) < 0)
+ if ((ret = ff_put_wav_header(s, pb, track->st->codecpar, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX)) < 0)
return ret;
return update_size(pb, pos);
}
-static int mov_write_chan_tag(AVIOContext *pb, MOVTrack *track)
+static int mov_write_chan_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track)
{
uint32_t layout_tag, bitmap;
int64_t pos = avio_tell(pb);
- layout_tag = ff_mov_get_channel_layout_tag(track->enc->codec_id,
- track->enc->channel_layout,
+ layout_tag = ff_mov_get_channel_layout_tag(track->par->codec_id,
+ track->par->channel_layout,
&bitmap);
if (!layout_tag) {
- av_log(track->enc, AV_LOG_WARNING, "not writing 'chan' tag due to "
+ av_log(s, AV_LOG_WARNING, "not writing 'chan' tag due to "
"lack of channel information\n");
return 0;
}
@@ -677,41 +677,41 @@ static int mov_write_chan_tag(AVIOContext *pb, MOVTrack *track)
return update_size(pb, pos);
}
-static int mov_write_wave_tag(AVIOContext *pb, MOVTrack *track)
+static int mov_write_wave_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
avio_wb32(pb, 0); /* size */
ffio_wfourcc(pb, "wave");
- if (track->enc->codec_id != AV_CODEC_ID_QDM2) {
+ if (track->par->codec_id != AV_CODEC_ID_QDM2) {
avio_wb32(pb, 12); /* size */
ffio_wfourcc(pb, "frma");
avio_wl32(pb, track->tag);
}
- if (track->enc->codec_id == AV_CODEC_ID_AAC) {
+ if (track->par->codec_id == AV_CODEC_ID_AAC) {
/* useless atom needed by mplayer, ipod, not needed by quicktime */
avio_wb32(pb, 12); /* size */
ffio_wfourcc(pb, "mp4a");
avio_wb32(pb, 0);
mov_write_esds_tag(pb, track);
- } else if (mov_pcm_le_gt16(track->enc->codec_id)) {
+ } else if (mov_pcm_le_gt16(track->par->codec_id)) {
mov_write_enda_tag(pb);
- } else if (mov_pcm_be_gt16(track->enc->codec_id)) {
+ } else if (mov_pcm_be_gt16(track->par->codec_id)) {
mov_write_enda_tag_be(pb);
- } else if (track->enc->codec_id == AV_CODEC_ID_AMR_NB) {
+ } else if (track->par->codec_id == AV_CODEC_ID_AMR_NB) {
mov_write_amr_tag(pb, track);
- } else if (track->enc->codec_id == AV_CODEC_ID_AC3) {
+ } else if (track->par->codec_id == AV_CODEC_ID_AC3) {
mov_write_ac3_tag(pb, track);
- } else if (track->enc->codec_id == AV_CODEC_ID_EAC3) {
+ } else if (track->par->codec_id == AV_CODEC_ID_EAC3) {
mov_write_eac3_tag(pb, track);
- } else if (track->enc->codec_id == AV_CODEC_ID_ALAC ||
- track->enc->codec_id == AV_CODEC_ID_QDM2) {
+ } else if (track->par->codec_id == AV_CODEC_ID_ALAC ||
+ track->par->codec_id == AV_CODEC_ID_QDM2) {
mov_write_extradata_tag(pb, track);
- } else if (track->enc->codec_id == AV_CODEC_ID_ADPCM_MS ||
- track->enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {
- mov_write_ms_tag(pb, track);
+ } else if (track->par->codec_id == AV_CODEC_ID_ADPCM_MS ||
+ track->par->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {
+ mov_write_ms_tag(s, pb, track);
}
avio_wb32(pb, 8); /* size */
@@ -880,7 +880,7 @@ static int get_samples_per_packet(MOVTrack *track)
{
int i, first_duration;
-// return track->enc->frame_size;
+// return track->par->frame_size;
/* use 1 for raw PCM */
if (!track->audio_vbr)
@@ -897,7 +897,7 @@ static int get_samples_per_packet(MOVTrack *track)
return first_duration;
}
-static int mov_write_audio_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track)
+static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
int version = 0;
@@ -905,14 +905,14 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *tr
if (track->mode == MODE_MOV) {
if (track->timescale > UINT16_MAX) {
- if (mov_get_lpcm_flags(track->enc->codec_id))
+ if (mov_get_lpcm_flags(track->par->codec_id))
tag = AV_RL32("lpcm");
version = 2;
- } else if (track->audio_vbr || mov_pcm_le_gt16(track->enc->codec_id) ||
- mov_pcm_be_gt16(track->enc->codec_id) ||
- track->enc->codec_id == AV_CODEC_ID_ADPCM_MS ||
- track->enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
- track->enc->codec_id == AV_CODEC_ID_QDM2) {
+ } else if (track->audio_vbr || mov_pcm_le_gt16(track->par->codec_id) ||
+ mov_pcm_be_gt16(track->par->codec_id) ||
+ track->par->codec_id == AV_CODEC_ID_ADPCM_MS ||
+ track->par->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
+ track->par->codec_id == AV_CODEC_ID_QDM2) {
version = 1;
}
}
@@ -939,21 +939,21 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *tr
avio_wb16(pb, 0);
avio_wb32(pb, 0x00010000);
avio_wb32(pb, 72);
- avio_wb64(pb, av_double2int(track->enc->sample_rate));
- avio_wb32(pb, track->enc->channels);
+ avio_wb64(pb, av_double2int(track->par->sample_rate));
+ avio_wb32(pb, track->par->channels);
avio_wb32(pb, 0x7F000000);
- avio_wb32(pb, av_get_bits_per_sample(track->enc->codec_id));
- avio_wb32(pb, mov_get_lpcm_flags(track->enc->codec_id));
+ avio_wb32(pb, av_get_bits_per_sample(track->par->codec_id));
+ avio_wb32(pb, mov_get_lpcm_flags(track->par->codec_id));
avio_wb32(pb, track->sample_size);
avio_wb32(pb, get_samples_per_packet(track));
} else {
if (track->mode == MODE_MOV) {
- avio_wb16(pb, track->enc->channels);
- if (track->enc->codec_id == AV_CODEC_ID_PCM_U8 ||
- track->enc->codec_id == AV_CODEC_ID_PCM_S8)
+ avio_wb16(pb, track->par->channels);
+ if (track->par->codec_id == AV_CODEC_ID_PCM_U8 ||
+ track->par->codec_id == AV_CODEC_ID_PCM_S8)
avio_wb16(pb, 8); /* bits per sample */
- else if (track->enc->codec_id == AV_CODEC_ID_ADPCM_G726)
- avio_wb16(pb, track->enc->bits_per_coded_sample);
+ else if (track->par->codec_id == AV_CODEC_ID_ADPCM_G726)
+ avio_wb16(pb, track->par->bits_per_coded_sample);
else
avio_wb16(pb, 16);
avio_wb16(pb, track->audio_vbr ? -2 : 0); /* compression ID */
@@ -964,51 +964,51 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *tr
}
avio_wb16(pb, 0); /* packet size (= 0) */
- avio_wb16(pb, track->enc->sample_rate <= UINT16_MAX ?
- track->enc->sample_rate : 0);
+ avio_wb16(pb, track->par->sample_rate <= UINT16_MAX ?
+ track->par->sample_rate : 0);
avio_wb16(pb, 0); /* Reserved */
}
if (version == 1) { /* SoundDescription V1 extended info */
- if (mov_pcm_le_gt16(track->enc->codec_id) ||
- mov_pcm_be_gt16(track->enc->codec_id))
+ if (mov_pcm_le_gt16(track->par->codec_id) ||
+ mov_pcm_be_gt16(track->par->codec_id))
avio_wb32(pb, 1); /* must be 1 for uncompressed formats */
else
- avio_wb32(pb, track->enc->frame_size); /* Samples per packet */
- avio_wb32(pb, track->sample_size / track->enc->channels); /* Bytes per packet */
+ avio_wb32(pb, track->par->frame_size); /* Samples per packet */
+ avio_wb32(pb, track->sample_size / track->par->channels); /* Bytes per packet */
avio_wb32(pb, track->sample_size); /* Bytes per frame */
avio_wb32(pb, 2); /* Bytes per sample */
}
if (track->mode == MODE_MOV &&
- (track->enc->codec_id == AV_CODEC_ID_AAC ||
- track->enc->codec_id == AV_CODEC_ID_AC3 ||
- track->enc->codec_id == AV_CODEC_ID_EAC3 ||
- track->enc->codec_id == AV_CODEC_ID_AMR_NB ||
- track->enc->codec_id == AV_CODEC_ID_ALAC ||
- track->enc->codec_id == AV_CODEC_ID_ADPCM_MS ||
- track->enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
- track->enc->codec_id == AV_CODEC_ID_QDM2 ||
- (mov_pcm_le_gt16(track->enc->codec_id) && version==1) ||
- (mov_pcm_be_gt16(track->enc->codec_id) && version==1)))
- mov_write_wave_tag(pb, track);
+ (track->par->codec_id == AV_CODEC_ID_AAC ||
+ track->par->codec_id == AV_CODEC_ID_AC3 ||
+ track->par->codec_id == AV_CODEC_ID_EAC3 ||
+ track->par->codec_id == AV_CODEC_ID_AMR_NB ||
+ track->par->codec_id == AV_CODEC_ID_ALAC ||
+ track->par->codec_id == AV_CODEC_ID_ADPCM_MS ||
+ track->par->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
+ track->par->codec_id == AV_CODEC_ID_QDM2 ||
+ (mov_pcm_le_gt16(track->par->codec_id) && version==1) ||
+ (mov_pcm_be_gt16(track->par->codec_id) && version==1)))
+ mov_write_wave_tag(s, pb, track);
else if (track->tag == MKTAG('m','p','4','a'))
mov_write_esds_tag(pb, track);
- else if (track->enc->codec_id == AV_CODEC_ID_AMR_NB)
+ else if (track->par->codec_id == AV_CODEC_ID_AMR_NB)
mov_write_amr_tag(pb, track);
- else if (track->enc->codec_id == AV_CODEC_ID_AC3)
+ else if (track->par->codec_id == AV_CODEC_ID_AC3)
mov_write_ac3_tag(pb, track);
- else if (track->enc->codec_id == AV_CODEC_ID_EAC3)
+ else if (track->par->codec_id == AV_CODEC_ID_EAC3)
mov_write_eac3_tag(pb, track);
- else if (track->enc->codec_id == AV_CODEC_ID_ALAC)
+ else if (track->par->codec_id == AV_CODEC_ID_ALAC)
mov_write_extradata_tag(pb, track);
- else if (track->enc->codec_id == AV_CODEC_ID_WMAPRO)
- mov_write_wfex_tag(pb, track);
+ else if (track->par->codec_id == AV_CODEC_ID_WMAPRO)
+ mov_write_wfex_tag(s, pb, track);
else if (track->vos_len > 0)
mov_write_glbl_tag(pb, track);
- if (track->mode == MODE_MOV && track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
- mov_write_chan_tag(pb, track);
+ if (track->mode == MODE_MOV && track->par->codec_type == AVMEDIA_TYPE_AUDIO)
+ mov_write_chan_tag(s, pb, track);
if (mov->encryption_scheme != MOV_ENC_NONE) {
ff_mov_cenc_write_sinf_tag(track, pb, mov->encryption_kid);
@@ -1078,8 +1078,8 @@ static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track)
ffio_wfourcc(pb, "ACLR");
ffio_wfourcc(pb, "ACLR");
ffio_wfourcc(pb, "0001");
- if (track->enc->color_range == AVCOL_RANGE_MPEG || /* Legal range (16-235) */
- track->enc->color_range == AVCOL_RANGE_UNSPECIFIED) {
+ if (track->par->color_range == AVCOL_RANGE_MPEG || /* Legal range (16-235) */
+ track->par->color_range == AVCOL_RANGE_UNSPECIFIED) {
avio_wb32(pb, 1); /* Corresponds to 709 in official encoder */
} else { /* Full range (0-255) */
avio_wb32(pb, 2); /* Corresponds to RGB in official encoder */
@@ -1098,18 +1098,18 @@ static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track)
ffio_wfourcc(pb, "ARES");
ffio_wfourcc(pb, "0001");
avio_wb32(pb, cid); /* dnxhd cid, some id ? */
- avio_wb32(pb, track->enc->width);
+ avio_wb32(pb, track->par->width);
/* values below are based on samples created with quicktime and avid codecs */
if (interlaced) {
- avio_wb32(pb, track->enc->height / 2);
+ avio_wb32(pb, track->par->height / 2);
avio_wb32(pb, 2); /* unknown */
avio_wb32(pb, 0); /* unknown */
avio_wb32(pb, 4); /* unknown */
} else {
- avio_wb32(pb, track->enc->height);
+ avio_wb32(pb, track->par->height);
avio_wb32(pb, 1); /* unknown */
avio_wb32(pb, 0); /* unknown */
- if (track->enc->height == 1080)
+ if (track->par->height == 1080)
avio_wb32(pb, 5); /* unknown */
else
avio_wb32(pb, 6); /* unknown */
@@ -1125,9 +1125,9 @@ static int mov_write_dpxe_tag(AVIOContext *pb, MOVTrack *track)
{
avio_wb32(pb, 12);
ffio_wfourcc(pb, "DpxE");
- if (track->enc->extradata_size >= 12 &&
- !memcmp(&track->enc->extradata[4], "DpxE", 4)) {
- avio_wb32(pb, track->enc->extradata[11]);
+ if (track->par->extradata_size >= 12 &&
+ !memcmp(&track->par->extradata[4], "DpxE", 4)) {
+ avio_wb32(pb, track->par->extradata[11]);
} else {
avio_wb32(pb, 1);
}
@@ -1136,21 +1136,21 @@ static int mov_write_dpxe_tag(AVIOContext *pb, MOVTrack *track)
static int mp4_get_codec_tag(AVFormatContext *s, MOVTrack *track)
{
- int tag = track->enc->codec_tag;
+ int tag = track->par->codec_tag;
- if (!ff_codec_get_tag(ff_mp4_obj_type, track->enc->codec_id))
+ if (!ff_codec_get_tag(ff_mp4_obj_type, track->par->codec_id))
return 0;
- if (track->enc->codec_id == AV_CODEC_ID_H264) tag = MKTAG('a','v','c','1');
- else if (track->enc->codec_id == AV_CODEC_ID_HEVC) tag = MKTAG('h','e','v','1');
- else if (track->enc->codec_id == AV_CODEC_ID_AC3) tag = MKTAG('a','c','-','3');
- else if (track->enc->codec_id == AV_CODEC_ID_EAC3) tag = MKTAG('e','c','-','3');
- else if (track->enc->codec_id == AV_CODEC_ID_DIRAC) tag = MKTAG('d','r','a','c');
- else if (track->enc->codec_id == AV_CODEC_ID_MOV_TEXT) tag = MKTAG('t','x','3','g');
- else if (track->enc->codec_id == AV_CODEC_ID_VC1) tag = MKTAG('v','c','-','1');
- else if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) tag = MKTAG('m','p','4','v');
- else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) tag = MKTAG('m','p','4','a');
- else if (track->enc->codec_id == AV_CODEC_ID_DVD_SUBTITLE) tag = MKTAG('m','p','4','s');
+ if (track->par->codec_id == AV_CODEC_ID_H264) tag = MKTAG('a','v','c','1');
+ else if (track->par->codec_id == AV_CODEC_ID_HEVC) tag = MKTAG('h','e','v','1');
+ else if (track->par->codec_id == AV_CODEC_ID_AC3) tag = MKTAG('a','c','-','3');
+ else if (track->par->codec_id == AV_CODEC_ID_EAC3) tag = MKTAG('e','c','-','3');
+ else if (track->par->codec_id == AV_CODEC_ID_DIRAC) tag = MKTAG('d','r','a','c');
+ else if (track->par->codec_id == AV_CODEC_ID_MOV_TEXT) tag = MKTAG('t','x','3','g');
+ else if (track->par->codec_id == AV_CODEC_ID_VC1) tag = MKTAG('v','c','-','1');
+ else if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) tag = MKTAG('m','p','4','v');
+ else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO) tag = MKTAG('m','p','4','a');
+ else if (track->par->codec_id == AV_CODEC_ID_DVD_SUBTITLE) tag = MKTAG('m','p','4','s');
return tag;
}
@@ -1168,13 +1168,13 @@ static const AVCodecTag codec_ipod_tags[] = {
static int ipod_get_codec_tag(AVFormatContext *s, MOVTrack *track)
{
- int tag = track->enc->codec_tag;
+ int tag = track->par->codec_tag;
// keep original tag for subs, ipod supports both formats
- if (!(track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE &&
+ if (!(track->par->codec_type == AVMEDIA_TYPE_SUBTITLE &&
(tag == MKTAG('t', 'x', '3', 'g') ||
tag == MKTAG('t', 'e', 'x', 't'))))
- tag = ff_codec_get_tag(codec_ipod_tags, track->enc->codec_id);
+ tag = ff_codec_get_tag(codec_ipod_tags, track->par->codec_id);
if (!av_match_ext(s->filename, "m4a") &&
!av_match_ext(s->filename, "m4b") &&
@@ -1189,17 +1189,17 @@ static int mov_get_dv_codec_tag(AVFormatContext *s, MOVTrack *track)
{
int tag;
- if (track->enc->width == 720) { /* SD */
- if (track->enc->height == 480) { /* NTSC */
- if (track->enc->pix_fmt == AV_PIX_FMT_YUV422P) tag = MKTAG('d','v','5','n');
+ if (track->par->width == 720) { /* SD */
+ if (track->par->height == 480) { /* NTSC */
+ if (track->par->format == AV_PIX_FMT_YUV422P) tag = MKTAG('d','v','5','n');
else tag = MKTAG('d','v','c',' ');
- }else if (track->enc->pix_fmt == AV_PIX_FMT_YUV422P) tag = MKTAG('d','v','5','p');
- else if (track->enc->pix_fmt == AV_PIX_FMT_YUV420P) tag = MKTAG('d','v','c','p');
+ }else if (track->par->format == AV_PIX_FMT_YUV422P) tag = MKTAG('d','v','5','p');
+ else if (track->par->format == AV_PIX_FMT_YUV420P) tag = MKTAG('d','v','c','p');
else tag = MKTAG('d','v','p','p');
- } else if (track->enc->height == 720) { /* HD 720 line */
+ } else if (track->par->height == 720) { /* HD 720 line */
if (track->st->time_base.den == 50) tag = MKTAG('d','v','h','q');
else tag = MKTAG('d','v','h','p');
- } else if (track->enc->height == 1080) { /* HD 1080 line */
+ } else if (track->par->height == 1080) { /* HD 1080 line */
if (track->st->time_base.den == 25) tag = MKTAG('d','v','h','5');
else tag = MKTAG('d','v','h','6');
} else {
@@ -1212,29 +1212,34 @@ static int mov_get_dv_codec_tag(AVFormatContext *s, MOVTrack *track)
static AVRational find_fps(AVFormatContext *s, AVStream *st)
{
- AVRational rate = {st->codec->time_base.den, st->codec->time_base.num};
- /* if the codec time base makes no sense, try to fallback on stream frame rate */
+ AVRational rate = st->avg_frame_rate;
+
+#if FF_API_LAVF_AVCTX
+ FF_DISABLE_DEPRECATION_WARNINGS
+ rate = av_inv_q(st->codec->time_base);
if (av_timecode_check_frame_rate(rate) < 0) {
av_log(s, AV_LOG_DEBUG, "timecode: tbc=%d/%d invalid, fallback on %d/%d\n",
rate.num, rate.den, st->avg_frame_rate.num, st->avg_frame_rate.den);
rate = st->avg_frame_rate;
}
+ FF_ENABLE_DEPRECATION_WARNINGS
+#endif
return rate;
}
static int mov_get_mpeg2_xdcam_codec_tag(AVFormatContext *s, MOVTrack *track)
{
- int tag = track->enc->codec_tag;
- int interlaced = track->enc->field_order > AV_FIELD_PROGRESSIVE;
+ int tag = track->par->codec_tag;
+ int interlaced = track->par->field_order > AV_FIELD_PROGRESSIVE;
AVStream *st = track->st;
int rate = av_q2d(find_fps(s, st));
if (!tag)
tag = MKTAG('m', '2', 'v', '1'); //fallback tag
- if (track->enc->pix_fmt == AV_PIX_FMT_YUV420P) {
- if (track->enc->width == 1280 && track->enc->height == 720) {
+ if (track->par->format == AV_PIX_FMT_YUV420P) {
+ if (track->par->width == 1280 && track->par->height == 720) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('x','d','v','4');
else if (rate == 25) tag = MKTAG('x','d','v','5');
@@ -1242,7 +1247,7 @@ static int mov_get_mpeg2_xdcam_codec_tag(AVFormatContext *s, MOVTrack *track)
else if (rate == 50) tag = MKTAG('x','d','v','a');
else if (rate == 60) tag = MKTAG('x','d','v','9');
}
- } else if (track->enc->width == 1440 && track->enc->height == 1080) {
+ } else if (track->par->width == 1440 && track->par->height == 1080) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('x','d','v','6');
else if (rate == 25) tag = MKTAG('x','d','v','7');
@@ -1251,7 +1256,7 @@ static int mov_get_mpeg2_xdcam_codec_tag(AVFormatContext *s, MOVTrack *track)
if (rate == 25) tag = MKTAG('x','d','v','3');
else if (rate == 30) tag = MKTAG('x','d','v','2');
}
- } else if (track->enc->width == 1920 && track->enc->height == 1080) {
+ } else if (track->par->width == 1920 && track->par->height == 1080) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('x','d','v','d');
else if (rate == 25) tag = MKTAG('x','d','v','e');
@@ -1261,8 +1266,8 @@ static int mov_get_mpeg2_xdcam_codec_tag(AVFormatContext *s, MOVTrack *track)
else if (rate == 30) tag = MKTAG('x','d','v','b');
}
}
- } else if (track->enc->pix_fmt == AV_PIX_FMT_YUV422P) {
- if (track->enc->width == 1280 && track->enc->height == 720) {
+ } else if (track->par->format == AV_PIX_FMT_YUV422P) {
+ if (track->par->width == 1280 && track->par->height == 720) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('x','d','5','4');
else if (rate == 25) tag = MKTAG('x','d','5','5');
@@ -1270,7 +1275,7 @@ static int mov_get_mpeg2_xdcam_codec_tag(AVFormatContext *s, MOVTrack *track)
else if (rate == 50) tag = MKTAG('x','d','5','a');
else if (rate == 60) tag = MKTAG('x','d','5','9');
}
- } else if (track->enc->width == 1920 && track->enc->height == 1080) {
+ } else if (track->par->width == 1920 && track->par->height == 1080) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('x','d','5','d');
else if (rate == 25) tag = MKTAG('x','d','5','e');
@@ -1287,16 +1292,16 @@ static int mov_get_mpeg2_xdcam_codec_tag(AVFormatContext *s, MOVTrack *track)
static int mov_get_h264_codec_tag(AVFormatContext *s, MOVTrack *track)
{
- int tag = track->enc->codec_tag;
- int interlaced = track->enc->field_order > AV_FIELD_PROGRESSIVE;
+ int tag = track->par->codec_tag;
+ int interlaced = track->par->field_order > AV_FIELD_PROGRESSIVE;
AVStream *st = track->st;
int rate = av_q2d(find_fps(s, st));
if (!tag)
tag = MKTAG('a', 'v', 'c', 'i'); //fallback tag
- if (track->enc->pix_fmt == AV_PIX_FMT_YUV420P10) {
- if (track->enc->width == 960 && track->enc->height == 720) {
+ if (track->par->format == AV_PIX_FMT_YUV420P10) {
+ if (track->par->width == 960 && track->par->height == 720) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('a','i','5','p');
else if (rate == 25) tag = MKTAG('a','i','5','q');
@@ -1304,7 +1309,7 @@ static int mov_get_h264_codec_tag(AVFormatContext *s, MOVTrack *track)
else if (rate == 50) tag = MKTAG('a','i','5','q');
else if (rate == 60) tag = MKTAG('a','i','5','p');
}
- } else if (track->enc->width == 1440 && track->enc->height == 1080) {
+ } else if (track->par->width == 1440 && track->par->height == 1080) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('a','i','5','3');
else if (rate == 25) tag = MKTAG('a','i','5','2');
@@ -1314,8 +1319,8 @@ static int mov_get_h264_codec_tag(AVFormatContext *s, MOVTrack *track)
else if (rate == 60) tag = MKTAG('a','i','5','6');
}
}
- } else if (track->enc->pix_fmt == AV_PIX_FMT_YUV422P10) {
- if (track->enc->width == 1280 && track->enc->height == 720) {
+ } else if (track->par->format == AV_PIX_FMT_YUV422P10) {
+ if (track->par->width == 1280 && track->par->height == 720) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('a','i','1','p');
else if (rate == 25) tag = MKTAG('a','i','1','q');
@@ -1323,7 +1328,7 @@ static int mov_get_h264_codec_tag(AVFormatContext *s, MOVTrack *track)
else if (rate == 50) tag = MKTAG('a','i','1','q');
else if (rate == 60) tag = MKTAG('a','i','1','p');
}
- } else if (track->enc->width == 1920 && track->enc->height == 1080) {
+ } else if (track->par->width == 1920 && track->par->height == 1080) {
if (!interlaced) {
if (rate == 24) tag = MKTAG('a','i','1','3');
else if (rate == 25) tag = MKTAG('a','i','1','2');
@@ -1333,9 +1338,9 @@ static int mov_get_h264_codec_tag(AVFormatContext *s, MOVTrack *track)
else if (rate == 50) tag = MKTAG('a','i','1','5');
else if (rate == 60) tag = MKTAG('a','i','1','6');
}
- } else if ( track->enc->width == 4096 && track->enc->height == 2160
- || track->enc->width == 3840 && track->enc->height == 2160
- || track->enc->width == 2048 && track->enc->height == 1080) {
+ } else if ( track->par->width == 4096 && track->par->height == 2160
+ || track->par->width == 3840 && track->par->height == 2160
+ || track->par->width == 2048 && track->par->height == 1080) {
tag = MKTAG('a','i','v','x');
}
}
@@ -1367,68 +1372,68 @@ static const struct {
static int mov_get_rawvideo_codec_tag(AVFormatContext *s, MOVTrack *track)
{
- int tag = track->enc->codec_tag;
+ int tag = track->par->codec_tag;
int i;
enum AVPixelFormat pix_fmt;
for (i = 0; i < FF_ARRAY_ELEMS(mov_pix_fmt_tags); i++) {
- if (track->enc->pix_fmt == mov_pix_fmt_tags[i].pix_fmt) {
+ if (track->par->format == mov_pix_fmt_tags[i].pix_fmt) {
tag = mov_pix_fmt_tags[i].tag;
- track->enc->bits_per_coded_sample = mov_pix_fmt_tags[i].bps;
- if (track->enc->codec_tag == mov_pix_fmt_tags[i].tag)
+ track->par->bits_per_coded_sample = mov_pix_fmt_tags[i].bps;
+ if (track->par->codec_tag == mov_pix_fmt_tags[i].tag)
break;
}
}
pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_mov,
- track->enc->bits_per_coded_sample);
+ track->par->bits_per_coded_sample);
if (tag == MKTAG('r','a','w',' ') &&
- track->enc->pix_fmt != pix_fmt &&
- track->enc->pix_fmt != AV_PIX_FMT_NONE)
+ track->par->format != pix_fmt &&
+ track->par->format != AV_PIX_FMT_NONE)
av_log(s, AV_LOG_ERROR, "%s rawvideo cannot be written to mov, output file will be unreadable\n",
- av_get_pix_fmt_name(track->enc->pix_fmt));
+ av_get_pix_fmt_name(track->par->format));
return tag;
}
static int mov_get_codec_tag(AVFormatContext *s, MOVTrack *track)
{
- int tag = track->enc->codec_tag;
+ int tag = track->par->codec_tag;
if (!tag || (s->strict_std_compliance >= FF_COMPLIANCE_NORMAL &&
- (track->enc->codec_id == AV_CODEC_ID_DVVIDEO ||
- track->enc->codec_id == AV_CODEC_ID_RAWVIDEO ||
- track->enc->codec_id == AV_CODEC_ID_H263 ||
- track->enc->codec_id == AV_CODEC_ID_H264 ||
- track->enc->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
- av_get_bits_per_sample(track->enc->codec_id)))) { // pcm audio
- if (track->enc->codec_id == AV_CODEC_ID_DVVIDEO)
+ (track->par->codec_id == AV_CODEC_ID_DVVIDEO ||
+ track->par->codec_id == AV_CODEC_ID_RAWVIDEO ||
+ track->par->codec_id == AV_CODEC_ID_H263 ||
+ track->par->codec_id == AV_CODEC_ID_H264 ||
+ track->par->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
+ av_get_bits_per_sample(track->par->codec_id)))) { // pcm audio
+ if (track->par->codec_id == AV_CODEC_ID_DVVIDEO)
tag = mov_get_dv_codec_tag(s, track);
- else if (track->enc->codec_id == AV_CODEC_ID_RAWVIDEO)
+ else if (track->par->codec_id == AV_CODEC_ID_RAWVIDEO)
tag = mov_get_rawvideo_codec_tag(s, track);
- else if (track->enc->codec_id == AV_CODEC_ID_MPEG2VIDEO)
+ else if (track->par->codec_id == AV_CODEC_ID_MPEG2VIDEO)
tag = mov_get_mpeg2_xdcam_codec_tag(s, track);
- else if (track->enc->codec_id == AV_CODEC_ID_H264)
+ else if (track->par->codec_id == AV_CODEC_ID_H264)
tag = mov_get_h264_codec_tag(s, track);
- else if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) {
- tag = ff_codec_get_tag(ff_codec_movvideo_tags, track->enc->codec_id);
+ else if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) {
+ tag = ff_codec_get_tag(ff_codec_movvideo_tags, track->par->codec_id);
if (!tag) { // if no mac fcc found, try with Microsoft tags
- tag = ff_codec_get_tag(ff_codec_bmp_tags, track->enc->codec_id);
+ tag = ff_codec_get_tag(ff_codec_bmp_tags, track->par->codec_id);
if (tag)
av_log(s, AV_LOG_WARNING, "Using MS style video codec tag, "
"the file may be unplayable!\n");
}
- } else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) {
- tag = ff_codec_get_tag(ff_codec_movaudio_tags, track->enc->codec_id);
+ } else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO) {
+ tag = ff_codec_get_tag(ff_codec_movaudio_tags, track->par->codec_id);
if (!tag) { // if no mac fcc found, try with Microsoft tags
- int ms_tag = ff_codec_get_tag(ff_codec_wav_tags, track->enc->codec_id);
+ int ms_tag = ff_codec_get_tag(ff_codec_wav_tags, track->par->codec_id);
if (ms_tag) {
tag = MKTAG('m', 's', ((ms_tag >> 8) & 0xff), (ms_tag & 0xff));
av_log(s, AV_LOG_WARNING, "Using MS style audio codec tag, "
"the file may be unplayable!\n");
}
}
- } else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE)
- tag = ff_codec_get_tag(ff_codec_movsubtitle_tags, track->enc->codec_id);
+ } else if (track->par->codec_type == AVMEDIA_TYPE_SUBTITLE)
+ tag = ff_codec_get_tag(ff_codec_movsubtitle_tags, track->par->codec_id);
}
return tag;
@@ -1462,14 +1467,14 @@ static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track)
tag = mp4_get_codec_tag(s, track);
else if (track->mode == MODE_ISM) {
tag = mp4_get_codec_tag(s, track);
- if (!tag && track->enc->codec_id == AV_CODEC_ID_WMAPRO)
+ if (!tag && track->par->codec_id == AV_CODEC_ID_WMAPRO)
tag = MKTAG('w', 'm', 'a', ' ');
} else if (track->mode == MODE_IPOD)
tag = ipod_get_codec_tag(s, track);
else if (track->mode & MODE_3GP)
- tag = ff_codec_get_tag(codec_3gp_tags, track->enc->codec_id);
+ tag = ff_codec_get_tag(codec_3gp_tags, track->par->codec_id);
else if (track->mode == MODE_F4V)
- tag = ff_codec_get_tag(codec_f4v_tags, track->enc->codec_id);
+ tag = ff_codec_get_tag(codec_f4v_tags, track->par->codec_id);
else
tag = mov_get_codec_tag(s, track);
@@ -1496,11 +1501,11 @@ static const uint16_t fiel_data[] = {
0x0000, 0x0100, 0x0201, 0x0206, 0x0209, 0x020e
};
-static int mov_write_fiel_tag(AVIOContext *pb, MOVTrack *track)
+static int mov_write_fiel_tag(AVIOContext *pb, MOVTrack *track, int field_order)
{
unsigned mov_field_order = 0;
- if (track->enc->field_order < FF_ARRAY_ELEMS(fiel_data))
- mov_field_order = fiel_data[track->enc->field_order];
+ if (field_order < FF_ARRAY_ELEMS(fiel_data))
+ mov_field_order = fiel_data[field_order];
else
return 0;
avio_wb32(pb, 10);
@@ -1518,10 +1523,10 @@ static int mov_write_subtitle_tag(AVIOContext *pb, MOVTrack *track)
avio_wb16(pb, 0); /* Reserved */
avio_wb16(pb, 1); /* Data-reference index */
- if (track->enc->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
+ if (track->par->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
mov_write_esds_tag(pb, track);
- else if (track->enc->extradata_size)
- avio_write(pb, track->enc->extradata, track->enc->extradata_size);
+ else if (track->par->extradata_size)
+ avio_write(pb, track->par->extradata, track->par->extradata_size);
return update_size(pb, pos);
}
@@ -1529,8 +1534,8 @@ static int mov_write_subtitle_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_pasp_tag(AVIOContext *pb, MOVTrack *track)
{
AVRational sar;
- av_reduce(&sar.num, &sar.den, track->enc->sample_aspect_ratio.num,
- track->enc->sample_aspect_ratio.den, INT_MAX);
+ av_reduce(&sar.num, &sar.den, track->par->sample_aspect_ratio.num,
+ track->par->sample_aspect_ratio.den, INT_MAX);
avio_wb32(pb, 16);
ffio_wfourcc(pb, "pasp");
@@ -1544,7 +1549,7 @@ static int mov_write_gama_tag(AVIOContext *pb, MOVTrack *track, double gamma)
uint32_t gama = 0;
if (gamma <= 0.0)
{
- gamma = avpriv_get_gamma_from_trc(track->enc->color_trc);
+ gamma = avpriv_get_gamma_from_trc(track->par->color_trc);
}
av_log(pb, AV_LOG_DEBUG, "gamma value %g\n", gamma);
@@ -1569,32 +1574,32 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack *track)
// Ref (MOV): https://developer.apple.com/library/mac/technotes/tn2162/_index.html#//apple_ref/doc/uid/DTS40013070-CH1-TNTAG9
// Ref (MP4): ISO/IEC 14496-12:2012
- if (track->enc->color_primaries == AVCOL_PRI_UNSPECIFIED &&
- track->enc->color_trc == AVCOL_TRC_UNSPECIFIED &&
- track->enc->colorspace == AVCOL_SPC_UNSPECIFIED) {
- if ((track->enc->width >= 1920 && track->enc->height >= 1080)
- || (track->enc->width == 1280 && track->enc->height == 720)) {
+ if (track->par->color_primaries == AVCOL_PRI_UNSPECIFIED &&
+ track->par->color_trc == AVCOL_TRC_UNSPECIFIED &&
+ track->par->color_space == AVCOL_SPC_UNSPECIFIED) {
+ if ((track->par->width >= 1920 && track->par->height >= 1080)
+ || (track->par->width == 1280 && track->par->height == 720)) {
av_log(NULL, AV_LOG_WARNING, "color primaries unspecified, assuming bt709\n");
- track->enc->color_primaries = AVCOL_PRI_BT709;
- } else if (track->enc->width == 720 && track->height == 576) {
+ track->par->color_primaries = AVCOL_PRI_BT709;
+ } else if (track->par->width == 720 && track->height == 576) {
av_log(NULL, AV_LOG_WARNING, "color primaries unspecified, assuming bt470bg\n");
- track->enc->color_primaries = AVCOL_PRI_BT470BG;
- } else if (track->enc->width == 720 &&
+ track->par->color_primaries = AVCOL_PRI_BT470BG;
+ } else if (track->par->width == 720 &&
(track->height == 486 || track->height == 480)) {
av_log(NULL, AV_LOG_WARNING, "color primaries unspecified, assuming smpte170\n");
- track->enc->color_primaries = AVCOL_PRI_SMPTE170M;
+ track->par->color_primaries = AVCOL_PRI_SMPTE170M;
} else {
av_log(NULL, AV_LOG_WARNING, "color primaries unspecified, unable to assume anything\n");
}
- switch (track->enc->color_primaries) {
+ switch (track->par->color_primaries) {
case AVCOL_PRI_BT709:
- track->enc->color_trc = AVCOL_TRC_BT709;
- track->enc->colorspace = AVCOL_SPC_BT709;
+ track->par->color_trc = AVCOL_TRC_BT709;
+ track->par->color_space = AVCOL_SPC_BT709;
break;
case AVCOL_PRI_SMPTE170M:
case AVCOL_PRI_BT470BG:
- track->enc->color_trc = AVCOL_TRC_BT709;
- track->enc->colorspace = AVCOL_SPC_SMPTE170M;
+ track->par->color_trc = AVCOL_TRC_BT709;
+ track->par->color_space = AVCOL_SPC_SMPTE170M;
break;
}
}
@@ -1608,20 +1613,20 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack *track)
ffio_wfourcc(pb, "nclx");
else
ffio_wfourcc(pb, "nclc");
- switch (track->enc->color_primaries) {
+ switch (track->par->color_primaries) {
case AVCOL_PRI_BT709: avio_wb16(pb, 1); break;
case AVCOL_PRI_SMPTE170M:
case AVCOL_PRI_SMPTE240M: avio_wb16(pb, 6); break;
case AVCOL_PRI_BT470BG: avio_wb16(pb, 5); break;
default: avio_wb16(pb, 2);
}
- switch (track->enc->color_trc) {
+ switch (track->par->color_trc) {
case AVCOL_TRC_BT709: avio_wb16(pb, 1); break;
case AVCOL_TRC_SMPTE170M: avio_wb16(pb, 1); break; // remapped
case AVCOL_TRC_SMPTE240M: avio_wb16(pb, 7); break;
default: avio_wb16(pb, 2);
}
- switch (track->enc->colorspace) {
+ switch (track->par->color_space) {
case AVCOL_SPC_BT709: avio_wb16(pb, 1); break;
case AVCOL_SPC_BT470BG:
case AVCOL_SPC_SMPTE170M: avio_wb16(pb, 6); break;
@@ -1630,7 +1635,7 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack *track)
}
if (track->mode == MODE_MP4) {
- int full_range = track->enc->color_range == AVCOL_RANGE_JPEG;
+ int full_range = track->par->color_range == AVCOL_RANGE_JPEG;
avio_w8(pb, full_range << 7);
return 19;
} else {
@@ -1641,26 +1646,26 @@ static int mov_write_colr_tag(AVIOContext *pb, MOVTrack *track)
static void find_compressor(char * compressor_name, int len, MOVTrack *track)
{
AVDictionaryEntry *encoder;
- int xdcam_res = (track->enc->width == 1280 && track->enc->height == 720)
- || (track->enc->width == 1440 && track->enc->height == 1080)
- || (track->enc->width == 1920 && track->enc->height == 1080);
+ int xdcam_res = (track->par->width == 1280 && track->par->height == 720)
+ || (track->par->width == 1440 && track->par->height == 1080)
+ || (track->par->width == 1920 && track->par->height == 1080);
if (track->mode == MODE_MOV &&
(encoder = av_dict_get(track->st->metadata, "encoder", NULL, 0))) {
av_strlcpy(compressor_name, encoder->value, 32);
- } else if (track->enc->codec_id == AV_CODEC_ID_MPEG2VIDEO && xdcam_res) {
- int interlaced = track->enc->field_order > AV_FIELD_PROGRESSIVE;
+ } else if (track->par->codec_id == AV_CODEC_ID_MPEG2VIDEO && xdcam_res) {
+ int interlaced = track->par->field_order > AV_FIELD_PROGRESSIVE;
AVStream *st = track->st;
int rate = av_q2d(find_fps(NULL, st));
av_strlcatf(compressor_name, len, "XDCAM");
- if (track->enc->pix_fmt == AV_PIX_FMT_YUV422P) {
+ if (track->par->format == AV_PIX_FMT_YUV422P) {
av_strlcatf(compressor_name, len, " HD422");
- } else if(track->enc->width == 1440) {
+ } else if(track->par->width == 1440) {
av_strlcatf(compressor_name, len, " HD");
} else
av_strlcatf(compressor_name, len, " EX");
- av_strlcatf(compressor_name, len, " %d%c", track->enc->height, interlaced ? 'i' : 'p');
+ av_strlcatf(compressor_name, len, " %d%c", track->par->height, interlaced ? 'i' : 'p');
av_strlcatf(compressor_name, len, "%d", rate * (interlaced + 1));
}
@@ -1686,7 +1691,7 @@ static int mov_write_video_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *tr
avio_wb16(pb, 0); /* Codec stream revision (=0) */
if (track->mode == MODE_MOV) {
ffio_wfourcc(pb, "FFMP"); /* Vendor */
- if (track->enc->codec_id == AV_CODEC_ID_RAWVIDEO) {
+ if (track->par->codec_id == AV_CODEC_ID_RAWVIDEO) {
avio_wb32(pb, 0); /* Temporal Quality */
avio_wb32(pb, 0x400); /* Spatial Quality = lossless*/
} else {
@@ -1698,7 +1703,7 @@ static int mov_write_video_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *tr
avio_wb32(pb, 0); /* Reserved */
avio_wb32(pb, 0); /* Reserved */
}
- avio_wb16(pb, track->enc->width); /* Video width */
+ avio_wb16(pb, track->par->width); /* Video width */
avio_wb16(pb, track->height); /* Video height */
avio_wb32(pb, 0x00480000); /* Horizontal resolution 72dpi */
avio_wb32(pb, 0x00480000); /* Vertical resolution 72dpi */
@@ -1710,14 +1715,14 @@ static int mov_write_video_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *tr
avio_w8(pb, strlen(compressor_name));
avio_write(pb, compressor_name, 31);
- if (track->mode == MODE_MOV && track->enc->bits_per_coded_sample)
- avio_wb16(pb, track->enc->bits_per_coded_sample |
- (track->enc->pix_fmt == AV_PIX_FMT_GRAY8 ? 0x20 : 0));
+ if (track->mode == MODE_MOV && track->par->bits_per_coded_sample)
+ avio_wb16(pb, track->par->bits_per_coded_sample |
+ (track->par->format == AV_PIX_FMT_GRAY8 ? 0x20 : 0));
else
avio_wb16(pb, 0x18); /* Reserved */
- if (track->mode == MODE_MOV && track->enc->pix_fmt == AV_PIX_FMT_PAL8) {
- int pal_size = 1 << track->enc->bits_per_coded_sample;
+ if (track->mode == MODE_MOV && track->par->format == AV_PIX_FMT_PAL8) {
+ int pal_size = 1 << track->par->bits_per_coded_sample;
int i;
avio_wb16(pb, 0); /* Color table ID */
avio_wb32(pb, 0); /* Color table seed */
@@ -1738,38 +1743,48 @@ static int mov_write_video_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *tr
if (track->tag == MKTAG('m','p','4','v'))
mov_write_esds_tag(pb, track);
- else if (track->enc->codec_id == AV_CODEC_ID_H263)
+ else if (track->par->codec_id == AV_CODEC_ID_H263)
mov_write_d263_tag(pb);
- else if (track->enc->codec_id == AV_CODEC_ID_AVUI ||
- track->enc->codec_id == AV_CODEC_ID_SVQ3) {
+ else if (track->par->codec_id == AV_CODEC_ID_AVUI ||
+ track->par->codec_id == AV_CODEC_ID_SVQ3) {
mov_write_extradata_tag(pb, track);
avio_wb32(pb, 0);
- } else if (track->enc->codec_id == AV_CODEC_ID_DNXHD) {
+ } else if (track->par->codec_id == AV_CODEC_ID_DNXHD) {
mov_write_avid_tag(pb, track);
avid = 1;
- } else if (track->enc->codec_id == AV_CODEC_ID_HEVC)
+ } else if (track->par->codec_id == AV_CODEC_ID_HEVC)
mov_write_hvcc_tag(pb, track);
- else if (track->enc->codec_id == AV_CODEC_ID_H264 && !TAG_IS_AVCI(track->tag)) {
+ else if (track->par->codec_id == AV_CODEC_ID_H264 && !TAG_IS_AVCI(track->tag)) {
mov_write_avcc_tag(pb, track);
if (track->mode == MODE_IPOD)
mov_write_uuid_tag_ipod(pb);
- } else if (track->enc->codec_id == AV_CODEC_ID_VC1 && track->vos_len > 0)
+ } else if (track->par->codec_id == AV_CODEC_ID_VC1 && track->vos_len > 0)
mov_write_dvc1_tag(pb, track);
- else if (track->enc->codec_id == AV_CODEC_ID_VP6F ||
- track->enc->codec_id == AV_CODEC_ID_VP6A) {
+ else if (track->par->codec_id == AV_CODEC_ID_VP6F ||
+ track->par->codec_id == AV_CODEC_ID_VP6A) {
/* Don't write any potential extradata here - the cropping
* is signalled via the normal width/height fields. */
- } else if (track->enc->codec_id == AV_CODEC_ID_R10K) {
- if (track->enc->codec_tag == MKTAG('R','1','0','k'))
+ } else if (track->par->codec_id == AV_CODEC_ID_R10K) {
+ if (track->par->codec_tag == MKTAG('R','1','0','k'))
mov_write_dpxe_tag(pb, track);
} else if (track->vos_len > 0)
mov_write_glbl_tag(pb, track);
- if (track->enc->codec_id != AV_CODEC_ID_H264 &&
- track->enc->codec_id != AV_CODEC_ID_MPEG4 &&
- track->enc->codec_id != AV_CODEC_ID_DNXHD)
- if (track->enc->field_order != AV_FIELD_UNKNOWN)
- mov_write_fiel_tag(pb, track);
+ if (track->par->codec_id != AV_CODEC_ID_H264 &&
+ track->par->codec_id != AV_CODEC_ID_MPEG4 &&
+ track->par->codec_id != AV_CODEC_ID_DNXHD) {
+ int field_order = track->par->field_order;
+
+#if FF_API_LAVF_AVCTX
+ FF_DISABLE_DEPRECATION_WARNINGS
+ if (field_order != track->st->codec->field_order && track->st->codec->field_order != AV_FIELD_UNKNOWN)
+ field_order = track->st->codec->field_order;
+ FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ if (field_order != AV_FIELD_UNKNOWN)
+ mov_write_fiel_tag(pb, track, field_order);
+ }
if (mov->flags & FF_MOV_FLAG_WRITE_GAMA) {
if (track->mode == MODE_MOV)
@@ -1784,8 +1799,8 @@ static int mov_write_video_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *tr
av_log(mov->fc, AV_LOG_WARNING, "Not writing 'colr' atom. Format is not MOV or MP4.\n");
}
- if (track->enc->sample_aspect_ratio.den && track->enc->sample_aspect_ratio.num &&
- track->enc->sample_aspect_ratio.den != track->enc->sample_aspect_ratio.num) {
+ if (track->par->sample_aspect_ratio.den && track->par->sample_aspect_ratio.num &&
+ track->par->sample_aspect_ratio.den != track->par->sample_aspect_ratio.num) {
mov_write_pasp_tag(pb, track);
}
@@ -1844,10 +1859,25 @@ static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
#if 1
- int frame_duration = av_rescale(track->timescale, track->enc->time_base.num, track->enc->time_base.den);
- int nb_frames = ROUNDED_DIV(track->enc->time_base.den, track->enc->time_base.num);
+ int frame_duration;
+ int nb_frames;
AVDictionaryEntry *t = NULL;
+ if (!track->st->avg_frame_rate.num || !track->st->avg_frame_rate.den) {
+#if FF_API_LAVF_AVCTX
+ FF_DISABLE_DEPRECATION_WARNINGS
+ frame_duration = av_rescale(track->timescale, track->st->codec->time_base.num, track->st->codec->time_base.den);
+ nb_frames = ROUNDED_DIV(track->st->codec->time_base.den, track->st->codec->time_base.num);
+ FF_ENABLE_DEPRECATION_WARNINGS
+#else
+ av_log(NULL, AV_LOG_ERROR, "avg_frame_rate not set for tmcd track.\n");
+ return AVERROR(EINVAL);
+#endif
+ } else {
+ frame_duration = av_rescale(track->timescale, track->st->avg_frame_rate.num, track->st->avg_frame_rate.den);
+ nb_frames = ROUNDED_DIV(track->st->avg_frame_rate.den, track->st->avg_frame_rate.num);
+ }
+
if (nb_frames > 255) {
av_log(NULL, AV_LOG_ERROR, "fps %d is too large\n", nb_frames);
return AVERROR(EINVAL);
@@ -1877,28 +1907,28 @@ static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track)
ffio_wfourcc(pb, "tmcd"); /* Data format */
avio_wb32(pb, 0); /* Reserved */
avio_wb32(pb, 1); /* Data reference index */
- if (track->enc->extradata_size)
- avio_write(pb, track->enc->extradata, track->enc->extradata_size);
+ if (track->par->extradata_size)
+ avio_write(pb, track->par->extradata, track->par->extradata_size);
#endif
return update_size(pb, pos);
}
-static int mov_write_stsd_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track)
+static int mov_write_stsd_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
avio_wb32(pb, 0); /* size */
ffio_wfourcc(pb, "stsd");
avio_wb32(pb, 0); /* version & flags */
avio_wb32(pb, 1); /* entry count */
- if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO)
+ if (track->par->codec_type == AVMEDIA_TYPE_VIDEO)
mov_write_video_tag(pb, mov, track);
- else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
- mov_write_audio_tag(pb, mov, track);
- else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE)
+ else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO)
+ mov_write_audio_tag(s, pb, mov, track);
+ else if (track->par->codec_type == AVMEDIA_TYPE_SUBTITLE)
mov_write_subtitle_tag(pb, track);
- else if (track->enc->codec_tag == MKTAG('r','t','p',' '))
+ else if (track->par->codec_tag == MKTAG('r','t','p',' '))
mov_write_rtp_tag(pb, track);
- else if (track->enc->codec_tag == MKTAG('t','m','c','d'))
+ else if (track->par->codec_tag == MKTAG('t','m','c','d'))
mov_write_tmcd_tag(pb, track);
return update_size(pb, pos);
}
@@ -1946,7 +1976,7 @@ static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track)
uint32_t atom_size;
int i;
- if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO && !track->audio_vbr) {
+ if (track->par->codec_type == AVMEDIA_TYPE_AUDIO && !track->audio_vbr) {
stts_entries = av_malloc(sizeof(*stts_entries)); /* one entry */
if (!stts_entries)
return AVERROR(ENOMEM);
@@ -1999,22 +2029,22 @@ static int mov_write_dref_tag(AVIOContext *pb)
return 28;
}
-static int mov_write_stbl_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track)
+static int mov_write_stbl_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
int ret;
avio_wb32(pb, 0); /* size */
ffio_wfourcc(pb, "stbl");
- mov_write_stsd_tag(pb, mov, track);
+ mov_write_stsd_tag(s, pb, mov, track);
mov_write_stts_tag(pb, track);
- if ((track->enc->codec_type == AVMEDIA_TYPE_VIDEO ||
- track->enc->codec_tag == MKTAG('r','t','p',' ')) &&
+ if ((track->par->codec_type == AVMEDIA_TYPE_VIDEO ||
+ track->par->codec_tag == MKTAG('r','t','p',' ')) &&
track->has_keyframes && track->has_keyframes < track->entry)
mov_write_stss_tag(pb, track, MOV_SYNC_SAMPLE);
if (track->mode == MODE_MOV && track->flags & MOV_TRACK_STPS)
mov_write_stss_tag(pb, track, MOV_PARTIAL_SYNC_SAMPLE);
- if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO &&
+ if (track->par->codec_type == AVMEDIA_TYPE_VIDEO &&
track->flags & MOV_TRACK_CTTS && track->entry) {
if ((ret = mov_write_ctts_tag(pb, track)) < 0)
@@ -2104,7 +2134,7 @@ static int mov_write_gmhd_tag(AVIOContext *pb, MOVTrack *track)
avio_wb16(pb, 0x0000);
}
- if (track->enc->codec_tag == MKTAG('t','m','c','d')) {
+ if (track->par->codec_tag == MKTAG('t','m','c','d')) {
int64_t tmcd_pos = avio_tell(pb);
avio_wb32(pb, 0); /* size */
ffio_wfourcc(pb, "tmcd");
@@ -2139,7 +2169,7 @@ static int is_clcp_track(MOVTrack *track)
track->tag == MKTAG('c','6','0','8');
}
-static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack *track)
+static int mov_write_hdlr_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track)
{
const char *hdlr, *descr = NULL, *hdlr_type = NULL;
int64_t pos = avio_tell(pb);
@@ -2150,13 +2180,13 @@ static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack *track)
if (track) {
hdlr = (track->mode == MODE_MOV) ? "mhlr" : "\0\0\0\0";
- if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) {
hdlr_type = "vide";
descr = "VideoHandler";
- } else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) {
+ } else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO) {
hdlr_type = "soun";
descr = "SoundHandler";
- } else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ } else if (track->par->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if (is_clcp_track(track)) {
hdlr_type = "clcp";
descr = "ClosedCaptionHandler";
@@ -2170,20 +2200,20 @@ static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack *track)
}
descr = "SubtitleHandler";
}
- } else if (track->enc->codec_tag == MKTAG('r','t','p',' ')) {
+ } else if (track->par->codec_tag == MKTAG('r','t','p',' ')) {
hdlr_type = "hint";
descr = "HintHandler";
- } else if (track->enc->codec_tag == MKTAG('t','m','c','d')) {
+ } else if (track->par->codec_tag == MKTAG('t','m','c','d')) {
hdlr_type = "tmcd";
descr = "TimeCodeHandler";
} else {
char tag_buf[32];
av_get_codec_tag_string(tag_buf, sizeof(tag_buf),
- track->enc->codec_tag);
+ track->par->codec_tag);
- av_log(track->enc, AV_LOG_WARNING,
+ av_log(s, AV_LOG_WARNING,
"Unknown hldr_type for %s / 0x%04X, writing dummy values\n",
- tag_buf, track->enc->codec_tag);
+ tag_buf, track->par->codec_tag);
}
if (track->st) {
// hdlr.name is used by some players to identify the content title
@@ -2227,18 +2257,18 @@ static int mov_write_hmhd_tag(AVIOContext *pb)
return 28;
}
-static int mov_write_minf_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track)
+static int mov_write_minf_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
int ret;
avio_wb32(pb, 0); /* size */
ffio_wfourcc(pb, "minf");
- if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO)
+ if (track->par->codec_type == AVMEDIA_TYPE_VIDEO)
mov_write_vmhd_tag(pb);
- else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
+ else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO)
mov_write_smhd_tag(pb);
- else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ else if (track->par->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if (track->tag == MKTAG('t','e','x','t') || is_clcp_track(track)) {
mov_write_gmhd_tag(pb, track);
} else {
@@ -2253,9 +2283,9 @@ static int mov_write_minf_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *tra
mov_write_gmhd_tag(pb, track);
}
if (track->mode == MODE_MOV) /* FIXME: Why do it for MODE_MOV only ? */
- mov_write_hdlr_tag(pb, NULL);
+ mov_write_hdlr_tag(s, pb, NULL);
mov_write_dinf_tag(pb);
- if ((ret = mov_write_stbl_tag(pb, mov, track)) < 0)
+ if ((ret = mov_write_stbl_tag(s, pb, mov, track)) < 0)
return ret;
return update_size(pb, pos);
}
@@ -2299,8 +2329,8 @@ static int mov_write_mdhd_tag(AVIOContext *pb, MOVMuxContext *mov,
return 32;
}
-static int mov_write_mdia_tag(AVIOContext *pb, MOVMuxContext *mov,
- MOVTrack *track)
+static int mov_write_mdia_tag(AVFormatContext *s, AVIOContext *pb,
+ MOVMuxContext *mov, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
int ret;
@@ -2308,8 +2338,8 @@ static int mov_write_mdia_tag(AVIOContext *pb, MOVMuxContext *mov,
avio_wb32(pb, 0); /* size */
ffio_wfourcc(pb, "mdia");
mov_write_mdhd_tag(pb, mov, track);
- mov_write_hdlr_tag(pb, track);
- if ((ret = mov_write_minf_tag(pb, mov, track)) < 0)
+ mov_write_hdlr_tag(s, pb, track);
+ if ((ret = mov_write_minf_tag(s, pb, mov, track)) < 0)
return ret;
return update_size(pb, pos);
}
@@ -2349,7 +2379,7 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov,
if (mov->per_stream_grouping)
group = st->index;
else
- group = st->codec->codec_type;
+ group = st->codecpar->codec_type;
display_matrix = (uint32_t*)av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX,
&display_matrix_size);
@@ -2388,7 +2418,7 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov,
avio_wb16(pb, 0); /* layer */
avio_wb16(pb, group); /* alternate group) */
/* Volume, only for audio */
- if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
+ if (track->par->codec_type == AVMEDIA_TYPE_AUDIO)
avio_wb16(pb, 0x0100);
else
avio_wb16(pb, 0);
@@ -2403,28 +2433,28 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov,
for (i = 0; i < 9; i++)
avio_wb32(pb, display_matrix[i]);
} else if (rotation == 90) {
- write_matrix(pb, 0, 1, -1, 0, track->enc->height, 0);
+ write_matrix(pb, 0, 1, -1, 0, track->par->height, 0);
} else if (rotation == 180) {
- write_matrix(pb, -1, 0, 0, -1, track->enc->width, track->enc->height);
+ write_matrix(pb, -1, 0, 0, -1, track->par->width, track->par->height);
} else if (rotation == 270) {
- write_matrix(pb, 0, -1, 1, 0, 0, track->enc->width);
+ write_matrix(pb, 0, -1, 1, 0, 0, track->par->width);
} else {
write_matrix(pb, 1, 0, 0, 1, 0, 0);
}
/* Track width and height, for visual only */
- if (st && (track->enc->codec_type == AVMEDIA_TYPE_VIDEO ||
- track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
+ if (st && (track->par->codec_type == AVMEDIA_TYPE_VIDEO ||
+ track->par->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
if (track->mode == MODE_MOV) {
- avio_wb32(pb, track->enc->width << 16);
+ avio_wb32(pb, track->par->width << 16);
avio_wb32(pb, track->height << 16);
} else {
int64_t track_width_1616 = av_rescale(st->sample_aspect_ratio.num,
- track->enc->width * 0x10000LL,
+ track->par->width * 0x10000LL,
st->sample_aspect_ratio.den);
if (!track_width_1616 ||
- track->height != track->enc->height ||
+ track->height != track->par->height ||
track_width_1616 > UINT32_MAX)
- track_width_1616 = track->enc->width * 0x10000U;
+ track_width_1616 = track->par->width * 0x10000U;
avio_wb32(pb, track_width_1616);
avio_wb32(pb, track->height * 0x10000U);
}
@@ -2437,8 +2467,8 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov,
static int mov_write_tapt_tag(AVIOContext *pb, MOVTrack *track)
{
- int32_t width = av_rescale(track->enc->sample_aspect_ratio.num, track->enc->width,
- track->enc->sample_aspect_ratio.den);
+ int32_t width = av_rescale(track->par->sample_aspect_ratio.num, track->par->width,
+ track->par->sample_aspect_ratio.den);
int64_t pos = avio_tell(pb);
@@ -2449,19 +2479,19 @@ static int mov_write_tapt_tag(AVIOContext *pb, MOVTrack *track)
ffio_wfourcc(pb, "clef");
avio_wb32(pb, 0);
avio_wb32(pb, width << 16);
- avio_wb32(pb, track->enc->height << 16);
+ avio_wb32(pb, track->par->height << 16);
avio_wb32(pb, 20);
ffio_wfourcc(pb, "prof");
avio_wb32(pb, 0);
avio_wb32(pb, width << 16);
- avio_wb32(pb, track->enc->height << 16);
+ avio_wb32(pb, track->par->height << 16);
avio_wb32(pb, 20);
ffio_wfourcc(pb, "enof");
avio_wb32(pb, 0);
- avio_wb32(pb, track->enc->width << 16);
- avio_wb32(pb, track->enc->height << 16);
+ avio_wb32(pb, track->par->width << 16);
+ avio_wb32(pb, track->par->height << 16);
return update_size(pb, pos);
}
@@ -2643,7 +2673,7 @@ static int mov_write_track_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
return 0;
}
-static int mov_write_trak_tag(AVIOContext *pb, MOVMuxContext *mov,
+static int mov_write_trak_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext *mov,
MOVTrack *track, AVStream *st)
{
int64_t pos = avio_tell(pb);
@@ -2673,14 +2703,14 @@ static int mov_write_trak_tag(AVIOContext *pb, MOVMuxContext *mov,
if (track->tref_tag)
mov_write_tref_tag(pb, track);
- if ((ret = mov_write_mdia_tag(pb, mov, track)) < 0)
+ if ((ret = mov_write_mdia_tag(s, pb, mov, track)) < 0)
return ret;
if (track->mode == MODE_PSP)
mov_write_uuid_tag_psp(pb, track); // PSP Movies require this uuid box
if (track->tag == MKTAG('r','t','p',' '))
mov_write_udta_sdp(pb, track);
if (track->mode == MODE_MOV) {
- if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) {
double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio);
if (st->sample_aspect_ratio.num && 1.0 != sample_aspect_ratio) {
mov_write_tapt_tag(pb, track);
@@ -2704,8 +2734,8 @@ static int mov_write_iods_tag(AVIOContext *pb, MOVMuxContext *mov)
int video_profile = mov->iods_video_profile;
for (i = 0; i < mov->nb_streams; i++) {
if (mov->tracks[i].entry > 0 || mov->flags & FF_MOV_FLAG_EMPTY_MOOV) {
- has_audio |= mov->tracks[i].enc->codec_type == AVMEDIA_TYPE_AUDIO;
- has_video |= mov->tracks[i].enc->codec_type == AVMEDIA_TYPE_VIDEO;
+ has_audio |= mov->tracks[i].par->codec_type == AVMEDIA_TYPE_AUDIO;
+ has_video |= mov->tracks[i].par->codec_type == AVMEDIA_TYPE_VIDEO;
}
}
if (audio_profile < 0)
@@ -3254,7 +3284,7 @@ static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov,
if (track->tag == MKTAG('r','t','p',' ')) {
track->tref_tag = MKTAG('h','i','n','t');
track->tref_id = mov->tracks[track->src_track].track_id;
- } else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) {
+ } else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO) {
int * fallback, size;
fallback = (int*)av_stream_get_side_data(track->st,
AV_PKT_DATA_FALLBACK_TRACK,
@@ -3284,7 +3314,7 @@ static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov,
mov_write_iods_tag(pb, mov);
for (i = 0; i < mov->nb_streams; i++) {
if (mov->tracks[i].entry > 0 || mov->flags & FF_MOV_FLAG_FRAGMENT) {
- int ret = mov_write_trak_tag(pb, mov, &(mov->tracks[i]), i < s->nb_streams ? s->streams[i] : NULL);
+ int ret = mov_write_trak_tag(s, pb, mov, &(mov->tracks[i]), i < s->nb_streams ? s->streams[i] : NULL);
if (ret < 0)
return ret;
}
@@ -3349,41 +3379,41 @@ static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov)
* here yet */
int track_id = i + 1;
- if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) {
type = "video";
- } else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) {
+ } else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO) {
type = "audio";
} else {
continue;
}
avio_printf(pb, "<%s systemBitrate=\"%"PRId64"\">\n", type,
- (int64_t)track->enc->bit_rate);
- param_write_int(pb, "systemBitrate", track->enc->bit_rate);
+ (int64_t)track->par->bit_rate);
+ param_write_int(pb, "systemBitrate", track->par->bit_rate);
param_write_int(pb, "trackID", track_id);
- if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) {
- if (track->enc->codec_id == AV_CODEC_ID_H264) {
+ if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (track->par->codec_id == AV_CODEC_ID_H264) {
uint8_t *ptr;
- int size = track->enc->extradata_size;
- if (!ff_avc_write_annexb_extradata(track->enc->extradata, &ptr,
+ int size = track->par->extradata_size;
+ if (!ff_avc_write_annexb_extradata(track->par->extradata, &ptr,
&size)) {
param_write_hex(pb, "CodecPrivateData",
- ptr ? ptr : track->enc->extradata,
+ ptr ? ptr : track->par->extradata,
size);
av_free(ptr);
}
param_write_string(pb, "FourCC", "H264");
- } else if (track->enc->codec_id == AV_CODEC_ID_VC1) {
+ } else if (track->par->codec_id == AV_CODEC_ID_VC1) {
param_write_string(pb, "FourCC", "WVC1");
- param_write_hex(pb, "CodecPrivateData", track->enc->extradata,
- track->enc->extradata_size);
+ param_write_hex(pb, "CodecPrivateData", track->par->extradata,
+ track->par->extradata_size);
}
- param_write_int(pb, "MaxWidth", track->enc->width);
- param_write_int(pb, "MaxHeight", track->enc->height);
- param_write_int(pb, "DisplayWidth", track->enc->width);
- param_write_int(pb, "DisplayHeight", track->enc->height);
+ param_write_int(pb, "MaxWidth", track->par->width);
+ param_write_int(pb, "MaxHeight", track->par->height);
+ param_write_int(pb, "DisplayWidth", track->par->width);
+ param_write_int(pb, "DisplayHeight", track->par->height);
} else {
- if (track->enc->codec_id == AV_CODEC_ID_AAC) {
- switch (track->enc->profile)
+ if (track->par->codec_id == AV_CODEC_ID_AAC) {
+ switch (track->par->profile)
{
case FF_PROFILE_AAC_HE_V2:
param_write_string(pb, "FourCC", "AACP");
@@ -3394,18 +3424,18 @@ static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov)
default:
param_write_string(pb, "FourCC", "AACL");
}
- } else if (track->enc->codec_id == AV_CODEC_ID_WMAPRO) {
+ } else if (track->par->codec_id == AV_CODEC_ID_WMAPRO) {
param_write_string(pb, "FourCC", "WMAP");
}
- param_write_hex(pb, "CodecPrivateData", track->enc->extradata,
- track->enc->extradata_size);
+ param_write_hex(pb, "CodecPrivateData", track->par->extradata,
+ track->par->extradata_size);
param_write_int(pb, "AudioTag", ff_codec_get_tag(ff_codec_wav_tags,
- track->enc->codec_id));
- param_write_int(pb, "Channels", track->enc->channels);
- param_write_int(pb, "SamplingRate", track->enc->sample_rate);
+ track->par->codec_id));
+ param_write_int(pb, "Channels", track->par->channels);
+ param_write_int(pb, "SamplingRate", track->par->sample_rate);
param_write_int(pb, "BitsPerSample", 16);
- param_write_int(pb, "PacketSize", track->enc->block_align ?
- track->enc->block_align : 4);
+ param_write_int(pb, "PacketSize", track->par->block_align ?
+ track->par->block_align : 4);
}
avio_printf(pb, "</%s>\n", type);
}
@@ -3482,7 +3512,7 @@ static int mov_write_tfhd_tag(AVIOContext *pb, MOVMuxContext *mov,
track->default_sample_flags = get_sample_flags(track, &track->cluster[1]);
else
track->default_sample_flags =
- track->enc->codec_type == AVMEDIA_TYPE_VIDEO ?
+ track->par->codec_type == AVMEDIA_TYPE_VIDEO ?
(MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES | MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC) :
MOV_FRAG_SAMPLE_FLAG_DEPENDS_NO;
avio_wb32(pb, track->default_sample_flags);
@@ -3917,9 +3947,9 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
has_video = 1;
- if (st->codec->codec_id == AV_CODEC_ID_H264)
+ if (st->codecpar->codec_id == AV_CODEC_ID_H264)
has_h264 = 1;
}
@@ -3985,13 +4015,13 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
static void mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s)
{
AVStream *video_st = s->streams[0];
- AVCodecContext *video_codec = s->streams[0]->codec;
- AVCodecContext *audio_codec = s->streams[1]->codec;
- int audio_rate = audio_codec->sample_rate;
+ AVCodecParameters *video_par = s->streams[0]->codecpar;
+ AVCodecParameters *audio_par = s->streams[1]->codecpar;
+ int audio_rate = audio_par->sample_rate;
// TODO: should be avg_frame_rate
int frame_rate = ((video_st->time_base.den) * (0x10000)) / (video_st->time_base.num);
- int audio_kbitrate = audio_codec->bit_rate / 1000;
- int video_kbitrate = FFMIN(video_codec->bit_rate / 1000, 800 - audio_kbitrate);
+ int audio_kbitrate = audio_par->bit_rate / 1000;
+ int video_kbitrate = FFMIN(video_par->bit_rate / 1000, 800 - audio_kbitrate);
avio_wb32(pb, 0x94); /* size */
ffio_wfourcc(pb, "uuid");
@@ -4020,13 +4050,13 @@ static void mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s)
avio_wb32(pb, audio_kbitrate);
avio_wb32(pb, audio_kbitrate);
avio_wb32(pb, audio_rate);
- avio_wb32(pb, audio_codec->channels);
+ avio_wb32(pb, audio_par->channels);
avio_wb32(pb, 0x34); /* size */
ffio_wfourcc(pb, "VPRF"); /* video */
avio_wb32(pb, 0x0);
avio_wb32(pb, 0x1); /* TrackID */
- if (video_codec->codec_id == AV_CODEC_ID_H264) {
+ if (video_par->codec_id == AV_CODEC_ID_H264) {
ffio_wfourcc(pb, "avc1");
avio_wb16(pb, 0x014D);
avio_wb16(pb, 0x0015);
@@ -4040,8 +4070,8 @@ static void mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s)
avio_wb32(pb, video_kbitrate);
avio_wb32(pb, frame_rate);
avio_wb32(pb, frame_rate);
- avio_wb16(pb, video_codec->width);
- avio_wb16(pb, video_codec->height);
+ avio_wb16(pb, video_par->width);
+ avio_wb16(pb, video_par->height);
avio_wb32(pb, 0x010001); /* ? */
}
@@ -4055,9 +4085,9 @@ static int mov_write_identification(AVIOContext *pb, AVFormatContext *s)
int video_streams_nb = 0, audio_streams_nb = 0, other_streams_nb = 0;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
video_streams_nb++;
- else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+ else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
audio_streams_nb++;
else
other_streams_nb++;
@@ -4371,7 +4401,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
MOVMuxContext *mov = s->priv_data;
AVIOContext *pb = s->pb;
MOVTrack *trk = &mov->tracks[pkt->stream_index];
- AVCodecContext *enc = trk->enc;
+ AVCodecParameters *par = trk->par;
unsigned int samples_in_chunk = 0;
int size = pkt->size, ret = 0;
uint8_t *reformatted_data = NULL;
@@ -4415,7 +4445,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
}
}
- if (enc->codec_id == AV_CODEC_ID_AMR_NB) {
+ if (par->codec_id == AV_CODEC_ID_AMR_NB) {
/* We must find out how many AMR blocks there are in one packet */
static const uint16_t packed_size[16] =
{13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 1};
@@ -4429,28 +4459,28 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
av_log(s, AV_LOG_ERROR, "fatal error, input is not a single packet, implement a AVParser for it\n");
return -1;
}
- } else if (enc->codec_id == AV_CODEC_ID_ADPCM_MS ||
- enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {
- samples_in_chunk = enc->frame_size;
+ } else if (par->codec_id == AV_CODEC_ID_ADPCM_MS ||
+ par->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {
+ samples_in_chunk = trk->par->frame_size;
} else if (trk->sample_size)
samples_in_chunk = size / trk->sample_size;
else
samples_in_chunk = 1;
/* copy extradata if it exists */
- if (trk->vos_len == 0 && enc->extradata_size > 0 &&
+ if (trk->vos_len == 0 && par->extradata_size > 0 &&
!TAG_IS_AVCI(trk->tag) &&
- (enc->codec_id != AV_CODEC_ID_DNXHD)) {
- trk->vos_len = enc->extradata_size;
+ (par->codec_id != AV_CODEC_ID_DNXHD)) {
+ trk->vos_len = par->extradata_size;
trk->vos_data = av_malloc(trk->vos_len);
if (!trk->vos_data) {
ret = AVERROR(ENOMEM);
goto err;
}
- memcpy(trk->vos_data, enc->extradata, trk->vos_len);
+ memcpy(trk->vos_data, par->extradata, trk->vos_len);
}
- if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 &&
+ if (par->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 &&
(AV_RB16(pkt->data) & 0xfff0) == 0xfff0) {
if (!s->streams[pkt->stream_index]->nb_frames) {
av_log(s, AV_LOG_ERROR, "Malformed AAC bitstream detected: "
@@ -4460,7 +4490,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
}
av_log(s, AV_LOG_WARNING, "aac bitstream error\n");
}
- if (enc->codec_id == AV_CODEC_ID_H264 && trk->vos_len > 0 && *(uint8_t *)trk->vos_data != 1 && !TAG_IS_AVCI(trk->tag)) {
+ if (par->codec_id == AV_CODEC_ID_H264 && trk->vos_len > 0 && *(uint8_t *)trk->vos_data != 1 && !TAG_IS_AVCI(trk->tag)) {
/* from x264 or from bytestream h264 */
/* nal reformating needed */
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
@@ -4478,7 +4508,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size);
}
}
- } else if (enc->codec_id == AV_CODEC_ID_HEVC && trk->vos_len > 6 &&
+ } else if (par->codec_id == AV_CODEC_ID_HEVC && trk->vos_len > 6 &&
(AV_RB24(trk->vos_data) == 1 || AV_RB32(trk->vos_data) == 1)) {
/* extradata is Annex B, assume the bitstream is too and convert it */
if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
@@ -4488,7 +4518,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
size = ff_hevc_annexb2mp4(pb, pkt->data, pkt->size, 0, NULL);
}
#if CONFIG_AC3_PARSER
- } else if (enc->codec_id == AV_CODEC_ID_EAC3) {
+ } else if (par->codec_id == AV_CODEC_ID_EAC3) {
size = handle_eac3(mov, pkt, trk);
if (size < 0)
return size;
@@ -4498,8 +4528,8 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
#endif
} else {
if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) {
- if (enc->codec_id == AV_CODEC_ID_H264 && enc->extradata_size > 4) {
- int nal_size_length = (enc->extradata[4] & 0x3) + 1;
+ if (par->codec_id == AV_CODEC_ID_H264 && par->extradata_size > 4) {
+ int nal_size_length = (par->extradata[4] & 0x3) + 1;
ret = ff_mov_cenc_avc_write_nal_units(s, &trk->cenc, nal_size_length, pb, pkt->data, size);
} else {
ret = ff_mov_cenc_write_packet(&trk->cenc, pb, pkt->data, size);
@@ -4513,8 +4543,8 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
}
}
- if ((enc->codec_id == AV_CODEC_ID_DNXHD ||
- enc->codec_id == AV_CODEC_ID_AC3) && !trk->vos_len) {
+ if ((par->codec_id == AV_CODEC_ID_DNXHD ||
+ par->codec_id == AV_CODEC_ID_AC3) && !trk->vos_len) {
/* copy frame to create needed atoms */
trk->vos_len = size;
trk->vos_data = av_malloc(size);
@@ -4618,10 +4648,10 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
trk->cluster[trk->entry].cts +
pkt->duration);
- if (enc->codec_id == AV_CODEC_ID_VC1) {
+ if (par->codec_id == AV_CODEC_ID_VC1) {
mov_parse_vc1_frame(pkt, trk);
} else if (pkt->flags & AV_PKT_FLAG_KEY) {
- if (mov->mode == MODE_MOV && enc->codec_id == AV_CODEC_ID_MPEG2VIDEO &&
+ if (mov->mode == MODE_MOV && par->codec_id == AV_CODEC_ID_MPEG2VIDEO &&
trk->entry > 0) { // force sync sample for the first key frame
mov_parse_mpeg2_frame(pkt, &trk->cluster[trk->entry].flags);
if (trk->cluster[trk->entry].flags & MOV_PARTIAL_SYNC_SAMPLE)
@@ -4651,7 +4681,7 @@ static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt)
{
MOVMuxContext *mov = s->priv_data;
MOVTrack *trk = &mov->tracks[pkt->stream_index];
- AVCodecContext *enc = trk->enc;
+ AVCodecParameters *par = trk->par;
int64_t frag_duration = 0;
int size = pkt->size;
@@ -4682,7 +4712,7 @@ static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt)
frag_duration >= mov->max_fragment_duration) ||
(mov->max_fragment_size && mov->mdat_size + size >= mov->max_fragment_size) ||
(mov->flags & FF_MOV_FLAG_FRAG_KEYFRAME &&
- enc->codec_type == AVMEDIA_TYPE_VIDEO &&
+ par->codec_type == AVMEDIA_TYPE_VIDEO &&
trk->entry && pkt->flags & AV_PKT_FLAG_KEY)) {
if (frag_duration >= mov->min_fragment_duration) {
// Set the duration of this track to line up with the next
@@ -4755,7 +4785,7 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
MOVTrack *trk = &mov->tracks[i];
int ret;
- if (trk->enc->codec_id == AV_CODEC_ID_MOV_TEXT &&
+ if (trk->par->codec_id == AV_CODEC_ID_MOV_TEXT &&
trk->track_duration < pkt->dts &&
(trk->entry == 0 || !trk->last_sample_is_subtitle_end)) {
ret = mov_write_subtitle_end_packet(s, i, trk->track_duration);
@@ -4764,26 +4794,26 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
}
}
- if (trk->mode == MODE_MOV && trk->enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (trk->mode == MODE_MOV && trk->par->codec_type == AVMEDIA_TYPE_VIDEO) {
AVPacket *opkt = pkt;
int ret;
if (trk->is_unaligned_qt_rgb) {
- int64_t bpc = trk->enc->bits_per_coded_sample != 15 ? trk->enc->bits_per_coded_sample : 16;
- int expected_stride = ((trk->enc->width * bpc + 15) >> 4)*2;
- ret = ff_reshuffle_raw_rgb(s, &pkt, trk->enc, expected_stride);
+ int64_t bpc = trk->par->bits_per_coded_sample != 15 ? trk->par->bits_per_coded_sample : 16;
+ int expected_stride = ((trk->par->width * bpc + 15) >> 4)*2;
+ ret = ff_reshuffle_raw_rgb(s, &pkt, trk->par, expected_stride);
if (ret < 0)
return ret;
} else
ret = 0;
- if (trk->enc->pix_fmt == AV_PIX_FMT_PAL8 && !trk->pal_done) {
+ if (trk->par->format == AV_PIX_FMT_PAL8 && !trk->pal_done) {
int ret2 = ff_get_packet_palette(s, opkt, ret, trk->palette);
if (ret2 < 0)
return ret2;
if (ret2)
trk->pal_done++;
- } else if (trk->enc->codec_id == AV_CODEC_ID_RAWVIDEO &&
- (trk->enc->pix_fmt == AV_PIX_FMT_GRAY8 ||
- trk->enc->pix_fmt == AV_PIX_FMT_MONOBLACK)) {
+ } else if (trk->par->codec_id == AV_CODEC_ID_RAWVIDEO &&
+ (trk->par->format == AV_PIX_FMT_GRAY8 ||
+ trk->par->format == AV_PIX_FMT_MONOBLACK)) {
for (i = 0; i < pkt->size; i++)
pkt->data[i] = ~pkt->data[i];
}
@@ -4812,16 +4842,16 @@ static int mov_create_chapter_track(AVFormatContext *s, int tracknum)
track->mode = mov->mode;
track->tag = MKTAG('t','e','x','t');
track->timescale = MOV_TIMESCALE;
- track->enc = avcodec_alloc_context3(NULL);
- if (!track->enc)
+ track->par = avcodec_parameters_alloc();
+ if (!track->par)
return AVERROR(ENOMEM);
- track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ track->par->codec_type = AVMEDIA_TYPE_SUBTITLE;
#if 0
// These properties are required to make QT recognize the chapter track
uint8_t chapter_properties[43] = { 0, 0, 0, 0, 0, 0, 0, 1, };
- if (ff_alloc_extradata(track->enc, sizeof(chapter_properties)))
+ if (ff_alloc_extradata(track->par, sizeof(chapter_properties)))
return AVERROR(ENOMEM);
- memcpy(track->enc->extradata, chapter_properties, sizeof(chapter_properties));
+ memcpy(track->par->extradata, chapter_properties, sizeof(chapter_properties));
#else
if (avio_open_dyn_buf(&pb) >= 0) {
int size;
@@ -4860,8 +4890,8 @@ static int mov_create_chapter_track(AVFormatContext *s, int tracknum)
avio_w8(pb, 0x00); // font name length
if ((size = avio_close_dyn_buf(pb, &buf)) > 0) {
- track->enc->extradata = buf;
- track->enc->extradata_size = size;
+ track->par->extradata = buf;
+ track->par->extradata_size = size;
} else {
av_freep(&buf);
}
@@ -4924,12 +4954,12 @@ static int mov_create_timecode_track(AVFormatContext *s, int index, int src_inde
track->st = src_st;
/* encode context: tmcd data stream */
- track->enc = avcodec_alloc_context3(NULL);
- if (!track->enc)
+ track->par = avcodec_parameters_alloc();
+ if (!track->par)
return AVERROR(ENOMEM);
- track->enc->codec_type = AVMEDIA_TYPE_DATA;
- track->enc->codec_tag = track->tag;
- track->enc->time_base = av_inv_q(rate);
+ track->par->codec_type = AVMEDIA_TYPE_DATA;
+ track->par->codec_tag = track->tag;
+ track->st->avg_frame_rate = av_inv_q(rate);
/* the tmcd track just contains one packet with the frame number */
pkt.data = av_malloc(pkt.size);
@@ -4967,15 +4997,15 @@ static void enable_tracks(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
- if (st->codec->codec_type <= AVMEDIA_TYPE_UNKNOWN ||
- st->codec->codec_type >= AVMEDIA_TYPE_NB)
+ if (st->codecpar->codec_type <= AVMEDIA_TYPE_UNKNOWN ||
+ st->codecpar->codec_type >= AVMEDIA_TYPE_NB)
continue;
- if (first[st->codec->codec_type] < 0)
- first[st->codec->codec_type] = i;
+ if (first[st->codecpar->codec_type] < 0)
+ first[st->codecpar->codec_type] = i;
if (st->disposition & AV_DISPOSITION_DEFAULT) {
mov->tracks[i].flags |= MOV_TRACK_ENABLED;
- enabled[st->codec->codec_type]++;
+ enabled[st->codecpar->codec_type]++;
}
}
@@ -4999,16 +5029,16 @@ static void mov_free(AVFormatContext *s)
int i;
if (mov->chapter_track) {
- if (mov->tracks[mov->chapter_track].enc)
- av_freep(&mov->tracks[mov->chapter_track].enc->extradata);
- av_freep(&mov->tracks[mov->chapter_track].enc);
+ if (mov->tracks[mov->chapter_track].par)
+ av_freep(&mov->tracks[mov->chapter_track].par->extradata);
+ av_freep(&mov->tracks[mov->chapter_track].par);
}
for (i = 0; i < mov->nb_streams; i++) {
if (mov->tracks[i].tag == MKTAG('r','t','p',' '))
ff_mov_close_hinting(&mov->tracks[i]);
else if (mov->tracks[i].tag == MKTAG('t','m','c','d') && mov->nb_meta_tmcd)
- av_freep(&mov->tracks[i].enc);
+ av_freep(&mov->tracks[i].par);
av_freep(&mov->tracks[i].cluster);
av_freep(&mov->tracks[i].frag_info);
@@ -5043,7 +5073,7 @@ static int mov_create_dvd_sub_decoder_specific_info(MOVTrack *track,
int i, width = 720, height = 480;
int have_palette = 0, have_size = 0;
uint32_t palette[16];
- char *cur = st->codec->extradata;
+ char *cur = st->codecpar->extradata;
while (cur && *cur) {
if (strncmp("palette:", cur, 8) == 0) {
@@ -5080,8 +5110,8 @@ static int mov_create_dvd_sub_decoder_specific_info(MOVTrack *track,
}
track->vos_len = 16 * 4;
}
- st->codec->width = width;
- st->codec->height = track->height = height;
+ st->codecpar->width = width;
+ st->codecpar->height = track->height = height;
return 0;
}
@@ -5187,8 +5217,8 @@ static int mov_write_header(AVFormatContext *s)
hint_track = mov->nb_streams;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
- st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
+ st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
mov->nb_streams++;
}
}
@@ -5200,7 +5230,7 @@ static int mov_write_header(AVFormatContext *s)
/* +1 tmcd track for each video stream with a timecode */
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
(global_tcr || av_dict_get(st->metadata, "timecode", NULL, 0)))
mov->nb_meta_tmcd++;
}
@@ -5209,7 +5239,7 @@ static int mov_write_header(AVFormatContext *s)
if (mov->nb_meta_tmcd) {
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
- if (st->codec->codec_tag == MKTAG('t','m','c','d')) {
+ if (st->codecpar->codec_tag == MKTAG('t','m','c','d')) {
av_log(s, AV_LOG_WARNING, "You requested a copy of the original timecode track "
"so timecode metadata are now ignored\n");
mov->nb_meta_tmcd = 0;
@@ -5257,7 +5287,7 @@ static int mov_write_header(AVFormatContext *s)
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
track->st = st;
- track->enc = st->codec;
+ track->par = st->codecpar;
track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV);
if (track->language < 0)
track->language = 0;
@@ -5266,7 +5296,7 @@ static int mov_write_header(AVFormatContext *s)
if (!track->tag) {
av_log(s, AV_LOG_ERROR, "Could not find tag for codec %s in stream #%d, "
"codec not currently supported in container\n",
- avcodec_get_name(st->codec->codec_id), i);
+ avcodec_get_name(st->codecpar->codec_id), i);
ret = AVERROR(EINVAL);
goto error;
}
@@ -5276,11 +5306,11 @@ static int mov_write_header(AVFormatContext *s)
track->start_dts = AV_NOPTS_VALUE;
track->start_cts = AV_NOPTS_VALUE;
track->end_pts = AV_NOPTS_VALUE;
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') ||
track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') ||
track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) {
- if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) {
+ if (st->codecpar->width != 720 || (st->codecpar->height != 608 && st->codecpar->height != 512)) {
av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n");
ret = AVERROR(EINVAL);
goto error;
@@ -5294,8 +5324,8 @@ static int mov_write_header(AVFormatContext *s)
while(track->timescale < 10000)
track->timescale *= 2;
}
- if (st->codec->width > 65535 || st->codec->height > 65535) {
- av_log(s, AV_LOG_ERROR, "Resolution %dx%d too large for mov/mp4\n", st->codec->width, st->codec->height);
+ if (st->codecpar->width > 65535 || st->codecpar->height > 65535) {
+ av_log(s, AV_LOG_ERROR, "Resolution %dx%d too large for mov/mp4\n", st->codecpar->width, st->codecpar->height);
ret = AVERROR(EINVAL);
goto error;
}
@@ -5305,10 +5335,10 @@ static int mov_write_header(AVFormatContext *s)
"file may not be playable by quicktime. Specify a shorter timebase\n"
"or choose different container.\n");
if (track->mode == MODE_MOV &&
- track->enc->codec_id == AV_CODEC_ID_RAWVIDEO &&
+ track->par->codec_id == AV_CODEC_ID_RAWVIDEO &&
track->tag == MKTAG('r','a','w',' ')) {
- enum AVPixelFormat pix_fmt = track->enc->pix_fmt;
- if (pix_fmt == AV_PIX_FMT_NONE && track->enc->bits_per_coded_sample == 1)
+ enum AVPixelFormat pix_fmt = track->par->format;
+ if (pix_fmt == AV_PIX_FMT_NONE && track->par->bits_per_coded_sample == 1)
pix_fmt = AV_PIX_FMT_MONOWHITE;
track->is_unaligned_qt_rgb =
pix_fmt == AV_PIX_FMT_RGB24 ||
@@ -5318,50 +5348,50 @@ static int mov_write_header(AVFormatContext *s)
pix_fmt == AV_PIX_FMT_MONOWHITE ||
pix_fmt == AV_PIX_FMT_MONOBLACK;
}
- } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- track->timescale = st->codec->sample_rate;
- if (!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ track->timescale = st->codecpar->sample_rate;
+ if (!st->codecpar->frame_size && !av_get_bits_per_sample(st->codecpar->codec_id)) {
av_log(s, AV_LOG_WARNING, "track %d: codec frame size is not set\n", i);
track->audio_vbr = 1;
- }else if (st->codec->codec_id == AV_CODEC_ID_ADPCM_MS ||
- st->codec->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
- st->codec->codec_id == AV_CODEC_ID_ILBC){
- if (!st->codec->block_align) {
+ }else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS ||
+ st->codecpar->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
+ st->codecpar->codec_id == AV_CODEC_ID_ILBC){
+ if (!st->codecpar->block_align) {
av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set for adpcm\n", i);
ret = AVERROR(EINVAL);
goto error;
}
- track->sample_size = st->codec->block_align;
- }else if (st->codec->frame_size > 1){ /* assume compressed audio */
+ track->sample_size = st->codecpar->block_align;
+ }else if (st->codecpar->frame_size > 1){ /* assume compressed audio */
track->audio_vbr = 1;
}else{
- track->sample_size = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels;
+ track->sample_size = (av_get_bits_per_sample(st->codecpar->codec_id) >> 3) * st->codecpar->channels;
}
- if (st->codec->codec_id == AV_CODEC_ID_ILBC ||
- st->codec->codec_id == AV_CODEC_ID_ADPCM_IMA_QT) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_ILBC ||
+ st->codecpar->codec_id == AV_CODEC_ID_ADPCM_IMA_QT) {
track->audio_vbr = 1;
}
if (track->mode != MODE_MOV &&
- track->enc->codec_id == AV_CODEC_ID_MP3 && track->timescale < 16000) {
+ track->par->codec_id == AV_CODEC_ID_MP3 && track->timescale < 16000) {
if (s->strict_std_compliance >= FF_COMPLIANCE_NORMAL) {
av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not standard, to mux anyway set strict to -1\n",
- i, track->enc->sample_rate);
+ i, track->par->sample_rate);
ret = AVERROR(EINVAL);
goto error;
} else {
av_log(s, AV_LOG_WARNING, "track %d: muxing mp3 at %dhz is not standard in MP4\n",
- i, track->enc->sample_rate);
+ i, track->par->sample_rate);
}
}
- } else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
track->timescale = st->time_base.den;
- } else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
track->timescale = st->time_base.den;
} else {
track->timescale = MOV_TIMESCALE;
}
if (!track->height)
- track->height = st->codec->height;
+ track->height = st->codecpar->height;
/* The ism specific timescale isn't mandatory, but is assumed by
* some tools, such as mp4split. */
if (mov->mode == MODE_ISM)
@@ -5370,23 +5400,23 @@ static int mov_write_header(AVFormatContext *s)
avpriv_set_pts_info(st, 64, 1, track->timescale);
/* copy extradata if it exists */
- if (st->codec->extradata_size) {
- if (st->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
+ if (st->codecpar->extradata_size) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
mov_create_dvd_sub_decoder_specific_info(track, st);
- else if (!TAG_IS_AVCI(track->tag) && st->codec->codec_id != AV_CODEC_ID_DNXHD) {
- track->vos_len = st->codec->extradata_size;
+ else if (!TAG_IS_AVCI(track->tag) && st->codecpar->codec_id != AV_CODEC_ID_DNXHD) {
+ track->vos_len = st->codecpar->extradata_size;
track->vos_data = av_malloc(track->vos_len);
if (!track->vos_data) {
ret = AVERROR(ENOMEM);
goto error;
}
- memcpy(track->vos_data, st->codec->extradata, track->vos_len);
+ memcpy(track->vos_data, st->codecpar->extradata, track->vos_len);
}
}
if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) {
ret = ff_mov_cenc_init(&track->cenc, mov->encryption_key,
- track->enc->codec_id == AV_CODEC_ID_H264, s->flags & AVFMT_FLAG_BITEXACT);
+ track->par->codec_id == AV_CODEC_ID_H264, s->flags & AVFMT_FLAG_BITEXACT);
if (ret) {
goto error;
}
@@ -5398,8 +5428,8 @@ static int mov_write_header(AVFormatContext *s)
AVStream *st= s->streams[i];
MOVTrack *track= &mov->tracks[i];
- if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO ||
- track->enc->channel_layout != AV_CH_LAYOUT_MONO)
+ if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO ||
+ track->par->channel_layout != AV_CH_LAYOUT_MONO)
continue;
for (j = 0; j < s->nb_streams; j++) {
@@ -5408,8 +5438,8 @@ static int mov_write_header(AVFormatContext *s)
if (j == i)
continue;
- if (stj->codec->codec_type != AVMEDIA_TYPE_AUDIO ||
- trackj->enc->channel_layout != AV_CH_LAYOUT_MONO ||
+ if (stj->codecpar->codec_type != AVMEDIA_TYPE_AUDIO ||
+ trackj->par->channel_layout != AV_CH_LAYOUT_MONO ||
trackj->language != track->language ||
trackj->tag != track->tag
)
@@ -5451,8 +5481,8 @@ static int mov_write_header(AVFormatContext *s)
/* Initialize the hint tracks for each audio and video stream */
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
- st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
+ st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
if ((ret = ff_mov_init_hinting(s, hint_track, i)) < 0)
goto error;
hint_track++;
@@ -5466,7 +5496,7 @@ static int mov_write_header(AVFormatContext *s)
AVStream *st = s->streams[i];
t = global_tcr;
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (!t)
t = av_dict_get(st->metadata, "timecode", NULL, 0);
if (!t)
@@ -5650,7 +5680,7 @@ static int mov_write_trailer(AVFormatContext *s)
*/
for (i = 0; i < mov->nb_streams; i++) {
MOVTrack *trk = &mov->tracks[i];
- if (trk->enc->codec_id == AV_CODEC_ID_MOV_TEXT &&
+ if (trk->par->codec_id == AV_CODEC_ID_MOV_TEXT &&
!trk->last_sample_is_subtitle_end) {
mov_write_subtitle_end_packet(s, i, trk->track_duration);
trk->last_sample_is_subtitle_end = 1;
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index 44caff9711..1090085a5a 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -101,7 +101,7 @@ typedef struct MOVTrack {
int track_id;
int tag; ///< stsd fourcc
AVStream *st;
- AVCodecContext *enc;
+ AVCodecParameters *par;
int multichannel_as_mono;
int vos_len;
diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c
index 9e667edce4..964026ec71 100644
--- a/libavformat/movenchint.c
+++ b/libavformat/movenchint.c
@@ -37,11 +37,11 @@ int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index)
track->tag = MKTAG('r','t','p',' ');
track->src_track = src_index;
- track->enc = avcodec_alloc_context3(NULL);
- if (!track->enc)
+ track->par = avcodec_parameters_alloc();
+ if (!track->par)
goto fail;
- track->enc->codec_type = AVMEDIA_TYPE_DATA;
- track->enc->codec_tag = track->tag;
+ track->par->codec_type = AVMEDIA_TYPE_DATA;
+ track->par->codec_tag = track->tag;
ret = ff_rtp_chain_mux_open(&track->rtp_ctx, s, src_st, NULL,
RTP_MAX_PACKET_SIZE, src_index);
@@ -58,7 +58,7 @@ int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index)
fail:
av_log(s, AV_LOG_WARNING,
"Unable to initialize hinting of stream %d\n", src_index);
- av_freep(&track->enc);
+ avcodec_parameters_free(&track->par);
/* Set a default timescale, to avoid crashes in av_dump_format */
track->timescale = 90000;
return ret;
@@ -460,7 +460,7 @@ void ff_mov_close_hinting(MOVTrack *track)
{
AVFormatContext *rtp_ctx = track->rtp_ctx;
- av_freep(&track->enc);
+ avcodec_parameters_free(&track->par);
sample_queue_free(&track->sample_queue);
if (!rtp_ctx)
return;
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 672d643cec..3725d6717c 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -331,7 +331,7 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base)
st->duration = av_rescale_q(mp3->frames, (AVRational){spf, c.sample_rate},
st->time_base);
if (mp3->header_filesize && mp3->frames && !mp3->is_cbr)
- st->codec->bit_rate = av_rescale(mp3->header_filesize, 8 * c.sample_rate, mp3->frames * (int64_t)spf);
+ st->codecpar->bit_rate = av_rescale(mp3->header_filesize, 8 * c.sample_rate, mp3->frames * (int64_t)spf);
return 0;
}
@@ -348,8 +348,8 @@ static int mp3_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_MP3;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_MP3;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
st->start_time = 0;
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 71f5178a50..de6340192c 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -129,7 +129,7 @@ static const uint8_t xing_offtbl[2][2] = {{32, 17}, {17, 9}};
static int mp3_write_xing(AVFormatContext *s)
{
MP3Context *mp3 = s->priv_data;
- AVCodecContext *codec = s->streams[mp3->audio_stream_idx]->codec;
+ AVCodecParameters *par = s->streams[mp3->audio_stream_idx]->codecpar;
AVDictionaryEntry *enc = av_dict_get(s->streams[mp3->audio_stream_idx]->metadata, "encoder", NULL, 0);
AVIOContext *dyn_ctx;
int32_t header;
@@ -148,9 +148,9 @@ static int mp3_write_xing(AVFormatContext *s)
for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++) {
const uint16_t base_freq = avpriv_mpa_freq_tab[i];
- if (codec->sample_rate == base_freq) ver = 0x3; // MPEG 1
- else if (codec->sample_rate == base_freq / 2) ver = 0x2; // MPEG 2
- else if (codec->sample_rate == base_freq / 4) ver = 0x0; // MPEG 2.5
+ if (par->sample_rate == base_freq) ver = 0x3; // MPEG 1
+ else if (par->sample_rate == base_freq / 2) ver = 0x2; // MPEG 2
+ else if (par->sample_rate == base_freq / 4) ver = 0x0; // MPEG 2.5
else continue;
srate_idx = i;
@@ -161,7 +161,7 @@ static int mp3_write_xing(AVFormatContext *s)
return -1;
}
- switch (codec->channels) {
+ switch (par->channels) {
case 1: channels = MPA_MONO; break;
case 2: channels = MPA_STEREO; break;
default: av_log(s, AV_LOG_WARNING, "Unsupported number of channels, "
@@ -177,7 +177,7 @@ static int mp3_write_xing(AVFormatContext *s)
for (bitrate_idx = 1; bitrate_idx < 15; bitrate_idx++) {
int bit_rate = 1000 * avpriv_mpa_bitrate_tab[ver != 3][3 - 1][bitrate_idx];
- int error = FFABS(bit_rate - codec->bit_rate);
+ int error = FFABS(bit_rate - par->bit_rate);
if (error < best_bitrate_error) {
best_bitrate_error = error;
@@ -249,10 +249,10 @@ static int mp3_write_xing(AVFormatContext *s)
avio_w8(dyn_ctx, 0); // unknown abr/minimal bitrate
// encoder delay
- if (codec->initial_padding - 528 - 1 >= 1 << 12) {
+ if (par->initial_padding - 528 - 1 >= 1 << 12) {
av_log(s, AV_LOG_WARNING, "Too many samples of initial padding.\n");
}
- avio_wb24(dyn_ctx, FFMAX(codec->initial_padding - 528 - 1, 0)<<12);
+ avio_wb24(dyn_ctx, FFMAX(par->initial_padding - 528 - 1, 0)<<12);
avio_w8(dyn_ctx, 0); // misc
avio_w8(dyn_ctx, 0); // mp3gain
@@ -575,14 +575,14 @@ static int mp3_write_header(struct AVFormatContext *s)
mp3->audio_stream_idx = -1;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- if (mp3->audio_stream_idx >= 0 || st->codec->codec_id != AV_CODEC_ID_MP3) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (mp3->audio_stream_idx >= 0 || st->codecpar->codec_id != AV_CODEC_ID_MP3) {
av_log(s, AV_LOG_ERROR, "Invalid audio stream. Exactly one MP3 "
"audio stream is required.\n");
return AVERROR(EINVAL);
}
mp3->audio_stream_idx = i;
- } else if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO) {
+ } else if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) {
av_log(s, AV_LOG_ERROR, "Only audio streams and pictures are allowed in MP3.\n");
return AVERROR(EINVAL);
}
diff --git a/libavformat/mpc.c b/libavformat/mpc.c
index d0c1b85a30..ffd1c56c1c 100644
--- a/libavformat/mpc.c
+++ b/libavformat/mpc.c
@@ -89,16 +89,16 @@ static int mpc_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_id = AV_CODEC_ID_MUSEPACK7;
- st->codec->channels = 2;
- st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
- st->codec->bits_per_coded_sample = 16;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_MUSEPACK7;
+ st->codecpar->channels = 2;
+ st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+ st->codecpar->bits_per_coded_sample = 16;
- if (ff_get_extradata(st->codec, s->pb, 16) < 0)
+ if (ff_get_extradata(st->codecpar, s->pb, 16) < 0)
return AVERROR(ENOMEM);
- st->codec->sample_rate = mpc_rate[st->codec->extradata[2] & 3];
- avpriv_set_pts_info(st, 32, MPC_FRAMESIZE, st->codec->sample_rate);
+ st->codecpar->sample_rate = mpc_rate[st->codecpar->extradata[2] & 3];
+ avpriv_set_pts_info(st, 32, MPC_FRAMESIZE, st->codecpar->sample_rate);
/* scan for seekpoints */
st->start_time = 0;
st->duration = c->fcount;
diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c
index bf597b88a5..288caa0639 100644
--- a/libavformat/mpc8.c
+++ b/libavformat/mpc8.c
@@ -248,18 +248,18 @@ static int mpc8_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_id = AV_CODEC_ID_MUSEPACK8;
- st->codec->bits_per_coded_sample = 16;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_MUSEPACK8;
+ st->codecpar->bits_per_coded_sample = 16;
- if (ff_get_extradata(st->codec, pb, 2) < 0)
+ if (ff_get_extradata(st->codecpar, pb, 2) < 0)
return AVERROR(ENOMEM);
- st->codec->channels = (st->codec->extradata[1] >> 4) + 1;
- st->codec->sample_rate = mpc8_rate[st->codec->extradata[0] >> 5];
- avpriv_set_pts_info(st, 32, 1152 << (st->codec->extradata[1]&3)*2, st->codec->sample_rate);
+ st->codecpar->channels = (st->codecpar->extradata[1] >> 4) + 1;
+ st->codecpar->sample_rate = mpc8_rate[st->codecpar->extradata[0] >> 5];
+ avpriv_set_pts_info(st, 32, 1152 << (st->codecpar->extradata[1]&3)*2, st->codecpar->sample_rate);
st->start_time = 0;
- st->duration = c->samples / (1152 << (st->codec->extradata[1]&3)*2);
+ st->duration = c->samples / (1152 << (st->codecpar->extradata[1]&3)*2);
size -= avio_tell(pb) - pos;
if (size > 0)
avio_skip(pb, size);
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 77d5cd10ab..c83c02681a 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -597,13 +597,13 @@ skip:
if (!st)
goto skip;
st->id = startcode;
- st->codec->codec_type = type;
- st->codec->codec_id = codec_id;
- if ( st->codec->codec_id == AV_CODEC_ID_PCM_MULAW
- || st->codec->codec_id == AV_CODEC_ID_PCM_ALAW) {
- st->codec->channels = 1;
- st->codec->channel_layout = AV_CH_LAYOUT_MONO;
- st->codec->sample_rate = 8000;
+ st->codecpar->codec_type = type;
+ st->codecpar->codec_id = codec_id;
+ if ( st->codecpar->codec_id == AV_CODEC_ID_PCM_MULAW
+ || st->codecpar->codec_id == AV_CODEC_ID_PCM_ALAW) {
+ st->codecpar->channels = 1;
+ st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+ st->codecpar->sample_rate = 8000;
}
st->request_probe = request_probe;
st->need_parsing = AVSTREAM_PARSE_FULL;
@@ -612,7 +612,7 @@ found:
if (st->discard >= AVDISCARD_ALL)
goto skip;
if (startcode >= 0xa0 && startcode <= 0xaf) {
- if (st->codec->codec_id == AV_CODEC_ID_MLP) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_MLP) {
if (len < 6)
goto skip;
avio_skip(s->pb, 6);
@@ -791,8 +791,8 @@ static int vobsub_read_header(AVFormatContext *s)
goto end;
}
st->id = stream_id;
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_DVD_SUBTITLE;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_DVD_SUBTITLE;
avpriv_set_pts_info(st, 64, 1, 1000);
av_dict_set(&st->metadata, "language", id, 0);
if (alt[0])
@@ -869,8 +869,8 @@ static int vobsub_read_header(AVFormatContext *s)
av_bprint_finalize(&header, &header_str);
for (i = 0; i < s->nb_streams; i++) {
AVStream *sub_st = s->streams[i];
- sub_st->codec->extradata = av_strdup(header_str);
- sub_st->codec->extradata_size = header.len;
+ sub_st->codecpar->extradata = av_strdup(header_str);
+ sub_st->codecpar->extradata_size = header.len;
}
av_free(header_str);
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 2e095495f0..358031d83d 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -348,35 +348,35 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
avpriv_set_pts_info(st, 64, 1, 90000);
- switch (st->codec->codec_type) {
+ switch (st->codecpar->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if (!s->is_mpeg2 &&
- (st->codec->codec_id == AV_CODEC_ID_AC3 ||
- st->codec->codec_id == AV_CODEC_ID_DTS ||
- st->codec->codec_id == AV_CODEC_ID_PCM_S16BE))
+ (st->codecpar->codec_id == AV_CODEC_ID_AC3 ||
+ st->codecpar->codec_id == AV_CODEC_ID_DTS ||
+ st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE))
av_log(ctx, AV_LOG_WARNING,
"%s in MPEG-1 system streams is not widely supported, "
"consider using the vob or the dvd muxer "
"to force a MPEG-2 program stream.\n",
- avcodec_get_name(st->codec->codec_id));
- if (st->codec->codec_id == AV_CODEC_ID_AC3) {
+ avcodec_get_name(st->codecpar->codec_id));
+ if (st->codecpar->codec_id == AV_CODEC_ID_AC3) {
stream->id = ac3_id++;
- } else if (st->codec->codec_id == AV_CODEC_ID_DTS) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_DTS) {
stream->id = dts_id++;
- } else if (st->codec->codec_id == AV_CODEC_ID_PCM_S16BE) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE) {
stream->id = lpcm_id++;
for (j = 0; j < 4; j++) {
- if (lpcm_freq_tab[j] == st->codec->sample_rate)
+ if (lpcm_freq_tab[j] == st->codecpar->sample_rate)
break;
}
if (j == 4)
goto fail;
- if (st->codec->channels > 8)
+ if (st->codecpar->channels > 8)
return -1;
stream->lpcm_header[0] = 0x0c;
- stream->lpcm_header[1] = (st->codec->channels - 1) | (j << 4);
+ stream->lpcm_header[1] = (st->codecpar->channels - 1) | (j << 4);
stream->lpcm_header[2] = 0x80;
- stream->lpcm_align = st->codec->channels * 2;
+ stream->lpcm_align = st->codecpar->channels * 2;
} else {
stream->id = mpa_id++;
}
@@ -387,7 +387,7 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
s->audio_bound++;
break;
case AVMEDIA_TYPE_VIDEO:
- if (st->codec->codec_id == AV_CODEC_ID_H264)
+ if (st->codecpar->codec_id == AV_CODEC_ID_H264)
stream->id = h264_id++;
else
stream->id = mpv_id++;
@@ -415,7 +415,7 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
break;
default:
av_log(ctx, AV_LOG_ERROR, "Invalid media type %s for output stream #%d\n",
- av_get_media_type_string(st->codec->codec_type), i);
+ av_get_media_type_string(st->codecpar->codec_type), i);
return AVERROR(EINVAL);
}
stream->fifo = av_fifo_alloc(16);
@@ -435,7 +435,7 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
if (props)
codec_rate = props->max_bitrate;
else
- codec_rate = st->codec->bit_rate;
+ codec_rate = st->codecpar->bit_rate;
if (!codec_rate)
codec_rate = (1 << 21) * 8 * 50 / ctx->nb_streams;
@@ -444,7 +444,7 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
if ((stream->id & 0xe0) == AUDIO_ID)
audio_bitrate += codec_rate;
- else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+ else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
video_bitrate += codec_rate;
}
@@ -984,7 +984,7 @@ retry:
/* for subtitle, a single PES packet must be generated,
* so we flush after every single subtitle packet */
if (s->packet_size > avail_data && !flush
- && st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE)
+ && st->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
return 0;
if (avail_data == 0)
continue;
@@ -1115,7 +1115,7 @@ static int mpeg_mux_write_packet(AVFormatContext *ctx, AVPacket *pkt)
int64_t pts, dts;
PacketDesc *pkt_desc;
int preload;
- const int is_iframe = st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
+ const int is_iframe = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
(pkt->flags & AV_PKT_FLAG_KEY);
preload = av_rescale(s->preload, 90000, AV_TIME_BASE);
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index dbec2558b1..5cdab58016 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -762,16 +762,15 @@ static void mpegts_find_stream_type(AVStream *st,
uint32_t stream_type,
const StreamType *types)
{
- if (avcodec_is_open(st->codec)) {
- av_log(NULL, AV_LOG_DEBUG, "cannot set stream info, codec is open\n");
- return;
- }
-
for (; types->stream_type; types++)
if (stream_type == types->stream_type) {
- st->codec->codec_type = types->codec_type;
- st->codec->codec_id = types->codec_id;
- st->request_probe = 0;
+ if (st->codecpar->codec_type != types->codec_type ||
+ st->codecpar->codec_id != types->codec_id) {
+ st->codecpar->codec_type = types->codec_type;
+ st->codecpar->codec_id = types->codec_id;
+ st->internal->need_context_update = 1;
+ }
+ st->request_probe = 0;
return;
}
}
@@ -779,18 +778,19 @@ static void mpegts_find_stream_type(AVStream *st,
static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
uint32_t stream_type, uint32_t prog_reg_desc)
{
- int old_codec_type = st->codec->codec_type;
- int old_codec_id = st->codec->codec_id;
+ int old_codec_type = st->codecpar->codec_type;
+ int old_codec_id = st->codecpar->codec_id;
+ int old_codec_tag = st->codecpar->codec_tag;
- if (avcodec_is_open(st->codec)) {
- av_log(pes->stream, AV_LOG_DEBUG, "cannot set stream info, codec is open\n");
+ if (avcodec_is_open(st->internal->avctx)) {
+ av_log(pes->stream, AV_LOG_DEBUG, "cannot set stream info, internal codec is open\n");
return 0;
}
avpriv_set_pts_info(st, 33, 1, 90000);
st->priv_data = pes;
- 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;
st->need_parsing = AVSTREAM_PARSE_FULL;
pes->st = st;
pes->stream_type = stream_type;
@@ -799,14 +799,14 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
"stream=%d stream_type=%x pid=%x prog_reg_desc=%.4s\n",
st->index, pes->stream_type, pes->pid, (char *)&prog_reg_desc);
- st->codec->codec_tag = pes->stream_type;
+ st->codecpar->codec_tag = pes->stream_type;
mpegts_find_stream_type(st, pes->stream_type, ISO_types);
if (pes->stream_type == 4)
st->request_probe = 50;
if ((prog_reg_desc == AV_RL32("HDMV") ||
prog_reg_desc == AV_RL32("HDPR")) &&
- st->codec->codec_id == AV_CODEC_ID_NONE) {
+ st->codecpar->codec_id == AV_CODEC_ID_NONE) {
mpegts_find_stream_type(st, pes->stream_type, HDMV_types);
if (pes->stream_type == 0x83) {
// HDMV TrueHD streams also contain an AC3 coded version of the
@@ -827,28 +827,33 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
sub_st->id = pes->pid;
avpriv_set_pts_info(sub_st, 33, 1, 90000);
sub_st->priv_data = sub_pes;
- sub_st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- sub_st->codec->codec_id = AV_CODEC_ID_AC3;
+ sub_st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ sub_st->codecpar->codec_id = AV_CODEC_ID_AC3;
sub_st->need_parsing = AVSTREAM_PARSE_FULL;
sub_pes->sub_st = pes->sub_st = sub_st;
}
}
- if (st->codec->codec_id == AV_CODEC_ID_NONE)
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE)
mpegts_find_stream_type(st, pes->stream_type, MISC_types);
- if (st->codec->codec_id == AV_CODEC_ID_NONE) {
- st->codec->codec_id = old_codec_id;
- st->codec->codec_type = old_codec_type;
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE) {
+ st->codecpar->codec_id = old_codec_id;
+ st->codecpar->codec_type = old_codec_type;
}
- if ((st->codec->codec_id == AV_CODEC_ID_NONE ||
+ if ((st->codecpar->codec_id == AV_CODEC_ID_NONE ||
(st->request_probe > 0 && st->request_probe < AVPROBE_SCORE_STREAM_RETRY / 5)) &&
- !avcodec_is_open(st->codec) &&
st->probe_packets > 0 &&
stream_type == STREAM_TYPE_PRIVATE_DATA) {
- st->codec->codec_type = AVMEDIA_TYPE_DATA;
- st->codec->codec_id = AV_CODEC_ID_BIN_DATA;
+ st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+ st->codecpar->codec_id = AV_CODEC_ID_BIN_DATA;
st->request_probe = AVPROBE_SCORE_STREAM_RETRY / 5;
}
+ /* queue a context update if properties changed */
+ if (old_codec_type != st->codecpar->codec_type ||
+ old_codec_id != st->codecpar->codec_id ||
+ old_codec_tag != st->codecpar->codec_tag)
+ st->internal->need_context_update = 1;
+
return 0;
}
@@ -1061,7 +1066,7 @@ static int mpegts_push_data(MpegTSFilter *filter,
code != 0x1ff && code != 0x1f2 && /* program_stream_directory, DSMCC_stream */
code != 0x1f8) { /* ITU-T Rec. H.222.1 type E stream */
pes->state = MPEGTS_PESHEADER;
- if (pes->st->codec->codec_id == AV_CODEC_ID_NONE && !pes->st->request_probe) {
+ if (pes->st->codecpar->codec_id == AV_CODEC_ID_NONE && !pes->st->request_probe) {
av_log(pes->stream, AV_LOG_TRACE,
"pid=%x stream_type=%x probing\n",
pes->pid,
@@ -1158,8 +1163,8 @@ skip:
buf_size -= 5;
}
if ( pes->ts->fix_teletext_pts
- && ( pes->st->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT
- || pes->st->codec->codec_id == AV_CODEC_ID_DVB_SUBTITLE)
+ && ( pes->st->codecpar->codec_id == AV_CODEC_ID_DVB_TELETEXT
+ || pes->st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE)
) {
AVProgram *p = NULL;
while ((p = av_find_program_from_stream(pes->stream, p, pes->st->index))) {
@@ -1175,7 +1180,7 @@ skip:
int i;
for (i = 0; i < p->nb_stream_indexes; i++) {
AVStream *pst = pes->stream->streams[p->stream_index[i]];
- if (pst->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+ if (pst->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
st = pst;
}
}
@@ -1189,10 +1194,10 @@ skip:
pes->st->pts_wrap_behavior = st->pts_wrap_behavior;
if (pes->dts == AV_NOPTS_VALUE || pes->dts < pcr) {
pes->pts = pes->dts = pcr;
- } else if (pes->st->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT &&
+ } else if (pes->st->codecpar->codec_id == AV_CODEC_ID_DVB_TELETEXT &&
pes->dts > pcr + 3654 + 9000) {
pes->pts = pes->dts = pcr + 3654 + 9000;
- } else if (pes->st->codec->codec_id == AV_CODEC_ID_DVB_SUBTITLE &&
+ } else if (pes->st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE &&
pes->dts > pcr + 10*90000) { //10sec
pes->pts = pes->dts = pcr + 3654 + 9000;
}
@@ -1554,14 +1559,15 @@ static void m4sl_cb(MpegTSFilter *filter, const uint8_t *section,
mp4_descr[i].dec_config_descr_len, 0,
NULL, NULL, NULL, NULL);
ff_mp4_read_dec_config_descr(s, st, &pb);
- if (st->codec->codec_id == AV_CODEC_ID_AAC &&
- st->codec->extradata_size > 0)
+ if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
+ st->codecpar->extradata_size > 0)
st->need_parsing = 0;
- if (st->codec->codec_id == AV_CODEC_ID_H264 &&
- st->codec->extradata_size > 0)
+ if (st->codecpar->codec_id == AV_CODEC_ID_H264 &&
+ st->codecpar->extradata_size > 0)
st->need_parsing = 0;
- st->codec->codec_type = avcodec_get_type(st->codec->codec_id);
+ st->codecpar->codec_type = avcodec_get_type(st->codecpar->codec_id);
+ st->internal->need_context_update = 1;
}
}
for (i = 0; i < mp4_descr_count; i++)
@@ -1609,7 +1615,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
av_log(fc, AV_LOG_TRACE, "tag: 0x%02x len=%d\n", desc_tag, desc_len);
- if ((st->codec->codec_id == AV_CODEC_ID_NONE || st->request_probe > 0) &&
+ if ((st->codecpar->codec_id == AV_CODEC_ID_NONE || st->request_probe > 0) &&
stream_type == STREAM_TYPE_PRIVATE_DATA)
mpegts_find_stream_type(st, desc_tag, DESC_types);
@@ -1628,10 +1634,12 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
mp4_descr[i].dec_config_descr_len, 0,
NULL, NULL, NULL, NULL);
ff_mp4_read_dec_config_descr(fc, st, &pb);
- if (st->codec->codec_id == AV_CODEC_ID_AAC &&
- st->codec->extradata_size > 0)
+ if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
+ st->codecpar->extradata_size > 0) {
st->need_parsing = 0;
- if (st->codec->codec_id == AV_CODEC_ID_MPEG4SYSTEMS)
+ st->internal->need_context_update = 1;
+ }
+ if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4SYSTEMS)
mpegts_open_section_filter(ts, pid, m4sl_cb, ts, 1);
}
break;
@@ -1639,8 +1647,8 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
if (get16(pp, desc_end) < 0)
break;
if (mp4_descr_count > 0 &&
- (st->codec->codec_id == AV_CODEC_ID_AAC_LATM ||
- (st->request_probe == 0 && st->codec->codec_id == AV_CODEC_ID_NONE) ||
+ (st->codecpar->codec_id == AV_CODEC_ID_AAC_LATM ||
+ (st->request_probe == 0 && st->codecpar->codec_id == AV_CODEC_ID_NONE) ||
st->request_probe > 0) &&
mp4_descr->dec_config_descr_len && mp4_descr->es_id == pid) {
AVIOContext pb;
@@ -1648,10 +1656,11 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
mp4_descr->dec_config_descr_len, 0,
NULL, NULL, NULL, NULL);
ff_mp4_read_dec_config_descr(fc, st, &pb);
- if (st->codec->codec_id == AV_CODEC_ID_AAC &&
- st->codec->extradata_size > 0) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
+ st->codecpar->extradata_size > 0) {
st->request_probe = st->need_parsing = 0;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->internal->need_context_update = 1;
}
}
break;
@@ -1667,16 +1676,16 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
/* 4 bytes per language code (3 bytes) with comma or NUL byte should fit language buffer */
av_assert0(language_count <= sizeof(language) / 4);
- if (st->codec->extradata == NULL) {
- if (ff_alloc_extradata(st->codec, language_count * 2)) {
+ if (st->codecpar->extradata == NULL) {
+ if (ff_alloc_extradata(st->codecpar, language_count * 2)) {
return AVERROR(ENOMEM);
}
}
- if (st->codec->extradata_size < language_count * 2)
+ if (st->codecpar->extradata_size < language_count * 2)
return AVERROR_INVALIDDATA;
- extradata = st->codec->extradata;
+ extradata = st->codecpar->extradata;
for (i = 0; i < language_count; i++) {
language[i * 4 + 0] = get8(pp, desc_end);
@@ -1692,6 +1701,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
language[i * 4 - 1] = 0;
av_dict_set(&st->metadata, "language", language, 0);
+ st->internal->need_context_update = 1;
}
}
break;
@@ -1717,16 +1727,16 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
/* 4 bytes per language code (3 bytes) with comma or NUL byte should fit language buffer */
av_assert0(language_count <= sizeof(language) / 4);
- if (st->codec->extradata == NULL) {
- if (ff_alloc_extradata(st->codec, language_count * 5)) {
+ if (st->codecpar->extradata == NULL) {
+ if (ff_alloc_extradata(st->codecpar, language_count * 5)) {
return AVERROR(ENOMEM);
}
}
- if (st->codec->extradata_size < language_count * 5)
+ if (st->codecpar->extradata_size < language_count * 5)
return AVERROR_INVALIDDATA;
- extradata = st->codec->extradata;
+ extradata = st->codecpar->extradata;
for (i = 0; i < language_count; i++) {
language[i * 4 + 0] = get8(pp, desc_end);
@@ -1755,6 +1765,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
language[i * 4 - 1] = 0;
av_dict_set(&st->metadata, "language", language, 0);
+ st->internal->need_context_update = 1;
}
}
break;
@@ -1782,10 +1793,10 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
}
break;
case 0x05: /* registration descriptor */
- st->codec->codec_tag = bytestream_get_le32(pp);
- av_log(fc, AV_LOG_TRACE, "reg_desc=%.4s\n", (char *)&st->codec->codec_tag);
- if (st->codec->codec_id == AV_CODEC_ID_NONE || st->request_probe > 0)
- mpegts_find_stream_type(st, st->codec->codec_tag, REGD_types);
+ st->codecpar->codec_tag = bytestream_get_le32(pp);
+ av_log(fc, AV_LOG_TRACE, "reg_desc=%.4s\n", (char *)&st->codecpar->codec_tag);
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE || st->request_probe > 0)
+ mpegts_find_stream_type(st, st->codecpar->codec_tag, REGD_types);
break;
case 0x52: /* stream identifier descriptor */
st->stream_identifier = 1 + get8(pp, desc_end);
@@ -1794,39 +1805,40 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
if (get16(pp, desc_end) == 0xFFFF)
*pp += 4;
if (get8(pp, desc_end) == 0xFF) {
- st->codec->codec_tag = bytestream_get_le32(pp);
- if (st->codec->codec_id == AV_CODEC_ID_NONE)
- mpegts_find_stream_type(st, st->codec->codec_tag, METADATA_types);
+ st->codecpar->codec_tag = bytestream_get_le32(pp);
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE)
+ mpegts_find_stream_type(st, st->codecpar->codec_tag, METADATA_types);
}
break;
case 0x7f: /* DVB extension descriptor */
ext_desc_tag = get8(pp, desc_end);
if (ext_desc_tag < 0)
return AVERROR_INVALIDDATA;
- if (st->codec->codec_id == AV_CODEC_ID_OPUS &&
+ if (st->codecpar->codec_id == AV_CODEC_ID_OPUS &&
ext_desc_tag == 0x80) { /* User defined (provisional Opus) */
- if (!st->codec->extradata) {
- st->codec->extradata = av_mallocz(sizeof(opus_default_extradata) +
- AV_INPUT_BUFFER_PADDING_SIZE);
- if (!st->codec->extradata)
+ if (!st->codecpar->extradata) {
+ st->codecpar->extradata = av_mallocz(sizeof(opus_default_extradata) +
+ AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
- st->codec->extradata_size = sizeof(opus_default_extradata);
- memcpy(st->codec->extradata, opus_default_extradata, sizeof(opus_default_extradata));
+ st->codecpar->extradata_size = sizeof(opus_default_extradata);
+ memcpy(st->codecpar->extradata, opus_default_extradata, sizeof(opus_default_extradata));
channel_config_code = get8(pp, desc_end);
if (channel_config_code < 0)
return AVERROR_INVALIDDATA;
if (channel_config_code <= 0x8) {
- st->codec->extradata[9] = channels = channel_config_code ? channel_config_code : 2;
- st->codec->extradata[18] = channel_config_code ? (channels > 2) : /* Dual Mono */ 255;
- st->codec->extradata[19] = opus_stream_cnt[channel_config_code];
- st->codec->extradata[20] = opus_coupled_stream_cnt[channel_config_code];
- memcpy(&st->codec->extradata[21], opus_channel_map[channels - 1], channels);
+ st->codecpar->extradata[9] = channels = channel_config_code ? channel_config_code : 2;
+ st->codecpar->extradata[18] = channel_config_code ? (channels > 2) : /* Dual Mono */ 255;
+ st->codecpar->extradata[19] = opus_stream_cnt[channel_config_code];
+ st->codecpar->extradata[20] = opus_coupled_stream_cnt[channel_config_code];
+ memcpy(&st->codecpar->extradata[21], opus_channel_map[channels - 1], channels);
} else {
avpriv_request_sample(fc, "Opus in MPEG-TS - channel_config_code > 0x8");
}
st->need_parsing = AVSTREAM_PARSE_FULL;
+ st->internal->need_context_update = 1;
}
}
break;
@@ -1963,7 +1975,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
if (!st)
goto out;
st->id = pid;
- st->codec->codec_type = AVMEDIA_TYPE_DATA;
+ st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
}
}
@@ -1994,7 +2006,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
stream_type == 0x83 && pes->sub_st) {
av_program_add_stream_index(ts->stream, h->id,
pes->sub_st->index);
- pes->sub_st->codec->codec_tag = st->codec->codec_tag;
+ pes->sub_st->codecpar->codec_tag = st->codecpar->codec_tag;
}
}
p = desc_list_end;
@@ -2278,7 +2290,7 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
int types = 0;
for (i = 0; i < ts->stream->nb_streams; i++) {
AVStream *st = ts->stream->streams[i];
- types |= 1<<st->codec->codec_type;
+ types |= 1<<st->codecpar->codec_type;
}
if ((types & (1<<AVMEDIA_TYPE_AUDIO) && types & (1<<AVMEDIA_TYPE_VIDEO)) || pos > 100000) {
av_log(ts->stream, AV_LOG_DEBUG, "All programs have pmt, headers found\n");
@@ -2571,8 +2583,8 @@ static int mpegts_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 60, 1, 27000000);
- st->codec->codec_type = AVMEDIA_TYPE_DATA;
- st->codec->codec_id = AV_CODEC_ID_MPEG2TS;
+ st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+ st->codecpar->codec_id = AV_CODEC_ID_MPEG2TS;
/* we iterate until we find two PCRs to estimate the bitrate */
pcr_pid = -1;
@@ -2603,7 +2615,7 @@ static int mpegts_read_header(AVFormatContext *s)
ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - packet_count[0]);
ts->cur_pcr = pcrs[0] - ts->pcr_incr * packet_count[0];
s->bit_rate = TS_PACKET_SIZE * 8 * 27000000LL / ts->pcr_incr;
- st->codec->bit_rate = s->bit_rate;
+ st->codecpar->bit_rate = s->bit_rate;
st->start_time = ts->cur_pcr;
av_log(ts->stream, AV_LOG_TRACE, "start=%0.3f pcr=%0.3f incr=%d\n",
st->start_time / 1000000.0, pcrs[0] / 27e6, ts->pcr_incr);
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 51677eaaf4..f4cb862bb9 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -293,7 +293,7 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
err = 1;
break;
}
- switch (st->codec->codec_id) {
+ switch (st->codecpar->codec_id) {
case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO:
stream_type = STREAM_TYPE_VIDEO_MPEG2;
@@ -358,19 +358,19 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
q += 2; /* patched after */
/* write optional descriptors here */
- switch (st->codec->codec_type) {
+ switch (st->codecpar->codec_type) {
case AVMEDIA_TYPE_AUDIO:
- if (st->codec->codec_id==AV_CODEC_ID_AC3 && (ts->flags & MPEGTS_FLAG_SYSTEM_B)) {
+ if (st->codecpar->codec_id==AV_CODEC_ID_AC3 && (ts->flags & MPEGTS_FLAG_SYSTEM_B)) {
*q++=0x6a; // AC3 descriptor see A038 DVB SI
*q++=1; // 1 byte, all flags sets to 0
*q++=0; // omit all fields...
}
- if (st->codec->codec_id==AV_CODEC_ID_EAC3 && (ts->flags & MPEGTS_FLAG_SYSTEM_B)) {
+ if (st->codecpar->codec_id==AV_CODEC_ID_EAC3 && (ts->flags & MPEGTS_FLAG_SYSTEM_B)) {
*q++=0x7a; // EAC3 descriptor see A038 DVB SI
*q++=1; // 1 byte, all flags sets to 0
*q++=0; // omit all fields...
}
- if (st->codec->codec_id==AV_CODEC_ID_S302M) {
+ if (st->codecpar->codec_id==AV_CODEC_ID_S302M) {
*q++ = 0x05; /* MPEG-2 registration descriptor*/
*q++ = 4;
*q++ = 'B';
@@ -378,7 +378,7 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
*q++ = 'S';
*q++ = 'D';
}
- if (st->codec->codec_id==AV_CODEC_ID_OPUS) {
+ if (st->codecpar->codec_id==AV_CODEC_ID_OPUS) {
/* 6 bytes registration descriptor, 4 bytes Opus audio descriptor */
if (q - data > SECTION_LENGTH - 6 - 4) {
err = 1;
@@ -396,12 +396,12 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
*q++ = 2;
*q++ = 0x80;
- if (st->codec->extradata && st->codec->extradata_size >= 19) {
- if (st->codec->extradata[18] == 0 && st->codec->channels <= 2) {
+ if (st->codecpar->extradata && st->codecpar->extradata_size >= 19) {
+ if (st->codecpar->extradata[18] == 0 && st->codecpar->channels <= 2) {
/* RTP mapping family */
- *q++ = st->codec->channels;
- } else if (st->codec->extradata[18] == 1 && st->codec->channels <= 8 &&
- st->codec->extradata_size >= 21 + st->codec->channels) {
+ *q++ = st->codecpar->channels;
+ } else if (st->codecpar->extradata[18] == 1 && st->codecpar->channels <= 8 &&
+ st->codecpar->extradata_size >= 21 + st->codecpar->channels) {
static const uint8_t coupled_stream_counts[9] = {
1, 0, 1, 1, 2, 2, 2, 3, 3
};
@@ -427,14 +427,14 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
};
/* Vorbis mapping family */
- if (st->codec->extradata[19] == st->codec->channels - coupled_stream_counts[st->codec->channels] &&
- st->codec->extradata[20] == coupled_stream_counts[st->codec->channels] &&
- memcmp(&st->codec->extradata[21], channel_map_a[st->codec->channels-1], st->codec->channels) == 0) {
- *q++ = st->codec->channels;
- } else if (st->codec->channels >= 2 && st->codec->extradata[19] == st->codec->channels &&
- st->codec->extradata[20] == 0 &&
- memcmp(&st->codec->extradata[21], channel_map_b[st->codec->channels-1], st->codec->channels) == 0) {
- *q++ = st->codec->channels | 0x80;
+ if (st->codecpar->extradata[19] == st->codecpar->channels - coupled_stream_counts[st->codecpar->channels] &&
+ st->codecpar->extradata[20] == coupled_stream_counts[st->codecpar->channels] &&
+ memcmp(&st->codecpar->extradata[21], channel_map_a[st->codecpar->channels-1], st->codecpar->channels) == 0) {
+ *q++ = st->codecpar->channels;
+ } else if (st->codecpar->channels >= 2 && st->codecpar->extradata[19] == st->codecpar->channels &&
+ st->codecpar->extradata[20] == 0 &&
+ memcmp(&st->codecpar->extradata[21], channel_map_b[st->codecpar->channels-1], st->codecpar->channels) == 0) {
+ *q++ = st->codecpar->channels | 0x80;
} else {
/* Unsupported, could write an extended descriptor here */
av_log(s, AV_LOG_ERROR, "Unsupported Opus Vorbis-style channel mapping");
@@ -442,12 +442,12 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
}
} else {
/* Unsupported */
- av_log(s, AV_LOG_ERROR, "Unsupported Opus channel mapping for family %d", st->codec->extradata[18]);
+ av_log(s, AV_LOG_ERROR, "Unsupported Opus channel mapping for family %d", st->codecpar->extradata[18]);
*q++ = 0xff;
}
- } else if (st->codec->channels <= 2) {
+ } else if (st->codecpar->channels <= 2) {
/* Assume RTP mapping family */
- *q++ = st->codec->channels;
+ *q++ = st->codecpar->channels;
} else {
/* Unsupported */
av_log(s, AV_LOG_ERROR, "Unsupported Opus channel mapping");
@@ -498,7 +498,7 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
const char default_language[] = "und";
const char *language = lang && strlen(lang->value) >= 3 ? lang->value : default_language;
- if (st->codec->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
uint8_t *len_ptr;
int extradata_copied = 0;
@@ -517,9 +517,9 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
if (*language != '\0')
language++;
- if (st->codec->extradata_size - extradata_copied >= 5) {
- *q++ = st->codec->extradata[extradata_copied + 4]; /* subtitling_type */
- memcpy(q, st->codec->extradata + extradata_copied, 4); /* composition_page_id and ancillary_page_id */
+ if (st->codecpar->extradata_size - extradata_copied >= 5) {
+ *q++ = st->codecpar->extradata[extradata_copied + 4]; /* subtitling_type */
+ memcpy(q, st->codecpar->extradata + extradata_copied, 4); /* composition_page_id and ancillary_page_id */
extradata_copied += 5;
q += 4;
} else {
@@ -527,9 +527,9 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
* 0x10 - normal with no monitor aspect ratio criticality
* 0x20 - for the hard of hearing with no monitor aspect ratio criticality */
*q++ = (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED) ? 0x20 : 0x10;
- if ((st->codec->extradata_size == 4) && (extradata_copied == 0)) {
+ if ((st->codecpar->extradata_size == 4) && (extradata_copied == 0)) {
/* support of old 4-byte extradata format */
- memcpy(q, st->codec->extradata, 4); /* composition_page_id and ancillary_page_id */
+ memcpy(q, st->codecpar->extradata, 4); /* composition_page_id and ancillary_page_id */
extradata_copied += 4;
q += 4;
} else {
@@ -540,7 +540,7 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
}
*len_ptr = q - len_ptr - 1;
- } else if (st->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
uint8_t *len_ptr = NULL;
int extradata_copied = 0;
@@ -556,8 +556,8 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
if (*language != '\0')
language++;
- if (st->codec->extradata_size - 1 > extradata_copied) {
- memcpy(q, st->codec->extradata + extradata_copied, 2);
+ if (st->codecpar->extradata_size - 1 > extradata_copied) {
+ memcpy(q, st->codecpar->extradata + extradata_copied, 2);
extradata_copied += 2;
q += 2;
} else {
@@ -592,7 +592,7 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
}
break;
case AVMEDIA_TYPE_DATA:
- if (st->codec->codec_id == AV_CODEC_ID_SMPTE_KLV) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_SMPTE_KLV) {
*q++ = 0x05; /* MPEG-2 registration descriptor */
*q++ = 4;
*q++ = 'K';
@@ -866,13 +866,13 @@ static int mpegts_init(AVFormatContext *s)
ts_st->first_pts_check = 1;
ts_st->cc = 15;
/* update PCR pid by using the first video stream */
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
service->pcr_pid == 0x1fff) {
service->pcr_pid = ts_st->pid;
pcr_st = st;
}
- if (st->codec->codec_id == AV_CODEC_ID_AAC &&
- st->codec->extradata_size > 0) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
+ st->codecpar->extradata_size > 0) {
AVStream *ast;
ts_st->amux = avformat_alloc_context();
if (!ts_st->amux) {
@@ -890,7 +890,7 @@ static int mpegts_init(AVFormatContext *s)
ret = AVERROR(ENOMEM);
goto fail;
}
- ret = avcodec_copy_context(ast->codec, st->codec);
+ ret = avcodec_parameters_copy(ast->codecpar, st->codecpar);
if (ret != 0)
goto fail;
ast->time_base = st->time_base;
@@ -898,8 +898,8 @@ static int mpegts_init(AVFormatContext *s)
if (ret < 0)
goto fail;
}
- if (st->codec->codec_id == AV_CODEC_ID_OPUS) {
- ts_st->opus_pending_trim_start = st->codec->initial_padding * 48000 / st->codec->sample_rate;
+ if (st->codecpar->codec_id == AV_CODEC_ID_OPUS) {
+ ts_st->opus_pending_trim_start = st->codecpar->initial_padding * 48000 / st->codecpar->sample_rate;
}
}
@@ -927,14 +927,15 @@ static int mpegts_init(AVFormatContext *s)
/* Arbitrary values, PAT/PMT will also be written on video key frames */
ts->sdt_packet_period = 200;
ts->pat_packet_period = 40;
- if (pcr_st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- if (!pcr_st->codec->frame_size) {
+ if (pcr_st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ int frame_size = av_get_audio_frame_duration2(pcr_st->codecpar, 0);
+ if (!frame_size) {
av_log(s, AV_LOG_WARNING, "frame size not set\n");
service->pcr_packet_period =
- pcr_st->codec->sample_rate / (10 * 512);
+ pcr_st->codecpar->sample_rate / (10 * 512);
} else {
service->pcr_packet_period =
- pcr_st->codec->sample_rate / (10 * pcr_st->codec->frame_size);
+ pcr_st->codecpar->sample_rate / (10 * frame_size);
}
} else {
// max delta PCR 0.1s
@@ -1132,10 +1133,10 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
int afc_len, stuffing_len;
int64_t pcr = -1; /* avoid warning */
int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
- int force_pat = st->codec->codec_type == AVMEDIA_TYPE_VIDEO && key && !ts_st->prev_payload_key;
+ int force_pat = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && key && !ts_st->prev_payload_key;
- av_assert0(ts_st->payload != buf || st->codec->codec_type != AVMEDIA_TYPE_VIDEO);
- if (ts->flags & MPEGTS_FLAG_PAT_PMT_AT_FRAMES && st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ av_assert0(ts_st->payload != buf || st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO);
+ if (ts->flags & MPEGTS_FLAG_PAT_PMT_AT_FRAMES && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
force_pat = 1;
}
@@ -1205,31 +1206,31 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
*q++ = 0x01;
is_dvb_subtitle = 0;
is_dvb_teletext = 0;
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- if (st->codec->codec_id == AV_CODEC_ID_DIRAC)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_DIRAC)
*q++ = 0xfd;
else
*q++ = 0xe0;
- } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
- (st->codec->codec_id == AV_CODEC_ID_MP2 ||
- st->codec->codec_id == AV_CODEC_ID_MP3 ||
- st->codec->codec_id == AV_CODEC_ID_AAC)) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
+ (st->codecpar->codec_id == AV_CODEC_ID_MP2 ||
+ st->codecpar->codec_id == AV_CODEC_ID_MP3 ||
+ st->codecpar->codec_id == AV_CODEC_ID_AAC)) {
*q++ = 0xc0;
- } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
- st->codec->codec_id == AV_CODEC_ID_AC3 &&
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
+ st->codecpar->codec_id == AV_CODEC_ID_AC3 &&
ts->m2ts_mode) {
*q++ = 0xfd;
- } else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
*q++ = stream_id != -1 ? stream_id : 0xfc;
if (stream_id == 0xbd) /* asynchronous KLV */
pts = dts = AV_NOPTS_VALUE;
} else {
*q++ = 0xbd;
- if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
- if (st->codec->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
is_dvb_subtitle = 1;
- } else if (st->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
is_dvb_teletext = 1;
}
}
@@ -1244,8 +1245,8 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
header_len += 5;
flags |= 0x40;
}
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
- st->codec->codec_id == AV_CODEC_ID_DIRAC) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
+ st->codecpar->codec_id == AV_CODEC_ID_DIRAC) {
/* set PES_extension_flag */
pes_extension = 1;
flags |= 0x01;
@@ -1259,8 +1260,8 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
* otherwise it will not play sound on blu-ray
*/
if (ts->m2ts_mode &&
- st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
- st->codec->codec_id == AV_CODEC_ID_AC3) {
+ st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
+ st->codecpar->codec_id == AV_CODEC_ID_AC3) {
/* set PES_extension_flag */
pes_extension = 1;
flags |= 0x01;
@@ -1278,14 +1279,14 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
}
if (len > 0xffff)
len = 0;
- if (ts->omit_video_pes_length && st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (ts->omit_video_pes_length && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
len = 0;
}
*q++ = len >> 8;
*q++ = len;
val = 0x80;
/* data alignment indicator is required for subtitle and data streams */
- if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE || st->codec->codec_type == AVMEDIA_TYPE_DATA)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || st->codecpar->codec_type == AVMEDIA_TYPE_DATA)
val |= 0x04;
*q++ = val;
*q++ = flags;
@@ -1298,7 +1299,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
write_pts(q, 1, dts);
q += 5;
}
- if (pes_extension && st->codec->codec_id == AV_CODEC_ID_DIRAC) {
+ if (pes_extension && st->codecpar->codec_id == AV_CODEC_ID_DIRAC) {
flags = 0x01; /* set PES_extension_flag_2 */
*q++ = flags;
*q++ = 0x80 | 0x01; /* marker bit + extension length */
@@ -1309,7 +1310,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
/* For Blu-ray AC3 Audio Setting extended flags */
if (ts->m2ts_mode &&
pes_extension &&
- st->codec->codec_id == AV_CODEC_ID_AC3) {
+ st->codecpar->codec_id == AV_CODEC_ID_AC3) {
flags = 0x01; /* set PES_extension_flag_2 */
*q++ = flags;
*q++ = 0x80 | 0x01; /* marker bit + extension length */
@@ -1503,15 +1504,15 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
}
ts_st->first_pts_check = 0;
- if (st->codec->codec_id == AV_CODEC_ID_H264) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
const uint8_t *p = buf, *buf_end = p + size;
uint32_t state = -1;
- int extradd = (pkt->flags & AV_PKT_FLAG_KEY) ? st->codec->extradata_size : 0;
+ int extradd = (pkt->flags & AV_PKT_FLAG_KEY) ? st->codecpar->extradata_size : 0;
int ret = ff_check_h264_startcode(s, st, pkt);
if (ret < 0)
return ret;
- if (extradd && AV_RB24(st->codec->extradata) > 1)
+ if (extradd && AV_RB24(st->codecpar->extradata) > 1)
extradd = 0;
do {
@@ -1528,7 +1529,7 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
data = av_malloc(pkt->size + 6 + extradd);
if (!data)
return AVERROR(ENOMEM);
- memcpy(data + 6, st->codec->extradata, extradd);
+ memcpy(data + 6, st->codecpar->extradata, extradd);
memcpy(data + 6 + extradd, pkt->data, pkt->size);
AV_WB32(data, 0x00000001);
data[4] = 0x09;
@@ -1536,7 +1537,7 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
buf = data;
size = pkt->size + 6 + extradd;
}
- } else if (st->codec->codec_id == AV_CODEC_ID_AAC) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
if (pkt->size < 2) {
av_log(s, AV_LOG_ERROR, "AAC packet too short\n");
return AVERROR_INVALIDDATA;
@@ -1569,11 +1570,11 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
buf = data;
}
}
- } else if (st->codec->codec_id == AV_CODEC_ID_HEVC) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_HEVC) {
int ret = check_hevc_startcode(s, st, pkt);
if (ret < 0)
return ret;
- } else if (st->codec->codec_id == AV_CODEC_ID_OPUS) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_OPUS) {
if (pkt->size < 2) {
av_log(s, AV_LOG_ERROR, "Opus packet too short\n");
return AVERROR_INVALIDDATA;
@@ -1594,7 +1595,7 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
&side_data_size);
if (side_data && side_data_size >= 10) {
- trim_end = AV_RL32(side_data + 4) * 48000 / st->codec->sample_rate;
+ trim_end = AV_RL32(side_data + 4) * 48000 / st->codecpar->sample_rate;
}
ctrl_header_size = pkt->size + 2 + pkt->size / 255 + 1;
@@ -1673,7 +1674,7 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
ts_st->opus_queued_samples = 0;
}
- if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO || size > ts->pes_payload_size) {
+ if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO || size > ts->pes_payload_size) {
av_assert0(!ts_st->payload_size);
// for video and subtitle, write a single pes packet
mpegts_write_pes(s, st, buf, size, pts, dts,
@@ -1766,11 +1767,11 @@ static int mpegts_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt
int ret = 1;
AVStream *st = s->streams[pkt->stream_index];
- if (st->codec->codec_id == AV_CODEC_ID_H264) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
if (pkt->size >= 5 && AV_RB32(pkt->data) != 0x0000001 &&
AV_RB24(pkt->data) != 0x000001)
ret = ff_stream_add_bitstream_filter(st, "h264_mp4toannexb", NULL);
- } else if (st->codec->codec_id == AV_CODEC_ID_HEVC) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_HEVC) {
if (pkt->size >= 5 && AV_RB32(pkt->data) != 0x0000001 &&
AV_RB24(pkt->data) != 0x000001)
ret = ff_stream_add_bitstream_filter(st, "hevc_mp4toannexb", NULL);
diff --git a/libavformat/mpjpegdec.c b/libavformat/mpjpegdec.c
index 6f85e5620f..4c7764412f 100644
--- a/libavformat/mpjpegdec.c
+++ b/libavformat/mpjpegdec.c
@@ -151,8 +151,8 @@ static int mpjpeg_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- 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;
avpriv_set_pts_info(st, 60, 1, 25);
diff --git a/libavformat/mpl2dec.c b/libavformat/mpl2dec.c
index 81cc0bbb2d..59589d5b5e 100644
--- a/libavformat/mpl2dec.c
+++ b/libavformat/mpl2dec.c
@@ -80,8 +80,8 @@ static int mpl2_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 10);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_MPL2;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_MPL2;
while (!avio_feof(s->pb)) {
char line[4096];
diff --git a/libavformat/mpsubdec.c b/libavformat/mpsubdec.c
index c5a50ecb5c..1236efa712 100644
--- a/libavformat/mpsubdec.c
+++ b/libavformat/mpsubdec.c
@@ -100,8 +100,8 @@ static int mpsub_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, pts_info.den, pts_info.num);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_TEXT;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_TEXT;
ff_subtitles_queue_finalize(s, &mpsub->q);
diff --git a/libavformat/msf.c b/libavformat/msf.c
index 97a6dc6929..0551e9bc24 100644
--- a/libavformat/msf.c
+++ b/libavformat/msf.c
@@ -51,41 +51,41 @@ static int msf_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
codec = avio_rb32(s->pb);
- st->codec->channels = avio_rb32(s->pb);
- if (st->codec->channels <= 0 || st->codec->channels >= INT_MAX / 1024)
+ st->codecpar->channels = avio_rb32(s->pb);
+ if (st->codecpar->channels <= 0 || st->codecpar->channels >= INT_MAX / 1024)
return AVERROR_INVALIDDATA;
size = avio_rb32(s->pb);
- st->codec->sample_rate = avio_rb32(s->pb);
- if (st->codec->sample_rate <= 0)
+ st->codecpar->sample_rate = avio_rb32(s->pb);
+ if (st->codecpar->sample_rate <= 0)
return AVERROR_INVALIDDATA;
align = avio_rb32(s->pb) ;
- if (align > INT_MAX / st->codec->channels)
+ if (align > INT_MAX / st->codecpar->channels)
return AVERROR_INVALIDDATA;
- st->codec->block_align = align;
+ st->codecpar->block_align = align;
switch (codec) {
- case 0: st->codec->codec_id = AV_CODEC_ID_PCM_S16BE; break;
- case 3: st->codec->block_align = 16 * st->codec->channels;
- st->codec->codec_id = AV_CODEC_ID_ADPCM_PSX; break;
+ case 0: st->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE; break;
+ case 3: st->codecpar->block_align = 16 * st->codecpar->channels;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX; break;
case 7: st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
- st->codec->codec_id = AV_CODEC_ID_MP3; break;
+ st->codecpar->codec_id = AV_CODEC_ID_MP3; break;
default:
avpriv_request_sample(s, "Codec %d", codec);
return AVERROR_PATCHWELCOME;
}
- st->duration = av_get_audio_frame_duration(st->codec, size);
+ st->duration = av_get_audio_frame_duration2(st->codecpar, size);
avio_skip(s->pb, 0x40 - avio_tell(s->pb));
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
static int msf_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- AVCodecContext *codec = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
- return av_get_packet(s->pb, pkt, codec->block_align ? codec->block_align : 1024 * codec->channels);
+ return av_get_packet(s->pb, pkt, par->block_align ? par->block_align : 1024 * par->channels);
}
AVInputFormat ff_msf_demuxer = {
diff --git a/libavformat/msnwc_tcp.c b/libavformat/msnwc_tcp.c
index 5abf006cc0..3c73ac7b2c 100644
--- a/libavformat/msnwc_tcp.c
+++ b/libavformat/msnwc_tcp.c
@@ -74,17 +74,17 @@ static int msnwc_tcp_probe(AVProbeData *p)
static int msnwc_tcp_read_header(AVFormatContext *ctx)
{
AVIOContext *pb = ctx->pb;
- AVCodecContext *codec;
+ AVCodecParameters *par;
AVStream *st;
st = avformat_new_stream(ctx, NULL);
if (!st)
return AVERROR(ENOMEM);
- codec = st->codec;
- codec->codec_type = AVMEDIA_TYPE_VIDEO;
- codec->codec_id = AV_CODEC_ID_MIMIC;
- codec->codec_tag = MKTAG('M', 'L', '2', '0');
+ par = st->codecpar;
+ par->codec_type = AVMEDIA_TYPE_VIDEO;
+ par->codec_id = AV_CODEC_ID_MIMIC;
+ par->codec_tag = MKTAG('M', 'L', '2', '0');
avpriv_set_pts_info(st, 32, 1, 1000);
diff --git a/libavformat/mtv.c b/libavformat/mtv.c
index a91e4c8649..dcf4aa4288 100644
--- a/libavformat/mtv.c
+++ b/libavformat/mtv.c
@@ -165,13 +165,13 @@ static int mtv_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, mtv->video_fps);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
- st->codec->pix_fmt = AV_PIX_FMT_RGB565BE;
- st->codec->width = mtv->img_width;
- st->codec->height = mtv->img_height;
- st->codec->extradata = av_strdup("BottomUp");
- st->codec->extradata_size = 9;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
+ st->codecpar->format = AV_PIX_FMT_RGB565BE;
+ st->codecpar->width = mtv->img_width;
+ st->codecpar->height = mtv->img_height;
+ st->codecpar->extradata = av_strdup("BottomUp");
+ st->codecpar->extradata_size = 9;
// audio - mp3
@@ -180,10 +180,10 @@ static int mtv_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, MTV_AUDIO_SAMPLING_RATE);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_MP3;
- st->codec->bit_rate = mtv->audio_br;
- st->need_parsing = AVSTREAM_PARSE_FULL;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_MP3;
+ st->codecpar->bit_rate = mtv->audio_br;
+ st->need_parsing = AVSTREAM_PARSE_FULL;
// Jump over header
diff --git a/libavformat/musx.c b/libavformat/musx.c
index ca43254028..aff6c31a86 100644
--- a/libavformat/musx.c
+++ b/libavformat/musx.c
@@ -55,32 +55,32 @@ static int musx_read_header(AVFormatContext *s)
if (version == 201) {
avio_skip(s->pb, 8);
offset = avio_rl32(s->pb);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_ADPCM_PSX;
- st->codec->channels = 2;
- st->codec->sample_rate = 32000;
- st->codec->block_align = 0x80 * st->codec->channels;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX;
+ st->codecpar->channels = 2;
+ st->codecpar->sample_rate = 32000;
+ st->codecpar->block_align = 0x80 * st->codecpar->channels;
} else if (version == 10) {
type = avio_rl32(s->pb);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
offset = 0x800;
switch (type) {
case MKTAG('P', 'S', '3', '_'):
- st->codec->channels = 2;
- st->codec->sample_rate = 44100;
+ st->codecpar->channels = 2;
+ st->codecpar->sample_rate = 44100;
avio_skip(s->pb, 44);
coding = avio_rl32(s->pb);
if (coding == MKTAG('D', 'A', 'T', '4') ||
coding == MKTAG('D', 'A', 'T', '8')) {
avio_skip(s->pb, 4);
- st->codec->channels = avio_rl32(s->pb);
- if (st->codec->channels <= 0 ||
- st->codec->channels > INT_MAX / 0x20)
+ st->codecpar->channels = avio_rl32(s->pb);
+ if (st->codecpar->channels <= 0 ||
+ st->codecpar->channels > INT_MAX / 0x20)
return AVERROR_INVALIDDATA;
- st->codec->sample_rate = avio_rl32(s->pb);
+ st->codecpar->sample_rate = avio_rl32(s->pb);
}
- st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_DAT4;
- st->codec->block_align = 0x20 * st->codec->channels;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_DAT4;
+ st->codecpar->block_align = 0x20 * st->codecpar->channels;
break;
case MKTAG('W', 'I', 'I', '_'):
avio_skip(s->pb, 44);
@@ -91,31 +91,31 @@ static int musx_read_header(AVFormatContext *s)
return AVERROR_PATCHWELCOME;
}
avio_skip(s->pb, 4);
- st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_DAT4;
- st->codec->channels = avio_rl32(s->pb);
- if (st->codec->channels <= 0 ||
- st->codec->channels > INT_MAX / 0x20)
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_DAT4;
+ st->codecpar->channels = avio_rl32(s->pb);
+ if (st->codecpar->channels <= 0 ||
+ st->codecpar->channels > INT_MAX / 0x20)
return AVERROR_INVALIDDATA;
- st->codec->sample_rate = avio_rl32(s->pb);
- st->codec->block_align = 0x20 * st->codec->channels;
+ st->codecpar->sample_rate = avio_rl32(s->pb);
+ st->codecpar->block_align = 0x20 * st->codecpar->channels;
break;
case MKTAG('X', 'E', '_', '_'):
- st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_DAT4;
- st->codec->channels = 2;
- st->codec->sample_rate = 32000;
- st->codec->block_align = 0x20 * st->codec->channels;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_DAT4;
+ st->codecpar->channels = 2;
+ st->codecpar->sample_rate = 32000;
+ st->codecpar->block_align = 0x20 * st->codecpar->channels;
break;
case MKTAG('P', 'S', 'P', '_'):
- st->codec->codec_id = AV_CODEC_ID_ADPCM_PSX;
- st->codec->channels = 2;
- st->codec->sample_rate = 32768;
- st->codec->block_align = 0x80 * st->codec->channels;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX;
+ st->codecpar->channels = 2;
+ st->codecpar->sample_rate = 32768;
+ st->codecpar->block_align = 0x80 * st->codecpar->channels;
break;
case MKTAG('P', 'S', '2', '_'):
- st->codec->codec_id = AV_CODEC_ID_ADPCM_PSX;
- st->codec->channels = 2;
- st->codec->sample_rate = 32000;
- st->codec->block_align = 0x80 * st->codec->channels;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX;
+ st->codecpar->channels = 2;
+ st->codecpar->sample_rate = 32000;
+ st->codecpar->block_align = 0x80 * st->codecpar->channels;
break;
default:
avpriv_request_sample(s, "Unsupported type: %X", type);
@@ -124,25 +124,25 @@ static int musx_read_header(AVFormatContext *s)
} else if (version == 6 || version == 5 || version == 4) {
type = avio_rl32(s->pb);
avio_skip(s->pb, 20);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->channels = 2;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->channels = 2;
switch (type) {
case MKTAG('G', 'C', '_', '_'):
- st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_DAT4;
- st->codec->block_align = 0x20 * st->codec->channels;
- st->codec->sample_rate = 32000;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_DAT4;
+ st->codecpar->block_align = 0x20 * st->codecpar->channels;
+ st->codecpar->sample_rate = 32000;
offset = avio_rb32(s->pb);
break;
case MKTAG('P', 'S', '2', '_'):
- st->codec->codec_id = AV_CODEC_ID_ADPCM_PSX;
- st->codec->block_align = 0x80 * st->codec->channels;
- st->codec->sample_rate = 32000;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX;
+ st->codecpar->block_align = 0x80 * st->codecpar->channels;
+ st->codecpar->sample_rate = 32000;
offset = avio_rl32(s->pb);
break;
case MKTAG('X', 'B', '_', '_'):
- st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_DAT4;
- st->codec->block_align = 0x20 * st->codec->channels;
- st->codec->sample_rate = 44100;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_DAT4;
+ st->codecpar->block_align = 0x20 * st->codecpar->channels;
+ st->codecpar->sample_rate = 44100;
offset = avio_rl32(s->pb);
break;
default:
@@ -155,16 +155,16 @@ static int musx_read_header(AVFormatContext *s)
avio_seek(s->pb, offset, SEEK_SET);
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
static int musx_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- AVCodecContext *codec = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
- return av_get_packet(s->pb, pkt, codec->block_align);
+ return av_get_packet(s->pb, pkt, par->block_align);
}
AVInputFormat ff_musx_demuxer = {
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 9ca5df4095..33301f1d79 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -117,24 +117,24 @@ AVRational ff_choose_timebase(AVFormatContext *s, AVStream *st, int min_precisio
enum AVChromaLocation ff_choose_chroma_location(AVFormatContext *s, AVStream *st)
{
- AVCodecContext *avctx = st->codec;
- const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+ AVCodecParameters *par = st->codecpar;
+ const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(par->format);
- if (avctx->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED)
- return avctx->chroma_sample_location;
+ if (par->chroma_location != AVCHROMA_LOC_UNSPECIFIED)
+ return par->chroma_location;
if (pix_desc) {
if (pix_desc->log2_chroma_h == 0) {
return AVCHROMA_LOC_TOPLEFT;
} else if (pix_desc->log2_chroma_w == 1 && pix_desc->log2_chroma_h == 1) {
- if (avctx->field_order == AV_FIELD_UNKNOWN || avctx->field_order == AV_FIELD_PROGRESSIVE) {
- switch (avctx->codec_id) {
+ if (par->field_order == AV_FIELD_UNKNOWN || par->field_order == AV_FIELD_PROGRESSIVE) {
+ switch (par->codec_id) {
case AV_CODEC_ID_MJPEG:
case AV_CODEC_ID_MPEG1VIDEO: return AVCHROMA_LOC_CENTER;
}
}
- if (avctx->field_order == AV_FIELD_UNKNOWN || avctx->field_order != AV_FIELD_PROGRESSIVE) {
- switch (avctx->codec_id) {
+ if (par->field_order == AV_FIELD_UNKNOWN || par->field_order != AV_FIELD_PROGRESSIVE) {
+ switch (par->codec_id) {
case AV_CODEC_ID_MPEG2VIDEO: return AVCHROMA_LOC_LEFT;
}
}
@@ -214,12 +214,12 @@ static int validate_codec_tag(AVFormatContext *s, AVStream *st)
for (n = 0; s->oformat->codec_tag[n]; n++) {
avctag = s->oformat->codec_tag[n];
while (avctag->id != AV_CODEC_ID_NONE) {
- if (avpriv_toupper4(avctag->tag) == avpriv_toupper4(st->codec->codec_tag)) {
+ if (avpriv_toupper4(avctag->tag) == avpriv_toupper4(st->codecpar->codec_tag)) {
id = avctag->id;
- if (id == st->codec->codec_id)
+ if (id == st->codecpar->codec_id)
return 1;
}
- if (avctag->id == st->codec->codec_id)
+ if (avctag->id == st->codecpar->codec_id)
tag = avctag->tag;
avctag++;
}
@@ -237,7 +237,7 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
int ret = 0, i;
AVStream *st;
AVDictionary *tmp = NULL;
- AVCodecContext *codec = NULL;
+ AVCodecParameters *par = NULL;
AVOutputFormat *of = s->oformat;
const AVCodecDescriptor *desc;
AVDictionaryEntry *e;
@@ -251,6 +251,8 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
(ret = av_opt_set_dict2(s->priv_data, &tmp, AV_OPT_SEARCH_CHILDREN)) < 0)
goto fail;
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
if (s->nb_streams && s->streams[0]->codec->flags & AV_CODEC_FLAG_BITEXACT) {
if (!(s->flags & AVFMT_FLAG_BITEXACT)) {
#if FF_API_LAVF_BITEXACT
@@ -268,6 +270,8 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
#endif
}
}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
// some sanity checks
if (s->nb_streams == 0 && !(of->flags & AVFMT_NOSTREAMS)) {
@@ -277,58 +281,72 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
}
for (i = 0; i < s->nb_streams; i++) {
- st = s->streams[i];
- codec = st->codec;
+ st = s->streams[i];
+ par = st->codecpar;
#if FF_API_LAVF_CODEC_TB
FF_DISABLE_DEPRECATION_WARNINGS
- if (!st->time_base.num && codec->time_base.num) {
+ if (!st->time_base.num && st->codec->time_base.num) {
av_log(s, AV_LOG_WARNING, "Using AVStream.codec.time_base as a "
"timebase hint to the muxer is deprecated. Set "
"AVStream.time_base instead.\n");
- avpriv_set_pts_info(st, 64, codec->time_base.num, codec->time_base.den);
+ avpriv_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den);
+ }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_UNKNOWN &&
+ st->codec->codec_type != AVMEDIA_TYPE_UNKNOWN) {
+ av_log(s, AV_LOG_WARNING, "Using AVStream.codec to pass codec "
+ "parameters to muxers is deprecated, use AVStream.codecpar "
+ "instead.\n");
+ ret = avcodec_parameters_from_context(st->codecpar, st->codec);
+ if (ret < 0)
+ goto fail;
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (!st->time_base.num) {
/* fall back on the default timebase values */
- if (codec->codec_type == AVMEDIA_TYPE_AUDIO && codec->sample_rate)
- avpriv_set_pts_info(st, 64, 1, codec->sample_rate);
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO && par->sample_rate)
+ avpriv_set_pts_info(st, 64, 1, par->sample_rate);
else
avpriv_set_pts_info(st, 33, 1, 90000);
}
- switch (codec->codec_type) {
+ switch (par->codec_type) {
case AVMEDIA_TYPE_AUDIO:
- if (codec->sample_rate <= 0) {
+ if (par->sample_rate <= 0) {
av_log(s, AV_LOG_ERROR, "sample rate not set\n");
ret = AVERROR(EINVAL);
goto fail;
}
- if (!codec->block_align)
- codec->block_align = codec->channels *
- av_get_bits_per_sample(codec->codec_id) >> 3;
+ if (!par->block_align)
+ par->block_align = par->channels *
+ av_get_bits_per_sample(par->codec_id) >> 3;
break;
case AVMEDIA_TYPE_VIDEO:
- if ((codec->width <= 0 || codec->height <= 0) &&
+ if ((par->width <= 0 || par->height <= 0) &&
!(of->flags & AVFMT_NODIMENSIONS)) {
av_log(s, AV_LOG_ERROR, "dimensions not set\n");
ret = AVERROR(EINVAL);
goto fail;
}
- if (av_cmp_q(st->sample_aspect_ratio, codec->sample_aspect_ratio)
- && fabs(av_q2d(st->sample_aspect_ratio) - av_q2d(codec->sample_aspect_ratio)) > 0.004*av_q2d(st->sample_aspect_ratio)
+ if (av_cmp_q(st->sample_aspect_ratio, par->sample_aspect_ratio)
+ && fabs(av_q2d(st->sample_aspect_ratio) - av_q2d(par->sample_aspect_ratio)) > 0.004*av_q2d(st->sample_aspect_ratio)
) {
if (st->sample_aspect_ratio.num != 0 &&
st->sample_aspect_ratio.den != 0 &&
- codec->sample_aspect_ratio.num != 0 &&
- codec->sample_aspect_ratio.den != 0) {
+ par->sample_aspect_ratio.num != 0 &&
+ par->sample_aspect_ratio.den != 0) {
av_log(s, AV_LOG_ERROR, "Aspect ratio mismatch between muxer "
"(%d/%d) and encoder layer (%d/%d)\n",
st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
- codec->sample_aspect_ratio.num,
- codec->sample_aspect_ratio.den);
+ par->sample_aspect_ratio.num,
+ par->sample_aspect_ratio.den);
ret = AVERROR(EINVAL);
goto fail;
}
@@ -336,36 +354,36 @@ FF_ENABLE_DEPRECATION_WARNINGS
break;
}
- desc = avcodec_descriptor_get(codec->codec_id);
+ desc = avcodec_descriptor_get(par->codec_id);
if (desc && desc->props & AV_CODEC_PROP_REORDER)
st->internal->reorder = 1;
if (of->codec_tag) {
- if ( codec->codec_tag
- && codec->codec_id == AV_CODEC_ID_RAWVIDEO
- && ( av_codec_get_tag(of->codec_tag, codec->codec_id) == 0
- || av_codec_get_tag(of->codec_tag, codec->codec_id) == MKTAG('r', 'a', 'w', ' '))
+ if ( par->codec_tag
+ && par->codec_id == AV_CODEC_ID_RAWVIDEO
+ && ( av_codec_get_tag(of->codec_tag, par->codec_id) == 0
+ || av_codec_get_tag(of->codec_tag, par->codec_id) == MKTAG('r', 'a', 'w', ' '))
&& !validate_codec_tag(s, st)) {
// the current rawvideo encoding system ends up setting
// the wrong codec_tag for avi/mov, we override it here
- codec->codec_tag = 0;
+ par->codec_tag = 0;
}
- if (codec->codec_tag) {
+ if (par->codec_tag) {
if (!validate_codec_tag(s, st)) {
char tagbuf[32], tagbuf2[32];
- av_get_codec_tag_string(tagbuf, sizeof(tagbuf), codec->codec_tag);
- av_get_codec_tag_string(tagbuf2, sizeof(tagbuf2), av_codec_get_tag(s->oformat->codec_tag, codec->codec_id));
+ av_get_codec_tag_string(tagbuf, sizeof(tagbuf), par->codec_tag);
+ av_get_codec_tag_string(tagbuf2, sizeof(tagbuf2), av_codec_get_tag(s->oformat->codec_tag, par->codec_id));
av_log(s, AV_LOG_ERROR,
"Tag %s/0x%08x incompatible with output codec id '%d' (%s)\n",
- tagbuf, codec->codec_tag, codec->codec_id, tagbuf2);
+ tagbuf, par->codec_tag, par->codec_id, tagbuf2);
ret = AVERROR_INVALIDDATA;
goto fail;
}
} else
- codec->codec_tag = av_codec_get_tag(of->codec_tag, codec->codec_id);
+ par->codec_tag = av_codec_get_tag(of->codec_tag, par->codec_id);
}
- if (codec->codec_type != AVMEDIA_TYPE_ATTACHMENT)
+ if (par->codec_type != AVMEDIA_TYPE_ATTACHMENT)
s->internal->nb_interleaved_streams++;
}
@@ -421,12 +439,12 @@ static int init_pts(AVFormatContext *s)
int64_t den = AV_NOPTS_VALUE;
st = s->streams[i];
- switch (st->codec->codec_type) {
+ switch (st->codecpar->codec_type) {
case AVMEDIA_TYPE_AUDIO:
- den = (int64_t)st->time_base.num * st->codec->sample_rate;
+ den = (int64_t)st->time_base.num * st->codecpar->sample_rate;
break;
case AVMEDIA_TYPE_VIDEO:
- den = (int64_t)st->time_base.num * st->codec->time_base.den;
+ den = (int64_t)st->time_base.num * st->time_base.den;
break;
default:
break;
@@ -490,10 +508,11 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options)
#if FF_API_COMPUTE_PKT_FIELDS2
+FF_DISABLE_DEPRECATION_WARNINGS
//FIXME merge with compute_pkt_fields
static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *pkt)
{
- int delay = FFMAX(st->codec->has_b_frames, st->codec->max_b_frames > 0);
+ int delay = FFMAX(st->codecpar->video_delay, st->internal->avctx->max_b_frames > 0);
int num, den, i;
int frame_size;
@@ -553,8 +572,8 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *
if (st->cur_dts && st->cur_dts != AV_NOPTS_VALUE &&
((!(s->oformat->flags & AVFMT_TS_NONSTRICT) &&
- st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE &&
- st->codec->codec_type != AVMEDIA_TYPE_DATA &&
+ st->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE &&
+ st->codecpar->codec_type != AVMEDIA_TYPE_DATA &&
st->cur_dts >= pkt->dts) || st->cur_dts > pkt->dts)) {
av_log(s, AV_LOG_ERROR,
"Application provided invalid, non monotonically increasing dts to muxer in stream %d: %s >= %s\n",
@@ -591,11 +610,12 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket *
}
break;
case AVMEDIA_TYPE_VIDEO:
- frac_add(st->priv_pts, (int64_t)st->time_base.den * st->codec->time_base.num);
+ frac_add(st->priv_pts, (int64_t)st->time_base.den * st->time_base.num);
break;
}
return 0;
}
+FF_ENABLE_DEPRECATION_WARNINGS
#endif
/**
@@ -715,7 +735,7 @@ static int check_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(EINVAL);
}
- if (s->streams[pkt->stream_index]->codec->codec_type == AVMEDIA_TYPE_ATTACHMENT) {
+ if (s->streams[pkt->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT) {
av_log(s, AV_LOG_ERROR, "Received a packet for an attachment stream.\n");
return AVERROR(EINVAL);
}
@@ -853,7 +873,7 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
st->interleaver_chunk_size = 0;
this_pktl->pkt.flags |= CHUNK_START;
if (max && st->interleaver_chunk_duration > max) {
- int64_t syncoffset = (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)*max/2;
+ int64_t syncoffset = (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)*max/2;
int64_t syncto = av_rescale(pkt->dts + syncoffset, 1, max)*max - syncoffset;
st->interleaver_chunk_duration += (pkt->dts - syncto)/8 - max;
@@ -898,12 +918,12 @@ static int interleave_compare_dts(AVFormatContext *s, AVPacket *next,
AVStream *st2 = s->streams[next->stream_index];
int comp = av_compare_ts(next->dts, st2->time_base, pkt->dts,
st->time_base);
- if (s->audio_preload && ((st->codec->codec_type == AVMEDIA_TYPE_AUDIO) != (st2->codec->codec_type == AVMEDIA_TYPE_AUDIO))) {
- int64_t ts = av_rescale_q(pkt ->dts, st ->time_base, AV_TIME_BASE_Q) - s->audio_preload*(st ->codec->codec_type == AVMEDIA_TYPE_AUDIO);
- int64_t ts2= av_rescale_q(next->dts, st2->time_base, AV_TIME_BASE_Q) - s->audio_preload*(st2->codec->codec_type == AVMEDIA_TYPE_AUDIO);
+ if (s->audio_preload && ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) != (st2->codecpar->codec_type == AVMEDIA_TYPE_AUDIO))) {
+ int64_t ts = av_rescale_q(pkt ->dts, st ->time_base, AV_TIME_BASE_Q) - s->audio_preload*(st ->codecpar->codec_type == AVMEDIA_TYPE_AUDIO);
+ int64_t ts2= av_rescale_q(next->dts, st2->time_base, AV_TIME_BASE_Q) - s->audio_preload*(st2->codecpar->codec_type == AVMEDIA_TYPE_AUDIO);
if (ts == ts2) {
- ts= ( pkt ->dts* st->time_base.num*AV_TIME_BASE - s->audio_preload*(int64_t)(st ->codec->codec_type == AVMEDIA_TYPE_AUDIO)* st->time_base.den)*st2->time_base.den
- -( next->dts*st2->time_base.num*AV_TIME_BASE - s->audio_preload*(int64_t)(st2->codec->codec_type == AVMEDIA_TYPE_AUDIO)*st2->time_base.den)* st->time_base.den;
+ ts= ( pkt ->dts* st->time_base.num*AV_TIME_BASE - s->audio_preload*(int64_t)(st ->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)* st->time_base.den)*st2->time_base.den
+ -( next->dts*st2->time_base.num*AV_TIME_BASE - s->audio_preload*(int64_t)(st2->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)*st2->time_base.den)* st->time_base.den;
ts2=0;
}
comp= (ts>ts2) - (ts<ts2);
@@ -930,9 +950,9 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
for (i = 0; i < s->nb_streams; i++) {
if (s->streams[i]->last_in_packet_buffer) {
++stream_count;
- } else if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_ATTACHMENT &&
- s->streams[i]->codec->codec_id != AV_CODEC_ID_VP8 &&
- s->streams[i]->codec->codec_id != AV_CODEC_ID_VP9) {
+ } else if (s->streams[i]->codecpar->codec_type != AVMEDIA_TYPE_ATTACHMENT &&
+ s->streams[i]->codecpar->codec_id != AV_CODEC_ID_VP8 &&
+ s->streams[i]->codecpar->codec_id != AV_CODEC_ID_VP9) {
++noninterleaved_count;
}
}
@@ -1034,9 +1054,16 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
}
}
- av_apply_bitstream_filters(st->codec, pkt, st->internal->bsfc);
+ av_apply_bitstream_filters(st->internal->avctx, pkt, st->internal->bsfc);
if (pkt->size == 0 && pkt->side_data_elems == 0)
return 0;
+ if (!st->codecpar->extradata && st->internal->avctx->extradata) {
+ int eret = ff_alloc_extradata(st->codecpar, st->internal->avctx->extradata_size);
+ if (eret < 0)
+ return AVERROR(ENOMEM);
+ st->codecpar->extradata_size = st->internal->avctx->extradata_size;
+ memcpy(st->codecpar->extradata, st->internal->avctx->extradata, st->internal->avctx->extradata_size);
+ }
if (s->debug & FF_FDEBUG_TS)
av_log(s, AV_LOG_TRACE, "av_interleaved_write_frame size:%d dts:%s pts:%s\n",
diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c
index 7aa6452f66..80ef4b1569 100644
--- a/libavformat/mvdec.c
+++ b/libavformat/mvdec.c
@@ -106,9 +106,9 @@ static int set_channels(AVFormatContext *avctx, AVStream *st, int channels)
av_log(avctx, AV_LOG_ERROR, "Channel count %d invalid.\n", channels);
return AVERROR_INVALIDDATA;
}
- st->codec->channels = channels;
- st->codec->channel_layout = (st->codec->channels == 1) ? AV_CH_LAYOUT_MONO
- : AV_CH_LAYOUT_STEREO;
+ st->codecpar->channels = channels;
+ st->codecpar->channel_layout = (st->codecpar->channels == 1) ? AV_CH_LAYOUT_MONO
+ : AV_CH_LAYOUT_STEREO;
return 0;
}
@@ -156,10 +156,10 @@ static int parse_audio_var(AVFormatContext *avctx, AVStream *st,
} else if (!strcmp(name, "NUM_CHANNELS")) {
return set_channels(avctx, st, var_read_int(pb, size));
} else if (!strcmp(name, "SAMPLE_RATE")) {
- st->codec->sample_rate = var_read_int(pb, size);
- avpriv_set_pts_info(st, 33, 1, st->codec->sample_rate);
+ st->codecpar->sample_rate = var_read_int(pb, size);
+ avpriv_set_pts_info(st, 33, 1, st->codecpar->sample_rate);
} else if (!strcmp(name, "SAMPLE_WIDTH")) {
- st->codec->bits_per_coded_sample = var_read_int(pb, size) * 8;
+ st->codecpar->bits_per_coded_sample = var_read_int(pb, size) * 8;
} else
return AVERROR_INVALIDDATA;
@@ -181,16 +181,16 @@ static int parse_video_var(AVFormatContext *avctx, AVStream *st,
if (!str)
return AVERROR_INVALIDDATA;
if (!strcmp(str, "1")) {
- st->codec->codec_id = AV_CODEC_ID_MVC1;
+ st->codecpar->codec_id = AV_CODEC_ID_MVC1;
} else if (!strcmp(str, "2")) {
- st->codec->pix_fmt = AV_PIX_FMT_ABGR;
- st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
+ st->codecpar->format = AV_PIX_FMT_ABGR;
+ st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
} else if (!strcmp(str, "3")) {
- st->codec->codec_id = AV_CODEC_ID_SGIRLE;
+ st->codecpar->codec_id = AV_CODEC_ID_SGIRLE;
} else if (!strcmp(str, "10")) {
- st->codec->codec_id = AV_CODEC_ID_MJPEG;
+ st->codecpar->codec_id = AV_CODEC_ID_MJPEG;
} else if (!strcmp(str, "MVC2")) {
- st->codec->codec_id = AV_CODEC_ID_MVC2;
+ st->codecpar->codec_id = AV_CODEC_ID_MVC2;
} else {
avpriv_request_sample(avctx, "Video compression %s", str);
}
@@ -200,18 +200,18 @@ static int parse_video_var(AVFormatContext *avctx, AVStream *st,
avpriv_set_pts_info(st, 64, fps.den, fps.num);
st->avg_frame_rate = fps;
} else if (!strcmp(name, "HEIGHT")) {
- st->codec->height = var_read_int(pb, size);
+ st->codecpar->height = var_read_int(pb, size);
} else if (!strcmp(name, "PIXEL_ASPECT")) {
st->sample_aspect_ratio = var_read_float(pb, size);
av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den,
st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
INT_MAX);
} else if (!strcmp(name, "WIDTH")) {
- st->codec->width = var_read_int(pb, size);
+ st->codecpar->width = var_read_int(pb, size);
} else if (!strcmp(name, "ORIENTATION")) {
if (var_read_int(pb, size) == 1101) {
- st->codec->extradata = av_strdup("BottomUp");
- st->codec->extradata_size = 9;
+ st->codecpar->extradata = av_strdup("BottomUp");
+ st->codecpar->extradata_size = 9;
}
} else if (!strcmp(name, "Q_SPATIAL") || !strcmp(name, "Q_TEMPORAL")) {
var_read_metadata(avctx, name, size);
@@ -259,8 +259,8 @@ static void read_index(AVIOContext *pb, AVStream *st)
uint32_t size = avio_rb32(pb);
avio_skip(pb, 8);
av_add_index_entry(st, pos, timestamp, size, 0, AVINDEX_KEYFRAME);
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- timestamp += size / (st->codec->channels * 2);
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ timestamp += size / (st->codecpar->channels * 2);
} else {
timestamp++;
}
@@ -293,37 +293,37 @@ static int mv_read_header(AVFormatContext *avctx)
if (!vst)
return AVERROR(ENOMEM);
avpriv_set_pts_info(vst, 64, 1, 15);
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
vst->avg_frame_rate = av_inv_q(vst->time_base);
vst->nb_frames = avio_rb32(pb);
v = avio_rb32(pb);
switch (v) {
case 1:
- vst->codec->codec_id = AV_CODEC_ID_MVC1;
+ vst->codecpar->codec_id = AV_CODEC_ID_MVC1;
break;
case 2:
- vst->codec->pix_fmt = AV_PIX_FMT_ARGB;
- vst->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
+ vst->codecpar->format = AV_PIX_FMT_ARGB;
+ vst->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
break;
default:
avpriv_request_sample(avctx, "Video compression %i", v);
break;
}
- vst->codec->codec_tag = 0;
- vst->codec->width = avio_rb32(pb);
- vst->codec->height = avio_rb32(pb);
+ vst->codecpar->codec_tag = 0;
+ vst->codecpar->width = avio_rb32(pb);
+ vst->codecpar->height = avio_rb32(pb);
avio_skip(pb, 12);
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
ast->nb_frames = vst->nb_frames;
- ast->codec->sample_rate = avio_rb32(pb);
- avpriv_set_pts_info(ast, 33, 1, ast->codec->sample_rate);
+ ast->codecpar->sample_rate = avio_rb32(pb);
+ avpriv_set_pts_info(ast, 33, 1, ast->codecpar->sample_rate);
if (set_channels(avctx, ast, avio_rb32(pb)) < 0)
return AVERROR_INVALIDDATA;
v = avio_rb32(pb);
if (v == AUDIO_FORMAT_SIGNED) {
- ast->codec->codec_id = AV_CODEC_ID_PCM_S16BE;
+ ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE;
} else {
avpriv_request_sample(avctx, "Audio compression (format %i)", v);
}
@@ -341,7 +341,7 @@ static int mv_read_header(AVFormatContext *avctx)
avio_skip(pb, 8);
av_add_index_entry(ast, pos, timestamp, asize, 0, AVINDEX_KEYFRAME);
av_add_index_entry(vst, pos + asize, i, vsize, 0, AVINDEX_KEYFRAME);
- timestamp += asize / (ast->codec->channels * 2);
+ timestamp += asize / (ast->codecpar->channels * 2);
}
} else if (!version && avio_rb16(pb) == 3) {
avio_skip(pb, 4);
@@ -356,21 +356,21 @@ static int mv_read_header(AVFormatContext *avctx)
ast = avformat_new_stream(avctx, NULL);
if (!ast)
return AVERROR(ENOMEM);
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
if ((read_table(avctx, ast, parse_audio_var)) < 0)
return ret;
if (mv->acompression == 100 &&
mv->aformat == AUDIO_FORMAT_SIGNED &&
- ast->codec->bits_per_coded_sample == 16) {
- ast->codec->codec_id = AV_CODEC_ID_PCM_S16BE;
+ ast->codecpar->bits_per_coded_sample == 16) {
+ ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE;
} else {
avpriv_request_sample(avctx,
"Audio compression %i (format %i, sr %i)",
mv->acompression, mv->aformat,
- ast->codec->bits_per_coded_sample);
- ast->codec->codec_id = AV_CODEC_ID_NONE;
+ ast->codecpar->bits_per_coded_sample);
+ ast->codecpar->codec_id = AV_CODEC_ID_NONE;
}
- if (ast->codec->channels <= 0) {
+ if (ast->codecpar->channels <= 0) {
av_log(avctx, AV_LOG_ERROR, "No valid channel count found.\n");
return AVERROR_INVALIDDATA;
}
@@ -383,7 +383,7 @@ static int mv_read_header(AVFormatContext *avctx)
vst = avformat_new_stream(avctx, NULL);
if (!vst)
return AVERROR(ENOMEM);
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
if ((ret = read_table(avctx, vst, parse_video_var))<0)
return ret;
}
diff --git a/libavformat/mvi.c b/libavformat/mvi.c
index a7cfcb9a7a..9f90faf56b 100644
--- a/libavformat/mvi.c
+++ b/libavformat/mvi.c
@@ -54,18 +54,18 @@ static int read_header(AVFormatContext *s)
if (!vst)
return AVERROR(ENOMEM);
- if (ff_alloc_extradata(vst->codec, 2))
+ if (ff_alloc_extradata(vst->codecpar, 2))
return AVERROR(ENOMEM);
version = avio_r8(pb);
- vst->codec->extradata[0] = avio_r8(pb);
- vst->codec->extradata[1] = avio_r8(pb);
+ vst->codecpar->extradata[0] = avio_r8(pb);
+ vst->codecpar->extradata[1] = avio_r8(pb);
frames_count = avio_rl32(pb);
msecs_per_frame = avio_rl32(pb);
- vst->codec->width = avio_rl16(pb);
- vst->codec->height = avio_rl16(pb);
+ vst->codecpar->width = avio_rl16(pb);
+ vst->codecpar->height = avio_rl16(pb);
avio_r8(pb);
- ast->codec->sample_rate = avio_rl16(pb);
+ ast->codecpar->sample_rate = avio_rl16(pb);
mvi->audio_data_size = avio_rl32(pb);
avio_r8(pb);
player_version = avio_rl32(pb);
@@ -80,20 +80,20 @@ static int read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
- avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- ast->codec->codec_id = AV_CODEC_ID_PCM_U8;
- ast->codec->channels = 1;
- ast->codec->channel_layout = AV_CH_LAYOUT_MONO;
- ast->codec->bits_per_coded_sample = 8;
- ast->codec->bit_rate = ast->codec->sample_rate * 8;
+ avpriv_set_pts_info(ast, 64, 1, ast->codecpar->sample_rate);
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
+ ast->codecpar->channels = 1;
+ ast->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+ ast->codecpar->bits_per_coded_sample = 8;
+ ast->codecpar->bit_rate = ast->codecpar->sample_rate * 8;
avpriv_set_pts_info(vst, 64, msecs_per_frame, 1000000);
vst->avg_frame_rate = av_inv_q(vst->time_base);
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_id = AV_CODEC_ID_MOTIONPIXELS;
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_id = AV_CODEC_ID_MOTIONPIXELS;
- mvi->get_int = (vst->codec->width * vst->codec->height < (1 << 16)) ? avio_rl16 : avio_rl24;
+ mvi->get_int = (vst->codecpar->width * vst->codecpar->height < (1 << 16)) ? avio_rl16 : avio_rl24;
mvi->audio_frame_size = ((uint64_t)mvi->audio_data_size << MVI_FRAC_BITS) / frames_count;
if (mvi->audio_frame_size <= 1 << MVI_FRAC_BITS - 1) {
@@ -103,7 +103,7 @@ static int read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
- mvi->audio_size_counter = (ast->codec->sample_rate * 830 / mvi->audio_frame_size - 1) * mvi->audio_frame_size;
+ mvi->audio_size_counter = (ast->codecpar->sample_rate * 830 / mvi->audio_frame_size - 1) * mvi->audio_frame_size;
mvi->audio_size_left = mvi->audio_data_size;
return 0;
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 40b4d79996..f8cf92283f 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -405,15 +405,15 @@ static int mxf_get_d10_aes3_packet(AVIOContext *pb, AVStream *st, AVPacket *pkt,
data_ptr = pkt->data;
end_ptr = pkt->data + length;
buf_ptr = pkt->data + 4; /* skip SMPTE 331M header */
- for (; end_ptr - buf_ptr >= st->codec->channels * 4; ) {
- for (i = 0; i < st->codec->channels; i++) {
+ for (; end_ptr - buf_ptr >= st->codecpar->channels * 4; ) {
+ for (i = 0; i < st->codecpar->channels; i++) {
uint32_t sample = bytestream_get_le32(&buf_ptr);
- if (st->codec->bits_per_coded_sample == 24)
+ if (st->codecpar->bits_per_coded_sample == 24)
bytestream_put_le24(&data_ptr, (sample >> 4) & 0xffffff);
else
bytestream_put_le16(&data_ptr, (sample >> 12) & 0xffff);
}
- buf_ptr += 32 - st->codec->channels*4; // always 8 channels stored SMPTE 331M
+ buf_ptr += 32 - st->codecpar->channels*4; // always 8 channels stored SMPTE 331M
}
av_shrink_packet(pkt, data_ptr - pkt->data);
return 0;
@@ -1969,7 +1969,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
PRINT_KEY(mxf->fc, "data definition ul", source_track->sequence->data_definition_ul);
codec_ul = mxf_get_codec_ul(ff_mxf_data_definition_uls, &source_track->sequence->data_definition_ul);
- st->codec->codec_type = codec_ul->id;
+ st->codecpar->codec_type = codec_ul->id;
if (!descriptor) {
av_log(mxf->fc, AV_LOG_INFO, "source track %d: stream %d, no descriptor found\n", source_track->track_id, st->index);
@@ -1993,14 +1993,14 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
/* TODO: drop PictureEssenceCoding and SoundEssenceCompression, only check EssenceContainer */
codec_ul = mxf_get_codec_ul(ff_mxf_codec_uls, &descriptor->essence_codec_ul);
- st->codec->codec_id = (enum AVCodecID)codec_ul->id;
- if (st->codec->codec_id == AV_CODEC_ID_NONE) {
+ st->codecpar->codec_id = (enum AVCodecID)codec_ul->id;
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE) {
codec_ul = mxf_get_codec_ul(ff_mxf_codec_uls, &descriptor->codec_ul);
- st->codec->codec_id = (enum AVCodecID)codec_ul->id;
+ st->codecpar->codec_id = (enum AVCodecID)codec_ul->id;
}
av_log(mxf->fc, AV_LOG_VERBOSE, "%s: Universal Label: ",
- avcodec_get_name(st->codec->codec_id));
+ avcodec_get_name(st->codecpar->codec_id));
for (k = 0; k < 16; k++) {
av_log(mxf->fc, AV_LOG_VERBOSE, "%.2x",
descriptor->essence_codec_ul[k]);
@@ -2015,16 +2015,16 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
mxf_parse_physical_source_package(mxf, source_track, st);
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
source_track->intra_only = mxf_is_intra_only(descriptor);
container_ul = mxf_get_codec_ul(mxf_picture_essence_container_uls, essence_container_ul);
- if (st->codec->codec_id == AV_CODEC_ID_NONE)
- st->codec->codec_id = container_ul->id;
- st->codec->width = descriptor->width;
- st->codec->height = descriptor->height; /* Field height, not frame height */
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE)
+ st->codecpar->codec_id = container_ul->id;
+ st->codecpar->width = descriptor->width;
+ st->codecpar->height = descriptor->height; /* Field height, not frame height */
switch (descriptor->frame_layout) {
case FullFrame:
- st->codec->field_order = AV_FIELD_PROGRESSIVE;
+ st->codecpar->field_order = AV_FIELD_PROGRESSIVE;
break;
case OneField:
/* Every other line is stored and needs to be duplicated. */
@@ -2035,14 +2035,14 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
case MixedFields:
break;
case SegmentedFrame:
- st->codec->field_order = AV_FIELD_PROGRESSIVE;
+ st->codecpar->field_order = AV_FIELD_PROGRESSIVE;
case SeparateFields:
switch (descriptor->field_dominance) {
case MXF_TFF:
- st->codec->field_order = AV_FIELD_TT;
+ st->codecpar->field_order = AV_FIELD_TT;
break;
case MXF_BFF:
- st->codec->field_order = AV_FIELD_BB;
+ st->codecpar->field_order = AV_FIELD_BB;
break;
default:
avpriv_request_sample(mxf->fc,
@@ -2052,27 +2052,27 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
break;
}
/* Turn field height into frame height. */
- st->codec->height *= 2;
+ st->codecpar->height *= 2;
break;
default:
av_log(mxf->fc, AV_LOG_INFO, "Unknown frame layout type: %d\n", descriptor->frame_layout);
}
- if (st->codec->codec_id == AV_CODEC_ID_RAWVIDEO) {
- st->codec->pix_fmt = descriptor->pix_fmt;
- if (st->codec->pix_fmt == AV_PIX_FMT_NONE) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) {
+ st->codecpar->format = descriptor->pix_fmt;
+ if (st->codecpar->format == AV_PIX_FMT_NONE) {
pix_fmt_ul = mxf_get_codec_ul(ff_mxf_pixel_format_uls,
&descriptor->essence_codec_ul);
- st->codec->pix_fmt = (enum AVPixelFormat)pix_fmt_ul->id;
- if (st->codec->pix_fmt == AV_PIX_FMT_NONE) {
- st->codec->codec_tag = mxf_get_codec_ul(ff_mxf_codec_tag_uls,
- &descriptor->essence_codec_ul)->id;
- if (!st->codec->codec_tag) {
+ st->codecpar->format = (enum AVPixelFormat)pix_fmt_ul->id;
+ if (st->codecpar->format== AV_PIX_FMT_NONE) {
+ st->codecpar->codec_tag = mxf_get_codec_ul(ff_mxf_codec_tag_uls,
+ &descriptor->essence_codec_ul)->id;
+ if (!st->codecpar->codec_tag) {
/* support files created before RP224v10 by defaulting to UYVY422
if subsampling is 4:2:2 and component depth is 8-bit */
if (descriptor->horiz_subsampling == 2 &&
descriptor->vert_subsampling == 1 &&
descriptor->component_depth == 8) {
- st->codec->pix_fmt = AV_PIX_FMT_UYVY422;
+ st->codecpar->format = AV_PIX_FMT_UYVY422;
}
}
}
@@ -2087,16 +2087,16 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
}
if (descriptor->aspect_ratio.num && descriptor->aspect_ratio.den)
st->display_aspect_ratio = descriptor->aspect_ratio;
- } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul);
/* Only overwrite existing codec ID if it is unset or A-law, which is the default according to SMPTE RP 224. */
- if (st->codec->codec_id == AV_CODEC_ID_NONE || (st->codec->codec_id == AV_CODEC_ID_PCM_ALAW && (enum AVCodecID)container_ul->id != AV_CODEC_ID_NONE))
- st->codec->codec_id = (enum AVCodecID)container_ul->id;
- st->codec->channels = descriptor->channels;
- st->codec->bits_per_coded_sample = descriptor->bits_per_sample;
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE || (st->codecpar->codec_id == AV_CODEC_ID_PCM_ALAW && (enum AVCodecID)container_ul->id != AV_CODEC_ID_NONE))
+ st->codecpar->codec_id = (enum AVCodecID)container_ul->id;
+ st->codecpar->channels = descriptor->channels;
+ st->codecpar->bits_per_coded_sample = descriptor->bits_per_sample;
if (descriptor->sample_rate.den > 0) {
- st->codec->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den;
+ st->codecpar->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den;
avpriv_set_pts_info(st, 64, descriptor->sample_rate.den, descriptor->sample_rate.num);
} else {
av_log(mxf->fc, AV_LOG_WARNING, "invalid sample rate (%d/%d) "
@@ -2113,20 +2113,20 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
st->time_base);
/* TODO: implement AV_CODEC_ID_RAWAUDIO */
- if (st->codec->codec_id == AV_CODEC_ID_PCM_S16LE) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE) {
if (descriptor->bits_per_sample > 16 && descriptor->bits_per_sample <= 24)
- st->codec->codec_id = AV_CODEC_ID_PCM_S24LE;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE;
else if (descriptor->bits_per_sample == 32)
- st->codec->codec_id = AV_CODEC_ID_PCM_S32LE;
- } else if (st->codec->codec_id == AV_CODEC_ID_PCM_S16BE) {
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE;
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE) {
if (descriptor->bits_per_sample > 16 && descriptor->bits_per_sample <= 24)
- st->codec->codec_id = AV_CODEC_ID_PCM_S24BE;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S24BE;
else if (descriptor->bits_per_sample == 32)
- st->codec->codec_id = AV_CODEC_ID_PCM_S32BE;
- } else if (st->codec->codec_id == AV_CODEC_ID_MP2) {
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S32BE;
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_MP2) {
st->need_parsing = AVSTREAM_PARSE_FULL;
}
- } else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
int codec_id = mxf_get_codec_ul(mxf_data_essence_container_uls,
essence_container_ul)->id;
if (codec_id >= 0 &&
@@ -2136,19 +2136,19 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
}
}
if (descriptor->extradata) {
- if (!ff_alloc_extradata(st->codec, descriptor->extradata_size)) {
- memcpy(st->codec->extradata, descriptor->extradata, descriptor->extradata_size);
+ if (!ff_alloc_extradata(st->codecpar, descriptor->extradata_size)) {
+ memcpy(st->codecpar->extradata, descriptor->extradata, descriptor->extradata_size);
}
- } else if (st->codec->codec_id == AV_CODEC_ID_H264) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
int coded_width = mxf_get_codec_ul(mxf_intra_only_picture_coded_width,
&descriptor->essence_codec_ul)->id;
if (coded_width)
- st->codec->width = coded_width;
+ st->codecpar->width = coded_width;
ret = ff_generate_avci_extradata(st);
if (ret < 0)
return ret;
}
- if (st->codec->codec_type != AVMEDIA_TYPE_DATA && (*essence_container_ul)[15] > 0x01) {
+ if (st->codecpar->codec_type != AVMEDIA_TYPE_DATA && (*essence_container_ul)[15] > 0x01) {
/* TODO: decode timestamps */
st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
}
@@ -2579,8 +2579,8 @@ static void mxf_handle_small_eubc(AVFormatContext *s)
/* expect PCM with exactly one index table segment and a small (< 32) EUBC */
if (s->nb_streams != 1 ||
- s->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO ||
- !is_pcm(s->streams[0]->codec->codec_id) ||
+ s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO ||
+ !is_pcm(s->streams[0]->codecpar->codec_id) ||
mxf->nb_index_tables != 1 ||
mxf->index_tables[0].nb_segments != 1 ||
mxf->index_tables[0].segments[0]->edit_unit_byte_count >= 32)
@@ -2609,7 +2609,7 @@ static int mxf_handle_missing_index_segment(MXFContext *mxf)
return 0;
/* TODO: support raw video without an index if they exist */
- if (s->nb_streams != 1 || s->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO || !is_pcm(s->streams[0]->codec->codec_id))
+ if (s->nb_streams != 1 || s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO || !is_pcm(s->streams[0]->codecpar->codec_id))
return 0;
/* check if file already has a IndexTableSegment */
@@ -2643,7 +2643,7 @@ static int mxf_handle_missing_index_segment(MXFContext *mxf)
st = s->streams[0];
segment->type = IndexTableSegment;
/* stream will be treated as small EditUnitByteCount */
- segment->edit_unit_byte_count = (av_get_bits_per_sample(st->codec->codec_id) * st->codec->channels) >> 3;
+ segment->edit_unit_byte_count = (av_get_bits_per_sample(st->codecpar->codec_id) * st->codecpar->channels) >> 3;
segment->index_start_position = 0;
segment->index_duration = s->streams[0]->duration;
segment->index_sid = p->index_sid;
@@ -2918,22 +2918,22 @@ static int mxf_compute_sample_count(MXFContext *mxf, int stream_index,
return 0;
}
-static int mxf_set_audio_pts(MXFContext *mxf, AVCodecContext *codec,
+static int mxf_set_audio_pts(MXFContext *mxf, AVCodecParameters *par,
AVPacket *pkt)
{
MXFTrack *track = mxf->fc->streams[pkt->stream_index]->priv_data;
- int64_t bits_per_sample = codec->bits_per_coded_sample;
+ int64_t bits_per_sample = par->bits_per_coded_sample;
if (!bits_per_sample)
- bits_per_sample = av_get_bits_per_sample(codec->codec_id);
+ bits_per_sample = av_get_bits_per_sample(par->codec_id);
pkt->pts = track->sample_count;
- if ( codec->channels <= 0
+ if ( par->channels <= 0
|| bits_per_sample <= 0
- || codec->channels * (int64_t)bits_per_sample < 8)
+ || par->channels * (int64_t)bits_per_sample < 8)
return AVERROR(EINVAL);
- track->sample_count += pkt->size / (codec->channels * (int64_t)bits_per_sample / 8);
+ track->sample_count += pkt->size / (par->channels * (int64_t)bits_per_sample / 8);
return 0;
}
@@ -2961,7 +2961,7 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
int64_t next_ofs, next_klv;
AVStream *st;
MXFTrack *track;
- AVCodecContext *codec;
+ AVCodecParameters *par;
if (index < 0) {
av_log(s, AV_LOG_ERROR,
@@ -3006,9 +3006,9 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
pkt->stream_index = index;
pkt->pos = klv.offset;
- codec = st->codec;
+ par = st->codecpar;
- if (codec->codec_type == AVMEDIA_TYPE_VIDEO && next_ofs >= 0) {
+ if (par->codec_type == AVMEDIA_TYPE_VIDEO && next_ofs >= 0) {
/* mxf->current_edit_unit good - see if we have an
* index table to derive timestamps from */
MXFIndexTable *t = &mxf->index_tables[0];
@@ -3021,8 +3021,8 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
* let utils.c figure out DTS since it can be < PTS if low_delay = 0 (Sony IMX30) */
pkt->pts = mxf->current_edit_unit;
}
- } else if (codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- ret = mxf_set_audio_pts(mxf, codec, pkt);
+ } else if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
+ ret = mxf_set_audio_pts(mxf, par, pkt);
if (ret < 0)
return ret;
}
@@ -3088,12 +3088,12 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->stream_index = 0;
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && t->ptses &&
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && t->ptses &&
mxf->current_edit_unit >= 0 && mxf->current_edit_unit < t->nb_ptses) {
pkt->dts = mxf->current_edit_unit + t->first_dts;
pkt->pts = t->ptses[mxf->current_edit_unit];
- } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- int ret = mxf_set_audio_pts(mxf, st->codec, pkt);
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ int ret = mxf_set_audio_pts(mxf, st->codecpar, pkt);
if (ret < 0)
return ret;
}
@@ -3172,7 +3172,7 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
MXFTrack *source_track = st->priv_data;
/* if audio then truncate sample_time to EditRate */
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
sample_time = av_rescale_q(sample_time, st->time_base,
av_inv_q(source_track->edit_rate));
@@ -3231,7 +3231,7 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
AVStream *cur_st = s->streams[i];
MXFTrack *cur_track = cur_st->priv_data;
uint64_t current_sample_count = 0;
- if (cur_st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (cur_st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
ret = mxf_compute_sample_count(mxf, i, &current_sample_count);
if (ret < 0)
return ret;
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index cd13f89787..36a43e4a41 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -834,14 +834,14 @@ static void mxf_write_common_fields(AVFormatContext *s, AVStream *st)
if (st == mxf->timecode_track)
avio_write(pb, smpte_12m_timecode_track_data_ul, 16);
else {
- const MXFCodecUL *data_def_ul = mxf_get_data_definition_ul(st->codec->codec_type);
+ const MXFCodecUL *data_def_ul = mxf_get_data_definition_ul(st->codecpar->codec_type);
avio_write(pb, data_def_ul->uid, 16);
}
// write duration
mxf_write_local_tag(pb, 8, 0x0202);
- if (st != mxf->timecode_track && s->oformat == &ff_mxf_opatom_muxer && st->codec->codec_type == AVMEDIA_TYPE_AUDIO){
+ if (st != mxf->timecode_track && s->oformat == &ff_mxf_opatom_muxer && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO){
avio_wb64(pb, mxf->body_offset / mxf->edit_unit_byte_count);
} else {
avio_wb64(pb, mxf->duration);
@@ -1010,7 +1010,7 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
{
MXFStreamContext *sc = st->priv_data;
AVIOContext *pb = s->pb;
- int stored_height = (st->codec->height+15)/16*16;
+ int stored_height = (st->codecpar->height+15)/16*16;
int display_height;
int f1, f2;
unsigned desc_size = size+8+8+8+8+8+8+8+5+16+4+12+20+5;
@@ -1022,27 +1022,27 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
mxf_write_generic_desc(s, st, key, desc_size);
mxf_write_local_tag(pb, 4, 0x3203);
- avio_wb32(pb, st->codec->width);
+ avio_wb32(pb, st->codecpar->width);
mxf_write_local_tag(pb, 4, 0x3202);
avio_wb32(pb, stored_height>>sc->interlaced);
mxf_write_local_tag(pb, 4, 0x3209);
- avio_wb32(pb, st->codec->width);
+ avio_wb32(pb, st->codecpar->width);
- if (st->codec->height == 608) // PAL + VBI
+ if (st->codecpar->height == 608) // PAL + VBI
display_height = 576;
- else if (st->codec->height == 512) // NTSC + VBI
+ else if (st->codecpar->height == 512) // NTSC + VBI
display_height = 486;
else
- display_height = st->codec->height;
+ display_height = st->codecpar->height;
mxf_write_local_tag(pb, 4, 0x3208);
avio_wb32(pb, display_height>>sc->interlaced);
// presentation Y offset
mxf_write_local_tag(pb, 4, 0x320B);
- avio_wb32(pb, (st->codec->height - display_height)>>sc->interlaced);
+ avio_wb32(pb, (st->codecpar->height - display_height)>>sc->interlaced);
// component depth
mxf_write_local_tag(pb, 4, 0x3301);
@@ -1066,10 +1066,10 @@ static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID ke
avio_w8(pb, sc->interlaced);
// video line map
- switch (st->codec->height) {
- case 576: f1 = 23; f2 = st->codec->codec_id == AV_CODEC_ID_DVVIDEO ? 335 : 336; break;
+ switch (st->codecpar->height) {
+ case 576: f1 = 23; f2 = st->codecpar->codec_id == AV_CODEC_ID_DVVIDEO ? 335 : 336; break;
case 608: f1 = 7; f2 = 320; break;
- case 480: f1 = 20; f2 = st->codec->codec_id == AV_CODEC_ID_DVVIDEO ? 285 : 283; break;
+ case 480: f1 = 20; f2 = st->codecpar->codec_id == AV_CODEC_ID_DVVIDEO ? 285 : 283; break;
case 512: f1 = 7; f2 = 270; break;
case 720: f1 = 26; f2 = 0; break; // progressive
case 1080: f1 = 21; f2 = 584; break;
@@ -1111,9 +1111,9 @@ static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st)
{
AVIOContext *pb = s->pb;
MXFStreamContext *sc = st->priv_data;
- int profile_and_level = (st->codec->profile<<4) | st->codec->level;
+ int profile_and_level = (st->codecpar->profile<<4) | st->codecpar->level;
- if (st->codec->codec_id != AV_CODEC_ID_H264) {
+ if (st->codecpar->codec_id != AV_CODEC_ID_H264) {
mxf_write_cdci_common(s, st, mxf_mpegvideo_descriptor_key, 8+5);
// bit rate
@@ -1122,7 +1122,7 @@ static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st)
// profile and level
mxf_write_local_tag(pb, 1, 0x8007);
- if (!st->codec->profile)
+ if (!st->codecpar->profile)
profile_and_level |= 0x80; // escape bit
avio_w8(pb, profile_and_level);
} else {
@@ -1153,16 +1153,16 @@ static void mxf_write_generic_sound_common(AVFormatContext *s, AVStream *st, con
// write audio sampling rate
mxf_write_local_tag(pb, 8, 0x3D03);
- avio_wb32(pb, st->codec->sample_rate);
+ avio_wb32(pb, st->codecpar->sample_rate);
avio_wb32(pb, 1);
mxf_write_local_tag(pb, 4, 0x3D07);
if (mxf->channel_count == -1) {
- if (show_warnings && (s->oformat == &ff_mxf_d10_muxer) && (st->codec->channels != 4) && (st->codec->channels != 8))
+ if (show_warnings && (s->oformat == &ff_mxf_d10_muxer) && (st->codecpar->channels != 4) && (st->codecpar->channels != 8))
av_log(s, AV_LOG_WARNING, "the number of audio channels shall be 4 or 8 : the output will not comply to MXF D-10 specs, use -d10_channelcount to fix this\n");
- avio_wb32(pb, st->codec->channels);
+ avio_wb32(pb, st->codecpar->channels);
} else if (s->oformat == &ff_mxf_d10_muxer) {
- if (show_warnings && (mxf->channel_count < st->codec->channels))
+ if (show_warnings && (mxf->channel_count < st->codecpar->channels))
av_log(s, AV_LOG_WARNING, "d10_channelcount < actual number of audio channels : some channels will be discarded\n");
if (show_warnings && (mxf->channel_count != 4) && (mxf->channel_count != 8))
av_log(s, AV_LOG_WARNING, "d10_channelcount shall be set to 4 or 8 : the output will not comply to MXF D-10 specs\n");
@@ -1170,11 +1170,11 @@ static void mxf_write_generic_sound_common(AVFormatContext *s, AVStream *st, con
} else {
if (show_warnings && mxf->channel_count != -1 && s->oformat != &ff_mxf_opatom_muxer)
av_log(s, AV_LOG_ERROR, "-d10_channelcount requires MXF D-10 and will be ignored\n");
- avio_wb32(pb, st->codec->channels);
+ avio_wb32(pb, st->codecpar->channels);
}
mxf_write_local_tag(pb, 4, 0x3D01);
- avio_wb32(pb, av_get_bits_per_sample(st->codec->codec_id));
+ avio_wb32(pb, av_get_bits_per_sample(st->codecpar->codec_id));
}
static void mxf_write_wav_common(AVFormatContext *s, AVStream *st, const UID key, unsigned size)
@@ -1184,11 +1184,11 @@ static void mxf_write_wav_common(AVFormatContext *s, AVStream *st, const UID key
mxf_write_generic_sound_common(s, st, key, size+6+8);
mxf_write_local_tag(pb, 2, 0x3D0A);
- avio_wb16(pb, st->codec->block_align);
+ avio_wb16(pb, st->codecpar->block_align);
// avg bytes per sec
mxf_write_local_tag(pb, 4, 0x3D09);
- avio_wb32(pb, st->codec->block_align*st->codec->sample_rate);
+ avio_wb32(pb, st->codecpar->block_align*st->codecpar->sample_rate);
}
static void mxf_write_wav_desc(AVFormatContext *s, AVStream *st)
@@ -1729,10 +1729,10 @@ AVPacket *pkt)
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
MXFStreamContext *sc = st->priv_data;
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
mxf->edit_unit_byte_count += 16 + 4 + sc->aic.samples[0]*sc->aic.sample_size;
mxf->edit_unit_byte_count += klv_fill_size(mxf->edit_unit_byte_count);
- } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
mxf->edit_unit_byte_count += 16 + 4 + frame_size;
mxf->edit_unit_byte_count += klv_fill_size(mxf->edit_unit_byte_count);
}
@@ -1804,10 +1804,10 @@ static int mxf_parse_dv_frame(AVFormatContext *s, AVStream *st, AVPacket *pkt)
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
MXFStreamContext *sc = st->priv_data;
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
mxf->edit_unit_byte_count += 16 + 4 + sc->aic.samples[0]*sc->aic.sample_size;
mxf->edit_unit_byte_count += klv_fill_size(mxf->edit_unit_byte_count);
- } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
mxf->edit_unit_byte_count += 16 + 4 + frame_size;
mxf->edit_unit_byte_count += klv_fill_size(mxf->edit_unit_byte_count);
}
@@ -1861,7 +1861,7 @@ static int mxf_parse_h264_frame(AVFormatContext *s, AVStream *st,
--buf;
switch (state & 0x1f) {
case NAL_SPS:
- st->codec->profile = buf[1];
+ st->codecpar->profile = buf[1];
e->flags |= 0x40;
break;
case NAL_PPS:
@@ -1881,7 +1881,7 @@ static int mxf_parse_h264_frame(AVFormatContext *s, AVStream *st,
sc->aspect_ratio = (AVRational){ 16, 9 }; // 16:9 is mandatory for broadcast HD
sc->component_depth = 10; // AVC Intra is always 10 Bit
- sc->interlaced = st->codec->field_order != AV_FIELD_PROGRESSIVE ? 1 : 0;
+ sc->interlaced = st->codecpar->field_order != AV_FIELD_PROGRESSIVE ? 1 : 0;
if (sc->interlaced)
sc->field_dominance = 1; // top field first is mandatory for AVC Intra
@@ -1891,7 +1891,7 @@ static int mxf_parse_h264_frame(AVFormatContext *s, AVStream *st,
if (frame_size == mxf_h264_codec_uls[i].frame_size && sc->interlaced == mxf_h264_codec_uls[i].interlaced) {
sc->codec_ul = &mxf_h264_codec_uls[i].uid;
return 1;
- } else if (st->codec->profile == mxf_h264_codec_uls[i].profile) {
+ } else if (st->codecpar->profile == mxf_h264_codec_uls[i].profile) {
sc->codec_ul = &mxf_h264_codec_uls[i].uid;
uid_found = 1;
}
@@ -1918,21 +1918,21 @@ static const UID mxf_mpeg2_codec_uls[] = {
{ 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x05,0x03,0x00 }, // MP@H-14 Long GOP
};
-static const UID *mxf_get_mpeg2_codec_ul(AVCodecContext *avctx)
+static const UID *mxf_get_mpeg2_codec_ul(AVCodecParameters *par)
{
int long_gop = 1;
- if (avctx->profile == 4) { // Main
- if (avctx->level == 8) // Main
+ if (par->profile == 4) { // Main
+ if (par->level == 8) // Main
return &mxf_mpeg2_codec_uls[0+long_gop];
- else if (avctx->level == 4) // High
+ else if (par->level == 4) // High
return &mxf_mpeg2_codec_uls[4+long_gop];
- else if (avctx->level == 6) // High 14
+ else if (par->level == 6) // High 14
return &mxf_mpeg2_codec_uls[8+long_gop];
- } else if (avctx->profile == 0) { // 422
- if (avctx->level == 5) // Main
+ } else if (par->profile == 0) { // 422
+ if (par->level == 5) // Main
return &mxf_mpeg2_codec_uls[2+long_gop];
- else if (avctx->level == 2) // High
+ else if (par->level == 2) // High
return &mxf_mpeg2_codec_uls[6+long_gop];
}
return NULL;
@@ -1949,8 +1949,8 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st,
c = (c<<8) + pkt->data[i];
if (c == 0x1b5) {
if ((pkt->data[i+1] & 0xf0) == 0x10) { // seq ext
- st->codec->profile = pkt->data[i+1] & 0x07;
- st->codec->level = pkt->data[i+2] >> 4;
+ st->codecpar->profile = pkt->data[i+1] & 0x07;
+ st->codecpar->level = pkt->data[i+2] >> 4;
} else if (i + 5 < pkt->size && (pkt->data[i+1] & 0xf0) == 0x80) { // pict coding ext
sc->interlaced = !(pkt->data[i+5] & 0x80); // progressive frame
if (sc->interlaced)
@@ -1971,7 +1971,7 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st,
case 4: sc->aspect_ratio = (AVRational){221,100}; break;
default:
av_reduce(&sc->aspect_ratio.num, &sc->aspect_ratio.den,
- st->codec->width, st->codec->height, 1024*1024);
+ st->codecpar->width, st->codecpar->height, 1024*1024);
}
} else if (c == 0x100) { // pic
int pict_type = (pkt->data[i+2]>>3) & 0x07;
@@ -1992,7 +1992,7 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st,
}
}
if (s->oformat != &ff_mxf_d10_muxer)
- sc->codec_ul = mxf_get_mpeg2_codec_ul(st->codec);
+ sc->codec_ul = mxf_get_mpeg2_codec_ul(st->codecpar);
return !!sc->codec_ul;
}
@@ -2061,13 +2061,13 @@ static int mxf_write_header(AVFormatContext *s)
return AVERROR(ENOMEM);
st->priv_data = sc;
- if (((i == 0) ^ (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)) && s->oformat != &ff_mxf_opatom_muxer) {
+ if (((i == 0) ^ (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)) && s->oformat != &ff_mxf_opatom_muxer) {
av_log(s, AV_LOG_ERROR, "there must be exactly one video stream and it must be the first one\n");
return -1;
}
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(st->codec->pix_fmt);
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+ const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(st->codecpar->format);
// TODO: should be avg_frame_rate
AVRational rate, tbc = st->time_base;
// Default component depth to 8
@@ -2099,7 +2099,7 @@ static int mxf_write_header(AVFormatContext *s)
if((ret = mxf_init_timecode(s, st, rate)) < 0)
return ret;
- sc->video_bit_rate = st->codec->bit_rate ? st->codec->bit_rate : st->codec->rc_max_rate;
+ sc->video_bit_rate = st->codecpar->bit_rate;
if (s->oformat == &ff_mxf_d10_muxer) {
if ((sc->video_bit_rate == 50000000) && (mxf->time_base.den == 25)) {
sc->index = 3;
@@ -2127,31 +2127,31 @@ static int mxf_write_header(AVFormatContext *s)
}
if (mxf->signal_standard >= 0)
sc->signal_standard = mxf->signal_standard;
- } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- if (st->codec->sample_rate != 48000) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (st->codecpar->sample_rate != 48000) {
av_log(s, AV_LOG_ERROR, "only 48khz is implemented\n");
return -1;
}
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
if (s->oformat == &ff_mxf_d10_muxer) {
if (st->index != 1) {
av_log(s, AV_LOG_ERROR, "MXF D-10 only support one audio track\n");
return -1;
}
- if (st->codec->codec_id != AV_CODEC_ID_PCM_S16LE &&
- st->codec->codec_id != AV_CODEC_ID_PCM_S24LE) {
+ if (st->codecpar->codec_id != AV_CODEC_ID_PCM_S16LE &&
+ st->codecpar->codec_id != AV_CODEC_ID_PCM_S24LE) {
av_log(s, AV_LOG_ERROR, "MXF D-10 only support 16 or 24 bits le audio\n");
}
sc->index = ((MXFStreamContext*)s->streams[0]->priv_data)->index + 1;
} else if (s->oformat == &ff_mxf_opatom_muxer) {
AVRational tbc = av_inv_q(mxf->audio_edit_rate);
- if (st->codec->codec_id != AV_CODEC_ID_PCM_S16LE &&
- st->codec->codec_id != AV_CODEC_ID_PCM_S24LE) {
+ if (st->codecpar->codec_id != AV_CODEC_ID_PCM_S16LE &&
+ st->codecpar->codec_id != AV_CODEC_ID_PCM_S24LE) {
av_log(s, AV_LOG_ERROR, "Only pcm_s16le and pcm_s24le audio codecs are implemented\n");
return AVERROR_PATCHWELCOME;
}
- if (st->codec->channels != 1) {
+ if (st->codecpar->channels != 1) {
av_log(s, AV_LOG_ERROR, "MXF OPAtom only supports single channel audio\n");
return AVERROR(EINVAL);
}
@@ -2167,7 +2167,7 @@ static int mxf_write_header(AVFormatContext *s)
return ret;
mxf->timecode_base = (tbc.den + tbc.num/2) / tbc.num;
- mxf->edit_unit_byte_count = (av_get_bits_per_sample(st->codec->codec_id) * st->codec->channels) >> 3;
+ mxf->edit_unit_byte_count = (av_get_bits_per_sample(st->codecpar->codec_id) * st->codecpar->channels) >> 3;
sc->index = 2;
} else {
mxf->slice_count = 1;
@@ -2175,7 +2175,7 @@ static int mxf_write_header(AVFormatContext *s)
}
if (!sc->index) {
- sc->index = mxf_get_essence_container_ul_index(st->codec->codec_id);
+ sc->index = mxf_get_essence_container_ul_index(st->codecpar->codec_id);
if (sc->index == -1) {
av_log(s, AV_LOG_ERROR, "track %d: could not find essence container ul, "
"codec not currently supported in container\n", i);
@@ -2309,7 +2309,7 @@ static void mxf_write_d10_audio_packet(AVFormatContext *s, AVStream *st, AVPacke
{
MXFContext *mxf = s->priv_data;
AVIOContext *pb = s->pb;
- int frame_size = pkt->size / st->codec->block_align;
+ int frame_size = pkt->size / st->codecpar->block_align;
uint8_t *samples = pkt->data;
uint8_t *end = pkt->data + pkt->size;
int i;
@@ -2318,12 +2318,12 @@ static void mxf_write_d10_audio_packet(AVFormatContext *s, AVStream *st, AVPacke
avio_w8(pb, (frame_size == 1920 ? 0 : (mxf->edit_units_count-1) % 5 + 1));
avio_wl16(pb, frame_size);
- avio_w8(pb, (1<<st->codec->channels)-1);
+ avio_w8(pb, (1<<st->codecpar->channels)-1);
while (samples < end) {
- for (i = 0; i < st->codec->channels; i++) {
+ for (i = 0; i < st->codecpar->channels; i++) {
uint32_t sample;
- if (st->codec->codec_id == AV_CODEC_ID_PCM_S24LE) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S24LE) {
sample = AV_RL24(samples)<< 4;
samples += 3;
} else {
@@ -2406,22 +2406,22 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt)
}
}
- if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
if (!mxf_parse_mpeg2_frame(s, st, pkt, &ie)) {
av_log(s, AV_LOG_ERROR, "could not get mpeg2 profile and level\n");
return -1;
}
- } else if (st->codec->codec_id == AV_CODEC_ID_DNXHD) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_DNXHD) {
if (!mxf_parse_dnxhd_frame(s, st, pkt)) {
av_log(s, AV_LOG_ERROR, "could not get dnxhd profile\n");
return -1;
}
- } else if (st->codec->codec_id == AV_CODEC_ID_DVVIDEO) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_DVVIDEO) {
if (!mxf_parse_dv_frame(s, st, pkt)) {
av_log(s, AV_LOG_ERROR, "could not get dv profile\n");
return -1;
}
- } else if (st->codec->codec_id == AV_CODEC_ID_H264) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
if (!mxf_parse_h264_frame(s, st, pkt, &ie)) {
av_log(s, AV_LOG_ERROR, "could not get h264 profile\n");
return -1;
@@ -2477,7 +2477,7 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt)
mxf_write_klv_fill(s);
avio_write(pb, sc->track_essence_element_key, 16); // write key
if (s->oformat == &ff_mxf_d10_muxer) {
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
mxf_write_d10_video_packet(s, st, pkt);
else
mxf_write_d10_audio_packet(s, st, pkt);
diff --git a/libavformat/mxg.c b/libavformat/mxg.c
index 45cc5b5284..6fbf99cfa3 100644
--- a/libavformat/mxg.c
+++ b/libavformat/mxg.c
@@ -48,20 +48,20 @@ static int mxg_read_header(AVFormatContext *s)
video_st = avformat_new_stream(s, NULL);
if (!video_st)
return AVERROR(ENOMEM);
- video_st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- video_st->codec->codec_id = AV_CODEC_ID_MXPEG;
+ video_st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ video_st->codecpar->codec_id = AV_CODEC_ID_MXPEG;
avpriv_set_pts_info(video_st, 64, 1, 1000000);
audio_st = avformat_new_stream(s, NULL);
if (!audio_st)
return AVERROR(ENOMEM);
- audio_st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- audio_st->codec->codec_id = AV_CODEC_ID_PCM_ALAW;
- audio_st->codec->channels = 1;
- audio_st->codec->channel_layout = AV_CH_LAYOUT_MONO;
- audio_st->codec->sample_rate = 8000;
- audio_st->codec->bits_per_coded_sample = 8;
- audio_st->codec->block_align = 1;
+ audio_st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ audio_st->codecpar->codec_id = AV_CODEC_ID_PCM_ALAW;
+ audio_st->codecpar->channels = 1;
+ audio_st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+ audio_st->codecpar->sample_rate = 8000;
+ audio_st->codecpar->bits_per_coded_sample = 8;
+ audio_st->codecpar->block_align = 1;
avpriv_set_pts_info(audio_st, 64, 1, 1000000);
mxg->soi_ptr = mxg->buffer_ptr = mxg->buffer = 0;
diff --git a/libavformat/ncdec.c b/libavformat/ncdec.c
index 745ba61eb2..8cadcc7cd7 100644
--- a/libavformat/ncdec.c
+++ b/libavformat/ncdec.c
@@ -51,8 +51,8 @@ static int nc_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_MPEG4;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_MPEG4;
st->need_parsing = AVSTREAM_PARSE_FULL;
avpriv_set_pts_info(st, 64, 1, 100);
diff --git a/libavformat/nistspheredec.c b/libavformat/nistspheredec.c
index 359d9e38a5..782d1dfbfb 100644
--- a/libavformat/nistspheredec.c
+++ b/libavformat/nistspheredec.c
@@ -43,7 +43,7 @@ static int nist_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
ff_get_line(s->pb, buffer, sizeof(buffer));
ff_get_line(s->pb, buffer, sizeof(buffer));
@@ -58,29 +58,29 @@ static int nist_read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
if (!memcmp(buffer, "end_head", 8)) {
- if (!st->codec->bits_per_coded_sample)
- st->codec->bits_per_coded_sample = bps << 3;
+ if (!st->codecpar->bits_per_coded_sample)
+ st->codecpar->bits_per_coded_sample = bps << 3;
if (!av_strcasecmp(coding, "pcm")) {
- if (st->codec->codec_id == AV_CODEC_ID_NONE)
- st->codec->codec_id = ff_get_pcm_codec_id(st->codec->bits_per_coded_sample,
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE)
+ st->codecpar->codec_id = ff_get_pcm_codec_id(st->codecpar->bits_per_coded_sample,
0, be, 0xFFFF);
} else if (!av_strcasecmp(coding, "alaw")) {
- st->codec->codec_id = AV_CODEC_ID_PCM_ALAW;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_ALAW;
} else if (!av_strcasecmp(coding, "ulaw") ||
!av_strcasecmp(coding, "mu-law")) {
- st->codec->codec_id = AV_CODEC_ID_PCM_MULAW;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_MULAW;
} else if (!av_strncasecmp(coding, "pcm,embedded-shorten", 20)) {
- st->codec->codec_id = AV_CODEC_ID_SHORTEN;
- if (ff_alloc_extradata(st->codec, 1))
- st->codec->extradata[0] = 1;
+ st->codecpar->codec_id = AV_CODEC_ID_SHORTEN;
+ if (ff_alloc_extradata(st->codecpar, 1))
+ st->codecpar->extradata[0] = 1;
} else {
avpriv_request_sample(s, "coding %s", coding);
}
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
- st->codec->block_align = st->codec->bits_per_coded_sample * st->codec->channels / 8;
+ st->codecpar->block_align = st->codecpar->bits_per_coded_sample * st->codecpar->channels / 8;
if (avio_tell(s->pb) > header_size)
return AVERROR_INVALIDDATA;
@@ -89,7 +89,7 @@ static int nist_read_header(AVFormatContext *s)
return 0;
} else if (!memcmp(buffer, "channel_count", 13)) {
- sscanf(buffer, "%*s %*s %"SCNd32, &st->codec->channels);
+ sscanf(buffer, "%*s %*s %"SCNd32, &st->codecpar->channels);
} else if (!memcmp(buffer, "sample_byte_format", 18)) {
sscanf(buffer, "%*s %*s %31s", format);
@@ -98,7 +98,7 @@ static int nist_read_header(AVFormatContext *s)
} else if (!av_strcasecmp(format, "10")) {
be = 1;
} else if (!av_strcasecmp(format, "mu-law")) {
- st->codec->codec_id = AV_CODEC_ID_PCM_MULAW;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_MULAW;
} else if (av_strcasecmp(format, "1")) {
avpriv_request_sample(s, "sample byte format %s", format);
return AVERROR_PATCHWELCOME;
@@ -110,9 +110,9 @@ static int nist_read_header(AVFormatContext *s)
} else if (!memcmp(buffer, "sample_n_bytes", 14)) {
sscanf(buffer, "%*s %*s %"SCNd32, &bps);
} else if (!memcmp(buffer, "sample_rate", 11)) {
- sscanf(buffer, "%*s %*s %"SCNd32, &st->codec->sample_rate);
+ sscanf(buffer, "%*s %*s %"SCNd32, &st->codecpar->sample_rate);
} else if (!memcmp(buffer, "sample_sig_bits", 15)) {
- sscanf(buffer, "%*s %*s %"SCNd32, &st->codec->bits_per_coded_sample);
+ sscanf(buffer, "%*s %*s %"SCNd32, &st->codecpar->bits_per_coded_sample);
} else {
char key[32], value[32];
if (sscanf(buffer, "%31s %*s %31s", key, value) == 2) {
diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c
index 95fab644a7..7f892973cc 100644
--- a/libavformat/nsvdec.c
+++ b/libavformat/nsvdec.c
@@ -434,12 +434,12 @@ static int nsv_parse_NSVs_header(AVFormatContext *s)
if (!nst)
goto fail;
st->priv_data = nst;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_tag = vtag;
- st->codec->codec_id = ff_codec_get_id(nsv_codec_video_tags, vtag);
- st->codec->width = vwidth;
- st->codec->height = vheight;
- st->codec->bits_per_coded_sample = 24; /* depth XXX */
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_tag = vtag;
+ st->codecpar->codec_id = ff_codec_get_id(nsv_codec_video_tags, vtag);
+ st->codecpar->width = vwidth;
+ st->codecpar->height = vheight;
+ st->codecpar->bits_per_coded_sample = 24; /* depth XXX */
avpriv_set_pts_info(st, 64, framerate.den, framerate.num);
st->start_time = 0;
@@ -465,9 +465,9 @@ static int nsv_parse_NSVs_header(AVFormatContext *s)
if (!nst)
goto fail;
st->priv_data = nst;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_tag = atag;
- st->codec->codec_id = ff_codec_get_id(nsv_codec_audio_tags, atag);
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_tag = atag;
+ st->codecpar->codec_id = ff_codec_get_id(nsv_codec_audio_tags, atag);
st->need_parsing = AVSTREAM_PARSE_FULL; /* for PCM we will read a chunk later and put correct info */
@@ -614,7 +614,7 @@ null_chunk_retry:
pkt = &nsv->ahead[NSV_ST_AUDIO];
/* read raw audio specific header on the first audio chunk... */
/* on ALL audio chunks ?? seems so! */
- if (asize && st[NSV_ST_AUDIO]->codec->codec_tag == MKTAG('P', 'C', 'M', ' ')/* && fill_header*/) {
+ if (asize && st[NSV_ST_AUDIO]->codecpar->codec_tag == MKTAG('P', 'C', 'M', ' ')/* && fill_header*/) {
uint8_t bps;
uint8_t channels;
uint16_t samplerate;
@@ -632,11 +632,11 @@ null_chunk_retry:
}
bps /= channels; // ???
if (bps == 8)
- st[NSV_ST_AUDIO]->codec->codec_id = AV_CODEC_ID_PCM_U8;
+ st[NSV_ST_AUDIO]->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
samplerate /= 4;/* UGH ??? XXX */
channels = 1;
- st[NSV_ST_AUDIO]->codec->channels = channels;
- st[NSV_ST_AUDIO]->codec->sample_rate = samplerate;
+ st[NSV_ST_AUDIO]->codecpar->channels = channels;
+ st[NSV_ST_AUDIO]->codecpar->sample_rate = samplerate;
av_log(s, AV_LOG_TRACE, "NSV RAWAUDIO: bps %d, nchan %d, srate %d\n", bps, channels, samplerate);
}
}
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 4df6a57a67..7286a26e17 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -415,11 +415,11 @@ static int decode_stream_header(NUTContext *nut)
class = ffio_read_varlen(bc);
tmp = get_fourcc(bc);
- st->codec->codec_tag = tmp;
+ st->codecpar->codec_tag = tmp;
switch (class) {
case 0:
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = av_codec_get_id((const AVCodecTag * const []) {
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = av_codec_get_id((const AVCodecTag * const []) {
ff_nut_video_tags,
ff_codec_bmp_tags,
ff_codec_movvideo_tags,
@@ -428,8 +428,8 @@ static int decode_stream_header(NUTContext *nut)
tmp);
break;
case 1:
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = av_codec_get_id((const AVCodecTag * const []) {
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = av_codec_get_id((const AVCodecTag * const []) {
ff_nut_audio_tags,
ff_codec_wav_tags,
ff_nut_audio_extra_tags,
@@ -438,18 +438,18 @@ static int decode_stream_header(NUTContext *nut)
tmp);
break;
case 2:
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = ff_codec_get_id(ff_nut_subtitle_tags, tmp);
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = ff_codec_get_id(ff_nut_subtitle_tags, tmp);
break;
case 3:
- st->codec->codec_type = AVMEDIA_TYPE_DATA;
- st->codec->codec_id = ff_codec_get_id(ff_nut_data_tags, tmp);
+ st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+ st->codecpar->codec_id = ff_codec_get_id(ff_nut_data_tags, tmp);
break;
default:
av_log(s, AV_LOG_ERROR, "unknown stream class (%d)\n", class);
return AVERROR(ENOSYS);
}
- if (class < 3 && st->codec->codec_id == AV_CODEC_ID_NONE)
+ if (class < 3 && st->codecpar->codec_id == AV_CODEC_ID_NONE)
av_log(s, AV_LOG_ERROR,
"Unknown codec tag '0x%04x' for stream number %d\n",
(unsigned int) tmp, stream_id);
@@ -458,18 +458,18 @@ static int decode_stream_header(NUTContext *nut)
GET_V(stc->msb_pts_shift, tmp < 16);
stc->max_pts_distance = ffio_read_varlen(bc);
GET_V(stc->decode_delay, tmp < 1000); // sanity limit, raise this if Moore's law is true
- st->codec->has_b_frames = stc->decode_delay;
+ st->codecpar->video_delay = stc->decode_delay;
ffio_read_varlen(bc); // stream flags
- GET_V(st->codec->extradata_size, tmp < (1 << 30));
- if (st->codec->extradata_size) {
- if (ff_get_extradata(st->codec, bc, st->codec->extradata_size) < 0)
+ GET_V(st->codecpar->extradata_size, tmp < (1 << 30));
+ if (st->codecpar->extradata_size) {
+ if (ff_get_extradata(st->codecpar, bc, st->codecpar->extradata_size) < 0)
return AVERROR(ENOMEM);
}
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- GET_V(st->codec->width, tmp > 0);
- GET_V(st->codec->height, tmp > 0);
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+ GET_V(st->codecpar->width, tmp > 0);
+ GET_V(st->codecpar->height, tmp > 0);
st->sample_aspect_ratio.num = ffio_read_varlen(bc);
st->sample_aspect_ratio.den = ffio_read_varlen(bc);
if ((!st->sample_aspect_ratio.num) != (!st->sample_aspect_ratio.den)) {
@@ -479,10 +479,10 @@ static int decode_stream_header(NUTContext *nut)
goto fail;
}
ffio_read_varlen(bc); /* csp type */
- } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- GET_V(st->codec->sample_rate, tmp > 0);
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ GET_V(st->codecpar->sample_rate, tmp > 0);
ffio_read_varlen(bc); // samplerate_den
- GET_V(st->codec->channels, tmp > 0);
+ GET_V(st->codecpar->channels, tmp > 0);
}
if (skip_reserved(bc, end) || ffio_get_checksum(bc)) {
av_log(s, AV_LOG_ERROR,
@@ -495,9 +495,9 @@ static int decode_stream_header(NUTContext *nut)
stc->time_base->den);
return 0;
fail:
- if (st && st->codec) {
- av_freep(&st->codec->extradata);
- st->codec->extradata_size = 0;
+ if (st && st->codecpar) {
+ av_freep(&st->codecpar->extradata);
+ st->codecpar->extradata_size = 0;
}
return ret;
}
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index 3a415a4584..9e422e1aa8 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -35,32 +35,32 @@
#include "avio_internal.h"
#include "riff.h"
-static int find_expected_header(AVCodecContext *c, int size, int key_frame,
+static int find_expected_header(AVCodecParameters *p, int size, int key_frame,
uint8_t out[64])
{
- int sample_rate = c->sample_rate;
+ int sample_rate = p->sample_rate;
if (size > 4096)
return 0;
AV_WB24(out, 1);
- if (c->codec_id == AV_CODEC_ID_MPEG4) {
+ if (p->codec_id == AV_CODEC_ID_MPEG4) {
if (key_frame) {
return 3;
} else {
out[3] = 0xB6;
return 4;
}
- } else if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO ||
- c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
+ } else if (p->codec_id == AV_CODEC_ID_MPEG1VIDEO ||
+ p->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
return 3;
- } else if (c->codec_id == AV_CODEC_ID_H264) {
+ } else if (p->codec_id == AV_CODEC_ID_H264) {
return 3;
- } else if (c->codec_id == AV_CODEC_ID_MP3 ||
- c->codec_id == AV_CODEC_ID_MP2) {
+ } else if (p->codec_id == AV_CODEC_ID_MP3 ||
+ p->codec_id == AV_CODEC_ID_MP2) {
int lsf, mpeg25, sample_rate_index, bitrate_index, frame_size;
- int layer = c->codec_id == AV_CODEC_ID_MP3 ? 3 : 2;
+ int layer = p->codec_id == AV_CODEC_ID_MP3 ? 3 : 2;
unsigned int header = 0xFFF00000;
lsf = sample_rate < (24000 + 32000) / 2;
@@ -102,12 +102,13 @@ static int find_expected_header(AVCodecContext *c, int size, int key_frame,
return 0;
}
-static int find_header_idx(AVFormatContext *s, AVCodecContext *c, int size, int frame_type)
+static int find_header_idx(AVFormatContext *s, AVCodecParameters *p, int size,
+ int frame_type)
{
NUTContext *nut = s->priv_data;
uint8_t out[64];
int i;
- int len = find_expected_header(c, size, frame_type, out);
+ int len = find_expected_header(p, size, frame_type, out);
for (i = 1; i < nut->header_count; i++) {
if (len == nut->header_len[i] && !memcmp(out, nut->header[i], len)) {
@@ -167,18 +168,18 @@ static void build_frame_code(AVFormatContext *s)
for (stream_id = 0; stream_id < s->nb_streams; stream_id++) {
int start2 = start + (end - start) * stream_id / s->nb_streams;
int end2 = start + (end - start) * (stream_id + 1) / s->nb_streams;
- AVCodecContext *codec = s->streams[stream_id]->codec;
- int is_audio = codec->codec_type == AVMEDIA_TYPE_AUDIO;
+ AVCodecParameters *par = s->streams[stream_id]->codecpar;
+ int is_audio = par->codec_type == AVMEDIA_TYPE_AUDIO;
int intra_only = /*codec->intra_only || */ is_audio;
int pred_count;
int frame_size = 0;
- if (codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- frame_size = av_get_audio_frame_duration(codec, 0);
- if (codec->codec_id == AV_CODEC_ID_VORBIS && !frame_size)
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
+ frame_size = av_get_audio_frame_duration2(par, 0);
+ if (par->codec_id == AV_CODEC_ID_VORBIS && !frame_size)
frame_size = 64;
} else {
- AVRational f = av_div_q(codec->time_base, *nut->stream[stream_id].time_base);
+ AVRational f = av_div_q(av_inv_q(s->streams[stream_id]->avg_frame_rate), *nut->stream[stream_id].time_base);
if (f.den == 1 && f.num>0)
frame_size = f.num;
}
@@ -193,7 +194,7 @@ static void build_frame_code(AVFormatContext *s)
ft->stream_id = stream_id;
ft->size_mul = 1;
if (is_audio)
- ft->header_idx = find_header_idx(s, codec, -1, key_frame);
+ ft->header_idx = find_header_idx(s, par, -1, key_frame);
start2++;
}
}
@@ -204,11 +205,11 @@ static void build_frame_code(AVFormatContext *s)
int frame_bytes;
int pts;
- if (codec->block_align > 0) {
- frame_bytes = codec->block_align;
+ if (par->block_align > 0) {
+ frame_bytes = par->block_align;
} else {
- int frame_size = av_get_audio_frame_duration(codec, 0);
- frame_bytes = frame_size * (int64_t)codec->bit_rate / (8 * codec->sample_rate);
+ int frame_size = av_get_audio_frame_duration2(par, 0);
+ frame_bytes = frame_size * (int64_t)par->bit_rate / (8 * par->sample_rate);
}
for (pts = 0; pts < 2; pts++) {
@@ -219,7 +220,7 @@ static void build_frame_code(AVFormatContext *s)
ft->size_mul = frame_bytes + 2;
ft->size_lsb = frame_bytes + pred;
ft->pts_delta = pts * frame_size;
- ft->header_idx = find_header_idx(s, codec, frame_bytes + pred, key_frame);
+ ft->header_idx = find_header_idx(s, par, frame_bytes + pred, key_frame);
start2++;
}
}
@@ -233,14 +234,14 @@ static void build_frame_code(AVFormatContext *s)
}
#endif
- if (codec->has_b_frames) {
+ if (par->video_delay) {
pred_count = 5;
pred_table[0] = -2;
pred_table[1] = -1;
pred_table[2] = 1;
pred_table[3] = 3;
pred_table[4] = 4;
- } else if (codec->codec_id == AV_CODEC_ID_VORBIS) {
+ } else if (par->codec_id == AV_CODEC_ID_VORBIS) {
pred_count = 3;
pred_table[0] = 2;
pred_table[1] = 9;
@@ -266,7 +267,7 @@ static void build_frame_code(AVFormatContext *s)
ft->size_lsb = index - start3;
ft->pts_delta = pred_table[pred];
if (is_audio)
- ft->header_idx = find_header_idx(s, codec, -1, key_frame);
+ ft->header_idx = find_header_idx(s, par, -1, key_frame);
}
}
}
@@ -425,18 +426,19 @@ static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc,
AVStream *st, int i)
{
NUTContext *nut = avctx->priv_data;
- AVCodecContext *codec = st->codec;
+ AVCodecParameters *par = st->codecpar;
ff_put_v(bc, i);
- switch (codec->codec_type) {
+ switch (par->codec_type) {
case AVMEDIA_TYPE_VIDEO: ff_put_v(bc, 0); break;
case AVMEDIA_TYPE_AUDIO: ff_put_v(bc, 1); break;
case AVMEDIA_TYPE_SUBTITLE: ff_put_v(bc, 2); break;
default: ff_put_v(bc, 3); break;
}
ff_put_v(bc, 4);
- if (codec->codec_tag) {
- avio_wl32(bc, codec->codec_tag);
+
+ if (par->codec_tag) {
+ avio_wl32(bc, par->codec_tag);
} else {
av_log(avctx, AV_LOG_ERROR, "No codec tag defined for stream %d\n", i);
return AVERROR(EINVAL);
@@ -445,21 +447,21 @@ static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc,
ff_put_v(bc, nut->stream[i].time_base - nut->time_base);
ff_put_v(bc, nut->stream[i].msb_pts_shift);
ff_put_v(bc, nut->stream[i].max_pts_distance);
- ff_put_v(bc, codec->has_b_frames);
+ ff_put_v(bc, par->video_delay);
avio_w8(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */
- ff_put_v(bc, codec->extradata_size);
- avio_write(bc, codec->extradata, codec->extradata_size);
+ ff_put_v(bc, par->extradata_size);
+ avio_write(bc, par->extradata, par->extradata_size);
- switch (codec->codec_type) {
+ switch (par->codec_type) {
case AVMEDIA_TYPE_AUDIO:
- ff_put_v(bc, codec->sample_rate);
+ ff_put_v(bc, par->sample_rate);
ff_put_v(bc, 1);
- ff_put_v(bc, codec->channels);
+ ff_put_v(bc, par->channels);
break;
case AVMEDIA_TYPE_VIDEO:
- ff_put_v(bc, codec->width);
- ff_put_v(bc, codec->height);
+ ff_put_v(bc, par->width);
+ ff_put_v(bc, par->height);
if (st->sample_aspect_ratio.num <= 0 ||
st->sample_aspect_ratio.den <= 0) {
@@ -530,12 +532,12 @@ static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id) {
if (st->disposition & ff_nut_dispositions[i].flag)
count += add_info(dyn_bc, "Disposition", ff_nut_dispositions[i].str);
}
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
uint8_t buf[256];
if (st->r_frame_rate.num>0 && st->r_frame_rate.den>0)
snprintf(buf, sizeof(buf), "%d/%d", st->r_frame_rate.num, st->r_frame_rate.den);
else
- snprintf(buf, sizeof(buf), "%d/%d", st->codec->time_base.den, st->codec->time_base.num);
+ snprintf(buf, sizeof(buf), "%d/%d", st->avg_frame_rate.num, st->avg_frame_rate.den);
count += add_info(dyn_bc, "r_frame_rate", buf);
}
dyn_size = avio_close_dyn_buf(dyn_bc, &dyn_buf);
@@ -730,8 +732,8 @@ static int nut_write_header(AVFormatContext *s)
AVRational time_base;
ff_parse_specific_params(st, &time_base.den, &ssize, &time_base.num);
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate) {
- time_base = (AVRational) {1, st->codec->sample_rate};
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate) {
+ time_base = (AVRational) {1, st->codecpar->sample_rate};
} else {
time_base = ff_choose_timebase(s, st, 48000);
}
diff --git a/libavformat/nuv.c b/libavformat/nuv.c
index c30da60711..57eea9e604 100644
--- a/libavformat/nuv.c
+++ b/libavformat/nuv.c
@@ -83,11 +83,11 @@ static int get_codec_data(AVIOContext *pb, AVStream *vst,
avio_skip(pb, 6);
size = PKTSIZE(avio_rl32(pb));
if (vst && subtype == 'R') {
- if (vst->codec->extradata) {
- av_freep(&vst->codec->extradata);
- vst->codec->extradata_size = 0;
+ if (vst->codecpar->extradata) {
+ av_freep(&vst->codecpar->extradata);
+ vst->codecpar->extradata_size = 0;
}
- if (ff_get_extradata(vst->codec, pb, size) < 0)
+ if (ff_get_extradata(vst->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
size = 0;
if (!myth)
@@ -101,32 +101,32 @@ static int get_codec_data(AVIOContext *pb, AVStream *vst,
break;
avio_rl32(pb); // version
if (vst) {
- vst->codec->codec_tag = avio_rl32(pb);
- vst->codec->codec_id =
- ff_codec_get_id(ff_codec_bmp_tags, vst->codec->codec_tag);
- if (vst->codec->codec_tag == MKTAG('R', 'J', 'P', 'G'))
- vst->codec->codec_id = AV_CODEC_ID_NUV;
+ vst->codecpar->codec_tag = avio_rl32(pb);
+ vst->codecpar->codec_id =
+ ff_codec_get_id(ff_codec_bmp_tags, vst->codecpar->codec_tag);
+ if (vst->codecpar->codec_tag == MKTAG('R', 'J', 'P', 'G'))
+ vst->codecpar->codec_id = AV_CODEC_ID_NUV;
} else
avio_skip(pb, 4);
if (ast) {
int id;
- ast->codec->codec_tag = avio_rl32(pb);
- ast->codec->sample_rate = avio_rl32(pb);
- ast->codec->bits_per_coded_sample = avio_rl32(pb);
- ast->codec->channels = avio_rl32(pb);
- ast->codec->channel_layout = 0;
+ ast->codecpar->codec_tag = avio_rl32(pb);
+ ast->codecpar->sample_rate = avio_rl32(pb);
+ ast->codecpar->bits_per_coded_sample = avio_rl32(pb);
+ ast->codecpar->channels = avio_rl32(pb);
+ ast->codecpar->channel_layout = 0;
- id = ff_wav_codec_get_id(ast->codec->codec_tag,
- ast->codec->bits_per_coded_sample);
+ id = ff_wav_codec_get_id(ast->codecpar->codec_tag,
+ ast->codecpar->bits_per_coded_sample);
if (id == AV_CODEC_ID_NONE) {
- id = ff_codec_get_id(nuv_audio_tags, ast->codec->codec_tag);
+ id = ff_codec_get_id(nuv_audio_tags, ast->codecpar->codec_tag);
if (id == AV_CODEC_ID_PCM_S16LE)
- id = ff_get_pcm_codec_id(ast->codec->bits_per_coded_sample,
+ id = ff_get_pcm_codec_id(ast->codecpar->bits_per_coded_sample,
0, 0, ~1);
}
- ast->codec->codec_id = id;
+ ast->codecpar->codec_id = id;
ast->need_parsing = AVSTREAM_PARSE_FULL;
} else
@@ -199,11 +199,11 @@ static int nuv_header(AVFormatContext *s)
if (ret < 0)
return ret;
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_id = AV_CODEC_ID_NUV;
- vst->codec->width = width;
- vst->codec->height = height;
- vst->codec->bits_per_coded_sample = 10;
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_id = AV_CODEC_ID_NUV;
+ vst->codecpar->width = width;
+ vst->codecpar->height = height;
+ vst->codecpar->bits_per_coded_sample = 10;
vst->sample_aspect_ratio = av_d2q(aspect * height / width,
10000);
#if FF_API_R_FRAME_RATE
@@ -220,14 +220,14 @@ static int nuv_header(AVFormatContext *s)
return AVERROR(ENOMEM);
ctx->a_id = ast->index;
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- ast->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
- ast->codec->channels = 2;
- ast->codec->channel_layout = AV_CH_LAYOUT_STEREO;
- ast->codec->sample_rate = 44100;
- ast->codec->bit_rate = 2 * 2 * 44100 * 8;
- ast->codec->block_align = 2 * 2;
- ast->codec->bits_per_coded_sample = 16;
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
+ ast->codecpar->channels = 2;
+ ast->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+ ast->codecpar->sample_rate = 44100;
+ ast->codecpar->bit_rate = 2 * 2 * 44100 * 8;
+ ast->codecpar->block_align = 2 * 2;
+ ast->codecpar->bits_per_coded_sample = 16;
avpriv_set_pts_info(ast, 32, 1, 1000);
} else
ctx->a_id = -1;
@@ -235,7 +235,7 @@ static int nuv_header(AVFormatContext *s)
if ((ret = get_codec_data(pb, vst, ast, is_mythtv)) < 0)
return ret;
- ctx->rtjpg_video = vst && vst->codec->codec_id == AV_CODEC_ID_NUV;
+ ctx->rtjpg_video = vst && vst->codecpar->codec_id == AV_CODEC_ID_NUV;
return 0;
}
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 9f1e0abb31..528d8db551 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -760,7 +760,7 @@ static void ogg_validate_keyframe(AVFormatContext *s, int idx, int pstart, int p
struct ogg_stream *os = ogg->streams + idx;
int invalid = 0;
if (psize) {
- switch (s->streams[idx]->codec->codec_id) {
+ switch (s->streams[idx]->codecpar->codec_id) {
case AV_CODEC_ID_THEORA:
invalid = !!(os->pflags & AV_PKT_FLAG_KEY) != !(os->buf[pstart] & 0x40);
break;
@@ -903,7 +903,7 @@ static int ogg_read_seek(AVFormatContext *s, int stream_index,
// Try seeking to a keyframe first. If this fails (very possible),
// av_seek_frame will fall back to ignoring keyframes
- if (s->streams[stream_index]->codec->codec_type == AVMEDIA_TYPE_VIDEO
+ if (s->streams[stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO
&& !(flags & AVSEEK_FLAG_ANY))
os->keyframe_seek = 1;
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 4907512989..f998af39ac 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -223,7 +223,7 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
// them as such, otherwise seeking will not work correctly at the very
// least with old libogg versions.
// Do not try to flush header packets though, that will create broken files.
- if (st->codec->codec_id == AV_CODEC_ID_THEORA && !header &&
+ if (st->codecpar->codec_id == AV_CODEC_ID_THEORA && !header &&
(ogg_granule_to_timestamp(oggstream, granule) >
ogg_granule_to_timestamp(oggstream, oggstream->last_granule) + 1 ||
ogg_key_granule(oggstream, granule))) {
@@ -311,13 +311,13 @@ static uint8_t *ogg_write_vorbiscomment(int64_t offset, int bitexact,
return p0;
}
-static int ogg_build_flac_headers(AVCodecContext *avctx,
+static int ogg_build_flac_headers(AVCodecParameters *par,
OGGStreamContext *oggstream, int bitexact,
AVDictionary **m)
{
uint8_t *p;
- if (avctx->extradata_size < FLAC_STREAMINFO_SIZE)
+ if (par->extradata_size < FLAC_STREAMINFO_SIZE)
return AVERROR(EINVAL);
// first packet: STREAMINFO
@@ -334,7 +334,7 @@ static int ogg_build_flac_headers(AVCodecContext *avctx,
bytestream_put_buffer(&p, "fLaC", 4);
bytestream_put_byte(&p, 0x00); // streaminfo
bytestream_put_be24(&p, 34);
- bytestream_put_buffer(&p, avctx->extradata, FLAC_STREAMINFO_SIZE);
+ bytestream_put_buffer(&p, par->extradata, FLAC_STREAMINFO_SIZE);
// second packet: VorbisComment
p = ogg_write_vorbiscomment(4, bitexact, &oggstream->header_len[1], m, 0);
@@ -349,13 +349,13 @@ static int ogg_build_flac_headers(AVCodecContext *avctx,
#define SPEEX_HEADER_SIZE 80
-static int ogg_build_speex_headers(AVCodecContext *avctx,
+static int ogg_build_speex_headers(AVCodecParameters *par,
OGGStreamContext *oggstream, int bitexact,
AVDictionary **m)
{
uint8_t *p;
- if (avctx->extradata_size < SPEEX_HEADER_SIZE)
+ if (par->extradata_size < SPEEX_HEADER_SIZE)
return AVERROR_INVALIDDATA;
// first packet: Speex header
@@ -364,7 +364,7 @@ static int ogg_build_speex_headers(AVCodecContext *avctx,
return AVERROR(ENOMEM);
oggstream->header[0] = p;
oggstream->header_len[0] = SPEEX_HEADER_SIZE;
- bytestream_put_buffer(&p, avctx->extradata, SPEEX_HEADER_SIZE);
+ bytestream_put_buffer(&p, par->extradata, SPEEX_HEADER_SIZE);
AV_WL32(&oggstream->header[0][68], 0); // set extra_headers to 0
// second packet: VorbisComment
@@ -378,22 +378,22 @@ static int ogg_build_speex_headers(AVCodecContext *avctx,
#define OPUS_HEADER_SIZE 19
-static int ogg_build_opus_headers(AVCodecContext *avctx,
+static int ogg_build_opus_headers(AVCodecParameters *par,
OGGStreamContext *oggstream, int bitexact,
AVDictionary **m)
{
uint8_t *p;
- if (avctx->extradata_size < OPUS_HEADER_SIZE)
+ if (par->extradata_size < OPUS_HEADER_SIZE)
return AVERROR_INVALIDDATA;
/* first packet: Opus header */
- p = av_mallocz(avctx->extradata_size);
+ p = av_mallocz(par->extradata_size);
if (!p)
return AVERROR(ENOMEM);
oggstream->header[0] = p;
- oggstream->header_len[0] = avctx->extradata_size;
- bytestream_put_buffer(&p, avctx->extradata, avctx->extradata_size);
+ oggstream->header_len[0] = par->extradata_size;
+ bytestream_put_buffer(&p, par->extradata, par->extradata_size);
/* second packet: VorbisComment */
p = ogg_write_vorbiscomment(8, bitexact, &oggstream->header_len[1], m, 0);
@@ -440,24 +440,24 @@ static int ogg_write_header(AVFormatContext *s)
AVStream *st = s->streams[i];
unsigned serial_num = i + ogg->serial_offset;
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- if (st->codec->codec_id == AV_CODEC_ID_OPUS)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_OPUS)
/* Opus requires a fixed 48kHz clock */
avpriv_set_pts_info(st, 64, 1, 48000);
else
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
}
- if (st->codec->codec_id != AV_CODEC_ID_VORBIS &&
- st->codec->codec_id != AV_CODEC_ID_THEORA &&
- st->codec->codec_id != AV_CODEC_ID_SPEEX &&
- st->codec->codec_id != AV_CODEC_ID_FLAC &&
- st->codec->codec_id != AV_CODEC_ID_OPUS) {
+ if (st->codecpar->codec_id != AV_CODEC_ID_VORBIS &&
+ st->codecpar->codec_id != AV_CODEC_ID_THEORA &&
+ st->codecpar->codec_id != AV_CODEC_ID_SPEEX &&
+ st->codecpar->codec_id != AV_CODEC_ID_FLAC &&
+ st->codecpar->codec_id != AV_CODEC_ID_OPUS) {
av_log(s, AV_LOG_ERROR, "Unsupported codec id in stream %d\n", i);
return AVERROR(EINVAL);
}
- if (!st->codec->extradata || !st->codec->extradata_size) {
+ if (!st->codecpar->extradata || !st->codecpar->extradata_size) {
av_log(s, AV_LOG_ERROR, "No extradata present\n");
return AVERROR_INVALIDDATA;
}
@@ -481,8 +481,8 @@ static int ogg_write_header(AVFormatContext *s)
av_dict_copy(&st->metadata, s->metadata, AV_DICT_DONT_OVERWRITE);
st->priv_data = oggstream;
- if (st->codec->codec_id == AV_CODEC_ID_FLAC) {
- int err = ogg_build_flac_headers(st->codec, oggstream,
+ if (st->codecpar->codec_id == AV_CODEC_ID_FLAC) {
+ int err = ogg_build_flac_headers(st->codecpar, oggstream,
s->flags & AVFMT_FLAG_BITEXACT,
&st->metadata);
if (err) {
@@ -490,8 +490,8 @@ static int ogg_write_header(AVFormatContext *s)
av_freep(&st->priv_data);
return err;
}
- } else if (st->codec->codec_id == AV_CODEC_ID_SPEEX) {
- int err = ogg_build_speex_headers(st->codec, oggstream,
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_SPEEX) {
+ int err = ogg_build_speex_headers(st->codecpar, oggstream,
s->flags & AVFMT_FLAG_BITEXACT,
&st->metadata);
if (err) {
@@ -499,8 +499,8 @@ static int ogg_write_header(AVFormatContext *s)
av_freep(&st->priv_data);
return err;
}
- } else if (st->codec->codec_id == AV_CODEC_ID_OPUS) {
- int err = ogg_build_opus_headers(st->codec, oggstream,
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_OPUS) {
+ int err = ogg_build_opus_headers(st->codecpar, oggstream,
s->flags & AVFMT_FLAG_BITEXACT,
&st->metadata);
if (err) {
@@ -510,12 +510,12 @@ static int ogg_write_header(AVFormatContext *s)
}
} else {
uint8_t *p;
- const char *cstr = st->codec->codec_id == AV_CODEC_ID_VORBIS ? "vorbis" : "theora";
- int header_type = st->codec->codec_id == AV_CODEC_ID_VORBIS ? 3 : 0x81;
- int framing_bit = st->codec->codec_id == AV_CODEC_ID_VORBIS ? 1 : 0;
+ const char *cstr = st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? "vorbis" : "theora";
+ int header_type = st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? 3 : 0x81;
+ int framing_bit = st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? 1 : 0;
- if (avpriv_split_xiph_headers(st->codec->extradata, st->codec->extradata_size,
- st->codec->codec_id == AV_CODEC_ID_VORBIS ? 30 : 42,
+ if (avpriv_split_xiph_headers(st->codecpar->extradata, st->codecpar->extradata_size,
+ st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? 30 : 42,
(const uint8_t**)oggstream->header, oggstream->header_len) < 0) {
av_log(s, AV_LOG_ERROR, "Extradata corrupted\n");
av_freep(&st->priv_data);
@@ -532,7 +532,7 @@ static int ogg_write_header(AVFormatContext *s)
bytestream_put_byte(&p, header_type);
bytestream_put_buffer(&p, cstr, 6);
- if (st->codec->codec_id == AV_CODEC_ID_THEORA) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_THEORA) {
/** KFGSHIFT is the width of the less significant section of the granule position
The less significant section is the frame count since the last keyframe */
oggstream->kfgshift = ((oggstream->header[0][40]&3)<<3)|(oggstream->header[0][41]>>5);
@@ -575,7 +575,7 @@ static int ogg_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
int ret;
int64_t granule;
- if (st->codec->codec_id == AV_CODEC_ID_THEORA) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_THEORA) {
int64_t pts = oggstream->vrev < 1 ? pkt->pts : pkt->pts + pkt->duration;
int pframe_count;
if (pkt->flags & AV_PKT_FLAG_KEY)
@@ -587,10 +587,10 @@ static int ogg_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
pframe_count = 0;
}
granule = (oggstream->last_kf_pts<<oggstream->kfgshift) | pframe_count;
- } else if (st->codec->codec_id == AV_CODEC_ID_OPUS)
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_OPUS)
granule = pkt->pts + pkt->duration +
- av_rescale_q(st->codec->initial_padding,
- (AVRational){ 1, st->codec->sample_rate },
+ av_rescale_q(st->codecpar->initial_padding,
+ (AVRational){ 1, st->codecpar->sample_rate },
st->time_base);
else
granule = pkt->pts + pkt->duration;
@@ -643,9 +643,9 @@ static int ogg_write_trailer(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
OGGStreamContext *oggstream = st->priv_data;
- if (st->codec->codec_id == AV_CODEC_ID_FLAC ||
- st->codec->codec_id == AV_CODEC_ID_SPEEX ||
- st->codec->codec_id == AV_CODEC_ID_OPUS) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_FLAC ||
+ st->codecpar->codec_id == AV_CODEC_ID_SPEEX ||
+ st->codecpar->codec_id == AV_CODEC_ID_OPUS) {
av_freep(&oggstream->header[0]);
}
av_freep(&oggstream->header[1]);
diff --git a/libavformat/oggparsecelt.c b/libavformat/oggparsecelt.c
index 2c0c511c7b..6d567f988a 100644
--- a/libavformat/oggparsecelt.c
+++ b/libavformat/oggparsecelt.c
@@ -48,7 +48,7 @@ static int celt_header(AVFormatContext *s, int idx)
priv = av_malloc(sizeof(struct oggcelt_private));
if (!priv)
return AVERROR(ENOMEM);
- if (ff_alloc_extradata(st->codec, 2 * sizeof(uint32_t)) < 0) {
+ if (ff_alloc_extradata(st->codecpar, 2 * sizeof(uint32_t)) < 0) {
av_free(priv);
return AVERROR(ENOMEM);
}
@@ -59,17 +59,17 @@ static int celt_header(AVFormatContext *s, int idx)
overlap = AV_RL32(p + 48);
/* unused bytes per packet field skipped */
extra_headers = AV_RL32(p + 56);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_CELT;
- st->codec->sample_rate = sample_rate;
- st->codec->channels = nb_channels;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_CELT;
+ st->codecpar->sample_rate = sample_rate;
+ st->codecpar->channels = nb_channels;
if (sample_rate)
avpriv_set_pts_info(st, 64, 1, sample_rate);
priv->extra_headers_left = 1 + extra_headers;
av_free(os->private);
os->private = priv;
- AV_WL32(st->codec->extradata + 0, overlap);
- AV_WL32(st->codec->extradata + 4, version);
+ AV_WL32(st->codecpar->extradata + 0, overlap);
+ AV_WL32(st->codecpar->extradata + 4, version);
return 1;
} else if (priv && priv->extra_headers_left) {
/* Extra headers (vorbiscomment) */
diff --git a/libavformat/oggparsedaala.c b/libavformat/oggparsedaala.c
index 3651ca188b..89bda58994 100644
--- a/libavformat/oggparsedaala.c
+++ b/libavformat/oggparsedaala.c
@@ -84,7 +84,7 @@ static int daala_header(AVFormatContext *s, int idx)
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
AVStream *st = s->streams[idx];
- int cds = st->codec->extradata_size + os->psize + 2;
+ int cds = st->codecpar->extradata_size + os->psize + 2;
DaalaInfoHeader *hdr = os->private;
if (!(os->buf[os->pstart] & 0x80))
@@ -106,8 +106,8 @@ static int daala_header(AVFormatContext *s, int idx)
hdr->version_min = bytestream2_get_byte(&gb);
hdr->version_sub = bytestream2_get_byte(&gb);
- st->codec->width = bytestream2_get_ne32(&gb);
- st->codec->height = bytestream2_get_ne32(&gb);
+ st->codecpar->width = bytestream2_get_ne32(&gb);
+ st->codecpar->height = bytestream2_get_ne32(&gb);
st->sample_aspect_ratio.num = bytestream2_get_ne32(&gb);
st->sample_aspect_ratio.den = bytestream2_get_ne32(&gb);
@@ -146,13 +146,13 @@ static int daala_header(AVFormatContext *s, int idx)
hdr->format.ydec[i] = bytestream2_get_byte(&gb);
}
- if ((st->codec->pix_fmt = daala_match_pix_fmt(&hdr->format)) < 0)
+ if ((st->codecpar->format = daala_match_pix_fmt(&hdr->format)) < 0)
av_log(s, AV_LOG_ERROR, "Unsupported pixel format - %i %i\n",
hdr->format.depth, hdr->format.planes);
- st->codec->codec_id = AV_CODEC_ID_DAALA;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->need_parsing = AVSTREAM_PARSE_HEADERS;
+ st->codecpar->codec_id = AV_CODEC_ID_DAALA;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->need_parsing = AVSTREAM_PARSE_HEADERS;
hdr->init_d = 1;
break;
@@ -173,18 +173,18 @@ static int daala_header(AVFormatContext *s, int idx)
break;
}
- if ((err = av_reallocp(&st->codec->extradata,
+ if ((err = av_reallocp(&st->codecpar->extradata,
cds + AV_INPUT_BUFFER_PADDING_SIZE)) < 0) {
- st->codec->extradata_size = 0;
+ st->codecpar->extradata_size = 0;
return err;
}
- memset(st->codec->extradata + cds, 0, AV_INPUT_BUFFER_PADDING_SIZE);
- cdp = st->codec->extradata + st->codec->extradata_size;
+ memset(st->codecpar->extradata + cds, 0, AV_INPUT_BUFFER_PADDING_SIZE);
+ cdp = st->codecpar->extradata + st->codecpar->extradata_size;
*cdp++ = os->psize >> 8;
*cdp++ = os->psize & 0xff;
memcpy(cdp, os->buf + os->pstart, os->psize);
- st->codec->extradata_size = cds;
+ st->codecpar->extradata_size = cds;
return 1;
}
diff --git a/libavformat/oggparsedirac.c b/libavformat/oggparsedirac.c
index 3e5e3930b2..9a67e25f3d 100644
--- a/libavformat/oggparsedirac.c
+++ b/libavformat/oggparsedirac.c
@@ -34,25 +34,25 @@ static int dirac_header(AVFormatContext *s, int idx)
int ret;
// already parsed the header
- if (st->codec->codec_id == AV_CODEC_ID_DIRAC)
+ if (st->codecpar->codec_id == AV_CODEC_ID_DIRAC)
return 0;
ret = av_dirac_parse_sequence_header(&dsh, os->buf + os->pstart + 13, (os->psize - 13), s);
if (ret < 0)
return ret;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_DIRAC;
- st->codec->width = dsh->width;
- st->codec->height = dsh->height;
- st->codec->pix_fmt = dsh->pix_fmt;
- st->codec->color_range = dsh->color_range;
- st->codec->color_trc = dsh->color_trc;
- st->codec->color_primaries = dsh->color_primaries;
- st->codec->colorspace = dsh->colorspace;
- st->codec->profile = dsh->profile;
- st->codec->level = dsh->level;
- if (av_image_check_sar(st->codec->width, st->codec->height, dsh->sample_aspect_ratio) >= 0)
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_DIRAC;
+ st->codecpar->width = dsh->width;
+ st->codecpar->height = dsh->height;
+ st->codecpar->format = dsh->pix_fmt;
+ st->codecpar->color_range = dsh->color_range;
+ st->codecpar->color_trc = dsh->color_trc;
+ st->codecpar->color_primaries = dsh->color_primaries;
+ st->codecpar->color_space = dsh->colorspace;
+ st->codecpar->profile = dsh->profile;
+ st->codecpar->level = dsh->level;
+ if (av_image_check_sar(st->codecpar->width, st->codecpar->height, dsh->sample_aspect_ratio) >= 0)
st->sample_aspect_ratio = dsh->sample_aspect_ratio;
// dirac in ogg always stores timestamps as though the video were interlaced
@@ -93,8 +93,8 @@ static int old_dirac_header(AVFormatContext *s, int idx)
if (buf[0] != 'K')
return 0;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_DIRAC;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_DIRAC;
avpriv_set_pts_info(st, 64, AV_RB32(buf+12), AV_RB32(buf+8));
return 1;
}
diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
index c7fb44618d..f08d07d7ab 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/oggparseflac.c
@@ -57,15 +57,15 @@ flac_header (AVFormatContext * s, int idx)
if (get_bits_long(&gb, 32) != FLAC_STREAMINFO_SIZE)
return -1;
- 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_HEADERS;
- if (ff_alloc_extradata(st->codec, FLAC_STREAMINFO_SIZE) < 0)
+ if (ff_alloc_extradata(st->codecpar, FLAC_STREAMINFO_SIZE) < 0)
return AVERROR(ENOMEM);
- memcpy(st->codec->extradata, streaminfo_start, st->codec->extradata_size);
+ memcpy(st->codecpar->extradata, streaminfo_start, st->codecpar->extradata_size);
- samplerate = AV_RB24(st->codec->extradata + 10) >> 4;
+ samplerate = AV_RB24(st->codecpar->extradata + 10) >> 4;
if (!samplerate)
return AVERROR_INVALIDDATA;
@@ -84,27 +84,38 @@ old_flac_header (AVFormatContext * s, int idx)
AVStream *st = s->streams[idx];
struct ogg_stream *os = ogg->streams + idx;
AVCodecParserContext *parser = av_parser_init(AV_CODEC_ID_FLAC);
- int size;
+ AVCodecContext *avctx;
+ int size, ret;
uint8_t *data;
if (!parser)
return -1;
- 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;
+
+ avctx = avcodec_alloc_context3(NULL);
+ if (!avctx)
+ return -1;
+
+ ret = avcodec_parameters_to_context(avctx, st->codecpar);
+ if (ret < 0)
+ return -1;
parser->flags = PARSER_FLAG_COMPLETE_FRAMES;
- av_parser_parse2(parser, st->codec,
+ av_parser_parse2(parser, avctx,
&data, &size, os->buf + os->pstart, os->psize,
AV_NOPTS_VALUE, AV_NOPTS_VALUE, -1);
av_parser_close(parser);
- if (st->codec->sample_rate) {
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ if (avctx->sample_rate) {
+ avpriv_set_pts_info(st, 64, 1, avctx->sample_rate);
+ avcodec_free_context(&avctx);
return 0;
}
+ avcodec_free_context(&avctx);
return 1;
}
diff --git a/libavformat/oggparseogm.c b/libavformat/oggparseogm.c
index d63c83b1c2..65c2d5f274 100644
--- a/libavformat/oggparseogm.c
+++ b/libavformat/oggparseogm.c
@@ -52,28 +52,28 @@ ogm_header(AVFormatContext *s, int idx)
if (bytestream2_peek_byte(&p) == 'v'){
int tag;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
bytestream2_skip(&p, 8);
tag = bytestream2_get_le32(&p);
- st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag);
- st->codec->codec_tag = tag;
- if (st->codec->codec_id == AV_CODEC_ID_MPEG4)
+ st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag);
+ st->codecpar->codec_tag = tag;
+ if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4)
st->need_parsing = AVSTREAM_PARSE_HEADERS;
} else if (bytestream2_peek_byte(&p) == 't') {
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_TEXT;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_TEXT;
bytestream2_skip(&p, 12);
} else {
uint8_t acid[5] = { 0 };
int cid;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
bytestream2_skip(&p, 8);
bytestream2_get_buffer(&p, acid, 4);
acid[4] = 0;
cid = strtol(acid, NULL, 16);
- st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags, cid);
+ st->codecpar->codec_id = ff_codec_get_id(ff_codec_wav_tags, cid);
// our parser completely breaks AAC in Ogg
- if (st->codec->codec_id != AV_CODEC_ID_AAC)
+ if (st->codecpar->codec_id != AV_CODEC_ID_AAC)
st->need_parsing = AVSTREAM_PARSE_FULL;
}
@@ -89,25 +89,25 @@ ogm_header(AVFormatContext *s, int idx)
bytestream2_skip(&p, 4); /* default_len */
bytestream2_skip(&p, 8); /* buffersize + bits_per_sample */
- if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){
- st->codec->width = bytestream2_get_le32(&p);
- st->codec->height = bytestream2_get_le32(&p);
+ if(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO){
+ st->codecpar->width = bytestream2_get_le32(&p);
+ st->codecpar->height = bytestream2_get_le32(&p);
avpriv_set_pts_info(st, 64, time_unit, spu * 10000000);
} else {
- st->codec->channels = bytestream2_get_le16(&p);
+ st->codecpar->channels = bytestream2_get_le16(&p);
bytestream2_skip(&p, 2); /* block_align */
- st->codec->bit_rate = bytestream2_get_le32(&p) * 8;
- st->codec->sample_rate = spu * 10000000 / time_unit;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
- if (size >= 56 && st->codec->codec_id == AV_CODEC_ID_AAC) {
+ st->codecpar->bit_rate = bytestream2_get_le32(&p) * 8;
+ st->codecpar->sample_rate = spu * 10000000 / time_unit;
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
+ if (size >= 56 && st->codecpar->codec_id == AV_CODEC_ID_AAC) {
bytestream2_skip(&p, 4);
size -= 4;
}
if (size > 52) {
av_assert0(AV_INPUT_BUFFER_PADDING_SIZE <= 52);
size -= 52;
- ff_alloc_extradata(st->codec, size);
- bytestream2_get_buffer(&p, st->codec->extradata, st->codec->extradata_size);
+ ff_alloc_extradata(st->codecpar, size);
+ bytestream2_get_buffer(&p, st->codecpar->extradata, st->codecpar->extradata_size);
}
}
} else if (bytestream2_peek_byte(&p) == 3) {
@@ -141,20 +141,20 @@ ogm_dshow_header(AVFormatContext *s, int idx)
if (os->psize < 184)
return AVERROR_INVALIDDATA;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(p + 68));
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(p + 68));
avpriv_set_pts_info(st, 64, AV_RL64(p + 164), 10000000);
- st->codec->width = AV_RL32(p + 176);
- st->codec->height = AV_RL32(p + 180);
+ st->codecpar->width = AV_RL32(p + 176);
+ st->codecpar->height = AV_RL32(p + 180);
} else if(t == 0x05589f81){
if (os->psize < 136)
return AVERROR_INVALIDDATA;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = ff_codec_get_id(ff_codec_wav_tags, AV_RL16(p + 124));
- st->codec->channels = AV_RL16(p + 126);
- st->codec->sample_rate = AV_RL32(p + 128);
- st->codec->bit_rate = AV_RL32(p + 132) * 8;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = ff_codec_get_id(ff_codec_wav_tags, AV_RL16(p + 124));
+ st->codecpar->channels = AV_RL16(p + 126);
+ st->codecpar->sample_rate = AV_RL32(p + 128);
+ st->codecpar->bit_rate = AV_RL32(p + 132) * 8;
}
return 1;
diff --git a/libavformat/oggparseopus.c b/libavformat/oggparseopus.c
index c8b02fab4d..8191b1083c 100644
--- a/libavformat/oggparseopus.c
+++ b/libavformat/oggparseopus.c
@@ -52,24 +52,24 @@ static int opus_header(AVFormatContext *avf, int idx)
if (os->flags & OGG_FLAG_BOS) {
if (os->psize < OPUS_HEAD_SIZE || (AV_RL8(packet + 8) & 0xF0) != 0)
return AVERROR_INVALIDDATA;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_OPUS;
- st->codec->channels = AV_RL8 (packet + 9);
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_OPUS;
+ st->codecpar->channels = AV_RL8(packet + 9);
+
priv->pre_skip = AV_RL16(packet + 10);
- st->codec->delay = priv->pre_skip;
+ st->codecpar->initial_padding = priv->pre_skip;
/*orig_sample_rate = AV_RL32(packet + 12);*/
/*gain = AV_RL16(packet + 16);*/
/*channel_map = AV_RL8 (packet + 18);*/
- if (ff_alloc_extradata(st->codec, os->psize))
+ if (ff_alloc_extradata(st->codecpar, os->psize))
return AVERROR(ENOMEM);
- memcpy(st->codec->extradata, packet, os->psize);
+ memcpy(st->codecpar->extradata, packet, os->psize);
- st->codec->sample_rate = 48000;
- av_codec_set_seek_preroll(st->codec,
- av_rescale(OPUS_SEEK_PREROLL_MS,
- st->codec->sample_rate, 1000));
+ st->codecpar->sample_rate = 48000;
+ st->codecpar->seek_preroll = av_rescale(OPUS_SEEK_PREROLL_MS,
+ st->codecpar->sample_rate, 1000);
avpriv_set_pts_info(st, 64, 1, 48000);
priv->need_comments = 1;
return 1;
diff --git a/libavformat/oggparseskeleton.c b/libavformat/oggparseskeleton.c
index 6c2105f324..532fa6aefa 100644
--- a/libavformat/oggparseskeleton.c
+++ b/libavformat/oggparseskeleton.c
@@ -34,7 +34,7 @@ static int skeleton_header(AVFormatContext *s, int idx)
uint64_t start_granule;
int target_idx, start_time;
- st->codec->codec_type = AVMEDIA_TYPE_DATA;
+ st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
if ((os->flags & OGG_FLAG_EOS) && os->psize == 0)
return 1;
diff --git a/libavformat/oggparsespeex.c b/libavformat/oggparsespeex.c
index c86b12713e..d7b153aa15 100644
--- a/libavformat/oggparsespeex.c
+++ b/libavformat/oggparsespeex.c
@@ -57,33 +57,33 @@ static int speex_header(AVFormatContext *s, int idx) {
if (spxp->seq == 0) {
int frames_per_packet;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_SPEEX;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_SPEEX;
if (os->psize < 68) {
av_log(s, AV_LOG_ERROR, "speex packet too small\n");
return AVERROR_INVALIDDATA;
}
- st->codec->sample_rate = AV_RL32(p + 36);
- st->codec->channels = AV_RL32(p + 48);
- if (st->codec->channels < 1 || st->codec->channels > 2) {
+ st->codecpar->sample_rate = AV_RL32(p + 36);
+ st->codecpar->channels = AV_RL32(p + 48);
+ if (st->codecpar->channels < 1 || st->codecpar->channels > 2) {
av_log(s, AV_LOG_ERROR, "invalid channel count. Speex must be mono or stereo.\n");
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;
spxp->packet_size = AV_RL32(p + 56);
frames_per_packet = AV_RL32(p + 64);
if (frames_per_packet)
spxp->packet_size *= frames_per_packet;
- if (ff_alloc_extradata(st->codec, os->psize) < 0)
+ if (ff_alloc_extradata(st->codecpar, os->psize) < 0)
return AVERROR(ENOMEM);
- memcpy(st->codec->extradata, p, st->codec->extradata_size);
+ memcpy(st->codecpar->extradata, p, st->codecpar->extradata_size);
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
} else
ff_vorbis_stream_comment(s, st, p, os->psize);
diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c
index 5f057c3c8a..b14f9f0669 100644
--- a/libavformat/oggparsetheora.c
+++ b/libavformat/oggparsetheora.c
@@ -41,7 +41,7 @@ static int theora_header(AVFormatContext *s, int idx)
struct ogg_stream *os = ogg->streams + idx;
AVStream *st = s->streams[idx];
TheoraParams *thp = os->private;
- int cds = st->codec->extradata_size + os->psize + 2;
+ int cds = st->codecpar->extradata_size + os->psize + 2;
int err;
uint8_t *cdp;
@@ -72,8 +72,8 @@ static int theora_header(AVFormatContext *s, int idx)
return AVERROR(ENOSYS);
}
- st->codec->width = get_bits(&gb, 16) << 4;
- st->codec->height = get_bits(&gb, 16) << 4;
+ st->codecpar->width = get_bits(&gb, 16) << 4;
+ st->codecpar->height = get_bits(&gb, 16) << 4;
if (thp->version >= 0x030400)
skip_bits(&gb, 100);
@@ -81,10 +81,10 @@ static int theora_header(AVFormatContext *s, int idx)
if (thp->version >= 0x030200) {
int width = get_bits_long(&gb, 24);
int height = get_bits_long(&gb, 24);
- if (width <= st->codec->width && width > st->codec->width - 16 &&
- height <= st->codec->height && height > st->codec->height - 16) {
- st->codec->width = width;
- st->codec->height = height;
+ if (width <= st->codecpar->width && width > st->codecpar->width - 16 &&
+ height <= st->codecpar->height && height > st->codecpar->height - 16) {
+ st->codecpar->width = width;
+ st->codecpar->height = height;
}
skip_bits(&gb, 16);
@@ -110,8 +110,8 @@ static int theora_header(AVFormatContext *s, int idx)
thp->gpshift = get_bits(&gb, 5);
thp->gpmask = (1U << thp->gpshift) - 1;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_THEORA;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_THEORA;
st->need_parsing = AVSTREAM_PARSE_HEADERS;
}
break;
@@ -126,18 +126,18 @@ static int theora_header(AVFormatContext *s, int idx)
return AVERROR_INVALIDDATA;
}
- if ((err = av_reallocp(&st->codec->extradata,
+ if ((err = av_reallocp(&st->codecpar->extradata,
cds + AV_INPUT_BUFFER_PADDING_SIZE)) < 0) {
- st->codec->extradata_size = 0;
+ st->codecpar->extradata_size = 0;
return err;
}
- memset(st->codec->extradata + cds, 0, AV_INPUT_BUFFER_PADDING_SIZE);
+ memset(st->codecpar->extradata + cds, 0, AV_INPUT_BUFFER_PADDING_SIZE);
- cdp = st->codec->extradata + st->codec->extradata_size;
+ cdp = st->codecpar->extradata + st->codecpar->extradata_size;
*cdp++ = os->psize >> 8;
*cdp++ = os->psize & 0xff;
memcpy(cdp, os->buf + os->pstart, os->psize);
- st->codec->extradata_size = cds;
+ st->codecpar->extradata_size = cds;
return 1;
}
diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index b96be98974..a8cd6c9f97 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -335,14 +335,14 @@ static int vorbis_header(AVFormatContext *s, int idx)
return AVERROR_INVALIDDATA;
channels = bytestream_get_byte(&p);
- if (st->codec->channels && channels != st->codec->channels) {
+ if (st->codecpar->channels && channels != st->codecpar->channels) {
av_log(s, AV_LOG_ERROR, "Channel change is not supported\n");
return AVERROR_PATCHWELCOME;
}
- st->codec->channels = channels;
+ st->codecpar->channels = channels;
srate = bytestream_get_le32(&p);
p += 4; // skip maximum bitrate
- st->codec->bit_rate = bytestream_get_le32(&p); // nominal bitrate
+ st->codecpar->bit_rate = bytestream_get_le32(&p); // nominal bitrate
p += 4; // skip minimum bitrate
blocksize = bytestream_get_byte(&p);
@@ -357,11 +357,11 @@ static int vorbis_header(AVFormatContext *s, int idx)
if (bytestream_get_byte(&p) != 1) /* framing_flag */
return AVERROR_INVALIDDATA;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_VORBIS;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_VORBIS;
if (srate > 0) {
- st->codec->sample_rate = srate;
+ st->codecpar->sample_rate = srate;
avpriv_set_pts_info(st, 64, 1, srate);
}
} else if (os->buf[os->pstart] == 3) {
@@ -381,17 +381,17 @@ static int vorbis_header(AVFormatContext *s, int idx)
}
}
} else {
- int ret = fixup_vorbis_headers(s, priv, &st->codec->extradata);
+ int ret = fixup_vorbis_headers(s, priv, &st->codecpar->extradata);
if (ret < 0) {
- st->codec->extradata_size = 0;
+ st->codecpar->extradata_size = 0;
return ret;
}
- st->codec->extradata_size = ret;
+ st->codecpar->extradata_size = ret;
- priv->vp = av_vorbis_parse_init(st->codec->extradata, st->codec->extradata_size);
+ priv->vp = av_vorbis_parse_init(st->codecpar->extradata, st->codecpar->extradata_size);
if (!priv->vp) {
- av_freep(&st->codec->extradata);
- st->codec->extradata_size = 0;
+ av_freep(&st->codecpar->extradata);
+ st->codecpar->extradata_size = 0;
return AVERROR_UNKNOWN;
}
}
diff --git a/libavformat/oggparsevp8.c b/libavformat/oggparsevp8.c
index 7aed8abad3..d57419e9f0 100644
--- a/libavformat/oggparsevp8.c
+++ b/libavformat/oggparsevp8.c
@@ -51,16 +51,16 @@ static int vp8_header(AVFormatContext *s, int idx)
return AVERROR_INVALIDDATA;
}
- st->codec->width = AV_RB16(p + 8);
- st->codec->height = AV_RB16(p + 10);
+ st->codecpar->width = AV_RB16(p + 8);
+ st->codecpar->height = AV_RB16(p + 10);
st->sample_aspect_ratio.num = AV_RB24(p + 12);
st->sample_aspect_ratio.den = AV_RB24(p + 15);
framerate.num = AV_RB32(p + 18);
framerate.den = AV_RB32(p + 22);
avpriv_set_pts_info(st, 64, framerate.den, framerate.num);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_VP8;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_VP8;
st->need_parsing = AVSTREAM_PARSE_HEADERS;
break;
case 0x02:
diff --git a/libavformat/omadec.c b/libavformat/omadec.c
index 132992dd33..6e476dbf25 100644
--- a/libavformat/omadec.c
+++ b/libavformat/omadec.c
@@ -342,10 +342,10 @@ static int oma_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
st->start_time = 0;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_tag = buf[32];
- st->codec->codec_id = ff_codec_get_id(ff_oma_codec_tags,
- st->codec->codec_tag);
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_tag = buf[32];
+ st->codecpar->codec_id = ff_codec_get_id(ff_oma_codec_tags,
+ st->codecpar->codec_tag);
switch (buf[32]) {
case OMA_CODECID_ATRAC3:
@@ -362,17 +362,17 @@ static int oma_read_header(AVFormatContext *s)
/* get stereo coding mode, 1 for joint-stereo */
jsflag = (codec_params >> 17) & 1;
- st->codec->channels = 2;
- st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
- st->codec->sample_rate = samplerate;
- st->codec->bit_rate = st->codec->sample_rate * framesize * 8 / 1024;
+ st->codecpar->channels = 2;
+ st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+ st->codecpar->sample_rate = samplerate;
+ st->codecpar->bit_rate = st->codecpar->sample_rate * framesize * 8 / 1024;
/* fake the ATRAC3 extradata
* (wav format, makes stream copy to wav work) */
- if (ff_alloc_extradata(st->codec, 14))
+ if (ff_alloc_extradata(st->codecpar, 14))
return AVERROR(ENOMEM);
- edata = st->codec->extradata;
+ edata = st->codecpar->extradata;
AV_WL16(&edata[0], 1); // always 1
AV_WL32(&edata[2], samplerate); // samples rate
AV_WL16(&edata[6], jsflag); // coding mode
@@ -380,7 +380,7 @@ static int oma_read_header(AVFormatContext *s)
AV_WL16(&edata[10], 1); // always 1
// AV_WL16(&edata[12], 0); // always 0
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
break;
case OMA_CODECID_ATRAC3P:
channel_id = (codec_params >> 10) & 7;
@@ -389,16 +389,16 @@ static int oma_read_header(AVFormatContext *s)
"Invalid ATRAC-X channel id: %"PRIu32"\n", channel_id);
return AVERROR_INVALIDDATA;
}
- st->codec->channel_layout = ff_oma_chid_to_native_layout[channel_id - 1];
- st->codec->channels = ff_oma_chid_to_num_channels[channel_id - 1];
+ st->codecpar->channel_layout = ff_oma_chid_to_native_layout[channel_id - 1];
+ st->codecpar->channels = ff_oma_chid_to_num_channels[channel_id - 1];
framesize = ((codec_params & 0x3FF) * 8) + 8;
samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7] * 100;
if (!samplerate) {
av_log(s, AV_LOG_ERROR, "Unsupported sample rate\n");
return AVERROR_INVALIDDATA;
}
- st->codec->sample_rate = samplerate;
- st->codec->bit_rate = samplerate * framesize * 8 / 2048;
+ st->codecpar->sample_rate = samplerate;
+ st->codecpar->bit_rate = samplerate * framesize * 8 / 2048;
avpriv_set_pts_info(st, 64, 1, samplerate);
break;
case OMA_CODECID_MP3:
@@ -407,22 +407,22 @@ static int oma_read_header(AVFormatContext *s)
break;
case OMA_CODECID_LPCM:
/* PCM 44.1 kHz 16 bit stereo big-endian */
- st->codec->channels = 2;
- st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
- st->codec->sample_rate = 44100;
+ st->codecpar->channels = 2;
+ st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+ st->codecpar->sample_rate = 44100;
framesize = 1024;
/* bit rate = sample rate x PCM block align (= 4) x 8 */
- st->codec->bit_rate = st->codec->sample_rate * 32;
- st->codec->bits_per_coded_sample =
- av_get_bits_per_sample(st->codec->codec_id);
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ st->codecpar->bit_rate = st->codecpar->sample_rate * 32;
+ st->codecpar->bits_per_coded_sample =
+ av_get_bits_per_sample(st->codecpar->codec_id);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
break;
default:
av_log(s, AV_LOG_ERROR, "Unsupported codec %d!\n", buf[32]);
return AVERROR(ENOSYS);
}
- st->codec->block_align = framesize;
+ st->codecpar->block_align = framesize;
return 0;
}
@@ -432,8 +432,8 @@ static int oma_read_packet(AVFormatContext *s, AVPacket *pkt)
{
OMAContext *oc = s->priv_data;
AVStream *st = s->streams[0];
- int packet_size = st->codec->block_align;
- int byte_rate = st->codec->bit_rate >> 3;
+ int packet_size = st->codecpar->block_align;
+ int byte_rate = st->codecpar->bit_rate >> 3;
int64_t pos = avio_tell(s->pb);
int ret = av_get_packet(s->pb, pkt, packet_size);
diff --git a/libavformat/omaenc.c b/libavformat/omaenc.c
index fe0669f5c9..d89cc37ee0 100644
--- a/libavformat/omaenc.c
+++ b/libavformat/omaenc.c
@@ -30,21 +30,21 @@
static av_cold int oma_write_header(AVFormatContext *s)
{
int i;
- AVCodecContext *format;
+ AVCodecParameters *par;
int srate_index;
int isjointstereo;
- format = s->streams[0]->codec;
+ par = s->streams[0]->codecpar;
/* check for support of the format first */
for (srate_index = 0; ; srate_index++) {
if (ff_oma_srate_tab[srate_index] == 0) {
av_log(s, AV_LOG_ERROR, "Sample rate %d not supported in OpenMG audio\n",
- format->sample_rate);
+ par->sample_rate);
return AVERROR(EINVAL);
}
- if (ff_oma_srate_tab[srate_index] * 100 == format->sample_rate)
+ if (ff_oma_srate_tab[srate_index] * 100 == par->sample_rate)
break;
}
@@ -58,16 +58,16 @@ static av_cold int oma_write_header(AVFormatContext *s)
for (i = 0; i < 6; i++)
avio_wl32(s->pb, 0); /* Padding + DRM id */
- switch(format->codec_tag) {
+ switch (par->codec_tag) {
case OMA_CODECID_ATRAC3:
- if (format->channels != 2) {
+ if (par->channels != 2) {
av_log(s, AV_LOG_ERROR, "ATRAC3 in OMA is only supported with 2 channels\n");
return AVERROR(EINVAL);
}
- if (format->extradata_size == 14) /* WAV format extradata */
- isjointstereo = format->extradata[6] != 0;
- else if(format->extradata_size == 10) /* RM format extradata */
- isjointstereo = format->extradata[8] == 0x12;
+ if (par->extradata_size == 14) /* WAV format extradata */
+ isjointstereo = par->extradata[6] != 0;
+ else if(par->extradata_size == 10) /* RM format extradata */
+ isjointstereo = par->extradata[8] == 0x12;
else {
av_log(s, AV_LOG_ERROR, "ATRAC3: Unsupported extradata size\n");
return AVERROR(EINVAL);
@@ -75,17 +75,17 @@ static av_cold int oma_write_header(AVFormatContext *s)
avio_wb32(s->pb, (OMA_CODECID_ATRAC3 << 24) |
(isjointstereo << 17) |
(srate_index << 13) |
- (format->block_align/8));
+ (par->block_align/8));
break;
case OMA_CODECID_ATRAC3P:
avio_wb32(s->pb, (OMA_CODECID_ATRAC3P << 24) |
(srate_index << 13) |
- (format->channels << 10) |
- (format->block_align/8 - 1));
+ (par->channels << 10) |
+ (par->block_align/8 - 1));
break;
default:
av_log(s, AV_LOG_ERROR, "unsupported codec tag %d for write\n",
- format->codec_tag);
+ par->codec_tag);
return AVERROR(EINVAL);
}
for (i = 0; i < (EA3_HEADER_SIZE - 36)/4; i++)
diff --git a/libavformat/paf.c b/libavformat/paf.c
index 4fc5006f40..fa30cdd72a 100644
--- a/libavformat/paf.c
+++ b/libavformat/paf.c
@@ -104,13 +104,13 @@ static int read_header(AVFormatContext *s)
p->nb_frames = avio_rl32(pb);
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);
avio_skip(pb, 4);
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_tag = 0;
- vst->codec->codec_id = AV_CODEC_ID_PAF_VIDEO;
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_tag = 0;
+ vst->codecpar->codec_id = AV_CODEC_ID_PAF_VIDEO;
avpriv_set_pts_info(vst, 64, 1, 10);
ast = avformat_new_stream(s, 0);
@@ -118,12 +118,12 @@ static int read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
ast->start_time = 0;
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- ast->codec->codec_tag = 0;
- ast->codec->codec_id = AV_CODEC_ID_PAF_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_tag = 0;
+ ast->codecpar->codec_id = AV_CODEC_ID_PAF_AUDIO;
+ ast->codecpar->channels = 2;
+ ast->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+ ast->codecpar->sample_rate = 22050;
avpriv_set_pts_info(ast, 64, 1, 22050);
p->buffer_size = avio_rl32(pb);
diff --git a/libavformat/pcm.c b/libavformat/pcm.c
index f62075fc82..806f91b6b1 100644
--- a/libavformat/pcm.c
+++ b/libavformat/pcm.c
@@ -30,7 +30,7 @@ int ff_pcm_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, size;
- size= RAW_SAMPLES*s->streams[0]->codec->block_align;
+ size= RAW_SAMPLES*s->streams[0]->codecpar->block_align;
if (size <= 0)
return AVERROR(EINVAL);
@@ -51,10 +51,10 @@ int ff_pcm_read_seek(AVFormatContext *s,
st = s->streams[0];
- block_align = st->codec->block_align ? st->codec->block_align :
- (av_get_bits_per_sample(st->codec->codec_id) * st->codec->channels) >> 3;
- byte_rate = st->codec->bit_rate ? st->codec->bit_rate >> 3 :
- block_align * st->codec->sample_rate;
+ block_align = st->codecpar->block_align ? st->codecpar->block_align :
+ (av_get_bits_per_sample(st->codecpar->codec_id) * st->codecpar->channels) >> 3;
+ byte_rate = st->codecpar->bit_rate ? st->codecpar->bit_rate >> 3 :
+ block_align * st->codecpar->sample_rate;
if (block_align <= 0 || byte_rate <= 0)
return -1;
diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c
index 2584c33c24..df94345a5a 100644
--- a/libavformat/pcmdec.c
+++ b/libavformat/pcmdec.c
@@ -42,20 +42,20 @@ static int pcm_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = s->iformat->raw_codec_id;
- st->codec->sample_rate = s1->sample_rate;
- st->codec->channels = s1->channels;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = s->iformat->raw_codec_id;
+ st->codecpar->sample_rate = s1->sample_rate;
+ st->codecpar->channels = s1->channels;
- 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);
- av_assert0(st->codec->bits_per_coded_sample > 0);
+ av_assert0(st->codecpar->bits_per_coded_sample > 0);
- st->codec->block_align =
- st->codec->bits_per_coded_sample * st->codec->channels / 8;
+ st->codecpar->block_align =
+ st->codecpar->bits_per_coded_sample * st->codecpar->channels / 8;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
diff --git a/libavformat/pjsdec.c b/libavformat/pjsdec.c
index a88d533192..bb587b569a 100644
--- a/libavformat/pjsdec.c
+++ b/libavformat/pjsdec.c
@@ -70,8 +70,8 @@ static int pjs_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 10);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_PJS;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_PJS;
while (!avio_feof(s->pb)) {
char line[4096];
diff --git a/libavformat/pmpdec.c b/libavformat/pmpdec.c
index ec966b3e1a..0e80a095fb 100644
--- a/libavformat/pmpdec.c
+++ b/libavformat/pmpdec.c
@@ -54,22 +54,22 @@ static int pmp_header(AVFormatContext *s)
AVStream *vst = avformat_new_stream(s, NULL);
if (!vst)
return AVERROR(ENOMEM);
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
avio_skip(pb, 8);
switch (avio_rl32(pb)) {
case 0:
- vst->codec->codec_id = AV_CODEC_ID_MPEG4;
+ vst->codecpar->codec_id = AV_CODEC_ID_MPEG4;
break;
case 1:
- vst->codec->codec_id = AV_CODEC_ID_H264;
+ vst->codecpar->codec_id = AV_CODEC_ID_H264;
break;
default:
av_log(s, AV_LOG_ERROR, "Unsupported video format\n");
break;
}
- index_cnt = avio_rl32(pb);
- vst->codec->width = avio_rl32(pb);
- vst->codec->height = avio_rl32(pb);
+ index_cnt = avio_rl32(pb);
+ vst->codecpar->width = avio_rl32(pb);
+ vst->codecpar->height = avio_rl32(pb);
tb_num = avio_rl32(pb);
tb_den = avio_rl32(pb);
@@ -117,10 +117,10 @@ static int pmp_header(AVFormatContext *s)
AVStream *ast = avformat_new_stream(s, NULL);
if (!ast)
return AVERROR(ENOMEM);
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- ast->codec->codec_id = audio_codec_id;
- ast->codec->channels = channels;
- ast->codec->sample_rate = srate;
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codecpar->codec_id = audio_codec_id;
+ ast->codecpar->channels = channels;
+ ast->codecpar->sample_rate = srate;
avpriv_set_pts_info(ast, 32, 1, srate);
}
return 0;
diff --git a/libavformat/psxstr.c b/libavformat/psxstr.c
index 38186f7fd1..ca89fcfe58 100644
--- a/libavformat/psxstr.c
+++ b/libavformat/psxstr.c
@@ -199,11 +199,11 @@ static int str_read_packet(AVFormatContext *s,
str->channels[channel].video_stream_index = st->index;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_MDEC;
- st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = AV_RL16(&sector[0x28]);
- st->codec->height = AV_RL16(&sector[0x2A]);
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_MDEC;
+ st->codecpar->codec_tag = 0; /* no fourcc */
+ st->codecpar->width = AV_RL16(&sector[0x28]);
+ st->codecpar->height = AV_RL16(&sector[0x2A]);
}
/* if this is the first sector of the frame, allocate a pkt */
@@ -248,22 +248,22 @@ static int str_read_packet(AVFormatContext *s,
str->channels[channel].audio_stream_index = st->index;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_ADPCM_XA;
- st->codec->codec_tag = 0; /* no fourcc */
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_XA;
+ st->codecpar->codec_tag = 0; /* no fourcc */
if (fmt & 1) {
- 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 = (fmt&4)?18900:37800;
- // st->codec->bit_rate = 0; //FIXME;
- st->codec->block_align = 128;
+ st->codecpar->sample_rate = (fmt&4)?18900:37800;
+ // st->codecpar->bit_rate = 0; //FIXME;
+ st->codecpar->block_align = 128;
- avpriv_set_pts_info(st, 64, 18 * 224 / st->codec->channels,
- st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 18 * 224 / st->codecpar->channels,
+ st->codecpar->sample_rate);
st->start_time = 0;
}
pkt = ret_pkt;
diff --git a/libavformat/pva.c b/libavformat/pva.c
index 900ad6133d..16381db905 100644
--- a/libavformat/pva.c
+++ b/libavformat/pva.c
@@ -59,16 +59,16 @@ static int pva_read_header(AVFormatContext *s) {
if (!(st = avformat_new_stream(s, NULL)))
return AVERROR(ENOMEM);
- 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_FULL;
avpriv_set_pts_info(st, 32, 1, 90000);
av_add_index_entry(st, 0, 0, 0, 0, AVINDEX_KEYFRAME);
if (!(st = avformat_new_stream(s, NULL)))
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_MP2;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_MP2;
st->need_parsing = AVSTREAM_PARSE_FULL;
avpriv_set_pts_info(st, 33, 1, 90000);
av_add_index_entry(st, 0, 0, 0, 0, AVINDEX_KEYFRAME);
diff --git a/libavformat/pvfdec.c b/libavformat/pvfdec.c
index c678046156..b9f6d4f2c2 100644
--- a/libavformat/pvfdec.c
+++ b/libavformat/pvfdec.c
@@ -51,14 +51,14 @@ static int pvf_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->channels = channels;
- st->codec->sample_rate = sample_rate;
- st->codec->codec_id = ff_get_pcm_codec_id(bps, 0, 1, 0xFFFF);
- st->codec->bits_per_coded_sample = bps;
- st->codec->block_align = bps * st->codec->channels / 8;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->channels = channels;
+ st->codecpar->sample_rate = sample_rate;
+ st->codecpar->codec_id = ff_get_pcm_codec_id(bps, 0, 1, 0xFFFF);
+ st->codecpar->bits_per_coded_sample = bps;
+ st->codecpar->block_align = bps * st->codecpar->channels / 8;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
diff --git a/libavformat/qcp.c b/libavformat/qcp.c
index ad4a8ae79c..b842e2633c 100644
--- a/libavformat/qcp.c
+++ b/libavformat/qcp.c
@@ -101,29 +101,29 @@ static int qcp_read_header(AVFormatContext *s)
avio_rb32(pb); // "RIFF"
avio_skip(pb, 4 + 8 + 4 + 1 + 1); // filesize + "QLCMfmt " + chunk-size + major-version + minor-version
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->channels = 1;
- st->codec->channel_layout = AV_CH_LAYOUT_MONO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->channels = 1;
+ st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
avio_read(pb, buf, 16);
if (is_qcelp_13k_guid(buf)) {
- st->codec->codec_id = AV_CODEC_ID_QCELP;
+ st->codecpar->codec_id = AV_CODEC_ID_QCELP;
} else if (!memcmp(buf, guid_evrc, 16)) {
- st->codec->codec_id = AV_CODEC_ID_EVRC;
+ st->codecpar->codec_id = AV_CODEC_ID_EVRC;
} else if (!memcmp(buf, guid_smv, 16)) {
- st->codec->codec_id = AV_CODEC_ID_SMV;
+ st->codecpar->codec_id = AV_CODEC_ID_SMV;
} else if (!memcmp(buf, guid_4gv, 16)) {
- st->codec->codec_id = AV_CODEC_ID_4GV;
+ st->codecpar->codec_id = AV_CODEC_ID_4GV;
} else {
av_log(s, AV_LOG_ERROR, "Unknown codec GUID "FF_PRI_GUID".\n",
FF_ARG_GUID(buf));
return AVERROR_INVALIDDATA;
}
avio_skip(pb, 2 + 80); // codec-version + codec-name
- st->codec->bit_rate = avio_rl16(pb);
+ st->codecpar->bit_rate = avio_rl16(pb);
s->packet_size = avio_rl16(pb);
avio_skip(pb, 2); // block-size
- st->codec->sample_rate = avio_rl16(pb);
+ st->codecpar->sample_rate = avio_rl16(pb);
avio_skip(pb, 2); // sample-size
memset(c->rates_per_mode, -1, sizeof(c->rates_per_mode));
diff --git a/libavformat/r3d.c b/libavformat/r3d.c
index 94c3015fd5..b609488839 100644
--- a/libavformat/r3d.c
+++ b/libavformat/r3d.c
@@ -62,8 +62,8 @@ static int r3d_read_red1(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_JPEG2000;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_JPEG2000;
tmp = avio_r8(s->pb); // major version
tmp2 = avio_r8(s->pb); // minor version
@@ -80,8 +80,8 @@ static int r3d_read_red1(AVFormatContext *s)
avio_skip(s->pb, 32); // unknown
- st->codec->width = avio_rb32(s->pb);
- st->codec->height = avio_rb32(s->pb);
+ st->codecpar->width = avio_rb32(s->pb);
+ st->codecpar->height = avio_rb32(s->pb);
tmp = avio_rb16(s->pb); // unknown
av_log(s, AV_LOG_TRACE, "unknown2 %d\n", tmp);
@@ -103,7 +103,7 @@ static int r3d_read_red1(AVFormatContext *s)
av_dict_set(&st->metadata, "filename", filename, 0);
av_log(s, AV_LOG_TRACE, "filename %s\n", filename);
- av_log(s, AV_LOG_TRACE, "resolution %dx%d\n", st->codec->width, st->codec->height);
+ av_log(s, AV_LOG_TRACE, "resolution %dx%d\n", st->codecpar->width, st->codecpar->height);
av_log(s, AV_LOG_TRACE, "timescale %d\n", st->time_base.den);
av_log(s, AV_LOG_TRACE, "frame rate %d/%d\n",
framerate.num, framerate.den);
@@ -284,9 +284,9 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
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_S32BE;
- st->codec->channels = r3d->audio_channels;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S32BE;
+ st->codecpar->channels = r3d->audio_channels;
avpriv_set_pts_info(st, 32, 1, s->streams[0]->time_base.den);
} else {
st = s->streams[1];
@@ -294,8 +294,8 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
dts = avio_rb32(s->pb);
- st->codec->sample_rate = avio_rb32(s->pb);
- if (st->codec->sample_rate <= 0) {
+ st->codecpar->sample_rate = avio_rb32(s->pb);
+ if (st->codecpar->sample_rate <= 0) {
av_log(s, AV_LOG_ERROR, "Bad sample rate\n");
return AVERROR_INVALIDDATA;
}
@@ -326,10 +326,10 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
pkt->stream_index = 1;
pkt->dts = dts;
- if (st->codec->sample_rate)
- pkt->duration = av_rescale(samples, st->time_base.den, st->codec->sample_rate);
+ if (st->codecpar->sample_rate)
+ pkt->duration = av_rescale(samples, st->time_base.den, st->codecpar->sample_rate);
av_log(s, AV_LOG_TRACE, "pkt dts %"PRId64" duration %"PRId64" samples %d sample rate %d\n",
- pkt->dts, pkt->duration, samples, st->codec->sample_rate);
+ pkt->dts, pkt->duration, samples, st->codecpar->sample_rate);
return 0;
}
diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
index 35ad1181c2..8c734dbb30 100644
--- a/libavformat/rawdec.c
+++ b/libavformat/rawdec.c
@@ -57,8 +57,8 @@ int ff_raw_audio_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 = 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_RAW;
st->start_time = 0;
/* the parameters will be extracted from the compressed bitstream */
@@ -80,12 +80,12 @@ int ff_raw_video_read_header(AVFormatContext *s)
goto fail;
}
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = s->iformat->raw_codec_id;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = s->iformat->raw_codec_id;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
- st->codec->framerate = s1->framerate;
- st->codec->time_base = av_inv_q(s1->framerate);
+ st->avg_frame_rate = s1->framerate;
+ st->internal->avctx->framerate = s1->framerate;
avpriv_set_pts_info(st, 64, 1, 1200000);
fail:
@@ -97,8 +97,8 @@ int ff_raw_data_read_header(AVFormatContext *s)
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_DATA;
- st->codec->codec_id = s->iformat->raw_codec_id;
+ st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+ st->codecpar->codec_id = s->iformat->raw_codec_id;
st->start_time = 0;
return 0;
}
diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index 14ba9fbf47..4b8b41ca04 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -60,11 +60,11 @@ AVOutputFormat ff_ac3_muxer = {
static int adx_write_trailer(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
- AVCodecContext *avctx = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
if (pb->seekable) {
int64_t file_size = avio_tell(pb);
- uint64_t sample_count = (file_size - 36) / avctx->channels / 18 * 32;
+ uint64_t sample_count = (file_size - 36) / par->channels / 18 * 32;
if (sample_count <= UINT32_MAX) {
avio_seek(pb, 12, SEEK_SET);
avio_wb32(pb, sample_count);
diff --git a/libavformat/rawutils.c b/libavformat/rawutils.c
index 26ebbb5629..996412adb9 100644
--- a/libavformat/rawutils.c
+++ b/libavformat/rawutils.c
@@ -22,30 +22,30 @@
#include "avformat.h"
#include "internal.h"
-int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecContext *enc, int expected_stride)
+int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecParameters *par, int expected_stride)
{
int ret;
AVPacket *pkt = *ppkt;
- int64_t bpc = enc->bits_per_coded_sample != 15 ? enc->bits_per_coded_sample : 16;
- int min_stride = (enc->width * bpc + 7) >> 3;
- int with_pal_size = min_stride * enc->height + 1024;
+ int64_t bpc = par->bits_per_coded_sample != 15 ? par->bits_per_coded_sample : 16;
+ int min_stride = (par->width * bpc + 7) >> 3;
+ int with_pal_size = min_stride * par->height + 1024;
int contains_pal = bpc == 8 && pkt->size == with_pal_size;
- int size = contains_pal ? min_stride * enc->height : pkt->size;
- int stride = size / enc->height;
+ int size = contains_pal ? min_stride * par->height : pkt->size;
+ int stride = size / par->height;
int padding = expected_stride - FFMIN(expected_stride, stride);
int y;
AVPacket *new_pkt;
- if (pkt->size == expected_stride * enc->height)
+ if (pkt->size == expected_stride * par->height)
return 0;
- if (size != stride * enc->height)
+ if (size != stride * par->height)
return 0;
new_pkt = av_packet_alloc();
if (!new_pkt)
return AVERROR(ENOMEM);
- ret = av_new_packet(new_pkt, expected_stride * enc->height);
+ ret = av_new_packet(new_pkt, expected_stride * par->height);
if (ret < 0)
goto fail;
@@ -53,7 +53,7 @@ int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecContext *en
if (ret < 0)
goto fail;
- for (y = 0; y<enc->height; y++) {
+ for (y = 0; y<par->height; y++) {
memcpy(new_pkt->data + y*expected_stride, pkt->data + y*stride, FFMIN(expected_stride, stride));
memset(new_pkt->data + y*expected_stride + expected_stride - padding, 0, padding);
}
diff --git a/libavformat/rawvideodec.c b/libavformat/rawvideodec.c
index 91bdba0e9a..b037aeaa59 100644
--- a/libavformat/rawvideodec.c
+++ b/libavformat/rawvideodec.c
@@ -45,9 +45,9 @@ static int rawvideo_read_header(AVFormatContext *ctx)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = ctx->iformat->raw_codec_id;
+ st->codecpar->codec_id = ctx->iformat->raw_codec_id;
if ((pix_fmt = av_get_pix_fmt(s->pixel_format)) == AV_PIX_FMT_NONE) {
av_log(ctx, AV_LOG_ERROR, "No such pixel format: %s.\n",
@@ -57,14 +57,14 @@ static int rawvideo_read_header(AVFormatContext *ctx)
avpriv_set_pts_info(st, 64, s->framerate.den, s->framerate.num);
- st->codec->width = s->width;
- st->codec->height = s->height;
- st->codec->pix_fmt = pix_fmt;
- packet_size = av_image_get_buffer_size(st->codec->pix_fmt, s->width, s->height, 1);
+ st->codecpar->width = s->width;
+ st->codecpar->height = s->height;
+ st->codecpar->format = pix_fmt;
+ packet_size = av_image_get_buffer_size(st->codecpar->format, s->width, s->height, 1);
if (packet_size < 0)
return packet_size;
ctx->packet_size = packet_size;
- st->codec->bit_rate = av_rescale_q(ctx->packet_size,
+ st->codecpar->bit_rate = av_rescale_q(ctx->packet_size,
(AVRational){8,1}, st->time_base);
return 0;
diff --git a/libavformat/rdt.c b/libavformat/rdt.c
index 0300b76928..6cb4d6aa42 100644
--- a/libavformat/rdt.c
+++ b/libavformat/rdt.c
@@ -309,7 +309,7 @@ rdt_parse_packet (AVFormatContext *ctx, PayloadContext *rdt, AVStream *st,
if (res < 0)
return res;
if (res > 0) {
- if (st->codec->codec_id == AV_CODEC_ID_AAC) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
memcpy (rdt->buffer, buf + pos, len - pos);
rdt->rmctx->pb = avio_alloc_context (rdt->buffer, len - pos, 0,
NULL, NULL, NULL, NULL);
@@ -322,7 +322,7 @@ get_cache:
ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb,
st, rdt->rmst[st->index], pkt);
if (rdt->audio_pkt_cnt == 0 &&
- st->codec->codec_id == AV_CODEC_ID_AAC)
+ st->codecpar->codec_id == AV_CODEC_ID_AAC)
av_freep(&rdt->rmctx->pb);
}
pkt->stream_index = st->index;
@@ -448,7 +448,7 @@ real_parse_asm_rule(AVStream *st, const char *p, const char *end)
{
do {
/* can be either averagebandwidth= or AverageBandwidth= */
- if (sscanf(p, " %*1[Aa]verage%*1[Bb]andwidth=%"SCNd64, &st->codec->bit_rate) == 1)
+ if (sscanf(p, " %*1[Aa]verage%*1[Bb]andwidth=%"SCNd64, &st->codecpar->bit_rate) == 1)
break;
if (!(p = strchr(p, ',')) || p > end)
p = end;
@@ -464,7 +464,7 @@ add_dstream(AVFormatContext *s, AVStream *orig_st)
if (!(st = avformat_new_stream(s, NULL)))
return NULL;
st->id = orig_st->id;
- st->codec->codec_type = orig_st->codec->codec_type;
+ st->codecpar->codec_type = orig_st->codecpar->codec_type;
st->first_dts = orig_st->first_dts;
return st;
diff --git a/libavformat/realtextdec.c b/libavformat/realtextdec.c
index f13321c91a..618d4f78ec 100644
--- a/libavformat/realtextdec.c
+++ b/libavformat/realtextdec.c
@@ -70,8 +70,8 @@ static int realtext_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 100);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_REALTEXT;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_REALTEXT;
av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
@@ -89,12 +89,12 @@ static int realtext_read_header(AVFormatContext *s)
if (p)
duration = read_ts(p);
- st->codec->extradata = av_strdup(buf.str);
- if (!st->codec->extradata) {
+ st->codecpar->extradata = av_strdup(buf.str);
+ if (!st->codecpar->extradata) {
res = AVERROR(ENOMEM);
goto end;
}
- st->codec->extradata_size = buf.len + 1;
+ st->codecpar->extradata_size = buf.len + 1;
} else {
/* if we just read a <time> tag, introduce a new event, otherwise merge
* with the previous one */
diff --git a/libavformat/redspark.c b/libavformat/redspark.c
index 5cea6e96b9..8535bef11a 100644
--- a/libavformat/redspark.c
+++ b/libavformat/redspark.c
@@ -55,7 +55,7 @@ static int redspark_read_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
RedSparkContext *redspark = s->priv_data;
- AVCodecContext *codec;
+ AVCodecParameters *par;
GetByteContext gbc;
int i, coef_off, ret = 0;
uint32_t key, data;
@@ -65,7 +65,7 @@ static int redspark_read_header(AVFormatContext *s)
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
- codec = st->codec;
+ par = st->codecpar;
header = av_malloc(HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
if (!header)
@@ -83,14 +83,14 @@ static int redspark_read_header(AVFormatContext *s)
bytestream_put_be32(&pbc, data);
}
- codec->codec_id = AV_CODEC_ID_ADPCM_THP;
- codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ par->codec_id = AV_CODEC_ID_ADPCM_THP;
+ par->codec_type = AVMEDIA_TYPE_AUDIO;
bytestream2_init(&gbc, header, HEADER_SIZE);
bytestream2_seek(&gbc, 0x3c, SEEK_SET);
- codec->sample_rate = bytestream2_get_be32u(&gbc);
- if (codec->sample_rate <= 0 || codec->sample_rate > 96000) {
- av_log(s, AV_LOG_ERROR, "Invalid sample rate: %d\n", codec->sample_rate);
+ par->sample_rate = bytestream2_get_be32u(&gbc);
+ if (par->sample_rate <= 0 || par->sample_rate > 96000) {
+ av_log(s, AV_LOG_ERROR, "Invalid sample rate: %d\n", par->sample_rate);
ret = AVERROR_INVALIDDATA;
goto fail;
}
@@ -98,37 +98,37 @@ static int redspark_read_header(AVFormatContext *s)
st->duration = bytestream2_get_be32u(&gbc) * 14;
redspark->samples_count = 0;
bytestream2_skipu(&gbc, 10);
- codec->channels = bytestream2_get_byteu(&gbc);
- if (!codec->channels) {
+ par->channels = bytestream2_get_byteu(&gbc);
+ if (!par->channels) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
- coef_off = 0x54 + codec->channels * 8;
+ coef_off = 0x54 + par->channels * 8;
if (bytestream2_get_byteu(&gbc)) // Loop flag
coef_off += 16;
- if (coef_off + codec->channels * (32 + 14) > HEADER_SIZE) {
+ if (coef_off + par->channels * (32 + 14) > HEADER_SIZE) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
- if (ff_alloc_extradata(codec, 32 * codec->channels)) {
+ if (ff_alloc_extradata(par, 32 * par->channels)) {
ret = AVERROR(ENOMEM);
goto fail;
}
/* Get the ADPCM table */
bytestream2_seek(&gbc, coef_off, SEEK_SET);
- for (i = 0; i < codec->channels; i++) {
- if (bytestream2_get_bufferu(&gbc, codec->extradata + i * 32, 32) != 32) {
+ for (i = 0; i < par->channels; i++) {
+ if (bytestream2_get_bufferu(&gbc, par->extradata + i * 32, 32) != 32) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
bytestream2_skipu(&gbc, 14);
}
- avpriv_set_pts_info(st, 64, 1, codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, par->sample_rate);
fail:
av_free(header);
@@ -138,9 +138,9 @@ fail:
static int redspark_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- AVCodecContext *codec = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
RedSparkContext *redspark = s->priv_data;
- uint32_t size = 8 * codec->channels;
+ uint32_t size = 8 * par->channels;
int ret;
if (avio_feof(s->pb) || redspark->samples_count == s->streams[0]->duration)
diff --git a/libavformat/riff.h b/libavformat/riff.h
index 3b57bb45d3..fe87e81933 100644
--- a/libavformat/riff.h
+++ b/libavformat/riff.h
@@ -45,7 +45,7 @@ void ff_end_tag(AVIOContext *pb, int64_t start);
*/
int ff_get_bmp_header(AVIOContext *pb, AVStream *st, unsigned *esize);
-void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf, int ignore_extradata);
+void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par, const AVCodecTag *tags, int for_asf, int ignore_extradata);
/**
* Tell ff_put_wav_header() to use WAVEFORMATEX even for PCM codecs.
@@ -64,10 +64,10 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const AVCodecTag *t
*
* @return the size or -1 on error
*/
-int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc, int flags);
+int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int flags);
enum AVCodecID ff_wav_codec_get_id(unsigned int tag, int bps);
-int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecContext *codec, int size, int big_endian);
+int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian);
extern const AVCodecTag ff_codec_bmp_tags[]; // exposed through avformat_get_riff_video_tags()
extern const AVCodecTag ff_codec_wav_tags[];
diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c
index 151178dbc5..0b1083264f 100644
--- a/libavformat/riffdec.c
+++ b/libavformat/riffdec.c
@@ -58,27 +58,27 @@ enum AVCodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid)
* an openended structure.
*/
-static void parse_waveformatex(AVIOContext *pb, AVCodecContext *c)
+static void parse_waveformatex(AVIOContext *pb, AVCodecParameters *par)
{
ff_asf_guid subformat;
int bps = avio_rl16(pb);
if (bps)
- c->bits_per_coded_sample = bps;
+ par->bits_per_coded_sample = bps;
- c->channel_layout = avio_rl32(pb); /* dwChannelMask */
+ par->channel_layout = avio_rl32(pb); /* dwChannelMask */
ff_get_guid(pb, &subformat);
if (!memcmp(subformat + 4,
(const uint8_t[]){ FF_AMBISONIC_BASE_GUID }, 12) ||
!memcmp(subformat + 4,
(const uint8_t[]){ FF_MEDIASUBTYPE_BASE_GUID }, 12)) {
- c->codec_tag = AV_RL32(subformat);
- c->codec_id = ff_wav_codec_get_id(c->codec_tag,
- c->bits_per_coded_sample);
+ par->codec_tag = AV_RL32(subformat);
+ par->codec_id = ff_wav_codec_get_id(par->codec_tag,
+ par->bits_per_coded_sample);
} else {
- c->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subformat);
- if (!c->codec_id)
- av_log(c, AV_LOG_WARNING,
+ par->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subformat);
+ if (!par->codec_id)
+ av_log(pb, AV_LOG_WARNING,
"unknown subformat:"FF_PRI_GUID"\n",
FF_ARG_GUID(subformat));
}
@@ -86,64 +86,64 @@ static void parse_waveformatex(AVIOContext *pb, AVCodecContext *c)
/* "big_endian" values are needed for RIFX file format */
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
- AVCodecContext *codec, int size, int big_endian)
+ AVCodecParameters *par, int size, int big_endian)
{
int id;
uint64_t bitrate = 0;
if (size < 14) {
- avpriv_request_sample(codec, "wav header size < 14");
+ avpriv_request_sample(s, "wav header size < 14");
return AVERROR_INVALIDDATA;
}
- codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ par->codec_type = AVMEDIA_TYPE_AUDIO;
if (!big_endian) {
id = avio_rl16(pb);
if (id != 0x0165) {
- codec->channels = avio_rl16(pb);
- codec->sample_rate = avio_rl32(pb);
+ par->channels = avio_rl16(pb);
+ par->sample_rate = avio_rl32(pb);
bitrate = avio_rl32(pb) * 8LL;
- codec->block_align = avio_rl16(pb);
+ par->block_align = avio_rl16(pb);
}
} else {
id = avio_rb16(pb);
- codec->channels = avio_rb16(pb);
- codec->sample_rate = avio_rb32(pb);
+ par->channels = avio_rb16(pb);
+ par->sample_rate = avio_rb32(pb);
bitrate = avio_rb32(pb) * 8LL;
- codec->block_align = avio_rb16(pb);
+ par->block_align = avio_rb16(pb);
}
if (size == 14) { /* We're dealing with plain vanilla WAVEFORMAT */
- codec->bits_per_coded_sample = 8;
+ par->bits_per_coded_sample = 8;
} else {
if (!big_endian) {
- codec->bits_per_coded_sample = avio_rl16(pb);
+ par->bits_per_coded_sample = avio_rl16(pb);
} else {
- codec->bits_per_coded_sample = avio_rb16(pb);
+ par->bits_per_coded_sample = avio_rb16(pb);
}
}
if (id == 0xFFFE) {
- codec->codec_tag = 0;
+ par->codec_tag = 0;
} else {
- codec->codec_tag = id;
- codec->codec_id = ff_wav_codec_get_id(id,
- codec->bits_per_coded_sample);
+ par->codec_tag = id;
+ par->codec_id = ff_wav_codec_get_id(id,
+ par->bits_per_coded_sample);
}
if (size >= 18 && id != 0x0165) { /* We're obviously dealing with WAVEFORMATEX */
int cbSize = avio_rl16(pb); /* cbSize */
if (big_endian) {
- avpriv_report_missing_feature(codec, "WAVEFORMATEX support for RIFX files");
+ avpriv_report_missing_feature(s, "WAVEFORMATEX support for RIFX files");
return AVERROR_PATCHWELCOME;
}
size -= 18;
cbSize = FFMIN(size, cbSize);
if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */
- parse_waveformatex(pb, codec);
+ parse_waveformatex(pb, par);
cbSize -= 22;
size -= 22;
}
if (cbSize > 0) {
- av_freep(&codec->extradata);
- if (ff_get_extradata(codec, pb, cbSize) < 0)
+ av_freep(&par->extradata);
+ if (ff_get_extradata(par, pb, cbSize) < 0)
return AVERROR(ENOMEM);
size -= cbSize;
}
@@ -155,35 +155,35 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
int nb_streams, i;
size -= 4;
- av_freep(&codec->extradata);
- if (ff_get_extradata(codec, pb, size) < 0)
+ av_freep(&par->extradata);
+ if (ff_get_extradata(par, pb, size) < 0)
return AVERROR(ENOMEM);
- nb_streams = AV_RL16(codec->extradata + 4);
- codec->sample_rate = AV_RL32(codec->extradata + 12);
- codec->channels = 0;
+ nb_streams = AV_RL16(par->extradata + 4);
+ par->sample_rate = AV_RL32(par->extradata + 12);
+ par->channels = 0;
bitrate = 0;
if (size < 8 + nb_streams * 20)
return AVERROR_INVALIDDATA;
for (i = 0; i < nb_streams; i++)
- codec->channels += codec->extradata[8 + i * 20 + 17];
+ par->channels += par->extradata[8 + i * 20 + 17];
}
- codec->bit_rate = bitrate;
+ par->bit_rate = bitrate;
- if (codec->sample_rate <= 0) {
+ if (par->sample_rate <= 0) {
av_log(s, AV_LOG_ERROR,
- "Invalid sample rate: %d\n", codec->sample_rate);
+ "Invalid sample rate: %d\n", par->sample_rate);
return AVERROR_INVALIDDATA;
}
- if (codec->codec_id == AV_CODEC_ID_AAC_LATM) {
+ if (par->codec_id == AV_CODEC_ID_AAC_LATM) {
/* Channels and sample_rate values are those prior to applying SBR
* and/or PS. */
- codec->channels = 0;
- codec->sample_rate = 0;
+ par->channels = 0;
+ par->sample_rate = 0;
}
/* override bits_per_coded_sample for G.726 */
- if (codec->codec_id == AV_CODEC_ID_ADPCM_G726 && codec->sample_rate)
- codec->bits_per_coded_sample = codec->bit_rate / codec->sample_rate;
+ if (par->codec_id == AV_CODEC_ID_ADPCM_G726 && par->sample_rate)
+ par->bits_per_coded_sample = par->bit_rate / par->sample_rate;
return 0;
}
@@ -210,11 +210,11 @@ int ff_get_bmp_header(AVIOContext *pb, AVStream *st, unsigned *esize)
int tag1;
if(esize) *esize = avio_rl32(pb);
else avio_rl32(pb);
- st->codec->width = avio_rl32(pb);
- st->codec->height = (int32_t)avio_rl32(pb);
+ st->codecpar->width = avio_rl32(pb);
+ st->codecpar->height = (int32_t)avio_rl32(pb);
avio_rl16(pb); /* planes */
- st->codec->bits_per_coded_sample = avio_rl16(pb); /* depth */
- tag1 = avio_rl32(pb);
+ st->codecpar->bits_per_coded_sample = avio_rl16(pb); /* depth */
+ tag1 = avio_rl32(pb);
avio_rl32(pb); /* ImageSize */
avio_rl32(pb); /* XPelsPerMeter */
avio_rl32(pb); /* YPelsPerMeter */
diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index 33879ea1ab..36e6ac7455 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -51,7 +51,8 @@ void ff_end_tag(AVIOContext *pb, int64_t start)
/* WAVEFORMATEX header */
/* returns the size or -1 on error */
-int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc, int flags)
+int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb,
+ AVCodecParameters *par, int flags)
{
int bps, blkalign, bytespersec, frame_size;
int hdrsize;
@@ -61,89 +62,89 @@ int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc, int flags)
uint8_t *riff_extradata = temp;
uint8_t *riff_extradata_start = temp;
- if (!enc->codec_tag || enc->codec_tag > 0xffff)
+ if (!par->codec_tag || par->codec_tag > 0xffff)
return -1;
/* We use the known constant frame size for the codec if known, otherwise
* fall back on using AVCodecContext.frame_size, which is not as reliable
* for indicating packet duration. */
- frame_size = av_get_audio_frame_duration(enc, enc->block_align);
+ frame_size = av_get_audio_frame_duration2(par, par->block_align);
- waveformatextensible = (enc->channels > 2 && enc->channel_layout) ||
- enc->sample_rate > 48000 ||
- enc->codec_id == AV_CODEC_ID_EAC3 ||
- av_get_bits_per_sample(enc->codec_id) > 16;
+ waveformatextensible = (par->channels > 2 && par->channel_layout) ||
+ par->sample_rate > 48000 ||
+ par->codec_id == AV_CODEC_ID_EAC3 ||
+ av_get_bits_per_sample(par->codec_id) > 16;
if (waveformatextensible)
avio_wl16(pb, 0xfffe);
else
- avio_wl16(pb, enc->codec_tag);
+ avio_wl16(pb, par->codec_tag);
- avio_wl16(pb, enc->channels);
- avio_wl32(pb, enc->sample_rate);
- if (enc->codec_id == AV_CODEC_ID_ATRAC3 ||
- enc->codec_id == AV_CODEC_ID_G723_1 ||
- enc->codec_id == AV_CODEC_ID_MP2 ||
- enc->codec_id == AV_CODEC_ID_MP3 ||
- enc->codec_id == AV_CODEC_ID_GSM_MS) {
+ avio_wl16(pb, par->channels);
+ avio_wl32(pb, par->sample_rate);
+ if (par->codec_id == AV_CODEC_ID_ATRAC3 ||
+ par->codec_id == AV_CODEC_ID_G723_1 ||
+ par->codec_id == AV_CODEC_ID_MP2 ||
+ par->codec_id == AV_CODEC_ID_MP3 ||
+ par->codec_id == AV_CODEC_ID_GSM_MS) {
bps = 0;
} else {
- if (!(bps = av_get_bits_per_sample(enc->codec_id))) {
- if (enc->bits_per_coded_sample)
- bps = enc->bits_per_coded_sample;
+ if (!(bps = av_get_bits_per_sample(par->codec_id))) {
+ if (par->bits_per_coded_sample)
+ bps = par->bits_per_coded_sample;
else
bps = 16; // default to 16
}
}
- if (bps != enc->bits_per_coded_sample && enc->bits_per_coded_sample) {
- av_log(enc, AV_LOG_WARNING,
+ if (bps != par->bits_per_coded_sample && par->bits_per_coded_sample) {
+ av_log(s, AV_LOG_WARNING,
"requested bits_per_coded_sample (%d) "
"and actually stored (%d) differ\n",
- enc->bits_per_coded_sample, bps);
+ par->bits_per_coded_sample, bps);
}
- if (enc->codec_id == AV_CODEC_ID_MP2) {
- blkalign = (144 * enc->bit_rate - 1)/enc->sample_rate + 1;
- } else if (enc->codec_id == AV_CODEC_ID_MP3) {
- blkalign = 576 * (enc->sample_rate <= (24000 + 32000)/2 ? 1 : 2);
- } else if (enc->codec_id == AV_CODEC_ID_AC3) {
+ if (par->codec_id == AV_CODEC_ID_MP2) {
+ blkalign = (144 * par->bit_rate - 1)/par->sample_rate + 1;
+ } else if (par->codec_id == AV_CODEC_ID_MP3) {
+ blkalign = 576 * (par->sample_rate <= (24000 + 32000)/2 ? 1 : 2);
+ } else if (par->codec_id == AV_CODEC_ID_AC3) {
blkalign = 3840; /* maximum bytes per frame */
- } else if (enc->codec_id == AV_CODEC_ID_AAC) {
- blkalign = 768 * enc->channels; /* maximum bytes per frame */
- } else if (enc->codec_id == AV_CODEC_ID_G723_1) {
+ } else if (par->codec_id == AV_CODEC_ID_AAC) {
+ blkalign = 768 * par->channels; /* maximum bytes per frame */
+ } else if (par->codec_id == AV_CODEC_ID_G723_1) {
blkalign = 24;
- } else if (enc->block_align != 0) { /* specified by the codec */
- blkalign = enc->block_align;
+ } else if (par->block_align != 0) { /* specified by the codec */
+ blkalign = par->block_align;
} else
- blkalign = bps * enc->channels / av_gcd(8, bps);
- if (enc->codec_id == AV_CODEC_ID_PCM_U8 ||
- enc->codec_id == AV_CODEC_ID_PCM_S24LE ||
- enc->codec_id == AV_CODEC_ID_PCM_S32LE ||
- enc->codec_id == AV_CODEC_ID_PCM_F32LE ||
- enc->codec_id == AV_CODEC_ID_PCM_F64LE ||
- enc->codec_id == AV_CODEC_ID_PCM_S16LE) {
- bytespersec = enc->sample_rate * blkalign;
- } else if (enc->codec_id == AV_CODEC_ID_G723_1) {
+ blkalign = bps * par->channels / av_gcd(8, bps);
+ if (par->codec_id == AV_CODEC_ID_PCM_U8 ||
+ par->codec_id == AV_CODEC_ID_PCM_S24LE ||
+ par->codec_id == AV_CODEC_ID_PCM_S32LE ||
+ par->codec_id == AV_CODEC_ID_PCM_F32LE ||
+ par->codec_id == AV_CODEC_ID_PCM_F64LE ||
+ par->codec_id == AV_CODEC_ID_PCM_S16LE) {
+ bytespersec = par->sample_rate * blkalign;
+ } else if (par->codec_id == AV_CODEC_ID_G723_1) {
bytespersec = 800;
} else {
- bytespersec = enc->bit_rate / 8;
+ bytespersec = par->bit_rate / 8;
}
avio_wl32(pb, bytespersec); /* bytes per second */
avio_wl16(pb, blkalign); /* block align */
avio_wl16(pb, bps); /* bits per sample */
- if (enc->codec_id == AV_CODEC_ID_MP3) {
+ if (par->codec_id == AV_CODEC_ID_MP3) {
bytestream_put_le16(&riff_extradata, 1); /* wID */
bytestream_put_le32(&riff_extradata, 2); /* fdwFlags */
bytestream_put_le16(&riff_extradata, 1152); /* nBlockSize */
bytestream_put_le16(&riff_extradata, 1); /* nFramesPerBlock */
bytestream_put_le16(&riff_extradata, 1393); /* nCodecDelay */
- } else if (enc->codec_id == AV_CODEC_ID_MP2) {
+ } else if (par->codec_id == AV_CODEC_ID_MP2) {
/* fwHeadLayer */
bytestream_put_le16(&riff_extradata, 2);
/* dwHeadBitrate */
- bytestream_put_le32(&riff_extradata, enc->bit_rate);
+ bytestream_put_le32(&riff_extradata, par->bit_rate);
/* fwHeadMode */
- bytestream_put_le16(&riff_extradata, enc->channels == 2 ? 1 : 8);
+ bytestream_put_le16(&riff_extradata, par->channels == 2 ? 1 : 8);
/* fwHeadModeExt */
bytestream_put_le16(&riff_extradata, 0);
/* wHeadEmphasis */
@@ -154,40 +155,40 @@ int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc, int flags)
bytestream_put_le32(&riff_extradata, 0);
/* dwPTSHigh */
bytestream_put_le32(&riff_extradata, 0);
- } else if (enc->codec_id == AV_CODEC_ID_G723_1) {
+ } else if (par->codec_id == AV_CODEC_ID_G723_1) {
bytestream_put_le32(&riff_extradata, 0x9ace0002); /* extradata needed for msacm g723.1 codec */
bytestream_put_le32(&riff_extradata, 0xaea2f732);
bytestream_put_le16(&riff_extradata, 0xacde);
- } else if (enc->codec_id == AV_CODEC_ID_GSM_MS ||
- enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {
+ } else if (par->codec_id == AV_CODEC_ID_GSM_MS ||
+ par->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {
/* wSamplesPerBlock */
bytestream_put_le16(&riff_extradata, frame_size);
- } else if (enc->extradata_size) {
- riff_extradata_start = enc->extradata;
- riff_extradata = enc->extradata + enc->extradata_size;
+ } else if (par->extradata_size) {
+ riff_extradata_start = par->extradata;
+ riff_extradata = par->extradata + par->extradata_size;
}
/* write WAVEFORMATEXTENSIBLE extensions */
if (waveformatextensible) {
int write_channel_mask = !(flags & FF_PUT_WAV_HEADER_SKIP_CHANNELMASK) &&
- (enc->strict_std_compliance < FF_COMPLIANCE_NORMAL ||
- enc->channel_layout < 0x40000);
+ (s->strict_std_compliance < FF_COMPLIANCE_NORMAL ||
+ par->channel_layout < 0x40000);
/* 22 is WAVEFORMATEXTENSIBLE size */
avio_wl16(pb, riff_extradata - riff_extradata_start + 22);
/* ValidBitsPerSample || SamplesPerBlock || Reserved */
avio_wl16(pb, bps);
/* dwChannelMask */
- avio_wl32(pb, write_channel_mask ? enc->channel_layout : 0);
+ avio_wl32(pb, write_channel_mask ? par->channel_layout : 0);
/* GUID + next 3 */
- if (enc->codec_id == AV_CODEC_ID_EAC3) {
- ff_put_guid(pb, ff_get_codec_guid(enc->codec_id, ff_codec_wav_guids));
+ if (par->codec_id == AV_CODEC_ID_EAC3) {
+ ff_put_guid(pb, ff_get_codec_guid(par->codec_id, ff_codec_wav_guids));
} else {
- avio_wl32(pb, enc->codec_tag);
+ avio_wl32(pb, par->codec_tag);
avio_wl32(pb, 0x00100000);
avio_wl32(pb, 0xAA000080);
avio_wl32(pb, 0x719B3800);
}
} else if ((flags & FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX) ||
- enc->codec_tag != 0x0001 /* PCM */ ||
+ par->codec_tag != 0x0001 /* PCM */ ||
riff_extradata - riff_extradata_start) {
/* WAVEFORMATEX */
avio_wl16(pb, riff_extradata - riff_extradata_start); /* cbSize */
@@ -203,16 +204,16 @@ int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc, int flags)
}
/* BITMAPINFOHEADER header */
-void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc,
+void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par,
const AVCodecTag *tags, int for_asf, int ignore_extradata)
{
- int keep_height = enc->extradata_size >= 9 &&
- !memcmp(enc->extradata + enc->extradata_size - 9, "BottomUp", 9);
- int extradata_size = enc->extradata_size - 9*keep_height;
- enum AVPixelFormat pix_fmt = enc->pix_fmt;
+ int keep_height = par->extradata_size >= 9 &&
+ !memcmp(par->extradata + par->extradata_size - 9, "BottomUp", 9);
+ int extradata_size = par->extradata_size - 9*keep_height;
+ enum AVPixelFormat pix_fmt = par->format;
int pal_avi;
- if (pix_fmt == AV_PIX_FMT_NONE && enc->bits_per_coded_sample == 1)
+ if (pix_fmt == AV_PIX_FMT_NONE && par->bits_per_coded_sample == 1)
pix_fmt = AV_PIX_FMT_MONOWHITE;
pal_avi = !for_asf &&
(pix_fmt == AV_PIX_FMT_PAL8 ||
@@ -221,32 +222,32 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc,
/* Size (not including the size of the color table or color masks) */
avio_wl32(pb, 40 + (ignore_extradata || pal_avi ? 0 : extradata_size));
- avio_wl32(pb, enc->width);
+ avio_wl32(pb, par->width);
//We always store RGB TopDown
- avio_wl32(pb, enc->codec_tag || keep_height ? enc->height : -enc->height);
+ avio_wl32(pb, par->codec_tag || keep_height ? par->height : -par->height);
/* planes */
avio_wl16(pb, 1);
/* depth */
- avio_wl16(pb, enc->bits_per_coded_sample ? enc->bits_per_coded_sample : 24);
+ avio_wl16(pb, par->bits_per_coded_sample ? par->bits_per_coded_sample : 24);
/* compression type */
- avio_wl32(pb, enc->codec_tag);
- avio_wl32(pb, (enc->width * enc->height * (enc->bits_per_coded_sample ? enc->bits_per_coded_sample : 24)+7) / 8);
+ avio_wl32(pb, par->codec_tag);
+ avio_wl32(pb, (par->width * par->height * (par->bits_per_coded_sample ? par->bits_per_coded_sample : 24)+7) / 8);
avio_wl32(pb, 0);
avio_wl32(pb, 0);
/* Number of color indices in the color table that are used.
* A value of 0 means 2^biBitCount indices, but this doesn't work
* with Windows Media Player and files containing xxpc chunks. */
- avio_wl32(pb, pal_avi ? 1 << enc->bits_per_coded_sample : 0);
+ avio_wl32(pb, pal_avi ? 1 << par->bits_per_coded_sample : 0);
avio_wl32(pb, 0);
if (!ignore_extradata) {
- if (enc->extradata_size) {
- avio_write(pb, enc->extradata, extradata_size);
+ if (par->extradata_size) {
+ avio_write(pb, par->extradata, extradata_size);
if (!for_asf && extradata_size & 1)
avio_w8(pb, 0);
} else if (pal_avi) {
int i;
- for (i = 0; i < 1 << enc->bits_per_coded_sample; i++) {
+ for (i = 0; i < 1 << par->bits_per_coded_sample; i++) {
/* Initialize 1 bpp palette to black & white */
if (i == 0 && pix_fmt == AV_PIX_FMT_MONOWHITE)
avio_wl32(pb, 0xffffff);
@@ -262,30 +263,27 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc,
void ff_parse_specific_params(AVStream *st, int *au_rate,
int *au_ssize, int *au_scale)
{
- AVCodecContext *codec = st->codec;
+ AVCodecParameters *par = st->codecpar;
int gcd;
int audio_frame_size;
- /* We use the known constant frame size for the codec if known, otherwise
- * fall back on using AVCodecContext.frame_size, which is not as reliable
- * for indicating packet duration. */
- audio_frame_size = av_get_audio_frame_duration(codec, 0);
+ audio_frame_size = av_get_audio_frame_duration2(par, 0);
if (!audio_frame_size)
- audio_frame_size = codec->frame_size;
+ audio_frame_size = par->frame_size;
- *au_ssize = codec->block_align;
- if (audio_frame_size && codec->sample_rate) {
+ *au_ssize = par->block_align;
+ if (audio_frame_size && par->sample_rate) {
*au_scale = audio_frame_size;
- *au_rate = codec->sample_rate;
- } else if (codec->codec_type == AVMEDIA_TYPE_VIDEO ||
- codec->codec_type == AVMEDIA_TYPE_DATA ||
- codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ *au_rate = par->sample_rate;
+ } else if (par->codec_type == AVMEDIA_TYPE_VIDEO ||
+ par->codec_type == AVMEDIA_TYPE_DATA ||
+ par->codec_type == AVMEDIA_TYPE_SUBTITLE) {
*au_scale = st->time_base.num;
*au_rate = st->time_base.den;
} else {
- *au_scale = codec->block_align ? codec->block_align * 8 : 8;
- *au_rate = codec->bit_rate ? codec->bit_rate :
- 8 * codec->sample_rate;
+ *au_scale = par->block_align ? par->block_align * 8 : 8;
+ *au_rate = par->bit_rate ? par->bit_rate :
+ 8 * par->sample_rate;
}
gcd = av_gcd(*au_scale, *au_rate);
*au_scale /= gcd;
diff --git a/libavformat/rl2.c b/libavformat/rl2.c
index 5017016644..077da4cb0e 100644
--- a/libavformat/rl2.c
+++ b/libavformat/rl2.c
@@ -115,19 +115,19 @@ static av_cold int rl2_read_header(AVFormatContext *s)
if(!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_RL2;
- st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = 320;
- st->codec->height = 200;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_RL2;
+ st->codecpar->codec_tag = 0; /* no fourcc */
+ st->codecpar->width = 320;
+ st->codecpar->height = 200;
/** allocate and fill extradata */
- st->codec->extradata_size = EXTRADATA1_SIZE;
+ st->codecpar->extradata_size = EXTRADATA1_SIZE;
if(signature == RLV3_TAG && back_size > 0)
- st->codec->extradata_size += back_size;
+ st->codecpar->extradata_size += back_size;
- if(ff_get_extradata(st->codec, pb, st->codec->extradata_size) < 0)
+ if(ff_get_extradata(st->codecpar, pb, st->codecpar->extradata_size) < 0)
return AVERROR(ENOMEM);
/** setup audio stream if present */
@@ -143,16 +143,16 @@ static av_cold int rl2_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_id = AV_CODEC_ID_PCM_U8;
- st->codec->codec_tag = 1;
- st->codec->channels = channels;
- st->codec->bits_per_coded_sample = 8;
- st->codec->sample_rate = rate;
- 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 / 8;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
+ st->codecpar->codec_tag = 1;
+ st->codecpar->channels = channels;
+ st->codecpar->bits_per_coded_sample = 8;
+ st->codecpar->sample_rate = rate;
+ 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 / 8;
avpriv_set_pts_info(st,32,1,rate);
}
diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index 1a61b10d44..2500852767 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -87,13 +87,13 @@ static void get_str8(AVIOContext *pb, char *buf, int buf_size)
get_strl(pb, buf, buf_size, avio_r8(pb));
}
-static int rm_read_extradata(AVIOContext *pb, AVCodecContext *avctx, unsigned size)
+static int rm_read_extradata(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, unsigned size)
{
if (size >= 1<<24) {
- av_log(avctx, AV_LOG_ERROR, "extradata size %u too large\n", size);
+ av_log(s, AV_LOG_ERROR, "extradata size %u too large\n", size);
return -1;
}
- if (ff_get_extradata(avctx, pb, size) < 0)
+ if (ff_get_extradata(par, pb, size) < 0)
return AVERROR(ENOMEM);
return 0;
}
@@ -150,12 +150,12 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
if ((startpos + header_size) > avio_tell(pb))
avio_skip(pb, header_size + startpos - avio_tell(pb));
if (bytes_per_minute)
- st->codec->bit_rate = 8LL * bytes_per_minute / 60;
- st->codec->sample_rate = 8000;
- st->codec->channels = 1;
- st->codec->channel_layout = AV_CH_LAYOUT_MONO;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_RA_144;
+ st->codecpar->bit_rate = 8LL * bytes_per_minute / 60;
+ st->codecpar->sample_rate = 8000;
+ st->codecpar->channels = 1;
+ st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_RA_144;
ast->deint_id = DEINT_ID_INT0;
} else {
int flavor, sub_packet_h, coded_framesize, sub_packet_size;
@@ -173,19 +173,19 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
bytes_per_minute = avio_rb32(pb);
if (version == 4) {
if (bytes_per_minute)
- st->codec->bit_rate = 8LL * bytes_per_minute / 60;
+ st->codecpar->bit_rate = 8LL * bytes_per_minute / 60;
}
avio_rb32(pb); /* ??? */
ast->sub_packet_h = sub_packet_h = avio_rb16(pb); /* 1 */
- st->codec->block_align= avio_rb16(pb); /* frame size */
+ st->codecpar->block_align= avio_rb16(pb); /* frame size */
ast->sub_packet_size = sub_packet_size = avio_rb16(pb); /* sub packet size */
avio_rb16(pb); /* ??? */
if (version == 5) {
avio_rb16(pb); avio_rb16(pb); avio_rb16(pb);
}
- st->codec->sample_rate = avio_rb16(pb);
+ st->codecpar->sample_rate = avio_rb16(pb);
avio_rb32(pb);
- st->codec->channels = avio_rb16(pb);
+ st->codecpar->channels = avio_rb16(pb);
if (version == 5) {
ast->deint_id = avio_rl32(pb);
avio_read(pb, buf, 4);
@@ -196,19 +196,19 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
ast->deint_id = AV_RL32(buf);
get_str8(pb, buf, sizeof(buf)); /* desc */
}
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_tag = AV_RL32(buf);
- st->codec->codec_id = ff_codec_get_id(ff_rm_codec_tags,
- st->codec->codec_tag);
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_tag = AV_RL32(buf);
+ st->codecpar->codec_id = ff_codec_get_id(ff_rm_codec_tags,
+ st->codecpar->codec_tag);
- switch (st->codec->codec_id) {
+ switch (st->codecpar->codec_id) {
case AV_CODEC_ID_AC3:
st->need_parsing = AVSTREAM_PARSE_FULL;
break;
case AV_CODEC_ID_RA_288:
- st->codec->extradata_size= 0;
- ast->audio_framesize = st->codec->block_align;
- st->codec->block_align = coded_framesize;
+ st->codecpar->extradata_size= 0;
+ ast->audio_framesize = st->codecpar->block_align;
+ st->codecpar->block_align = coded_framesize;
break;
case AV_CODEC_ID_COOK:
st->need_parsing = AVSTREAM_PARSE_HEADERS;
@@ -227,22 +227,22 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
}
}
- ast->audio_framesize = st->codec->block_align;
- if (st->codec->codec_id == AV_CODEC_ID_SIPR) {
+ ast->audio_framesize = st->codecpar->block_align;
+ if (st->codecpar->codec_id == AV_CODEC_ID_SIPR) {
if (flavor > 3) {
av_log(s, AV_LOG_ERROR, "bad SIPR file flavor %d\n",
flavor);
return -1;
}
- st->codec->block_align = ff_sipr_subpk_size[flavor];
+ st->codecpar->block_align = ff_sipr_subpk_size[flavor];
} else {
if(sub_packet_size <= 0){
av_log(s, AV_LOG_ERROR, "sub_packet_size is invalid\n");
return -1;
}
- st->codec->block_align = ast->sub_packet_size;
+ st->codecpar->block_align = ast->sub_packet_size;
}
- if ((ret = rm_read_extradata(pb, st->codec, codecdata_length)) < 0)
+ if ((ret = rm_read_extradata(s, pb, st->codecpar, codecdata_length)) < 0)
return ret;
break;
@@ -257,7 +257,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
}
if (codecdata_length >= 1) {
avio_r8(pb);
- if ((ret = rm_read_extradata(pb, st->codec, codecdata_length - 1)) < 0)
+ if ((ret = rm_read_extradata(s, pb, st->codecpar, codecdata_length - 1)) < 0)
return ret;
}
break;
@@ -292,9 +292,9 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
if (ast->deint_id == DEINT_ID_INT4 ||
ast->deint_id == DEINT_ID_GENR ||
ast->deint_id == DEINT_ID_SIPR) {
- if (st->codec->block_align <= 0 ||
+ if (st->codecpar->block_align <= 0 ||
ast->audio_framesize * sub_packet_h > (unsigned)INT_MAX ||
- ast->audio_framesize * sub_packet_h < st->codec->block_align)
+ ast->audio_framesize * sub_packet_h < st->codecpar->block_align)
return AVERROR_INVALIDDATA;
if (av_new_packet(&ast->pkt, ast->audio_framesize * sub_packet_h) < 0)
return AVERROR(ENOMEM);
@@ -334,13 +334,13 @@ int ff_rm_read_mdpr_codecdata(AVFormatContext *s, AVIOContext *pb,
return -1;
} else if (v == MKBETAG('L', 'S', 'D', ':')) {
avio_seek(pb, -4, SEEK_CUR);
- if ((ret = rm_read_extradata(pb, st->codec, codec_data_size)) < 0)
+ if ((ret = rm_read_extradata(s, pb, st->codecpar, codec_data_size)) < 0)
return ret;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_tag = AV_RL32(st->codec->extradata);
- st->codec->codec_id = ff_codec_get_id(ff_rm_codec_tags,
- st->codec->codec_tag);
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_tag = AV_RL32(st->codecpar->extradata);
+ st->codecpar->codec_id = ff_codec_get_id(ff_rm_codec_tags,
+ st->codecpar->codec_tag);
} else if(mime && !strcmp(mime, "logical-fileinfo")){
int stream_count, rule_count, property_count, i;
ff_free_stream(s, st);
@@ -375,21 +375,21 @@ int ff_rm_read_mdpr_codecdata(AVFormatContext *s, AVIOContext *pb,
av_log(s, AV_LOG_WARNING, "Unsupported stream type %08x\n", v);
goto skip;
}
- st->codec->codec_tag = avio_rl32(pb);
- st->codec->codec_id = ff_codec_get_id(ff_rm_codec_tags,
- st->codec->codec_tag);
- av_log(s, AV_LOG_TRACE, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0'));
- if (st->codec->codec_id == AV_CODEC_ID_NONE)
+ st->codecpar->codec_tag = avio_rl32(pb);
+ st->codecpar->codec_id = ff_codec_get_id(ff_rm_codec_tags,
+ st->codecpar->codec_tag);
+ av_log(s, AV_LOG_TRACE, "%X %X\n", st->codecpar->codec_tag, MKTAG('R', 'V', '2', '0'));
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE)
goto fail1;
- st->codec->width = avio_rb16(pb);
- st->codec->height = avio_rb16(pb);
+ st->codecpar->width = avio_rb16(pb);
+ st->codecpar->height = avio_rb16(pb);
avio_skip(pb, 2); // looks like bits per sample
avio_skip(pb, 4); // always zero?
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
fps = avio_rb32(pb);
- if ((ret = rm_read_extradata(pb, st->codec, codec_data_size - (avio_tell(pb) - codec_pos))) < 0)
+ if ((ret = rm_read_extradata(s, pb, st->codecpar, codec_data_size - (avio_tell(pb) - codec_pos))) < 0)
return ret;
if (fps > 0) {
@@ -511,10 +511,10 @@ static int rm_read_multi(AVFormatContext *s, AVIOContext *pb,
return ret;
}
st2->id = st->id + (i<<16);
- st2->codec->bit_rate = st->codec->bit_rate;
+ st2->codecpar->bit_rate = st->codecpar->bit_rate;
st2->start_time = st->start_time;
st2->duration = st->duration;
- st2->codec->codec_type = AVMEDIA_TYPE_DATA;
+ st2->codecpar->codec_type = AVMEDIA_TYPE_DATA;
st2->priv_data = ff_rm_alloc_rmstream();
if (!st2->priv_data)
return AVERROR(ENOMEM);
@@ -598,7 +598,7 @@ static int rm_read_header(AVFormatContext *s)
}
st->id = avio_rb16(pb);
avio_rb32(pb); /* max bit rate */
- st->codec->bit_rate = avio_rb32(pb); /* bit rate */
+ st->codecpar->bit_rate = avio_rb32(pb); /* bit rate */
avio_rb32(pb); /* max packet size */
avio_rb32(pb); /* avg packet size */
start_time = avio_rb32(pb); /* start time */
@@ -610,7 +610,7 @@ static int rm_read_header(AVFormatContext *s)
s->duration = AV_NOPTS_VALUE;
get_str8(pb, buf, sizeof(buf)); /* desc */
get_str8(pb, mime, sizeof(mime)); /* mimetype */
- st->codec->codec_type = AVMEDIA_TYPE_DATA;
+ st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
st->priv_data = ff_rm_alloc_rmstream();
if (!st->priv_data)
return AVERROR(ENOMEM);
@@ -864,7 +864,7 @@ rm_ac3_swap_bytes (AVStream *st, AVPacket *pkt)
uint8_t *ptr;
int j;
- if (st->codec->codec_id == AV_CODEC_ID_AC3) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_AC3) {
ptr = pkt->data;
for (j=0;j<pkt->size;j+=2) {
FFSWAP(int, ptr[0], ptr[1]);
@@ -891,12 +891,12 @@ ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb,
RMDemuxContext *rm = s->priv_data;
int ret;
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
rm->current_stream= st->id;
ret = rm_assemble_video_frame(s, pb, rm, ast, pkt, len, seq, &timestamp);
if(ret)
return ret < 0 ? ret : -1; //got partial frame or error
- } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
if ((ast->deint_id == DEINT_ID_GENR) ||
(ast->deint_id == DEINT_ID_INT4) ||
(ast->deint_id == DEINT_ID_SIPR)) {
@@ -933,7 +933,7 @@ ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb,
ast->sub_packet_cnt = 0;
rm->audio_stream_num = st->index;
- rm->audio_pkt_cnt = h * w / st->codec->block_align;
+ rm->audio_pkt_cnt = h * w / st->codecpar->block_align;
} else if ((ast->deint_id == DEINT_ID_VBRF) ||
(ast->deint_id == DEINT_ID_VBRS)) {
int x;
@@ -959,8 +959,8 @@ ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb,
pkt->stream_index = st->index;
#if 0
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- if(st->codec->codec_id == AV_CODEC_ID_RV20){
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if(st->codecpar->codec_id == AV_CODEC_ID_RV20){
int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1);
av_log(s, AV_LOG_DEBUG, "%d %"PRId64" %d\n", *timestamp, *timestamp*512LL/25, seq);
@@ -975,7 +975,7 @@ ff_rm_parse_packet (AVFormatContext *s, AVIOContext *pb,
if (flags & 2)
pkt->flags |= AV_PKT_FLAG_KEY;
- return st->codec->codec_type == AVMEDIA_TYPE_AUDIO ? rm->audio_pkt_cnt : 0;
+ return st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO ? rm->audio_pkt_cnt : 0;
}
int
@@ -992,12 +992,12 @@ ff_rm_retrieve_cache (AVFormatContext *s, AVIOContext *pb,
if (ret < 0)
return ret;
} else {
- int ret = av_new_packet(pkt, st->codec->block_align);
+ int ret = av_new_packet(pkt, st->codecpar->block_align);
if (ret < 0)
return ret;
- memcpy(pkt->data, ast->pkt.data + st->codec->block_align * //FIXME avoid this
- (ast->sub_packet_h * ast->audio_framesize / st->codec->block_align - rm->audio_pkt_cnt),
- st->codec->block_align);
+ memcpy(pkt->data, ast->pkt.data + st->codecpar->block_align * //FIXME avoid this
+ (ast->sub_packet_h * ast->audio_framesize / st->codecpar->block_align - rm->audio_pkt_cnt),
+ st->codecpar->block_align);
}
rm->audio_pkt_cnt--;
if ((pkt->pts = ast->audiotimestamp) != AV_NOPTS_VALUE) {
@@ -1114,7 +1114,7 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index,
return AV_NOPTS_VALUE;
st = s->streams[stream_index2];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
h= avio_r8(s->pb); len--;
if(!(h & 0x40)){
seq = avio_r8(s->pb); len--;
diff --git a/libavformat/rmenc.c b/libavformat/rmenc.c
index 33eaf6360d..a0cda92da1 100644
--- a/libavformat/rmenc.c
+++ b/libavformat/rmenc.c
@@ -33,7 +33,7 @@ typedef struct StreamInfo {
int nb_frames; /* current frame number */
int total_frames; /* total number of frames */
int num;
- AVCodecContext *enc;
+ AVCodecParameters *par;
} StreamInfo;
typedef struct RMMuxContext {
@@ -147,7 +147,7 @@ static int rv10_write_header(AVFormatContext *ctx,
stream = &rm->streams[i];
- if (stream->enc->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (stream->par->codec_type == AVMEDIA_TYPE_AUDIO) {
desc = "The Audio Stream";
mimetype = "audio/x-pn-realaudio";
codec_data_size = 73;
@@ -183,11 +183,11 @@ static int rv10_write_header(AVFormatContext *ctx,
put_str8(s, mimetype);
avio_wb32(s, codec_data_size);
- if (stream->enc->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (stream->par->codec_type == AVMEDIA_TYPE_AUDIO) {
int coded_frame_size, fscode, sample_rate;
- int frame_size = av_get_audio_frame_duration(stream->enc, 0);
- sample_rate = stream->enc->sample_rate;
- coded_frame_size = (stream->enc->bit_rate *
+ int frame_size = av_get_audio_frame_duration2(stream->par, 0);
+ sample_rate = stream->par->sample_rate;
+ coded_frame_size = (stream->par->bit_rate *
frame_size) / (8 * sample_rate);
/* audio codec info */
avio_write(s, ".ra", 3);
@@ -222,19 +222,19 @@ static int rv10_write_header(AVFormatContext *ctx,
coded_frame_size--;
avio_wb32(s, coded_frame_size); /* frame length */
avio_wb32(s, 0x51540); /* unknown */
- avio_wb32(s, stream->enc->bit_rate / 8 * 60); /* bytes per minute */
- avio_wb32(s, stream->enc->bit_rate / 8 * 60); /* bytes per minute */
+ avio_wb32(s, stream->par->bit_rate / 8 * 60); /* bytes per minute */
+ avio_wb32(s, stream->par->bit_rate / 8 * 60); /* bytes per minute */
avio_wb16(s, 0x01);
/* frame length : seems to be very important */
avio_wb16(s, coded_frame_size);
avio_wb32(s, 0); /* unknown */
- avio_wb16(s, stream->enc->sample_rate); /* sample rate */
+ avio_wb16(s, stream->par->sample_rate); /* sample rate */
avio_wb32(s, 0x10); /* unknown */
- avio_wb16(s, stream->enc->channels);
+ avio_wb16(s, stream->par->channels);
put_str8(s, "Int0"); /* codec name */
- if (stream->enc->codec_tag) {
+ if (stream->par->codec_tag) {
avio_w8(s, 4); /* tag length */
- avio_wl32(s, stream->enc->codec_tag);
+ avio_wl32(s, stream->par->codec_tag);
} else {
av_log(ctx, AV_LOG_ERROR, "Invalid codec tag\n");
return -1;
@@ -247,12 +247,12 @@ static int rv10_write_header(AVFormatContext *ctx,
/* video codec info */
avio_wb32(s,34); /* size */
ffio_wfourcc(s, "VIDO");
- if(stream->enc->codec_id == AV_CODEC_ID_RV10)
+ if(stream->par->codec_id == AV_CODEC_ID_RV10)
ffio_wfourcc(s,"RV10");
else
ffio_wfourcc(s,"RV20");
- avio_wb16(s, stream->enc->width);
- avio_wb16(s, stream->enc->height);
+ avio_wb16(s, stream->par->width);
+ avio_wb16(s, stream->par->height);
avio_wb16(s, stream->frame_rate.num / stream->frame_rate.den); /* frames per seconds ? */
avio_wb32(s,0); /* unknown meaning */
avio_wb16(s, stream->frame_rate.num / stream->frame_rate.den); /* unknown meaning */
@@ -261,7 +261,7 @@ static int rv10_write_header(AVFormatContext *ctx,
/* Seems to be the codec version: only use basic H263. The next
versions seems to add a diffential DC coding as in
MPEG... nothing new under the sun */
- if(stream->enc->codec_id == AV_CODEC_ID_RV10)
+ if(stream->par->codec_id == AV_CODEC_ID_RV10)
avio_wb32(s,0x10000000);
else
avio_wb32(s,0x20103001);
@@ -312,7 +312,7 @@ static int rm_write_header(AVFormatContext *s)
RMMuxContext *rm = s->priv_data;
StreamInfo *stream;
int n;
- AVCodecContext *codec;
+ AVCodecParameters *par;
if (s->nb_streams > 2) {
av_log(s, AV_LOG_ERROR, "At most 2 streams are currently supported for muxing in RM\n");
@@ -324,18 +324,18 @@ static int rm_write_header(AVFormatContext *s)
int frame_size;
s->streams[n]->id = n;
- codec = s->streams[n]->codec;
+ par = s->streams[n]->codecpar;
stream = &rm->streams[n];
memset(stream, 0, sizeof(StreamInfo));
stream->num = n;
- stream->bit_rate = codec->bit_rate;
- stream->enc = codec;
+ stream->bit_rate = par->bit_rate;
+ stream->par = par;
- switch(codec->codec_type) {
+ switch (par->codec_type) {
case AVMEDIA_TYPE_AUDIO:
rm->audio_stream = stream;
- frame_size = av_get_audio_frame_duration(codec, 0);
- stream->frame_rate = (AVRational){codec->sample_rate, frame_size};
+ frame_size = av_get_audio_frame_duration2(par, 0);
+ stream->frame_rate = (AVRational){par->sample_rate, frame_size};
/* XXX: dummy values */
stream->packet_max_size = 1024;
stream->nb_packets = 0;
@@ -370,7 +370,7 @@ static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int
write_packet_header(s, stream, size, !!(flags & AV_PKT_FLAG_KEY));
- if (stream->enc->codec_id == AV_CODEC_ID_AC3) {
+ if (stream->par->codec_id == AV_CODEC_ID_AC3) {
/* for AC-3, the words seem to be reversed */
for (i = 0; i < size; i += 2) {
avio_w8(pb, buf[i + 1]);
@@ -433,7 +433,7 @@ static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size, int
static int rm_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- if (s->streams[pkt->stream_index]->codec->codec_type ==
+ if (s->streams[pkt->stream_index]->codecpar->codec_type ==
AVMEDIA_TYPE_AUDIO)
return rm_write_audio(s, pkt->data, pkt->size, pkt->flags);
else
diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index 76c385bd32..a794d3b485 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -145,34 +145,34 @@ static int rpl_read_header(AVFormatContext *s)
vst = avformat_new_stream(s, NULL);
if (!vst)
return AVERROR(ENOMEM);
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_tag = read_line_and_int(pb, &error); // video format
- vst->codec->width = read_line_and_int(pb, &error); // video width
- vst->codec->height = read_line_and_int(pb, &error); // video height
- vst->codec->bits_per_coded_sample = read_line_and_int(pb, &error); // video bits per sample
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_tag = read_line_and_int(pb, &error); // video format
+ vst->codecpar->width = read_line_and_int(pb, &error); // video width
+ vst->codecpar->height = read_line_and_int(pb, &error); // video height
+ vst->codecpar->bits_per_coded_sample = read_line_and_int(pb, &error); // video bits per sample
error |= read_line(pb, line, sizeof(line)); // video frames per second
fps = read_fps(line, &error);
avpriv_set_pts_info(vst, 32, fps.den, fps.num);
// Figure out the video codec
- switch (vst->codec->codec_tag) {
+ switch (vst->codecpar->codec_tag) {
#if 0
case 122:
- vst->codec->codec_id = AV_CODEC_ID_ESCAPE122;
+ vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE122;
break;
#endif
case 124:
- vst->codec->codec_id = AV_CODEC_ID_ESCAPE124;
+ vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE124;
// The header is wrong here, at least sometimes
- vst->codec->bits_per_coded_sample = 16;
+ vst->codecpar->bits_per_coded_sample = 16;
break;
case 130:
- vst->codec->codec_id = AV_CODEC_ID_ESCAPE130;
+ vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE130;
break;
default:
avpriv_report_missing_feature(s, "Video format %i",
- vst->codec->codec_tag);
- vst->codec->codec_id = AV_CODEC_ID_NONE;
+ vst->codecpar->codec_tag);
+ vst->codecpar->codec_id = AV_CODEC_ID_NONE;
}
// Audio headers
@@ -184,57 +184,57 @@ static int rpl_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 = audio_format;
- ast->codec->sample_rate = read_line_and_int(pb, &error); // audio bitrate
- ast->codec->channels = read_line_and_int(pb, &error); // number of audio channels
- ast->codec->bits_per_coded_sample = read_line_and_int(pb, &error); // audio bits per sample
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codecpar->codec_tag = audio_format;
+ ast->codecpar->sample_rate = read_line_and_int(pb, &error); // audio bitrate
+ ast->codecpar->channels = read_line_and_int(pb, &error); // number of audio channels
+ ast->codecpar->bits_per_coded_sample = read_line_and_int(pb, &error); // audio bits per sample
// At least one sample uses 0 for ADPCM, which is really 4 bits
// per sample.
- if (ast->codec->bits_per_coded_sample == 0)
- ast->codec->bits_per_coded_sample = 4;
+ if (ast->codecpar->bits_per_coded_sample == 0)
+ ast->codecpar->bits_per_coded_sample = 4;
- ast->codec->bit_rate = ast->codec->sample_rate *
- ast->codec->bits_per_coded_sample *
- ast->codec->channels;
+ ast->codecpar->bit_rate = ast->codecpar->sample_rate *
+ ast->codecpar->bits_per_coded_sample *
+ ast->codecpar->channels;
- ast->codec->codec_id = AV_CODEC_ID_NONE;
+ ast->codecpar->codec_id = AV_CODEC_ID_NONE;
switch (audio_format) {
case 1:
- if (ast->codec->bits_per_coded_sample == 16) {
+ if (ast->codecpar->bits_per_coded_sample == 16) {
// 16-bit audio is always signed
- ast->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
+ ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
break;
}
// There are some other formats listed as legal per the spec;
// samples needed.
break;
case 101:
- if (ast->codec->bits_per_coded_sample == 8) {
+ if (ast->codecpar->bits_per_coded_sample == 8) {
// The samples with this kind of audio that I have
// are all unsigned.
- ast->codec->codec_id = AV_CODEC_ID_PCM_U8;
+ ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
break;
- } else if (ast->codec->bits_per_coded_sample == 4) {
- ast->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_EA_SEAD;
+ } else if (ast->codecpar->bits_per_coded_sample == 4) {
+ ast->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_EA_SEAD;
break;
}
break;
}
- if (ast->codec->codec_id == AV_CODEC_ID_NONE)
+ if (ast->codecpar->codec_id == AV_CODEC_ID_NONE)
avpriv_request_sample(s, "Audio format %"PRId32,
audio_format);
- avpriv_set_pts_info(ast, 32, 1, ast->codec->bit_rate);
+ avpriv_set_pts_info(ast, 32, 1, ast->codecpar->bit_rate);
} else {
for (i = 0; i < 3; i++)
error |= read_line(pb, line, sizeof(line));
}
rpl->frames_per_chunk = read_line_and_int(pb, &error); // video frames per chunk
- if (rpl->frames_per_chunk > 1 && vst->codec->codec_tag != 124)
+ if (rpl->frames_per_chunk > 1 && vst->codecpar->codec_tag != 124)
av_log(s, AV_LOG_WARNING,
"Don't know how to split frames for video format %i. "
- "Video stream will be broken!\n", vst->codec->codec_tag);
+ "Video stream will be broken!\n", vst->codecpar->codec_tag);
number_of_chunks = read_line_and_int(pb, &error); // number of chunks in the file
// The number in the header is actually the index of the last chunk.
@@ -296,8 +296,8 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
if (avio_seek(pb, index_entry->pos, SEEK_SET) < 0)
return AVERROR(EIO);
- if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
- stream->codec->codec_tag == 124) {
+ if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
+ stream->codecpar->codec_tag == 124) {
// We have to split Escape 124 frames because there are
// multiple frames per chunk in Escape 124 samples.
uint32_t frame_size;
@@ -332,7 +332,7 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(EIO);
}
- if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
// frames_per_chunk should always be one here; the header
// parsing will warn if it isn't.
pkt->duration = rpl->frames_per_chunk;
diff --git a/libavformat/rsd.c b/libavformat/rsd.c
index dd1f3723d0..e02d767a01 100644
--- a/libavformat/rsd.c
+++ b/libavformat/rsd.c
@@ -56,7 +56,7 @@ static int rsd_read_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
int i, ret, version, start = 0x800;
- AVCodecContext *codec;
+ AVCodecParameters *par;
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
@@ -65,16 +65,16 @@ static int rsd_read_header(AVFormatContext *s)
avio_skip(pb, 3); // "RSD"
version = avio_r8(pb) - '0';
- codec = st->codec;
- codec->codec_type = AVMEDIA_TYPE_AUDIO;
- codec->codec_tag = avio_rl32(pb);
- codec->codec_id = ff_codec_get_id(rsd_tags, codec->codec_tag);
- if (!codec->codec_id) {
+ par = st->codecpar;
+ par->codec_type = AVMEDIA_TYPE_AUDIO;
+ par->codec_tag = avio_rl32(pb);
+ par->codec_id = ff_codec_get_id(rsd_tags, par->codec_tag);
+ if (!par->codec_id) {
char tag_buf[32];
- av_get_codec_tag_string(tag_buf, sizeof(tag_buf), codec->codec_tag);
+ av_get_codec_tag_string(tag_buf, sizeof(tag_buf), par->codec_tag);
for (i=0; i < FF_ARRAY_ELEMS(rsd_unsupported_tags); i++) {
- if (codec->codec_tag == rsd_unsupported_tags[i]) {
+ if (par->codec_tag == rsd_unsupported_tags[i]) {
avpriv_request_sample(s, "Codec tag: %s", tag_buf);
return AVERROR_PATCHWELCOME;
}
@@ -83,43 +83,43 @@ static int rsd_read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
- codec->channels = avio_rl32(pb);
- if (!codec->channels)
+ par->channels = avio_rl32(pb);
+ if (!par->channels)
return AVERROR_INVALIDDATA;
avio_skip(pb, 4); // Bit depth
- codec->sample_rate = avio_rl32(pb);
- if (!codec->sample_rate)
+ par->sample_rate = avio_rl32(pb);
+ if (!par->sample_rate)
return AVERROR_INVALIDDATA;
avio_skip(pb, 4); // Unknown
- switch (codec->codec_id) {
+ switch (par->codec_id) {
case AV_CODEC_ID_XMA2:
- codec->block_align = 2048;
- ff_alloc_extradata(codec, 34);
- if (!codec->extradata)
+ par->block_align = 2048;
+ ff_alloc_extradata(par, 34);
+ if (!par->extradata)
return AVERROR(ENOMEM);
- memset(codec->extradata, 0, 34);
+ memset(par->extradata, 0, 34);
break;
case AV_CODEC_ID_ADPCM_PSX:
- codec->block_align = 16 * codec->channels;
+ par->block_align = 16 * par->channels;
if (pb->seekable)
- st->duration = av_get_audio_frame_duration(codec, avio_size(pb) - start);
+ st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start);
break;
case AV_CODEC_ID_ADPCM_IMA_RAD:
- codec->block_align = 20 * codec->channels;
+ par->block_align = 20 * par->channels;
if (pb->seekable)
- st->duration = av_get_audio_frame_duration(codec, avio_size(pb) - start);
+ st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start);
break;
case AV_CODEC_ID_ADPCM_IMA_WAV:
if (version == 2)
start = avio_rl32(pb);
- codec->bits_per_coded_sample = 4;
- codec->block_align = 36 * codec->channels;
+ par->bits_per_coded_sample = 4;
+ par->block_align = 36 * par->channels;
if (pb->seekable)
- st->duration = av_get_audio_frame_duration(codec, avio_size(pb) - start);
+ st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start);
break;
case AV_CODEC_ID_ADPCM_THP_LE:
/* RSD3GADP is mono, so only alloc enough memory
@@ -127,24 +127,24 @@ static int rsd_read_header(AVFormatContext *s)
start = avio_rl32(pb);
- if ((ret = ff_get_extradata(codec, s->pb, 32)) < 0)
+ if ((ret = ff_get_extradata(par, s->pb, 32)) < 0)
return ret;
if (pb->seekable)
- st->duration = av_get_audio_frame_duration(codec, avio_size(pb) - start);
+ st->duration = av_get_audio_frame_duration2(par, avio_size(pb) - start);
break;
case AV_CODEC_ID_ADPCM_THP:
- codec->block_align = 8 * codec->channels;
+ par->block_align = 8 * par->channels;
avio_skip(s->pb, 0x1A4 - avio_tell(s->pb));
- if ((ret = ff_alloc_extradata(st->codec, 32 * st->codec->channels)) < 0)
+ if ((ret = ff_alloc_extradata(st->codecpar, 32 * par->channels)) < 0)
return ret;
- for (i = 0; i < st->codec->channels; i++) {
- avio_read(s->pb, st->codec->extradata + 32 * i, 32);
+ for (i = 0; i < par->channels; i++) {
+ avio_read(s->pb, st->codecpar->extradata + 32 * i, 32);
avio_skip(s->pb, 8);
}
if (pb->seekable)
- st->duration = (avio_size(pb) - start) / (8 * st->codec->channels) * 14;
+ st->duration = (avio_size(pb) - start) / (8 * par->channels) * 14;
break;
case AV_CODEC_ID_PCM_S16LE:
case AV_CODEC_ID_PCM_S16BE:
@@ -152,24 +152,24 @@ static int rsd_read_header(AVFormatContext *s)
start = avio_rl32(pb);
if (pb->seekable)
- st->duration = (avio_size(pb) - start) / 2 / codec->channels;
+ st->duration = (avio_size(pb) - start) / 2 / par->channels;
break;
}
avio_skip(pb, start - avio_tell(pb));
- if (codec->codec_id == AV_CODEC_ID_XMA2) {
+ if (par->codec_id == AV_CODEC_ID_XMA2) {
avio_skip(pb, avio_rb32(pb) + avio_rb32(pb));
st->duration = avio_rb32(pb);
}
- avpriv_set_pts_info(st, 64, 1, codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, par->sample_rate);
return 0;
}
static int rsd_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- AVCodecContext *codec = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
int ret, size = 1024;
int64_t pos;
@@ -177,20 +177,20 @@ static int rsd_read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR_EOF;
pos = avio_tell(s->pb);
- if (codec->codec_id == AV_CODEC_ID_ADPCM_IMA_RAD ||
- codec->codec_id == AV_CODEC_ID_ADPCM_PSX ||
- codec->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
- codec->codec_id == AV_CODEC_ID_XMA2) {
- ret = av_get_packet(s->pb, pkt, codec->block_align);
- } else if (codec->codec_tag == MKTAG('W','A','D','P') &&
- codec->channels > 1) {
+ if (par->codec_id == AV_CODEC_ID_ADPCM_IMA_RAD ||
+ par->codec_id == AV_CODEC_ID_ADPCM_PSX ||
+ par->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV ||
+ par->codec_id == AV_CODEC_ID_XMA2) {
+ ret = av_get_packet(s->pb, pkt, par->block_align);
+ } else if (par->codec_tag == MKTAG('W','A','D','P') &&
+ par->channels > 1) {
int i, ch;
- ret = av_new_packet(pkt, codec->block_align);
+ ret = av_new_packet(pkt, par->block_align);
if (ret < 0)
return ret;
for (i = 0; i < 4; i++) {
- for (ch = 0; ch < codec->channels; ch++) {
+ for (ch = 0; ch < par->channels; ch++) {
pkt->data[ch * 8 + i * 2 + 0] = avio_r8(s->pb);
pkt->data[ch * 8 + i * 2 + 1] = avio_r8(s->pb);
}
@@ -200,7 +200,7 @@ static int rsd_read_packet(AVFormatContext *s, AVPacket *pkt)
ret = av_get_packet(s->pb, pkt, size);
}
- if (codec->codec_id == AV_CODEC_ID_XMA2 && pkt->size >= 1)
+ if (par->codec_id == AV_CODEC_ID_XMA2 && pkt->size >= 1)
pkt->duration = (pkt->data[0] >> 2) * 512;
pkt->pos = pos;
diff --git a/libavformat/rsodec.c b/libavformat/rsodec.c
index 6e3ea0a153..b2d9a7c403 100644
--- a/libavformat/rsodec.c
+++ b/libavformat/rsodec.c
@@ -59,13 +59,13 @@ static int rso_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
st->duration = (size * 8) / bps;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_tag = id;
- st->codec->codec_id = codec;
- st->codec->channels = 1;
- st->codec->channel_layout = AV_CH_LAYOUT_MONO;
- st->codec->sample_rate = rate;
- st->codec->block_align = 1;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_tag = id;
+ st->codecpar->codec_id = codec;
+ st->codecpar->channels = 1;
+ st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+ st->codecpar->sample_rate = rate;
+ st->codecpar->block_align = 1;
avpriv_set_pts_info(st, 64, 1, rate);
diff --git a/libavformat/rsoenc.c b/libavformat/rsoenc.c
index 6da9594fcb..3c5c1180f5 100644
--- a/libavformat/rsoenc.c
+++ b/libavformat/rsoenc.c
@@ -28,12 +28,12 @@
static int rso_write_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
- AVCodecContext *enc = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
- if (!enc->codec_tag)
+ if (!par->codec_tag)
return AVERROR_INVALIDDATA;
- if (enc->channels != 1) {
+ if (par->channels != 1) {
av_log(s, AV_LOG_ERROR, "RSO only supports mono\n");
return AVERROR_INVALIDDATA;
}
@@ -44,20 +44,20 @@ static int rso_write_header(AVFormatContext *s)
}
/* XXX: find legal sample rates (if any) */
- if (enc->sample_rate >= 1u<<16) {
+ if (par->sample_rate >= 1u<<16) {
av_log(s, AV_LOG_ERROR, "Sample rate must be < 65536\n");
return AVERROR_INVALIDDATA;
}
- if (enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {
+ if (par->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {
av_log(s, AV_LOG_ERROR, "ADPCM in RSO not implemented\n");
return AVERROR_PATCHWELCOME;
}
/* format header */
- avio_wb16(pb, enc->codec_tag); /* codec ID */
+ avio_wb16(pb, par->codec_tag); /* codec ID */
avio_wb16(pb, 0); /* data size, will be written at EOF */
- avio_wb16(pb, enc->sample_rate);
+ avio_wb16(pb, par->sample_rate);
avio_wb16(pb, 0x0000); /* play mode ? (0x0000 = don't loop) */
avio_flush(pb);
diff --git a/libavformat/rtp.c b/libavformat/rtp.c
index 4d41350f3c..4745e54bb0 100644
--- a/libavformat/rtp.c
+++ b/libavformat/rtp.c
@@ -68,19 +68,19 @@ static const struct {
{-1, "", AVMEDIA_TYPE_UNKNOWN, AV_CODEC_ID_NONE, -1, -1}
};
-int ff_rtp_get_codec_info(AVCodecContext *codec, int payload_type)
+int ff_rtp_get_codec_info(AVCodecParameters *par, int payload_type)
{
int i = 0;
for (i = 0; rtp_payload_types[i].pt >= 0; i++)
if (rtp_payload_types[i].pt == payload_type) {
if (rtp_payload_types[i].codec_id != AV_CODEC_ID_NONE) {
- codec->codec_type = rtp_payload_types[i].codec_type;
- codec->codec_id = rtp_payload_types[i].codec_id;
+ par->codec_type = rtp_payload_types[i].codec_type;
+ par->codec_id = rtp_payload_types[i].codec_id;
if (rtp_payload_types[i].audio_channels > 0)
- codec->channels = rtp_payload_types[i].audio_channels;
+ par->channels = rtp_payload_types[i].audio_channels;
if (rtp_payload_types[i].clock_rate > 0)
- codec->sample_rate = rtp_payload_types[i].clock_rate;
+ par->sample_rate = rtp_payload_types[i].clock_rate;
return 0;
}
}
@@ -88,7 +88,7 @@ int ff_rtp_get_codec_info(AVCodecContext *codec, int payload_type)
}
int ff_rtp_get_payload_type(AVFormatContext *fmt,
- AVCodecContext *codec, int idx)
+ AVCodecParameters *par, int idx)
{
int i;
AVOutputFormat *ofmt = fmt ? fmt->oformat : NULL;
@@ -103,27 +103,27 @@ int ff_rtp_get_payload_type(AVFormatContext *fmt,
/* static payload type */
for (i = 0; rtp_payload_types[i].pt >= 0; ++i)
- if (rtp_payload_types[i].codec_id == codec->codec_id) {
- if (codec->codec_id == AV_CODEC_ID_H263 && (!fmt || !fmt->oformat ||
+ if (rtp_payload_types[i].codec_id == par->codec_id) {
+ if (par->codec_id == AV_CODEC_ID_H263 && (!fmt || !fmt->oformat ||
!fmt->oformat->priv_class || !fmt->priv_data ||
!av_opt_flag_is_set(fmt->priv_data, "rtpflags", "rfc2190")))
continue;
/* G722 has 8000 as nominal rate even if the sample rate is 16000,
* see section 4.5.2 in RFC 3551. */
- if (codec->codec_id == AV_CODEC_ID_ADPCM_G722 &&
- codec->sample_rate == 16000 && codec->channels == 1)
+ if (par->codec_id == AV_CODEC_ID_ADPCM_G722 &&
+ par->sample_rate == 16000 && par->channels == 1)
return rtp_payload_types[i].pt;
- if (codec->codec_type == AVMEDIA_TYPE_AUDIO &&
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO &&
((rtp_payload_types[i].clock_rate > 0 &&
- codec->sample_rate != rtp_payload_types[i].clock_rate) ||
+ par->sample_rate != rtp_payload_types[i].clock_rate) ||
(rtp_payload_types[i].audio_channels > 0 &&
- codec->channels != rtp_payload_types[i].audio_channels)))
+ par->channels != rtp_payload_types[i].audio_channels)))
continue;
return rtp_payload_types[i].pt;
}
if (idx < 0)
- idx = codec->codec_type == AVMEDIA_TYPE_AUDIO;
+ idx = par->codec_type == AVMEDIA_TYPE_AUDIO;
/* dynamic payload type */
return RTP_PT_PRIVATE + idx;
diff --git a/libavformat/rtp.h b/libavformat/rtp.h
index 66a4f3afbd..54512c6f71 100644
--- a/libavformat/rtp.h
+++ b/libavformat/rtp.h
@@ -32,11 +32,11 @@
* The format context private option payload_type overrides both.
*
* @param fmt The context of the format
- * @param codec The context of the codec
+ * @param par The codec parameters
* @param idx The stream index
* @return The payload type (the 'PT' field in the RTP header).
*/
-int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec,
+int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecParameters *par,
int idx);
/**
@@ -46,12 +46,12 @@ int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec,
* information depending on the payload type; for audio codecs, the
* channels and sample_rate fields are also filled.
*
- * @param codec The context of the codec
+ * @param par The codec parameters
* @param payload_type The payload type (the 'PT' field in the RTP header)
* @return In case of unknown payload type or dynamic payload type, a
* negative value is returned; otherwise, 0 is returned
*/
-int ff_rtp_get_codec_info(AVCodecContext *codec, int payload_type);
+int ff_rtp_get_codec_info(AVCodecParameters *par, int payload_type);
/**
* Return the encoding name (as defined in
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 037260596a..bf3680cb04 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -526,12 +526,12 @@ RTPDemuxContext *ff_rtp_parse_open(AVFormatContext *s1, AVStream *st,
rtp_init_statistics(&s->statistics, 0);
if (st) {
- switch (st->codec->codec_id) {
+ switch (st->codecpar->codec_id) {
case AV_CODEC_ID_ADPCM_G722:
/* According to RFC 3551, the stream clock rate is 8000
* even if the sample rate is 16000. */
- if (st->codec->sample_rate == 8000)
- st->codec->sample_rate = 16000;
+ if (st->codecpar->sample_rate == 8000)
+ st->codecpar->sample_rate = 16000;
break;
default:
break;
diff --git a/libavformat/rtpdec_amr.c b/libavformat/rtpdec_amr.c
index 848db9d62a..8687e654a3 100644
--- a/libavformat/rtpdec_amr.c
+++ b/libavformat/rtpdec_amr.c
@@ -55,20 +55,20 @@ static int amr_handle_packet(AVFormatContext *ctx, PayloadContext *data,
const uint8_t *speech_data;
uint8_t *ptr;
- if (st->codec->codec_id == AV_CODEC_ID_AMR_NB) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_AMR_NB) {
frame_sizes = frame_sizes_nb;
- } else if (st->codec->codec_id == AV_CODEC_ID_AMR_WB) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_AMR_WB) {
frame_sizes = frame_sizes_wb;
} else {
av_log(ctx, AV_LOG_ERROR, "Bad codec ID\n");
return AVERROR_INVALIDDATA;
}
- if (st->codec->channels != 1) {
+ if (st->codecpar->channels != 1) {
av_log(ctx, AV_LOG_ERROR, "Only mono AMR is supported\n");
return AVERROR_INVALIDDATA;
}
- st->codec->channel_layout = AV_CH_LAYOUT_MONO;
+ st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
/* The AMR RTP packet consists of one header byte, followed
* by one TOC byte for each AMR frame in the packet, followed
diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c
index 041085fb8d..8459a513fb 100644
--- a/libavformat/rtpdec_asf.c
+++ b/libavformat/rtpdec_asf.c
@@ -165,12 +165,10 @@ static int asfrtp_parse_sdp_line(AVFormatContext *s, int stream_index,
for (i = 0; i < rt->asf_ctx->nb_streams; i++) {
if (s->streams[stream_index]->id == rt->asf_ctx->streams[i]->id) {
- *s->streams[stream_index]->codec =
- *rt->asf_ctx->streams[i]->codec;
+ avcodec_parameters_copy(s->streams[stream_index]->codecpar,
+ rt->asf_ctx->streams[i]->codecpar);
s->streams[stream_index]->need_parsing =
rt->asf_ctx->streams[i]->need_parsing;
- rt->asf_ctx->streams[i]->codec->extradata_size = 0;
- rt->asf_ctx->streams[i]->codec->extradata = NULL;
avpriv_set_pts_info(s->streams[stream_index], 32, 1, 1000);
}
}
diff --git a/libavformat/rtpdec_formats.h b/libavformat/rtpdec_formats.h
index 4f58dee0e8..cf251a54aa 100644
--- a/libavformat/rtpdec_formats.h
+++ b/libavformat/rtpdec_formats.h
@@ -45,7 +45,7 @@ int ff_h264_handle_aggregated_packet(AVFormatContext *ctx, PayloadContext *data,
int ff_h264_handle_frag_packet(AVPacket *pkt, const uint8_t *buf, int len,
int start_bit, const uint8_t *nal_header,
int nal_header_len);
-void ff_h264_parse_framesize(AVCodecContext *codec, const char *p);
+void ff_h264_parse_framesize(AVCodecParameters *par, const char *p);
extern RTPDynamicProtocolHandler ff_ac3_dynamic_handler;
extern RTPDynamicProtocolHandler ff_amr_nb_dynamic_handler;
diff --git a/libavformat/rtpdec_g726.c b/libavformat/rtpdec_g726.c
index 7e9ef56e06..172a4b36ab 100644
--- a/libavformat/rtpdec_g726.c
+++ b/libavformat/rtpdec_g726.c
@@ -27,10 +27,10 @@ static av_cold int g726_ ## bitrate ##_init(AVFormatContext *s, int st_index, \
PayloadContext *data) \
{ \
AVStream *stream = s->streams[st_index]; \
- AVCodecContext *codec = stream->codec; \
+ AVCodecParameters *par = stream->codecpar; \
\
- codec->bits_per_coded_sample = bitrate/8; \
- codec->bit_rate = codec->bits_per_coded_sample * codec->sample_rate; \
+ par->bits_per_coded_sample = bitrate/8; \
+ par->bit_rate = par->bits_per_coded_sample * par->sample_rate; \
\
return 0; \
} \
diff --git a/libavformat/rtpdec_h264.c b/libavformat/rtpdec_h264.c
index e707d03b87..c5eb341b7b 100644
--- a/libavformat/rtpdec_h264.c
+++ b/libavformat/rtpdec_h264.c
@@ -146,7 +146,7 @@ static int sdp_parse_fmtp_config_h264(AVFormatContext *s,
PayloadContext *h264_data,
const char *attr, const char *value)
{
- AVCodecContext *codec = stream->codec;
+ AVCodecParameters *par = stream->codecpar;
if (!strcmp(attr, "packetization-mode")) {
av_log(s, AV_LOG_DEBUG, "RTP Packetization Mode: %d\n", atoi(value));
@@ -170,18 +170,18 @@ static int sdp_parse_fmtp_config_h264(AVFormatContext *s,
av_log(s, AV_LOG_WARNING, "Missing PPS in sprop-parameter-sets, ignoring\n");
return 0;
}
- codec->extradata_size = 0;
- av_freep(&codec->extradata);
- ret = ff_h264_parse_sprop_parameter_sets(s, &codec->extradata,
- &codec->extradata_size, value);
+ par->extradata_size = 0;
+ av_freep(&par->extradata);
+ ret = ff_h264_parse_sprop_parameter_sets(s, &par->extradata,
+ &par->extradata_size, value);
av_log(s, AV_LOG_DEBUG, "Extradata set to %p (size: %d)\n",
- codec->extradata, codec->extradata_size);
+ par->extradata, par->extradata_size);
return ret;
}
return 0;
}
-void ff_h264_parse_framesize(AVCodecContext *codec, const char *p)
+void ff_h264_parse_framesize(AVCodecParameters *par, const char *p)
{
char buf1[50];
char *dst = buf1;
@@ -199,8 +199,8 @@ void ff_h264_parse_framesize(AVCodecContext *codec, const char *p)
// a='framesize:96 320-240'
// set our parameters
- codec->width = atoi(buf1);
- codec->height = atoi(p + 1); // skip the -
+ par->width = atoi(buf1);
+ par->height = atoi(p + 1); // skip the -
}
int ff_h264_handle_aggregated_packet(AVFormatContext *ctx, PayloadContext *data, AVPacket *pkt,
@@ -400,7 +400,7 @@ static int parse_h264_sdp_line(AVFormatContext *s, int st_index,
stream = s->streams[st_index];
if (av_strstart(p, "framesize:", &p)) {
- ff_h264_parse_framesize(stream->codec, p);
+ ff_h264_parse_framesize(stream->codecpar, p);
} else if (av_strstart(p, "fmtp:", &p)) {
return ff_parse_fmtp(s, stream, h264_data, p, sdp_parse_fmtp_config_h264);
} else if (av_strstart(p, "cliprect:", &p)) {
diff --git a/libavformat/rtpdec_hevc.c b/libavformat/rtpdec_hevc.c
index 68ca17f3cb..a0e3a7c2f4 100644
--- a/libavformat/rtpdec_hevc.c
+++ b/libavformat/rtpdec_hevc.c
@@ -131,41 +131,41 @@ static av_cold int hevc_parse_sdp_line(AVFormatContext *ctx, int st_index,
PayloadContext *hevc_data, const char *line)
{
AVStream *current_stream;
- AVCodecContext *codec;
+ AVCodecParameters *par;
const char *sdp_line_ptr = line;
if (st_index < 0)
return 0;
current_stream = ctx->streams[st_index];
- codec = current_stream->codec;
+ par = current_stream->codecpar;
if (av_strstart(sdp_line_ptr, "framesize:", &sdp_line_ptr)) {
- ff_h264_parse_framesize(codec, sdp_line_ptr);
+ ff_h264_parse_framesize(par, sdp_line_ptr);
} else if (av_strstart(sdp_line_ptr, "fmtp:", &sdp_line_ptr)) {
int ret = ff_parse_fmtp(ctx, current_stream, hevc_data, sdp_line_ptr,
hevc_sdp_parse_fmtp_config);
if (hevc_data->vps_size || hevc_data->sps_size ||
hevc_data->pps_size || hevc_data->sei_size) {
- av_freep(&codec->extradata);
- codec->extradata_size = hevc_data->vps_size + hevc_data->sps_size +
- hevc_data->pps_size + hevc_data->sei_size;
- codec->extradata = av_malloc(codec->extradata_size +
- AV_INPUT_BUFFER_PADDING_SIZE);
- if (!codec->extradata) {
+ av_freep(&par->extradata);
+ par->extradata_size = hevc_data->vps_size + hevc_data->sps_size +
+ hevc_data->pps_size + hevc_data->sei_size;
+ par->extradata = av_malloc(par->extradata_size +
+ AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!par->extradata) {
ret = AVERROR(ENOMEM);
- codec->extradata_size = 0;
+ par->extradata_size = 0;
} else {
int pos = 0;
- memcpy(codec->extradata + pos, hevc_data->vps, hevc_data->vps_size);
+ memcpy(par->extradata + pos, hevc_data->vps, hevc_data->vps_size);
pos += hevc_data->vps_size;
- memcpy(codec->extradata + pos, hevc_data->sps, hevc_data->sps_size);
+ memcpy(par->extradata + pos, hevc_data->sps, hevc_data->sps_size);
pos += hevc_data->sps_size;
- memcpy(codec->extradata + pos, hevc_data->pps, hevc_data->pps_size);
+ memcpy(par->extradata + pos, hevc_data->pps, hevc_data->pps_size);
pos += hevc_data->pps_size;
- memcpy(codec->extradata + pos, hevc_data->sei, hevc_data->sei_size);
+ memcpy(par->extradata + pos, hevc_data->sei, hevc_data->sei_size);
pos += hevc_data->sei_size;
- memset(codec->extradata + pos, 0, AV_INPUT_BUFFER_PADDING_SIZE);
+ memset(par->extradata + pos, 0, AV_INPUT_BUFFER_PADDING_SIZE);
}
av_freep(&hevc_data->vps);
diff --git a/libavformat/rtpdec_ilbc.c b/libavformat/rtpdec_ilbc.c
index 82109e1344..cb48f7661d 100644
--- a/libavformat/rtpdec_ilbc.c
+++ b/libavformat/rtpdec_ilbc.c
@@ -31,10 +31,10 @@ static int ilbc_parse_fmtp(AVFormatContext *s,
int mode = atoi(value);
switch (mode) {
case 20:
- stream->codec->block_align = 38;
+ stream->codecpar->block_align = 38;
break;
case 30:
- stream->codec->block_align = 50;
+ stream->codecpar->block_align = 50;
break;
default:
av_log(s, AV_LOG_ERROR, "Unsupported iLBC mode %d\n", mode);
@@ -58,7 +58,7 @@ static int ilbc_parse_sdp_line(AVFormatContext *s, int st_index,
int ret = ff_parse_fmtp(s, st, data, p, ilbc_parse_fmtp);
if (ret < 0)
return ret;
- if (!st->codec->block_align) {
+ if (!st->codecpar->block_align) {
av_log(s, AV_LOG_ERROR, "No iLBC mode set\n");
return AVERROR(EINVAL);
}
diff --git a/libavformat/rtpdec_latm.c b/libavformat/rtpdec_latm.c
index aebba5741d..e51f0cdae8 100644
--- a/libavformat/rtpdec_latm.c
+++ b/libavformat/rtpdec_latm.c
@@ -115,13 +115,13 @@ static int parse_fmtp_config(AVStream *st, const char *value)
ret = AVERROR_PATCHWELCOME;
goto end;
}
- av_freep(&st->codec->extradata);
- if (ff_alloc_extradata(st->codec, (get_bits_left(&gb) + 7)/8)) {
+ av_freep(&st->codecpar->extradata);
+ if (ff_alloc_extradata(st->codecpar, (get_bits_left(&gb) + 7)/8)) {
ret = AVERROR(ENOMEM);
goto end;
}
- for (i = 0; i < st->codec->extradata_size; i++)
- st->codec->extradata[i] = get_bits(&gb, 8);
+ for (i = 0; i < st->codecpar->extradata_size; i++)
+ st->codecpar->extradata[i] = get_bits(&gb, 8);
end:
av_free(config);
diff --git a/libavformat/rtpdec_mpeg12.c b/libavformat/rtpdec_mpeg12.c
index e6185eafa6..b93de3d9e4 100644
--- a/libavformat/rtpdec_mpeg12.c
+++ b/libavformat/rtpdec_mpeg12.c
@@ -34,7 +34,7 @@ static int mpeg_parse_packet(AVFormatContext *ctx, PayloadContext *data,
h = AV_RB32(buf);
buf += 4;
len -= 4;
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && h & (1 << 26)) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && h & (1 << 26)) {
/* MPEG-2 */
if (len <= 4)
return AVERROR_INVALIDDATA;
diff --git a/libavformat/rtpdec_mpeg4.c b/libavformat/rtpdec_mpeg4.c
index 70e51f862c..37602925ff 100644
--- a/libavformat/rtpdec_mpeg4.c
+++ b/libavformat/rtpdec_mpeg4.c
@@ -97,14 +97,14 @@ static void close_context(PayloadContext *data)
av_freep(&data->mode);
}
-static int parse_fmtp_config(AVCodecContext *codec, const char *value)
+static int parse_fmtp_config(AVCodecParameters *par, char *value)
{
/* decode the hexa encoded parameter */
int len = ff_hex_to_data(NULL, value);
- av_freep(&codec->extradata);
- if (ff_alloc_extradata(codec, len))
+ av_freep(&par->extradata);
+ if (ff_alloc_extradata(par, len))
return AVERROR(ENOMEM);
- ff_hex_to_data(codec->extradata, value);
+ ff_hex_to_data(par->extradata, value);
return 0;
}
@@ -274,17 +274,17 @@ static int parse_fmtp(AVFormatContext *s,
AVStream *stream, PayloadContext *data,
const char *attr, const char *value)
{
- AVCodecContext *codec = stream->codec;
+ AVCodecParameters *par = stream->codecpar;
int res, i;
if (!strcmp(attr, "config")) {
- res = parse_fmtp_config(codec, value);
+ res = parse_fmtp_config(par, value);
if (res < 0)
return res;
}
- if (codec->codec_id == AV_CODEC_ID_AAC) {
+ if (par->codec_id == AV_CODEC_ID_AAC) {
/* Looking for a known attribute */
for (i = 0; attr_names[i].str; ++i) {
if (!av_strcasecmp(attr, attr_names[i].str)) {
diff --git a/libavformat/rtpdec_qdm2.c b/libavformat/rtpdec_qdm2.c
index 22b419e7e0..1f4fd5aace 100644
--- a/libavformat/rtpdec_qdm2.c
+++ b/libavformat/rtpdec_qdm2.c
@@ -104,18 +104,18 @@ static int qdm2_parse_config(PayloadContext *qdm, AVStream *st,
case 4: /* stream with extradata */
if (item_len < 30)
return AVERROR_INVALIDDATA;
- av_freep(&st->codec->extradata);
- if (ff_alloc_extradata(st->codec, 26 + item_len)) {
+ av_freep(&st->codecpar->extradata);
+ if (ff_alloc_extradata(st->codecpar, 26 + item_len)) {
return AVERROR(ENOMEM);
}
- AV_WB32(st->codec->extradata, 12);
- memcpy(st->codec->extradata + 4, "frma", 4);
- memcpy(st->codec->extradata + 8, "QDM2", 4);
- AV_WB32(st->codec->extradata + 12, 6 + item_len);
- memcpy(st->codec->extradata + 16, "QDCA", 4);
- memcpy(st->codec->extradata + 20, p + 2, item_len - 2);
- AV_WB32(st->codec->extradata + 18 + item_len, 8);
- AV_WB32(st->codec->extradata + 22 + item_len, 0);
+ AV_WB32(st->codecpar->extradata, 12);
+ memcpy(st->codecpar->extradata + 4, "frma", 4);
+ memcpy(st->codecpar->extradata + 8, "QDM2", 4);
+ AV_WB32(st->codecpar->extradata + 12, 6 + item_len);
+ memcpy(st->codecpar->extradata + 16, "QDCA", 4);
+ memcpy(st->codecpar->extradata + 20, p + 2, item_len - 2);
+ AV_WB32(st->codecpar->extradata + 18 + item_len, 8);
+ AV_WB32(st->codecpar->extradata + 22 + item_len, 0);
qdm->block_size = AV_RB32(p + 26);
break;
@@ -265,9 +265,9 @@ static int qdm2_parse_packet(AVFormatContext *s, PayloadContext *qdm,
* carried within the RTP stream, not SDP. Here,
* by setting codec_id to AV_CODEC_ID_QDM2, we are signalling
* to the decoder that it is OK to initialize. */
- st->codec->codec_id = AV_CODEC_ID_QDM2;
+ st->codecpar->codec_id = AV_CODEC_ID_QDM2;
}
- if (st->codec->codec_id == AV_CODEC_ID_NONE)
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE)
return AVERROR(EAGAIN);
/* subpackets */
diff --git a/libavformat/rtpdec_qt.c b/libavformat/rtpdec_qt.c
index 2d1b58e701..f383afc35e 100644
--- a/libavformat/rtpdec_qt.c
+++ b/libavformat/rtpdec_qt.c
@@ -106,9 +106,9 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt,
avio_seek(&pb, pos + 4, SEEK_SET);
tag = avio_rl32(&pb);
- if ((st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
+ if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
tag != MKTAG('v','i','d','e')) ||
- (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
+ (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
tag != MKTAG('s','o','u','n')))
return AVERROR_INVALIDDATA;
avpriv_set_pts_info(st, 32, 1, avio_rb32(&pb));
diff --git a/libavformat/rtpdec_svq3.c b/libavformat/rtpdec_svq3.c
index bad199fef3..18d79d2e22 100644
--- a/libavformat/rtpdec_svq3.c
+++ b/libavformat/rtpdec_svq3.c
@@ -59,22 +59,22 @@ static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv,
if (config_packet) {
- av_freep(&st->codec->extradata);
- st->codec->extradata_size = 0;
+ av_freep(&st->codecpar->extradata);
+ st->codecpar->extradata_size = 0;
- if (len < 2 || ff_alloc_extradata(st->codec, len + 8))
+ if (len < 2 || ff_alloc_extradata(st->codecpar, len + 8))
return AVERROR_INVALIDDATA;
- memcpy(st->codec->extradata, "SEQH", 4);
- AV_WB32(st->codec->extradata + 4, len);
- memcpy(st->codec->extradata + 8, buf, len);
+ memcpy(st->codecpar->extradata, "SEQH", 4);
+ AV_WB32(st->codecpar->extradata + 4, len);
+ memcpy(st->codecpar->extradata + 8, buf, len);
/* We set codec_id to AV_CODEC_ID_NONE initially to
* delay decoder initialization since extradata is
* carried within the RTP stream, not SDP. Here,
* by setting codec_id to AV_CODEC_ID_SVQ3, we are signalling
* to the decoder that it is OK to initialize. */
- st->codec->codec_id = AV_CODEC_ID_SVQ3;
+ st->codecpar->codec_id = AV_CODEC_ID_SVQ3;
return AVERROR(EAGAIN);
}
diff --git a/libavformat/rtpdec_xiph.c b/libavformat/rtpdec_xiph.c
index 6d9d0fd04d..26aef54e1d 100644
--- a/libavformat/rtpdec_xiph.c
+++ b/libavformat/rtpdec_xiph.c
@@ -222,16 +222,17 @@ static int get_base128(const uint8_t ** buf, const uint8_t * buf_end)
* Based off parse_packed_headers in Vorbis RTP
*/
static int
-parse_packed_headers(const uint8_t * packed_headers,
+parse_packed_headers(AVFormatContext *s,
+ const uint8_t * packed_headers,
const uint8_t * packed_headers_end,
- AVCodecContext * codec, PayloadContext * xiph_data)
+ AVCodecParameters *par, PayloadContext * xiph_data)
{
unsigned num_packed, num_headers, length, length1, length2, extradata_alloc;
uint8_t *ptr;
if (packed_headers_end - packed_headers < 9) {
- av_log(codec, AV_LOG_ERROR,
+ av_log(s, AV_LOG_ERROR,
"Invalid %"PTRDIFF_SPECIFIER" byte packed header.",
packed_headers_end - packed_headers);
return AVERROR_INVALIDDATA;
@@ -245,7 +246,7 @@ parse_packed_headers(const uint8_t * packed_headers,
length2 = get_base128(&packed_headers, packed_headers_end);
if (num_packed != 1 || num_headers > 3) {
- av_log(codec, AV_LOG_ERROR,
+ av_log(s, AV_LOG_ERROR,
"Unimplemented number of headers: %d packed headers, %d headers\n",
num_packed, num_headers);
return AVERROR_PATCHWELCOME;
@@ -253,7 +254,7 @@ parse_packed_headers(const uint8_t * packed_headers,
if (packed_headers_end - packed_headers != length ||
length1 > length || length2 > length - length1) {
- av_log(codec, AV_LOG_ERROR,
+ av_log(s, AV_LOG_ERROR,
"Bad packed header lengths (%d,%d,%"PTRDIFF_SPECIFIER",%d)\n", length1,
length2, packed_headers_end - packed_headers, length);
return AVERROR_INVALIDDATA;
@@ -265,19 +266,19 @@ parse_packed_headers(const uint8_t * packed_headers,
* -- AV_INPUT_BUFFER_PADDING_SIZE required */
extradata_alloc = length + length/255 + 3 + AV_INPUT_BUFFER_PADDING_SIZE;
- if (ff_alloc_extradata(codec, extradata_alloc)) {
- av_log(codec, AV_LOG_ERROR, "Out of memory\n");
+ if (ff_alloc_extradata(par, extradata_alloc)) {
+ av_log(s, AV_LOG_ERROR, "Out of memory\n");
return AVERROR(ENOMEM);
}
- ptr = codec->extradata;
+ ptr = par->extradata;
*ptr++ = 2;
ptr += av_xiphlacing(ptr, length1);
ptr += av_xiphlacing(ptr, length2);
memcpy(ptr, packed_headers, length);
ptr += length;
- codec->extradata_size = ptr - codec->extradata;
+ par->extradata_size = ptr - par->extradata;
// clear out remaining parts of the buffer
- memset(ptr, 0, extradata_alloc - codec->extradata_size);
+ memset(ptr, 0, extradata_alloc - par->extradata_size);
return 0;
}
@@ -287,16 +288,16 @@ static int xiph_parse_fmtp_pair(AVFormatContext *s,
PayloadContext *xiph_data,
const char *attr, const char *value)
{
- AVCodecContext *codec = stream->codec;
+ AVCodecParameters *par = stream->codecpar;
int result = 0;
if (!strcmp(attr, "sampling")) {
if (!strcmp(value, "YCbCr-4:2:0")) {
- codec->pix_fmt = AV_PIX_FMT_YUV420P;
+ par->format = AV_PIX_FMT_YUV420P;
} else if (!strcmp(value, "YCbCr-4:4:2")) {
- codec->pix_fmt = AV_PIX_FMT_YUV422P;
+ par->format = AV_PIX_FMT_YUV422P;
} else if (!strcmp(value, "YCbCr-4:4:4")) {
- codec->pix_fmt = AV_PIX_FMT_YUV444P;
+ par->format = AV_PIX_FMT_YUV444P;
} else {
av_log(s, AV_LOG_ERROR,
"Unsupported pixel format %s\n", attr);
@@ -305,12 +306,12 @@ static int xiph_parse_fmtp_pair(AVFormatContext *s,
} else if (!strcmp(attr, "width")) {
/* This is an integer between 1 and 1048561
* and MUST be in multiples of 16. */
- codec->width = atoi(value);
+ par->width = atoi(value);
return 0;
} else if (!strcmp(attr, "height")) {
/* This is an integer between 1 and 1048561
* and MUST be in multiples of 16. */
- codec->height = atoi(value);
+ par->height = atoi(value);
return 0;
} else if (!strcmp(attr, "delivery-method")) {
/* Possible values are: inline, in_band, out_band/specific_name. */
@@ -334,7 +335,7 @@ static int xiph_parse_fmtp_pair(AVFormatContext *s,
av_base64_decode(decoded_packet, value, decoded_alloc);
result = parse_packed_headers
- (decoded_packet, decoded_packet + packet_size, codec,
+ (s, decoded_packet, decoded_packet + packet_size, par,
xiph_data);
} else {
av_log(s, AV_LOG_ERROR,
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 00b69f5765..ef51236ab3 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -97,8 +97,8 @@ static int rtp_write_header(AVFormatContext *s1)
return AVERROR(EINVAL);
}
st = s1->streams[0];
- if (!is_supported(st->codec->codec_id)) {
- av_log(s1, AV_LOG_ERROR, "Unsupported codec %s\n", avcodec_get_name(st->codec->codec_id));
+ if (!is_supported(st->codecpar->codec_id)) {
+ av_log(s1, AV_LOG_ERROR, "Unsupported codec %s\n", avcodec_get_name(st->codecpar->codec_id));
return -1;
}
@@ -106,7 +106,7 @@ static int rtp_write_header(AVFormatContext *s1)
if (s->payload_type < 0) {
/* Re-validate non-dynamic payload types */
if (st->id < RTP_PT_PRIVATE)
- st->id = ff_rtp_get_payload_type(s1, st->codec, -1);
+ st->id = ff_rtp_get_payload_type(s1, st->codecpar, -1);
s->payload_type = st->id;
} else {
@@ -152,13 +152,13 @@ static int rtp_write_header(AVFormatContext *s1)
}
s->max_payload_size = s1->packet_size - 12;
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate);
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ avpriv_set_pts_info(st, 32, 1, st->codecpar->sample_rate);
} else {
avpriv_set_pts_info(st, 32, 1, 90000);
}
s->buf_ptr = s->buf;
- switch(st->codec->codec_id) {
+ switch(st->codecpar->codec_id) {
case AV_CODEC_ID_MP2:
case AV_CODEC_ID_MP3:
s->buf_ptr = s->buf + 4;
@@ -186,8 +186,8 @@ static int rtp_write_header(AVFormatContext *s1)
break;
case AV_CODEC_ID_H264:
/* check for H.264 MP4 syntax */
- if (st->codec->extradata_size > 4 && st->codec->extradata[0] == 1) {
- s->nal_length_size = (st->codec->extradata[4] & 0x03) + 1;
+ if (st->codecpar->extradata_size > 4 && st->codecpar->extradata[0] == 1) {
+ s->nal_length_size = (st->codecpar->extradata[4] & 0x03) + 1;
}
break;
case AV_CODEC_ID_HEVC:
@@ -195,8 +195,8 @@ static int rtp_write_header(AVFormatContext *s1)
* things simple and similar to the avcC/H264 case above, instead
* of trying to handle the pre-standardization versions (as in
* libavcodec/hevc.c). */
- if (st->codec->extradata_size > 21 && st->codec->extradata[0] == 1) {
- s->nal_length_size = (st->codec->extradata[21] & 0x03) + 1;
+ if (st->codecpar->extradata_size > 21 && st->codecpar->extradata[0] == 1) {
+ s->nal_length_size = (st->codecpar->extradata[21] & 0x03) + 1;
}
break;
case AV_CODEC_ID_VORBIS:
@@ -209,7 +209,7 @@ static int rtp_write_header(AVFormatContext *s1)
avpriv_set_pts_info(st, 32, 1, 8000);
break;
case AV_CODEC_ID_OPUS:
- if (st->codec->channels > 2) {
+ if (st->codecpar->channels > 2) {
av_log(s1, AV_LOG_ERROR, "Multistream opus not supported in RTP\n");
goto fail;
}
@@ -219,16 +219,16 @@ static int rtp_write_header(AVFormatContext *s1)
avpriv_set_pts_info(st, 32, 1, 48000);
break;
case AV_CODEC_ID_ILBC:
- if (st->codec->block_align != 38 && st->codec->block_align != 50) {
+ if (st->codecpar->block_align != 38 && st->codecpar->block_align != 50) {
av_log(s1, AV_LOG_ERROR, "Incorrect iLBC block size specified\n");
goto fail;
}
- s->max_frames_per_packet = s->max_payload_size / st->codec->block_align;
+ s->max_frames_per_packet = s->max_payload_size / st->codecpar->block_align;
break;
case AV_CODEC_ID_AMR_NB:
case AV_CODEC_ID_AMR_WB:
s->max_frames_per_packet = 50;
- if (st->codec->codec_id == AV_CODEC_ID_AMR_NB)
+ if (st->codecpar->codec_id == AV_CODEC_ID_AMR_NB)
n = 31;
else
n = 61;
@@ -237,7 +237,7 @@ static int rtp_write_header(AVFormatContext *s1)
av_log(s1, AV_LOG_ERROR, "RTP max payload size too small for AMR\n");
goto fail;
}
- if (st->codec->channels != 1) {
+ if (st->codecpar->channels != 1) {
av_log(s1, AV_LOG_ERROR, "Only mono is supported\n");
goto fail;
}
@@ -458,8 +458,8 @@ static int rtp_send_ilbc(AVFormatContext *s1, const uint8_t *buf, int size)
{
RTPMuxContext *s = s1->priv_data;
AVStream *st = s1->streams[0];
- int frame_duration = av_get_audio_frame_duration(st->codec, 0);
- int frame_size = st->codec->block_align;
+ int frame_duration = av_get_audio_frame_duration2(st->codecpar, 0);
+ int frame_size = st->codecpar->block_align;
int frames = size / frame_size;
while (frames > 0) {
@@ -509,26 +509,26 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
}
s->cur_timestamp = s->base_timestamp + pkt->pts;
- switch(st->codec->codec_id) {
+ switch(st->codecpar->codec_id) {
case AV_CODEC_ID_PCM_MULAW:
case AV_CODEC_ID_PCM_ALAW:
case AV_CODEC_ID_PCM_U8:
case AV_CODEC_ID_PCM_S8:
- return rtp_send_samples(s1, pkt->data, size, 8 * st->codec->channels);
+ return rtp_send_samples(s1, pkt->data, size, 8 * st->codecpar->channels);
case AV_CODEC_ID_PCM_U16BE:
case AV_CODEC_ID_PCM_U16LE:
case AV_CODEC_ID_PCM_S16BE:
case AV_CODEC_ID_PCM_S16LE:
- return rtp_send_samples(s1, pkt->data, size, 16 * st->codec->channels);
+ return rtp_send_samples(s1, pkt->data, size, 16 * st->codecpar->channels);
case AV_CODEC_ID_ADPCM_G722:
/* The actual sample size is half a byte per sample, but since the
* stream clock rate is 8000 Hz while the sample rate is 16000 Hz,
* the correct parameter for send_samples_bits is 8 bits per stream
* clock. */
- return rtp_send_samples(s1, pkt->data, size, 8 * st->codec->channels);
+ return rtp_send_samples(s1, pkt->data, size, 8 * st->codecpar->channels);
case AV_CODEC_ID_ADPCM_G726:
return rtp_send_samples(s1, pkt->data, size,
- st->codec->bits_per_coded_sample * st->codec->channels);
+ st->codecpar->bits_per_coded_sample * st->codecpar->channels);
case AV_CODEC_ID_MP2:
case AV_CODEC_ID_MP3:
rtp_send_mpegaudio(s1, pkt->data, size);
diff --git a/libavformat/rtpenc_aac.c b/libavformat/rtpenc_aac.c
index f835183ac3..fad8ea2a5b 100644
--- a/libavformat/rtpenc_aac.c
+++ b/libavformat/rtpenc_aac.c
@@ -33,7 +33,7 @@ void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)
uint8_t *p;
/* skip ADTS header, if present */
- if ((s1->streams[0]->codec->extradata_size) == 0) {
+ if ((s1->streams[0]->codecpar->extradata_size) == 0) {
size -= 7;
buff += 7;
}
diff --git a/libavformat/rtpenc_chain.c b/libavformat/rtpenc_chain.c
index 96e65efbaa..f768fb002e 100644
--- a/libavformat/rtpenc_chain.c
+++ b/libavformat/rtpenc_chain.c
@@ -63,7 +63,7 @@ int ff_rtp_chain_mux_open(AVFormatContext **out, AVFormatContext *s,
/* Get the payload type from the codec */
if (st->id < RTP_PT_PRIVATE)
rtpctx->streams[0]->id =
- ff_rtp_get_payload_type(s, st->codec, idx);
+ ff_rtp_get_payload_type(s, st->codecpar, idx);
else
rtpctx->streams[0]->id = st->id;
@@ -74,7 +74,7 @@ int ff_rtp_chain_mux_open(AVFormatContext **out, AVFormatContext *s,
/* Set the synchronized start time. */
rtpctx->start_time_realtime = s->start_time_realtime;
- avcodec_copy_context(rtpctx->streams[0]->codec, st->codec);
+ avcodec_parameters_copy(rtpctx->streams[0]->codecpar, st->codecpar);
rtpctx->streams[0]->time_base = st->time_base;
if (handle) {
diff --git a/libavformat/rtpenc_h264_hevc.c b/libavformat/rtpenc_h264_hevc.c
index 7234c7ebd9..0c88fc2a23 100644
--- a/libavformat/rtpenc_h264_hevc.c
+++ b/libavformat/rtpenc_h264_hevc.c
@@ -40,7 +40,7 @@ static void flush_buffered(AVFormatContext *s1, int last)
// If we're only sending one single NAL unit, send it as such, skip
// the STAP-A/AP framing
if (s->buffered_nals == 1) {
- enum AVCodecID codec = s1->streams[0]->codec->codec_id;
+ enum AVCodecID codec = s1->streams[0]->codecpar->codec_id;
if (codec == AV_CODEC_ID_H264)
ff_rtp_send_data(s1, s->buf + 3, s->buf_ptr - s->buf - 3, last);
else
@@ -55,7 +55,7 @@ static void flush_buffered(AVFormatContext *s1, int last)
static void nal_send(AVFormatContext *s1, const uint8_t *buf, int size, int last)
{
RTPMuxContext *s = s1->priv_data;
- enum AVCodecID codec = s1->streams[0]->codec->codec_id;
+ enum AVCodecID codec = s1->streams[0]->codecpar->codec_id;
av_log(s1, AV_LOG_DEBUG, "Sending NAL %x of len %d M=%d\n", buf[0] & 0x1F, size, last);
if (size <= s->max_payload_size) {
diff --git a/libavformat/rtpenc_jpeg.c b/libavformat/rtpenc_jpeg.c
index 72c07c7842..88acb37fea 100644
--- a/libavformat/rtpenc_jpeg.c
+++ b/libavformat/rtpenc_jpeg.c
@@ -42,17 +42,17 @@ void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size)
s->timestamp = s->cur_timestamp;
/* convert video pixel dimensions from pixels to blocks */
- w = AV_CEIL_RSHIFT(s1->streams[0]->codec->width, 3);
- h = AV_CEIL_RSHIFT(s1->streams[0]->codec->height, 3);
+ w = AV_CEIL_RSHIFT(s1->streams[0]->codecpar->width, 3);
+ h = AV_CEIL_RSHIFT(s1->streams[0]->codecpar->height, 3);
/* get the pixel format type or fail */
- if (s1->streams[0]->codec->pix_fmt == AV_PIX_FMT_YUVJ422P ||
- (s1->streams[0]->codec->color_range == AVCOL_RANGE_JPEG &&
- s1->streams[0]->codec->pix_fmt == AV_PIX_FMT_YUV422P)) {
+ if (s1->streams[0]->codecpar->format == AV_PIX_FMT_YUVJ422P ||
+ (s1->streams[0]->codecpar->color_range == AVCOL_RANGE_JPEG &&
+ s1->streams[0]->codecpar->format == AV_PIX_FMT_YUV422P)) {
type = 0;
- } else if (s1->streams[0]->codec->pix_fmt == AV_PIX_FMT_YUVJ420P ||
- (s1->streams[0]->codec->color_range == AVCOL_RANGE_JPEG &&
- s1->streams[0]->codec->pix_fmt == AV_PIX_FMT_YUV420P)) {
+ } else if (s1->streams[0]->codecpar->format == AV_PIX_FMT_YUVJ420P ||
+ (s1->streams[0]->codecpar->color_range == AVCOL_RANGE_JPEG &&
+ s1->streams[0]->codecpar->format == AV_PIX_FMT_YUV420P)) {
type = 1;
} else {
av_log(s1, AV_LOG_ERROR, "Unsupported pixel format\n");
diff --git a/libavformat/rtpenc_latm.c b/libavformat/rtpenc_latm.c
index 4430c44afe..7bda66af95 100644
--- a/libavformat/rtpenc_latm.c
+++ b/libavformat/rtpenc_latm.c
@@ -34,7 +34,7 @@ void ff_rtp_send_latm(AVFormatContext *s1, const uint8_t *buff, int size)
int len = 0;
/* skip ADTS header, if present */
- if ((s1->streams[0]->codec->extradata_size) == 0) {
+ if ((s1->streams[0]->codecpar->extradata_size) == 0) {
size -= 7;
buff += 7;
}
diff --git a/libavformat/rtpenc_mpegts.c b/libavformat/rtpenc_mpegts.c
index db1680e069..7af02e0d2f 100644
--- a/libavformat/rtpenc_mpegts.c
+++ b/libavformat/rtpenc_mpegts.c
@@ -66,7 +66,7 @@ static int rtp_mpegts_write_header(AVFormatContext *s)
goto fail;
st->time_base = s->streams[i]->time_base;
st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
- avcodec_copy_context(st->codec, s->streams[i]->codec);
+ avcodec_parameters_copy(st->codecpar, s->streams[i]->codecpar);
}
if ((ret = avio_open_dyn_buf(&mpegts_ctx->pb)) < 0)
goto fail;
@@ -87,7 +87,7 @@ static int rtp_mpegts_write_header(AVFormatContext *s)
st = avformat_new_stream(rtp_ctx, NULL);
st->time_base.num = 1;
st->time_base.den = 90000;
- st->codec->codec_id = AV_CODEC_ID_MPEG2TS;
+ st->codecpar->codec_id = AV_CODEC_ID_MPEG2TS;
rtp_ctx->pb = s->pb;
if ((ret = avformat_write_header(rtp_ctx, NULL)) < 0)
goto fail;
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 485e35626d..bbff70b37d 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -206,11 +206,11 @@ static int get_sockaddr(AVFormatContext *s,
static void init_rtp_handler(RTPDynamicProtocolHandler *handler,
RTSPStream *rtsp_st, AVStream *st)
{
- AVCodecContext *codec = st ? st->codec : NULL;
+ AVCodecParameters *par = st ? st->codecpar : NULL;
if (!handler)
return;
- if (codec)
- codec->codec_id = handler->codec_id;
+ if (par)
+ par->codec_id = handler->codec_id;
rtsp_st->dynamic_handler = handler;
if (st)
st->need_parsing = handler->need_parsing;
@@ -245,7 +245,7 @@ static int sdp_parse_rtpmap(AVFormatContext *s,
AVStream *st, RTSPStream *rtsp_st,
int payload_type, const char *p)
{
- AVCodecContext *codec = st->codec;
+ AVCodecParameters *par = st->codecpar;
char buf[256];
int i;
AVCodec *c;
@@ -259,22 +259,22 @@ static int sdp_parse_rtpmap(AVFormatContext *s,
if (payload_type < RTP_PT_PRIVATE) {
/* We are in a standard case
* (from http://www.iana.org/assignments/rtp-parameters). */
- codec->codec_id = ff_rtp_codec_id(buf, codec->codec_type);
+ par->codec_id = ff_rtp_codec_id(buf, par->codec_type);
}
- if (codec->codec_id == AV_CODEC_ID_NONE) {
+ if (par->codec_id == AV_CODEC_ID_NONE) {
RTPDynamicProtocolHandler *handler =
- ff_rtp_handler_find_by_name(buf, codec->codec_type);
+ ff_rtp_handler_find_by_name(buf, par->codec_type);
init_rtp_handler(handler, rtsp_st, st);
/* If no dynamic handler was found, check with the list of standard
* allocated types, if such a stream for some reason happens to
* use a private payload type. This isn't handled in rtpdec.c, since
* the format name from the rtpmap line never is passed into rtpdec. */
if (!rtsp_st->dynamic_handler)
- codec->codec_id = ff_rtp_codec_id(buf, codec->codec_type);
+ par->codec_id = ff_rtp_codec_id(buf, par->codec_type);
}
- c = avcodec_find_decoder(codec->codec_id);
+ c = avcodec_find_decoder(par->codec_id);
if (c && c->name)
c_name = c->name;
else
@@ -282,23 +282,23 @@ static int sdp_parse_rtpmap(AVFormatContext *s,
get_word_sep(buf, sizeof(buf), "/", &p);
i = atoi(buf);
- switch (codec->codec_type) {
+ switch (par->codec_type) {
case AVMEDIA_TYPE_AUDIO:
av_log(s, AV_LOG_DEBUG, "audio codec set to: %s\n", c_name);
- codec->sample_rate = RTSP_DEFAULT_AUDIO_SAMPLERATE;
- codec->channels = RTSP_DEFAULT_NB_AUDIO_CHANNELS;
+ par->sample_rate = RTSP_DEFAULT_AUDIO_SAMPLERATE;
+ par->channels = RTSP_DEFAULT_NB_AUDIO_CHANNELS;
if (i > 0) {
- codec->sample_rate = i;
- avpriv_set_pts_info(st, 32, 1, codec->sample_rate);
+ par->sample_rate = i;
+ avpriv_set_pts_info(st, 32, 1, par->sample_rate);
get_word_sep(buf, sizeof(buf), "/", &p);
i = atoi(buf);
if (i > 0)
- codec->channels = i;
+ par->channels = i;
}
av_log(s, AV_LOG_DEBUG, "audio samplerate set to: %i\n",
- codec->sample_rate);
+ par->sample_rate);
av_log(s, AV_LOG_DEBUG, "audio channels set to: %i\n",
- codec->channels);
+ par->channels);
break;
case AVMEDIA_TYPE_VIDEO:
av_log(s, AV_LOG_DEBUG, "video codec set to: %s\n", c_name);
@@ -503,17 +503,17 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
return;
st->id = rt->nb_rtsp_streams - 1;
rtsp_st->stream_index = st->index;
- st->codec->codec_type = codec_type;
+ st->codecpar->codec_type = codec_type;
if (rtsp_st->sdp_payload_type < RTP_PT_PRIVATE) {
RTPDynamicProtocolHandler *handler;
/* if standard payload type, we can find the codec right now */
- ff_rtp_get_codec_info(st->codec, rtsp_st->sdp_payload_type);
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
- st->codec->sample_rate > 0)
- avpriv_set_pts_info(st, 32, 1, st->codec->sample_rate);
+ ff_rtp_get_codec_info(st->codecpar, rtsp_st->sdp_payload_type);
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
+ st->codecpar->sample_rate > 0)
+ avpriv_set_pts_info(st, 32, 1, st->codecpar->sample_rate);
/* Even static payload types may need a custom depacketizer */
handler = ff_rtp_handler_find_by_id(
- rtsp_st->sdp_payload_type, st->codec->codec_type);
+ rtsp_st->sdp_payload_type, st->codecpar->codec_type);
init_rtp_handler(handler, rtsp_st, st);
finalize_rtp_handler_init(s, rtsp_st, st);
}
@@ -598,7 +598,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
} else if (av_strstart(p, "SampleRate:integer;", &p) &&
s->nb_streams > 0) {
st = s->streams[s->nb_streams - 1];
- st->codec->sample_rate = atoi(p);
+ st->codecpar->sample_rate = atoi(p);
} else if (av_strstart(p, "crypto:", &p) && s->nb_streams > 0) {
// RFC 4568
rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];
@@ -1501,7 +1501,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
* will return an error. Therefore, we skip those streams. */
if (rt->server_type == RTSP_SERVER_WMS &&
(rtsp_st->stream_index < 0 ||
- s->streams[rtsp_st->stream_index]->codec->codec_type ==
+ s->streams[rtsp_st->stream_index]->codecpar->codec_type ==
AVMEDIA_TYPE_DATA))
continue;
snprintf(transport, sizeof(transport) - 1,
@@ -2377,7 +2377,7 @@ static int rtp_read_header(AVFormatContext *s)
int ret, port;
URLContext* in = NULL;
int payload_type;
- AVCodecContext codec = { 0 };
+ AVCodecParameters *par = NULL;
struct sockaddr_storage addr;
AVIOContext pb;
socklen_t addrlen = sizeof(addr);
@@ -2418,13 +2418,19 @@ static int rtp_read_header(AVFormatContext *s)
ffurl_close(in);
in = NULL;
- if (ff_rtp_get_codec_info(&codec, payload_type)) {
+ par = avcodec_parameters_alloc();
+ if (!par) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+
+ if (ff_rtp_get_codec_info(par, payload_type)) {
av_log(s, AV_LOG_ERROR, "Unable to receive RTP payload type %d "
"without an SDP file describing it\n",
payload_type);
goto fail;
}
- if (codec.codec_type != AVMEDIA_TYPE_DATA) {
+ if (par->codec_type != AVMEDIA_TYPE_DATA) {
av_log(s, AV_LOG_WARNING, "Guessing on RTP content - if not received "
"properly you need an SDP file "
"describing it\n");
@@ -2436,10 +2442,11 @@ static int rtp_read_header(AVFormatContext *s)
snprintf(sdp, sizeof(sdp),
"v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
addr.ss_family == AF_INET ? 4 : 6, host,
- codec.codec_type == AVMEDIA_TYPE_DATA ? "application" :
- codec.codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
+ par->codec_type == AVMEDIA_TYPE_DATA ? "application" :
+ par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio",
port, payload_type);
av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", sdp);
+ avcodec_parameters_free(&par);
ffio_init_context(&pb, sdp, strlen(sdp), 0, NULL, NULL, NULL, NULL);
s->pb = &pb;
@@ -2454,6 +2461,7 @@ static int rtp_read_header(AVFormatContext *s)
return ret;
fail:
+ avcodec_parameters_free(&par);
if (in)
ffurl_close(in);
ff_network_close();
diff --git a/libavformat/samidec.c b/libavformat/samidec.c
index 11c674ce19..7ea1bdfdd9 100644
--- a/libavformat/samidec.c
+++ b/libavformat/samidec.c
@@ -59,8 +59,8 @@ static int sami_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 1000);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_SAMI;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_SAMI;
av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
av_bprint_init(&hdr_buf, 0, AV_BPRINT_SIZE_UNLIMITED);
@@ -101,7 +101,7 @@ static int sami_read_header(AVFormatContext *s)
av_bprint_clear(&buf);
}
- res = avpriv_bprint_to_extradata(st->codec, &hdr_buf);
+ res = ff_bprint_to_codecpar_extradata(st->codecpar, &hdr_buf);
if (res < 0)
goto end;
diff --git a/libavformat/sapdec.c b/libavformat/sapdec.c
index 0473b018f9..218c32a2eb 100644
--- a/libavformat/sapdec.c
+++ b/libavformat/sapdec.c
@@ -176,7 +176,7 @@ static int sap_read_header(AVFormatContext *s)
goto fail;
}
st->id = i;
- avcodec_copy_context(st->codec, sap->sdp_ctx->streams[i]->codec);
+ avcodec_parameters_copy(st->codecpar, sap->sdp_ctx->streams[i]->codecpar);
st->time_base = sap->sdp_ctx->streams[i]->time_base;
}
@@ -225,7 +225,7 @@ static int sap_fetch_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(ENOMEM);
}
st->id = i;
- avcodec_copy_context(st->codec, sap->sdp_ctx->streams[i]->codec);
+ avcodec_parameters_copy(st->codecpar, sap->sdp_ctx->streams[i]->codecpar);
st->time_base = sap->sdp_ctx->streams[i]->time_base;
}
}
diff --git a/libavformat/sauce.c b/libavformat/sauce.c
index a2347b0197..5ac9ca9d14 100644
--- a/libavformat/sauce.c
+++ b/libavformat/sauce.c
@@ -65,18 +65,18 @@ int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int g
if (got_width && datatype && filetype) {
if ((datatype == 1 && filetype <=2) || (datatype == 5 && filetype == 255) || datatype == 6) {
if (t1) {
- avctx->streams[0]->codec->width = t1<<3;
+ avctx->streams[0]->codecpar->width = t1<<3;
*got_width = 1;
}
if (get_height && t2)
- avctx->streams[0]->codec->height = t2<<4;
+ avctx->streams[0]->codecpar->height = t2<<4;
} else if (datatype == 5) {
if (filetype) {
- avctx->streams[0]->codec->width = (filetype == 1 ? t1 : filetype) << 4;
+ avctx->streams[0]->codecpar->width = (filetype == 1 ? t1 : filetype) << 4;
*got_width = 1;
}
if (get_height && t2)
- avctx->streams[0]->codec->height = t2<<4;
+ avctx->streams[0]->codecpar->height = t2<<4;
}
}
diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c
index 03cd9226c9..bb020d7f9a 100644
--- a/libavformat/sbgdec.c
+++ b/libavformat/sbgdec.c
@@ -1324,7 +1324,7 @@ static int generate_intervals(void *log, struct sbg_script *s, int sample_rate,
return 0;
}
-static int encode_intervals(struct sbg_script *s, AVCodecContext *avc,
+static int encode_intervals(struct sbg_script *s, AVCodecParameters *par,
struct ws_intervals *inter)
{
int i, edata_size = 4;
@@ -1336,9 +1336,9 @@ static int encode_intervals(struct sbg_script *s, AVCodecContext *avc,
if (edata_size < 0)
return AVERROR(ENOMEM);
}
- if (ff_alloc_extradata(avc, edata_size))
+ if (ff_alloc_extradata(par, edata_size))
return AVERROR(ENOMEM);
- edata = avc->extradata;
+ edata = par->extradata;
#define ADD_EDATA32(v) do { AV_WL32(edata, (v)); edata += 4; } while(0)
#define ADD_EDATA64(v) do { AV_WL64(edata, (v)); edata += 8; } while(0)
@@ -1362,7 +1362,7 @@ static int encode_intervals(struct sbg_script *s, AVCodecContext *avc,
break;
}
}
- if (edata != avc->extradata + edata_size)
+ if (edata != par->extradata + edata_size)
return AVERROR_BUG;
return 0;
}
@@ -1414,13 +1414,13 @@ static av_cold int sbg_read_header(AVFormatContext *avf)
st = avformat_new_stream(avf, NULL);
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_FFWAVESYNTH;
- st->codec->channels = 2;
- st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
- st->codec->sample_rate = sbg->sample_rate;
- st->codec->frame_size = sbg->frame_size;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_FFWAVESYNTH;
+ st->codecpar->channels = 2;
+ st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+ st->codecpar->sample_rate = sbg->sample_rate;
+ st->codecpar->frame_size = sbg->frame_size;
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
st->probe_packets = 0;
st->start_time = av_rescale(script.start_ts,
sbg->sample_rate, AV_TIME_BASE);
@@ -1428,7 +1428,7 @@ static av_cold int sbg_read_header(AVFormatContext *avf)
av_rescale(script.end_ts - script.start_ts,
sbg->sample_rate, AV_TIME_BASE);
st->cur_dts = st->start_time;
- r = encode_intervals(&script, st->codec, &inter);
+ r = encode_intervals(&script, st->codecpar, &inter);
if (r < 0)
goto fail;
@@ -1448,7 +1448,7 @@ static int sbg_read_packet(AVFormatContext *avf, AVPacket *packet)
int64_t ts, end_ts;
ts = avf->streams[0]->cur_dts;
- end_ts = ts + avf->streams[0]->codec->frame_size;
+ end_ts = ts + avf->streams[0]->codecpar->frame_size;
if (avf->streams[0]->duration != AV_NOPTS_VALUE)
end_ts = FFMIN(avf->streams[0]->start_time + avf->streams[0]->duration,
end_ts);
diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index 368402b072..7ba4a9a3a0 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -151,24 +151,24 @@ static int sdp_get_address(char *dest_addr, int size, int *ttl, const char *url)
}
#define MAX_PSET_SIZE 1024
-static char *extradata2psets(AVCodecContext *c)
+static char *extradata2psets(AVFormatContext *s, AVCodecParameters *par)
{
char *psets, *p;
const uint8_t *r;
static const char pset_string[] = "; sprop-parameter-sets=";
static const char profile_string[] = "; profile-level-id=";
- uint8_t *extradata = c->extradata;
- int extradata_size = c->extradata_size;
+ uint8_t *extradata = par->extradata;
+ int extradata_size = par->extradata_size;
uint8_t *tmpbuf = NULL;
const uint8_t *sps = NULL, *sps_end;
- if (c->extradata_size > MAX_EXTRADATA_SIZE) {
- av_log(c, AV_LOG_ERROR, "Too much extradata!\n");
+ if (par->extradata_size > MAX_EXTRADATA_SIZE) {
+ av_log(s, AV_LOG_ERROR, "Too much extradata!\n");
return NULL;
}
- if (c->extradata[0] == 1) {
- if (ff_avc_write_annexb_extradata(c->extradata, &extradata,
+ if (par->extradata[0] == 1) {
+ if (ff_avc_write_annexb_extradata(par->extradata, &extradata,
&extradata_size))
return NULL;
tmpbuf = extradata;
@@ -176,7 +176,7 @@ static char *extradata2psets(AVCodecContext *c)
psets = av_mallocz(MAX_PSET_SIZE);
if (!psets) {
- av_log(c, AV_LOG_ERROR, "Cannot allocate memory for the parameter sets.\n");
+ av_log(s, AV_LOG_ERROR, "Cannot allocate memory for the parameter sets.\n");
av_free(tmpbuf);
return NULL;
}
@@ -203,7 +203,7 @@ static char *extradata2psets(AVCodecContext *c)
sps_end = r1;
}
if (!av_base64_encode(p, MAX_PSET_SIZE - (p - psets), r, r1 - r)) {
- av_log(c, AV_LOG_ERROR, "Cannot Base64-encode %"PTRDIFF_SPECIFIER" %"PTRDIFF_SPECIFIER"!\n", MAX_PSET_SIZE - (p - psets), r1 - r);
+ av_log(s, AV_LOG_ERROR, "Cannot Base64-encode %"PTRDIFF_SPECIFIER" %"PTRDIFF_SPECIFIER"!\n", MAX_PSET_SIZE - (p - psets), r1 - r);
av_free(psets);
av_free(tmpbuf);
@@ -223,11 +223,11 @@ static char *extradata2psets(AVCodecContext *c)
return psets;
}
-static char *extradata2psets_hevc(AVCodecContext *c)
+static char *extradata2psets_hevc(AVCodecParameters *par)
{
char *psets;
- uint8_t *extradata = c->extradata;
- int extradata_size = c->extradata_size;
+ uint8_t *extradata = par->extradata;
+ int extradata_size = par->extradata_size;
uint8_t *tmpbuf = NULL;
int ps_pos[3] = { 0 };
static const char * const ps_names[3] = { "vps", "sps", "pps" };
@@ -238,11 +238,11 @@ static char *extradata2psets_hevc(AVCodecContext *c)
// the same type, and we might need to convert from one format to the
// other anyway, we get away with a little less work by using the hvcc
// format.
- if (c->extradata[0] != 1) {
+ if (par->extradata[0] != 1) {
AVIOContext *pb;
if (avio_open_dyn_buf(&pb) < 0)
return NULL;
- if (ff_isom_write_hvcc(pb, c->extradata, c->extradata_size, 0) < 0) {
+ if (ff_isom_write_hvcc(pb, par->extradata, par->extradata_size, 0) < 0) {
avio_close_dyn_buf(pb, &tmpbuf);
goto err;
}
@@ -324,35 +324,35 @@ err:
return NULL;
}
-static char *extradata2config(AVCodecContext *c)
+static char *extradata2config(AVFormatContext *s, AVCodecParameters *par)
{
char *config;
- if (c->extradata_size > MAX_EXTRADATA_SIZE) {
- av_log(c, AV_LOG_ERROR, "Too much extradata!\n");
+ if (par->extradata_size > MAX_EXTRADATA_SIZE) {
+ av_log(s, AV_LOG_ERROR, "Too much extradata!\n");
return NULL;
}
- config = av_malloc(10 + c->extradata_size * 2);
+ config = av_malloc(10 + par->extradata_size * 2);
if (!config) {
- av_log(c, AV_LOG_ERROR, "Cannot allocate memory for the config info.\n");
+ av_log(s, AV_LOG_ERROR, "Cannot allocate memory for the config info.\n");
return NULL;
}
memcpy(config, "; config=", 9);
- ff_data_to_hex(config + 9, c->extradata, c->extradata_size, 0);
- config[9 + c->extradata_size * 2] = 0;
+ ff_data_to_hex(config + 9, par->extradata, par->extradata_size, 0);
+ config[9 + par->extradata_size * 2] = 0;
return config;
}
-static char *xiph_extradata2config(AVCodecContext *c)
+static char *xiph_extradata2config(AVFormatContext *s, AVCodecParameters *par)
{
char *config, *encoded_config;
const uint8_t *header_start[3];
int headers_len, header_len[3], config_len;
int first_header_size;
- switch (c->codec_id) {
+ switch (par->codec_id) {
case AV_CODEC_ID_THEORA:
first_header_size = 42;
break;
@@ -360,14 +360,14 @@ static char *xiph_extradata2config(AVCodecContext *c)
first_header_size = 30;
break;
default:
- av_log(c, AV_LOG_ERROR, "Unsupported Xiph codec ID\n");
+ av_log(s, AV_LOG_ERROR, "Unsupported Xiph codec ID\n");
return NULL;
}
- if (avpriv_split_xiph_headers(c->extradata, c->extradata_size,
+ if (avpriv_split_xiph_headers(par->extradata, par->extradata_size,
first_header_size, header_start,
header_len) < 0) {
- av_log(c, AV_LOG_ERROR, "Extradata corrupt.\n");
+ av_log(s, AV_LOG_ERROR, "Extradata corrupt.\n");
return NULL;
}
@@ -409,12 +409,12 @@ static char *xiph_extradata2config(AVCodecContext *c)
return encoded_config;
xiph_fail:
- av_log(c, AV_LOG_ERROR,
+ av_log(s, AV_LOG_ERROR,
"Not enough memory for configuration string\n");
return NULL;
}
-static int latm_context2profilelevel(AVCodecContext *c)
+static int latm_context2profilelevel(AVCodecParameters *par)
{
/* MP4A-LATM
* The RTP payload format specification is described in RFC 3016
@@ -425,17 +425,17 @@ static int latm_context2profilelevel(AVCodecContext *c)
/* TODO: AAC Profile only supports AAC LC Object Type.
* Different Object Types should implement different Profile Levels */
- if (c->sample_rate <= 24000) {
- if (c->channels <= 2)
+ if (par->sample_rate <= 24000) {
+ if (par->channels <= 2)
profile_level = 0x28; // AAC Profile, Level 1
- } else if (c->sample_rate <= 48000) {
- if (c->channels <= 2) {
+ } else if (par->sample_rate <= 48000) {
+ if (par->channels <= 2) {
profile_level = 0x29; // AAC Profile, Level 2
- } else if (c->channels <= 5) {
+ } else if (par->channels <= 5) {
profile_level = 0x2A; // AAC Profile, Level 4
}
- } else if (c->sample_rate <= 96000) {
- if (c->channels <= 5) {
+ } else if (par->sample_rate <= 96000) {
+ if (par->channels <= 5) {
profile_level = 0x2B; // AAC Profile, Level 5
}
}
@@ -443,7 +443,7 @@ static int latm_context2profilelevel(AVCodecContext *c)
return profile_level;
}
-static char *latm_context2config(AVCodecContext *c)
+static char *latm_context2config(AVFormatContext *s, AVCodecParameters *par)
{
/* MP4A-LATM
* The RTP payload format specification is described in RFC 3016
@@ -454,23 +454,23 @@ static char *latm_context2config(AVCodecContext *c)
char *config;
for (rate_index = 0; rate_index < 16; rate_index++)
- if (avpriv_mpeg4audio_sample_rates[rate_index] == c->sample_rate)
+ if (avpriv_mpeg4audio_sample_rates[rate_index] == par->sample_rate)
break;
if (rate_index == 16) {
- av_log(c, AV_LOG_ERROR, "Unsupported sample rate\n");
+ av_log(s, AV_LOG_ERROR, "Unsupported sample rate\n");
return NULL;
}
config_byte[0] = 0x40;
config_byte[1] = 0;
config_byte[2] = 0x20 | rate_index;
- config_byte[3] = c->channels << 4;
+ config_byte[3] = par->channels << 4;
config_byte[4] = 0x3f;
config_byte[5] = 0xc0;
config = av_malloc(6*2+1);
if (!config) {
- av_log(c, AV_LOG_ERROR, "Cannot allocate memory for the config info.\n");
+ av_log(s, AV_LOG_ERROR, "Cannot allocate memory for the config info.\n");
return NULL;
}
ff_data_to_hex(config, config_byte, 6, 1);
@@ -479,18 +479,19 @@ static char *latm_context2config(AVCodecContext *c)
return config;
}
-static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c, int payload_type, AVFormatContext *fmt)
+static char *sdp_write_media_attributes(char *buff, int size, AVStream *st, int payload_type, AVFormatContext *fmt)
{
char *config = NULL;
+ AVCodecParameters *p = st->codecpar;
- switch (c->codec_id) {
+ switch (p->codec_id) {
case AV_CODEC_ID_H264: {
int mode = 1;
if (fmt && fmt->oformat && fmt->oformat->priv_class &&
av_opt_flag_is_set(fmt->priv_data, "rtpflags", "h264_mode0"))
mode = 0;
- if (c->extradata_size) {
- config = extradata2psets(c);
+ if (p->extradata_size) {
+ config = extradata2psets(fmt, p);
}
av_strlcatf(buff, size, "a=rtpmap:%d H264/90000\r\n"
"a=fmtp:%d packetization-mode=%d%s\r\n",
@@ -502,9 +503,9 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
{
const char *pic_fmt = NULL;
/* only QCIF and CIF are specified as supported in RFC 4587 */
- if (c->width == 176 && c->height == 144)
+ if (p->width == 176 && p->height == 144)
pic_fmt = "QCIF=1";
- else if (c->width == 352 && c->height == 288)
+ else if (p->width == 352 && p->height == 288)
pic_fmt = "CIF=1";
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d H261/90000\r\n", payload_type);
@@ -520,23 +521,23 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
* stagefright and on Samsung bada. */
if (!fmt || !fmt->oformat->priv_class ||
!av_opt_flag_is_set(fmt->priv_data, "rtpflags", "rfc2190") ||
- c->codec_id == AV_CODEC_ID_H263P)
+ p->codec_id == AV_CODEC_ID_H263P)
av_strlcatf(buff, size, "a=rtpmap:%d H263-2000/90000\r\n"
"a=framesize:%d %d-%d\r\n",
payload_type,
- payload_type, c->width, c->height);
+ payload_type, p->width, p->height);
break;
case AV_CODEC_ID_HEVC:
- if (c->extradata_size)
- config = extradata2psets_hevc(c);
+ if (p->extradata_size)
+ config = extradata2psets_hevc(p);
av_strlcatf(buff, size, "a=rtpmap:%d H265/90000\r\n", payload_type);
if (config)
av_strlcatf(buff, size, "a=fmtp:%d %s\r\n",
payload_type, config);
break;
case AV_CODEC_ID_MPEG4:
- if (c->extradata_size) {
- config = extradata2config(c);
+ if (p->extradata_size) {
+ config = extradata2config(fmt, p);
}
av_strlcatf(buff, size, "a=rtpmap:%d MP4V-ES/90000\r\n"
"a=fmtp:%d profile-level-id=1%s\r\n",
@@ -546,21 +547,21 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
case AV_CODEC_ID_AAC:
if (fmt && fmt->oformat && fmt->oformat->priv_class &&
av_opt_flag_is_set(fmt->priv_data, "rtpflags", "latm")) {
- config = latm_context2config(c);
+ config = latm_context2config(fmt, p);
if (!config)
return NULL;
av_strlcatf(buff, size, "a=rtpmap:%d MP4A-LATM/%d/%d\r\n"
"a=fmtp:%d profile-level-id=%d;cpresent=0;config=%s\r\n",
- payload_type, c->sample_rate, c->channels,
- payload_type, latm_context2profilelevel(c), config);
+ payload_type, p->sample_rate, p->channels,
+ payload_type, latm_context2profilelevel(p), config);
} else {
- if (c->extradata_size) {
- config = extradata2config(c);
+ if (p->extradata_size) {
+ config = extradata2config(fmt, p);
} else {
/* FIXME: maybe we can forge config information based on the
* codec parameters...
*/
- av_log(c, AV_LOG_ERROR, "AAC with no global headers is currently not supported.\n");
+ av_log(fmt, AV_LOG_ERROR, "AAC with no global headers is currently not supported.\n");
return NULL;
}
if (!config) {
@@ -570,7 +571,7 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
"a=fmtp:%d profile-level-id=1;"
"mode=AAC-hbr;sizelength=13;indexlength=3;"
"indexdeltalength=3%s\r\n",
- payload_type, c->sample_rate, c->channels,
+ payload_type, p->sample_rate, p->channels,
payload_type, config);
}
break;
@@ -578,48 +579,48 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d L16/%d/%d\r\n",
payload_type,
- c->sample_rate, c->channels);
+ p->sample_rate, p->channels);
break;
case AV_CODEC_ID_PCM_MULAW:
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d PCMU/%d/%d\r\n",
payload_type,
- c->sample_rate, c->channels);
+ p->sample_rate, p->channels);
break;
case AV_CODEC_ID_PCM_ALAW:
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d PCMA/%d/%d\r\n",
payload_type,
- c->sample_rate, c->channels);
+ p->sample_rate, p->channels);
break;
case AV_CODEC_ID_AMR_NB:
av_strlcatf(buff, size, "a=rtpmap:%d AMR/%d/%d\r\n"
"a=fmtp:%d octet-align=1\r\n",
- payload_type, c->sample_rate, c->channels,
+ payload_type, p->sample_rate, p->channels,
payload_type);
break;
case AV_CODEC_ID_AMR_WB:
av_strlcatf(buff, size, "a=rtpmap:%d AMR-WB/%d/%d\r\n"
"a=fmtp:%d octet-align=1\r\n",
- payload_type, c->sample_rate, c->channels,
+ payload_type, p->sample_rate, p->channels,
payload_type);
break;
case AV_CODEC_ID_VORBIS:
- if (c->extradata_size)
- config = xiph_extradata2config(c);
+ if (p->extradata_size)
+ config = xiph_extradata2config(fmt, p);
else
- av_log(c, AV_LOG_ERROR, "Vorbis configuration info missing\n");
+ av_log(fmt, AV_LOG_ERROR, "Vorbis configuration info missing\n");
if (!config)
return NULL;
av_strlcatf(buff, size, "a=rtpmap:%d vorbis/%d/%d\r\n"
"a=fmtp:%d configuration=%s\r\n",
- payload_type, c->sample_rate, c->channels,
+ payload_type, p->sample_rate, p->channels,
payload_type, config);
break;
case AV_CODEC_ID_THEORA: {
const char *pix_fmt;
- switch (c->pix_fmt) {
+ switch (p->format) {
case AV_PIX_FMT_YUV420P:
pix_fmt = "YCbCr-4:2:0";
break;
@@ -630,14 +631,14 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
pix_fmt = "YCbCr-4:4:4";
break;
default:
- av_log(c, AV_LOG_ERROR, "Unsupported pixel format.\n");
+ av_log(fmt, AV_LOG_ERROR, "Unsupported pixel format.\n");
return NULL;
}
- if (c->extradata_size)
- config = xiph_extradata2config(c);
+ if (p->extradata_size)
+ config = xiph_extradata2config(fmt, p);
else
- av_log(c, AV_LOG_ERROR, "Theora configuation info missing\n");
+ av_log(fmt, AV_LOG_ERROR, "Theora configuation info missing\n");
if (!config)
return NULL;
@@ -646,7 +647,7 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
"width=%d; height=%d; sampling=%s; "
"configuration=%s\r\n",
payload_type, payload_type,
- c->width, c->height, pix_fmt, config);
+ p->width, p->height, pix_fmt, config);
break;
}
case AV_CODEC_ID_VP8:
@@ -662,32 +663,32 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d G722/%d/%d\r\n",
payload_type,
- 8000, c->channels);
+ 8000, p->channels);
break;
case AV_CODEC_ID_ADPCM_G726: {
if (payload_type >= RTP_PT_PRIVATE)
av_strlcatf(buff, size, "a=rtpmap:%d G726-%d/%d\r\n",
payload_type,
- c->bits_per_coded_sample*8,
- c->sample_rate);
+ p->bits_per_coded_sample*8,
+ p->sample_rate);
break;
}
case AV_CODEC_ID_ILBC:
av_strlcatf(buff, size, "a=rtpmap:%d iLBC/%d\r\n"
"a=fmtp:%d mode=%d\r\n",
- payload_type, c->sample_rate,
- payload_type, c->block_align == 38 ? 20 : 30);
+ payload_type, p->sample_rate,
+ payload_type, p->block_align == 38 ? 20 : 30);
break;
case AV_CODEC_ID_SPEEX:
av_strlcatf(buff, size, "a=rtpmap:%d speex/%d\r\n",
- payload_type, c->sample_rate);
- if (c->codec) {
+ payload_type, p->sample_rate);
+ if (st->codec) {
const char *mode;
uint64_t vad_option;
- if (c->flags & AV_CODEC_FLAG_QSCALE)
+ if (st->codec->flags & AV_CODEC_FLAG_QSCALE)
mode = "on";
- else if (!av_opt_get_int(c, "vad", AV_OPT_FLAG_ENCODING_PARAM, &vad_option) && vad_option)
+ else if (!av_opt_get_int(st->codec, "vad", AV_OPT_FLAG_ENCODING_PARAM, &vad_option) && vad_option)
mode = "vad";
else
mode = "off";
@@ -705,7 +706,7 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
receivers MUST be able to receive and process stereo packets. */
av_strlcatf(buff, size, "a=rtpmap:%d opus/48000/2\r\n",
payload_type);
- if (c->channels == 2) {
+ if (p->channels == 2) {
av_strlcatf(buff, size, "a=fmtp:%d sprop-stereo=1\r\n",
payload_type);
}
@@ -724,13 +725,13 @@ void ff_sdp_write_media(char *buff, int size, AVStream *st, int idx,
const char *dest_addr, const char *dest_type,
int port, int ttl, AVFormatContext *fmt)
{
- AVCodecContext *c = st->codec;
+ AVCodecParameters *p = st->codecpar;
const char *type;
int payload_type;
- payload_type = ff_rtp_get_payload_type(fmt, c, idx);
+ payload_type = ff_rtp_get_payload_type(fmt, st->codecpar, idx);
- switch (c->codec_type) {
+ switch (p->codec_type) {
case AVMEDIA_TYPE_VIDEO : type = "video" ; break;
case AVMEDIA_TYPE_AUDIO : type = "audio" ; break;
case AVMEDIA_TYPE_SUBTITLE: type = "text" ; break;
@@ -739,11 +740,11 @@ void ff_sdp_write_media(char *buff, int size, AVStream *st, int idx,
av_strlcatf(buff, size, "m=%s %d RTP/AVP %d\r\n", type, port, payload_type);
sdp_write_address(buff, size, dest_addr, dest_type, ttl);
- if (c->bit_rate) {
- av_strlcatf(buff, size, "b=AS:%"PRId64"\r\n", (int64_t)c->bit_rate / 1000);
+ if (p->bit_rate) {
+ av_strlcatf(buff, size, "b=AS:%"PRId64"\r\n", (int64_t)p->bit_rate / 1000);
}
- sdp_write_media_attributes(buff, size, c, payload_type, fmt);
+ sdp_write_media_attributes(buff, size, st, payload_type, fmt);
}
int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
diff --git a/libavformat/sdr2.c b/libavformat/sdr2.c
index edb454caec..c9953336c5 100644
--- a/libavformat/sdr2.c
+++ b/libavformat/sdr2.c
@@ -47,16 +47,16 @@ static int sdr2_read_header(AVFormatContext *s)
avio_skip(s->pb, 20);
avpriv_set_pts_info(st, 64, 1, avio_rl32(s->pb));
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->width = avio_rl32(s->pb);
- st->codec->height = avio_rl32(s->pb);
- st->codec->codec_id = AV_CODEC_ID_H264;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->width = avio_rl32(s->pb);
+ st->codecpar->height = avio_rl32(s->pb);
+ st->codecpar->codec_id = AV_CODEC_ID_H264;
st->need_parsing = AVSTREAM_PARSE_FULL;
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- ast->codec->channels = 1;
- ast->codec->sample_rate = 8000;
- ast->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codecpar->channels = 1;
+ ast->codecpar->sample_rate = 8000;
+ ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
avpriv_set_pts_info(ast, 64, 1, 8000);
avio_seek(s->pb, FIRST, SEEK_SET);
diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c
index 94b377215e..6ee2bd435e 100644
--- a/libavformat/segafilm.c
+++ b/libavformat/segafilm.c
@@ -150,15 +150,15 @@ static int film_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
film->video_stream_index = st->index;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = film->video_type;
- st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = AV_RB32(&scratch[16]);
- st->codec->height = AV_RB32(&scratch[12]);
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = film->video_type;
+ st->codecpar->codec_tag = 0; /* no fourcc */
+ st->codecpar->width = AV_RB32(&scratch[16]);
+ st->codecpar->height = AV_RB32(&scratch[12]);
if (film->video_type == AV_CODEC_ID_RAWVIDEO) {
if (scratch[20] == 24) {
- st->codec->pix_fmt = AV_PIX_FMT_RGB24;
+ st->codecpar->format = AV_PIX_FMT_RGB24;
} else {
av_log(s, AV_LOG_ERROR, "raw video is using unhandled %dbpp\n", scratch[20]);
return -1;
@@ -171,24 +171,24 @@ static int film_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
film->audio_stream_index = st->index;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = film->audio_type;
- st->codec->codec_tag = 1;
- st->codec->channels = film->audio_channels;
- st->codec->sample_rate = film->audio_samplerate;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = film->audio_type;
+ st->codecpar->codec_tag = 1;
+ st->codecpar->channels = film->audio_channels;
+ st->codecpar->sample_rate = film->audio_samplerate;
if (film->audio_type == AV_CODEC_ID_ADPCM_ADX) {
- st->codec->bits_per_coded_sample = 18 * 8 / 32;
- st->codec->block_align = st->codec->channels * 18;
+ st->codecpar->bits_per_coded_sample = 18 * 8 / 32;
+ st->codecpar->block_align = st->codecpar->channels * 18;
st->need_parsing = AVSTREAM_PARSE_FULL;
} else {
- st->codec->bits_per_coded_sample = film->audio_bits;
- st->codec->block_align = st->codec->channels *
- st->codec->bits_per_coded_sample / 8;
+ st->codecpar->bits_per_coded_sample = film->audio_bits;
+ st->codecpar->block_align = st->codecpar->channels *
+ st->codecpar->bits_per_coded_sample / 8;
}
- st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
- st->codec->bits_per_coded_sample;
+ st->codecpar->bit_rate = st->codecpar->channels * st->codecpar->sample_rate *
+ st->codecpar->bits_per_coded_sample;
}
/* load the sample table */
@@ -206,7 +206,7 @@ static int film_read_header(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
avpriv_set_pts_info(st, 33, 1, film->base_clock);
else
avpriv_set_pts_info(st, 64, 1, film->audio_samplerate);
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 9527c87667..6d693f8886 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -165,19 +165,19 @@ static int segment_mux_init(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
AVStream *st;
- AVCodecContext *icodec, *ocodec;
+ AVCodecParameters *ipar, *opar;
if (!(st = avformat_new_stream(oc, NULL)))
return AVERROR(ENOMEM);
- icodec = s->streams[i]->codec;
- ocodec = st->codec;
- avcodec_copy_context(ocodec, icodec);
+ ipar = s->streams[i]->codecpar;
+ opar = st->codecpar;
+ avcodec_parameters_copy(opar, ipar);
if (!oc->oformat->codec_tag ||
- av_codec_get_id (oc->oformat->codec_tag, icodec->codec_tag) == ocodec->codec_id ||
- av_codec_get_tag(oc->oformat->codec_tag, icodec->codec_id) <= 0) {
- ocodec->codec_tag = icodec->codec_tag;
+ av_codec_get_id (oc->oformat->codec_tag, ipar->codec_tag) == opar->codec_id ||
+ av_codec_get_tag(oc->oformat->codec_tag, ipar->codec_id) <= 0) {
+ opar->codec_tag = ipar->codec_tag;
} else {
- ocodec->codec_tag = 0;
+ opar->codec_tag = 0;
}
st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
st->time_base = s->streams[i]->time_base;
@@ -408,7 +408,7 @@ static int segment_end(AVFormatContext *s, int write_trailer, int is_last)
if (tcr) {
/* search the first video stream */
for (i = 0; i < s->nb_streams; i++) {
- if (s->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (s->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
rate = s->streams[i]->avg_frame_rate;/* Get fps from the video stream */
err = av_timecode_init_from_string(&tc, rate, tcr->value, s);
if (err < 0) {
@@ -592,7 +592,7 @@ static int select_reference_stream(AVFormatContext *s)
/* select first index for each type */
for (i = 0; i < s->nb_streams; i++) {
- type = s->streams[i]->codec->codec_type;
+ type = s->streams[i]->codecpar->codec_type;
if ((unsigned)type < AVMEDIA_TYPE_NB && type_index_map[type] == -1
/* ignore attached pictures/cover art streams */
&& !(s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC))
@@ -715,7 +715,7 @@ static int seg_init(AVFormatContext *s)
goto fail;
av_log(s, AV_LOG_VERBOSE, "Selected stream id:%d type:%s\n",
seg->reference_stream_index,
- av_get_media_type_string(s->streams[seg->reference_stream_index]->codec->codec_type));
+ av_get_media_type_string(s->streams[seg->reference_stream_index]->codecpar->codec_type));
seg->oformat = av_guess_format(seg->format, s->filename, NULL);
diff --git a/libavformat/sierravmd.c b/libavformat/sierravmd.c
index 2ab0e38a1c..882f70e9ee 100644
--- a/libavformat/sierravmd.c
+++ b/libavformat/sierravmd.c
@@ -118,18 +118,18 @@ static int vmd_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avpriv_set_pts_info(vst, 33, 1, 10);
vmd->video_stream_index = vst->index;
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_id = vmd->is_indeo3 ? AV_CODEC_ID_INDEO3 : AV_CODEC_ID_VMDVIDEO;
- vst->codec->codec_tag = 0; /* no fourcc */
- vst->codec->width = width;
- vst->codec->height = height;
- if(vmd->is_indeo3 && vst->codec->width > 320){
- vst->codec->width >>= 1;
- vst->codec->height >>= 1;
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_id = vmd->is_indeo3 ? AV_CODEC_ID_INDEO3 : AV_CODEC_ID_VMDVIDEO;
+ vst->codecpar->codec_tag = 0; /* no fourcc */
+ vst->codecpar->width = width;
+ vst->codecpar->height = height;
+ if(vmd->is_indeo3 && vst->codecpar->width > 320){
+ vst->codecpar->width >>= 1;
+ vst->codecpar->height >>= 1;
}
- if (ff_alloc_extradata(vst->codec, VMD_HEADER_SIZE))
+ if (ff_alloc_extradata(vst->codecpar, VMD_HEADER_SIZE))
return AVERROR(ENOMEM);
- memcpy(vst->codec->extradata, vmd->vmd_header, VMD_HEADER_SIZE);
+ memcpy(vst->codecpar->extradata, vmd->vmd_header, VMD_HEADER_SIZE);
}
/* if sample rate is 0, assume no audio */
@@ -139,30 +139,30 @@ static int vmd_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
vmd->audio_stream_index = st->index;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_VMDAUDIO;
- st->codec->codec_tag = 0; /* no fourcc */
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_VMDAUDIO;
+ st->codecpar->codec_tag = 0; /* no fourcc */
if (vmd->vmd_header[811] & 0x80) {
- 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 = vmd->sample_rate;
- st->codec->block_align = AV_RL16(&vmd->vmd_header[806]);
- if (st->codec->block_align & 0x8000) {
- st->codec->bits_per_coded_sample = 16;
- st->codec->block_align = -(st->codec->block_align - 0x10000);
+ st->codecpar->sample_rate = vmd->sample_rate;
+ st->codecpar->block_align = AV_RL16(&vmd->vmd_header[806]);
+ if (st->codecpar->block_align & 0x8000) {
+ st->codecpar->bits_per_coded_sample = 16;
+ st->codecpar->block_align = -(st->codecpar->block_align - 0x10000);
} else {
- st->codec->bits_per_coded_sample = 8;
+ st->codecpar->bits_per_coded_sample = 8;
}
- st->codec->bit_rate = st->codec->sample_rate *
- st->codec->bits_per_coded_sample * st->codec->channels;
+ st->codecpar->bit_rate = st->codecpar->sample_rate *
+ st->codecpar->bits_per_coded_sample * st->codecpar->channels;
/* calculate pts */
- num = st->codec->block_align;
- den = st->codec->sample_rate * st->codec->channels;
+ num = st->codecpar->block_align;
+ den = st->codecpar->sample_rate * st->codecpar->channels;
av_reduce(&num, &den, num, den, (1UL<<31)-1);
if (vst)
avpriv_set_pts_info(vst, 33, num, den);
diff --git a/libavformat/siff.c b/libavformat/siff.c
index 028f18be16..ddd1715680 100644
--- a/libavformat/siff.c
+++ b/libavformat/siff.c
@@ -78,12 +78,12 @@ static int create_audio_stream(AVFormatContext *s, SIFFContext *c)
ast = avformat_new_stream(s, NULL);
if (!ast)
return AVERROR(ENOMEM);
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- ast->codec->codec_id = AV_CODEC_ID_PCM_U8;
- ast->codec->channels = 1;
- ast->codec->channel_layout = AV_CH_LAYOUT_MONO;
- ast->codec->bits_per_coded_sample = 8;
- ast->codec->sample_rate = c->rate;
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
+ ast->codecpar->channels = 1;
+ ast->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+ ast->codecpar->bits_per_coded_sample = 8;
+ ast->codecpar->sample_rate = c->rate;
avpriv_set_pts_info(ast, 16, 1, c->rate);
ast->start_time = 0;
return 0;
@@ -123,14 +123,14 @@ static int siff_parse_vbv1(AVFormatContext *s, SIFFContext *c, AVIOContext *pb)
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_VB;
- st->codec->codec_tag = MKTAG('V', 'B', 'V', '1');
- st->codec->width = width;
- st->codec->height = height;
- st->codec->pix_fmt = AV_PIX_FMT_PAL8;
- st->nb_frames =
- st->duration = c->frames;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_VB;
+ st->codecpar->codec_tag = MKTAG('V', 'B', 'V', '1');
+ st->codecpar->width = width;
+ st->codecpar->height = height;
+ st->codecpar->format = AV_PIX_FMT_PAL8;
+ st->nb_frames =
+ st->duration = c->frames;
avpriv_set_pts_info(st, 16, 1, 12);
c->cur_frame = 0;
diff --git a/libavformat/smacker.c b/libavformat/smacker.c
index de8bbdb07a..8a21cc0767 100644
--- a/libavformat/smacker.c
+++ b/libavformat/smacker.c
@@ -175,12 +175,12 @@ static int smacker_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
smk->videoindex = st->index;
- st->codec->width = smk->width;
- st->codec->height = smk->height;
- st->codec->pix_fmt = AV_PIX_FMT_PAL8;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_SMACKVIDEO;
- st->codec->codec_tag = smk->magic;
+ st->codecpar->width = smk->width;
+ st->codecpar->height = smk->height;
+ st->codecpar->format = AV_PIX_FMT_PAL8;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_SMACKVIDEO;
+ st->codecpar->codec_tag = smk->magic;
/* Smacker uses 100000 as internal timebase */
if(smk->pts_inc < 0)
smk->pts_inc = -smk->pts_inc;
@@ -198,36 +198,36 @@ static int smacker_read_header(AVFormatContext *s)
if (!ast[i])
return AVERROR(ENOMEM);
smk->indexes[i] = ast[i]->index;
- ast[i]->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
if (smk->aflags[i] & SMK_AUD_BINKAUD) {
- ast[i]->codec->codec_id = AV_CODEC_ID_BINKAUDIO_RDFT;
+ ast[i]->codecpar->codec_id = AV_CODEC_ID_BINKAUDIO_RDFT;
} else if (smk->aflags[i] & SMK_AUD_USEDCT) {
- ast[i]->codec->codec_id = AV_CODEC_ID_BINKAUDIO_DCT;
+ ast[i]->codecpar->codec_id = AV_CODEC_ID_BINKAUDIO_DCT;
} else if (smk->aflags[i] & SMK_AUD_PACKED){
- ast[i]->codec->codec_id = AV_CODEC_ID_SMACKAUDIO;
- ast[i]->codec->codec_tag = MKTAG('S', 'M', 'K', 'A');
+ ast[i]->codecpar->codec_id = AV_CODEC_ID_SMACKAUDIO;
+ ast[i]->codecpar->codec_tag = MKTAG('S', 'M', 'K', 'A');
} else {
- ast[i]->codec->codec_id = AV_CODEC_ID_PCM_U8;
+ ast[i]->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
}
if (smk->aflags[i] & SMK_AUD_STEREO) {
- ast[i]->codec->channels = 2;
- ast[i]->codec->channel_layout = AV_CH_LAYOUT_STEREO;
+ ast[i]->codecpar->channels = 2;
+ ast[i]->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
} else {
- ast[i]->codec->channels = 1;
- ast[i]->codec->channel_layout = AV_CH_LAYOUT_MONO;
+ ast[i]->codecpar->channels = 1;
+ ast[i]->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
}
- ast[i]->codec->sample_rate = smk->rates[i];
- ast[i]->codec->bits_per_coded_sample = (smk->aflags[i] & SMK_AUD_16BITS) ? 16 : 8;
- if(ast[i]->codec->bits_per_coded_sample == 16 && ast[i]->codec->codec_id == AV_CODEC_ID_PCM_U8)
- ast[i]->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
- avpriv_set_pts_info(ast[i], 64, 1, ast[i]->codec->sample_rate
- * ast[i]->codec->channels * ast[i]->codec->bits_per_coded_sample / 8);
+ ast[i]->codecpar->sample_rate = smk->rates[i];
+ ast[i]->codecpar->bits_per_coded_sample = (smk->aflags[i] & SMK_AUD_16BITS) ? 16 : 8;
+ if(ast[i]->codecpar->bits_per_coded_sample == 16 && ast[i]->codecpar->codec_id == AV_CODEC_ID_PCM_U8)
+ ast[i]->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
+ avpriv_set_pts_info(ast[i], 64, 1, ast[i]->codecpar->sample_rate
+ * ast[i]->codecpar->channels * ast[i]->codecpar->bits_per_coded_sample / 8);
}
}
/* load trees to extradata, they will be unpacked by decoder */
- if(ff_alloc_extradata(st->codec, smk->treesize + 16)){
+ if(ff_alloc_extradata(st->codecpar, smk->treesize + 16)){
av_log(s, AV_LOG_ERROR,
"Cannot allocate %"PRIu32" bytes of extradata\n",
smk->treesize + 16);
@@ -235,16 +235,16 @@ static int smacker_read_header(AVFormatContext *s)
av_freep(&smk->frm_flags);
return AVERROR(ENOMEM);
}
- ret = avio_read(pb, st->codec->extradata + 16, st->codec->extradata_size - 16);
- if(ret != st->codec->extradata_size - 16){
+ ret = avio_read(pb, st->codecpar->extradata + 16, st->codecpar->extradata_size - 16);
+ if(ret != st->codecpar->extradata_size - 16){
av_freep(&smk->frm_size);
av_freep(&smk->frm_flags);
return AVERROR(EIO);
}
- ((int32_t*)st->codec->extradata)[0] = av_le2ne32(smk->mmap_size);
- ((int32_t*)st->codec->extradata)[1] = av_le2ne32(smk->mclr_size);
- ((int32_t*)st->codec->extradata)[2] = av_le2ne32(smk->full_size);
- ((int32_t*)st->codec->extradata)[3] = av_le2ne32(smk->type_size);
+ ((int32_t*)st->codecpar->extradata)[0] = av_le2ne32(smk->mmap_size);
+ ((int32_t*)st->codecpar->extradata)[1] = av_le2ne32(smk->mclr_size);
+ ((int32_t*)st->codecpar->extradata)[2] = av_le2ne32(smk->full_size);
+ ((int32_t*)st->codecpar->extradata)[3] = av_le2ne32(smk->type_size);
smk->curstream = -1;
smk->nextpos = avio_tell(pb);
diff --git a/libavformat/smjpegdec.c b/libavformat/smjpegdec.c
index 99ca2ff8c9..c184c0d9fd 100644
--- a/libavformat/smjpegdec.c
+++ b/libavformat/smjpegdec.c
@@ -88,13 +88,13 @@ static int smjpeg_read_header(AVFormatContext *s)
ast = avformat_new_stream(s, 0);
if (!ast)
return AVERROR(ENOMEM);
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- ast->codec->sample_rate = avio_rb16(pb);
- ast->codec->bits_per_coded_sample = avio_r8(pb);
- ast->codec->channels = avio_r8(pb);
- ast->codec->codec_tag = avio_rl32(pb);
- ast->codec->codec_id = ff_codec_get_id(ff_codec_smjpeg_audio_tags,
- ast->codec->codec_tag);
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codecpar->sample_rate = avio_rb16(pb);
+ ast->codecpar->bits_per_coded_sample = avio_r8(pb);
+ ast->codecpar->channels = avio_r8(pb);
+ ast->codecpar->codec_tag = avio_rl32(pb);
+ ast->codecpar->codec_id = ff_codec_get_id(ff_codec_smjpeg_audio_tags,
+ ast->codecpar->codec_tag);
ast->duration = duration;
sc->audio_stream_index = ast->index;
avpriv_set_pts_info(ast, 32, 1, 1000);
@@ -111,13 +111,13 @@ static int smjpeg_read_header(AVFormatContext *s)
vst = avformat_new_stream(s, 0);
if (!vst)
return AVERROR(ENOMEM);
- vst->nb_frames = avio_rb32(pb);
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->width = avio_rb16(pb);
- vst->codec->height = avio_rb16(pb);
- vst->codec->codec_tag = avio_rl32(pb);
- vst->codec->codec_id = ff_codec_get_id(ff_codec_smjpeg_video_tags,
- vst->codec->codec_tag);
+ vst->nb_frames = avio_rb32(pb);
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->width = avio_rb16(pb);
+ vst->codecpar->height = avio_rb16(pb);
+ vst->codecpar->codec_tag = avio_rl32(pb);
+ vst->codecpar->codec_id = ff_codec_get_id(ff_codec_smjpeg_video_tags,
+ vst->codecpar->codec_tag);
vst->duration = duration;
sc->video_stream_index = vst->index;
avpriv_set_pts_info(vst, 32, 1, 1000);
diff --git a/libavformat/smjpegenc.c b/libavformat/smjpegenc.c
index 4553c8624c..314593a5c9 100644
--- a/libavformat/smjpegenc.c
+++ b/libavformat/smjpegenc.c
@@ -57,22 +57,22 @@ static int smjpeg_write_header(AVFormatContext *s)
for (n = 0; n < s->nb_streams; n++) {
AVStream *st = s->streams[n];
- AVCodecContext *codec = st->codec;
- if (codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- tag = ff_codec_get_tag(ff_codec_smjpeg_audio_tags, codec->codec_id);
+ AVCodecParameters *par = st->codecpar;
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
+ tag = ff_codec_get_tag(ff_codec_smjpeg_audio_tags, par->codec_id);
if (!tag) {
av_log(s, AV_LOG_ERROR, "unsupported audio codec\n");
return AVERROR(EINVAL);
}
avio_wl32(pb, SMJPEG_SND);
avio_wb32(pb, 8);
- avio_wb16(pb, codec->sample_rate);
- avio_w8(pb, codec->bits_per_coded_sample);
- avio_w8(pb, codec->channels);
+ avio_wb16(pb, par->sample_rate);
+ avio_w8(pb, par->bits_per_coded_sample);
+ avio_w8(pb, par->channels);
avio_wl32(pb, tag);
avpriv_set_pts_info(st, 32, 1, 1000);
- } else if (codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- tag = ff_codec_get_tag(ff_codec_smjpeg_video_tags, codec->codec_id);
+ } else if (par->codec_type == AVMEDIA_TYPE_VIDEO) {
+ tag = ff_codec_get_tag(ff_codec_smjpeg_video_tags, par->codec_id);
if (!tag) {
av_log(s, AV_LOG_ERROR, "unsupported video codec\n");
return AVERROR(EINVAL);
@@ -80,8 +80,8 @@ static int smjpeg_write_header(AVFormatContext *s)
avio_wl32(pb, SMJPEG_VID);
avio_wb32(pb, 12);
avio_wb32(pb, 0);
- avio_wb16(pb, codec->width);
- avio_wb16(pb, codec->height);
+ avio_wb16(pb, par->width);
+ avio_wb16(pb, par->height);
avio_wl32(pb, tag);
avpriv_set_pts_info(st, 32, 1, 1000);
}
@@ -98,11 +98,11 @@ static int smjpeg_write_packet(AVFormatContext *s, AVPacket *pkt)
SMJPEGMuxContext *smc = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st = s->streams[pkt->stream_index];
- AVCodecContext *codec = st->codec;
+ AVCodecParameters *par = st->codecpar;
- if (codec->codec_type == AVMEDIA_TYPE_AUDIO)
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO)
avio_wl32(pb, SMJPEG_SNDD);
- else if (codec->codec_type == AVMEDIA_TYPE_VIDEO)
+ else if (par->codec_type == AVMEDIA_TYPE_VIDEO)
avio_wl32(pb, SMJPEG_VIDD);
else
return 0;
diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index 5333ba86c7..193c360db1 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -146,14 +146,14 @@ static int64_t ism_seek(void *opaque, int64_t offset, int whence)
static void get_private_data(OutputStream *os)
{
- AVCodecContext *codec = os->ctx->streams[0]->codec;
- uint8_t *ptr = codec->extradata;
- int size = codec->extradata_size;
+ AVCodecParameters *par = os->ctx->streams[0]->codecpar;
+ uint8_t *ptr = par->extradata;
+ int size = par->extradata_size;
int i;
- if (codec->codec_id == AV_CODEC_ID_H264) {
+ if (par->codec_id == AV_CODEC_ID_H264) {
ff_avc_write_annexb_extradata(ptr, &ptr, &size);
if (!ptr)
- ptr = codec->extradata;
+ ptr = par->extradata;
}
if (!ptr)
return;
@@ -163,7 +163,7 @@ static void get_private_data(OutputStream *os)
for (i = 0; i < size; i++)
snprintf(&os->private_str[2*i], 3, "%02x", ptr[i]);
fail:
- if (ptr != codec->extradata)
+ if (ptr != par->extradata)
av_free(ptr);
}
@@ -235,7 +235,7 @@ static int write_manifest(AVFormatContext *s, int final)
Fragment *last = os->fragments[os->nb_fragments - 1];
duration = last->start_time + last->duration;
}
- if (s->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (s->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
video_chunks = os->nb_fragments;
video_streams++;
} else {
@@ -260,10 +260,10 @@ static int write_manifest(AVFormatContext *s, int final)
avio_printf(out, "<StreamIndex Type=\"video\" QualityLevels=\"%d\" Chunks=\"%d\" Url=\"QualityLevels({bitrate})/Fragments(video={start time})\">\n", video_streams, video_chunks);
for (i = 0; i < s->nb_streams; i++) {
OutputStream *os = &c->streams[i];
- if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_VIDEO)
+ if (s->streams[i]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
continue;
last = i;
- avio_printf(out, "<QualityLevel Index=\"%d\" Bitrate=\"%"PRId64"\" FourCC=\"%s\" MaxWidth=\"%d\" MaxHeight=\"%d\" CodecPrivateData=\"%s\" />\n", index, (int64_t)s->streams[i]->codec->bit_rate, os->fourcc, s->streams[i]->codec->width, s->streams[i]->codec->height, os->private_str);
+ avio_printf(out, "<QualityLevel Index=\"%d\" Bitrate=\"%"PRId64"\" FourCC=\"%s\" MaxWidth=\"%d\" MaxHeight=\"%d\" CodecPrivateData=\"%s\" />\n", index, (int64_t)s->streams[i]->codecpar->bit_rate, os->fourcc, s->streams[i]->codecpar->width, s->streams[i]->codecpar->height, os->private_str);
index++;
}
output_chunk_list(&c->streams[last], out, final, c->lookahead_count, c->window_size);
@@ -274,10 +274,10 @@ static int write_manifest(AVFormatContext *s, int final)
avio_printf(out, "<StreamIndex Type=\"audio\" QualityLevels=\"%d\" Chunks=\"%d\" Url=\"QualityLevels({bitrate})/Fragments(audio={start time})\">\n", audio_streams, audio_chunks);
for (i = 0; i < s->nb_streams; i++) {
OutputStream *os = &c->streams[i];
- if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_AUDIO)
+ if (s->streams[i]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
continue;
last = i;
- avio_printf(out, "<QualityLevel Index=\"%d\" Bitrate=\"%"PRId64"\" FourCC=\"%s\" SamplingRate=\"%d\" Channels=\"%d\" BitsPerSample=\"16\" PacketSize=\"%d\" AudioTag=\"%d\" CodecPrivateData=\"%s\" />\n", index, (int64_t)s->streams[i]->codec->bit_rate, os->fourcc, s->streams[i]->codec->sample_rate, s->streams[i]->codec->channels, os->packet_size, os->audio_tag, os->private_str);
+ avio_printf(out, "<QualityLevel Index=\"%d\" Bitrate=\"%"PRId64"\" FourCC=\"%s\" SamplingRate=\"%d\" Channels=\"%d\" BitsPerSample=\"16\" PacketSize=\"%d\" AudioTag=\"%d\" CodecPrivateData=\"%s\" />\n", index, (int64_t)s->streams[i]->codecpar->bit_rate, os->fourcc, s->streams[i]->codecpar->sample_rate, s->streams[i]->codecpar->channels, os->packet_size, os->audio_tag, os->private_str);
index++;
}
output_chunk_list(&c->streams[last], out, final, c->lookahead_count, c->window_size);
@@ -319,12 +319,12 @@ static int ism_write_header(AVFormatContext *s)
AVStream *st;
AVDictionary *opts = NULL;
- if (!s->streams[i]->codec->bit_rate) {
+ if (!s->streams[i]->codecpar->bit_rate) {
av_log(s, AV_LOG_ERROR, "No bit rate set for stream %d\n", i);
ret = AVERROR(EINVAL);
goto fail;
}
- snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(%"PRId64")", s->filename, (int64_t)s->streams[i]->codec->bit_rate);
+ snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(%"PRId64")", s->filename, (int64_t)s->streams[i]->codecpar->bit_rate);
if (mkdir(os->dirname, 0777) == -1 && errno != EEXIST) {
ret = AVERROR(errno);
av_log(s, AV_LOG_ERROR, "mkdir failed\n");
@@ -344,7 +344,7 @@ static int ism_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;
@@ -363,12 +363,12 @@ static int ism_write_header(AVFormatContext *s)
avio_flush(ctx->pb);
av_dict_free(&opts);
s->streams[i]->time_base = st->time_base;
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
c->has_video = 1;
os->stream_type_tag = "video";
- if (st->codec->codec_id == AV_CODEC_ID_H264) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
os->fourcc = "H264";
- } else if (st->codec->codec_id == AV_CODEC_ID_VC1) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_VC1) {
os->fourcc = "WVC1";
} else {
av_log(s, AV_LOG_ERROR, "Unsupported video codec\n");
@@ -378,10 +378,10 @@ static int ism_write_header(AVFormatContext *s)
} else {
c->has_audio = 1;
os->stream_type_tag = "audio";
- if (st->codec->codec_id == AV_CODEC_ID_AAC) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
os->fourcc = "AACL";
os->audio_tag = 0xff;
- } else if (st->codec->codec_id == AV_CODEC_ID_WMAPRO) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_WMAPRO) {
os->fourcc = "WMAP";
os->audio_tag = 0x0162;
} else {
@@ -389,7 +389,7 @@ static int ism_write_header(AVFormatContext *s)
ret = AVERROR(EINVAL);
goto fail;
}
- os->packet_size = st->codec->block_align ? st->codec->block_align : 4;
+ os->packet_size = st->codecpar->block_align ? st->codecpar->block_align : 4;
}
get_private_data(os);
}
@@ -588,7 +588,7 @@ static int ism_write_packet(AVFormatContext *s, AVPacket *pkt)
if (st->first_dts == AV_NOPTS_VALUE)
st->first_dts = pkt->dts;
- if ((!c->has_video || st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&
+ if ((!c->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) {
diff --git a/libavformat/smush.c b/libavformat/smush.c
index abb6989fe4..5a9249ac4f 100644
--- a/libavformat/smush.c
+++ b/libavformat/smush.c
@@ -151,19 +151,19 @@ static int smush_read_header(AVFormatContext *ctx)
vst->duration =
vst->nb_frames = nframes;
vst->avg_frame_rate = av_inv_q(vst->time_base);
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_id = AV_CODEC_ID_SANM;
- vst->codec->codec_tag = 0;
- vst->codec->width = width;
- vst->codec->height = height;
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_id = AV_CODEC_ID_SANM;
+ vst->codecpar->codec_tag = 0;
+ vst->codecpar->width = width;
+ vst->codecpar->height = height;
if (!smush->version) {
- if (ff_alloc_extradata(vst->codec, 1024 + 2))
+ if (ff_alloc_extradata(vst->codecpar, 1024 + 2))
return AVERROR(ENOMEM);
- AV_WL16(vst->codec->extradata, subversion);
+ AV_WL16(vst->codecpar->extradata, subversion);
for (i = 0; i < 256; i++)
- AV_WL32(vst->codec->extradata + 2 + i * 4, palette[i]);
+ AV_WL32(vst->codecpar->extradata + 2 + i * 4, palette[i]);
}
if (got_audio) {
@@ -174,13 +174,13 @@ static int smush_read_header(AVFormatContext *ctx)
smush->audio_stream_index = ast->index;
ast->start_time = 0;
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- ast->codec->codec_id = AV_CODEC_ID_ADPCM_VIMA;
- ast->codec->codec_tag = 0;
- ast->codec->sample_rate = sample_rate;
- ast->codec->channels = channels;
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codecpar->codec_id = AV_CODEC_ID_ADPCM_VIMA;
+ ast->codecpar->codec_tag = 0;
+ ast->codecpar->sample_rate = sample_rate;
+ ast->codecpar->channels = channels;
- avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
+ avpriv_set_pts_info(ast, 64, 1, ast->codecpar->sample_rate);
}
return 0;
diff --git a/libavformat/sol.c b/libavformat/sol.c
index c9434535ef..5796f8d234 100644
--- a/libavformat/sol.c
+++ b/libavformat/sol.c
@@ -110,13 +110,13 @@ static int sol_read_header(AVFormatContext *s)
st = avformat_new_stream(s, NULL);
if (!st)
return -1;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_tag = id;
- st->codec->codec_id = codec;
- st->codec->channels = channels;
- st->codec->channel_layout = channels == 1 ? AV_CH_LAYOUT_MONO :
- AV_CH_LAYOUT_STEREO;
- st->codec->sample_rate = rate;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_tag = id;
+ st->codecpar->codec_id = codec;
+ st->codecpar->channels = channels;
+ st->codecpar->channel_layout = channels == 1 ? AV_CH_LAYOUT_MONO :
+ AV_CH_LAYOUT_STEREO;
+ st->codecpar->sample_rate = rate;
avpriv_set_pts_info(st, 64, 1, rate);
return 0;
}
diff --git a/libavformat/soxdec.c b/libavformat/soxdec.c
index aec42843cb..0a937e7cc7 100644
--- a/libavformat/soxdec.c
+++ b/libavformat/soxdec.c
@@ -55,21 +55,21 @@ static int sox_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
if (avio_rl32(pb) == SOX_TAG) {
- st->codec->codec_id = AV_CODEC_ID_PCM_S32LE;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE;
header_size = avio_rl32(pb);
avio_skip(pb, 8); /* sample count */
sample_rate = av_int2double(avio_rl64(pb));
- st->codec->channels = avio_rl32(pb);
+ st->codecpar->channels = avio_rl32(pb);
comment_size = avio_rl32(pb);
} else {
- st->codec->codec_id = AV_CODEC_ID_PCM_S32BE;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S32BE;
header_size = avio_rb32(pb);
avio_skip(pb, 8); /* sample count */
sample_rate = av_int2double(avio_rb64(pb));
- st->codec->channels = avio_rb32(pb);
+ st->codecpar->channels = avio_rb32(pb);
comment_size = avio_rb32(pb);
}
@@ -90,7 +90,7 @@ static int sox_read_header(AVFormatContext *s)
sample_rate_frac);
if ((header_size + 4) & 7 || header_size < SOX_FIXED_HDR + comment_size
- || st->codec->channels > 65535) /* Reserve top 16 bits */ {
+ || st->codecpar->channels > 65535) /* Reserve top 16 bits */ {
av_log(s, AV_LOG_ERROR, "invalid header\n");
return AVERROR_INVALIDDATA;
}
@@ -111,15 +111,15 @@ static int sox_read_header(AVFormatContext *s)
avio_skip(pb, header_size - SOX_FIXED_HDR - comment_size);
- st->codec->sample_rate = sample_rate;
- st->codec->bits_per_coded_sample = 32;
- st->codec->bit_rate = st->codec->sample_rate *
- st->codec->bits_per_coded_sample *
- st->codec->channels;
- st->codec->block_align = st->codec->bits_per_coded_sample *
- st->codec->channels / 8;
+ st->codecpar->sample_rate = sample_rate;
+ st->codecpar->bits_per_coded_sample = 32;
+ st->codecpar->bit_rate = st->codecpar->sample_rate *
+ st->codecpar->bits_per_coded_sample *
+ st->codecpar->channels;
+ st->codecpar->block_align = st->codecpar->bits_per_coded_sample *
+ st->codecpar->channels / 8;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
diff --git a/libavformat/soxenc.c b/libavformat/soxenc.c
index bfa90025e1..b307157856 100644
--- a/libavformat/soxenc.c
+++ b/libavformat/soxenc.c
@@ -45,7 +45,7 @@ static int sox_write_header(AVFormatContext *s)
{
SoXContext *sox = s->priv_data;
AVIOContext *pb = s->pb;
- AVCodecContext *enc = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
AVDictionaryEntry *comment;
size_t comment_len = 0, comment_size;
@@ -56,19 +56,19 @@ static int sox_write_header(AVFormatContext *s)
sox->header_size = SOX_FIXED_HDR + comment_size;
- if (enc->codec_id == AV_CODEC_ID_PCM_S32LE) {
+ if (par->codec_id == AV_CODEC_ID_PCM_S32LE) {
ffio_wfourcc(pb, ".SoX");
avio_wl32(pb, sox->header_size);
avio_wl64(pb, 0); /* number of samples */
- avio_wl64(pb, av_double2int(enc->sample_rate));
- avio_wl32(pb, enc->channels);
+ avio_wl64(pb, av_double2int(par->sample_rate));
+ avio_wl32(pb, par->channels);
avio_wl32(pb, comment_size);
- } else if (enc->codec_id == AV_CODEC_ID_PCM_S32BE) {
+ } else if (par->codec_id == AV_CODEC_ID_PCM_S32BE) {
ffio_wfourcc(pb, "XoS.");
avio_wb32(pb, sox->header_size);
avio_wb64(pb, 0); /* number of samples */
- avio_wb64(pb, av_double2int(enc->sample_rate));
- avio_wb32(pb, enc->channels);
+ avio_wb64(pb, av_double2int(par->sample_rate));
+ avio_wb32(pb, par->channels);
avio_wb32(pb, comment_size);
} else {
av_log(s, AV_LOG_ERROR, "invalid codec; use pcm_s32le or pcm_s32be\n");
@@ -89,14 +89,14 @@ static int sox_write_trailer(AVFormatContext *s)
{
SoXContext *sox = s->priv_data;
AVIOContext *pb = s->pb;
- AVCodecContext *enc = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
if (s->pb->seekable) {
/* update number of samples */
int64_t file_size = avio_tell(pb);
int64_t num_samples = (file_size - sox->header_size - 4LL) >> 2LL;
avio_seek(pb, 8, SEEK_SET);
- if (enc->codec_id == AV_CODEC_ID_PCM_S32LE) {
+ if (par->codec_id == AV_CODEC_ID_PCM_S32LE) {
avio_wl64(pb, num_samples);
} else
avio_wb64(pb, num_samples);
diff --git a/libavformat/spdifdec.c b/libavformat/spdifdec.c
index a2f06a9746..f7288376f6 100644
--- a/libavformat/spdifdec.c
+++ b/libavformat/spdifdec.c
@@ -215,17 +215,17 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
av_packet_unref(pkt);
return AVERROR(ENOMEM);
}
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = codec_id;
- } else if (codec_id != s->streams[0]->codec->codec_id) {
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = codec_id;
+ } else if (codec_id != s->streams[0]->codecpar->codec_id) {
avpriv_report_missing_feature(s, "Codec change in IEC 61937");
return AVERROR_PATCHWELCOME;
}
- if (!s->bit_rate && s->streams[0]->codec->sample_rate)
+ if (!s->bit_rate && s->streams[0]->codecpar->sample_rate)
/* stream bitrate matches 16-bit stereo PCM bitrate for currently
supported codecs */
- s->bit_rate = 2 * 16 * s->streams[0]->codec->sample_rate;
+ s->bit_rate = 2 * 16 * s->streams[0]->codecpar->sample_rate;
return 0;
}
diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c
index 64c5f38875..978803874b 100644
--- a/libavformat/spdifenc.c
+++ b/libavformat/spdifenc.c
@@ -444,7 +444,7 @@ static int spdif_write_header(AVFormatContext *s)
{
IEC61937Context *ctx = s->priv_data;
- switch (s->streams[0]->codec->codec_id) {
+ switch (s->streams[0]->codecpar->codec_id) {
case AV_CODEC_ID_AC3:
ctx->header_info = spdif_header_ac3;
break;
diff --git a/libavformat/srtdec.c b/libavformat/srtdec.c
index 3734d39d3b..585aa6a4c3 100644
--- a/libavformat/srtdec.c
+++ b/libavformat/srtdec.c
@@ -135,8 +135,8 @@ static int srt_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 1000);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_SUBRIP;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_SUBRIP;
av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
diff --git a/libavformat/srtenc.c b/libavformat/srtenc.c
index 24c25ec643..d811a4da0e 100644
--- a/libavformat/srtenc.c
+++ b/libavformat/srtenc.c
@@ -39,16 +39,16 @@ static int srt_write_header(AVFormatContext *avf)
SRTContext *srt = avf->priv_data;
if (avf->nb_streams != 1 ||
- avf->streams[0]->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) {
+ avf->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) {
av_log(avf, AV_LOG_ERROR,
"SRT supports only a single subtitles stream.\n");
return AVERROR(EINVAL);
}
- if (avf->streams[0]->codec->codec_id != AV_CODEC_ID_TEXT &&
- avf->streams[0]->codec->codec_id != AV_CODEC_ID_SUBRIP) {
+ if (avf->streams[0]->codecpar->codec_id != AV_CODEC_ID_TEXT &&
+ avf->streams[0]->codecpar->codec_id != AV_CODEC_ID_SUBRIP) {
av_log(avf, AV_LOG_ERROR,
"Unsupported subtitles codec: %s\n",
- avcodec_get_name(avf->streams[0]->codec->codec_id));
+ avcodec_get_name(avf->streams[0]->codecpar->codec_id));
return AVERROR(EINVAL);
}
avpriv_set_pts_info(avf->streams[0], 64, 1, 1000);
diff --git a/libavformat/stldec.c b/libavformat/stldec.c
index 8b1f0a6d5b..35de49322c 100644
--- a/libavformat/stldec.c
+++ b/libavformat/stldec.c
@@ -77,8 +77,8 @@ static int stl_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 100);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_STL;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_STL;
while (!avio_feof(s->pb)) {
char line[4096];
diff --git a/libavformat/subviewer1dec.c b/libavformat/subviewer1dec.c
index 93db4ebf21..e579d1ca9a 100644
--- a/libavformat/subviewer1dec.c
+++ b/libavformat/subviewer1dec.c
@@ -50,8 +50,8 @@ static int subviewer1_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 1);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_SUBVIEWER1;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_SUBVIEWER1;
while (!avio_feof(s->pb)) {
char line[4096];
diff --git a/libavformat/subviewerdec.c b/libavformat/subviewerdec.c
index d4b2fdf456..af084f4856 100644
--- a/libavformat/subviewerdec.c
+++ b/libavformat/subviewerdec.c
@@ -79,8 +79,8 @@ static int subviewer_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 100);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_SUBVIEWER;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_SUBVIEWER;
av_bprint_init(&header, 0, AV_BPRINT_SIZE_UNLIMITED);
@@ -101,11 +101,11 @@ static int subviewer_read_header(AVFormatContext *s)
strstr(line, "[FONT]") || strstr(line, "[STYLE]"))
continue;
- if (!st->codec->extradata) { // header not finalized yet
+ if (!st->codecpar->extradata) { // header not finalized yet
av_bprintf(&header, "%s\n", line);
if (!strncmp(line, "[END INFORMATION]", 17) || !strncmp(line, "[SUBTITLE]", 10)) {
/* end of header */
- res = avpriv_bprint_to_extradata(st->codec, &header);
+ res = ff_bprint_to_codecpar_extradata(st->codecpar, &header);
if (res < 0)
goto end;
} else if (strncmp(line, "[INFORMATION]", 13)) {
diff --git a/libavformat/supdec.c b/libavformat/supdec.c
index 48083b2c53..0930dbcef2 100644
--- a/libavformat/supdec.c
+++ b/libavformat/supdec.c
@@ -27,8 +27,8 @@ static int sup_read_header(AVFormatContext *s)
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_HDMV_PGS_SUBTITLE;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_HDMV_PGS_SUBTITLE;
avpriv_set_pts_info(st, 32, 1, 90000);
return 0;
diff --git a/libavformat/svag.c b/libavformat/svag.c
index 08fc06b1ba..828b853483 100644
--- a/libavformat/svag.c
+++ b/libavformat/svag.c
@@ -42,30 +42,30 @@ static int svag_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
size = avio_rl32(s->pb);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_ADPCM_PSX;
- st->codec->sample_rate = avio_rl32(s->pb);
- if (st->codec->sample_rate <= 0)
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX;
+ st->codecpar->sample_rate = avio_rl32(s->pb);
+ if (st->codecpar->sample_rate <= 0)
return AVERROR_INVALIDDATA;
- st->codec->channels = avio_rl32(s->pb);
- if (st->codec->channels <= 0 || st->codec->channels > 8)
+ st->codecpar->channels = avio_rl32(s->pb);
+ if (st->codecpar->channels <= 0 || st->codecpar->channels > 8)
return AVERROR_INVALIDDATA;
- st->duration = size / (16 * st->codec->channels) * 28;
+ st->duration = size / (16 * st->codecpar->channels) * 28;
align = avio_rl32(s->pb);
- if (align <= 0 || align > INT_MAX / st->codec->channels)
+ if (align <= 0 || align > INT_MAX / st->codecpar->channels)
return AVERROR_INVALIDDATA;
- st->codec->block_align = align * st->codec->channels;
+ st->codecpar->block_align = align * st->codecpar->channels;
avio_skip(s->pb, 0x800 - avio_tell(s->pb));
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
static int svag_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- AVCodecContext *codec = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
- return av_get_packet(s->pb, pkt, codec->block_align);
+ return av_get_packet(s->pb, pkt, par->block_align);
}
AVInputFormat ff_svag_demuxer = {
diff --git a/libavformat/swf.h b/libavformat/swf.h
index ab67c756f4..d0f0194c3f 100644
--- a/libavformat/swf.h
+++ b/libavformat/swf.h
@@ -131,7 +131,7 @@ typedef struct SWFContext {
int frame_rate;
int tag;
AVFifoBuffer *audio_fifo;
- AVCodecContext *audio_enc, *video_enc;
+ AVCodecParameters *audio_par, *video_par;
AVStream *video_st;
#if CONFIG_ZLIB
#define ZBUF_SIZE 4096
diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
index eb17e82e08..fa2435e0a0 100644
--- a/libavformat/swfdec.c
+++ b/libavformat/swfdec.c
@@ -181,21 +181,21 @@ static AVStream *create_new_audio_stream(AVFormatContext *s, int id, int info)
return NULL;
ast->id = id;
if (info & 1) {
- 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->codec_type = AVMEDIA_TYPE_AUDIO;
- ast->codec->codec_id = ff_codec_get_id(swf_audio_codec_tags, info>>4 & 15);
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codecpar->codec_id = ff_codec_get_id(swf_audio_codec_tags, info>>4 & 15);
ast->need_parsing = AVSTREAM_PARSE_FULL;
sample_rate_code = info>>2 & 3;
sample_size_code = info>>1 & 1;
- if (!sample_size_code && ast->codec->codec_id == AV_CODEC_ID_PCM_S16LE)
- ast->codec->codec_id = AV_CODEC_ID_PCM_U8;
- ast->codec->sample_rate = 44100 >> (3 - sample_rate_code);
- avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
+ if (!sample_size_code && ast->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE)
+ ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
+ ast->codecpar->sample_rate = 44100 >> (3 - sample_rate_code);
+ avpriv_set_pts_info(ast, 64, 1, ast->codecpar->sample_rate);
return ast;
}
@@ -226,7 +226,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
for (i=0; i<s->nb_streams; i++) {
st = s->streams[i];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id)
goto skip;
}
@@ -239,8 +239,8 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
if (!vst)
return AVERROR(ENOMEM);
vst->id = ch_id;
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_id = ff_codec_get_id(ff_swf_codec_tags, avio_r8(pb));
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_id = ff_codec_get_id(ff_swf_codec_tags, avio_r8(pb));
avpriv_set_pts_info(vst, 16, 256, swf->frame_rate);
len -= 8;
} else if (tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) {
@@ -248,7 +248,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
for (i=0; i<s->nb_streams; i++) {
st = s->streams[i];
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1)
goto skip;
}
@@ -265,7 +265,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
for (i=0; i<s->nb_streams; i++) {
st = s->streams[i];
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == ch_id)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->id == ch_id)
goto skip;
}
@@ -292,7 +292,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
len -= 2;
for(i=0; i<s->nb_streams; i++) {
st = s->streams[i];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->id == ch_id) {
frame = avio_rl16(pb);
len -= 2;
if (len <= 0)
@@ -368,7 +368,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
- if (st->codec->codec_id == AV_CODEC_ID_RAWVIDEO && st->id == -3)
+ if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO && st->id == -3)
break;
}
if (i == s->nb_streams) {
@@ -378,17 +378,17 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
goto bitmap_end;
}
vst->id = -3; /* -3 to avoid clash with video stream and audio stream */
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
avpriv_set_pts_info(vst, 64, 256, swf->frame_rate);
st = vst;
}
if ((res = av_new_packet(pkt, out_len - colormapsize * colormapbpp)) < 0)
goto bitmap_end;
- if (!st->codec->width && !st->codec->height) {
- st->codec->width = width;
- st->codec->height = height;
+ if (!st->codecpar->width && !st->codecpar->height) {
+ st->codecpar->width = width;
+ st->codecpar->height = height;
} else {
ff_add_param_change(pkt, 0, 0, 0, width, height);
}
@@ -417,10 +417,10 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
default:
av_assert0(0);
}
- if (st->codec->pix_fmt != AV_PIX_FMT_NONE && st->codec->pix_fmt != pix_fmt) {
+ if (st->codecpar->format != AV_PIX_FMT_NONE && st->codecpar->format != pix_fmt) {
av_log(s, AV_LOG_ERROR, "pixel format change unsupported\n");
} else
- st->codec->pix_fmt = pix_fmt;
+ st->codecpar->format = pix_fmt;
if (linesize * height > pkt->size) {
res = AVERROR_INVALIDDATA;
@@ -443,8 +443,8 @@ bitmap_end_skip:
} else if (tag == TAG_STREAMBLOCK) {
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1) {
- if (st->codec->codec_id == AV_CODEC_ID_MP3) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->id == -1) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_MP3) {
avio_skip(pb, 4);
len -= 4;
if (len <= 0)
@@ -465,7 +465,7 @@ bitmap_end_skip:
} else if (tag == TAG_JPEG2) {
for (i=0; i<s->nb_streams; i++) {
st = s->streams[i];
- if (st->codec->codec_id == AV_CODEC_ID_MJPEG && st->id == -2)
+ if (st->codecpar->codec_id == AV_CODEC_ID_MJPEG && st->id == -2)
break;
}
if (i == s->nb_streams) {
@@ -473,8 +473,8 @@ bitmap_end_skip:
if (!vst)
return AVERROR(ENOMEM);
vst->id = -2; /* -2 to avoid clash with video stream and audio stream */
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_id = AV_CODEC_ID_MJPEG;
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_id = AV_CODEC_ID_MJPEG;
avpriv_set_pts_info(vst, 64, 256, swf->frame_rate);
st = vst;
}
diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c
index 8d5933e9bf..3733a0442c 100644
--- a/libavformat/swfenc.c
+++ b/libavformat/swfenc.c
@@ -185,18 +185,14 @@ static int swf_write_header(AVFormatContext *s)
swf->video_frame_number = 0;
for(i=0;i<s->nb_streams;i++) {
- AVCodecContext *enc = s->streams[i]->codec;
- if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
- if (swf->audio_enc) {
+ AVCodecParameters *par = s->streams[i]->codecpar;
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (swf->audio_par) {
av_log(s, AV_LOG_ERROR, "SWF muxer only supports 1 audio stream\n");
return AVERROR_INVALIDDATA;
}
- if (enc->codec_id == AV_CODEC_ID_MP3) {
- if (!enc->frame_size) {
- av_log(s, AV_LOG_ERROR, "audio frame size not set\n");
- return -1;
- }
- swf->audio_enc = enc;
+ if (par->codec_id == AV_CODEC_ID_MP3) {
+ swf->audio_par = par;
swf->audio_fifo= av_fifo_alloc(AUDIO_FIFO_SIZE);
if (!swf->audio_fifo)
return AVERROR(ENOMEM);
@@ -205,15 +201,15 @@ static int swf_write_header(AVFormatContext *s)
return -1;
}
} else {
- if (swf->video_enc) {
+ if (swf->video_par) {
av_log(s, AV_LOG_ERROR, "SWF muxer only supports 1 video stream\n");
return AVERROR_INVALIDDATA;
}
- if (enc->codec_id == AV_CODEC_ID_VP6F ||
- enc->codec_id == AV_CODEC_ID_FLV1 ||
- enc->codec_id == AV_CODEC_ID_MJPEG) {
+ if (par->codec_id == AV_CODEC_ID_VP6F ||
+ par->codec_id == AV_CODEC_ID_FLV1 ||
+ par->codec_id == AV_CODEC_ID_MJPEG) {
swf->video_st = s->streams[i];
- swf->video_enc = enc;
+ swf->video_par = par;
} else {
av_log(s, AV_LOG_ERROR, "SWF muxer only supports VP6, FLV1 and MJPEG\n");
return -1;
@@ -221,32 +217,32 @@ static int swf_write_header(AVFormatContext *s)
}
}
- if (!swf->video_enc) {
+ if (!swf->video_par) {
/* currently, cannot work correctly if audio only */
width = 320;
height = 200;
rate = 10;
rate_base= 1;
} else {
- width = swf->video_enc->width;
- height = swf->video_enc->height;
+ width = swf->video_par->width;
+ height = swf->video_par->height;
// TODO: should be avg_frame_rate
rate = swf->video_st->time_base.den;
rate_base = swf->video_st->time_base.num;
}
- if (!swf->audio_enc)
+ if (!swf->audio_par)
swf->samples_per_frame = (44100LL * rate_base) / rate;
else
- swf->samples_per_frame = (swf->audio_enc->sample_rate * rate_base) / rate;
+ swf->samples_per_frame = (swf->audio_par->sample_rate * rate_base) / rate;
avio_write(pb, "FWS", 3);
if (!strcmp("avm2", s->oformat->name))
version = 9;
- else if (swf->video_enc && swf->video_enc->codec_id == AV_CODEC_ID_VP6F)
+ else if (swf->video_par && swf->video_par->codec_id == AV_CODEC_ID_VP6F)
version = 8; /* version 8 and above support VP6 codec */
- else if (swf->video_enc && swf->video_enc->codec_id == AV_CODEC_ID_FLV1)
+ else if (swf->video_par && swf->video_par->codec_id == AV_CODEC_ID_FLV1)
version = 6; /* version 6 and above support FLV1 codec */
else
version = 4; /* version 4 for mpeg audio support */
@@ -272,7 +268,7 @@ static int swf_write_header(AVFormatContext *s)
}
/* define a shape with the jpeg inside */
- if (swf->video_enc && swf->video_enc->codec_id == AV_CODEC_ID_MJPEG) {
+ if (swf->video_par && swf->video_par->codec_id == AV_CODEC_ID_MJPEG) {
put_swf_tag(s, TAG_DEFINESHAPE);
avio_wl16(pb, SHAPE_ID); /* ID of shape */
@@ -315,12 +311,12 @@ static int swf_write_header(AVFormatContext *s)
put_swf_end_tag(s);
}
- if (swf->audio_enc && swf->audio_enc->codec_id == AV_CODEC_ID_MP3) {
+ if (swf->audio_par && swf->audio_par->codec_id == AV_CODEC_ID_MP3) {
int v = 0;
/* start sound */
put_swf_tag(s, TAG_STREAMHEAD2);
- switch(swf->audio_enc->sample_rate) {
+ switch(swf->audio_par->sample_rate) {
case 11025: v |= 1 << 2; break;
case 22050: v |= 2 << 2; break;
case 44100: v |= 3 << 2; break;
@@ -330,7 +326,7 @@ static int swf_write_header(AVFormatContext *s)
return -1;
}
v |= 0x02; /* 16 bit playback */
- if (swf->audio_enc->channels == 2)
+ if (swf->audio_par->channels == 2)
v |= 0x01; /* stereo playback */
avio_w8(s->pb, v);
v |= 0x20; /* mp3 compressed */
@@ -346,27 +342,27 @@ static int swf_write_header(AVFormatContext *s)
}
static int swf_write_video(AVFormatContext *s,
- AVCodecContext *enc, const uint8_t *buf, int size)
+ AVCodecParameters *par, const uint8_t *buf, int size)
{
SWFContext *swf = s->priv_data;
AVIOContext *pb = s->pb;
/* Flash Player limit */
if (swf->swf_frame_number == 16000)
- av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
+ av_log(s, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
- if (enc->codec_id == AV_CODEC_ID_VP6F ||
- enc->codec_id == AV_CODEC_ID_FLV1) {
+ if (par->codec_id == AV_CODEC_ID_VP6F ||
+ par->codec_id == AV_CODEC_ID_FLV1) {
if (swf->video_frame_number == 0) {
/* create a new video object */
put_swf_tag(s, TAG_VIDEOSTREAM);
avio_wl16(pb, VIDEO_ID);
swf->vframes_pos = avio_tell(pb);
avio_wl16(pb, 15000); /* hard flash player limit */
- avio_wl16(pb, enc->width);
- avio_wl16(pb, enc->height);
+ avio_wl16(pb, par->width);
+ avio_wl16(pb, par->height);
avio_w8(pb, 0);
- avio_w8(pb,ff_codec_get_tag(ff_swf_codec_tags, enc->codec_id));
+ avio_w8(pb,ff_codec_get_tag(ff_swf_codec_tags, par->codec_id));
put_swf_end_tag(s);
/* place the video object for the first time */
@@ -394,7 +390,7 @@ static int swf_write_video(AVFormatContext *s,
avio_wl16(pb, swf->video_frame_number++);
avio_write(pb, buf, size);
put_swf_end_tag(s);
- } else if (enc->codec_id == AV_CODEC_ID_MJPEG) {
+ } else if (par->codec_id == AV_CODEC_ID_MJPEG) {
if (swf->swf_frame_number > 0) {
/* remove the shape */
put_swf_tag(s, TAG_REMOVEOBJECT);
@@ -431,7 +427,7 @@ static int swf_write_video(AVFormatContext *s,
swf->swf_frame_number++;
/* streaming sound always should be placed just before showframe tags */
- if (swf->audio_enc && av_fifo_size(swf->audio_fifo)) {
+ if (swf->audio_par && av_fifo_size(swf->audio_fifo)) {
int frame_size = av_fifo_size(swf->audio_fifo);
put_swf_tag(s, TAG_STREAMBLOCK | TAG_LONG);
avio_wl16(pb, swf->sound_samples);
@@ -451,13 +447,13 @@ static int swf_write_video(AVFormatContext *s,
}
static int swf_write_audio(AVFormatContext *s,
- AVCodecContext *enc, uint8_t *buf, int size)
+ AVCodecParameters *par, uint8_t *buf, int size)
{
SWFContext *swf = s->priv_data;
/* Flash Player limit */
if (swf->swf_frame_number == 16000)
- av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
+ av_log(s, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
if (av_fifo_size(swf->audio_fifo) + size > AUDIO_FIFO_SIZE) {
av_log(s, AV_LOG_ERROR, "audio fifo too small to mux audio essence\n");
@@ -465,36 +461,36 @@ static int swf_write_audio(AVFormatContext *s,
}
av_fifo_generic_write(swf->audio_fifo, buf, size, NULL);
- swf->sound_samples += enc->frame_size;
+ swf->sound_samples += av_get_audio_frame_duration2(par, size);
/* if audio only stream make sure we add swf frames */
- if (!swf->video_enc)
- swf_write_video(s, enc, 0, 0);
+ if (!swf->video_par)
+ swf_write_video(s, par, 0, 0);
return 0;
}
static int swf_write_packet(AVFormatContext *s, AVPacket *pkt)
{
- AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
- if (codec->codec_type == AVMEDIA_TYPE_AUDIO)
- return swf_write_audio(s, codec, pkt->data, pkt->size);
+ AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO)
+ return swf_write_audio(s, par, pkt->data, pkt->size);
else
- return swf_write_video(s, codec, pkt->data, pkt->size);
+ return swf_write_video(s, par, pkt->data, pkt->size);
}
static int swf_write_trailer(AVFormatContext *s)
{
SWFContext *swf = s->priv_data;
AVIOContext *pb = s->pb;
- AVCodecContext *enc, *video_enc;
+ AVCodecParameters *par, *video_par;
int file_size, i;
- 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_VIDEO)
- video_enc = enc;
+ par = s->streams[i]->codecpar;
+ if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+ video_par = par;
else {
av_fifo_freep(&swf->audio_fifo);
}
@@ -504,7 +500,7 @@ static int swf_write_trailer(AVFormatContext *s)
put_swf_end_tag(s);
/* patch file size and number of frames if not streamed */
- if (s->pb->seekable && video_enc) {
+ if (s->pb->seekable && video_par) {
file_size = avio_tell(pb);
avio_seek(pb, 4, SEEK_SET);
avio_wl32(pb, file_size);
diff --git a/libavformat/takdec.c b/libavformat/takdec.c
index 970ab4a8b4..4b4124f9d4 100644
--- a/libavformat/takdec.c
+++ b/libavformat/takdec.c
@@ -58,9 +58,9 @@ static int tak_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_TAK;
- st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_TAK;
+ st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
tc->mlast_frame = 0;
if (avio_rl32(pb) != MKTAG('t', 'B', 'a', 'K')) {
@@ -145,15 +145,15 @@ static int tak_read_header(AVFormatContext *s)
avpriv_tak_parse_streaminfo(&gb, &ti);
if (ti.samples > 0)
st->duration = ti.samples;
- st->codec->bits_per_coded_sample = ti.bps;
+ st->codecpar->bits_per_coded_sample = ti.bps;
if (ti.ch_layout)
- st->codec->channel_layout = ti.ch_layout;
- st->codec->sample_rate = ti.sample_rate;
- st->codec->channels = ti.channels;
+ st->codecpar->channel_layout = ti.ch_layout;
+ st->codecpar->sample_rate = ti.sample_rate;
+ st->codecpar->channels = ti.channels;
st->start_time = 0;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
- st->codec->extradata = buffer;
- st->codec->extradata_size = size - 3;
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
+ st->codecpar->extradata = buffer;
+ st->codecpar->extradata_size = size - 3;
buffer = NULL;
} else if (type == TAK_METADATA_LAST_FRAME) {
if (size != 11)
diff --git a/libavformat/tedcaptionsdec.c b/libavformat/tedcaptionsdec.c
index b6dc517073..774d4993b5 100644
--- a/libavformat/tedcaptionsdec.c
+++ b/libavformat/tedcaptionsdec.c
@@ -295,8 +295,8 @@ static av_cold int tedcaptions_read_header(AVFormatContext *avf)
st = avformat_new_stream(avf, NULL);
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_TEXT;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_TEXT;
avpriv_set_pts_info(st, 64, 1, 1000);
st->probe_packets = 0;
st->start_time = 0;
diff --git a/libavformat/tee.c b/libavformat/tee.c
index 139070556c..bb344e6231 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -226,7 +226,7 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
st2->sample_aspect_ratio = st->sample_aspect_ratio;
st2->avg_frame_rate = st->avg_frame_rate;
av_dict_copy(&st2->metadata, st->metadata, 0);
- if ((ret = avcodec_copy_context(st2->codec, st->codec)) < 0)
+ if ((ret = avcodec_parameters_copy(st2->codecpar, st->codecpar)) < 0)
goto end;
}
@@ -347,8 +347,8 @@ static void log_slave(TeeSlave *slave, void *log_ctx, int log_level)
AVBitStreamFilterContext *bsf = slave->bsfs[i];
av_log(log_ctx, log_level, " stream:%d codec:%s type:%s",
- i, avcodec_get_name(st->codec->codec_id),
- av_get_media_type_string(st->codec->codec_type));
+ i, avcodec_get_name(st->codecpar->codec_id),
+ av_get_media_type_string(st->codecpar->codec_type));
if (bsf) {
av_log(log_ctx, log_level, " bsfs:");
while (bsf) {
diff --git a/libavformat/thp.c b/libavformat/thp.c
index 5569027dba..76b9b3820c 100644
--- a/libavformat/thp.c
+++ b/libavformat/thp.c
@@ -109,11 +109,12 @@ static int thp_read_header(AVFormatContext *s)
/* The denominator and numerator are switched because 1/fps
is required. */
avpriv_set_pts_info(st, 64, thp->fps.den, thp->fps.num);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_THP;
- st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = avio_rb32(pb);
- st->codec->height = avio_rb32(pb);
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_THP;
+ st->codecpar->codec_tag = 0; /* no fourcc */
+ st->codecpar->width = avio_rb32(pb);
+ st->codecpar->height = avio_rb32(pb);
+ st->codecpar->sample_rate = av_q2d(thp->fps);
st->nb_frames =
st->duration = thp->framecnt;
thp->vst = st;
@@ -130,14 +131,14 @@ static int thp_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_ADPCM_THP;
- st->codec->codec_tag = 0; /* no fourcc */
- st->codec->channels = avio_rb32(pb); /* numChannels. */
- st->codec->sample_rate = avio_rb32(pb); /* Frequency. */
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_THP;
+ st->codecpar->codec_tag = 0; /* no fourcc */
+ st->codecpar->channels = avio_rb32(pb); /* numChannels. */
+ st->codecpar->sample_rate = avio_rb32(pb); /* Frequency. */
st->duration = avio_rb32(pb);
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
thp->audio_stream_index = st->index;
thp->has_audio = 1;
diff --git a/libavformat/tiertexseq.c b/libavformat/tiertexseq.c
index 659ba06dd7..6e00692e26 100644
--- a/libavformat/tiertexseq.c
+++ b/libavformat/tiertexseq.c
@@ -214,11 +214,11 @@ static int seq_read_header(AVFormatContext *s)
avpriv_set_pts_info(st, 32, 1, SEQ_FRAME_RATE);
seq->video_stream_index = st->index;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_TIERTEXSEQVIDEO;
- st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = SEQ_FRAME_W;
- st->codec->height = SEQ_FRAME_H;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_TIERTEXSEQVIDEO;
+ st->codecpar->codec_tag = 0; /* no fourcc */
+ st->codecpar->width = SEQ_FRAME_W;
+ st->codecpar->height = SEQ_FRAME_H;
/* initialize the audio decoder stream */
st = avformat_new_stream(s, NULL);
@@ -228,15 +228,15 @@ static int seq_read_header(AVFormatContext *s)
st->start_time = 0;
avpriv_set_pts_info(st, 32, 1, SEQ_SAMPLE_RATE);
seq->audio_stream_index = st->index;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_PCM_S16BE;
- st->codec->codec_tag = 0; /* no tag */
- st->codec->channels = 1;
- st->codec->channel_layout = AV_CH_LAYOUT_MONO;
- st->codec->sample_rate = SEQ_SAMPLE_RATE;
- st->codec->bits_per_coded_sample = 16;
- st->codec->bit_rate = st->codec->sample_rate * st->codec->bits_per_coded_sample * st->codec->channels;
- st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample / 8;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE;
+ st->codecpar->codec_tag = 0; /* no tag */
+ st->codecpar->channels = 1;
+ st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+ st->codecpar->sample_rate = SEQ_SAMPLE_RATE;
+ st->codecpar->bits_per_coded_sample = 16;
+ st->codecpar->bit_rate = st->codecpar->sample_rate * st->codecpar->bits_per_coded_sample * st->codecpar->channels;
+ st->codecpar->block_align = st->codecpar->channels * st->codecpar->bits_per_coded_sample / 8;
return 0;
}
diff --git a/libavformat/tmv.c b/libavformat/tmv.c
index ad172f4308..2e351714bc 100644
--- a/libavformat/tmv.c
+++ b/libavformat/tmv.c
@@ -81,8 +81,8 @@ static int tmv_read_header(AVFormatContext *s)
if (!(ast = avformat_new_stream(s, NULL)))
return AVERROR(ENOMEM);
- ast->codec->sample_rate = avio_rl16(pb);
- if (!ast->codec->sample_rate) {
+ ast->codecpar->sample_rate = avio_rl16(pb);
+ if (!ast->codecpar->sample_rate) {
av_log(s, AV_LOG_ERROR, "invalid sample rate\n");
return -1;
}
@@ -111,29 +111,29 @@ static int tmv_read_header(AVFormatContext *s)
return -1;
}
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- ast->codec->codec_id = AV_CODEC_ID_PCM_U8;
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
if (features & TMV_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->bits_per_coded_sample = 8;
- ast->codec->bit_rate = ast->codec->sample_rate *
- ast->codec->bits_per_coded_sample;
- avpriv_set_pts_info(ast, 32, 1, ast->codec->sample_rate);
+ ast->codecpar->bits_per_coded_sample = 8;
+ ast->codecpar->bit_rate = ast->codecpar->sample_rate *
+ ast->codecpar->bits_per_coded_sample;
+ avpriv_set_pts_info(ast, 32, 1, ast->codecpar->sample_rate);
- fps.num = ast->codec->sample_rate * ast->codec->channels;
+ fps.num = ast->codecpar->sample_rate * ast->codecpar->channels;
fps.den = tmv->audio_chunk_size;
av_reduce(&fps.num, &fps.den, fps.num, fps.den, 0xFFFFFFFFLL);
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_id = AV_CODEC_ID_TMV;
- vst->codec->pix_fmt = AV_PIX_FMT_PAL8;
- vst->codec->width = char_cols * 8;
- vst->codec->height = char_rows * 8;
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_id = AV_CODEC_ID_TMV;
+ vst->codecpar->format = AV_PIX_FMT_PAL8;
+ vst->codecpar->width = char_cols * 8;
+ vst->codecpar->height = char_rows * 8;
avpriv_set_pts_info(vst, 32, fps.den, fps.num);
if (features & TMV_PADDING)
@@ -141,8 +141,8 @@ static int tmv_read_header(AVFormatContext *s)
((tmv->video_chunk_size + tmv->audio_chunk_size + 511) & ~511) -
(tmv->video_chunk_size + tmv->audio_chunk_size);
- vst->codec->bit_rate = ((tmv->video_chunk_size + tmv->padding) *
- fps.num * 8) / fps.den;
+ vst->codecpar->bit_rate = ((tmv->video_chunk_size + tmv->padding) *
+ fps.num * 8) / fps.den;
return 0;
}
diff --git a/libavformat/tta.c b/libavformat/tta.c
index 7566939d48..ba1a385834 100644
--- a/libavformat/tta.c
+++ b/libavformat/tta.c
@@ -114,11 +114,11 @@ static int tta_read_header(AVFormatContext *s)
return framepos;
framepos += 4 * c->totalframes + 4;
- if (ff_alloc_extradata(st->codec, avio_tell(s->pb) - start_offset))
+ if (ff_alloc_extradata(st->codecpar, avio_tell(s->pb) - start_offset))
return AVERROR(ENOMEM);
avio_seek(s->pb, start_offset, SEEK_SET);
- avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
+ avio_read(s->pb, st->codecpar->extradata, st->codecpar->extradata_size);
ffio_init_checksum(s->pb, tta_check_crc, UINT32_MAX);
for (i = 0; i < c->totalframes; i++) {
@@ -135,11 +135,11 @@ static int tta_read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_TTA;
- st->codec->channels = channels;
- st->codec->sample_rate = samplerate;
- st->codec->bits_per_coded_sample = bps;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_TTA;
+ st->codecpar->channels = channels;
+ st->codecpar->sample_rate = samplerate;
+ st->codecpar->bits_per_coded_sample = bps;
if (s->pb->seekable) {
int64_t pos = avio_tell(s->pb);
diff --git a/libavformat/tty.c b/libavformat/tty.c
index 9022e915fa..ba7aebd17f 100644
--- a/libavformat/tty.c
+++ b/libavformat/tty.c
@@ -82,12 +82,12 @@ static int read_header(AVFormatContext *avctx)
ret = AVERROR(ENOMEM);
goto fail;
}
- st->codec->codec_tag = 0;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_ANSI;
+ st->codecpar->codec_tag = 0;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_ANSI;
- st->codec->width = s->width;
- st->codec->height = s->height;
+ st->codecpar->width = s->width;
+ st->codecpar->height = s->height;
avpriv_set_pts_info(st, 60, s->framerate.den, s->framerate.num);
st->avg_frame_rate = s->framerate;
diff --git a/libavformat/txd.c b/libavformat/txd.c
index cac37d54b4..18c968395b 100644
--- a/libavformat/txd.c
+++ b/libavformat/txd.c
@@ -44,8 +44,8 @@ static int txd_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_TXD;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_TXD;
avpriv_set_pts_info(st, 64, 1, 5);
st->avg_frame_rate = av_inv_q(st->time_base);
/* the parameters will be extracted from the compressed bitstream */
diff --git a/libavformat/uncodedframecrcenc.c b/libavformat/uncodedframecrcenc.c
index ed4532daf1..9702a70007 100644
--- a/libavformat/uncodedframecrcenc.c
+++ b/libavformat/uncodedframecrcenc.c
@@ -133,7 +133,7 @@ static int write_frame(struct AVFormatContext *s, int stream_index,
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
av_bprintf(&bp, "%d, %10"PRId64"",
stream_index, (*frame)->pts);
- type = s->streams[stream_index]->codec->codec_type;
+ type = s->streams[stream_index]->codecpar->codec_type;
type_name = av_get_media_type_string(type);
av_bprintf(&bp, ", %s", type_name ? type_name : "unknown");
switch (type) {
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 3bf96adaab..229c0776ed 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -164,10 +164,14 @@ int ff_copy_whiteblacklists(AVFormatContext *dst, AVFormatContext *src)
static const AVCodec *find_decoder(AVFormatContext *s, AVStream *st, enum AVCodecID codec_id)
{
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
if (st->codec->codec)
return st->codec->codec;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
- switch (st->codec->codec_type) {
+ switch (st->codecpar->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (s->video_codec) return s->video_codec;
break;
@@ -311,8 +315,15 @@ static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st,
fmt->name, score);
for (i = 0; fmt_id_type[i].name; i++) {
if (!strcmp(fmt->name, fmt_id_type[i].name)) {
- st->codec->codec_id = fmt_id_type[i].id;
- st->codec->codec_type = fmt_id_type[i].type;
+ st->codecpar->codec_id = fmt_id_type[i].id;
+ st->codecpar->codec_type = fmt_id_type[i].type;
+ st->internal->need_context_update = 1;
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+ st->codec->codec_type = st->codecpar->codec_type;
+ st->codec->codec_id = st->codecpar->codec_id;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
return score;
}
}
@@ -425,11 +436,40 @@ int avformat_queue_attached_pictures(AVFormatContext *s)
return 0;
}
+static int update_stream_avctx(AVFormatContext *s)
+{
+ int i, ret;
+ for (i = 0; i < s->nb_streams; i++) {
+ AVStream *st = s->streams[i];
+
+ if (!st->internal->need_context_update)
+ continue;
+
+ /* update internal codec context, for the parser */
+ ret = avcodec_parameters_to_context(st->internal->avctx, st->codecpar);
+ if (ret < 0)
+ return ret;
+
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+ /* update deprecated public codec context */
+ ret = avcodec_parameters_to_context(st->codec, st->codecpar);
+ if (ret < 0)
+ return ret;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ st->internal->need_context_update = 0;
+ }
+ return 0;
+}
+
+
int avformat_open_input(AVFormatContext **ps, const char *filename,
AVInputFormat *fmt, AVDictionary **options)
{
AVFormatContext *s = *ps;
- int ret = 0;
+ int i, ret = 0;
AVDictionary *tmp = NULL;
ID3v2ExtraMeta *id3v2_extra_meta = NULL;
@@ -530,6 +570,11 @@ int avformat_open_input(AVFormatContext **ps, const char *filename,
s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
+ update_stream_avctx(s);
+
+ for (i = 0; i < s->nb_streams; i++)
+ s->streams[i]->internal->orig_codec_id = s->streams[i]->codecpar->codec_id;
+
if (options) {
av_dict_free(options);
*options = tmp;
@@ -551,18 +596,18 @@ fail:
static void force_codec_ids(AVFormatContext *s, AVStream *st)
{
- switch (st->codec->codec_type) {
+ switch (st->codecpar->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (s->video_codec_id)
- st->codec->codec_id = s->video_codec_id;
+ st->codecpar->codec_id = s->video_codec_id;
break;
case AVMEDIA_TYPE_AUDIO:
if (s->audio_codec_id)
- st->codec->codec_id = s->audio_codec_id;
+ st->codecpar->codec_id = s->audio_codec_id;
break;
case AVMEDIA_TYPE_SUBTITLE:
if (s->subtitle_codec_id)
- st->codec->codec_id = s->subtitle_codec_id;
+ st->codecpar->codec_id = s->subtitle_codec_id;
break;
}
}
@@ -601,12 +646,12 @@ no_packet:
if (end || av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)) {
int score = set_codec_from_probe_data(s, st, pd);
- if ( (st->codec->codec_id != AV_CODEC_ID_NONE && score > AVPROBE_SCORE_STREAM_RETRY)
+ if ( (st->codecpar->codec_id != AV_CODEC_ID_NONE && score > AVPROBE_SCORE_STREAM_RETRY)
|| end) {
pd->buf_size = 0;
av_freep(&pd->buf);
st->request_probe = -1;
- if (st->codec->codec_id != AV_CODEC_ID_NONE) {
+ if (st->codecpar->codec_id != AV_CODEC_ID_NONE) {
av_log(s, AV_LOG_DEBUG, "probed stream %d\n", st->index);
} else
av_log(s, AV_LOG_WARNING, "probed stream %d failed\n", st->index);
@@ -804,13 +849,20 @@ static int determinable_frame_size(AVCodecContext *avctx)
void ff_compute_frame_duration(AVFormatContext *s, int *pnum, int *pden, AVStream *st,
AVCodecParserContext *pc, AVPacket *pkt)
{
- AVRational codec_framerate = s->iformat ? st->codec->framerate :
- av_mul_q(av_inv_q(st->codec->time_base), (AVRational){1, st->codec->ticks_per_frame});
- int frame_size;
+ AVRational codec_framerate = s->iformat ? st->internal->avctx->framerate :
+ av_mul_q(av_inv_q(st->internal->avctx->time_base), (AVRational){1, st->internal->avctx->ticks_per_frame});
+ int frame_size, sample_rate;
+
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+ if ((!codec_framerate.den || !codec_framerate.num) && st->codec->time_base.den && st->codec->time_base.num)
+ codec_framerate = av_mul_q(av_inv_q(st->codec->time_base), (AVRational){1, st->codec->ticks_per_frame});
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
*pnum = 0;
*pden = 0;
- switch (st->codec->codec_type) {
+ switch (st->codecpar->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (st->r_frame_rate.num && !pc && s->iformat) {
*pnum = st->r_frame_rate.den;
@@ -819,10 +871,10 @@ void ff_compute_frame_duration(AVFormatContext *s, int *pnum, int *pden, AVStrea
*pnum = st->time_base.num;
*pden = st->time_base.den;
} else if (codec_framerate.den * 1000LL > codec_framerate.num) {
- av_assert0(st->codec->ticks_per_frame);
+ av_assert0(st->internal->avctx->ticks_per_frame);
av_reduce(pnum, pden,
codec_framerate.den,
- codec_framerate.num * (int64_t)st->codec->ticks_per_frame,
+ codec_framerate.num * (int64_t)st->internal->avctx->ticks_per_frame,
INT_MAX);
if (pc && pc->repeat_pict) {
@@ -835,51 +887,51 @@ void ff_compute_frame_duration(AVFormatContext *s, int *pnum, int *pden, AVStrea
/* If this codec can be interlaced or progressive then we need
* a parser to compute duration of a packet. Thus if we have
* no parser in such case leave duration undefined. */
- if (st->codec->ticks_per_frame > 1 && !pc)
+ if (st->internal->avctx->ticks_per_frame > 1 && !pc)
*pnum = *pden = 0;
}
break;
case AVMEDIA_TYPE_AUDIO:
- frame_size = av_get_audio_frame_duration(st->codec, pkt->size);
- if (frame_size <= 0 || st->codec->sample_rate <= 0)
+ if (st->internal->avctx_inited) {
+ frame_size = av_get_audio_frame_duration(st->internal->avctx, pkt->size);
+ sample_rate = st->internal->avctx->sample_rate;
+ } else {
+ frame_size = av_get_audio_frame_duration2(st->codecpar, pkt->size);
+ sample_rate = st->codecpar->sample_rate;
+ }
+ if (frame_size <= 0 || sample_rate <= 0)
break;
*pnum = frame_size;
- *pden = st->codec->sample_rate;
+ *pden = sample_rate;
break;
default:
break;
}
}
-static int is_intra_only(AVCodecContext *enc) {
- const AVCodecDescriptor *desc;
-
- if (enc->codec_type != AVMEDIA_TYPE_VIDEO)
- return 1;
-
- desc = av_codec_get_codec_descriptor(enc);
- if (!desc) {
- desc = avcodec_descriptor_get(enc->codec_id);
- av_codec_set_codec_descriptor(enc, desc);
- }
- if (desc)
- return !!(desc->props & AV_CODEC_PROP_INTRA_ONLY);
- return 0;
+static int is_intra_only(enum AVCodecID id)
+{
+ const AVCodecDescriptor *d = avcodec_descriptor_get(id);
+ if (!d)
+ return 0;
+ if (d->type == AVMEDIA_TYPE_VIDEO && !(d->props & AV_CODEC_PROP_INTRA_ONLY))
+ return 0;
+ return 1;
}
static int has_decode_delay_been_guessed(AVStream *st)
{
- if (st->codec->codec_id != AV_CODEC_ID_H264) return 1;
+ if (st->codecpar->codec_id != AV_CODEC_ID_H264) return 1;
if (!st->info) // if we have left find_stream_info then nb_decoded_frames won't increase anymore for stream copy
return 1;
#if CONFIG_H264_DECODER
- if (st->codec->has_b_frames &&
- avpriv_h264_has_num_reorder_frames(st->codec) == st->codec->has_b_frames)
+ if (st->internal->avctx->has_b_frames &&
+ avpriv_h264_has_num_reorder_frames(st->internal->avctx) == st->internal->avctx->has_b_frames)
return 1;
#endif
- if (st->codec->has_b_frames<3)
+ if (st->internal->avctx->has_b_frames<3)
return st->nb_decoded_frames >= 7;
- else if (st->codec->has_b_frames<4)
+ else if (st->internal->avctx->has_b_frames<4)
return st->nb_decoded_frames >= 18;
else
return st->nb_decoded_frames >= 20;
@@ -895,11 +947,11 @@ static AVPacketList *get_next_pkt(AVFormatContext *s, AVStream *st, AVPacketList
}
static int64_t select_from_pts_buffer(AVStream *st, int64_t *pts_buffer, int64_t dts) {
- int onein_oneout = st->codec->codec_id != AV_CODEC_ID_H264 &&
- st->codec->codec_id != AV_CODEC_ID_HEVC;
+ int onein_oneout = st->codecpar->codec_id != AV_CODEC_ID_H264 &&
+ st->codecpar->codec_id != AV_CODEC_ID_HEVC;
if(!onein_oneout) {
- int delay = st->codec->has_b_frames;
+ int delay = st->internal->avctx->has_b_frames;
int i;
if (dts == AV_NOPTS_VALUE) {
@@ -944,7 +996,7 @@ static void update_dts_from_pts(AVFormatContext *s, int stream_index,
AVPacketList *pkt_buffer)
{
AVStream *st = s->streams[stream_index];
- int delay = st->codec->has_b_frames;
+ int delay = st->internal->avctx->has_b_frames;
int i;
int64_t pts_buffer[MAX_REORDER_DELAY+1];
@@ -999,8 +1051,8 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
if (st->start_time == AV_NOPTS_VALUE && pktl_it->pkt.pts != AV_NOPTS_VALUE) {
st->start_time = pktl_it->pkt.pts;
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate)
- st->start_time += av_rescale_q(st->skip_samples, (AVRational){1, st->codec->sample_rate}, st->time_base);
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate)
+ st->start_time += av_rescale_q(st->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base);
}
}
@@ -1010,8 +1062,8 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
if (st->start_time == AV_NOPTS_VALUE) {
st->start_time = pts;
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate)
- st->start_time += av_rescale_q(st->skip_samples, (AVRational){1, st->codec->sample_rate}, st->time_base);
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate)
+ st->start_time += av_rescale_q(st->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base);
}
}
@@ -1056,9 +1108,9 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st,
(pktl->pkt.dts == AV_NOPTS_VALUE || pktl->pkt.dts == st->first_dts) &&
!pktl->pkt.duration) {
pktl->pkt.dts = cur_dts;
- if (!st->codec->has_b_frames)
+ if (!st->internal->avctx->has_b_frames)
pktl->pkt.pts = cur_dts;
-// if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO)
+// if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
pktl->pkt.duration = duration;
} else
break;
@@ -1075,13 +1127,13 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
int num, den, presentation_delayed, delay, i;
int64_t offset;
AVRational duration;
- int onein_oneout = st->codec->codec_id != AV_CODEC_ID_H264 &&
- st->codec->codec_id != AV_CODEC_ID_HEVC;
+ int onein_oneout = st->codecpar->codec_id != AV_CODEC_ID_H264 &&
+ st->codecpar->codec_id != AV_CODEC_ID_HEVC;
if (s->flags & AVFMT_FLAG_NOFILLIN)
return;
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && pkt->dts != AV_NOPTS_VALUE) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && pkt->dts != AV_NOPTS_VALUE) {
if (pkt->dts == pkt->pts && st->last_dts_for_order_check != AV_NOPTS_VALUE) {
if (st->last_dts_for_order_check <= pkt->dts) {
st->dts_ordered++;
@@ -1107,12 +1159,12 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
pkt->dts = AV_NOPTS_VALUE;
if (pc && pc->pict_type == AV_PICTURE_TYPE_B
- && !st->codec->has_b_frames)
+ && !st->internal->avctx->has_b_frames)
//FIXME Set low_delay = 0 when has_b_frames = 1
- st->codec->has_b_frames = 1;
+ st->internal->avctx->has_b_frames = 1;
/* do we have a video B-frame ? */
- delay = st->codec->has_b_frames;
+ delay = st->internal->avctx->has_b_frames;
presentation_delayed = 0;
/* XXX: need has_b_frame, but cannot get it if the codec is
@@ -1248,7 +1300,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
presentation_delayed, delay, av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts));
/* update flags */
- if (is_intra_only(st->codec))
+ if (is_intra_only(st->codecpar->codec_id))
pkt->flags |= AV_PKT_FLAG_KEY;
#if FF_API_CONVERGENCE_DURATION
FF_DISABLE_DEPRECATION_WARNINGS
@@ -1297,7 +1349,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index)
int64_t next_dts = pkt->dts;
av_init_packet(&out_pkt);
- len = av_parser_parse2(st->parser, st->codec,
+ len = av_parser_parse2(st->parser, st->internal->avctx,
&out_pkt.data, &out_pkt.size, data, size,
pkt->pts, pkt->dts, pkt->pos);
@@ -1321,11 +1373,11 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index)
/* set the duration */
out_pkt.duration = (st->parser->flags & PARSER_FLAG_COMPLETE_FRAMES) ? pkt->duration : 0;
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- if (st->codec->sample_rate > 0) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (st->internal->avctx->sample_rate > 0) {
out_pkt.duration =
av_rescale_q_rnd(st->parser->duration,
- (AVRational) { 1, st->codec->sample_rate },
+ (AVRational) { 1, st->internal->avctx->sample_rate },
st->time_base,
AV_ROUND_DOWN);
}
@@ -1384,7 +1436,7 @@ static int read_from_packet_buffer(AVPacketList **pkt_buffer,
static int64_t ts_to_samples(AVStream *st, int64_t ts)
{
- return av_rescale(ts, st->time_base.num * st->codec->sample_rate, st->time_base.den);
+ return av_rescale(ts, st->time_base.num * st->codecpar->sample_rate, st->time_base.den);
}
static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
@@ -1416,6 +1468,21 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
ret = 0;
st = s->streams[cur_pkt.stream_index];
+ /* update context if required */
+ if (st->internal->need_context_update) {
+ if (avcodec_is_open(st->internal->avctx)) {
+ av_log(s, AV_LOG_DEBUG, "Demuxer context update while decoder is open, closing and trying to re-open\n");
+ avcodec_close(st->internal->avctx);
+ st->info->found_decoder = 0;
+ }
+
+ ret = avcodec_parameters_to_context(st->internal->avctx, st->codecpar);
+ if (ret < 0)
+ return ret;
+
+ st->internal->need_context_update = 0;
+ }
+
if (cur_pkt.pts != AV_NOPTS_VALUE &&
cur_pkt.dts != AV_NOPTS_VALUE &&
cur_pkt.pts < cur_pkt.dts) {
@@ -1435,11 +1502,11 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
cur_pkt.size, cur_pkt.duration, cur_pkt.flags);
if (st->need_parsing && !st->parser && !(s->flags & AVFMT_FLAG_NOPARSE)) {
- st->parser = av_parser_init(st->codec->codec_id);
+ st->parser = av_parser_init(st->codecpar->codec_id);
if (!st->parser) {
av_log(s, AV_LOG_VERBOSE, "parser not found for codec "
"%s, packets or times may be invalid.\n",
- avcodec_get_name(st->codec->codec_id));
+ avcodec_get_name(st->codecpar->codec_id));
/* no parser available: just output the raw packets */
st->need_parsing = AVSTREAM_PARSE_NONE;
} else if (st->need_parsing == AVSTREAM_PARSE_HEADERS)
@@ -1464,6 +1531,11 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
} else if (st->discard < AVDISCARD_ALL) {
if ((ret = parse_packet(s, &cur_pkt, cur_pkt.stream_index)) < 0)
return ret;
+ st->codecpar->sample_rate = st->internal->avctx->sample_rate;
+ st->codecpar->bit_rate = st->internal->avctx->bit_rate;
+ st->codecpar->channels = st->internal->avctx->channels;
+ st->codecpar->channel_layout = st->internal->avctx->channel_layout;
+ st->codecpar->codec_id = st->internal->avctx->codec_id;
} else {
/* free packet */
av_packet_unref(&cur_pkt);
@@ -1537,6 +1609,10 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
av_opt_set_dict_val(s, "metadata", NULL, AV_OPT_SEARCH_CHILDREN);
}
+#if FF_API_LAVF_AVCTX
+ update_stream_avctx(s);
+#endif
+
if (s->debug & FF_FDEBUG_TS)
av_log(s, AV_LOG_DEBUG,
"read_frame_internal stream=%d, pts=%s, dts=%s, "
@@ -1671,15 +1747,15 @@ int av_find_default_stream_index(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
int score = 0;
st = s->streams[i];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (st->disposition & AV_DISPOSITION_ATTACHED_PIC)
score -= 400;
- if (st->codec->width && st->codec->height)
+ if (st->codecpar->width && st->codecpar->height)
score += 50;
score+= 25;
}
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- if (st->codec->sample_rate)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (st->codecpar->sample_rate)
score += 50;
}
if (st->codec_info_nb_frames)
@@ -2206,7 +2282,7 @@ static int seek_frame_generic(AVFormatContext *s, int stream_index,
av_packet_unref(&pkt);
break;
}
- if (nonkey++ > 1000 && st->codec->codec_id != AV_CODEC_ID_CDGRAPHICS) {
+ if (nonkey++ > 1000 && st->codecpar->codec_id != AV_CODEC_ID_CDGRAPHICS) {
av_log(s, AV_LOG_ERROR,"seek_frame_generic failed as this stream seems to contain no keyframes after the target timestamp, %d non keyframes found\n", nonkey);
av_packet_unref(&pkt);
break;
@@ -2404,7 +2480,7 @@ static void update_stream_timings(AVFormatContext *ic)
if (st->start_time != AV_NOPTS_VALUE && st->time_base.den) {
start_time1 = av_rescale_q(st->start_time, st->time_base,
AV_TIME_BASE_Q);
- if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE || st->codec->codec_type == AVMEDIA_TYPE_DATA) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
if (start_time1 < start_time_text)
start_time_text = start_time1;
} else
@@ -2489,13 +2565,13 @@ static void estimate_timings_from_bit_rate(AVFormatContext *ic)
int bit_rate = 0;
for (i = 0; i < ic->nb_streams; i++) {
st = ic->streams[i];
- if (st->codec->bit_rate > 0) {
- if (INT_MAX - st->codec->bit_rate < bit_rate) {
+ if (st->codecpar->bit_rate > 0) {
+ if (INT_MAX - st->codecpar->bit_rate < bit_rate) {
bit_rate = 0;
break;
}
- bit_rate += st->codec->bit_rate;
- } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->codec_info_nb_frames > 1) {
+ bit_rate += st->codecpar->bit_rate;
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->codec_info_nb_frames > 1) {
// If we have a videostream with packets but without a bitrate
// then consider the sum not known
bit_rate = 0;
@@ -2550,8 +2626,8 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
st = ic->streams[i];
if (st->start_time == AV_NOPTS_VALUE &&
st->first_dts == AV_NOPTS_VALUE &&
- st->codec->codec_type != AVMEDIA_TYPE_UNKNOWN)
- av_log(st->codec, AV_LOG_WARNING,
+ st->codecpar->codec_type != AVMEDIA_TYPE_UNKNOWN)
+ av_log(ic, AV_LOG_WARNING,
"start time for stream %d is not set in estimate_timings_from_pts\n", i);
if (st->parser) {
@@ -2616,7 +2692,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
is_end = 1;
for (i = 0; i < ic->nb_streams; i++) {
st = ic->streams[i];
- switch (st->codec->codec_type) {
+ switch (st->codecpar->codec_type) {
case AVMEDIA_TYPE_VIDEO:
case AVMEDIA_TYPE_AUDIO:
if (st->duration == AV_NOPTS_VALUE)
@@ -2634,7 +2710,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
for (i = 0; i < ic->nb_streams; i++) {
st = ic->streams[i];
if (st->duration == AV_NOPTS_VALUE) {
- switch (st->codec->codec_type) {
+ switch (st->codecpar->codec_type) {
case AVMEDIA_TYPE_VIDEO:
case AVMEDIA_TYPE_AUDIO:
if (st->start_time != AV_NOPTS_VALUE || st->first_dts != AV_NOPTS_VALUE) {
@@ -2708,7 +2784,7 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
static int has_codec_parameters(AVStream *st, const char **errmsg_ptr)
{
- AVCodecContext *avctx = st->codec;
+ AVCodecContext *avctx = st->internal->avctx;
#define FAIL(errmsg) do { \
if (errmsg_ptr) \
@@ -2738,8 +2814,8 @@ static int has_codec_parameters(AVStream *st, const char **errmsg_ptr)
FAIL("unspecified size");
if (st->info->found_decoder >= 0 && avctx->pix_fmt == AV_PIX_FMT_NONE)
FAIL("unspecified pixel format");
- if (st->codec->codec_id == AV_CODEC_ID_RV30 || st->codec->codec_id == AV_CODEC_ID_RV40)
- if (!st->sample_aspect_ratio.num && !st->codec->sample_aspect_ratio.num && !st->codec_info_nb_frames)
+ if (st->codecpar->codec_id == AV_CODEC_ID_RV30 || st->codecpar->codec_id == AV_CODEC_ID_RV40)
+ if (!st->sample_aspect_ratio.num && !st->codecpar->sample_aspect_ratio.num && !st->codec_info_nb_frames)
FAIL("no frame in rv30/40 and no sar");
break;
case AVMEDIA_TYPE_SUBTITLE:
@@ -2757,6 +2833,7 @@ static int has_codec_parameters(AVStream *st, const char **errmsg_ptr)
static int try_decode_frame(AVFormatContext *s, AVStream *st, AVPacket *avpkt,
AVDictionary **options)
{
+ AVCodecContext *avctx = st->internal->avctx;
const AVCodec *codec;
int got_picture = 1, ret = 0;
AVFrame *frame = av_frame_alloc();
@@ -2768,15 +2845,15 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, AVPacket *avpkt,
if (!frame)
return AVERROR(ENOMEM);
- if (!avcodec_is_open(st->codec) &&
+ if (!avcodec_is_open(avctx) &&
st->info->found_decoder <= 0 &&
- (st->codec->codec_id != -st->info->found_decoder || !st->codec->codec_id)) {
+ (st->codecpar->codec_id != -st->info->found_decoder || !st->codecpar->codec_id)) {
AVDictionary *thread_opt = NULL;
- codec = find_decoder(s, st, st->codec->codec_id);
+ codec = find_decoder(s, st, st->codecpar->codec_id);
if (!codec) {
- st->info->found_decoder = -st->codec->codec_id;
+ st->info->found_decoder = -st->codecpar->codec_id;
ret = -1;
goto fail;
}
@@ -2786,11 +2863,11 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, AVPacket *avpkt,
av_dict_set(options ? options : &thread_opt, "threads", "1", 0);
if (s->codec_whitelist)
av_dict_set(options ? options : &thread_opt, "codec_whitelist", s->codec_whitelist, 0);
- ret = avcodec_open2(st->codec, codec, options ? options : &thread_opt);
+ ret = avcodec_open2(avctx, codec, options ? options : &thread_opt);
if (!options)
av_dict_free(&thread_opt);
if (ret < 0) {
- st->info->found_decoder = -st->codec->codec_id;
+ st->info->found_decoder = -avctx->codec_id;
goto fail;
}
st->info->found_decoder = 1;
@@ -2802,28 +2879,28 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, AVPacket *avpkt,
goto fail;
}
- if (st->codec->codec->caps_internal & FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM) {
+ if (avctx->codec->caps_internal & FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM) {
do_skip_frame = 1;
- skip_frame = st->codec->skip_frame;
- st->codec->skip_frame = AVDISCARD_ALL;
+ skip_frame = avctx->skip_frame;
+ avctx->skip_frame = AVDISCARD_ALL;
}
while ((pkt.size > 0 || (!pkt.data && got_picture)) &&
ret >= 0 &&
(!has_codec_parameters(st, NULL) || !has_decode_delay_been_guessed(st) ||
(!st->codec_info_nb_frames &&
- (st->codec->codec->capabilities & AV_CODEC_CAP_CHANNEL_CONF)))) {
+ (avctx->codec->capabilities & AV_CODEC_CAP_CHANNEL_CONF)))) {
got_picture = 0;
- switch (st->codec->codec_type) {
+ switch (avctx->codec_type) {
case AVMEDIA_TYPE_VIDEO:
- ret = avcodec_decode_video2(st->codec, frame,
+ ret = avcodec_decode_video2(avctx, frame,
&got_picture, &pkt);
break;
case AVMEDIA_TYPE_AUDIO:
- ret = avcodec_decode_audio4(st->codec, frame, &got_picture, &pkt);
+ ret = avcodec_decode_audio4(avctx, frame, &got_picture, &pkt);
break;
case AVMEDIA_TYPE_SUBTITLE:
- ret = avcodec_decode_subtitle2(st->codec, &subtitle,
+ ret = avcodec_decode_subtitle2(avctx, &subtitle,
&got_picture, &pkt);
ret = pkt.size;
break;
@@ -2844,7 +2921,7 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, AVPacket *avpkt,
fail:
if (do_skip_frame) {
- st->codec->skip_frame = skip_frame;
+ avctx->skip_frame = skip_frame;
}
av_frame_free(&frame);
@@ -3019,37 +3096,37 @@ static int tb_unreliable(AVCodecContext *c)
return 0;
}
-int ff_alloc_extradata(AVCodecContext *avctx, int size)
+int ff_alloc_extradata(AVCodecParameters *par, int size)
{
int ret;
if (size < 0 || size >= INT32_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {
- avctx->extradata = NULL;
- avctx->extradata_size = 0;
+ par->extradata = NULL;
+ par->extradata_size = 0;
return AVERROR(EINVAL);
}
- avctx->extradata = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE);
- if (avctx->extradata) {
- memset(avctx->extradata + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
- avctx->extradata_size = size;
+ par->extradata = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (par->extradata) {
+ memset(par->extradata + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
+ par->extradata_size = size;
ret = 0;
} else {
- avctx->extradata_size = 0;
+ par->extradata_size = 0;
ret = AVERROR(ENOMEM);
}
return ret;
}
-int ff_get_extradata(AVCodecContext *avctx, AVIOContext *pb, int size)
+int ff_get_extradata(AVCodecParameters *par, AVIOContext *pb, int size)
{
- int ret = ff_alloc_extradata(avctx, size);
+ int ret = ff_alloc_extradata(par, size);
if (ret < 0)
return ret;
- ret = avio_read(pb, avctx->extradata, size);
+ ret = avio_read(pb, par->extradata, size);
if (ret != size) {
- av_freep(&avctx->extradata);
- avctx->extradata_size = 0;
- av_log(avctx, AV_LOG_ERROR, "Failed to read extradata of size %d\n", size);
+ av_freep(&par->extradata);
+ par->extradata_size = 0;
+ av_log(par, AV_LOG_ERROR, "Failed to read extradata of size %d\n", size);
return ret < 0 ? ret : AVERROR_INVALIDDATA;
}
@@ -3121,15 +3198,15 @@ void ff_rfps_calculate(AVFormatContext *ic)
for (i = 0; i < ic->nb_streams; i++) {
AVStream *st = ic->streams[i];
- if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO)
+ if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
continue;
// the check for tb_unreliable() is not completely correct, since this is not about handling
// an unreliable/inexact time base, but a time base that is finer than necessary, as e.g.
// ipmovie.c produces.
- if (tb_unreliable(st->codec) && st->info->duration_count > 15 && st->info->duration_gcd > FFMAX(1, st->time_base.den/(500LL*st->time_base.num)) && !st->r_frame_rate.num)
+ if (tb_unreliable(st->internal->avctx) && st->info->duration_count > 15 && st->info->duration_gcd > FFMAX(1, st->time_base.den/(500LL*st->time_base.num)) && !st->r_frame_rate.num)
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, st->time_base.den, st->time_base.num * st->info->duration_gcd, INT_MAX);
if (st->info->duration_count>1 && !st->r_frame_rate.num
- && tb_unreliable(st->codec)) {
+ && tb_unreliable(st->internal->avctx)) {
int num = 0;
double best_error= 0.01;
AVRational ref_rate = st->r_frame_rate.num ? st->r_frame_rate : av_inv_q(st->time_base);
@@ -3185,6 +3262,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
int i, count, ret = 0, j;
int64_t read_size;
AVStream *st;
+ AVCodecContext *avctx;
AVPacket pkt1, *pkt;
int64_t old_offset = avio_tell(ic->pb);
// new streams might appear, no options for those
@@ -3220,17 +3298,18 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
const AVCodec *codec;
AVDictionary *thread_opt = NULL;
st = ic->streams[i];
+ avctx = st->internal->avctx;
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
- st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
+ st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
/* if (!st->time_base.num)
st->time_base = */
- if (!st->codec->time_base.num)
- st->codec->time_base = st->time_base;
+ if (!avctx->time_base.num)
+ avctx->time_base = st->time_base;
}
// only for the split stuff
if (!st->parser && !(ic->flags & AVFMT_FLAG_NOPARSE) && st->request_probe <= 0) {
- st->parser = av_parser_init(st->codec->codec_id);
+ st->parser = av_parser_init(st->codecpar->codec_id);
if (st->parser) {
if (st->need_parsing == AVSTREAM_PARSE_HEADERS) {
st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
@@ -3240,10 +3319,30 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
} else if (st->need_parsing) {
av_log(ic, AV_LOG_VERBOSE, "parser not found for codec "
"%s, packets or times may be invalid.\n",
- avcodec_get_name(st->codec->codec_id));
+ avcodec_get_name(st->codecpar->codec_id));
}
}
- codec = find_decoder(ic, st, st->codec->codec_id);
+
+ /* check if the caller has overridden the codec id */
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (st->codec->codec_id != st->internal->orig_codec_id) {
+ st->codecpar->codec_id = st->codec->codec_id;
+ st->codecpar->codec_type = st->codec->codec_type;
+ st->internal->orig_codec_id = st->codec->codec_id;
+ }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ if (st->codecpar->codec_id != st->internal->orig_codec_id)
+ st->internal->orig_codec_id = st->codecpar->codec_id;
+
+ ret = avcodec_parameters_to_context(avctx, st->codecpar);
+ if (ret < 0)
+ goto find_stream_info_err;
+ if (st->request_probe <= 0)
+ st->internal->avctx_inited = 1;
+
+ codec = find_decoder(ic, st, st->codecpar->codec_id);
/* Force thread count to 1 since the H.264 decoder will not extract
* SPS and PPS to extradata during multi-threaded decoding. */
@@ -3253,17 +3352,17 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
av_dict_set(options ? &options[i] : &thread_opt, "codec_whitelist", ic->codec_whitelist, 0);
/* Ensure that subtitle_header is properly set. */
- if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE
- && codec && !st->codec->codec) {
- if (avcodec_open2(st->codec, codec, options ? &options[i] : &thread_opt) < 0)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE
+ && codec && !avctx->codec) {
+ if (avcodec_open2(avctx, codec, options ? &options[i] : &thread_opt) < 0)
av_log(ic, AV_LOG_WARNING,
"Failed to open codec in av_find_stream_info\n");
}
// Try to just open decoders, in case this is enough to get parameters.
if (!has_codec_parameters(st, NULL) && st->request_probe <= 0) {
- if (codec && !st->codec->codec)
- if (avcodec_open2(st->codec, codec, options ? &options[i] : &thread_opt) < 0)
+ if (codec && !avctx->codec)
+ if (avcodec_open2(avctx, codec, options ? &options[i] : &thread_opt) < 0)
av_log(ic, AV_LOG_WARNING,
"Failed to open codec in av_find_stream_info\n");
}
@@ -3301,7 +3400,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
* the correct fps. */
if (av_q2d(st->time_base) > 0.0005)
fps_analyze_framecount *= 2;
- if (!tb_unreliable(st->codec))
+ if (!tb_unreliable(st->internal->avctx))
fps_analyze_framecount = 0;
if (ic->fps_probe_size >= 0)
fps_analyze_framecount = ic->fps_probe_size;
@@ -3309,7 +3408,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
fps_analyze_framecount = 0;
/* variable fps and no guess at the real fps */
if (!(st->r_frame_rate.num && st->avg_frame_rate.num) &&
- st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
int count = (ic->iformat->flags & AVFMT_NOTIMESTAMPS) ?
st->info->codec_info_duration_fields/2 :
st->info->duration_count;
@@ -3317,13 +3416,13 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
break;
}
if (st->parser && st->parser->parser->split &&
- !st->codec->extradata)
+ !st->codecpar->extradata)
break;
if (st->first_dts == AV_NOPTS_VALUE &&
!(ic->iformat->flags & AVFMT_NOTIMESTAMPS) &&
st->codec_info_nb_frames < ((st->disposition & AV_DISPOSITION_ATTACHED_PIC) ? 1 : ic->max_ts_probe) &&
- (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
- st->codec->codec_type == AVMEDIA_TYPE_AUDIO))
+ (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
+ st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO))
break;
}
analyzed_all_streams = 0;
@@ -3347,7 +3446,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
for (i = 0; i < ic->nb_streams; i++)
if (!ic->streams[i]->r_frame_rate.num &&
ic->streams[i]->info->duration_count <= 1 &&
- ic->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
+ ic->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
strcmp(ic->iformat->name, "image2"))
av_log(ic, AV_LOG_WARNING,
"Stream #%d: not enough frames to estimate rate; "
@@ -3380,6 +3479,14 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
if (!(st->disposition & AV_DISPOSITION_ATTACHED_PIC))
read_size += pkt->size;
+ avctx = st->internal->avctx;
+ if (!st->internal->avctx_inited) {
+ ret = avcodec_parameters_to_context(avctx, st->codecpar);
+ if (ret < 0)
+ goto find_stream_info_err;
+ st->internal->avctx_inited = 1;
+ }
+
if (pkt->dts != AV_NOPTS_VALUE && st->codec_info_nb_frames > 1) {
/* check for non-increasing dts */
if (st->info->fps_last_dts != AV_NOPTS_VALUE &&
@@ -3435,7 +3542,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
t = FFMAX(t, av_rescale_q(st->info->fps_last_dts - st->info->fps_first_dts, st->time_base, AV_TIME_BASE_Q));
if (analyzed_all_streams) limit = max_analyze_duration;
- else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) limit = max_subtitle_analyze_duration;
+ else if (avctx->codec_type == AVMEDIA_TYPE_SUBTITLE) limit = max_subtitle_analyze_duration;
else limit = max_stream_analyze_duration;
if (t >= limit) {
@@ -3447,24 +3554,27 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
break;
}
if (pkt->duration) {
- if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE && pkt->pts != AV_NOPTS_VALUE && pkt->pts >= st->start_time) {
+ if (avctx->codec_type == AVMEDIA_TYPE_SUBTITLE && pkt->pts != AV_NOPTS_VALUE && pkt->pts >= st->start_time) {
st->info->codec_info_duration = FFMIN(pkt->pts - st->start_time, st->info->codec_info_duration + pkt->duration);
} else
st->info->codec_info_duration += pkt->duration;
- st->info->codec_info_duration_fields += st->parser && st->need_parsing && st->codec->ticks_per_frame ==2 ? st->parser->repeat_pict + 1 : 2;
+ st->info->codec_info_duration_fields += st->parser && st->need_parsing && avctx->ticks_per_frame ==2 ? st->parser->repeat_pict + 1 : 2;
}
}
#if FF_API_R_FRAME_RATE
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
ff_rfps_add_frame(ic, st, pkt->dts);
#endif
- if (st->parser && st->parser->parser->split && !st->codec->extradata) {
- int i = st->parser->parser->split(st->codec, pkt->data, pkt->size);
+ if (st->parser && st->parser->parser->split && !avctx->extradata) {
+ int i = st->parser->parser->split(avctx, pkt->data, pkt->size);
if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) {
- if (ff_alloc_extradata(st->codec, i))
+ avctx->extradata_size = i;
+ avctx->extradata = av_mallocz(avctx->extradata_size +
+ AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!avctx->extradata)
return AVERROR(ENOMEM);
- memcpy(st->codec->extradata, pkt->data,
- st->codec->extradata_size);
+ memcpy(avctx->extradata, pkt->data,
+ avctx->extradata_size);
}
}
@@ -3526,18 +3636,19 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
// close codecs which were opened in try_decode_frame()
for (i = 0; i < ic->nb_streams; i++) {
st = ic->streams[i];
- avcodec_close(st->codec);
+ avcodec_close(st->internal->avctx);
}
ff_rfps_calculate(ic);
for (i = 0; i < ic->nb_streams; i++) {
st = ic->streams[i];
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- if (st->codec->codec_id == AV_CODEC_ID_RAWVIDEO && !st->codec->codec_tag && !st->codec->bits_per_coded_sample) {
- uint32_t tag= avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
- if (avpriv_find_pix_fmt(avpriv_get_raw_pix_fmt_tags(), tag) == st->codec->pix_fmt)
- st->codec->codec_tag= tag;
+ avctx = st->internal->avctx;
+ if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (avctx->codec_id == AV_CODEC_ID_RAWVIDEO && !avctx->codec_tag && !avctx->bits_per_coded_sample) {
+ uint32_t tag= avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);
+ if (avpriv_find_pix_fmt(avpriv_get_raw_pix_fmt_tags(), tag) == avctx->pix_fmt)
+ avctx->codec_tag= tag;
}
/* estimate average framerate if not set by demuxer */
@@ -3573,26 +3684,26 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
}
if (!st->r_frame_rate.num) {
- if ( st->codec->time_base.den * (int64_t) st->time_base.num
- <= st->codec->time_base.num * st->codec->ticks_per_frame * (int64_t) st->time_base.den) {
- st->r_frame_rate.num = st->codec->time_base.den;
- st->r_frame_rate.den = st->codec->time_base.num * st->codec->ticks_per_frame;
+ if ( avctx->time_base.den * (int64_t) st->time_base.num
+ <= avctx->time_base.num * avctx->ticks_per_frame * (int64_t) st->time_base.den) {
+ st->r_frame_rate.num = avctx->time_base.den;
+ st->r_frame_rate.den = avctx->time_base.num * avctx->ticks_per_frame;
} else {
st->r_frame_rate.num = st->time_base.den;
st->r_frame_rate.den = st->time_base.num;
}
}
if (st->display_aspect_ratio.num && st->display_aspect_ratio.den) {
- AVRational hw_ratio = { st->codec->height, st->codec->width };
+ AVRational hw_ratio = { avctx->height, avctx->width };
st->sample_aspect_ratio = av_mul_q(st->display_aspect_ratio,
hw_ratio);
}
- } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- if (!st->codec->bits_per_coded_sample)
- st->codec->bits_per_coded_sample =
- av_get_bits_per_sample(st->codec->codec_id);
+ } else if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (!avctx->bits_per_coded_sample)
+ avctx->bits_per_coded_sample =
+ av_get_bits_per_sample(avctx->codec_id);
// set stream disposition based on audio service type
- switch (st->codec->audio_service_type) {
+ switch (avctx->audio_service_type) {
case AV_AUDIO_SERVICE_TYPE_EFFECTS:
st->disposition = AV_DISPOSITION_CLEAN_EFFECTS;
break;
@@ -3623,9 +3734,16 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
for (i = 0; i < ic->nb_streams; i++) {
const char *errmsg;
st = ic->streams[i];
+
+ /* if no packet was ever seen, update context now for has_codec_parameters */
+ if (!st->internal->avctx_inited) {
+ ret = avcodec_parameters_to_context(st->internal->avctx, st->codecpar);
+ if (ret < 0)
+ goto find_stream_info_err;
+ }
if (!has_codec_parameters(st, &errmsg)) {
char buf[256];
- avcodec_string(buf, sizeof(buf), st->codec, 0);
+ avcodec_string(buf, sizeof(buf), st->internal->avctx, 0);
av_log(ic, AV_LOG_WARNING,
"Could not find codec parameters for stream %d (%s): %s\n"
"Consider increasing the value for the 'analyzeduration' and 'probesize' options\n",
@@ -3637,11 +3755,60 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
compute_chapters_end(ic);
+ /* update the stream parameters from the internal codec contexts */
+ for (i = 0; i < ic->nb_streams; i++) {
+ st = ic->streams[i];
+
+ if (st->internal->avctx_inited) {
+ int orig_w = st->codecpar->width;
+ int orig_h = st->codecpar->height;
+ ret = avcodec_parameters_from_context(st->codecpar, st->internal->avctx);
+ if (ret < 0)
+ goto find_stream_info_err;
+ // The decoder might reduce the video size by the lowres factor.
+ if (st->internal->avctx->lowres && orig_w) {
+ st->codecpar->width = orig_w;
+ st->codecpar->height = orig_h;
+ }
+ }
+
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+ ret = avcodec_parameters_to_context(st->codec, st->codecpar);
+ if (ret < 0)
+ goto find_stream_info_err;
+
+ // The old API (AVStream.codec) "requires" the resolution to be adjusted
+ // by the lowres factor.
+ if (st->internal->avctx->lowres && st->internal->avctx->width) {
+ st->codec->lowres = st->internal->avctx->lowres;
+ st->codec->width = st->internal->avctx->width;
+ st->codec->height = st->internal->avctx->height;
+ st->codec->coded_width = st->internal->avctx->coded_width;
+ st->codec->coded_height = st->internal->avctx->coded_height;
+ }
+
+ if (st->codec->codec_tag != MKTAG('t','m','c','d'))
+ st->codec->time_base = st->internal->avctx->time_base;
+ st->codec->framerate = st->avg_frame_rate;
+
+ if (st->internal->avctx->subtitle_header) {
+ st->codec->subtitle_header = av_malloc(st->internal->avctx->subtitle_header_size);
+ if (!st->codec->subtitle_header)
+ goto find_stream_info_err;
+ st->codec->subtitle_header_size = st->internal->avctx->subtitle_header_size;
+ memcpy(st->codec->subtitle_header, st->internal->avctx->subtitle_header,
+ st->codec->subtitle_header_size);
+ }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ st->internal->avctx_inited = 0;
+ }
+
find_stream_info_err:
for (i = 0; i < ic->nb_streams; i++) {
st = ic->streams[i];
- if (ic->streams[i]->codec->codec_type != AVMEDIA_TYPE_AUDIO)
- ic->streams[i]->codec->thread_count = 0;
if (st->info)
av_freep(&st->info->duration_error);
av_freep(&ic->streams[i]->info);
@@ -3688,8 +3855,8 @@ int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type,
for (i = 0; i < nb_streams; i++) {
int real_stream_index = program ? program[i] : i;
AVStream *st = ic->streams[real_stream_index];
- AVCodecContext *avctx = st->codec;
- if (avctx->codec_type != type)
+ AVCodecParameters *par = st->codecpar;
+ if (par->codec_type != type)
continue;
if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
continue;
@@ -3697,10 +3864,10 @@ int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type,
st->disposition & (AV_DISPOSITION_HEARING_IMPAIRED |
AV_DISPOSITION_VISUAL_IMPAIRED))
continue;
- if (type == AVMEDIA_TYPE_AUDIO && !(avctx->channels && avctx->sample_rate))
+ if (type == AVMEDIA_TYPE_AUDIO && !(par->channels && par->sample_rate))
continue;
if (decoder_ret) {
- decoder = find_decoder(ic, st, st->codec->codec_id);
+ decoder = find_decoder(ic, st, par->codec_id);
if (!decoder) {
if (ret < 0)
ret = AVERROR_DECODER_NOT_FOUND;
@@ -3708,9 +3875,7 @@ int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type,
}
}
count = st->codec_info_nb_frames;
- bitrate = avctx->bit_rate;
- if (!bitrate)
- bitrate = avctx->rc_max_rate;
+ bitrate = par->bit_rate;
multiframe = FFMIN(5, count);
if ((best_multiframe > multiframe) ||
(best_multiframe == multiframe && best_bitrate > bitrate) ||
@@ -3771,14 +3936,22 @@ static void free_stream(AVStream **pst)
if (st->attached_pic.data)
av_packet_unref(&st->attached_pic);
+ if (st->internal) {
+ avcodec_free_context(&st->internal->avctx);
+ }
av_freep(&st->internal);
av_dict_free(&st->metadata);
+ avcodec_parameters_free(&st->codecpar);
av_freep(&st->probe_data.buf);
av_freep(&st->index_entries);
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
av_freep(&st->codec->extradata);
av_freep(&st->codec->subtitle_header);
av_freep(&st->codec);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
av_freep(&st->priv_data);
if (st->info)
av_freep(&st->info->duration_error);
@@ -3883,20 +4056,36 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
}
st->info->last_dts = AV_NOPTS_VALUE;
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
st->codec = avcodec_alloc_context3(c);
if (!st->codec) {
av_free(st->info);
av_free(st);
return NULL;
}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
st->internal = av_mallocz(sizeof(*st->internal));
if (!st->internal)
goto fail;
+ st->codecpar = avcodec_parameters_alloc();
+ if (!st->codecpar)
+ goto fail;
+
+ st->internal->avctx = avcodec_alloc_context3(NULL);
+ if (!st->internal->avctx)
+ goto fail;
+
if (s->iformat) {
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
/* no default bitrate if decoding */
st->codec->bit_rate = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
/* default pts setting is MPEG-like */
avpriv_set_pts_info(st, 33, 1, 90000);
@@ -3932,6 +4121,8 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
st->inject_global_side_data = s->internal->inject_global_side_data;
+ st->internal->need_context_update = 1;
+
s->streams[s->nb_streams++] = st;
return st;
fail:
@@ -4226,7 +4417,12 @@ void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits,
return;
}
s->time_base = new_tb;
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
av_codec_set_pkt_timebase(s->codec, new_tb);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+ av_codec_set_pkt_timebase(s->internal->avctx, new_tb);
s->pts_wrap_bits = pts_wrap_bits;
}
@@ -4379,7 +4575,7 @@ AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *strea
{
AVRational undef = {0, 1};
AVRational stream_sample_aspect_ratio = stream ? stream->sample_aspect_ratio : undef;
- AVRational codec_sample_aspect_ratio = stream && stream->codec ? stream->codec->sample_aspect_ratio : undef;
+ AVRational codec_sample_aspect_ratio = stream && stream->codecpar ? stream->codecpar->sample_aspect_ratio : undef;
AVRational frame_sample_aspect_ratio = frame ? frame->sample_aspect_ratio : codec_sample_aspect_ratio;
av_reduce(&stream_sample_aspect_ratio.num, &stream_sample_aspect_ratio.den,
@@ -4401,7 +4597,7 @@ AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *strea
AVRational av_guess_frame_rate(AVFormatContext *format, AVStream *st, AVFrame *frame)
{
AVRational fr = st->r_frame_rate;
- AVRational codec_fr = st->codec->framerate;
+ AVRational codec_fr = st->internal->avctx->framerate;
AVRational avg_fr = st->avg_frame_rate;
if (avg_fr.num > 0 && avg_fr.den > 0 && fr.num > 0 && fr.den > 0 &&
@@ -4410,7 +4606,7 @@ AVRational av_guess_frame_rate(AVFormatContext *format, AVStream *st, AVFrame *f
}
- if (st->codec->ticks_per_frame > 1) {
+ if (st->internal->avctx->ticks_per_frame > 1) {
if ( codec_fr.num > 0 && codec_fr.den > 0 &&
(fr.num == 0 || av_q2d(codec_fr) < av_q2d(fr)*0.7 && fabs(1.0 - av_q2d(av_div_q(avg_fr, fr))) > 0.1))
fr = codec_fr;
@@ -4438,17 +4634,37 @@ int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
case 'V': type = AVMEDIA_TYPE_VIDEO; nopic = 1; break;
default: av_assert0(0);
}
- if (type != st->codec->codec_type)
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (type != st->codecpar->codec_type
+ && (st->codecpar->codec_type != AVMEDIA_TYPE_UNKNOWN || st->codec->codec_type != type))
+ return 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#else
+ if (type != st->codecpar->codec_type)
return 0;
+#endif
if (nopic && (st->disposition & AV_DISPOSITION_ATTACHED_PIC))
return 0;
if (*spec++ == ':') { /* possibly followed by :index */
int i, index = strtol(spec, NULL, 0);
- for (i = 0; i < s->nb_streams; i++)
- if (s->streams[i]->codec->codec_type == type &&
+ for (i = 0; i < s->nb_streams; i++) {
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+ if ((s->streams[i]->codecpar->codec_type == type
+ || s->streams[i]->codec->codec_type == type
+ ) &&
!(nopic && (st->disposition & AV_DISPOSITION_ATTACHED_PIC)) &&
index-- == 0)
return i == st->index;
+FF_ENABLE_DEPRECATION_WARNINGS
+#else
+ if ((s->streams[i]->codecpar->codec_type == type) &&
+ !(nopic && (st->disposition & AV_DISPOSITION_ATTACHED_PIC)) &&
+ index-- == 0)
+ return i == st->index;
+#endif
+ }
return 0;
}
return 1;
@@ -4505,17 +4721,36 @@ int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
av_freep(&key);
return ret;
} else if (*spec == 'u') {
- AVCodecContext *avctx = st->codec;
+ AVCodecParameters *par = st->codecpar;
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+ AVCodecContext *codec = st->codec;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
int val;
- switch (avctx->codec_type) {
+ switch (par->codec_type) {
case AVMEDIA_TYPE_AUDIO:
- val = avctx->sample_rate && avctx->channels;
- if (avctx->sample_fmt == AV_SAMPLE_FMT_NONE)
+ val = par->sample_rate && par->channels;
+#if FF_API_LAVF_AVCTX
+ val = val || (codec->sample_rate && codec->channels);
+#endif
+ if (par->format == AV_SAMPLE_FMT_NONE
+#if FF_API_LAVF_AVCTX
+ && codec->sample_fmt == AV_SAMPLE_FMT_NONE
+#endif
+ )
return 0;
break;
case AVMEDIA_TYPE_VIDEO:
- val = avctx->width && avctx->height;
- if (avctx->pix_fmt == AV_PIX_FMT_NONE)
+ val = par->width && par->height;
+#if FF_API_LAVF_AVCTX
+ val = val || (codec->width && codec->height);
+#endif
+ if (par->format == AV_PIX_FMT_NONE
+#if FF_API_LAVF_AVCTX
+ && codec->pix_fmt == AV_PIX_FMT_NONE
+#endif
+ )
return 0;
break;
case AVMEDIA_TYPE_UNKNOWN:
@@ -4525,7 +4760,11 @@ int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
val = 1;
break;
}
- return avctx->codec_id != AV_CODEC_ID_NONE && val != 0;
+#if FF_API_LAVF_AVCTX
+ return (par->codec_id != AV_CODEC_ID_NONE || codec->codec_id != AV_CODEC_ID_NONE) && val != 0;
+#else
+ return par->codec_id != AV_CODEC_ID_NONE && val != 0;
+#endif
} else if (!*spec) /* empty specifier, matches everything */
return 1;
@@ -4634,26 +4873,26 @@ int ff_generate_avci_extradata(AVStream *st)
const uint8_t *data = NULL;
int size = 0;
- if (st->codec->width == 1920) {
- if (st->codec->field_order == AV_FIELD_PROGRESSIVE) {
+ if (st->codecpar->width == 1920) {
+ if (st->codecpar->field_order == AV_FIELD_PROGRESSIVE) {
data = avci100_1080p_extradata;
size = sizeof(avci100_1080p_extradata);
} else {
data = avci100_1080i_extradata;
size = sizeof(avci100_1080i_extradata);
}
- } else if (st->codec->width == 1440) {
- if (st->codec->field_order == AV_FIELD_PROGRESSIVE) {
+ } else if (st->codecpar->width == 1440) {
+ if (st->codecpar->field_order == AV_FIELD_PROGRESSIVE) {
data = avci50_1080p_extradata;
size = sizeof(avci50_1080p_extradata);
} else {
data = avci50_1080i_extradata;
size = sizeof(avci50_1080i_extradata);
}
- } else if (st->codec->width == 1280) {
+ } else if (st->codecpar->width == 1280) {
data = avci100_720p_extradata;
size = sizeof(avci100_720p_extradata);
- } else if (st->codec->width == 960) {
+ } else if (st->codecpar->width == 960) {
data = avci50_720p_extradata;
size = sizeof(avci50_720p_extradata);
}
@@ -4661,10 +4900,10 @@ int ff_generate_avci_extradata(AVStream *st)
if (!size)
return 0;
- av_freep(&st->codec->extradata);
- if (ff_alloc_extradata(st->codec, size))
+ av_freep(&st->codecpar->extradata);
+ if (ff_alloc_extradata(st->codecpar, size))
return AVERROR(ENOMEM);
- memcpy(st->codec->extradata, data, size);
+ memcpy(st->codecpar->extradata, data, size);
return 0;
}
@@ -4736,7 +4975,7 @@ int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *a
av_bitstream_filter_close(bsfc);
return AVERROR(ENOMEM);
}
- av_log(st->codec, AV_LOG_VERBOSE,
+ av_log(NULL, AV_LOG_VERBOSE,
"Automatically inserted bitstream filter '%s'; args='%s'\n",
name, args ? args : "");
*dest = bsfc;
diff --git a/libavformat/v210.c b/libavformat/v210.c
index 31387a4d48..24ce042ff5 100644
--- a/libavformat/v210.c
+++ b/libavformat/v210.c
@@ -45,21 +45,21 @@ static int v210_read_header(AVFormatContext *ctx)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = ctx->iformat->raw_codec_id;
+ st->codecpar->codec_id = ctx->iformat->raw_codec_id;
avpriv_set_pts_info(st, 64, s->framerate.den, s->framerate.num);
ret = av_image_check_size(s->width, s->height, 0, ctx);
if (ret < 0)
return ret;
- st->codec->width = s->width;
- st->codec->height = s->height;
- st->codec->pix_fmt = ctx->iformat->raw_codec_id == AV_CODEC_ID_V210 ?
- AV_PIX_FMT_YUV422P10 : AV_PIX_FMT_YUV422P16;
- ctx->packet_size = GET_PACKET_SIZE(s->width, s->height);
- st->codec->bit_rate = av_rescale_q(ctx->packet_size,
+ st->codecpar->width = s->width;
+ st->codecpar->height = s->height;
+ st->codecpar->format = ctx->iformat->raw_codec_id == AV_CODEC_ID_V210 ?
+ AV_PIX_FMT_YUV422P10 : AV_PIX_FMT_YUV422P16;
+ ctx->packet_size = GET_PACKET_SIZE(s->width, s->height);
+ st->codecpar->bit_rate = av_rescale_q(ctx->packet_size,
(AVRational){8,1}, st->time_base);
return 0;
diff --git a/libavformat/vag.c b/libavformat/vag.c
index 2875db501e..e8ebcaffd6 100644
--- a/libavformat/vag.c
+++ b/libavformat/vag.c
@@ -40,37 +40,37 @@ static int vag_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avio_skip(s->pb, 4);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_ADPCM_PSX;
- st->codec->channels = 1 + (avio_rb32(s->pb) == 0x00000004);
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX;
+ st->codecpar->channels = 1 + (avio_rb32(s->pb) == 0x00000004);
avio_skip(s->pb, 4);
- if (st->codec->channels > 1) {
+ if (st->codecpar->channels > 1) {
st->duration = avio_rb32(s->pb);
} else {
st->duration = avio_rb32(s->pb) / 16 * 28;
}
- st->codec->sample_rate = avio_rb32(s->pb);
- if (st->codec->sample_rate <= 0)
+ st->codecpar->sample_rate = avio_rb32(s->pb);
+ if (st->codecpar->sample_rate <= 0)
return AVERROR_INVALIDDATA;
avio_seek(s->pb, 0x1000, SEEK_SET);
if (avio_rl32(s->pb) == MKTAG('V','A','G','p')) {
- st->codec->block_align = 0x1000 * st->codec->channels;
+ st->codecpar->block_align = 0x1000 * st->codecpar->channels;
avio_seek(s->pb, 0, SEEK_SET);
st->duration = st->duration / 16 * 28;
} else {
- st->codec->block_align = 16 * st->codec->channels;
- avio_seek(s->pb, st->codec->channels > 1 ? 0x80 : 0x30, SEEK_SET);
+ st->codecpar->block_align = 16 * st->codecpar->channels;
+ avio_seek(s->pb, st->codecpar->channels > 1 ? 0x80 : 0x30, SEEK_SET);
}
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
static int vag_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- AVCodecContext *codec = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
- return av_get_packet(s->pb, pkt, codec->block_align);
+ return av_get_packet(s->pb, pkt, par->block_align);
}
AVInputFormat ff_vag_demuxer = {
diff --git a/libavformat/vc1test.c b/libavformat/vc1test.c
index 3afe398d8b..1414426d02 100644
--- a/libavformat/vc1test.c
+++ b/libavformat/vc1test.c
@@ -58,13 +58,13 @@ static int vc1t_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_WMV3;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_WMV3;
- if (ff_get_extradata(st->codec, pb, VC1_EXTRADATA_SIZE) < 0)
+ if (ff_get_extradata(st->codecpar, pb, VC1_EXTRADATA_SIZE) < 0)
return AVERROR(ENOMEM);
- st->codec->height = avio_rl32(pb);
- st->codec->width = avio_rl32(pb);
+ st->codecpar->height = avio_rl32(pb);
+ st->codecpar->width = avio_rl32(pb);
if(avio_rl32(pb) != 0xC)
return AVERROR_INVALIDDATA;
avio_skip(pb, 8);
diff --git a/libavformat/vc1testenc.c b/libavformat/vc1testenc.c
index 751333a4b8..60fb894a97 100644
--- a/libavformat/vc1testenc.c
+++ b/libavformat/vc1testenc.c
@@ -27,19 +27,19 @@ typedef struct RCVContext {
static int vc1test_write_header(AVFormatContext *s)
{
- AVCodecContext *avc = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
AVIOContext *pb = s->pb;
- if (avc->codec_id != AV_CODEC_ID_WMV3) {
+ if (par->codec_id != AV_CODEC_ID_WMV3) {
av_log(s, AV_LOG_ERROR, "Only WMV3 is accepted!\n");
return -1;
}
avio_wl24(pb, 0); //frames count will be here
avio_w8(pb, 0xC5);
avio_wl32(pb, 4);
- avio_write(pb, avc->extradata, 4);
- avio_wl32(pb, avc->height);
- avio_wl32(pb, avc->width);
+ avio_write(pb, par->extradata, 4);
+ avio_wl32(pb, par->height);
+ avio_wl32(pb, par->width);
avio_wl32(pb, 0xC);
avio_wl24(pb, 0); // hrd_buffer
avio_w8(pb, 0x80); // level|cbr|res1
diff --git a/libavformat/version.h b/libavformat/version.h
index 92a77efb11..d3408eb968 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -74,6 +74,9 @@
#ifndef FF_API_OLD_OPEN_CALLBACKS
#define FF_API_OLD_OPEN_CALLBACKS (LIBAVFORMAT_VERSION_MAJOR < 58)
#endif
+#ifndef FF_API_LAVF_AVCTX
+#define FF_API_LAVF_AVCTX (LIBAVFORMAT_VERSION_MAJOR < 58)
+#endif
#ifndef FF_API_R_FRAME_RATE
#define FF_API_R_FRAME_RATE 1
diff --git a/libavformat/vivo.c b/libavformat/vivo.c
index 10d81b9142..a9effd5835 100644
--- a/libavformat/vivo.c
+++ b/libavformat/vivo.c
@@ -131,7 +131,7 @@ static int vivo_read_header(AVFormatContext *s)
if (!ast || !vst)
return AVERROR(ENOMEM);
- ast->codec->sample_rate = 8000;
+ ast->codecpar->sample_rate = 8000;
while (1) {
if ((ret = vivo_get_packet_header(s)) < 0)
@@ -182,15 +182,15 @@ static int vivo_read_header(AVFormatContext *s)
if (!strcmp(key, "Duration")) {
duration = value_int;
} else if (!strcmp(key, "Width")) {
- vst->codec->width = value_int;
+ vst->codecpar->width = value_int;
} else if (!strcmp(key, "Height")) {
- vst->codec->height = value_int;
+ vst->codecpar->height = value_int;
} else if (!strcmp(key, "TimeUnitNumerator")) {
fps.num = value_int / 1000;
} else if (!strcmp(key, "TimeUnitDenominator")) {
fps.den = value_int;
} else if (!strcmp(key, "SamplingFrequency")) {
- ast->codec->sample_rate = value_int;
+ ast->codecpar->sample_rate = value_int;
} else if (!strcmp(key, "NominalBitrate")) {
} else if (!strcmp(key, "Length")) {
// size of file
@@ -216,27 +216,27 @@ static int vivo_read_header(AVFormatContext *s)
}
}
- avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
+ avpriv_set_pts_info(ast, 64, 1, ast->codecpar->sample_rate);
avpriv_set_pts_info(vst, 64, fps.num, fps.den);
if (duration)
s->duration = av_rescale(duration, 1000, 1);
vst->start_time = 0;
- vst->codec->codec_tag = 0;
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_tag = 0;
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
if (vivo->version == 1) {
- vst->codec->codec_id = AV_CODEC_ID_H263;
- ast->codec->codec_id = AV_CODEC_ID_G723_1;
- ast->codec->bits_per_coded_sample = 8;
- ast->codec->block_align = 24;
- ast->codec->bit_rate = 6400;
+ vst->codecpar->codec_id = AV_CODEC_ID_H263;
+ ast->codecpar->codec_id = AV_CODEC_ID_G723_1;
+ ast->codecpar->bits_per_coded_sample = 8;
+ ast->codecpar->block_align = 24;
+ ast->codecpar->bit_rate = 6400;
}
ast->start_time = 0;
- ast->codec->codec_tag = 0;
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- ast->codec->channels = 1;
+ ast->codecpar->codec_tag = 0;
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codecpar->channels = 1;
return 0;
}
diff --git a/libavformat/voc_packet.c b/libavformat/voc_packet.c
index f4b82312f7..5833a79b56 100644
--- a/libavformat/voc_packet.c
+++ b/libavformat/voc_packet.c
@@ -27,7 +27,7 @@ int
ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
{
VocDecContext *voc = s->priv_data;
- AVCodecContext *dec = st->codec;
+ AVCodecParameters *par = st->codecpar;
AVIOContext *pb = s->pb;
VocType type;
int size, tmp_codec=-1;
@@ -57,13 +57,13 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
switch (type) {
case VOC_TYPE_VOICE_DATA:
- if (!dec->sample_rate) {
- dec->sample_rate = 1000000 / (256 - avio_r8(pb));
+ if (!par->sample_rate) {
+ par->sample_rate = 1000000 / (256 - avio_r8(pb));
if (sample_rate)
- dec->sample_rate = sample_rate;
- avpriv_set_pts_info(st, 64, 1, dec->sample_rate);
- dec->channels = channels;
- dec->bits_per_coded_sample = av_get_bits_per_sample(dec->codec_id);
+ par->sample_rate = sample_rate;
+ avpriv_set_pts_info(st, 64, 1, par->sample_rate);
+ par->channels = channels;
+ par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);
} else
avio_skip(pb, 1);
tmp_codec = avio_r8(pb);
@@ -85,11 +85,11 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
break;
case VOC_TYPE_NEW_VOICE_DATA:
- if (!dec->sample_rate) {
- dec->sample_rate = avio_rl32(pb);
- avpriv_set_pts_info(st, 64, 1, dec->sample_rate);
- dec->bits_per_coded_sample = avio_r8(pb);
- dec->channels = avio_r8(pb);
+ if (!par->sample_rate) {
+ par->sample_rate = avio_rl32(pb);
+ avpriv_set_pts_info(st, 64, 1, par->sample_rate);
+ par->bits_per_coded_sample = avio_r8(pb);
+ par->channels = avio_r8(pb);
} else
avio_skip(pb, 6);
tmp_codec = avio_rl16(pb);
@@ -108,11 +108,11 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
if (tmp_codec >= 0) {
tmp_codec = ff_codec_get_id(ff_voc_codec_tags, tmp_codec);
- if (dec->codec_id == AV_CODEC_ID_NONE)
- dec->codec_id = tmp_codec;
- else if (dec->codec_id != tmp_codec)
+ if (par->codec_id == AV_CODEC_ID_NONE)
+ par->codec_id = tmp_codec;
+ else if (par->codec_id != tmp_codec)
av_log(s, AV_LOG_WARNING, "Ignoring mid-stream change in audio codec\n");
- if (dec->codec_id == AV_CODEC_ID_NONE) {
+ if (par->codec_id == AV_CODEC_ID_NONE) {
if (s->audio_codec_id == AV_CODEC_ID_NONE) {
av_log(s, AV_LOG_ERROR, "unknown codec tag\n");
return AVERROR(EINVAL);
@@ -121,7 +121,7 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
}
}
- dec->bit_rate = dec->sample_rate * dec->channels * dec->bits_per_coded_sample;
+ par->bit_rate = par->sample_rate * par->channels * par->bits_per_coded_sample;
if (max_size <= 0)
max_size = 2048;
@@ -131,7 +131,7 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
ret = av_get_packet(pb, pkt, size);
pkt->dts = pkt->pts = voc->pts;
- duration = av_get_audio_frame_duration(st->codec, size);
+ duration = av_get_audio_frame_duration2(st->codecpar, size);
if (duration > 0 && voc->pts != AV_NOPTS_VALUE)
voc->pts += duration;
else
diff --git a/libavformat/vocdec.c b/libavformat/vocdec.c
index 0a11b97567..10df28b806 100644
--- a/libavformat/vocdec.c
+++ b/libavformat/vocdec.c
@@ -42,7 +42,6 @@ static int voc_read_header(AVFormatContext *s)
VocDecContext *voc = s->priv_data;
AVIOContext *pb = s->pb;
int header_size;
- AVStream *st;
avio_skip(pb, 20);
header_size = avio_rl16(pb) - 22;
@@ -51,10 +50,8 @@ static int voc_read_header(AVFormatContext *s)
return AVERROR(ENOSYS);
}
avio_skip(pb, header_size);
- st = avformat_new_stream(s, NULL);
- if (!st)
- return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+
+ s->ctx_flags |= AVFMTCTX_NOHEADER;
voc->remaining_size = 0;
return 0;
@@ -62,6 +59,12 @@ static int voc_read_header(AVFormatContext *s)
static int voc_read_packet(AVFormatContext *s, AVPacket *pkt)
{
+ if (!s->nb_streams) {
+ AVStream *st = avformat_new_stream(s, NULL);
+ if (!st)
+ return AVERROR(ENOMEM);
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ }
return ff_voc_get_packet(s, pkt, s->streams[0], 0);
}
@@ -69,8 +72,16 @@ static int voc_read_seek(AVFormatContext *s, int stream_index,
int64_t timestamp, int flags)
{
VocDecContext *voc = s->priv_data;
- AVStream *st = s->streams[stream_index];
- int index = av_index_search_timestamp(st, timestamp, flags);
+ AVStream *st;
+ int index;
+
+ if (s->nb_streams < 1) {
+ av_log(s, AV_LOG_ERROR, "cannot seek while no stream was found yet\n");
+ return AVERROR(EINVAL);
+ }
+
+ st = s->streams[stream_index];
+ index = av_index_search_timestamp(st, timestamp, flags);
if (index >= 0 && index < st->nb_index_entries - 1) {
AVIndexEntry *e = &st->index_entries[index];
diff --git a/libavformat/vocenc.c b/libavformat/vocenc.c
index 0bb532e0c6..321b113032 100644
--- a/libavformat/vocenc.c
+++ b/libavformat/vocenc.c
@@ -30,15 +30,15 @@ typedef struct voc_enc_context {
static int voc_write_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
- AVCodecContext *enc = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
const int header_size = 26;
const int version = 0x0114;
if (s->nb_streams != 1
- || s->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO)
+ || s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
return AVERROR_PATCHWELCOME;
- if (!enc->codec_tag && enc->codec_id != AV_CODEC_ID_PCM_U8) {
+ if (!par->codec_tag && par->codec_id != AV_CODEC_ID_PCM_U8) {
av_log(s, AV_LOG_ERROR, "unsupported codec\n");
return AVERROR(EINVAL);
}
@@ -54,30 +54,30 @@ static int voc_write_header(AVFormatContext *s)
static int voc_write_packet(AVFormatContext *s, AVPacket *pkt)
{
VocEncContext *voc = s->priv_data;
- AVCodecContext *enc = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
AVIOContext *pb = s->pb;
if (!voc->param_written) {
- if (enc->codec_tag > 3) {
+ if (par->codec_tag > 3) {
avio_w8(pb, VOC_TYPE_NEW_VOICE_DATA);
avio_wl24(pb, pkt->size + 12);
- avio_wl32(pb, enc->sample_rate);
- avio_w8(pb, enc->bits_per_coded_sample);
- avio_w8(pb, enc->channels);
- avio_wl16(pb, enc->codec_tag);
+ avio_wl32(pb, par->sample_rate);
+ avio_w8(pb, par->bits_per_coded_sample);
+ avio_w8(pb, par->channels);
+ avio_wl16(pb, par->codec_tag);
avio_wl32(pb, 0);
} else {
- if (s->streams[0]->codec->channels > 1) {
+ if (s->streams[0]->codecpar->channels > 1) {
avio_w8(pb, VOC_TYPE_EXTENDED);
avio_wl24(pb, 4);
- avio_wl16(pb, 65536-(256000000 + enc->sample_rate*enc->channels/2)/(enc->sample_rate*enc->channels));
- avio_w8(pb, enc->codec_tag);
- avio_w8(pb, enc->channels - 1);
+ avio_wl16(pb, 65536-(256000000 + par->sample_rate*par->channels/2)/(par->sample_rate*par->channels));
+ avio_w8(pb, par->codec_tag);
+ avio_w8(pb, par->channels - 1);
}
avio_w8(pb, VOC_TYPE_VOICE_DATA);
avio_wl24(pb, pkt->size + 2);
- avio_w8(pb, 256 - (1000000 + enc->sample_rate/2) / enc->sample_rate);
- avio_w8(pb, enc->codec_tag);
+ avio_w8(pb, 256 - (1000000 + par->sample_rate/2) / par->sample_rate);
+ avio_w8(pb, par->codec_tag);
}
voc->param_written = 1;
} else {
diff --git a/libavformat/vpk.c b/libavformat/vpk.c
index 751904949f..bb9eabb2ba 100644
--- a/libavformat/vpk.c
+++ b/libavformat/vpk.c
@@ -52,41 +52,41 @@ static int vpk_read_header(AVFormatContext *s)
avio_skip(s->pb, 4);
st->duration = avio_rl32(s->pb) * 28 / 16;
offset = avio_rl32(s->pb);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_ADPCM_PSX;
- st->codec->block_align = avio_rl32(s->pb);
- st->codec->sample_rate = avio_rl32(s->pb);
- if (st->codec->sample_rate <= 0)
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX;
+ st->codecpar->block_align = avio_rl32(s->pb);
+ st->codecpar->sample_rate = avio_rl32(s->pb);
+ if (st->codecpar->sample_rate <= 0)
return AVERROR_INVALIDDATA;
- st->codec->channels = avio_rl32(s->pb);
- if (st->codec->channels <= 0)
+ st->codecpar->channels = avio_rl32(s->pb);
+ if (st->codecpar->channels <= 0)
return AVERROR_INVALIDDATA;
- samples_per_block = ((st->codec->block_align / st->codec->channels) * 28) / 16;
+ samples_per_block = ((st->codecpar->block_align / st->codecpar->channels) * 28) / 16;
if (samples_per_block <= 0)
return AVERROR_INVALIDDATA;
vpk->block_count = (st->duration + (samples_per_block - 1)) / samples_per_block;
- vpk->last_block_size = (st->duration % samples_per_block) * 16 * st->codec->channels / 28;
+ vpk->last_block_size = (st->duration % samples_per_block) * 16 * st->codecpar->channels / 28;
avio_skip(s->pb, offset - avio_tell(s->pb));
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
static int vpk_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- AVCodecContext *codec = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
VPKDemuxContext *vpk = s->priv_data;
int ret, i;
vpk->current_block++;
if (vpk->current_block == vpk->block_count) {
- unsigned size = vpk->last_block_size / codec->channels;
- unsigned skip = (codec->block_align - vpk->last_block_size) / codec->channels;
+ unsigned size = vpk->last_block_size / par->channels;
+ unsigned skip = (par->block_align - vpk->last_block_size) / par->channels;
ret = av_new_packet(pkt, vpk->last_block_size);
if (ret < 0)
return ret;
- for (i = 0; i < codec->channels; i++) {
+ for (i = 0; i < par->channels; i++) {
ret = avio_read(s->pb, pkt->data + i * size, size);
avio_skip(s->pb, skip);
if (ret != size) {
@@ -97,7 +97,7 @@ static int vpk_read_packet(AVFormatContext *s, AVPacket *pkt)
}
pkt->stream_index = 0;
} else if (vpk->current_block < vpk->block_count) {
- ret = av_get_packet(s->pb, pkt, codec->block_align);
+ ret = av_get_packet(s->pb, pkt, par->block_align);
pkt->stream_index = 0;
} else {
return AVERROR_EOF;
diff --git a/libavformat/vplayerdec.c b/libavformat/vplayerdec.c
index 2bb7f32829..897c4083b6 100644
--- a/libavformat/vplayerdec.c
+++ b/libavformat/vplayerdec.c
@@ -63,8 +63,8 @@ static int vplayer_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 100);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_VPLAYER;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_VPLAYER;
while (!avio_feof(s->pb)) {
char line[4096];
diff --git a/libavformat/vqf.c b/libavformat/vqf.c
index 3c897e1cc6..969fbefea6 100644
--- a/libavformat/vqf.c
+++ b/libavformat/vqf.c
@@ -107,8 +107,8 @@ static int vqf_read_header(AVFormatContext *s)
header_size = avio_rb32(s->pb);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_TWINVQ;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_TWINVQ;
st->start_time = 0;
do {
@@ -130,17 +130,17 @@ static int vqf_read_header(AVFormatContext *s)
switch(chunk_tag){
case MKTAG('C','O','M','M'):
avio_read(s->pb, comm_chunk, 12);
- st->codec->channels = AV_RB32(comm_chunk ) + 1;
+ st->codecpar->channels = AV_RB32(comm_chunk ) + 1;
read_bitrate = AV_RB32(comm_chunk + 4);
rate_flag = AV_RB32(comm_chunk + 8);
avio_skip(s->pb, len-12);
- if (st->codec->channels <= 0) {
+ if (st->codecpar->channels <= 0) {
av_log(s, AV_LOG_ERROR, "Invalid number of channels\n");
return AVERROR_INVALIDDATA;
}
- st->codec->bit_rate = read_bitrate*1000;
+ st->codecpar->bit_rate = read_bitrate * 1000;
break;
case MKTAG('D','S','I','Z'): // size of compressed data
{
@@ -169,32 +169,32 @@ static int vqf_read_header(AVFormatContext *s)
av_log(s, AV_LOG_ERROR, "COMM tag not found!\n");
return -1;
case 44:
- st->codec->sample_rate = 44100;
+ st->codecpar->sample_rate = 44100;
break;
case 22:
- st->codec->sample_rate = 22050;
+ st->codecpar->sample_rate = 22050;
break;
case 11:
- st->codec->sample_rate = 11025;
+ st->codecpar->sample_rate = 11025;
break;
default:
if (rate_flag < 8 || rate_flag > 44) {
av_log(s, AV_LOG_ERROR, "Invalid rate flag %d\n", rate_flag);
return AVERROR_INVALIDDATA;
}
- st->codec->sample_rate = rate_flag*1000;
+ st->codecpar->sample_rate = rate_flag*1000;
break;
}
- if (read_bitrate / st->codec->channels < 8 ||
- read_bitrate / st->codec->channels > 48) {
+ if (read_bitrate / st->codecpar->channels < 8 ||
+ read_bitrate / st->codecpar->channels > 48) {
av_log(s, AV_LOG_ERROR, "Invalid bitrate per channel %d\n",
- read_bitrate / st->codec->channels);
+ read_bitrate / st->codecpar->channels);
return AVERROR_INVALIDDATA;
}
- switch (((st->codec->sample_rate/1000) << 8) +
- read_bitrate/st->codec->channels) {
+ switch (((st->codecpar->sample_rate/1000) << 8) +
+ read_bitrate/st->codecpar->channels) {
case (11<<8) + 8 :
case (8 <<8) + 8 :
case (11<<8) + 10:
@@ -212,16 +212,16 @@ static int vqf_read_header(AVFormatContext *s)
break;
default:
av_log(s, AV_LOG_ERROR, "Mode not supported: %d Hz, %"PRId64" kb/s.\n",
- st->codec->sample_rate, (int64_t)st->codec->bit_rate);
+ st->codecpar->sample_rate, (int64_t)st->codecpar->bit_rate);
return -1;
}
- c->frame_bit_len = st->codec->bit_rate*size/st->codec->sample_rate;
- avpriv_set_pts_info(st, 64, size, st->codec->sample_rate);
+ c->frame_bit_len = st->codecpar->bit_rate*size/st->codecpar->sample_rate;
+ avpriv_set_pts_info(st, 64, size, st->codecpar->sample_rate);
/* put first 12 bytes of COMM chunk in extradata */
- if (ff_alloc_extradata(st->codec, 12))
+ if (ff_alloc_extradata(st->codecpar, 12))
return AVERROR(ENOMEM);
- memcpy(st->codec->extradata, comm_chunk, 12);
+ memcpy(st->codecpar->extradata, comm_chunk, 12);
ff_metadata_conv_ctx(s, NULL, vqf_metadata_conv);
@@ -265,7 +265,7 @@ static int vqf_read_seek(AVFormatContext *s,
int64_t pos;
st = s->streams[stream_index];
- pos = av_rescale_rnd(timestamp * st->codec->bit_rate,
+ pos = av_rescale_rnd(timestamp * st->codecpar->bit_rate,
st->time_base.num,
st->time_base.den * (int64_t)c->frame_bit_len,
(flags & AVSEEK_FLAG_BACKWARD) ?
@@ -273,7 +273,7 @@ static int vqf_read_seek(AVFormatContext *s,
pos *= c->frame_bit_len;
st->cur_dts = av_rescale(pos, st->time_base.den,
- st->codec->bit_rate * (int64_t)st->time_base.num);
+ st->codecpar->bit_rate * (int64_t)st->time_base.num);
if ((ret = avio_seek(s->pb, ((pos-7) >> 3) + s->internal->data_offset, SEEK_SET)) < 0)
return ret;
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index ac98fa99d7..7176cd6f2d 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -62,7 +62,7 @@ typedef struct WAVDemuxContext {
static void set_spdif(AVFormatContext *s, WAVDemuxContext *wav)
{
- if (CONFIG_SPDIF_DEMUXER && s->streams[0]->codec->codec_tag == 1) {
+ if (CONFIG_SPDIF_DEMUXER && s->streams[0]->codecpar->codec_tag == 1) {
enum AVCodecID codec;
uint8_t *buf = NULL;
int len = 1<<16;
@@ -84,7 +84,7 @@ static void set_spdif(AVFormatContext *s, WAVDemuxContext *wav)
ret = ff_spdif_probe(buf, len, &codec);
if (ret > AVPROBE_SCORE_EXTENSION) {
- s->streams[0]->codec->codec_id = codec;
+ s->streams[0]->codecpar->codec_id = codec;
wav->spdif = 1;
}
end:
@@ -152,7 +152,7 @@ static int wav_probe(AVProbeData *p)
static void handle_stream_probing(AVStream *st)
{
- if (st->codec->codec_id == AV_CODEC_ID_PCM_S16LE) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE) {
st->request_probe = AVPROBE_SCORE_EXTENSION;
st->probe_packets = FFMIN(st->probe_packets, 32);
}
@@ -169,14 +169,14 @@ static int wav_parse_fmt_tag(AVFormatContext *s, int64_t size, AVStream **st)
if (!*st)
return AVERROR(ENOMEM);
- ret = ff_get_wav_header(s, pb, (*st)->codec, size, wav->rifx);
+ ret = ff_get_wav_header(s, pb, (*st)->codecpar, size, wav->rifx);
if (ret < 0)
return ret;
handle_stream_probing(*st);
(*st)->need_parsing = AVSTREAM_PARSE_FULL_RAW;
- avpriv_set_pts_info(*st, 64, 1, (*st)->codec->sample_rate);
+ avpriv_set_pts_info(*st, 64, 1, (*st)->codecpar->sample_rate);
return 0;
}
@@ -193,16 +193,16 @@ static int wav_parse_xma2_tag(AVFormatContext *s, int64_t size, AVStream **st)
if (!*st)
return AVERROR(ENOMEM);
- (*st)->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- (*st)->codec->codec_id = AV_CODEC_ID_XMA2;
- (*st)->need_parsing = AVSTREAM_PARSE_FULL_RAW;
+ (*st)->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ (*st)->codecpar->codec_id = AV_CODEC_ID_XMA2;
+ (*st)->need_parsing = AVSTREAM_PARSE_FULL_RAW;
avio_skip(pb, 1);
num_streams = avio_r8(pb);
if (size < 40 + num_streams * 4)
return AVERROR_INVALIDDATA;
avio_skip(pb, 10);
- (*st)->codec->sample_rate = avio_rb32(pb);
+ (*st)->codecpar->sample_rate = avio_rb32(pb);
avio_skip(pb, 12);
(*st)->duration = avio_rb32(pb);
avio_skip(pb, 8);
@@ -211,15 +211,15 @@ static int wav_parse_xma2_tag(AVFormatContext *s, int64_t size, AVStream **st)
channels += avio_r8(pb);
avio_skip(pb, 3);
}
- (*st)->codec->channels = channels;
+ (*st)->codecpar->channels = channels;
- if ((*st)->codec->channels <= 0 || (*st)->codec->sample_rate <= 0)
+ if ((*st)->codecpar->channels <= 0 || (*st)->codecpar->sample_rate <= 0)
return AVERROR_INVALIDDATA;
- avpriv_set_pts_info(*st, 64, 1, (*st)->codec->sample_rate);
- if (ff_alloc_extradata((*st)->codec, 34))
+ avpriv_set_pts_info(*st, 64, 1, (*st)->codecpar->sample_rate);
+ if (ff_alloc_extradata((*st)->codecpar, 34))
return AVERROR(ENOMEM);
- memset((*st)->codec->extradata, 0, 34);
+ memset((*st)->codecpar->extradata, 0, 34);
return 0;
}
@@ -465,11 +465,11 @@ static int wav_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avio_r8(pb);
vst->id = 1;
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_id = AV_CODEC_ID_SMVJPEG;
- vst->codec->width = avio_rl24(pb);
- vst->codec->height = avio_rl24(pb);
- if (ff_alloc_extradata(vst->codec, 4)) {
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_id = AV_CODEC_ID_SMVJPEG;
+ vst->codecpar->width = avio_rl24(pb);
+ vst->codecpar->height = avio_rl24(pb);
+ if (ff_alloc_extradata(vst->codecpar, 4)) {
av_log(s, AV_LOG_ERROR, "Could not allocate extradata.\n");
return AVERROR(ENOMEM);
}
@@ -486,7 +486,7 @@ static int wav_read_header(AVFormatContext *s)
av_log(s, AV_LOG_ERROR, "too many frames per jpeg\n");
return AVERROR_INVALIDDATA;
}
- AV_WL32(vst->codec->extradata, wav->smv_frames_per_jpeg);
+ AV_WL32(vst->codecpar->extradata, wav->smv_frames_per_jpeg);
wav->smv_cur_pt = 0;
goto break_loop;
case MKTAG('L', 'I', 'S', 'T'):
@@ -526,36 +526,36 @@ break_loop:
data_size = 0;
}
- if ( st->codec->bit_rate > 0 && data_size > 0
- && st->codec->sample_rate > 0
- && sample_count > 0 && st->codec->channels > 1
- && sample_count % st->codec->channels == 0) {
- if (fabs(8.0 * data_size * st->codec->channels * st->codec->sample_rate /
- sample_count /st->codec->bit_rate - 1.0) < 0.3)
- sample_count /= st->codec->channels;
+ if ( st->codecpar->bit_rate > 0 && data_size > 0
+ && st->codecpar->sample_rate > 0
+ && sample_count > 0 && st->codecpar->channels > 1
+ && sample_count % st->codecpar->channels == 0) {
+ if (fabs(8.0 * data_size * st->codecpar->channels * st->codecpar->sample_rate /
+ sample_count /st->codecpar->bit_rate - 1.0) < 0.3)
+ sample_count /= st->codecpar->channels;
}
- if ( data_size > 0 && sample_count && st->codec->channels
- && (data_size << 3) / sample_count / st->codec->channels > st->codec->bits_per_coded_sample + 1) {
+ if ( data_size > 0 && sample_count && st->codecpar->channels
+ && (data_size << 3) / sample_count / st->codecpar->channels > st->codecpar->bits_per_coded_sample + 1) {
av_log(s, AV_LOG_WARNING, "ignoring wrong sample_count %"PRId64"\n", sample_count);
sample_count = 0;
}
/* G.729 hack (for Ticket4577)
* FIXME: Come up with cleaner, more general solution */
- if (st->codec->codec_id == AV_CODEC_ID_G729 && sample_count && (data_size << 3) > sample_count) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_G729 && sample_count && (data_size << 3) > sample_count) {
av_log(s, AV_LOG_WARNING, "ignoring wrong sample_count %"PRId64"\n", sample_count);
sample_count = 0;
}
- if (!sample_count || av_get_exact_bits_per_sample(st->codec->codec_id) > 0)
- if ( st->codec->channels
+ if (!sample_count || av_get_exact_bits_per_sample(st->codecpar->codec_id) > 0)
+ if ( st->codecpar->channels
&& data_size
- && av_get_bits_per_sample(st->codec->codec_id)
+ && av_get_bits_per_sample(st->codecpar->codec_id)
&& wav->data_end <= avio_size(pb))
sample_count = (data_size << 3)
/
- (st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id));
+ (st->codecpar->channels * (uint64_t)av_get_bits_per_sample(st->codecpar->codec_id));
if (sample_count)
st->duration = sample_count;
@@ -668,10 +668,10 @@ smv_out:
}
size = MAX_SIZE;
- if (st->codec->block_align > 1) {
- if (size < st->codec->block_align)
- size = st->codec->block_align;
- size = (size / st->codec->block_align) * st->codec->block_align;
+ if (st->codecpar->block_align > 1) {
+ if (size < st->codecpar->block_align)
+ size = st->codecpar->block_align;
+ size = (size / st->codecpar->block_align) * st->codecpar->block_align;
}
size = FFMIN(size, left);
ret = av_get_packet(s->pb, pkt, size);
@@ -702,7 +702,7 @@ static int wav_read_seek(AVFormatContext *s,
}
st = s->streams[0];
- switch (st->codec->codec_id) {
+ switch (st->codecpar->codec_id) {
case AV_CODEC_ID_MP2:
case AV_CODEC_ID_MP3:
case AV_CODEC_ID_AC3:
@@ -792,12 +792,12 @@ static int w64_read_header(AVFormatContext *s)
if (!memcmp(guid, ff_w64_guid_fmt, 16)) {
/* subtract chunk header size - normal wav file doesn't count it */
- ret = ff_get_wav_header(s, pb, st->codec, size - 24, 0);
+ ret = ff_get_wav_header(s, pb, st->codecpar, size - 24, 0);
if (ret < 0)
return ret;
avio_skip(pb, FFALIGN(size, INT64_C(8)) - size);
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
} else if (!memcmp(guid, ff_w64_guid_fact, 16)) {
int64_t samples;
diff --git a/libavformat/wavenc.c b/libavformat/wavenc.c
index 0156f6e8a3..a21d4c547e 100644
--- a/libavformat/wavenc.c
+++ b/libavformat/wavenc.c
@@ -155,18 +155,19 @@ static av_cold void peak_free_buffers(AVFormatContext *s)
static av_cold int peak_init_writer(AVFormatContext *s)
{
WAVMuxContext *wav = s->priv_data;
- AVCodecContext *enc = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
- if (enc->codec_id != AV_CODEC_ID_PCM_S8 &&
- enc->codec_id != AV_CODEC_ID_PCM_S16LE &&
- enc->codec_id != AV_CODEC_ID_PCM_U8 &&
- enc->codec_id != AV_CODEC_ID_PCM_U16LE) {
+ if (par->codec_id != AV_CODEC_ID_PCM_S8 &&
+ par->codec_id != AV_CODEC_ID_PCM_S16LE &&
+ par->codec_id != AV_CODEC_ID_PCM_U8 &&
+ par->codec_id != AV_CODEC_ID_PCM_U16LE) {
+ AVCodec *codec = avcodec_find_decoder(s->streams[0]->codecpar->codec_id);
av_log(s, AV_LOG_ERROR, "%s codec not supported for Peak Chunk\n",
- s->streams[0]->codec->codec ? s->streams[0]->codec->codec->name : "NONE");
+ codec ? codec->name : "NONE");
return -1;
}
- wav->peak_bps = av_get_bits_per_sample(enc->codec_id) / 8;
+ wav->peak_bps = av_get_bits_per_sample(par->codec_id) / 8;
if (wav->peak_bps == 1 && wav->peak_format == PEAK_FORMAT_UINT16) {
av_log(s, AV_LOG_ERROR,
@@ -174,8 +175,8 @@ static av_cold int peak_init_writer(AVFormatContext *s)
return AVERROR(EINVAL);
}
- wav->peak_maxpos = av_mallocz_array(enc->channels, sizeof(*wav->peak_maxpos));
- wav->peak_maxneg = av_mallocz_array(enc->channels, sizeof(*wav->peak_maxneg));
+ wav->peak_maxpos = av_mallocz_array(par->channels, sizeof(*wav->peak_maxpos));
+ wav->peak_maxneg = av_mallocz_array(par->channels, sizeof(*wav->peak_maxneg));
wav->peak_output = av_malloc(PEAK_BUFFER_SIZE);
if (!wav->peak_maxpos || !wav->peak_maxneg || !wav->peak_output)
goto nomem;
@@ -193,14 +194,14 @@ nomem:
static void peak_write_frame(AVFormatContext *s)
{
WAVMuxContext *wav = s->priv_data;
- AVCodecContext *enc = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
int peak_of_peaks;
int c;
if (!wav->peak_output)
return;
- for (c = 0; c < enc->channels; c++) {
+ for (c = 0; c < par->channels; c++) {
wav->peak_maxneg[c] = -wav->peak_maxneg[c];
if (wav->peak_bps == 2 && wav->peak_format == PEAK_FORMAT_UINT8) {
@@ -256,7 +257,7 @@ static int peak_write_chunk(AVFormatContext *s)
{
WAVMuxContext *wav = s->priv_data;
AVIOContext *pb = s->pb;
- AVCodecContext *enc = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
int64_t peak = ff_start_tag(s->pb, "levl");
int64_t now0;
time_t now_secs;
@@ -284,7 +285,7 @@ static int peak_write_chunk(AVFormatContext *s)
avio_wl32(pb, wav->peak_format); /* 8 or 16 bit */
avio_wl32(pb, wav->peak_ppv); /* positive and negative */
avio_wl32(pb, wav->peak_block_size); /* frames per value */
- avio_wl32(pb, enc->channels); /* number of channels */
+ avio_wl32(pb, par->channels); /* number of channels */
avio_wl32(pb, wav->peak_num_frames); /* number of peak frames */
avio_wl32(pb, wav->peak_pos_pop); /* audio sample frame index */
avio_wl32(pb, 128); /* equal to size of header */
@@ -333,8 +334,8 @@ static int wav_write_header(AVFormatContext *s)
if (wav->write_peak != 2) {
/* format header */
fmt = ff_start_tag(pb, "fmt ");
- if (ff_put_wav_header(pb, s->streams[0]->codec, 0) < 0) {
- const AVCodecDescriptor *desc = avcodec_descriptor_get(s->streams[0]->codec->codec_id);
+ if (ff_put_wav_header(s, pb, s->streams[0]->codecpar, 0) < 0) {
+ const AVCodecDescriptor *desc = avcodec_descriptor_get(s->streams[0]->codecpar->codec_id);
av_log(s, AV_LOG_ERROR, "%s codec not supported in WAVE format\n",
desc ? desc->name : "unknown");
return AVERROR(ENOSYS);
@@ -342,7 +343,7 @@ static int wav_write_header(AVFormatContext *s)
ff_end_tag(pb, fmt);
}
- if (s->streams[0]->codec->codec_tag != 0x01 /* hence for all other than PCM */
+ if (s->streams[0]->codecpar->codec_tag != 0x01 /* hence for all other than PCM */
&& s->pb->seekable) {
wav->fact_pos = ff_start_tag(pb, "fact");
avio_wl32(pb, 0);
@@ -358,7 +359,7 @@ static int wav_write_header(AVFormatContext *s)
return ret;
}
- 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);
wav->maxpts = wav->last_duration = 0;
wav->minpts = INT64_MAX;
@@ -394,7 +395,7 @@ static int wav_write_packet(AVFormatContext *s, AVPacket *pkt)
wav->peak_maxpos[c] = FFMAX(wav->peak_maxpos[c], (int16_t)AV_RL16(pkt->data + i));
wav->peak_maxneg[c] = FFMIN(wav->peak_maxneg[c], (int16_t)AV_RL16(pkt->data + i));
}
- if (++c == s->streams[0]->codec->channels) {
+ if (++c == s->streams[0]->codecpar->channels) {
c = 0;
if (++wav->peak_block_pos == wav->peak_block_size) {
peak_write_frame(s);
@@ -453,10 +454,10 @@ static int wav_write_trailer(AVFormatContext *s)
}
number_of_samples = av_rescale(wav->maxpts - wav->minpts + wav->last_duration,
- s->streams[0]->codec->sample_rate * (int64_t)s->streams[0]->time_base.num,
+ s->streams[0]->codecpar->sample_rate * (int64_t)s->streams[0]->time_base.num,
s->streams[0]->time_base.den);
- if(s->streams[0]->codec->codec_tag != 0x01) {
+ if(s->streams[0]->codecpar->codec_tag != 0x01) {
/* Update num_samps in fact chunk */
avio_seek(pb, wav->fact_pos, SEEK_SET);
if (rf64 || (wav->rf64 == RF64_AUTO && number_of_samples > UINT32_MAX)) {
@@ -574,14 +575,15 @@ static int w64_write_header(AVFormatContext *s)
avio_wl64(pb, -1);
avio_write(pb, ff_w64_guid_wave, sizeof(ff_w64_guid_wave));
start_guid(pb, ff_w64_guid_fmt, &start);
- if ((ret = ff_put_wav_header(pb, s->streams[0]->codec, 0)) < 0) {
+ if ((ret = ff_put_wav_header(s, pb, s->streams[0]->codecpar, 0)) < 0) {
+ AVCodec *codec = avcodec_find_decoder(s->streams[0]->codecpar->codec_id);
av_log(s, AV_LOG_ERROR, "%s codec not supported\n",
- s->streams[0]->codec->codec ? s->streams[0]->codec->codec->name : "NONE");
+ codec ? codec->name : "NONE");
return ret;
}
end_guid(pb, start);
- if (s->streams[0]->codec->codec_tag != 0x01 /* hence for all other than PCM */
+ if (s->streams[0]->codecpar->codec_tag != 0x01 /* hence for all other than PCM */
&& s->pb->seekable) {
start_guid(pb, ff_w64_guid_fact, &wav->fact_pos);
avio_wl64(pb, 0);
@@ -606,11 +608,11 @@ static int w64_write_trailer(AVFormatContext *s)
avio_seek(pb, 16, SEEK_SET);
avio_wl64(pb, file_size);
- if (s->streams[0]->codec->codec_tag != 0x01) {
+ if (s->streams[0]->codecpar->codec_tag != 0x01) {
int64_t number_of_samples;
number_of_samples = av_rescale(wav->maxpts - wav->minpts + wav->last_duration,
- s->streams[0]->codec->sample_rate * (int64_t)s->streams[0]->time_base.num,
+ s->streams[0]->codecpar->sample_rate * (int64_t)s->streams[0]->time_base.num,
s->streams[0]->time_base.den);
avio_seek(pb, wav->fact_pos + 24, SEEK_SET);
avio_wl64(pb, number_of_samples);
diff --git a/libavformat/wc3movie.c b/libavformat/wc3movie.c
index 04f8667a66..6b4e41e9cc 100644
--- a/libavformat/wc3movie.c
+++ b/libavformat/wc3movie.c
@@ -170,27 +170,27 @@ static int wc3_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 33, 1, WC3_FRAME_FPS);
wc3->video_stream_index = st->index;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_XAN_WC3;
- st->codec->codec_tag = 0; /* no fourcc */
- st->codec->width = wc3->width;
- st->codec->height = wc3->height;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_XAN_WC3;
+ st->codecpar->codec_tag = 0; /* no fourcc */
+ st->codecpar->width = wc3->width;
+ st->codecpar->height = wc3->height;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 33, 1, WC3_FRAME_FPS);
wc3->audio_stream_index = st->index;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
- st->codec->codec_tag = 1;
- st->codec->channels = WC3_AUDIO_CHANNELS;
- st->codec->channel_layout = AV_CH_LAYOUT_MONO;
- st->codec->bits_per_coded_sample = WC3_AUDIO_BITS;
- st->codec->sample_rate = WC3_SAMPLE_RATE;
- st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
- st->codec->bits_per_coded_sample;
- st->codec->block_align = WC3_AUDIO_BITS * WC3_AUDIO_CHANNELS;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
+ st->codecpar->codec_tag = 1;
+ st->codecpar->channels = WC3_AUDIO_CHANNELS;
+ st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+ st->codecpar->bits_per_coded_sample = WC3_AUDIO_BITS;
+ st->codecpar->sample_rate = WC3_SAMPLE_RATE;
+ st->codecpar->bit_rate = st->codecpar->channels * st->codecpar->sample_rate *
+ st->codecpar->bits_per_coded_sample;
+ st->codecpar->block_align = WC3_AUDIO_BITS * WC3_AUDIO_CHANNELS;
return 0;
}
diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c
index 063eb3beb8..9db4fabdcd 100644
--- a/libavformat/webm_chunk.c
+++ b/libavformat/webm_chunk.c
@@ -187,7 +187,7 @@ static int webm_chunk_write_packet(AVFormatContext *s, AVPacket *pkt)
AVStream *st = s->streams[pkt->stream_index];
int ret;
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
wc->duration_written += av_rescale_q(pkt->pts - wc->prev_pts,
st->time_base,
(AVRational) {1, 1000});
@@ -196,9 +196,9 @@ static int webm_chunk_write_packet(AVFormatContext *s, AVPacket *pkt)
// For video, a new chunk is started only on key frames. For audio, a new
// chunk is started based on chunk_duration.
- if ((st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
+ if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
(pkt->flags & AV_PKT_FLAG_KEY)) ||
- (st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
+ (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
(pkt->pts == 0 || wc->duration_written >= wc->chunk_duration))) {
wc->duration_written = 0;
if ((ret = chunk_end(s)) < 0 || (ret = chunk_start(s)) < 0) {
diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c
index 301c045b41..d4b3146790 100644
--- a/libavformat/webmdashenc.c
+++ b/libavformat/webmdashenc.c
@@ -152,17 +152,17 @@ static int bitstream_switching(AVFormatContext *s, AdaptationSet *as) {
int i;
AVDictionaryEntry *gold_track_num = av_dict_get(s->streams[as->streams[0]]->metadata,
TRACK_NUMBER, NULL, 0);
- AVCodecContext *gold_codec = s->streams[as->streams[0]]->codec;
+ AVCodecParameters *gold_par = s->streams[as->streams[0]]->codecpar;
if (!gold_track_num) return 0;
for (i = 1; i < as->nb_streams; i++) {
AVDictionaryEntry *track_num = av_dict_get(s->streams[as->streams[i]]->metadata,
TRACK_NUMBER, NULL, 0);
- AVCodecContext *codec = s->streams[as->streams[i]]->codec;
+ AVCodecParameters *par = s->streams[as->streams[i]]->codecpar;
if (!track_num ||
strncmp(gold_track_num->value, track_num->value, strlen(gold_track_num->value)) ||
- gold_codec->codec_id != codec->codec_id ||
- gold_codec->extradata_size != codec->extradata_size ||
- memcmp(gold_codec->extradata, codec->extradata, codec->extradata_size)) {
+ gold_par->codec_id != par->codec_id ||
+ gold_par->extradata_size != par->extradata_size ||
+ memcmp(gold_par->extradata, par->extradata, par->extradata_size)) {
return 0;
}
}
@@ -189,18 +189,18 @@ static int write_representation(AVFormatContext *s, AVStream *stream, char *id,
avio_printf(s->pb, "<Representation id=\"%s\"", id);
// FIXME: For live, This should be obtained from the input file or as an AVOption.
avio_printf(s->pb, " bandwidth=\"%s\"",
- w->is_live ? (stream->codec->codec_type == AVMEDIA_TYPE_AUDIO ? "128000" : "1000000") : bandwidth->value);
- if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO && output_width)
- avio_printf(s->pb, " width=\"%d\"", stream->codec->width);
- if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO && output_height)
- avio_printf(s->pb, " height=\"%d\"", stream->codec->height);
- if (stream->codec->codec_type == AVMEDIA_TYPE_AUDIO && output_sample_rate)
- avio_printf(s->pb, " audioSamplingRate=\"%d\"", stream->codec->sample_rate);
+ w->is_live ? (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO ? "128000" : "1000000") : bandwidth->value);
+ if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && output_width)
+ avio_printf(s->pb, " width=\"%d\"", stream->codecpar->width);
+ if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && output_height)
+ avio_printf(s->pb, " height=\"%d\"", stream->codecpar->height);
+ if (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && output_sample_rate)
+ avio_printf(s->pb, " audioSamplingRate=\"%d\"", stream->codecpar->sample_rate);
if (w->is_live) {
// For live streams, Codec and Mime Type always go in the Representation tag.
- avio_printf(s->pb, " codecs=\"%s\"", get_codec_name(stream->codec->codec_id));
+ avio_printf(s->pb, " codecs=\"%s\"", get_codec_name(stream->codecpar->codec_id));
avio_printf(s->pb, " mimeType=\"%s/webm\"",
- stream->codec->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio");
+ stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio");
// For live streams, subsegments always start with key frames. So this
// is always 1.
avio_printf(s->pb, " startsWithSAP=\"1\"");
@@ -224,9 +224,9 @@ static int write_representation(AVFormatContext *s, AVStream *stream, char *id,
static int check_matching_width(AVFormatContext *s, AdaptationSet *as) {
int first_width, i;
if (as->nb_streams < 2) return 1;
- first_width = s->streams[as->streams[0]]->codec->width;
+ first_width = s->streams[as->streams[0]]->codecpar->width;
for (i = 1; i < as->nb_streams; i++)
- if (first_width != s->streams[as->streams[i]]->codec->width)
+ if (first_width != s->streams[as->streams[i]]->codecpar->width)
return 0;
return 1;
}
@@ -237,9 +237,9 @@ static int check_matching_width(AVFormatContext *s, AdaptationSet *as) {
static int check_matching_height(AVFormatContext *s, AdaptationSet *as) {
int first_height, i;
if (as->nb_streams < 2) return 1;
- first_height = s->streams[as->streams[0]]->codec->height;
+ first_height = s->streams[as->streams[0]]->codecpar->height;
for (i = 1; i < as->nb_streams; i++)
- if (first_height != s->streams[as->streams[i]]->codec->height)
+ if (first_height != s->streams[as->streams[i]]->codecpar->height)
return 0;
return 1;
}
@@ -250,9 +250,9 @@ static int check_matching_height(AVFormatContext *s, AdaptationSet *as) {
static int check_matching_sample_rate(AVFormatContext *s, AdaptationSet *as) {
int first_sample_rate, i;
if (as->nb_streams < 2) return 1;
- first_sample_rate = s->streams[as->streams[0]]->codec->sample_rate;
+ first_sample_rate = s->streams[as->streams[0]]->codecpar->sample_rate;
for (i = 1; i < as->nb_streams; i++)
- if (first_sample_rate != s->streams[as->streams[i]]->codec->sample_rate)
+ if (first_sample_rate != s->streams[as->streams[i]]->codecpar->sample_rate)
return 0;
return 1;
}
@@ -319,7 +319,7 @@ static int write_adaptation_set(AVFormatContext *s, int as_index)
{
WebMDashMuxContext *w = s->priv_data;
AdaptationSet *as = &w->as[as_index];
- AVCodecContext *codec = s->streams[as->streams[0]]->codec;
+ AVCodecParameters *par = s->streams[as->streams[0]]->codecpar;
AVDictionaryEntry *lang;
int i;
static const char boolean[2][6] = { "false", "true" };
@@ -330,7 +330,7 @@ static int write_adaptation_set(AVFormatContext *s, int as_index)
// on their respective Representation tag. For live streams, they always go
// in the Representation tag.
int width_in_as = 1, height_in_as = 1, sample_rate_in_as = 1;
- if (codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (par->codec_type == AVMEDIA_TYPE_VIDEO) {
width_in_as = !w->is_live && check_matching_width(s, as);
height_in_as = !w->is_live && check_matching_height(s, as);
} else {
@@ -339,18 +339,18 @@ static int write_adaptation_set(AVFormatContext *s, int as_index)
avio_printf(s->pb, "<AdaptationSet id=\"%s\"", as->id);
avio_printf(s->pb, " mimeType=\"%s/webm\"",
- codec->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio");
- avio_printf(s->pb, " codecs=\"%s\"", get_codec_name(codec->codec_id));
+ par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio");
+ avio_printf(s->pb, " codecs=\"%s\"", get_codec_name(par->codec_id));
lang = av_dict_get(s->streams[as->streams[0]]->metadata, "language", NULL, 0);
if (lang) avio_printf(s->pb, " lang=\"%s\"", lang->value);
- if (codec->codec_type == AVMEDIA_TYPE_VIDEO && width_in_as)
- avio_printf(s->pb, " width=\"%d\"", codec->width);
- if (codec->codec_type == AVMEDIA_TYPE_VIDEO && height_in_as)
- avio_printf(s->pb, " height=\"%d\"", codec->height);
- if (codec->codec_type == AVMEDIA_TYPE_AUDIO && sample_rate_in_as)
- avio_printf(s->pb, " audioSamplingRate=\"%d\"", codec->sample_rate);
+ if (par->codec_type == AVMEDIA_TYPE_VIDEO && width_in_as)
+ avio_printf(s->pb, " width=\"%d\"", par->width);
+ if (par->codec_type == AVMEDIA_TYPE_VIDEO && height_in_as)
+ avio_printf(s->pb, " height=\"%d\"", par->height);
+ if (par->codec_type == AVMEDIA_TYPE_AUDIO && sample_rate_in_as)
+ avio_printf(s->pb, " audioSamplingRate=\"%d\"", par->sample_rate);
avio_printf(s->pb, " bitstreamSwitching=\"%s\"",
boolean[bitstream_switching(s, as)]);
@@ -374,7 +374,7 @@ static int write_adaptation_set(AVFormatContext *s, int as_index)
&media_pattern);
if (ret) return ret;
avio_printf(s->pb, "<ContentComponent id=\"1\" type=\"%s\"/>\n",
- codec->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio");
+ par->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio");
avio_printf(s->pb, "<SegmentTemplate");
avio_printf(s->pb, " timescale=\"1000\"");
avio_printf(s->pb, " duration=\"%d\"", w->chunk_duration);
diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c
index 2a21730f1b..2e0147cefd 100644
--- a/libavformat/webpenc.c
+++ b/libavformat/webpenc.c
@@ -42,7 +42,7 @@ static int webp_write_header(AVFormatContext *s)
return AVERROR(EINVAL);
}
st = s->streams[0];
- if (st->codec->codec_id != AV_CODEC_ID_WEBP) {
+ if (st->codecpar->codec_id != AV_CODEC_ID_WEBP) {
av_log(s, AV_LOG_ERROR, "Only WebP is supported\n");
return AVERROR(EINVAL);
}
@@ -115,8 +115,8 @@ static int flush(AVFormatContext *s, int trailer, int64_t pts)
avio_wl32(s->pb, 10);
avio_w8(s->pb, flags);
avio_wl24(s->pb, 0);
- avio_wl24(s->pb, st->codec->width - 1);
- avio_wl24(s->pb, st->codec->height - 1);
+ avio_wl24(s->pb, st->codecpar->width - 1);
+ avio_wl24(s->pb, st->codecpar->height - 1);
}
if (!trailer) {
avio_write(s->pb, "ANIM", 4);
@@ -131,8 +131,8 @@ static int flush(AVFormatContext *s, int trailer, int64_t pts)
avio_wl32(s->pb, 16 + w->last_pkt.size - skip);
avio_wl24(s->pb, 0);
avio_wl24(s->pb, 0);
- avio_wl24(s->pb, st->codec->width - 1);
- avio_wl24(s->pb, st->codec->height - 1);
+ avio_wl24(s->pb, st->codecpar->width - 1);
+ avio_wl24(s->pb, st->codecpar->height - 1);
if (w->last_pkt.pts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE) {
avio_wl24(s->pb, pts - w->last_pkt.pts);
} else
diff --git a/libavformat/webvttdec.c b/libavformat/webvttdec.c
index 47a3255fd0..0aeb8a63f4 100644
--- a/libavformat/webvttdec.c
+++ b/libavformat/webvttdec.c
@@ -67,8 +67,8 @@ static int webvtt_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 1000);
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- st->codec->codec_id = AV_CODEC_ID_WEBVTT;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_WEBVTT;
st->disposition |= webvtt->kind;
av_bprint_init(&header, 0, AV_BPRINT_SIZE_UNLIMITED);
diff --git a/libavformat/webvttenc.c b/libavformat/webvttenc.c
index c386538718..4827de05d5 100644
--- a/libavformat/webvttenc.c
+++ b/libavformat/webvttenc.c
@@ -46,10 +46,10 @@ static void webvtt_write_time(AVIOContext *pb, int64_t millisec)
static int webvtt_write_header(AVFormatContext *ctx)
{
AVStream *s = ctx->streams[0];
- AVCodecContext *avctx = ctx->streams[0]->codec;
+ AVCodecParameters *par = ctx->streams[0]->codecpar;
AVIOContext *pb = ctx->pb;
- if (ctx->nb_streams != 1 || avctx->codec_id != AV_CODEC_ID_WEBVTT) {
+ if (ctx->nb_streams != 1 || par->codec_id != AV_CODEC_ID_WEBVTT) {
av_log(ctx, AV_LOG_ERROR, "Exactly one WebVTT stream is needed.\n");
return AVERROR(EINVAL);
}
diff --git a/libavformat/westwood_aud.c b/libavformat/westwood_aud.c
index 6d8dbdbd35..fe8bdb01c2 100644
--- a/libavformat/westwood_aud.c
+++ b/libavformat/westwood_aud.c
@@ -105,23 +105,23 @@ static int wsaud_read_header(AVFormatContext *s)
avpriv_request_sample(s, "Stereo WS-SND1");
return AVERROR_PATCHWELCOME;
}
- st->codec->codec_id = AV_CODEC_ID_WESTWOOD_SND1;
+ st->codecpar->codec_id = AV_CODEC_ID_WESTWOOD_SND1;
break;
case 99:
- st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_WS;
- st->codec->bits_per_coded_sample = 4;
- st->codec->bit_rate = channels * sample_rate * 4;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_WS;
+ st->codecpar->bits_per_coded_sample = 4;
+ st->codecpar->bit_rate = channels * sample_rate * 4;
break;
default:
avpriv_request_sample(s, "Unknown codec: %d", codec);
return AVERROR_PATCHWELCOME;
}
avpriv_set_pts_info(st, 64, 1, sample_rate);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->channels = channels;
- st->codec->channel_layout = channels == 1 ? AV_CH_LAYOUT_MONO :
- AV_CH_LAYOUT_STEREO;
- st->codec->sample_rate = sample_rate;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->channels = channels;
+ st->codecpar->channel_layout = channels == 1 ? AV_CH_LAYOUT_MONO :
+ AV_CH_LAYOUT_STEREO;
+ st->codecpar->sample_rate = sample_rate;
return 0;
}
@@ -145,7 +145,7 @@ static int wsaud_read_packet(AVFormatContext *s,
chunk_size = AV_RL16(&preamble[0]);
- if (st->codec->codec_id == AV_CODEC_ID_WESTWOOD_SND1) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_WESTWOOD_SND1) {
/* For Westwood SND1 audio we need to add the output size and input
size to the start of the packet to match what is in VQA.
Specifically, this is needed to signal when a packet should be
@@ -165,7 +165,7 @@ static int wsaud_read_packet(AVFormatContext *s,
return AVERROR(EIO);
/* 2 samples/byte, 1 or 2 samples per frame depending on stereo */
- pkt->duration = (chunk_size * 2) / st->codec->channels;
+ pkt->duration = (chunk_size * 2) / st->codecpar->channels;
}
pkt->stream_index = st->index;
diff --git a/libavformat/westwood_vqa.c b/libavformat/westwood_vqa.c
index 546164c692..44388d6413 100644
--- a/libavformat/westwood_vqa.c
+++ b/libavformat/westwood_vqa.c
@@ -93,19 +93,19 @@ static int wsvqa_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
st->start_time = 0;
wsvqa->video_stream_index = st->index;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_WS_VQA;
- st->codec->codec_tag = 0; /* no fourcc */
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_WS_VQA;
+ st->codecpar->codec_tag = 0; /* no fourcc */
/* skip to the start of the VQA header */
avio_seek(pb, 20, SEEK_SET);
/* the VQA header needs to go to the decoder */
- if (ff_get_extradata(st->codec, pb, VQA_HEADER_SIZE) < 0)
+ if (ff_get_extradata(st->codecpar, pb, VQA_HEADER_SIZE) < 0)
return AVERROR(ENOMEM);
- header = st->codec->extradata;
- st->codec->width = AV_RL16(&header[6]);
- st->codec->height = AV_RL16(&header[8]);
+ header = st->codecpar->extradata;
+ st->codecpar->width = AV_RL16(&header[6]);
+ st->codecpar->height = AV_RL16(&header[8]);
fps = header[12];
st->nb_frames =
st->duration = AV_RL16(&header[4]);
@@ -196,28 +196,28 @@ static int wsvqa_read_packet(AVFormatContext *s,
wsvqa->channels = 1;
if (!wsvqa->bps)
wsvqa->bps = 8;
- st->codec->sample_rate = wsvqa->sample_rate;
- st->codec->bits_per_coded_sample = wsvqa->bps;
- st->codec->channels = wsvqa->channels;
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->sample_rate = wsvqa->sample_rate;
+ st->codecpar->bits_per_coded_sample = wsvqa->bps;
+ st->codecpar->channels = wsvqa->channels;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
switch (chunk_type) {
case SND0_TAG:
if (wsvqa->bps == 16)
- st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
else
- st->codec->codec_id = AV_CODEC_ID_PCM_U8;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
break;
case SND1_TAG:
- st->codec->codec_id = AV_CODEC_ID_WESTWOOD_SND1;
+ st->codecpar->codec_id = AV_CODEC_ID_WESTWOOD_SND1;
break;
case SND2_TAG:
- st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_WS;
- if (ff_alloc_extradata(st->codec, 2))
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_WS;
+ if (ff_alloc_extradata(st->codecpar, 2))
return AVERROR(ENOMEM);
- AV_WL16(st->codec->extradata, wsvqa->version);
+ AV_WL16(st->codecpar->extradata, wsvqa->version);
break;
}
}
diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index 1c3aa26f4a..39547f092c 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -447,8 +447,8 @@ static void get_attachment(AVFormatContext *s, AVIOContext *pb, int length)
if (!st)
goto done;
av_dict_set(&st->metadata, "title", description, 0);
- 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;
st->id = -1;
ret = av_get_packet(pb, &st->attached_pic, filesize);
if (ret < 0)
@@ -565,7 +565,7 @@ static int parse_videoinfoheader2(AVFormatContext *s, AVStream *st)
AVIOContext *pb = wtv->pb;
avio_skip(pb, 72); // picture aspect ratio is unreliable
- st->codec->codec_tag = ff_get_bmp_header(pb, st, NULL);
+ st->codecpar->codec_tag = ff_get_bmp_header(pb, st, NULL);
return 72 + 40;
}
@@ -576,23 +576,23 @@ static int parse_videoinfoheader2(AVFormatContext *s, AVStream *st)
static void parse_mpeg1waveformatex(AVStream *st)
{
/* fwHeadLayer */
- switch (AV_RL16(st->codec->extradata)) {
- case 0x0001 : st->codec->codec_id = AV_CODEC_ID_MP1; break;
- case 0x0002 : st->codec->codec_id = AV_CODEC_ID_MP2; break;
- case 0x0004 : st->codec->codec_id = AV_CODEC_ID_MP3; break;
+ switch (AV_RL16(st->codecpar->extradata)) {
+ case 0x0001 : st->codecpar->codec_id = AV_CODEC_ID_MP1; break;
+ case 0x0002 : st->codecpar->codec_id = AV_CODEC_ID_MP2; break;
+ case 0x0004 : st->codecpar->codec_id = AV_CODEC_ID_MP3; break;
}
- st->codec->bit_rate = AV_RL32(st->codec->extradata + 2); /* dwHeadBitrate */
+ st->codecpar->bit_rate = AV_RL32(st->codecpar->extradata + 2); /* dwHeadBitrate */
/* dwHeadMode */
- switch (AV_RL16(st->codec->extradata + 6)) {
+ switch (AV_RL16(st->codecpar->extradata + 6)) {
case 1 :
case 2 :
- case 4 : st->codec->channels = 2;
- st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
+ case 4 : st->codecpar->channels = 2;
+ st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
break;
- case 8 : st->codec->channels = 1;
- st->codec->channel_layout = AV_CH_LAYOUT_MONO;
+ case 8 : st->codecpar->channels = 1;
+ st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
break;
}
}
@@ -605,9 +605,9 @@ static void parse_mpeg1waveformatex(AVStream *st)
static AVStream * new_stream(AVFormatContext *s, AVStream *st, int sid, int codec_type)
{
if (st) {
- if (st->codec->extradata) {
- av_freep(&st->codec->extradata);
- st->codec->extradata_size = 0;
+ if (st->codecpar->extradata) {
+ av_freep(&st->codecpar->extradata);
+ st->codecpar->extradata_size = 0;
}
} else {
WtvStream *wst = av_mallocz(sizeof(WtvStream));
@@ -621,7 +621,7 @@ static AVStream * new_stream(AVFormatContext *s, AVStream *st, int sid, int code
st->id = sid;
st->priv_data = wst;
}
- st->codec->codec_type = codec_type;
+ st->codecpar->codec_type = codec_type;
st->need_parsing = AVSTREAM_PARSE_FULL;
avpriv_set_pts_info(st, 64, 1, 10000000);
return st;
@@ -666,7 +666,7 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
if (!st)
return NULL;
if (!ff_guidcmp(formattype, ff_format_waveformatex)) {
- int ret = ff_get_wav_header(s, pb, st->codec, size, 0);
+ int ret = ff_get_wav_header(s, pb, st->codecpar, size, 0);
if (ret < 0)
return NULL;
} else {
@@ -676,15 +676,15 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
}
if (!memcmp(subtype + 4, (const uint8_t[]){FF_MEDIASUBTYPE_BASE_GUID}, 12)) {
- st->codec->codec_id = ff_wav_codec_get_id(AV_RL32(subtype), st->codec->bits_per_coded_sample);
+ st->codecpar->codec_id = ff_wav_codec_get_id(AV_RL32(subtype), st->codecpar->bits_per_coded_sample);
} else if (!ff_guidcmp(subtype, mediasubtype_mpeg1payload)) {
- if (st->codec->extradata && st->codec->extradata_size >= 22)
+ if (st->codecpar->extradata && st->codecpar->extradata_size >= 22)
parse_mpeg1waveformatex(st);
else
av_log(s, AV_LOG_WARNING, "MPEG1WAVEFORMATEX underflow\n");
} else {
- st->codec->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subtype);
- if (st->codec->codec_id == AV_CODEC_ID_NONE)
+ st->codecpar->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subtype);
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE)
av_log(s, AV_LOG_WARNING, "unknown subtype:"FF_PRI_GUID"\n", FF_ARG_GUID(subtype));
}
return st;
@@ -706,11 +706,11 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
}
if (!memcmp(subtype + 4, (const uint8_t[]){FF_MEDIASUBTYPE_BASE_GUID}, 12)) {
- st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(subtype));
+ st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(subtype));
} else {
- st->codec->codec_id = ff_codec_guid_get_id(ff_video_guids, subtype);
+ st->codecpar->codec_id = ff_codec_guid_get_id(ff_video_guids, subtype);
}
- if (st->codec->codec_id == AV_CODEC_ID_NONE)
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE)
av_log(s, AV_LOG_WARNING, "unknown subtype:"FF_PRI_GUID"\n", FF_ARG_GUID(subtype));
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mpeg2_pes) &&
@@ -721,7 +721,7 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
if (ff_guidcmp(formattype, ff_format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype));
avio_skip(pb, size);
- st->codec->codec_id = AV_CODEC_ID_DVB_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_DVB_SUBTITLE;
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mstvcaption) &&
(!ff_guidcmp(subtype, mediasubtype_teletext) || !ff_guidcmp(subtype, mediasubtype_dtvccdata))) {
@@ -731,7 +731,7 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
if (ff_guidcmp(formattype, ff_format_none))
av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype));
avio_skip(pb, size);
- st->codec->codec_id = !ff_guidcmp(subtype, mediasubtype_teletext) ? AV_CODEC_ID_DVB_TELETEXT : AV_CODEC_ID_EIA_608;
+ st->codecpar->codec_id = !ff_guidcmp(subtype, mediasubtype_teletext) ? AV_CODEC_ID_DVB_TELETEXT : AV_CODEC_ID_EIA_608;
return st;
} else if (!ff_guidcmp(mediatype, mediatype_mpeg2_sections) &&
!ff_guidcmp(subtype, mediasubtype_mpeg2_sections)) {
diff --git a/libavformat/wtvenc.c b/libavformat/wtvenc.c
index 908448f1df..a7ca1c39aa 100644
--- a/libavformat/wtvenc.c
+++ b/libavformat/wtvenc.c
@@ -215,22 +215,22 @@ static void finish_chunk(AVFormatContext *s)
static void put_videoinfoheader2(AVIOContext *pb, AVStream *st)
{
- AVRational dar = av_mul_q(st->sample_aspect_ratio, (AVRational){st->codec->width, st->codec->height});
+ AVRational dar = av_mul_q(st->sample_aspect_ratio, (AVRational){st->codecpar->width, st->codecpar->height});
unsigned int num, den;
av_reduce(&num, &den, dar.num, dar.den, 0xFFFFFFFF);
/* VIDEOINFOHEADER2 */
avio_wl32(pb, 0);
avio_wl32(pb, 0);
- avio_wl32(pb, st->codec->width);
- avio_wl32(pb, st->codec->height);
+ avio_wl32(pb, st->codecpar->width);
+ avio_wl32(pb, st->codecpar->height);
avio_wl32(pb, 0);
avio_wl32(pb, 0);
avio_wl32(pb, 0);
avio_wl32(pb, 0);
- avio_wl32(pb, st->codec->bit_rate);
+ avio_wl32(pb, st->codecpar->bit_rate);
avio_wl32(pb, 0);
avio_wl64(pb, st->avg_frame_rate.num && st->avg_frame_rate.den ? INT64_C(10000000) / av_q2d(st->avg_frame_rate) : 0);
avio_wl32(pb, 0);
@@ -241,17 +241,17 @@ static void put_videoinfoheader2(AVIOContext *pb, AVStream *st)
avio_wl32(pb, 0);
avio_wl32(pb, 0);
- ff_put_bmp_header(pb, st->codec, ff_codec_bmp_tags, 0, 1);
+ ff_put_bmp_header(pb, st->codecpar, ff_codec_bmp_tags, 0, 1);
- if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
- int padding = (st->codec->extradata_size & 3) ? 4 - (st->codec->extradata_size & 3) : 0;
+ if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
+ int padding = (st->codecpar->extradata_size & 3) ? 4 - (st->codecpar->extradata_size & 3) : 0;
/* MPEG2VIDEOINFO */
avio_wl32(pb, 0);
- avio_wl32(pb, st->codec->extradata_size + padding);
+ avio_wl32(pb, st->codecpar->extradata_size + padding);
avio_wl32(pb, -1);
avio_wl32(pb, -1);
avio_wl32(pb, 0);
- avio_write(pb, st->codec->extradata, st->codec->extradata_size);
+ avio_write(pb, st->codecpar->extradata, st->codecpar->extradata_size);
ffio_fill(pb, 0, padding);
}
}
@@ -264,18 +264,18 @@ static int write_stream_codec_info(AVFormatContext *s, AVStream *st)
int64_t hdr_pos_start;
int hdr_size = 0;
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- g = ff_get_codec_guid(st->codec->codec_id, ff_video_guids);
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+ g = ff_get_codec_guid(st->codecpar->codec_id, ff_video_guids);
media_type = &ff_mediatype_video;
- format_type = st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO ? &ff_format_mpeg2_video : &ff_format_videoinfo2;
+ format_type = st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO ? &ff_format_mpeg2_video : &ff_format_videoinfo2;
tags = ff_codec_bmp_tags;
- } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- g = ff_get_codec_guid(st->codec->codec_id, ff_codec_wav_guids);
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ g = ff_get_codec_guid(st->codecpar->codec_id, ff_codec_wav_guids);
media_type = &ff_mediatype_audio;
format_type = &ff_format_waveformatex;
tags = ff_codec_wav_tags;
} else {
- av_log(s, AV_LOG_ERROR, "unknown codec_type (0x%x)\n", st->codec->codec_type);
+ av_log(s, AV_LOG_ERROR, "unknown codec_type (0x%x)\n", st->codecpar->codec_type);
return -1;
}
@@ -286,10 +286,10 @@ static int write_stream_codec_info(AVFormatContext *s, AVStream *st)
avio_wl32(pb, 0); // size
hdr_pos_start = avio_tell(pb);
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
put_videoinfoheader2(pb, st);
} else {
- if (ff_put_wav_header(pb, st->codec, 0) < 0)
+ if (ff_put_wav_header(s, pb, st->codecpar, 0) < 0)
format_type = &ff_format_none;
}
hdr_size = avio_tell(pb) - hdr_pos_start;
@@ -301,9 +301,9 @@ static int write_stream_codec_info(AVFormatContext *s, AVStream *st)
if (g) {
ff_put_guid(pb, g); // actual_subtype
} else {
- int tag = ff_codec_get_tag(tags, st->codec->codec_id);
+ int tag = ff_codec_get_tag(tags, st->codecpar->codec_id);
if (!tag) {
- av_log(s, AV_LOG_ERROR, "unsupported codec_id (0x%x)\n", st->codec->codec_id);
+ av_log(s, AV_LOG_ERROR, "unsupported codec_id (0x%x)\n", st->codecpar->codec_id);
return -1;
}
avio_wl32(pb, tag);
@@ -326,7 +326,7 @@ static int write_stream_codec(AVFormatContext *s, AVStream * st)
ret = write_stream_codec_info(s, st);
if (ret < 0) {
- av_log(s, AV_LOG_ERROR, "write stream codec info failed codec_type(0x%x)\n", st->codec->codec_type);
+ av_log(s, AV_LOG_ERROR, "write stream codec info failed codec_type(0x%x)\n", st->codecpar->codec_type);
return -1;
}
@@ -364,7 +364,7 @@ static int write_stream_data(AVFormatContext *s, AVStream *st)
ret = write_stream_codec_info(s, st);
if (ret < 0) {
- av_log(s, AV_LOG_ERROR, "write stream codec info failed codec_type(0x%x)\n", st->codec->codec_type);
+ av_log(s, AV_LOG_ERROR, "write stream codec info failed codec_type(0x%x)\n", st->codecpar->codec_type);
return -1;
}
finish_chunk(s);
@@ -411,11 +411,11 @@ static int write_header(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
- if (st->codec->codec_id == AV_CODEC_ID_MJPEG)
+ if (st->codecpar->codec_id == AV_CODEC_ID_MJPEG)
continue;
ret = write_stream_codec(s, st);
if (ret < 0) {
- av_log(s, AV_LOG_ERROR, "write stream codec failed codec_type(0x%x)\n", st->codec->codec_type);
+ av_log(s, AV_LOG_ERROR, "write stream codec failed codec_type(0x%x)\n", st->codecpar->codec_type);
return -1;
}
if (!i)
@@ -424,11 +424,11 @@ static int write_header(AVFormatContext *s)
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
- if (st->codec->codec_id == AV_CODEC_ID_MJPEG)
+ if (st->codecpar->codec_id == AV_CODEC_ID_MJPEG)
continue;
ret = write_stream_data(s, st);
if (ret < 0) {
- av_log(s, AV_LOG_ERROR, "write stream data failed codec_type(0x%x)\n", st->codec->codec_type);
+ av_log(s, AV_LOG_ERROR, "write stream data failed codec_type(0x%x)\n", st->codecpar->codec_type);
return -1;
}
}
@@ -443,7 +443,7 @@ static void write_timestamp(AVFormatContext *s, AVPacket *pkt)
{
AVIOContext *pb = s->pb;
WtvContext *wctx = s->priv_data;
- AVCodecContext *enc = s->streams[pkt->stream_index]->codec;
+ AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
write_chunk_header(s, &ff_timestamp_guid, 56, 0x40000000 | (INDEX_BASE + pkt->stream_index));
write_pad(pb, 8);
@@ -451,7 +451,7 @@ static void write_timestamp(AVFormatContext *s, AVPacket *pkt)
avio_wl64(pb, pkt->pts == AV_NOPTS_VALUE ? -1 : pkt->pts);
avio_wl64(pb, pkt->pts == AV_NOPTS_VALUE ? -1 : pkt->pts);
avio_wl64(pb, 0);
- avio_wl64(pb, enc->codec_type == AVMEDIA_TYPE_VIDEO && (pkt->flags & AV_PKT_FLAG_KEY) ? 1 : 0);
+ avio_wl64(pb, par->codec_type == AVMEDIA_TYPE_VIDEO && (pkt->flags & AV_PKT_FLAG_KEY) ? 1 : 0);
avio_wl64(pb, 0);
wctx->last_timestamp_pos = wctx->last_chunk_pos;
@@ -463,10 +463,10 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
WtvContext *wctx = s->priv_data;
AVStream *st = s->streams[pkt->stream_index];
- if (st->codec->codec_id == AV_CODEC_ID_MJPEG && !wctx->thumbnail.size) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_MJPEG && !wctx->thumbnail.size) {
av_copy_packet(&wctx->thumbnail, pkt);
return 0;
- } else if (st->codec->codec_id == AV_CODEC_ID_H264) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
int ret = ff_check_h264_startcode(s, st, pkt);
if (ret < 0)
return ret;
diff --git a/libavformat/wvdec.c b/libavformat/wvdec.c
index 042f96b855..1ec52f689d 100644
--- a/libavformat/wvdec.c
+++ b/libavformat/wvdec.c
@@ -230,12 +230,12 @@ static int wv_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_id = AV_CODEC_ID_WAVPACK;
- st->codec->channels = wc->chan;
- st->codec->channel_layout = wc->chmask;
- st->codec->sample_rate = wc->rate;
- st->codec->bits_per_coded_sample = wc->bpp;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_WAVPACK;
+ st->codecpar->channels = wc->chan;
+ st->codecpar->channel_layout = wc->chmask;
+ st->codecpar->sample_rate = wc->rate;
+ st->codecpar->bits_per_coded_sample = wc->bpp;
avpriv_set_pts_info(st, 64, 1, wc->rate);
st->start_time = 0;
if (wc->header.total_samples != 0xFFFFFFFFu)
diff --git a/libavformat/wvedec.c b/libavformat/wvedec.c
index 8e74abe5ea..89c00016cd 100644
--- a/libavformat/wvedec.c
+++ b/libavformat/wvedec.c
@@ -40,13 +40,13 @@ static int wve_read_header(AVFormatContext *s)
avio_skip(s->pb, 18);
st->duration = avio_rb32(s->pb);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_PCM_ALAW;
- st->codec->sample_rate = 8000;
- st->codec->channels = 1;
- st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id);
- st->codec->block_align = st->codec->bits_per_coded_sample * st->codec->channels / 8;
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_ALAW;
+ st->codecpar->sample_rate = 8000;
+ st->codecpar->channels = 1;
+ st->codecpar->bits_per_coded_sample = av_get_bits_per_sample(st->codecpar->codec_id);
+ st->codecpar->block_align = st->codecpar->bits_per_coded_sample * st->codecpar->channels / 8;
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
avio_skip(s->pb, 10);
return 0;
diff --git a/libavformat/wvenc.c b/libavformat/wvenc.c
index b0d74caaec..48e371aa13 100644
--- a/libavformat/wvenc.c
+++ b/libavformat/wvenc.c
@@ -33,7 +33,7 @@ typedef struct WvMuxContext {
static av_cold int wv_write_header(AVFormatContext *ctx)
{
if (ctx->nb_streams > 1 ||
- ctx->streams[0]->codec->codec_id != AV_CODEC_ID_WAVPACK) {
+ ctx->streams[0]->codecpar->codec_id != AV_CODEC_ID_WAVPACK) {
av_log(ctx, AV_LOG_ERROR, "This muxer only supports a single WavPack stream.\n");
return AVERROR(EINVAL);
}
diff --git a/libavformat/xa.c b/libavformat/xa.c
index 43661dea43..810e0c0197 100644
--- a/libavformat/xa.c
+++ b/libavformat/xa.c
@@ -73,24 +73,24 @@ static int xa_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_ADPCM_EA_MAXIS_XA;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_EA_MAXIS_XA;
avio_skip(pb, 4); /* Skip the XA ID */
xa->out_size = avio_rl32(pb);
avio_skip(pb, 2); /* Skip the tag */
- st->codec->channels = avio_rl16(pb);
- st->codec->sample_rate = avio_rl32(pb);
+ st->codecpar->channels = avio_rl16(pb);
+ st->codecpar->sample_rate = avio_rl32(pb);
avio_skip(pb, 4); /* Skip average byte rate */
avio_skip(pb, 2); /* Skip block align */
avio_skip(pb, 2); /* Skip bits-per-sample */
- if (!st->codec->channels || !st->codec->sample_rate)
+ if (!st->codecpar->channels || !st->codecpar->sample_rate)
return AVERROR_INVALIDDATA;
- st->codec->bit_rate = av_clip(15LL * st->codec->channels * 8 *
- st->codec->sample_rate / 28, 0, INT_MAX);
+ st->codecpar->bit_rate = av_clip(15LL * st->codecpar->channels * 8 *
+ st->codecpar->sample_rate / 28, 0, INT_MAX);
- 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;
@@ -108,7 +108,7 @@ static int xa_read_packet(AVFormatContext *s,
if (xa->sent_bytes >= xa->out_size)
return AVERROR_EOF;
/* 1 byte header and 14 bytes worth of samples * number channels per block */
- packet_size = 15*st->codec->channels;
+ packet_size = 15*st->codecpar->channels;
ret = av_get_packet(pb, pkt, packet_size);
if(ret < 0)
diff --git a/libavformat/xmv.c b/libavformat/xmv.c
index 45e5ebcaf2..b85d0ccc43 100644
--- a/libavformat/xmv.c
+++ b/libavformat/xmv.c
@@ -53,6 +53,7 @@
/** A video packet with an XMV file. */
typedef struct XMVVideoPacket {
+ int created;
int stream_index; ///< The decoder stream index for this video packet.
uint32_t data_size; ///< The size of the remaining video data.
@@ -70,6 +71,7 @@ typedef struct XMVVideoPacket {
/** An audio packet with an XMV file. */
typedef struct XMVAudioPacket {
+ int created;
int stream_index; ///< The decoder stream index for this audio packet.
/* Stream format properties. */
@@ -105,6 +107,10 @@ typedef struct XMVDemuxContext {
uint16_t current_stream; ///< The index of the stream currently handling.
uint16_t stream_count; ///< The number of streams in this file.
+ uint32_t video_duration;
+ uint32_t video_width;
+ uint32_t video_height;
+
XMVVideoPacket video; ///< The video packet contained in each packet.
XMVAudioPacket *audio; ///< The audio packets contained in each packet.
} XMVDemuxContext;
@@ -139,13 +145,14 @@ static int xmv_read_header(AVFormatContext *s)
{
XMVDemuxContext *xmv = s->priv_data;
AVIOContext *pb = s->pb;
- AVStream *vst = NULL;
uint32_t file_version;
uint32_t this_packet_size;
uint16_t audio_track;
int ret;
+ s->ctx_flags |= AVFMTCTX_NOHEADER;
+
avio_skip(pb, 4); /* Next packet size */
this_packet_size = avio_rl32(pb);
@@ -157,24 +164,11 @@ static int xmv_read_header(AVFormatContext *s)
if ((file_version != 4) && (file_version != 2))
avpriv_request_sample(s, "Uncommon version %"PRIu32"", file_version);
+ /* Video tracks */
- /* Video track */
-
- vst = avformat_new_stream(s, NULL);
- if (!vst)
- return AVERROR(ENOMEM);
-
- avpriv_set_pts_info(vst, 32, 1, 1000);
-
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_id = AV_CODEC_ID_WMV2;
- vst->codec->codec_tag = MKBETAG('W', 'M', 'V', '2');
- vst->codec->width = avio_rl32(pb);
- vst->codec->height = avio_rl32(pb);
-
- vst->duration = avio_rl32(pb);
-
- xmv->video.stream_index = vst->index;
+ xmv->video_width = avio_rl32(pb);
+ xmv->video_height = avio_rl32(pb);
+ xmv->video_duration = avio_rl32(pb);
/* Audio tracks */
@@ -182,7 +176,7 @@ static int xmv_read_header(AVFormatContext *s)
avio_skip(pb, 2); /* Unknown (padding?) */
- xmv->audio = av_malloc_array(xmv->audio_track_count, sizeof(XMVAudioPacket));
+ xmv->audio = av_mallocz_array(xmv->audio_track_count, sizeof(XMVAudioPacket));
if (!xmv->audio) {
ret = AVERROR(ENOMEM);
goto fail;
@@ -190,7 +184,6 @@ static int xmv_read_header(AVFormatContext *s)
for (audio_track = 0; audio_track < xmv->audio_track_count; audio_track++) {
XMVAudioPacket *packet = &xmv->audio[audio_track];
- AVStream *ast = NULL;
packet->compression = avio_rl16(pb);
packet->channels = avio_rl16(pb);
@@ -224,27 +217,6 @@ static int xmv_read_header(AVFormatContext *s)
ret = AVERROR_INVALIDDATA;
goto fail;
}
-
- ast = avformat_new_stream(s, NULL);
- if (!ast) {
- ret = AVERROR(ENOMEM);
- goto fail;
- }
-
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- ast->codec->codec_id = packet->codec_id;
- ast->codec->codec_tag = packet->compression;
- ast->codec->channels = packet->channels;
- ast->codec->sample_rate = packet->sample_rate;
- ast->codec->bits_per_coded_sample = packet->bits_per_sample;
- ast->codec->bit_rate = packet->bit_rate;
- ast->codec->block_align = 36 * packet->channels;
-
- avpriv_set_pts_info(ast, 32, packet->block_samples, packet->sample_rate);
-
- packet->stream_index = ast->index;
-
- ast->duration = vst->duration;
}
@@ -315,6 +287,26 @@ static int xmv_process_packet_header(AVFormatContext *s)
xmv->video.has_extradata = (data[3] & 0x80) != 0;
+ if (!xmv->video.created) {
+ AVStream *vst = avformat_new_stream(s, NULL);
+ if (!vst)
+ return AVERROR(ENOMEM);
+
+ avpriv_set_pts_info(vst, 32, 1, 1000);
+
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_id = AV_CODEC_ID_WMV2;
+ vst->codecpar->codec_tag = MKBETAG('W', 'M', 'V', '2');
+ vst->codecpar->width = xmv->video_width;
+ vst->codecpar->height = xmv->video_height;
+
+ vst->duration = xmv->video_duration;
+
+ xmv->video.stream_index = vst->index;
+
+ xmv->video.created = 1;
+ }
+
/* Adding the audio data sizes and the video data size keeps you 4 bytes
* short for every audio track. But as playing around with XMV files with
* ADPCM audio showed, taking the extra 4 bytes from the audio data gives
@@ -340,6 +332,29 @@ static int xmv_process_packet_header(AVFormatContext *s)
if (avio_read(pb, data, 4) != 4)
return AVERROR(EIO);
+ if (!packet->created) {
+ AVStream *ast = avformat_new_stream(s, NULL);
+ if (!ast)
+ return AVERROR(ENOMEM);
+
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codecpar->codec_id = packet->codec_id;
+ ast->codecpar->codec_tag = packet->compression;
+ ast->codecpar->channels = packet->channels;
+ ast->codecpar->sample_rate = packet->sample_rate;
+ ast->codecpar->bits_per_coded_sample = packet->bits_per_sample;
+ ast->codecpar->bit_rate = packet->bit_rate;
+ ast->codecpar->block_align = 36 * packet->channels;
+
+ avpriv_set_pts_info(ast, 32, packet->block_samples, packet->sample_rate);
+
+ packet->stream_index = ast->index;
+
+ ast->duration = xmv->video_duration;
+
+ packet->created = 1;
+ }
+
packet->data_size = AV_RL32(data) & 0x007FFFFF;
if ((packet->data_size == 0) && (audio_track != 0))
/* This happens when I create an XMV with several identical audio
@@ -381,14 +396,14 @@ static int xmv_process_packet_header(AVFormatContext *s)
av_assert0(xmv->video.stream_index < s->nb_streams);
- if (vst->codec->extradata_size < 4) {
- av_freep(&vst->codec->extradata);
+ if (vst->codecpar->extradata_size < 4) {
+ av_freep(&vst->codecpar->extradata);
- if ((ret = ff_alloc_extradata(vst->codec, 4)) < 0)
+ if ((ret = ff_alloc_extradata(vst->codecpar, 4)) < 0)
return ret;
}
- memcpy(vst->codec->extradata, xmv->video.extradata, 4);
+ memcpy(vst->codecpar->extradata, xmv->video.extradata, 4);
}
}
}
diff --git a/libavformat/xvag.c b/libavformat/xvag.c
index 92c80a48e8..5ef4fb0900 100644
--- a/libavformat/xvag.c
+++ b/libavformat/xvag.c
@@ -43,7 +43,7 @@ static int xvag_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
offset = avio_rl32(s->pb);
big_endian = offset > av_bswap32(offset);
@@ -51,30 +51,30 @@ static int xvag_read_header(AVFormatContext *s)
offset = av_bswap32(offset);
avio_skip(s->pb, 28);
codec = avio_rb32(s->pb);
- st->codec->channels = avio_rb32(s->pb);
+ st->codecpar->channels = avio_rb32(s->pb);
avio_skip(s->pb, 4);
st->duration = avio_rb32(s->pb);
avio_skip(s->pb, 8);
- st->codec->sample_rate = avio_rb32(s->pb);
+ st->codecpar->sample_rate = avio_rb32(s->pb);
} else {
avio_skip(s->pb, 28);
codec = avio_rl32(s->pb);
- st->codec->channels = avio_rl32(s->pb);
+ st->codecpar->channels = avio_rl32(s->pb);
avio_skip(s->pb, 4);
st->duration = avio_rl32(s->pb);
avio_skip(s->pb, 8);
- st->codec->sample_rate = avio_rl32(s->pb);
+ st->codecpar->sample_rate = avio_rl32(s->pb);
}
- if (st->codec->sample_rate <= 0)
+ if (st->codecpar->sample_rate <= 0)
return AVERROR_INVALIDDATA;
- if (st->codec->channels <= 0)
+ if (st->codecpar->channels <= 0)
return AVERROR_INVALIDDATA;
switch (codec) {
case 0x1c:
- st->codec->codec_id = AV_CODEC_ID_ADPCM_PSX;
- st->codec->block_align = 16 * st->codec->channels;
+ st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX;
+ st->codecpar->block_align = 16 * st->codecpar->channels;
break;
default:
avpriv_request_sample(s, "codec %X", codec);
@@ -84,22 +84,22 @@ static int xvag_read_header(AVFormatContext *s)
avio_skip(s->pb, offset - avio_tell(s->pb));
if (avio_rb16(s->pb) == 0xFFFB) {
- st->codec->codec_id = AV_CODEC_ID_MP3;
- st->codec->block_align = 0x1000;
+ st->codecpar->codec_id = AV_CODEC_ID_MP3;
+ st->codecpar->block_align = 0x1000;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
}
avio_skip(s->pb, -2);
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
static int xvag_read_packet(AVFormatContext *s, AVPacket *pkt)
{
- AVCodecContext *codec = s->streams[0]->codec;
+ AVCodecParameters *par = s->streams[0]->codecpar;
- return av_get_packet(s->pb, pkt, codec->block_align);
+ return av_get_packet(s->pb, pkt, par->block_align);
}
AVInputFormat ff_xvag_demuxer = {
diff --git a/libavformat/xwma.c b/libavformat/xwma.c
index d516b767f7..df84d25331 100644
--- a/libavformat/xwma.c
+++ b/libavformat/xwma.c
@@ -75,7 +75,7 @@ static int xwma_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- ret = ff_get_wav_header(s, pb, st->codec, size, 0);
+ ret = ff_get_wav_header(s, pb, st->codecpar, size, 0);
if (ret < 0)
return ret;
st->need_parsing = AVSTREAM_PARSE_NONE;
@@ -85,10 +85,10 @@ static int xwma_read_header(AVFormatContext *s)
* extradata for that. Thus, ask the user for feedback, but try to go on
* anyway.
*/
- if (st->codec->codec_id != AV_CODEC_ID_WMAV2 &&
- st->codec->codec_id != AV_CODEC_ID_WMAPRO) {
+ if (st->codecpar->codec_id != AV_CODEC_ID_WMAV2 &&
+ st->codecpar->codec_id != AV_CODEC_ID_WMAPRO) {
avpriv_request_sample(s, "Unexpected codec (tag 0x04%x; id %d)",
- st->codec->codec_tag, st->codec->codec_id);
+ st->codecpar->codec_tag, st->codecpar->codec_id);
} else {
/* In all xWMA files I have seen, there is no extradata. But the WMA
* codecs require extradata, so we provide our own fake extradata.
@@ -97,43 +97,43 @@ static int xwma_read_header(AVFormatContext *s)
* there was, then try to use it, after asking the user to provide a
* sample of this unusual file.
*/
- if (st->codec->extradata_size != 0) {
+ if (st->codecpar->extradata_size != 0) {
/* Surprise, surprise: We *did* get some extradata. No idea
* if it will work, but just go on and try it, after asking
* the user for a sample.
*/
avpriv_request_sample(s, "Unexpected extradata (%d bytes)",
- st->codec->extradata_size);
- } else if (st->codec->codec_id == AV_CODEC_ID_WMAPRO) {
- if (ff_alloc_extradata(st->codec, 18))
+ st->codecpar->extradata_size);
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_WMAPRO) {
+ if (ff_alloc_extradata(st->codecpar, 18))
return AVERROR(ENOMEM);
- memset(st->codec->extradata, 0, st->codec->extradata_size);
- st->codec->extradata[ 0] = st->codec->bits_per_coded_sample;
- st->codec->extradata[14] = 224;
+ memset(st->codecpar->extradata, 0, st->codecpar->extradata_size);
+ st->codecpar->extradata[ 0] = st->codecpar->bits_per_coded_sample;
+ st->codecpar->extradata[14] = 224;
} else {
- if (ff_alloc_extradata(st->codec, 6))
+ if (ff_alloc_extradata(st->codecpar, 6))
return AVERROR(ENOMEM);
- memset(st->codec->extradata, 0, st->codec->extradata_size);
+ memset(st->codecpar->extradata, 0, st->codecpar->extradata_size);
/* setup extradata with our experimentally obtained value */
- st->codec->extradata[4] = 31;
+ st->codecpar->extradata[4] = 31;
}
}
- if (!st->codec->channels) {
+ if (!st->codecpar->channels) {
av_log(s, AV_LOG_WARNING, "Invalid channel count: %d\n",
- st->codec->channels);
+ st->codecpar->channels);
return AVERROR_INVALIDDATA;
}
- if (!st->codec->bits_per_coded_sample) {
+ if (!st->codecpar->bits_per_coded_sample) {
av_log(s, AV_LOG_WARNING, "Invalid bits_per_coded_sample: %d\n",
- st->codec->bits_per_coded_sample);
+ st->codecpar->bits_per_coded_sample);
return AVERROR_INVALIDDATA;
}
/* set the sample rate */
- avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
/* parse the remaining RIFF chunks */
for (;;) {
@@ -153,7 +153,7 @@ static int xwma_read_header(AVFormatContext *s)
* number of bytes accumulated after the corresponding xWMA packet
* is decoded in order."
*
- * Each packet has size equal to st->codec->block_align, which in
+ * Each packet has size equal to st->codecpar->block_align, which in
* all cases I saw so far was always 2230. Thus, we can use the
* dpds data to compute a seeking index.
*/
@@ -207,7 +207,7 @@ static int xwma_read_header(AVFormatContext *s)
if (dpds_table && dpds_table_size) {
int64_t cur_pos;
const uint32_t bytes_per_sample
- = (st->codec->channels * st->codec->bits_per_coded_sample) >> 3;
+ = (st->codecpar->channels * st->codecpar->bits_per_coded_sample) >> 3;
/* Estimate the duration from the total number of output bytes. */
const uint64_t total_decoded_bytes = dpds_table[dpds_table_size - 1];
@@ -215,7 +215,7 @@ static int xwma_read_header(AVFormatContext *s)
if (!bytes_per_sample) {
av_log(s, AV_LOG_ERROR,
"Invalid bits_per_coded_sample %d for %d channels\n",
- st->codec->bits_per_coded_sample, st->codec->channels);
+ st->codecpar->bits_per_coded_sample, st->codecpar->channels);
ret = AVERROR_INVALIDDATA;
goto fail;
}
@@ -238,18 +238,18 @@ static int xwma_read_header(AVFormatContext *s)
* an offset / timestamp pair.
*/
av_add_index_entry(st,
- cur_pos + (i+1) * st->codec->block_align, /* pos */
- dpds_table[i] / bytes_per_sample, /* timestamp */
- st->codec->block_align, /* size */
- 0, /* duration */
+ cur_pos + (i+1) * st->codecpar->block_align, /* pos */
+ dpds_table[i] / bytes_per_sample, /* timestamp */
+ st->codecpar->block_align, /* size */
+ 0, /* duration */
AVINDEX_KEYFRAME);
}
- } else if (st->codec->bit_rate) {
+ } else if (st->codecpar->bit_rate) {
/* No dpds chunk was present (or only an empty one), so estimate
* the total duration using the average bits per sample and the
* total data length.
*/
- st->duration = (size<<3) * st->codec->sample_rate / st->codec->bit_rate;
+ st->duration = (size<<3) * st->codecpar->sample_rate / st->codecpar->bit_rate;
}
fail:
@@ -273,7 +273,7 @@ static int xwma_read_packet(AVFormatContext *s, AVPacket *pkt)
}
/* read a single block; the default block size is 2230. */
- size = (st->codec->block_align > 1) ? st->codec->block_align : 2230;
+ size = (st->codecpar->block_align > 1) ? st->codecpar->block_align : 2230;
size = FFMIN(size, left);
ret = av_get_packet(s->pb, pkt, size);
diff --git a/libavformat/yop.c b/libavformat/yop.c
index 9b77f6e30e..997ca4b745 100644
--- a/libavformat/yop.c
+++ b/libavformat/yop.c
@@ -58,7 +58,7 @@ static int yop_read_header(AVFormatContext *s)
YopDecContext *yop = s->priv_data;
AVIOContext *pb = s->pb;
- AVCodecContext *audio_dec, *video_dec;
+ AVCodecParameters *audio_par, *video_par;
AVStream *audio_stream, *video_stream;
int frame_rate, ret;
@@ -69,39 +69,45 @@ static int yop_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
// Extra data that will be passed to the decoder
- if (ff_alloc_extradata(video_stream->codec, 8))
+ if (ff_alloc_extradata(video_stream->codecpar, 8))
return AVERROR(ENOMEM);
+ video_stream->codecpar->extradata = av_mallocz(8 + AV_INPUT_BUFFER_PADDING_SIZE);
+
+ if (!video_stream->codecpar->extradata)
+ return AVERROR(ENOMEM);
+ video_stream->codecpar->extradata_size = 8;
+
// Audio
- audio_dec = audio_stream->codec;
- audio_dec->codec_type = AVMEDIA_TYPE_AUDIO;
- audio_dec->codec_id = AV_CODEC_ID_ADPCM_IMA_APC;
- audio_dec->channels = 1;
- audio_dec->channel_layout = AV_CH_LAYOUT_MONO;
- audio_dec->sample_rate = 22050;
+ audio_par = audio_stream->codecpar;
+ audio_par->codec_type = AVMEDIA_TYPE_AUDIO;
+ audio_par->codec_id = AV_CODEC_ID_ADPCM_IMA_APC;
+ audio_par->channels = 1;
+ audio_par->channel_layout = AV_CH_LAYOUT_MONO;
+ audio_par->sample_rate = 22050;
// Video
- video_dec = video_stream->codec;
- video_dec->codec_type = AVMEDIA_TYPE_VIDEO;
- video_dec->codec_id = AV_CODEC_ID_YOP;
+ video_par = video_stream->codecpar;
+ video_par->codec_type = AVMEDIA_TYPE_VIDEO;
+ video_par->codec_id = AV_CODEC_ID_YOP;
avio_skip(pb, 6);
frame_rate = avio_r8(pb);
yop->frame_size = avio_r8(pb) * 2048;
- video_dec->width = avio_rl16(pb);
- video_dec->height = avio_rl16(pb);
+ video_par->width = avio_rl16(pb);
+ video_par->height = avio_rl16(pb);
video_stream->sample_aspect_ratio = (AVRational){1, 2};
- ret = avio_read(pb, video_dec->extradata, 8);
+ ret = avio_read(pb, video_par->extradata, 8);
if (ret < 8)
return ret < 0 ? ret : AVERROR_EOF;
- yop->palette_size = video_dec->extradata[0] * 3 + 4;
- yop->audio_block_length = AV_RL16(video_dec->extradata + 6);
+ yop->palette_size = video_par->extradata[0] * 3 + 4;
+ yop->audio_block_length = AV_RL16(video_par->extradata + 6);
- video_dec->bit_rate = 8 * (yop->frame_size - yop->audio_block_length) * frame_rate;
+ video_par->bit_rate = 8 * (yop->frame_size - yop->audio_block_length) * frame_rate;
// 1840 samples per frame, 1 nibble per sample; hence 1840/2 = 920
if (yop->audio_block_length < 920 ||
diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
index db07566eb6..a91645f6d6 100644
--- a/libavformat/yuv4mpegdec.c
+++ b/libavformat/yuv4mpegdec.c
@@ -247,18 +247,18 @@ static int yuv4_read_header(AVFormatContext *s)
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
- st->codec->width = width;
- st->codec->height = height;
+ st->codecpar->width = width;
+ st->codecpar->height = height;
av_reduce(&raten, &rated, raten, rated, (1UL << 31) - 1);
avpriv_set_pts_info(st, 64, rated, raten);
st->avg_frame_rate = av_inv_q(st->time_base);
- st->codec->pix_fmt = pix_fmt;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
+ st->codecpar->format = pix_fmt;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
st->sample_aspect_ratio = (AVRational){ aspectn, aspectd };
- st->codec->chroma_sample_location = chroma_sample_location;
- st->codec->field_order = field_order;
- s->packet_size = av_image_get_buffer_size(st->codec->pix_fmt, width, height, 1) + Y4M_FRAME_MAGIC_LEN;
+ st->codecpar->chroma_location = chroma_sample_location;
+ st->codecpar->field_order = field_order;
+ s->packet_size = av_image_get_buffer_size(st->codecpar->format, width, height, 1) + Y4M_FRAME_MAGIC_LEN;
if ((int) s->packet_size < 0)
return s->packet_size;
s->internal->data_offset = avio_tell(pb);
diff --git a/libavformat/yuv4mpegenc.c b/libavformat/yuv4mpegenc.c
index 033badb0af..b4dc6e9ef6 100644
--- a/libavformat/yuv4mpegenc.c
+++ b/libavformat/yuv4mpegenc.c
@@ -33,10 +33,12 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf)
int raten, rated, aspectn, aspectd, n;
char inter;
const char *colorspace = "";
+ int field_order;
st = s->streams[0];
- width = st->codec->width;
- height = st->codec->height;
+ width = st->codecpar->width;
+ height = st->codecpar->height;
+ field_order = st->codecpar->field_order;
// TODO: should be avg_frame_rate
av_reduce(&raten, &rated, st->time_base.den,
@@ -48,7 +50,14 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf)
if (aspectn == 0 && aspectd == 1)
aspectd = 0; // 0:0 means unknown
- switch (st->codec->field_order) {
+#if FF_API_LAVF_AVCTX
+ FF_DISABLE_DEPRECATION_WARNINGS
+ if (field_order != st->codec->field_order && st->codec->field_order != AV_FIELD_UNKNOWN)
+ field_order = st->codec->field_order;
+ FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
+ switch (field_order) {
case AV_FIELD_TB:
case AV_FIELD_TT: inter = 't'; break;
case AV_FIELD_BT:
@@ -56,7 +65,7 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf)
default: inter = 'p'; break;
}
- switch (st->codec->pix_fmt) {
+ switch (st->codecpar->format) {
case AV_PIX_FMT_GRAY8:
colorspace = " Cmono";
break;
@@ -67,7 +76,7 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf)
colorspace = " C411 XYSCSS=411";
break;
case AV_PIX_FMT_YUV420P:
- switch (st->codec->chroma_sample_location) {
+ switch (st->codecpar->chroma_location) {
case AVCHROMA_LOC_TOPLEFT: colorspace = " C420paldv XYSCSS=420PALDV"; break;
case AVCHROMA_LOC_LEFT: colorspace = " C420mpeg2 XYSCSS=420MPEG2"; break;
default: colorspace = " C420jpeg XYSCSS=420JPEG"; break;
@@ -163,12 +172,12 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
avio_printf(s->pb, "%s\n", Y4M_FRAME_MAGIC);
- width = st->codec->width;
- height = st->codec->height;
+ width = st->codecpar->width;
+ height = st->codecpar->height;
ptr = frame->data[0];
- switch (st->codec->pix_fmt) {
+ switch (st->codecpar->format) {
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_YUV411P:
case AV_PIX_FMT_YUV420P:
@@ -195,7 +204,7 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
break;
default:
av_log(s, AV_LOG_ERROR, "The pixel format '%s' is not supported.\n",
- av_get_pix_fmt_name(st->codec->pix_fmt));
+ av_get_pix_fmt_name(st->codecpar->format));
return AVERROR(EINVAL);
}
@@ -204,10 +213,10 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
ptr += frame->linesize[0];
}
- if (st->codec->pix_fmt != AV_PIX_FMT_GRAY8 &&
- st->codec->pix_fmt != AV_PIX_FMT_GRAY16) {
+ if (st->codecpar->format != AV_PIX_FMT_GRAY8 &&
+ st->codecpar->format != AV_PIX_FMT_GRAY16) {
// Adjust for smaller Cb and Cr planes
- av_pix_fmt_get_chroma_sub_sample(st->codec->pix_fmt, &h_chroma_shift,
+ av_pix_fmt_get_chroma_sub_sample(st->codecpar->format, &h_chroma_shift,
&v_chroma_shift);
// Shift right, rounding up
width = AV_CEIL_RSHIFT(width, h_chroma_shift);
@@ -235,12 +244,12 @@ static int yuv4_write_header(AVFormatContext *s)
if (s->nb_streams != 1)
return AVERROR(EIO);
- if (s->streams[0]->codec->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME) {
+ if (s->streams[0]->codecpar->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME) {
av_log(s, AV_LOG_ERROR, "ERROR: Codec not supported.\n");
return AVERROR_INVALIDDATA;
}
- switch (s->streams[0]->codec->pix_fmt) {
+ switch (s->streams[0]->codecpar->format) {
case AV_PIX_FMT_YUV411P:
av_log(s, AV_LOG_WARNING, "Warning: generating rarely used 4:1:1 YUV "
"stream, some mjpegtools might not work.\n");
@@ -269,7 +278,7 @@ static int yuv4_write_header(AVFormatContext *s)
if (s->strict_std_compliance >= FF_COMPLIANCE_NORMAL) {
av_log(s, AV_LOG_ERROR, "'%s' is not an official yuv4mpegpipe pixel format. "
"Use '-strict -1' to encode to this pixel format.\n",
- av_get_pix_fmt_name(s->streams[0]->codec->pix_fmt));
+ av_get_pix_fmt_name(s->streams[0]->codecpar->format));
return AVERROR(EINVAL);
}
av_log(s, AV_LOG_WARNING, "Warning: generating non standard YUV stream. "
diff --git a/tests/api/api-band-test.c b/tests/api/api-band-test.c
index 8644e7df9e..5ccba4f766 100644
--- a/tests/api/api-band-test.c
+++ b/tests/api/api-band-test.c
@@ -67,7 +67,8 @@ static void draw_horiz_band(AVCodecContext *ctx, const AVFrame *fr, int offset[4
static int video_decode(const char *input_filename)
{
AVCodec *codec = NULL;
- AVCodecContext *origin_ctx = NULL, *ctx= NULL;
+ AVCodecContext *ctx= NULL;
+ AVCodecParameters *origin_par = NULL;
uint8_t *byte_buffer = NULL;
AVFrame *fr = NULL;
AVPacket pkt;
@@ -99,9 +100,9 @@ static int video_decode(const char *input_filename)
return -1;
}
- origin_ctx = fmt_ctx->streams[video_stream]->codec;
+ origin_par = fmt_ctx->streams[video_stream]->codecpar;
- codec = avcodec_find_decoder(origin_ctx->codec_id);
+ codec = avcodec_find_decoder(origin_par->codec_id);
if (!codec) {
av_log(NULL, AV_LOG_ERROR, "Can't find decoder\n");
return -1;
@@ -113,7 +114,7 @@ static int video_decode(const char *input_filename)
return AVERROR(ENOMEM);
}
- result = avcodec_copy_context(ctx, origin_ctx);
+ result = avcodec_parameters_to_context(ctx, origin_par);
if (result) {
av_log(NULL, AV_LOG_ERROR, "Can't copy decoder context\n");
return result;
diff --git a/tests/api/api-h264-test.c b/tests/api/api-h264-test.c
index acf1636b39..ef3a1fefff 100644
--- a/tests/api/api-h264-test.c
+++ b/tests/api/api-h264-test.c
@@ -32,7 +32,8 @@
static int video_decode_example(const char *input_filename)
{
AVCodec *codec = NULL;
- AVCodecContext *origin_ctx = NULL, *ctx= NULL;
+ AVCodecContext *ctx= NULL;
+ AVCodecParameters *origin_par = NULL;
AVFrame *fr = NULL;
uint8_t *byte_buffer = NULL;
AVPacket pkt;
@@ -63,9 +64,9 @@ static int video_decode_example(const char *input_filename)
return -1;
}
- origin_ctx = fmt_ctx->streams[video_stream]->codec;
+ origin_par = fmt_ctx->streams[video_stream]->codecpar;
- codec = avcodec_find_decoder(origin_ctx->codec_id);
+ codec = avcodec_find_decoder(origin_par->codec_id);
if (!codec) {
av_log(NULL, AV_LOG_ERROR, "Can't find decoder\n");
return -1;
@@ -77,7 +78,7 @@ static int video_decode_example(const char *input_filename)
return AVERROR(ENOMEM);
}
- result = avcodec_copy_context(ctx, origin_ctx);
+ result = avcodec_parameters_to_context(ctx, origin_par);
if (result) {
av_log(NULL, AV_LOG_ERROR, "Can't copy decoder context\n");
return result;
diff --git a/tests/api/api-seek-test.c b/tests/api/api-seek-test.c
index 135b972440..df47a5fbdb 100644
--- a/tests/api/api-seek-test.c
+++ b/tests/api/api-seek-test.c
@@ -174,7 +174,8 @@ static long int read_seek_range(const char *string_with_number)
static int seek_test(const char *input_filename, const char *start, const char *end)
{
AVCodec *codec = NULL;
- AVCodecContext *origin_ctx = NULL, *ctx= NULL;
+ AVCodecContext *ctx= NULL;
+ AVCodecParameters *origin_par = NULL;
AVFrame *fr = NULL;
AVFormatContext *fmt_ctx = NULL;
int video_stream;
@@ -210,9 +211,9 @@ static int seek_test(const char *input_filename, const char *start, const char *
return -1;
}
- origin_ctx = fmt_ctx->streams[video_stream]->codec;
+ origin_par = fmt_ctx->streams[video_stream]->codecpar;
- codec = avcodec_find_decoder(origin_ctx->codec_id);
+ codec = avcodec_find_decoder(origin_par->codec_id);
if (!codec) {
av_log(NULL, AV_LOG_ERROR, "Can't find decoder\n");
return -1;
@@ -224,7 +225,7 @@ static int seek_test(const char *input_filename, const char *start, const char *
return AVERROR(ENOMEM);
}
- result = avcodec_copy_context(ctx, origin_ctx);
+ result = avcodec_parameters_to_context(ctx, origin_par);
if (result) {
av_log(NULL, AV_LOG_ERROR, "Can't copy decoder context\n");
return result;
diff --git a/tests/fate/vpx.mak b/tests/fate/vpx.mak
index 57e2d8101f..f0bcfaca4a 100644
--- a/tests/fate/vpx.mak
+++ b/tests/fate/vpx.mak
@@ -20,10 +20,10 @@ FATE_VP6-$(call DEMDEC, EA, VP6) += fate-vp61
fate-vp61: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/ea-vp6/MovieSkirmishGondor.vp6 -t 4
FATE_VP6-$(call DEMDEC, FLV, VP6A) += fate-vp6a
-fate-vp6a: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/flash-vp6/300x180-Scr-f8-056alpha.flv
+fate-vp6a: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/flash-vp6/300x180-Scr-f8-056alpha.mov
FATE_VP6-$(call DEMDEC, FLV, VP6A) += fate-vp6a-skip_alpha
-fate-vp6a-skip_alpha: CMD = framecrc -flags +bitexact -skip_alpha 1 -i $(TARGET_SAMPLES)/flash-vp6/300x180-Scr-f8-056alpha.flv
+fate-vp6a-skip_alpha: CMD = framecrc -flags +bitexact -skip_alpha 1 -i $(TARGET_SAMPLES)/flash-vp6/300x180-Scr-f8-056alpha.mov
FATE_VP6-$(call DEMDEC, FLV, VP6F) += fate-vp6f
fate-vp6f: CMD = framecrc -flags +bitexact -i $(TARGET_SAMPLES)/flash-vp6/clip1024.flv
diff --git a/tests/ref/fate/concat-demuxer-extended-lavf-mxf b/tests/ref/fate/concat-demuxer-extended-lavf-mxf
index 4caec5a988..b89493857d 100644
--- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf
+++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf
@@ -1 +1 @@
-37b4a84fce71b3f8b129f8b866c5f55a *tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe
+0aa1ca6ff6e2e5aa926454d22fdaecd5 *tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe
diff --git a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
index 1965050a5e..b378a2da21 100644
--- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
+++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
@@ -1 +1 @@
-2f5e935f86304c843be1454b1354a4b7 *tests/data/fate/concat-demuxer-extended-lavf-mxf_d10.ffprobe
+14c2b8d8f82f261c9627b33c481c0e8c *tests/data/fate/concat-demuxer-extended-lavf-mxf_d10.ffprobe
diff --git a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
index c28db28ebc..3fc7957a13 100644
--- a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
+++ b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
@@ -120,5 +120,5 @@ audio|1|65280|1.360000|65280|1.360000|1920|0.040000|N/A|N/A|3840|206848|K|1
Strings Metadata|8
video|0|37|1.480000|34|1.360000|1|0.040000|N/A|N/A|24786|211456|K|1
Strings Metadata|8
-0|mpeg2video|4|video|1/50|[0][0][0][0]|0x0000|352|288|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|00:00:00:00|1|N/A|25/1|25/1|1/25|N/A|N/A|N/A|N/A|N/A|104857200|N/A|N/A|N/A|51|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
+0|mpeg2video|4|video|1/25|[0][0][0][0]|0x0000|352|288|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|N/A|1|N/A|25/1|25/1|1/25|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|51|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
1|pcm_s16le|unknown|audio|1/48000|[0][0][0][0]|0x0000|s16|48000|1|unknown|16|N/A|0/0|0/0|1/48000|0|0.000000|N/A|N/A|768000|N/A|N/A|N/A|N/A|50|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
diff --git a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10 b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
index 3b6e3fe0e4..0ff1b04c7c 100644
--- a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
+++ b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
@@ -78,5 +78,5 @@ video|0|34|1.360000|34|1.360000|1|0.040000|N/A|N/A|150000|1923072|K|1
Strings Metadata|8
audio|1|65280|1.360000|65280|1.360000|1920|0.040000|N/A|N/A|7680|2073600|K|1
Strings Metadata|8
-0|mpeg2video|0|video|1/50|[0][0][0][0]|0x0000|720|608|0|0|0|1:1|45:38|yuv422p|5|tv|unknown|unknown|unknown|topleft|00:00:00:00|1|N/A|25/1|25/1|1/25|0|0.000000|N/A|N/A|30000000|30000000|N/A|N/A|N/A|35|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
+0|mpeg2video|0|video|1/25|[0][0][0][0]|0x0000|720|608|0|0|0|1:1|45:38|yuv422p|5|tv|unknown|unknown|unknown|topleft|N/A|1|N/A|25/1|25/1|1/25|0|0.000000|N/A|N/A|30000000|N/A|N/A|N/A|N/A|35|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
1|pcm_s16le|unknown|audio|1/48000|[0][0][0][0]|0x0000|s16|48000|2|unknown|16|N/A|0/0|0/0|1/48000|0|0.000000|N/A|N/A|1536000|N/A|N/A|N/A|N/A|35|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
diff --git a/tests/ref/fate/concat-demuxer-simple2-lavf-ts b/tests/ref/fate/concat-demuxer-simple2-lavf-ts
index 4a50f52c6f..33337cff43 100644
--- a/tests/ref/fate/concat-demuxer-simple2-lavf-ts
+++ b/tests/ref/fate/concat-demuxer-simple2-lavf-ts
@@ -148,4 +148,4 @@ video|1|168382|1.870911|164782|1.830911|3600|0.040000|N/A|N/A|24800|189692|K
video|1|171982|1.910911|168382|1.870911|3600|0.040000|N/A|N/A|17454|216388|_
video|1|175582|1.950911|171982|1.910911|3600|0.040000|N/A|N/A|15033|235000|_
0|mp2|unknown|audio|1/44100|[3][0][0][0]|0x0003|s16p|44100|1|mono|0|N/A|0/0|0/0|1/90000|0|0.000000|N/A|N/A|64000|N/A|N/A|N/A|N/A|89|0|0|0|0|0|0|0|0|0|0|0
-1|mpeg2video|4|video|1/50|[2][0][0][0]|0x0002|352|288|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|00:00:00:00|1|N/A|25/1|25/1|1/90000|N/A|N/A|N/A|N/A|N/A|104857200|N/A|N/A|N/A|60|0|0|0|0|0|0|0|0|0|0|0
+1|mpeg2video|4|video|1/25|[2][0][0][0]|0x0002|352|288|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|N/A|1|N/A|25/1|25/1|1/90000|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|60|0|0|0|0|0|0|0|0|0|0|0
diff --git a/tests/ref/fate/ffprobe_compact b/tests/ref/fate/ffprobe_compact
index 4e1288431d..d529bb617e 100644
--- a/tests/ref/fate/ffprobe_compact
+++ b/tests/ref/fate/ffprobe_compact
@@ -27,6 +27,6 @@ frame|media_type=video|stream_index=1|key_frame=1|pkt_pts=6144|pkt_pts_time=0.12
packet|codec_type=video|stream_index=2|pts=6144|pts_time=0.120000|dts=6144|dts_time=0.120000|duration=2048|duration_time=0.040000|convergence_duration=N/A|convergence_duration_time=N/A|size=30000|pos=1024806|flags=K
frame|media_type=video|stream_index=2|key_frame=1|pkt_pts=6144|pkt_pts_time=0.120000|pkt_dts=6144|pkt_dts_time=0.120000|best_effort_timestamp=6144|best_effort_timestamp_time=0.120000|pkt_duration=2048|pkt_duration_time=0.040000|pkt_pos=1024806|pkt_size=30000|width=100|height=100|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0
stream|index=0|codec_name=pcm_s16le|profile=unknown|codec_type=audio|codec_time_base=1/44100|codec_tag_string=PSD[16]|codec_tag=0x10445350|sample_fmt=s16|sample_rate=44100|channels=1|channel_layout=unknown|bits_per_sample=16|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/44100|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=705600|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=6|nb_read_packets=6|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|tag:E=mc²|tag:encoder=Lavc pcm_s16le
-stream|index=1|codec_name=rawvideo|profile=unknown|codec_type=video|codec_time_base=1/51200|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=320|height=240|coded_width=320|coded_height=240|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=4:3|pix_fmt=rgb24|level=-99|color_range=N/A|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=unspecified|timecode=N/A|refs=1|id=N/A|r_frame_rate=25/1|avg_frame_rate=25/1|time_base=1/51200|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|tag:title=foobar|tag:duration_ts=field-and-tags-conflict-attempt|tag:encoder=Lavc rawvideo
-stream|index=2|codec_name=rawvideo|profile=unknown|codec_type=video|codec_time_base=1/51200|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=100|height=100|coded_width=100|coded_height=100|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=1:1|pix_fmt=rgb24|level=-99|color_range=N/A|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=unspecified|timecode=N/A|refs=1|id=N/A|r_frame_rate=25/1|avg_frame_rate=25/1|time_base=1/51200|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|tag:encoder=Lavc rawvideo
+stream|index=1|codec_name=rawvideo|profile=unknown|codec_type=video|codec_time_base=1/25|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=320|height=240|coded_width=320|coded_height=240|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=4:3|pix_fmt=rgb24|level=-99|color_range=N/A|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=unspecified|timecode=N/A|refs=1|id=N/A|r_frame_rate=25/1|avg_frame_rate=25/1|time_base=1/51200|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|tag:title=foobar|tag:duration_ts=field-and-tags-conflict-attempt|tag:encoder=Lavc rawvideo
+stream|index=2|codec_name=rawvideo|profile=unknown|codec_type=video|codec_time_base=1/25|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=100|height=100|coded_width=100|coded_height=100|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=1:1|pix_fmt=rgb24|level=-99|color_range=N/A|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=unspecified|timecode=N/A|refs=1|id=N/A|r_frame_rate=25/1|avg_frame_rate=25/1|time_base=1/51200|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|tag:encoder=Lavc rawvideo
format|filename=tests/data/ffprobe-test.nut|nb_streams=3|nb_programs=0|format_name=nut|start_time=0.000000|duration=0.120000|size=1054887|bit_rate=70325800|probe_score=100|tag:title=ffprobe test file|tag:comment='A comment with CSV, XML & JSON special chars': <tag value="x">|tag:comment2=I ♥ Üñîçød€
diff --git a/tests/ref/fate/ffprobe_csv b/tests/ref/fate/ffprobe_csv
index 8088c4e232..882c1b80be 100644
--- a/tests/ref/fate/ffprobe_csv
+++ b/tests/ref/fate/ffprobe_csv
@@ -27,6 +27,6 @@ frame,video,1,1,6144,0.120000,6144,0.120000,6144,0.120000,2048,0.040000,794382,2
packet,video,2,6144,0.120000,6144,0.120000,2048,0.040000,N/A,N/A,30000,1024806,K
frame,video,2,1,6144,0.120000,6144,0.120000,6144,0.120000,2048,0.040000,1024806,30000,100,100,rgb24,1:1,I,0,0,0,0,0
stream,0,pcm_s16le,unknown,audio,1/44100,PSD[16],0x10445350,s16,44100,1,unknown,16,N/A,0/0,0/0,1/44100,0,0.000000,N/A,N/A,705600,N/A,N/A,N/A,6,6,0,0,0,0,0,0,0,0,0,0,0,mc²,Lavc pcm_s16le
-stream,1,rawvideo,unknown,video,1/51200,RGB[24],0x18424752,320,240,320,240,0,1:1,4:3,rgb24,-99,N/A,unknown,unknown,unknown,unspecified,N/A,1,N/A,25/1,25/1,1/51200,0,0.000000,N/A,N/A,N/A,N/A,N/A,N/A,4,4,0,0,0,0,0,0,0,0,0,0,0,foobar,field-and-tags-conflict-attempt,Lavc rawvideo
-stream,2,rawvideo,unknown,video,1/51200,RGB[24],0x18424752,100,100,100,100,0,1:1,1:1,rgb24,-99,N/A,unknown,unknown,unknown,unspecified,N/A,1,N/A,25/1,25/1,1/51200,0,0.000000,N/A,N/A,N/A,N/A,N/A,N/A,4,4,0,0,0,0,0,0,0,0,0,0,0,Lavc rawvideo
+stream,1,rawvideo,unknown,video,1/25,RGB[24],0x18424752,320,240,320,240,0,1:1,4:3,rgb24,-99,N/A,unknown,unknown,unknown,unspecified,N/A,1,N/A,25/1,25/1,1/51200,0,0.000000,N/A,N/A,N/A,N/A,N/A,N/A,4,4,0,0,0,0,0,0,0,0,0,0,0,foobar,field-and-tags-conflict-attempt,Lavc rawvideo
+stream,2,rawvideo,unknown,video,1/25,RGB[24],0x18424752,100,100,100,100,0,1:1,1:1,rgb24,-99,N/A,unknown,unknown,unknown,unspecified,N/A,1,N/A,25/1,25/1,1/51200,0,0.000000,N/A,N/A,N/A,N/A,N/A,N/A,4,4,0,0,0,0,0,0,0,0,0,0,0,Lavc rawvideo
format,tests/data/ffprobe-test.nut,3,0,nut,0.000000,0.120000,1054887,70325800,100,ffprobe test file,"'A comment with CSV, XML & JSON special chars': <tag value=""x"">",I ♥ Üñîçød€
diff --git a/tests/ref/fate/ffprobe_default b/tests/ref/fate/ffprobe_default
index 2adb4a4fb2..4adb33068c 100644
--- a/tests/ref/fate/ffprobe_default
+++ b/tests/ref/fate/ffprobe_default
@@ -568,7 +568,7 @@ index=1
codec_name=rawvideo
profile=unknown
codec_type=video
-codec_time_base=1/51200
+codec_time_base=1/25
codec_tag_string=RGB[24]
codec_tag=0x18424752
width=320
@@ -621,7 +621,7 @@ index=2
codec_name=rawvideo
profile=unknown
codec_type=video
-codec_time_base=1/51200
+codec_time_base=1/25
codec_tag_string=RGB[24]
codec_tag=0x18424752
width=100
diff --git a/tests/ref/fate/ffprobe_flat b/tests/ref/fate/ffprobe_flat
index e3483238b8..4b2c91a1aa 100644
--- a/tests/ref/fate/ffprobe_flat
+++ b/tests/ref/fate/ffprobe_flat
@@ -509,7 +509,7 @@ streams.stream.1.index=1
streams.stream.1.codec_name="rawvideo"
streams.stream.1.profile="unknown"
streams.stream.1.codec_type="video"
-streams.stream.1.codec_time_base="1/51200"
+streams.stream.1.codec_time_base="1/25"
streams.stream.1.codec_tag_string="RGB[24]"
streams.stream.1.codec_tag="0x18424752"
streams.stream.1.width=320
@@ -560,7 +560,7 @@ streams.stream.2.index=2
streams.stream.2.codec_name="rawvideo"
streams.stream.2.profile="unknown"
streams.stream.2.codec_type="video"
-streams.stream.2.codec_time_base="1/51200"
+streams.stream.2.codec_time_base="1/25"
streams.stream.2.codec_tag_string="RGB[24]"
streams.stream.2.codec_tag="0x18424752"
streams.stream.2.width=100
diff --git a/tests/ref/fate/ffprobe_ini b/tests/ref/fate/ffprobe_ini
index cc556a4432..ba59d61909 100644
--- a/tests/ref/fate/ffprobe_ini
+++ b/tests/ref/fate/ffprobe_ini
@@ -574,7 +574,7 @@ index=1
codec_name=rawvideo
profile=unknown
codec_type=video
-codec_time_base=1/51200
+codec_time_base=1/25
codec_tag_string=RGB[24]
codec_tag=0x18424752
width=320
@@ -631,7 +631,7 @@ index=2
codec_name=rawvideo
profile=unknown
codec_type=video
-codec_time_base=1/51200
+codec_time_base=1/25
codec_tag_string=RGB[24]
codec_tag=0x18424752
width=100
diff --git a/tests/ref/fate/ffprobe_json b/tests/ref/fate/ffprobe_json
index 34be90738b..8d7abda685 100644
--- a/tests/ref/fate/ffprobe_json
+++ b/tests/ref/fate/ffprobe_json
@@ -561,7 +561,7 @@
"index": 1,
"codec_name": "rawvideo",
"codec_type": "video",
- "codec_time_base": "1/51200",
+ "codec_time_base": "1/25",
"codec_tag_string": "RGB[24]",
"codec_tag": "0x18424752",
"width": 320,
@@ -604,7 +604,7 @@
"index": 2,
"codec_name": "rawvideo",
"codec_type": "video",
- "codec_time_base": "1/51200",
+ "codec_time_base": "1/25",
"codec_tag_string": "RGB[24]",
"codec_tag": "0x18424752",
"width": 100,
diff --git a/tests/ref/fate/ffprobe_xml b/tests/ref/fate/ffprobe_xml
index 834243aa9e..b51b0c61ca 100644
--- a/tests/ref/fate/ffprobe_xml
+++ b/tests/ref/fate/ffprobe_xml
@@ -37,13 +37,13 @@
<tag key="E" value="mc²"/>
<tag key="encoder" value="Lavc pcm_s16le"/>
</stream>
- <stream index="1" codec_name="rawvideo" codec_type="video" codec_time_base="1/51200" codec_tag_string="RGB[24]" codec_tag="0x18424752" width="320" height="240" coded_width="320" coded_height="240" has_b_frames="0" sample_aspect_ratio="1:1" display_aspect_ratio="4:3" pix_fmt="rgb24" level="-99" refs="1" r_frame_rate="25/1" avg_frame_rate="25/1" time_base="1/51200" start_pts="0" start_time="0.000000" nb_read_frames="4" nb_read_packets="4">
+ <stream index="1" codec_name="rawvideo" codec_type="video" codec_time_base="1/25" codec_tag_string="RGB[24]" codec_tag="0x18424752" width="320" height="240" coded_width="320" coded_height="240" has_b_frames="0" sample_aspect_ratio="1:1" display_aspect_ratio="4:3" pix_fmt="rgb24" level="-99" refs="1" r_frame_rate="25/1" avg_frame_rate="25/1" time_base="1/51200" start_pts="0" start_time="0.000000" nb_read_frames="4" nb_read_packets="4">
<disposition default="0" dub="0" original="0" comment="0" lyrics="0" karaoke="0" forced="0" hearing_impaired="0" visual_impaired="0" clean_effects="0" attached_pic="0"/>
<tag key="title" value="foobar"/>
<tag key="duration_ts" value="field-and-tags-conflict-attempt"/>
<tag key="encoder" value="Lavc rawvideo"/>
</stream>
- <stream index="2" codec_name="rawvideo" codec_type="video" codec_time_base="1/51200" codec_tag_string="RGB[24]" codec_tag="0x18424752" width="100" height="100" coded_width="100" coded_height="100" has_b_frames="0" sample_aspect_ratio="1:1" display_aspect_ratio="1:1" pix_fmt="rgb24" level="-99" refs="1" r_frame_rate="25/1" avg_frame_rate="25/1" time_base="1/51200" start_pts="0" start_time="0.000000" nb_read_frames="4" nb_read_packets="4">
+ <stream index="2" codec_name="rawvideo" codec_type="video" codec_time_base="1/25" codec_tag_string="RGB[24]" codec_tag="0x18424752" width="100" height="100" coded_width="100" coded_height="100" has_b_frames="0" sample_aspect_ratio="1:1" display_aspect_ratio="1:1" pix_fmt="rgb24" level="-99" refs="1" r_frame_rate="25/1" avg_frame_rate="25/1" time_base="1/51200" start_pts="0" start_time="0.000000" nb_read_frames="4" nb_read_packets="4">
<disposition default="0" dub="0" original="0" comment="0" lyrics="0" karaoke="0" forced="0" hearing_impaired="0" visual_impaired="0" clean_effects="0" attached_pic="0"/>
<tag key="encoder" value="Lavc rawvideo"/>
</stream>
diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc
index 845ef543fd..d6a7e34259 100644
--- a/tests/ref/fate/movenc
+++ b/tests/ref/fate/movenc
@@ -1,28 +1,28 @@
-249e02e3645ea5ca2c74397c62c53314 3269 non-empty-moov
-3281ff664e9a06e5a03ec6ea1729696c 3721 non-empty-moov-elst
-b408a545b1963a5ea82cf37208b66548 3629 non-empty-moov-no-elst
-a66c786022280c1f69ad7c98c719fa53 4435 ismv
-176a315a5385cb2e082d863e0fb22bf1 2891 empty-moov
-10eb3fdf6ed1400a1eec50746537159f 3283 empty-moov-no-elst
-bcd4d6d22f828f1061e13f3af459644f 3115 empty-moov-no-elst-no-adjust
-176a315a5385cb2e082d863e0fb22bf1 2891 delay-moov
-1398c80f1f5fd7f8e127bb5b17311016 3203 delay-moov-elst
-ed6dd0e0fd6d0d9d1145b201674325f6 2098 delay-moov-empty-track
-7f1dabd680135708c6ff359e4ab27165 2001 delay-moov-empty-track-flush
-39d798aa11a265c7906f9e11d4f303c0 1159 empty-moov-header
+214242e9c7c93171d2f47f5b47776559 3269 non-empty-moov
+44467d568a3cc38d414fd8ed4b2a968f 3721 non-empty-moov-elst
+de22b98a3885f9b4b83cdd48ff46aeb9 3629 non-empty-moov-no-elst
+1f37c1a8e01651e8bebcd66f00b6a226 4435 ismv
+ed8506ebfce4c41732205ae26a4759fd 2891 empty-moov
+1844ee6d19fd1e6daf2655632cf26310 3283 empty-moov-no-elst
+139b27dbe2a80c2dc088d0c755f26033 3115 empty-moov-no-elst-no-adjust
+ed8506ebfce4c41732205ae26a4759fd 2891 delay-moov
+3ece148745cd64b4428530a4d1080a2d 3203 delay-moov-elst
+9562946a369e6fb570fb2fd7aa2fe728 2098 delay-moov-empty-track
+4c7832b81836331c6c37155dc31d95be 2001 delay-moov-empty-track-flush
+b7e3c768b9094ebe2fda44979a7f8985 1159 empty-moov-header
a0165f4a26a409212b0946e981bdefb9 1584 empty-moov-content
-39d798aa11a265c7906f9e11d4f303c0 1159 delay-moov-header
+b7e3c768b9094ebe2fda44979a7f8985 1159 delay-moov-header
a0165f4a26a409212b0946e981bdefb9 1584 delay-moov-content
272a474cfd2a68cc5f05b426b14a2b7d 876 empty-moov-second-frag
272a474cfd2a68cc5f05b426b14a2b7d 876 empty-moov-second-frag-discont
272a474cfd2a68cc5f05b426b14a2b7d 876 delay-moov-second-frag-discont
-6256445b9595de78be493e0faf2bc5d7 1219 delay-moov-elst-init
+6ec3698bcc86013e0016e3d47d230363 1219 delay-moov-elst-init
fcae8f40e015b59aabc8d4a99a759ca1 996 delay-moov-elst-second-frag
-6256445b9595de78be493e0faf2bc5d7 1219 delay-moov-elst-init-discont
+6ec3698bcc86013e0016e3d47d230363 1219 delay-moov-elst-init-discont
fcae8f40e015b59aabc8d4a99a759ca1 996 delay-moov-elst-second-frag-discont
-29f875e401df0fc3026995d12872ef21 1219 delay-moov-elst-signal-init
+c3681590a292cb9ca19a5a982e530166 1219 delay-moov-elst-signal-init
aa5462cc0d2144f72154d9c309edb57d 996 delay-moov-elst-signal-second-frag
-29f875e401df0fc3026995d12872ef21 1219 delay-moov-elst-signal-init-discont
+c3681590a292cb9ca19a5a982e530166 1219 delay-moov-elst-signal-init-discont
aa5462cc0d2144f72154d9c309edb57d 996 delay-moov-elst-signal-second-frag-discont
-6cd6085f4f0ff536acfcb77cb658eb47 4935 vfr
-6cd6085f4f0ff536acfcb77cb658eb47 4935 vfr-noduration
+f12d4a0e054abcc508cc0d28cb320e57 4935 vfr
+f12d4a0e054abcc508cc0d28cb320e57 4935 vfr-noduration
diff --git a/tests/ref/fate/xmv-demux b/tests/ref/fate/xmv-demux
index d13270a6fc..75b515fa3c 100644
--- a/tests/ref/fate/xmv-demux
+++ b/tests/ref/fate/xmv-demux
@@ -84,33 +84,33 @@
0, 4640, 4640, 0, 100, 0x45023894, F=0x0
0, 4680, 4680, 0, 948, 0xa65ed345, F=0x0
0, 4720, 4720, 0, 2808, 0xd7285746, F=0x0
-0, 4760, 4760, 40, 5372, 0x05794175, F=0x0
+0, 4760, 4760, 0, 5372, 0x05794175, F=0x0
1, 3307, 3307, 21, 1512, 0xed8b3f4b
-0, 4800, 4800, 40, 11596, 0x8636eca7, F=0x0
+0, 4800, 4800, 0, 11596, 0x8636eca7, F=0x0
1, 3328, 3328, 21, 1512, 0xa27d3891
-0, 4840, 4840, 40, 11524, 0xe1f39be3, F=0x0
+0, 4840, 4840, 0, 11524, 0xe1f39be3, F=0x0
1, 3349, 3349, 21, 1512, 0xb0f13eb6
-0, 4880, 4880, 40, 23392, 0xab053f05, F=0x0
+0, 4880, 4880, 0, 23392, 0xab053f05, F=0x0
1, 3370, 3370, 23, 1656, 0xe5a98324
-0, 4920, 4920, 40, 4560, 0x03197d07, F=0x0
+0, 4920, 4920, 0, 4560, 0x03197d07, F=0x0
1, 3393, 3393, 31, 2232, 0x15445433
-0, 4960, 4960, 40, 4440, 0x1cc361a2, F=0x0
+0, 4960, 4960, 0, 4440, 0x1cc361a2, F=0x0
1, 3424, 3424, 31, 2232, 0x5cb348a9
-0, 5000, 5000, 40, 23688, 0x16030634, F=0x0
+0, 5000, 5000, 0, 23688, 0x16030634, F=0x0
1, 3455, 3455, 31, 2232, 0xf10347da
-0, 5040, 5040, 40, 16132, 0xf0eca799, F=0x0
+0, 5040, 5040, 0, 16132, 0xf0eca799, F=0x0
1, 3486, 3486, 34, 2448, 0x3e16a175
-0, 5080, 5080, 40, 29896, 0x0c0988ea, F=0x0
+0, 5080, 5080, 0, 29896, 0x0c0988ea, F=0x0
1, 3520, 3520, 35, 2520, 0x17e3ca2b
-0, 5120, 5120, 40, 19956, 0x0093aa0b, F=0x0
+0, 5120, 5120, 0, 19956, 0x0093aa0b, F=0x0
1, 3555, 3555, 27, 1944, 0x35c2de84
-0, 5160, 5160, 40, 16392, 0x8829a9ca, F=0x0
+0, 5160, 5160, 0, 16392, 0x8829a9ca, F=0x0
1, 3582, 3582, 27, 1944, 0x55b4db40
-0, 5200, 5200, 40, 16772, 0x9a4a546d, F=0x0
+0, 5200, 5200, 0, 16772, 0x9a4a546d, F=0x0
1, 3609, 3609, 29, 2088, 0xdaae14b2
-0, 5240, 5240, 40, 8920, 0xcd8ca203, F=0x0
+0, 5240, 5240, 0, 8920, 0xcd8ca203, F=0x0
1, 3638, 3638, 27, 1944, 0x92ccd37f
-0, 5280, 5280, 40, 9632, 0x53c1d37b, F=0x0
+0, 5280, 5280, 0, 9632, 0x53c1d37b, F=0x0
1, 3665, 3665, 27, 1944, 0x70efede1
0, 5320, 5320, 40, 8976, 0xfe4da2cc, F=0x0
1, 3692, 3692, 27, 1944, 0x7601d304
diff --git a/tests/ref/lavf/ffm b/tests/ref/lavf/ffm
index c4d7e1f807..e45ef08a24 100644
--- a/tests/ref/lavf/ffm
+++ b/tests/ref/lavf/ffm
@@ -1,3 +1,3 @@
-e63c16b5f0ad5015304fc4009fdb33ca *./tests/data/lavf/lavf.ffm
+79674a5219d00e1d2221a29157b35eb4 *./tests/data/lavf/lavf.ffm
376832 ./tests/data/lavf/lavf.ffm
./tests/data/lavf/lavf.ffm CRC=0x000e23ae
diff --git a/tests/ref/seek/lavf-voc b/tests/ref/seek/lavf-voc
index 483c782e78..014c251129 100644
--- a/tests/ref/seek/lavf-voc
+++ b/tests/ref/seek/lavf-voc
@@ -4,13 +4,13 @@ ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 32 size: 1024
ret: 0 st:-1 flags:1 ts: 1.894167
ret:-EOF
ret: 0 st: 0 flags:0 ts: 0.788330
-ret: 0 st: 0 flags:1 dts: 0.800773 pts: 0.800773 pos: 33956 size: 1024
+ret: 0 st: 0 flags:1 dts: 0.800773 pts: 0.800773 pos: 34984 size: 1024
ret:-1 st: 0 flags:1 ts:-0.317494
ret:-1 st:-1 flags:0 ts: 2.576668
ret: 0 st:-1 flags:1 ts: 1.470835
ret:-EOF
ret: 0 st: 0 flags:0 ts: 0.365012
-ret: 0 st: 0 flags:1 dts: 0.376834 pts: 0.376834 pos: 15452 size: 1024
+ret: 0 st: 0 flags:1 dts: 0.376834 pts: 0.376834 pos: 16480 size: 1024
ret:-1 st: 0 flags:1 ts:-0.740834
ret:-1 st:-1 flags:0 ts: 2.153336
ret: 0 st:-1 flags:1 ts: 1.047503
@@ -21,24 +21,24 @@ ret: 0 st: 0 flags:1 ts: 2.835848
ret:-EOF
ret:-1 st:-1 flags:0 ts: 1.730004
ret: 0 st:-1 flags:1 ts: 0.624171
-ret: 0 st: 0 flags:1 dts: 0.612356 pts: 0.612356 pos: 25732 size: 1024
+ret: 0 st: 0 flags:1 dts: 0.612356 pts: 0.612356 pos: 26760 size: 1024
ret: 0 st: 0 flags:0 ts:-0.481669
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 32 size: 1024
ret: 0 st: 0 flags:1 ts: 2.412507
ret:-EOF
ret:-1 st:-1 flags:0 ts: 1.306672
ret: 0 st:-1 flags:1 ts: 0.200839
-ret: 0 st: 0 flags:1 dts: 0.188417 pts: 0.188417 pos: 7228 size: 1024
+ret: 0 st: 0 flags:1 dts: 0.188417 pts: 0.188417 pos: 8256 size: 1024
ret: 0 st: 0 flags:0 ts:-0.904986
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 32 size: 1024
ret: 0 st: 0 flags:1 ts: 1.989167
ret:-EOF
ret: 0 st:-1 flags:0 ts: 0.883340
-ret: 0 st: 0 flags:1 dts: 0.894981 pts: 0.894981 pos: 38068 size: 1024
+ret: 0 st: 0 flags:1 dts: 0.894981 pts: 0.894981 pos: 39096 size: 1024
ret:-1 st:-1 flags:1 ts:-0.222493
ret:-1 st: 0 flags:0 ts: 2.671673
ret: 0 st: 0 flags:1 ts: 1.565849
ret:-EOF
ret: 0 st:-1 flags:0 ts: 0.460008
-ret: 0 st: 0 flags:1 dts: 0.471043 pts: 0.471043 pos: 19564 size: 1024
+ret: 0 st: 0 flags:1 dts: 0.471043 pts: 0.471043 pos: 20592 size: 1024
ret:-1 st:-1 flags:1 ts:-0.645825