Merge commit '36ef5369ee9b336febc2c270f8718cec4476cb85'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 7 Aug 2012 20:45:46 +0000 (22:45 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 7 Aug 2012 20:45:46 +0000 (22:45 +0200)
* commit '36ef5369ee9b336febc2c270f8718cec4476cb85':
  Replace all CODEC_ID_* with AV_CODEC_ID_*
  lavc: add AV prefix to codec ids.

Conflicts:
doc/APIchanges
doc/examples/decoding_encoding.c
doc/examples/muxing.c
ffmpeg.c
ffprobe.c
ffserver.c
libavcodec/8svx.c
libavcodec/avcodec.h
libavcodec/dnxhd_parser.c
libavcodec/dvdsubdec.c
libavcodec/error_resilience.c
libavcodec/h263dec.c
libavcodec/libvorbisenc.c
libavcodec/mjpeg_parser.c
libavcodec/mjpegenc.c
libavcodec/mpeg12.c
libavcodec/mpeg4videodec.c
libavcodec/mpegvideo.c
libavcodec/mpegvideo_enc.c
libavcodec/pcm.c
libavcodec/r210dec.c
libavcodec/utils.c
libavcodec/v210dec.c
libavcodec/version.h
libavdevice/alsa-audio-dec.c
libavdevice/bktr.c
libavdevice/v4l2.c
libavformat/asfdec.c
libavformat/asfenc.c
libavformat/avformat.h
libavformat/avidec.c
libavformat/caf.c
libavformat/electronicarts.c
libavformat/flacdec.c
libavformat/flvdec.c
libavformat/flvenc.c
libavformat/framecrcenc.c
libavformat/img2.c
libavformat/img2dec.c
libavformat/img2enc.c
libavformat/ipmovie.c
libavformat/isom.c
libavformat/matroska.c
libavformat/matroskadec.c
libavformat/matroskaenc.c
libavformat/mov.c
libavformat/movenc.c
libavformat/mp3dec.c
libavformat/mpeg.c
libavformat/mpegts.c
libavformat/mxf.c
libavformat/mxfdec.c
libavformat/mxfenc.c
libavformat/nsvdec.c
libavformat/nut.c
libavformat/oggenc.c
libavformat/pmpdec.c
libavformat/rawdec.c
libavformat/rawenc.c
libavformat/riff.c
libavformat/sdp.c
libavformat/utils.c
libavformat/vocenc.c
libavformat/wtv.c
libavformat/xmv.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
659 files changed:
1  2 
cmdutils.c
cmdutils.h
doc/APIchanges
doc/developer.texi
doc/examples/decoding_encoding.c
doc/examples/muxing.c
ffmpeg.c
ffprobe.c
ffserver.c
libavcodec/4xm.c
libavcodec/8bps.c
libavcodec/8svx.c
libavcodec/Makefile
libavcodec/a64multienc.c
libavcodec/aac_ac3_parser.c
libavcodec/aac_ac3_parser.h
libavcodec/aac_parser.c
libavcodec/aacdec.c
libavcodec/aacenc.c
libavcodec/aasc.c
libavcodec/ac3_parser.c
libavcodec/ac3dec.c
libavcodec/ac3enc.c
libavcodec/ac3enc_fixed.c
libavcodec/ac3enc_float.c
libavcodec/adpcm.c
libavcodec/adpcmenc.c
libavcodec/adxdec.c
libavcodec/adxenc.c
libavcodec/alac.c
libavcodec/alacenc.c
libavcodec/alsdec.c
libavcodec/amrnbdec.c
libavcodec/amrwbdec.c
libavcodec/anm.c
libavcodec/ansi.c
libavcodec/apedec.c
libavcodec/arm/h264pred_init_arm.c
libavcodec/arm/vp56dsp_init_arm.c
libavcodec/assdec.c
libavcodec/assenc.c
libavcodec/asv1.c
libavcodec/atrac1.c
libavcodec/atrac3.c
libavcodec/aura.c
libavcodec/avcodec.h
libavcodec/avs.c
libavcodec/avuidec.c
libavcodec/avuienc.c
libavcodec/bethsoftvideo.c
libavcodec/bfi.c
libavcodec/bink.c
libavcodec/binkaudio.c
libavcodec/bintext.c
libavcodec/bmp.c
libavcodec/bmp_parser.c
libavcodec/bmpenc.c
libavcodec/bmv.c
libavcodec/c93.c
libavcodec/cavs_parser.c
libavcodec/cavsdec.c
libavcodec/cdgraphics.c
libavcodec/cdxl.c
libavcodec/cinepak.c
libavcodec/cljr.c
libavcodec/cllc.c
libavcodec/codec_names.sh
libavcodec/cook.c
libavcodec/crystalhd.c
libavcodec/cscd.c
libavcodec/cyuv.c
libavcodec/dca_parser.c
libavcodec/dcadec.c
libavcodec/dcaenc.c
libavcodec/dfa.c
libavcodec/dirac_parser.c
libavcodec/diracdec.c
libavcodec/dnxhd_parser.c
libavcodec/dnxhddec.c
libavcodec/dnxhdenc.c
libavcodec/dpcm.c
libavcodec/dpx.c
libavcodec/dpxenc.c
libavcodec/dsicinav.c
libavcodec/dv.c
libavcodec/dvbsub.c
libavcodec/dvbsub_parser.c
libavcodec/dvbsubdec.c
libavcodec/dvdec.c
libavcodec/dvdsub_parser.c
libavcodec/dvdsubdec.c
libavcodec/dvdsubenc.c
libavcodec/dxa.c
libavcodec/dxva2_h264.c
libavcodec/dxva2_mpeg2.c
libavcodec/dxva2_vc1.c
libavcodec/eac3enc.c
libavcodec/eacmv.c
libavcodec/eamad.c
libavcodec/eatgq.c
libavcodec/eatgv.c
libavcodec/eatqi.c
libavcodec/error_resilience.c
libavcodec/escape124.c
libavcodec/escape130.c
libavcodec/exr.c
libavcodec/ffv1.c
libavcodec/ffwavesynth.c
libavcodec/flac_parser.c
libavcodec/flacdec.c
libavcodec/flacenc.c
libavcodec/flashsv.c
libavcodec/flashsv2enc.c
libavcodec/flashsvenc.c
libavcodec/flicvideo.c
libavcodec/flvdec.c
libavcodec/flvenc.c
libavcodec/fraps.c
libavcodec/frwu.c
libavcodec/g722enc.c
libavcodec/g723_1.c
libavcodec/g726.c
libavcodec/g729dec.c
libavcodec/gif.c
libavcodec/gifdec.c
libavcodec/gsmdec.c
libavcodec/h261_parser.c
libavcodec/h261dec.c
libavcodec/h261enc.c
libavcodec/h263_parser.c
libavcodec/h263dec.c
libavcodec/h264.c
libavcodec/h264_mb_template.c
libavcodec/h264_parser.c
libavcodec/h264pred.c
libavcodec/huffyuv.c
libavcodec/idcinvideo.c
libavcodec/iff.c
libavcodec/imc.c
libavcodec/imx_dump_header_bsf.c
libavcodec/indeo2.c
libavcodec/indeo3.c
libavcodec/indeo4.c
libavcodec/indeo5.c
libavcodec/intelh263dec.c
libavcodec/internal.h
libavcodec/interplayvideo.c
libavcodec/ituh263dec.c
libavcodec/ituh263enc.c
libavcodec/ivi_common.c
libavcodec/j2kdec.c
libavcodec/j2kenc.c
libavcodec/jacosubdec.c
libavcodec/jpeglsdec.c
libavcodec/jpeglsenc.c
libavcodec/jvdec.c
libavcodec/kgv1dec.c
libavcodec/kmvc.c
libavcodec/lagarith.c
libavcodec/latm_parser.c
libavcodec/lcldec.c
libavcodec/lclenc.c
libavcodec/libaacplus.c
libavcodec/libcelt_dec.c
libavcodec/libfaac.c
libavcodec/libfdk-aacenc.c
libavcodec/libgsm.c
libavcodec/libilbc.c
libavcodec/libmp3lame.c
libavcodec/libopencore-amr.c
libavcodec/libopenjpegdec.c
libavcodec/libopenjpegenc.c
libavcodec/libopus_dec.c
libavcodec/libschroedingerdec.c
libavcodec/libschroedingerenc.c
libavcodec/libspeexdec.c
libavcodec/libspeexenc.c
libavcodec/libstagefright.cpp
libavcodec/libtheoraenc.c
libavcodec/libtwolame.c
libavcodec/libutvideodec.cpp
libavcodec/libutvideoenc.cpp
libavcodec/libvo-aacenc.c
libavcodec/libvo-amrwbenc.c
libavcodec/libvorbisdec.c
libavcodec/libvorbisenc.c
libavcodec/libvpxdec.c
libavcodec/libvpxenc.c
libavcodec/libx264.c
libavcodec/libxavs.c
libavcodec/libxvid.c
libavcodec/ljpegenc.c
libavcodec/loco.c
libavcodec/mace.c
libavcodec/mdec.c
libavcodec/microdvddec.c
libavcodec/mimic.c
libavcodec/mjpeg_parser.c
libavcodec/mjpega_dump_header_bsf.c
libavcodec/mjpegbdec.c
libavcodec/mjpegdec.c
libavcodec/mjpegenc.c
libavcodec/mlp_parser.c
libavcodec/mlpdec.c
libavcodec/mmvideo.c
libavcodec/motion_est.c
libavcodec/motionpixels.c
libavcodec/movtextdec.c
libavcodec/movtextenc.c
libavcodec/mpc7.c
libavcodec/mpc8.c
libavcodec/mpeg12.c
libavcodec/mpeg12enc.c
libavcodec/mpeg4video_parser.c
libavcodec/mpeg4videodec.c
libavcodec/mpeg4videoenc.c
libavcodec/mpegaudio_parser.c
libavcodec/mpegaudiodec.c
libavcodec/mpegaudiodec_float.c
libavcodec/mpegaudiodecheader.c
libavcodec/mpegaudioenc.c
libavcodec/mpegvideo.c
libavcodec/mpegvideo.h
libavcodec/mpegvideo_common.h
libavcodec/mpegvideo_enc.c
libavcodec/mpegvideo_parser.c
libavcodec/msmpeg4.c
libavcodec/msrle.c
libavcodec/mss1.c
libavcodec/mss3.c
libavcodec/mss4.c
libavcodec/msvideo1.c
libavcodec/msvideo1enc.c
libavcodec/mxpegdec.c
libavcodec/nellymoserdec.c
libavcodec/nellymoserenc.c
libavcodec/nuv.c
libavcodec/old_codec_ids.h
libavcodec/paf.c
libavcodec/pamenc.c
libavcodec/parser.c
libavcodec/pcm-mpeg.c
libavcodec/pcm.c
libavcodec/pcx.c
libavcodec/pcxenc.c
libavcodec/pgssubdec.c
libavcodec/pictordec.c
libavcodec/png_parser.c
libavcodec/pngdec.c
libavcodec/pngenc.c
libavcodec/pnm.c
libavcodec/pnm_parser.c
libavcodec/pnmdec.c
libavcodec/pnmenc.c
libavcodec/proresdec2.c
libavcodec/proresdec_lgpl.c
libavcodec/proresenc_anatoliy.c
libavcodec/proresenc_kostya.c
libavcodec/psymodel.c
libavcodec/pthread.c
libavcodec/ptx.c
libavcodec/qcelpdec.c
libavcodec/qdm2.c
libavcodec/qdrw.c
libavcodec/qpeg.c
libavcodec/qtrle.c
libavcodec/qtrleenc.c
libavcodec/r210dec.c
libavcodec/r210enc.c
libavcodec/ra144dec.c
libavcodec/ra144enc.c
libavcodec/ra288.c
libavcodec/ratecontrol.c
libavcodec/rawdec.c
libavcodec/rawenc.c
libavcodec/realtextdec.c
libavcodec/rl2.c
libavcodec/roqaudioenc.c
libavcodec/roqvideodec.c
libavcodec/roqvideoenc.c
libavcodec/rpza.c
libavcodec/rv10.c
libavcodec/rv10enc.c
libavcodec/rv20enc.c
libavcodec/rv30.c
libavcodec/rv34.c
libavcodec/rv34_parser.c
libavcodec/rv40.c
libavcodec/s302m.c
libavcodec/samidec.c
libavcodec/sanm.c
libavcodec/sgidec.c
libavcodec/sgienc.c
libavcodec/shorten.c
libavcodec/sipr.c
libavcodec/smacker.c
libavcodec/smc.c
libavcodec/snowdec.c
libavcodec/snowenc.c
libavcodec/sonic.c
libavcodec/sp5xdec.c
libavcodec/srtdec.c
libavcodec/srtenc.c
libavcodec/subviewerdec.c
libavcodec/sunrast.c
libavcodec/sunrastenc.c
libavcodec/svq1dec.c
libavcodec/svq1enc.c
libavcodec/svq3.c
libavcodec/targa.c
libavcodec/targaenc.c
libavcodec/tiertexseqv.c
libavcodec/tiff.c
libavcodec/tiffenc.c
libavcodec/tmv.c
libavcodec/truemotion1.c
libavcodec/truemotion2.c
libavcodec/truespeech.c
libavcodec/tscc.c
libavcodec/tscc2.c
libavcodec/tta.c
libavcodec/twinvq.c
libavcodec/txd.c
libavcodec/ulti.c
libavcodec/utils.c
libavcodec/utvideo.c
libavcodec/v210dec.c
libavcodec/v210enc.c
libavcodec/v210x.c
libavcodec/v308dec.c
libavcodec/v308enc.c
libavcodec/v408dec.c
libavcodec/v408enc.c
libavcodec/v410dec.c
libavcodec/v410enc.c
libavcodec/vaapi_h264.c
libavcodec/vaapi_mpeg2.c
libavcodec/vaapi_mpeg4.c
libavcodec/vaapi_vc1.c
libavcodec/vb.c
libavcodec/vble.c
libavcodec/vc1_parser.c
libavcodec/vc1dec.c
libavcodec/vcr1.c
libavcodec/vda_h264.c
libavcodec/vdpau.c
libavcodec/version.h
libavcodec/vima.c
libavcodec/vmdav.c
libavcodec/vmnc.c
libavcodec/vorbis_parser.c
libavcodec/vorbisdec.c
libavcodec/vorbisenc.c
libavcodec/vp3.c
libavcodec/vp3_parser.c
libavcodec/vp5.c
libavcodec/vp56.c
libavcodec/vp56dsp.c
libavcodec/vp56dsp.h
libavcodec/vp6.c
libavcodec/vp8.c
libavcodec/vp8_parser.c
libavcodec/vqavideo.c
libavcodec/wavpack.c
libavcodec/wma.c
libavcodec/wmadec.c
libavcodec/wmaenc.c
libavcodec/wmalosslessdec.c
libavcodec/wmaprodec.c
libavcodec/wmavoice.c
libavcodec/wmv2dec.c
libavcodec/wmv2enc.c
libavcodec/wnv1.c
libavcodec/ws-snd1.c
libavcodec/x86/dsputil_mmx.c
libavcodec/x86/h264_intrapred_init.c
libavcodec/x86/motion_est_mmx.c
libavcodec/x86/vp56dsp_init.c
libavcodec/xan.c
libavcodec/xbmdec.c
libavcodec/xbmenc.c
libavcodec/xl.c
libavcodec/xsubdec.c
libavcodec/xsubenc.c
libavcodec/xwddec.c
libavcodec/xwdenc.c
libavcodec/xxan.c
libavcodec/y41pdec.c
libavcodec/y41penc.c
libavcodec/yop.c
libavcodec/yuv4dec.c
libavcodec/yuv4enc.c
libavcodec/zmbv.c
libavcodec/zmbvenc.c
libavdevice/alsa-audio-common.c
libavdevice/alsa-audio-dec.c
libavdevice/alsa-audio-enc.c
libavdevice/alsa-audio.h
libavdevice/bktr.c
libavdevice/caca.c
libavdevice/dshow.c
libavdevice/fbdev.c
libavdevice/jack_audio.c
libavdevice/lavfi.c
libavdevice/libcdio.c
libavdevice/libdc1394.c
libavdevice/openal-dec.c
libavdevice/oss_audio.c
libavdevice/pulse.c
libavdevice/sdl.c
libavdevice/sndio_common.c
libavdevice/sndio_common.h
libavdevice/sndio_enc.c
libavdevice/v4l.c
libavdevice/v4l2.c
libavdevice/vfwcap.c
libavdevice/x11grab.c
libavfilter/libmpcodecs/vf_mcdeint.c
libavfilter/libmpcodecs/vf_uspp.c
libavformat/4xm.c
libavformat/a64.c
libavformat/aacdec.c
libavformat/ac3dec.c
libavformat/act.c
libavformat/adtsenc.c
libavformat/aea.c
libavformat/aiff.h
libavformat/aiffdec.c
libavformat/aiffenc.c
libavformat/amr.c
libavformat/anm.c
libavformat/apc.c
libavformat/ape.c
libavformat/apetag.c
libavformat/asfdec.c
libavformat/asfenc.c
libavformat/assdec.c
libavformat/assenc.c
libavformat/au.c
libavformat/avformat.h
libavformat/avidec.c
libavformat/avienc.c
libavformat/avisynth.c
libavformat/avs.c
libavformat/bethsoftvid.c
libavformat/bfi.c
libavformat/bink.c
libavformat/bintext.c
libavformat/bit.c
libavformat/c93.c
libavformat/caf.c
libavformat/cafdec.c
libavformat/cafenc.c
libavformat/cavsvideodec.c
libavformat/cdg.c
libavformat/cdxl.c
libavformat/crcenc.c
libavformat/daud.c
libavformat/dfa.c
libavformat/diracdec.c
libavformat/dnxhddec.c
libavformat/dsicin.c
libavformat/dtsdec.c
libavformat/dv.c
libavformat/dvenc.c
libavformat/dxa.c
libavformat/eacdata.c
libavformat/electronicarts.c
libavformat/ffmenc.c
libavformat/ffmetadec.c
libavformat/filmstripdec.c
libavformat/filmstripenc.c
libavformat/flacdec.c
libavformat/flacenc.c
libavformat/flic.c
libavformat/flvdec.c
libavformat/flvenc.c
libavformat/framecrcenc.c
libavformat/g723_1.c
libavformat/g729dec.c
libavformat/gif.c
libavformat/gsmdec.c
libavformat/gxf.c
libavformat/gxfenc.c
libavformat/h261dec.c
libavformat/h263dec.c
libavformat/h264dec.c
libavformat/icodec.c
libavformat/id3v2.c
libavformat/id3v2.h
libavformat/id3v2enc.c
libavformat/idcin.c
libavformat/idroqdec.c
libavformat/idroqenc.c
libavformat/iff.c
libavformat/ilbc.c
libavformat/img2.c
libavformat/img2dec.c
libavformat/img2enc.c
libavformat/ingenientdec.c
libavformat/internal.h
libavformat/ipmovie.c
libavformat/isom.c
libavformat/isom.h
libavformat/iss.c
libavformat/iv8.c
libavformat/ivfenc.c
libavformat/jacosubdec.c
libavformat/jacosubenc.c
libavformat/jvdec.c
libavformat/latmenc.c
libavformat/libmodplug.c
libavformat/libnut.c
libavformat/lmlm4.c
libavformat/loasdec.c
libavformat/lxfdec.c
libavformat/m4vdec.c
libavformat/matroska.c
libavformat/matroska.h
libavformat/matroskadec.c
libavformat/matroskaenc.c
libavformat/md5enc.c
libavformat/microdvddec.c
libavformat/microdvdenc.c
libavformat/mkvtimestamp_v2.c
libavformat/mm.c
libavformat/mmf.c
libavformat/mov.c
libavformat/mov_chan.c
libavformat/movenc.c
libavformat/mp3dec.c
libavformat/mp3enc.c
libavformat/mpc.c
libavformat/mpc8.c
libavformat/mpeg.c
libavformat/mpegenc.c
libavformat/mpegts.c
libavformat/mpegtsenc.c
libavformat/mpegvideodec.c
libavformat/mpjpeg.c
libavformat/msnwc_tcp.c
libavformat/mtv.c
libavformat/mvi.c
libavformat/mxf.c
libavformat/mxfdec.c
libavformat/mxfenc.c
libavformat/mxg.c
libavformat/ncdec.c
libavformat/nsvdec.c
libavformat/nullenc.c
libavformat/nut.c
libavformat/nutdec.c
libavformat/nutenc.c
libavformat/nuv.c
libavformat/oggdec.c
libavformat/oggenc.c
libavformat/oggparsecelt.c
libavformat/oggparsedirac.c
libavformat/oggparseflac.c
libavformat/oggparseogm.c
libavformat/oggparseopus.c
libavformat/oggparsetheora.c
libavformat/oggparsevorbis.c
libavformat/oma.c
libavformat/paf.c
libavformat/pcmdec.c
libavformat/pcmenc.c
libavformat/pmpdec.c
libavformat/psxstr.c
libavformat/pva.c
libavformat/qcp.c
libavformat/r3d.c
libavformat/rawdec.c
libavformat/rawenc.c
libavformat/rawvideodec.c
libavformat/rdt.c
libavformat/realtextdec.c
libavformat/riff.c
libavformat/riff.h
libavformat/rl2.c
libavformat/rm.c
libavformat/rmdec.c
libavformat/rmenc.c
libavformat/rpl.c
libavformat/rso.c
libavformat/rsodec.c
libavformat/rsoenc.c
libavformat/rtp.c
libavformat/rtp.h
libavformat/rtpdec.c
libavformat/rtpdec.h
libavformat/rtpdec_amr.c
libavformat/rtpdec_asf.c
libavformat/rtpdec_g726.c
libavformat/rtpdec_h263.c
libavformat/rtpdec_h264.c
libavformat/rtpdec_ilbc.c
libavformat/rtpdec_latm.c
libavformat/rtpdec_mpeg4.c
libavformat/rtpdec_qcelp.c
libavformat/rtpdec_qdm2.c
libavformat/rtpdec_qt.c
libavformat/rtpdec_svq3.c
libavformat/rtpdec_vp8.c
libavformat/rtpdec_xiph.c
libavformat/rtpenc.c
libavformat/rtsp.c
libavformat/rtspenc.c
libavformat/samidec.c
libavformat/sapenc.c
libavformat/sbgdec.c
libavformat/sdp.c
libavformat/segafilm.c
libavformat/sierravmd.c
libavformat/siff.c
libavformat/smacker.c
libavformat/smjpeg.c
libavformat/smjpegenc.c
libavformat/smush.c
libavformat/sol.c
libavformat/soxdec.c
libavformat/soxenc.c
libavformat/spdifdec.c
libavformat/spdifenc.c
libavformat/srtdec.c
libavformat/srtenc.c
libavformat/subviewerdec.c
libavformat/swf.h
libavformat/swfdec.c
libavformat/swfenc.c
libavformat/thp.c
libavformat/tiertexseq.c
libavformat/tmv.c
libavformat/tta.c
libavformat/tty.c
libavformat/txd.c
libavformat/utils.c
libavformat/vc1test.c
libavformat/vc1testenc.c
libavformat/voc.c
libavformat/vocdec.c
libavformat/vocenc.c
libavformat/vqf.c
libavformat/wav.c
libavformat/wc3movie.c
libavformat/westwood_aud.c
libavformat/westwood_vqa.c
libavformat/wtv.c
libavformat/wtvdec.c
libavformat/wtvenc.c
libavformat/wv.c
libavformat/wvenc.c
libavformat/xa.c
libavformat/xmv.c
libavformat/xwma.c
libavformat/yop.c
libavformat/yuv4mpeg.c
mt-work/mplayer.diff
tools/ismindex.c

diff --cc cmdutils.c
@@@ -1088,13 -896,59 +1088,13 @@@ FILE *get_preset_file(char *filename, s
  
  int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
  {
 -    if (*spec <= '9' && *spec >= '0') /* opt:index */
 -        return strtol(spec, NULL, 0) == st->index;
 -    else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' ||
 -             *spec == 't') { /* opt:[vasdt] */
 -        enum AVMediaType type;
 -
 -        switch (*spec++) {
 -        case 'v': type = AVMEDIA_TYPE_VIDEO;      break;
 -        case 'a': type = AVMEDIA_TYPE_AUDIO;      break;
 -        case 's': type = AVMEDIA_TYPE_SUBTITLE;   break;
 -        case 'd': type = AVMEDIA_TYPE_DATA;       break;
 -        case 't': type = AVMEDIA_TYPE_ATTACHMENT; break;
 -        default:  av_assert0(0);
 -        }
 -        if (type != st->codec->codec_type)
 -            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 && index-- == 0)
 -                   return i == st->index;
 -            return 0;
 -        }
 -        return 1;
 -    } else if (*spec == 'p' && *(spec + 1) == ':') {
 -        int prog_id, i, j;
 -        char *endptr;
 -        spec += 2;
 -        prog_id = strtol(spec, &endptr, 0);
 -        for (i = 0; i < s->nb_programs; i++) {
 -            if (s->programs[i]->id != prog_id)
 -                continue;
 -
 -            if (*endptr++ == ':') {
 -                int stream_idx = strtol(endptr, NULL, 0);
 -                return stream_idx >= 0 &&
 -                    stream_idx < s->programs[i]->nb_stream_indexes &&
 -                    st->index == s->programs[i]->stream_index[stream_idx];
 -            }
 -
 -            for (j = 0; j < s->programs[i]->nb_stream_indexes; j++)
 -                if (st->index == s->programs[i]->stream_index[j])
 -                    return 1;
 -        }
 -        return 0;
 -    } else if (!*spec) /* empty specifier, matches everything */
 -        return 1;
 -
 -    av_log(s, AV_LOG_ERROR, "Invalid stream specifier: %s.\n", spec);
 -    return AVERROR(EINVAL);
 +    int ret = avformat_match_stream_specifier(s, st, spec);
 +    if (ret < 0)
 +        av_log(s, AV_LOG_ERROR, "Invalid stream specifier: %s.\n", spec);
 +    return ret;
  }
  
- AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id,
+ AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
                                  AVFormatContext *s, AVStream *st, AVCodec *codec)
  {
      AVDictionary    *ret = NULL;
diff --cc cmdutils.h
Simple merge
diff --cc doc/APIchanges
@@@ -15,61 -13,9 +15,64 @@@ libavutil:     2011-04-1
  
  API changes, most recent first:
  
 +2012-07-31 - xxxxxxx - lavc 54.46.100
 +  Add channels field to AVFrame.
 +
 +2012-07-30 - xxxxxxx - lavu 51.66.100
 +  Add av_get_channel_description()
 +  and av_get_standard_channel_layout() functions.
 +
 +2012-07-20 - xxxxxxx - lavc 54.43.100
 +  Add decode_error_flags field to AVFrame.
 +
 +2012-07-20 - xxxxxxx - lavf 54.18.100
 +  Add avformat_match_stream_specifier() function.
 +
 +2012-07-14 - xxxxxxx - lavc 54.38.100 - avcodec.h
 +  Add metadata to AVFrame, and the accessor functions
 +  av_frame_get_metadata() and av_frame_set_metadata().
 +
 +2012-07-10 - xxxxxxx - lavc 54.33.100
 +  Add av_fast_padded_mallocz().
 +
 +2012-07-10 - xxxxxxx - lavfi 3.2.0 - avfilter.h
 +  Add init_opaque() callback to AVFilter struct.
 +
 +2012-06-26 - xxxxxxx - lavu 51.63.100 - imgutils.h
 +  Add functions to libavutil/imgutils.h:
 +  av_image_get_buffer_size()
 +  av_image_fill_arrays()
 +  av_image_copy_to_buffer()
 +
 +2012-06-24 - xxxxxxx - lavu 51.62.100 - version.h
 +  version moved from avutil.h to version.h
 +
 +2012-04-11 - xxxxxxx - lavu 51.58.100 - error.h
 +  Add av_make_error_string() and av_err2str() utilities to
 +  libavutil/error.h.
 +
 +2012-06-05 - xxxxxxx - lavc 54.24.100
 +  Add pkt_duration field to AVFrame.
 +
 +2012-05-24 - xxxxxxx - lavu 51.54.100
 +  Move AVPALETTE_SIZE and AVPALETTE_COUNT macros from
 +  libavcodec/avcodec.h to libavutil/pixfmt.h.
 +
 +2012-05-07 - xxxxxxx - lavf 54.5.100
 +  Add av_guess_sample_aspect_ratio() function.
 +
 +2012-04-20 - xxxxxxx - lavfi 2.70.100
 +  Add avfilter_unref_bufferp() to avfilter.h.
 +
 +2012-04-12 - xxxxxxx - lavfi 2.68.100
 +  Install libavfilter/asrc_abuffer.h public header.
 +
 +2012-03-26 - a67d9cf - lavfi 2.66.100
 +  Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions.
 +
+ 2012-08-xx - xxxxxxx - lavc 54.25 - avcodec.h
+   Rename CodecID to AVCodecID and all CODEC_ID_* to AV_CODEC_ID_*.
  2012-08-03 - xxxxxxx - lavu 51.37.1 - cpu.h
                         lsws 2.1.1   - swscale.h
    Rename AV_CPU_FLAG_MMX2  ---> AV_CPU_FLAG_MMXEXT.
@@@ -393,9 -403,9 +393,9 @@@ send a reminder by email. Your patch sh
  @item
      Did you register it in @file{allcodecs.c} or @file{allformats.c}?
  @item
-     Did you add the CodecID to @file{avcodec.h}?
+     Did you add the AVCodecID to @file{avcodec.h}?
  @item
 -    If it has a fourcc, did you add it to @file{libavformat/riff.c},
 +    If it has a fourCC, did you add it to @file{libavformat/riff.c},
      even if it is only a decoder?
  @item
      Did you add a rule to compile the appropriate files in the Makefile?
@@@ -54,10 -57,10 +54,10 @@@ static void audio_encode_example(const 
      float t, tincr;
      uint8_t *outbuf;
  
 -    printf("Audio encoding\n");
 +    printf("Encode audio file %s\n", filename);
  
      /* find the MP2 encoder */
-     codec = avcodec_find_encoder(CODEC_ID_MP2);
+     codec = avcodec_find_encoder(AV_CODEC_ID_MP2);
      if (!codec) {
          fprintf(stderr, "codec not found\n");
          exit(1);
@@@ -125,10 -127,10 +125,10 @@@ static void audio_decode_example(const 
  
      av_init_packet(&avpkt);
  
 -    printf("Audio decoding\n");
 +    printf("Decode audio file %s\n", filename);
  
      /* find the mpeg audio decoder */
-     codec = avcodec_find_decoder(CODEC_ID_MP2);
+     codec = avcodec_find_decoder(AV_CODEC_ID_MP2);
      if (!codec) {
          fprintf(stderr, "codec not found\n");
          exit(1);
@@@ -242,9 -241,6 +242,9 @@@ static void video_encode_example(const 
      c->max_b_frames=1;
      c->pix_fmt = PIX_FMT_YUV420P;
  
-     if(codec_id == CODEC_ID_H264)
++    if(codec_id == AV_CODEC_ID_H264)
 +        av_opt_set(c->priv_data, "preset", "slow", 0);
 +
      /* open it */
      if (avcodec_open2(c, codec, NULL) < 0) {
          fprintf(stderr, "could not open codec\n");
@@@ -351,10 -349,10 +351,10 @@@ static void video_decode_example(const 
      /* set end of buffer to 0 (this ensures that no overreading happens for damaged mpeg streams) */
      memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
  
 -    printf("Video decoding\n");
 +    printf("Decode video file %s\n", filename);
  
      /* find the mpeg1 video decoder */
-     codec = avcodec_find_decoder(CODEC_ID_MPEG1VIDEO);
+     codec = avcodec_find_decoder(AV_CODEC_ID_MPEG1VIDEO);
      if (!codec) {
          fprintf(stderr, "codec not found\n");
          exit(1);
@@@ -465,8 -463,7 +465,8 @@@ int main(int argc, char **argv
          audio_encode_example("/tmp/test.mp2");
          audio_decode_example("/tmp/test.sw", "/tmp/test.mp2");
  
-         video_encode_example("/tmp/test.h264", CODEC_ID_H264);
-         video_encode_example("/tmp/test.mpg", CODEC_ID_MPEG1VIDEO);
 -        video_encode_example("/tmp/test.mpg");
++        video_encode_example("/tmp/test.h264", AV_CODEC_ID_H264);
++        video_encode_example("/tmp/test.mpg", AV_CODEC_ID_MPEG1VIDEO);
          filename = "/tmp/test.mpg";
      } else {
          filename = argv[1];
@@@ -57,8 -58,7 +57,8 @@@ static int audio_input_frame_size
  /*
   * add an audio output stream
   */
 -static AVStream *add_audio_stream(AVFormatContext *oc, enum AVCodecID codec_id)
 +static AVStream *add_audio_stream(AVFormatContext *oc, AVCodec **codec,
-                                   enum CodecID codec_id)
++                                  enum AVCodecID codec_id)
  {
      AVCodecContext *c;
      AVStream *st;
@@@ -182,8 -182,7 +182,8 @@@ static uint8_t *video_outbuf
  static int frame_count, video_outbuf_size;
  
  /* Add a video output stream. */
 -static AVStream *add_video_stream(AVFormatContext *oc, enum AVCodecID codec_id)
 +static AVStream *add_video_stream(AVFormatContext *oc, AVCodec **codec,
-                                   enum CodecID codec_id)
++                                  enum AVCodecID codec_id)
  {
      AVCodecContext *c;
      AVStream *st;
@@@ -445,11 -460,11 +445,11 @@@ int main(int argc, char **argv
       * and initialize the codecs. */
      video_st = NULL;
      audio_st = NULL;
-     if (fmt->video_codec != CODEC_ID_NONE) {
+     if (fmt->video_codec != AV_CODEC_ID_NONE) {
 -        video_st = add_video_stream(oc, fmt->video_codec);
 +        video_st = add_video_stream(oc, &video_codec, fmt->video_codec);
      }
-     if (fmt->audio_codec != CODEC_ID_NONE) {
+     if (fmt->audio_codec != AV_CODEC_ID_NONE) {
 -        audio_st = add_audio_stream(oc, fmt->audio_codec);
 +        audio_st = add_audio_stream(oc, &audio_codec, fmt->audio_codec);
      }
  
      /* Now that all the parameters are set, we can open the audio and
diff --cc ffmpeg.c
+++ b/ffmpeg.c
@@@ -708,80 -453,6 +708,80 @@@ static void reset_options(OptionsContex
      init_opts();
  }
  
-             if (st->codec->codec_id == CODEC_ID_MJPEG) {
 +static enum PixelFormat choose_pixel_fmt(AVStream *st, AVCodec *codec, enum PixelFormat target)
 +{
 +    if (codec && codec->pix_fmts) {
 +        const enum PixelFormat *p = codec->pix_fmts;
 +        int has_alpha= av_pix_fmt_descriptors[target].nb_components % 2 == 0;
 +        enum PixelFormat best= PIX_FMT_NONE;
 +        if (st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
-             } else if (st->codec->codec_id == CODEC_ID_LJPEG) {
++            if (st->codec->codec_id == AV_CODEC_ID_MJPEG) {
 +                p = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE };
-             if (ost->st->codec->codec_id == CODEC_ID_MJPEG) {
++            } else if (st->codec->codec_id == AV_CODEC_ID_LJPEG) {
 +                p = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ444P, PIX_FMT_YUV420P,
 +                                                 PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_BGRA, PIX_FMT_NONE };
 +            }
 +        }
 +        for (; *p != PIX_FMT_NONE; p++) {
 +            best= avcodec_find_best_pix_fmt2(best, *p, target, has_alpha, NULL);
 +            if (*p == target)
 +                break;
 +        }
 +        if (*p == PIX_FMT_NONE) {
 +            if (target != PIX_FMT_NONE)
 +                av_log(NULL, AV_LOG_WARNING,
 +                       "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n",
 +                       av_pix_fmt_descriptors[target].name,
 +                       codec->name,
 +                       av_pix_fmt_descriptors[best].name);
 +            return best;
 +        }
 +    }
 +    return target;
 +}
 +
 +static char *choose_pix_fmts(OutputStream *ost)
 +{
 +     if (ost->keep_pix_fmt) {
 +        if (ost->filter)
 +            avfilter_graph_set_auto_convert(ost->filter->graph->graph,
 +                                            AVFILTER_AUTO_CONVERT_NONE);
 +        if (ost->st->codec->pix_fmt == PIX_FMT_NONE)
 +            return NULL;
 +        return av_strdup(av_get_pix_fmt_name(ost->st->codec->pix_fmt));
 +    }
 +    if (ost->st->codec->pix_fmt != PIX_FMT_NONE) {
 +        return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc, ost->st->codec->pix_fmt)));
 +    } else if (ost->enc && ost->enc->pix_fmts) {
 +        const enum PixelFormat *p;
 +        AVIOContext *s = NULL;
 +        uint8_t *ret;
 +        int len;
 +
 +        if (avio_open_dyn_buf(&s) < 0)
 +            exit_program(1);
 +
 +        p = ost->enc->pix_fmts;
 +        if (ost->st->codec->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
-             } else if (ost->st->codec->codec_id == CODEC_ID_LJPEG) {
++            if (ost->st->codec->codec_id == AV_CODEC_ID_MJPEG) {
 +                p = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE };
++            } else if (ost->st->codec->codec_id == AV_CODEC_ID_LJPEG) {
 +                p = (const enum PixelFormat[]) { PIX_FMT_YUVJ420P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ444P, PIX_FMT_YUV420P,
 +                                                    PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_BGRA, PIX_FMT_NONE };
 +            }
 +        }
 +
 +        for (; *p != PIX_FMT_NONE; p++) {
 +            const char *name = av_get_pix_fmt_name(*p);
 +            avio_printf(s, "%s:", name);
 +        }
 +        len = avio_close_dyn_buf(s, &ret);
 +        ret[len - 1] = 0;
 +        return ret;
 +    } else
 +        return NULL;
 +}
 +
  /**
   * Define a function for building a string containing a list of
   * allowed formats,
@@@ -1871,8 -1363,7 +1871,8 @@@ static void do_subtitle_out(AVFormatCon
          pkt.data = subtitle_out;
          pkt.size = subtitle_out_size;
          pkt.pts  = av_rescale_q(sub->pts, AV_TIME_BASE_Q, ost->st->time_base);
-         if (enc->codec_id == CODEC_ID_DVB_SUBTITLE) {
 +        pkt.duration = av_rescale_q(sub->end_display_time, (AVRational){ 1, 1000 }, ost->st->time_base);
+         if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
              /* XXX: the pts correction is handled here. Maybe handling
                 it in the codec would be better */
              if (i == 0)
@@@ -3205,10 -2470,6 +3205,10 @@@ static int transcode_init(void
                  codec->frame_size         = icodec->frame_size;
                  codec->audio_service_type = icodec->audio_service_type;
                  codec->block_align        = icodec->block_align;
-                 if((codec->block_align == 1 || codec->block_align == 1152) && codec->codec_id == CODEC_ID_MP3)
++                if((codec->block_align == 1 || codec->block_align == 1152) && codec->codec_id == AV_CODEC_ID_MP3)
 +                    codec->block_align= 0;
-                 if(codec->codec_id == CODEC_ID_AC3)
++                if(codec->codec_id == AV_CODEC_ID_AC3)
 +                    codec->block_align= 0;
                  break;
              case AVMEDIA_TYPE_VIDEO:
                  codec->pix_fmt            = icodec->pix_fmt;
@@@ -4683,12 -3616,6 +4683,12 @@@ static int opt_input_file(OptionsContex
      if (o->nb_frame_pix_fmts)
          av_dict_set(&format_opts, "pixel_format", o->frame_pix_fmts[o->nb_frame_pix_fmts - 1].u.str, 0);
  
-         find_codec_or_die(video_codec_name   , AVMEDIA_TYPE_VIDEO   , 0)->id : CODEC_ID_NONE;
 +    ic->video_codec_id   = video_codec_name ?
-         find_codec_or_die(audio_codec_name   , AVMEDIA_TYPE_AUDIO   , 0)->id : CODEC_ID_NONE;
++        find_codec_or_die(video_codec_name   , AVMEDIA_TYPE_VIDEO   , 0)->id : AV_CODEC_ID_NONE;
 +    ic->audio_codec_id   = audio_codec_name ?
-         find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0)->id : CODEC_ID_NONE;
++        find_codec_or_die(audio_codec_name   , AVMEDIA_TYPE_AUDIO   , 0)->id : AV_CODEC_ID_NONE;
 +    ic->subtitle_codec_id= subtitle_codec_name ?
++        find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0)->id : AV_CODEC_ID_NONE;
      ic->flags |= AVFMT_FLAG_NONBLOCK;
      ic->interrupt_callback = int_cb;
  
@@@ -5365,40 -4218,19 +5365,40 @@@ static void opt_output_file(void *optct
          }
      }
  
 -    if (!o->nb_stream_maps) {
 -        /* pick the "best" stream of each type */
 -#define NEW_STREAM(type, index)\
 -        if (index >= 0) {\
 -            ost = new_ ## type ## _stream(o, oc);\
 -            ost->source_index = index;\
 -            ost->sync_ist     = input_streams[index];\
 -            input_streams[index]->discard = 0;\
 -            input_streams[index]->st->discard = AVDISCARD_NONE;\
 +    if (!strcmp(file_oformat->name, "ffm") &&
 +        av_strstart(filename, "http:", NULL)) {
 +        int j;
 +        /* special case for files sent to ffserver: we get the stream
 +           parameters from ffserver */
 +        int err = read_ffserver_streams(o, oc, filename);
 +        if (err < 0) {
 +            print_error(filename, err);
 +            exit_program(1);
 +        }
 +        for(j = nb_output_streams - oc->nb_streams; j < nb_output_streams; j++) {
 +            ost = output_streams[j];
 +            for (i = 0; i < nb_input_streams; i++) {
 +                ist = input_streams[i];
 +                if(ist->st->codec->codec_type == ost->st->codec->codec_type){
 +                    ost->sync_ist= ist;
 +                    ost->source_index= i;
 +                    if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) ost->avfilter = av_strdup("anull");
 +                    if(ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) ost->avfilter = av_strdup("null");
 +                    ist->discard = 0;
 +                    ist->st->discard = AVDISCARD_NONE;
 +                    break;
 +                }
 +            }
 +            if(!ost->sync_ist){
 +                av_log(NULL, AV_LOG_FATAL, "Missing %s stream which is required by this ffm\n", av_get_media_type_string(ost->st->codec->codec_type));
 +                exit_program(1);
 +            }
          }
 +    } else if (!o->nb_stream_maps) {
 +        /* pick the "best" stream of each type */
  
          /* video: highest resolution */
-         if (!o->video_disable && oc->oformat->video_codec != CODEC_ID_NONE) {
+         if (!o->video_disable && oc->oformat->video_codec != AV_CODEC_ID_NONE) {
              int area = 0, idx = -1;
              for (i = 0; i < nb_input_streams; i++) {
                  ist = input_streams[i];
          }
  
          /* subtitles: pick first */
-         if (!o->subtitle_disable && (oc->oformat->subtitle_codec != CODEC_ID_NONE || subtitle_codec_name)) {
 -        if (!o->subtitle_disable && oc->oformat->subtitle_codec != AV_CODEC_ID_NONE) {
++        if (!o->subtitle_disable && (oc->oformat->subtitle_codec != AV_CODEC_ID_NONE || subtitle_codec_name)) {
              for (i = 0; i < nb_input_streams; i++)
                  if (input_streams[i]->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
 -                    NEW_STREAM(subtitle, i);
 +                    new_subtitle_stream(o, oc, i);
                      break;
                  }
          }
diff --cc ffprobe.c
index af69792,0000000..e1ad6a7
mode 100644,000000..100644
--- /dev/null
+++ b/ffprobe.c
@@@ -1,2217 -1,0 +1,2217 @@@
-         if (stream->codec->codec_id == CODEC_ID_PROBE) {
 +/*
 + * Copyright (c) 2007-2010 Stefano Sabatini
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +/**
 + * @file
 + * simple media prober based on the FFmpeg libraries
 + */
 +
 +#include "config.h"
 +#include "version.h"
 +
 +#include "libavformat/avformat.h"
 +#include "libavcodec/avcodec.h"
 +#include "libavutil/avstring.h"
 +#include "libavutil/bprint.h"
 +#include "libavutil/opt.h"
 +#include "libavutil/pixdesc.h"
 +#include "libavutil/dict.h"
 +#include "libavutil/timecode.h"
 +#include "libavdevice/avdevice.h"
 +#include "libswscale/swscale.h"
 +#include "libswresample/swresample.h"
 +#include "libpostproc/postprocess.h"
 +#include "cmdutils.h"
 +
 +const char program_name[] = "ffprobe";
 +const int program_birth_year = 2007;
 +
 +static int do_count_frames = 0;
 +static int do_count_packets = 0;
 +static int do_read_frames  = 0;
 +static int do_read_packets = 0;
 +static int do_show_error   = 0;
 +static int do_show_format  = 0;
 +static int do_show_frames  = 0;
 +static AVDictionary *fmt_entries_to_show = NULL;
 +static int do_show_packets = 0;
 +static int do_show_streams = 0;
 +static int do_show_data    = 0;
 +static int do_show_program_version  = 0;
 +static int do_show_library_versions = 0;
 +
 +static int show_value_unit              = 0;
 +static int use_value_prefix             = 0;
 +static int use_byte_value_binary_prefix = 0;
 +static int use_value_sexagesimal_format = 0;
 +static int show_private_data            = 1;
 +
 +static char *print_format;
 +
 +static const OptionDef *options;
 +
 +/* FFprobe context */
 +static const char *input_filename;
 +static AVInputFormat *iformat = NULL;
 +
 +static const char *const binary_unit_prefixes [] = { "", "Ki", "Mi", "Gi", "Ti", "Pi" };
 +static const char *const decimal_unit_prefixes[] = { "", "K" , "M" , "G" , "T" , "P"  };
 +
 +static const char unit_second_str[]         = "s"    ;
 +static const char unit_hertz_str[]          = "Hz"   ;
 +static const char unit_byte_str[]           = "byte" ;
 +static const char unit_bit_per_second_str[] = "bit/s";
 +static uint64_t *nb_streams_packets;
 +static uint64_t *nb_streams_frames;
 +
 +void av_noreturn exit_program(int ret)
 +{
 +    av_dict_free(&fmt_entries_to_show);
 +    exit(ret);
 +}
 +
 +struct unit_value {
 +    union { double d; long long int i; } val;
 +    const char *unit;
 +};
 +
 +static char *value_string(char *buf, int buf_size, struct unit_value uv)
 +{
 +    double vald;
 +    int show_float = 0;
 +
 +    if (uv.unit == unit_second_str) {
 +        vald = uv.val.d;
 +        show_float = 1;
 +    } else {
 +        vald = uv.val.i;
 +    }
 +
 +    if (uv.unit == unit_second_str && use_value_sexagesimal_format) {
 +        double secs;
 +        int hours, mins;
 +        secs  = vald;
 +        mins  = (int)secs / 60;
 +        secs  = secs - mins * 60;
 +        hours = mins / 60;
 +        mins %= 60;
 +        snprintf(buf, buf_size, "%d:%02d:%09.6f", hours, mins, secs);
 +    } else {
 +        const char *prefix_string = "";
 +        int l;
 +
 +        if (use_value_prefix && vald > 1) {
 +            long long int index;
 +
 +            if (uv.unit == unit_byte_str && use_byte_value_binary_prefix) {
 +                index = (long long int) (log(vald)/log(2)) / 10;
 +                index = av_clip(index, 0, FF_ARRAY_ELEMS(binary_unit_prefixes) - 1);
 +                vald /= pow(2, index * 10);
 +                prefix_string = binary_unit_prefixes[index];
 +            } else {
 +                index = (long long int) (log10(vald)) / 3;
 +                index = av_clip(index, 0, FF_ARRAY_ELEMS(decimal_unit_prefixes) - 1);
 +                vald /= pow(10, index * 3);
 +                prefix_string = decimal_unit_prefixes[index];
 +            }
 +        }
 +
 +        if (show_float || (use_value_prefix && vald != (long long int)vald))
 +            l = snprintf(buf, buf_size, "%f", vald);
 +        else
 +            l = snprintf(buf, buf_size, "%lld", (long long int)vald);
 +        snprintf(buf+l, buf_size-l, "%s%s%s", *prefix_string || show_value_unit ? " " : "",
 +                 prefix_string, show_value_unit ? uv.unit : "");
 +    }
 +
 +    return buf;
 +}
 +
 +/* WRITERS API */
 +
 +typedef struct WriterContext WriterContext;
 +
 +#define WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS 1
 +#define WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER 2
 +
 +typedef struct Writer {
 +    int priv_size;                  ///< private size for the writer context
 +    const char *name;
 +
 +    int  (*init)  (WriterContext *wctx, const char *args, void *opaque);
 +    void (*uninit)(WriterContext *wctx);
 +
 +    void (*print_header)(WriterContext *ctx);
 +    void (*print_footer)(WriterContext *ctx);
 +
 +    void (*print_chapter_header)(WriterContext *wctx, const char *);
 +    void (*print_chapter_footer)(WriterContext *wctx, const char *);
 +    void (*print_section_header)(WriterContext *wctx, const char *);
 +    void (*print_section_footer)(WriterContext *wctx, const char *);
 +    void (*print_integer)       (WriterContext *wctx, const char *, long long int);
 +    void (*print_rational)      (WriterContext *wctx, AVRational *q, char *sep);
 +    void (*print_string)        (WriterContext *wctx, const char *, const char *);
 +    void (*show_tags)           (WriterContext *wctx, AVDictionary *dict);
 +    int flags;                  ///< a combination or WRITER_FLAG_*
 +} Writer;
 +
 +struct WriterContext {
 +    const AVClass *class;           ///< class of the writer
 +    const Writer *writer;           ///< the Writer of which this is an instance
 +    char *name;                     ///< name of this writer instance
 +    void *priv;                     ///< private data for use by the filter
 +    unsigned int nb_item;           ///< number of the item printed in the given section, starting at 0
 +    unsigned int nb_section;        ///< number of the section printed in the given section sequence, starting at 0
 +    unsigned int nb_section_packet; ///< number of the packet section in case we are in "packets_and_frames" section
 +    unsigned int nb_section_frame;  ///< number of the frame  section in case we are in "packets_and_frames" section
 +    unsigned int nb_section_packet_frame; ///< nb_section_packet or nb_section_frame according if is_packets_and_frames
 +    unsigned int nb_chapter;        ///< number of the chapter, starting at 0
 +
 +    int multiple_sections;          ///< tells if the current chapter can contain multiple sections
 +    int is_fmt_chapter;             ///< tells if the current chapter is "format", required by the print_format_entry option
 +    int is_packets_and_frames;      ///< tells if the current section is "packets_and_frames"
 +};
 +
 +static const char *writer_get_name(void *p)
 +{
 +    WriterContext *wctx = p;
 +    return wctx->writer->name;
 +}
 +
 +static const AVClass writer_class = {
 +    "Writer",
 +    writer_get_name,
 +    NULL,
 +    LIBAVUTIL_VERSION_INT,
 +};
 +
 +static void writer_close(WriterContext **wctx)
 +{
 +    if (!*wctx)
 +        return;
 +
 +    if ((*wctx)->writer->uninit)
 +        (*wctx)->writer->uninit(*wctx);
 +    av_freep(&((*wctx)->priv));
 +    av_freep(wctx);
 +}
 +
 +static int writer_open(WriterContext **wctx, const Writer *writer,
 +                       const char *args, void *opaque)
 +{
 +    int ret = 0;
 +
 +    if (!(*wctx = av_malloc(sizeof(WriterContext)))) {
 +        ret = AVERROR(ENOMEM);
 +        goto fail;
 +    }
 +
 +    if (!((*wctx)->priv = av_mallocz(writer->priv_size))) {
 +        ret = AVERROR(ENOMEM);
 +        goto fail;
 +    }
 +
 +    (*wctx)->class = &writer_class;
 +    (*wctx)->writer = writer;
 +    if ((*wctx)->writer->init)
 +        ret = (*wctx)->writer->init(*wctx, args, opaque);
 +    if (ret < 0)
 +        goto fail;
 +
 +    return 0;
 +
 +fail:
 +    writer_close(wctx);
 +    return ret;
 +}
 +
 +static inline void writer_print_header(WriterContext *wctx)
 +{
 +    if (wctx->writer->print_header)
 +        wctx->writer->print_header(wctx);
 +    wctx->nb_chapter = 0;
 +}
 +
 +static inline void writer_print_footer(WriterContext *wctx)
 +{
 +    if (wctx->writer->print_footer)
 +        wctx->writer->print_footer(wctx);
 +}
 +
 +static inline void writer_print_chapter_header(WriterContext *wctx,
 +                                               const char *chapter)
 +{
 +    wctx->nb_section =
 +    wctx->nb_section_packet = wctx->nb_section_frame =
 +    wctx->nb_section_packet_frame = 0;
 +    wctx->is_packets_and_frames = !strcmp(chapter, "packets_and_frames");
 +    wctx->multiple_sections = !strcmp(chapter, "packets") || !strcmp(chapter, "frames" ) ||
 +                              wctx->is_packets_and_frames ||
 +                              !strcmp(chapter, "streams") || !strcmp(chapter, "library_versions");
 +    wctx->is_fmt_chapter = !strcmp(chapter, "format");
 +
 +    if (wctx->writer->print_chapter_header)
 +        wctx->writer->print_chapter_header(wctx, chapter);
 +}
 +
 +static inline void writer_print_chapter_footer(WriterContext *wctx,
 +                                               const char *chapter)
 +{
 +    if (wctx->writer->print_chapter_footer)
 +        wctx->writer->print_chapter_footer(wctx, chapter);
 +    wctx->nb_chapter++;
 +}
 +
 +static inline void writer_print_section_header(WriterContext *wctx,
 +                                               const char *section)
 +{
 +    if (wctx->is_packets_and_frames)
 +        wctx->nb_section_packet_frame = !strcmp(section, "packet") ? wctx->nb_section_packet
 +                                                                   : wctx->nb_section_frame;
 +    if (wctx->writer->print_section_header)
 +        wctx->writer->print_section_header(wctx, section);
 +    wctx->nb_item = 0;
 +}
 +
 +static inline void writer_print_section_footer(WriterContext *wctx,
 +                                               const char *section)
 +{
 +    if (wctx->writer->print_section_footer)
 +        wctx->writer->print_section_footer(wctx, section);
 +    if (wctx->is_packets_and_frames) {
 +        if (!strcmp(section, "packet")) wctx->nb_section_packet++;
 +        else                            wctx->nb_section_frame++;
 +    }
 +    wctx->nb_section++;
 +}
 +
 +static inline void writer_print_integer(WriterContext *wctx,
 +                                        const char *key, long long int val)
 +{
 +    if (!wctx->is_fmt_chapter || !fmt_entries_to_show || av_dict_get(fmt_entries_to_show, key, NULL, 0)) {
 +        wctx->writer->print_integer(wctx, key, val);
 +        wctx->nb_item++;
 +    }
 +}
 +
 +static inline void writer_print_rational(WriterContext *wctx,
 +                                         const char *key, AVRational q, char sep)
 +{
 +    AVBPrint buf;
 +    av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC);
 +    av_bprintf(&buf, "%d%c%d", q.num, sep, q.den);
 +    wctx->writer->print_string(wctx, key, buf.str);
 +    wctx->nb_item++;
 +}
 +
 +static inline void writer_print_string(WriterContext *wctx,
 +                                       const char *key, const char *val, int opt)
 +{
 +    if (opt && !(wctx->writer->flags & WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS))
 +        return;
 +    if (!wctx->is_fmt_chapter || !fmt_entries_to_show || av_dict_get(fmt_entries_to_show, key, NULL, 0)) {
 +        wctx->writer->print_string(wctx, key, val);
 +        wctx->nb_item++;
 +    }
 +}
 +
 +static void writer_print_time(WriterContext *wctx, const char *key,
 +                              int64_t ts, const AVRational *time_base, int is_duration)
 +{
 +    char buf[128];
 +
 +    if (!wctx->is_fmt_chapter || !fmt_entries_to_show || av_dict_get(fmt_entries_to_show, key, NULL, 0)) {
 +        if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
 +            writer_print_string(wctx, key, "N/A", 1);
 +        } else {
 +            double d = ts * av_q2d(*time_base);
 +            value_string(buf, sizeof(buf), (struct unit_value){.val.d=d, .unit=unit_second_str});
 +            writer_print_string(wctx, key, buf, 0);
 +        }
 +    }
 +}
 +
 +static void writer_print_ts(WriterContext *wctx, const char *key, int64_t ts, int is_duration)
 +{
 +    if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
 +        writer_print_string(wctx, key, "N/A", 1);
 +    } else {
 +        writer_print_integer(wctx, key, ts);
 +    }
 +}
 +
 +static inline void writer_show_tags(WriterContext *wctx, AVDictionary *dict)
 +{
 +    wctx->writer->show_tags(wctx, dict);
 +}
 +
 +static void writer_print_data(WriterContext *wctx, const char *name,
 +                              uint8_t *data, int size)
 +{
 +    AVBPrint bp;
 +    int offset = 0, l, i;
 +
 +    av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
 +    av_bprintf(&bp, "\n");
 +    while (size) {
 +        av_bprintf(&bp, "%08x: ", offset);
 +        l = FFMIN(size, 16);
 +        for (i = 0; i < l; i++) {
 +            av_bprintf(&bp, "%02x", data[i]);
 +            if (i & 1)
 +                av_bprintf(&bp, " ");
 +        }
 +        av_bprint_chars(&bp, ' ', 41 - 2 * i - i / 2);
 +        for (i = 0; i < l; i++)
 +            av_bprint_chars(&bp, data[i] - 32U < 95 ? data[i] : '.', 1);
 +        av_bprintf(&bp, "\n");
 +        offset += l;
 +        data   += l;
 +        size   -= l;
 +    }
 +    writer_print_string(wctx, name, bp.str, 0);
 +    av_bprint_finalize(&bp, NULL);
 +}
 +
 +#define MAX_REGISTERED_WRITERS_NB 64
 +
 +static const Writer *registered_writers[MAX_REGISTERED_WRITERS_NB + 1];
 +
 +static int writer_register(const Writer *writer)
 +{
 +    static int next_registered_writer_idx = 0;
 +
 +    if (next_registered_writer_idx == MAX_REGISTERED_WRITERS_NB)
 +        return AVERROR(ENOMEM);
 +
 +    registered_writers[next_registered_writer_idx++] = writer;
 +    return 0;
 +}
 +
 +static const Writer *writer_get_by_name(const char *name)
 +{
 +    int i;
 +
 +    for (i = 0; registered_writers[i]; i++)
 +        if (!strcmp(registered_writers[i]->name, name))
 +            return registered_writers[i];
 +
 +    return NULL;
 +}
 +
 +
 +/* WRITERS */
 +
 +/* Default output */
 +
 +typedef struct DefaultContext {
 +    const AVClass *class;
 +    int nokey;
 +    int noprint_wrappers;
 +} DefaultContext;
 +
 +#define OFFSET(x) offsetof(DefaultContext, x)
 +
 +static const AVOption default_options[] = {
 +    { "noprint_wrappers", "do not print headers and footers", OFFSET(noprint_wrappers), AV_OPT_TYPE_INT, {.dbl=0}, 0, 1 },
 +    { "nw",               "do not print headers and footers", OFFSET(noprint_wrappers), AV_OPT_TYPE_INT, {.dbl=0}, 0, 1 },
 +    { "nokey",          "force no key printing",     OFFSET(nokey),          AV_OPT_TYPE_INT, {.dbl=0}, 0, 1 },
 +    { "nk",             "force no key printing",     OFFSET(nokey),          AV_OPT_TYPE_INT, {.dbl=0}, 0, 1 },
 +    {NULL},
 +};
 +
 +static const char *default_get_name(void *ctx)
 +{
 +    return "default";
 +}
 +
 +static const AVClass default_class = {
 +    "DefaultContext",
 +    default_get_name,
 +    default_options
 +};
 +
 +static av_cold int default_init(WriterContext *wctx, const char *args, void *opaque)
 +{
 +    DefaultContext *def = wctx->priv;
 +    int err;
 +
 +    def->class = &default_class;
 +    av_opt_set_defaults(def);
 +
 +    if (args &&
 +        (err = (av_set_options_string(def, args, "=", ":"))) < 0) {
 +        av_log(wctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
 +        return err;
 +    }
 +
 +    return 0;
 +}
 +
 +static void default_print_footer(WriterContext *wctx)
 +{
 +    DefaultContext *def = wctx->priv;
 +
 +    if (!def->noprint_wrappers)
 +        printf("\n");
 +}
 +
 +static void default_print_chapter_header(WriterContext *wctx, const char *chapter)
 +{
 +    DefaultContext *def = wctx->priv;
 +
 +    if (!def->noprint_wrappers && wctx->nb_chapter)
 +        printf("\n");
 +}
 +
 +/* lame uppercasing routine, assumes the string is lower case ASCII */
 +static inline char *upcase_string(char *dst, size_t dst_size, const char *src)
 +{
 +    int i;
 +    for (i = 0; src[i] && i < dst_size-1; i++)
 +        dst[i] = av_toupper(src[i]);
 +    dst[i] = 0;
 +    return dst;
 +}
 +
 +static void default_print_section_header(WriterContext *wctx, const char *section)
 +{
 +    DefaultContext *def = wctx->priv;
 +    char buf[32];
 +
 +    if (wctx->nb_section)
 +        printf("\n");
 +    if (!def->noprint_wrappers)
 +        printf("[%s]\n", upcase_string(buf, sizeof(buf), section));
 +}
 +
 +static void default_print_section_footer(WriterContext *wctx, const char *section)
 +{
 +    DefaultContext *def = wctx->priv;
 +    char buf[32];
 +
 +    if (!def->noprint_wrappers)
 +        printf("[/%s]", upcase_string(buf, sizeof(buf), section));
 +}
 +
 +static void default_print_str(WriterContext *wctx, const char *key, const char *value)
 +{
 +    DefaultContext *def = wctx->priv;
 +    if (!def->nokey)
 +        printf("%s=", key);
 +    printf("%s\n", value);
 +}
 +
 +static void default_print_int(WriterContext *wctx, const char *key, long long int value)
 +{
 +    DefaultContext *def = wctx->priv;
 +
 +    if (!def->nokey)
 +        printf("%s=", key);
 +    printf("%lld\n", value);
 +}
 +
 +static void default_show_tags(WriterContext *wctx, AVDictionary *dict)
 +{
 +    AVDictionaryEntry *tag = NULL;
 +    while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) {
 +        if (!fmt_entries_to_show || (tag->key && av_dict_get(fmt_entries_to_show, tag->key, NULL, 0)))
 +            printf("TAG:");
 +        writer_print_string(wctx, tag->key, tag->value, 0);
 +    }
 +}
 +
 +static const Writer default_writer = {
 +    .name                  = "default",
 +    .priv_size             = sizeof(DefaultContext),
 +    .init                  = default_init,
 +    .print_footer          = default_print_footer,
 +    .print_chapter_header  = default_print_chapter_header,
 +    .print_section_header  = default_print_section_header,
 +    .print_section_footer  = default_print_section_footer,
 +    .print_integer         = default_print_int,
 +    .print_string          = default_print_str,
 +    .show_tags             = default_show_tags,
 +    .flags = WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS,
 +};
 +
 +/* Compact output */
 +
 +/**
 + * Apply C-language-like string escaping.
 + */
 +static const char *c_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
 +{
 +    const char *p;
 +
 +    for (p = src; *p; p++) {
 +        switch (*p) {
 +        case '\b': av_bprintf(dst, "%s", "\\b");  break;
 +        case '\f': av_bprintf(dst, "%s", "\\f");  break;
 +        case '\n': av_bprintf(dst, "%s", "\\n");  break;
 +        case '\r': av_bprintf(dst, "%s", "\\r");  break;
 +        case '\\': av_bprintf(dst, "%s", "\\\\"); break;
 +        default:
 +            if (*p == sep)
 +                av_bprint_chars(dst, '\\', 1);
 +            av_bprint_chars(dst, *p, 1);
 +        }
 +    }
 +    return dst->str;
 +}
 +
 +/**
 + * Quote fields containing special characters, check RFC4180.
 + */
 +static const char *csv_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
 +{
 +    const char *p;
 +    int quote = 0;
 +
 +    /* check if input needs quoting */
 +    for (p = src; *p; p++)
 +        if (*p == '"' || *p == sep || *p == '\n' || *p == '\r')
 +            quote = 1;
 +
 +    if (quote)
 +        av_bprint_chars(dst, '\"', 1);
 +
 +    for (p = src; *p; p++) {
 +        if (*p == '"')
 +            av_bprint_chars(dst, '\"', 1);
 +        av_bprint_chars(dst, *p, 1);
 +    }
 +    if (quote)
 +        av_bprint_chars(dst, '\"', 1);
 +    return dst->str;
 +}
 +
 +static const char *none_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx)
 +{
 +    return src;
 +}
 +
 +typedef struct CompactContext {
 +    const AVClass *class;
 +    char *item_sep_str;
 +    char item_sep;
 +    int nokey;
 +    char *escape_mode_str;
 +    const char * (*escape_str)(AVBPrint *dst, const char *src, const char sep, void *log_ctx);
 +} CompactContext;
 +
 +#undef OFFSET
 +#define OFFSET(x) offsetof(CompactContext, x)
 +
 +static const AVOption compact_options[]= {
 +    {"item_sep", "set item separator",    OFFSET(item_sep_str),    AV_OPT_TYPE_STRING, {.str="|"},  CHAR_MIN, CHAR_MAX },
 +    {"s",        "set item separator",    OFFSET(item_sep_str),    AV_OPT_TYPE_STRING, {.str="|"},  CHAR_MIN, CHAR_MAX },
 +    {"nokey",    "force no key printing", OFFSET(nokey),           AV_OPT_TYPE_INT,    {.dbl=0},    0,        1        },
 +    {"nk",       "force no key printing", OFFSET(nokey),           AV_OPT_TYPE_INT,    {.dbl=0},    0,        1        },
 +    {"escape",   "set escape mode",       OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str="c"},  CHAR_MIN, CHAR_MAX },
 +    {"e",        "set escape mode",       OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str="c"},  CHAR_MIN, CHAR_MAX },
 +    {NULL},
 +};
 +
 +static const char *compact_get_name(void *ctx)
 +{
 +    return "compact";
 +}
 +
 +static const AVClass compact_class = {
 +    "CompactContext",
 +    compact_get_name,
 +    compact_options
 +};
 +
 +static av_cold int compact_init(WriterContext *wctx, const char *args, void *opaque)
 +{
 +    CompactContext *compact = wctx->priv;
 +    int err;
 +
 +    compact->class = &compact_class;
 +    av_opt_set_defaults(compact);
 +
 +    if (args &&
 +        (err = (av_set_options_string(compact, args, "=", ":"))) < 0) {
 +        av_log(wctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
 +        return err;
 +    }
 +    if (strlen(compact->item_sep_str) != 1) {
 +        av_log(wctx, AV_LOG_ERROR, "Item separator '%s' specified, but must contain a single character\n",
 +               compact->item_sep_str);
 +        return AVERROR(EINVAL);
 +    }
 +    compact->item_sep = compact->item_sep_str[0];
 +
 +    if      (!strcmp(compact->escape_mode_str, "none")) compact->escape_str = none_escape_str;
 +    else if (!strcmp(compact->escape_mode_str, "c"   )) compact->escape_str = c_escape_str;
 +    else if (!strcmp(compact->escape_mode_str, "csv" )) compact->escape_str = csv_escape_str;
 +    else {
 +        av_log(wctx, AV_LOG_ERROR, "Unknown escape mode '%s'\n", compact->escape_mode_str);
 +        return AVERROR(EINVAL);
 +    }
 +
 +    return 0;
 +}
 +
 +static av_cold void compact_uninit(WriterContext *wctx)
 +{
 +    CompactContext *compact = wctx->priv;
 +
 +    av_freep(&compact->item_sep_str);
 +    av_freep(&compact->escape_mode_str);
 +}
 +
 +static void compact_print_section_header(WriterContext *wctx, const char *section)
 +{
 +    CompactContext *compact = wctx->priv;
 +
 +    printf("%s%c", section, compact->item_sep);
 +}
 +
 +static void compact_print_section_footer(WriterContext *wctx, const char *section)
 +{
 +    printf("\n");
 +}
 +
 +static void compact_print_str(WriterContext *wctx, const char *key, const char *value)
 +{
 +    CompactContext *compact = wctx->priv;
 +    AVBPrint buf;
 +
 +    if (wctx->nb_item) printf("%c", compact->item_sep);
 +    if (!compact->nokey)
 +        printf("%s=", key);
 +    av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
 +    printf("%s", compact->escape_str(&buf, value, compact->item_sep, wctx));
 +    av_bprint_finalize(&buf, NULL);
 +}
 +
 +static void compact_print_int(WriterContext *wctx, const char *key, long long int value)
 +{
 +    CompactContext *compact = wctx->priv;
 +
 +    if (wctx->nb_item) printf("%c", compact->item_sep);
 +    if (!compact->nokey)
 +        printf("%s=", key);
 +    printf("%lld", value);
 +}
 +
 +static void compact_show_tags(WriterContext *wctx, AVDictionary *dict)
 +{
 +    CompactContext *compact = wctx->priv;
 +    AVDictionaryEntry *tag = NULL;
 +    AVBPrint buf;
 +
 +    av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
 +    while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) {
 +        if (wctx->nb_item) printf("%c", compact->item_sep);
 +        if (!compact->nokey) {
 +            av_bprint_clear(&buf);
 +            printf("tag:%s=", compact->escape_str(&buf, tag->key, compact->item_sep, wctx));
 +        }
 +        av_bprint_clear(&buf);
 +        printf("%s", compact->escape_str(&buf, tag->value, compact->item_sep, wctx));
 +    }
 +    av_bprint_finalize(&buf, NULL);
 +}
 +
 +static const Writer compact_writer = {
 +    .name                 = "compact",
 +    .priv_size            = sizeof(CompactContext),
 +    .init                 = compact_init,
 +    .uninit               = compact_uninit,
 +    .print_section_header = compact_print_section_header,
 +    .print_section_footer = compact_print_section_footer,
 +    .print_integer        = compact_print_int,
 +    .print_string         = compact_print_str,
 +    .show_tags            = compact_show_tags,
 +    .flags = WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS,
 +};
 +
 +/* CSV output */
 +
 +static av_cold int csv_init(WriterContext *wctx, const char *args, void *opaque)
 +{
 +    return compact_init(wctx, "item_sep=,:nokey=1:escape=csv", opaque);
 +}
 +
 +static const Writer csv_writer = {
 +    .name                 = "csv",
 +    .priv_size            = sizeof(CompactContext),
 +    .init                 = csv_init,
 +    .uninit               = compact_uninit,
 +    .print_section_header = compact_print_section_header,
 +    .print_section_footer = compact_print_section_footer,
 +    .print_integer        = compact_print_int,
 +    .print_string         = compact_print_str,
 +    .show_tags            = compact_show_tags,
 +    .flags = WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS,
 +};
 +
 +/* Flat output */
 +
 +typedef struct FlatContext {
 +    const AVClass *class;
 +    const char *section, *chapter;
 +    const char *sep_str;
 +    char sep;
 +    int hierarchical;
 +} FlatContext;
 +
 +#undef OFFSET
 +#define OFFSET(x) offsetof(FlatContext, x)
 +
 +static const AVOption flat_options[]= {
 +    {"sep_char", "set separator",    OFFSET(sep_str),    AV_OPT_TYPE_STRING, {.str="."},  CHAR_MIN, CHAR_MAX },
 +    {"s",        "set separator",    OFFSET(sep_str),    AV_OPT_TYPE_STRING, {.str="."},  CHAR_MIN, CHAR_MAX },
 +    {"hierarchical", "specify if the section specification should be hierarchical", OFFSET(hierarchical), AV_OPT_TYPE_INT, {.dbl=1}, 0, 1 },
 +    {"h",           "specify if the section specification should be hierarchical", OFFSET(hierarchical), AV_OPT_TYPE_INT, {.dbl=1}, 0, 1 },
 +    {NULL},
 +};
 +
 +static const char *flat_get_name(void *ctx)
 +{
 +    return "flat";
 +}
 +
 +static const AVClass flat_class = {
 +    "FlatContext",
 +    flat_get_name,
 +    flat_options
 +};
 +
 +static av_cold int flat_init(WriterContext *wctx, const char *args, void *opaque)
 +{
 +    FlatContext *flat = wctx->priv;
 +    int err;
 +
 +    flat->class = &flat_class;
 +    av_opt_set_defaults(flat);
 +
 +    if (args &&
 +        (err = (av_set_options_string(flat, args, "=", ":"))) < 0) {
 +        av_log(wctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
 +        return err;
 +    }
 +    if (strlen(flat->sep_str) != 1) {
 +        av_log(wctx, AV_LOG_ERROR, "Item separator '%s' specified, but must contain a single character\n",
 +               flat->sep_str);
 +        return AVERROR(EINVAL);
 +    }
 +    flat->sep = flat->sep_str[0];
 +    return 0;
 +}
 +
 +static const char *flat_escape_key_str(AVBPrint *dst, const char *src, const char sep)
 +{
 +    const char *p;
 +
 +    for (p = src; *p; p++) {
 +        if (!((*p >= '0' && *p <= '9') ||
 +              (*p >= 'a' && *p <= 'z') ||
 +              (*p >= 'A' && *p <= 'Z')))
 +            av_bprint_chars(dst, '_', 1);
 +        else
 +            av_bprint_chars(dst, *p, 1);
 +    }
 +    return dst->str;
 +}
 +
 +static const char *flat_escape_value_str(AVBPrint *dst, const char *src)
 +{
 +    const char *p;
 +
 +    for (p = src; *p; p++) {
 +        switch (*p) {
 +        case '\n': av_bprintf(dst, "%s", "\\n");  break;
 +        case '\r': av_bprintf(dst, "%s", "\\r");  break;
 +        case '\\': av_bprintf(dst, "%s", "\\\\"); break;
 +        case '"':  av_bprintf(dst, "%s", "\\\""); break;
 +        case '`':  av_bprintf(dst, "%s", "\\`");  break;
 +        case '$':  av_bprintf(dst, "%s", "\\$");  break;
 +        default:   av_bprint_chars(dst, *p, 1);   break;
 +        }
 +    }
 +    return dst->str;
 +}
 +
 +static void flat_print_chapter_header(WriterContext *wctx, const char *chapter)
 +{
 +    FlatContext *flat = wctx->priv;
 +    flat->chapter = chapter;
 +}
 +
 +static void flat_print_section_header(WriterContext *wctx, const char *section)
 +{
 +    FlatContext *flat = wctx->priv;
 +    flat->section = section;
 +}
 +
 +static void flat_print_section(WriterContext *wctx)
 +{
 +    FlatContext *flat = wctx->priv;
 +    int n = wctx->is_packets_and_frames ? wctx->nb_section_packet_frame
 +                                        : wctx->nb_section;
 +
 +    if (flat->hierarchical && wctx->multiple_sections)
 +        printf("%s%c", flat->chapter, flat->sep);
 +    printf("%s%c", flat->section, flat->sep);
 +    if (wctx->multiple_sections)
 +        printf("%d%c", n, flat->sep);
 +}
 +
 +static void flat_print_int(WriterContext *wctx, const char *key, long long int value)
 +{
 +    flat_print_section(wctx);
 +    printf("%s=%lld\n", key, value);
 +}
 +
 +static void flat_print_str(WriterContext *wctx, const char *key, const char *value)
 +{
 +    FlatContext *flat = wctx->priv;
 +    AVBPrint buf;
 +
 +    flat_print_section(wctx);
 +    av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
 +    printf("%s=", flat_escape_key_str(&buf, key, flat->sep));
 +    av_bprint_clear(&buf);
 +    printf("\"%s\"\n", flat_escape_value_str(&buf, value));
 +    av_bprint_finalize(&buf, NULL);
 +}
 +
 +static void flat_show_tags(WriterContext *wctx, AVDictionary *dict)
 +{
 +    FlatContext *flat = wctx->priv;
 +    AVBPrint buf;
 +    AVDictionaryEntry *tag = NULL;
 +
 +    av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
 +    while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) {
 +        flat_print_section(wctx);
 +        av_bprint_clear(&buf);
 +        printf("tags%c%s=", flat->sep, flat_escape_key_str(&buf, tag->key, flat->sep));
 +        av_bprint_clear(&buf);
 +        printf("\"%s\"\n", flat_escape_value_str(&buf, tag->value));
 +    }
 +    av_bprint_finalize(&buf, NULL);
 +}
 +
 +static const Writer flat_writer = {
 +    .name                  = "flat",
 +    .priv_size             = sizeof(FlatContext),
 +    .init                  = flat_init,
 +    .print_chapter_header  = flat_print_chapter_header,
 +    .print_section_header  = flat_print_section_header,
 +    .print_integer         = flat_print_int,
 +    .print_string          = flat_print_str,
 +    .show_tags             = flat_show_tags,
 +    .flags = WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS|WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER,
 +};
 +
 +/* INI format output */
 +
 +typedef struct {
 +    const AVClass *class;
 +    AVBPrint chapter_name, section_name;
 +    int hierarchical;
 +} INIContext;
 +
 +#undef OFFSET
 +#define OFFSET(x) offsetof(INIContext, x)
 +
 +static const AVOption ini_options[] = {
 +    {"hierarchical", "specify if the section specification should be hierarchical", OFFSET(hierarchical), AV_OPT_TYPE_INT, {.dbl=1}, 0, 1 },
 +    {"h",           "specify if the section specification should be hierarchical", OFFSET(hierarchical), AV_OPT_TYPE_INT, {.dbl=1}, 0, 1 },
 +    {NULL},
 +};
 +
 +static const char *ini_get_name(void *ctx)
 +{
 +    return "ini";
 +}
 +
 +static const AVClass ini_class = {
 +    "INIContext",
 +    ini_get_name,
 +    ini_options
 +};
 +
 +static av_cold int ini_init(WriterContext *wctx, const char *args, void *opaque)
 +{
 +    INIContext *ini = wctx->priv;
 +    int err;
 +
 +    av_bprint_init(&ini->chapter_name, 1, AV_BPRINT_SIZE_UNLIMITED);
 +    av_bprint_init(&ini->section_name, 1, AV_BPRINT_SIZE_UNLIMITED);
 +
 +    ini->class = &ini_class;
 +    av_opt_set_defaults(ini);
 +
 +    if (args && (err = av_set_options_string(ini, args, "=", ":")) < 0) {
 +        av_log(wctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
 +        return err;
 +    }
 +
 +    return 0;
 +}
 +
 +static av_cold void ini_uninit(WriterContext *wctx)
 +{
 +    INIContext *ini = wctx->priv;
 +    av_bprint_finalize(&ini->chapter_name, NULL);
 +    av_bprint_finalize(&ini->section_name, NULL);
 +}
 +
 +static void ini_print_header(WriterContext *wctx)
 +{
 +    printf("# ffprobe output\n\n");
 +}
 +
 +static char *ini_escape_str(AVBPrint *dst, const char *src)
 +{
 +    int i = 0;
 +    char c = 0;
 +
 +    while (c = src[i++]) {
 +        switch (c) {
 +        case '\b': av_bprintf(dst, "%s", "\\b"); break;
 +        case '\f': av_bprintf(dst, "%s", "\\f"); break;
 +        case '\n': av_bprintf(dst, "%s", "\\n"); break;
 +        case '\r': av_bprintf(dst, "%s", "\\r"); break;
 +        case '\t': av_bprintf(dst, "%s", "\\t"); break;
 +        case '\\':
 +        case '#' :
 +        case '=' :
 +        case ':' : av_bprint_chars(dst, '\\', 1);
 +        default:
 +            if ((unsigned char)c < 32)
 +                av_bprintf(dst, "\\x00%02x", c & 0xff);
 +            else
 +                av_bprint_chars(dst, c, 1);
 +            break;
 +        }
 +    }
 +    return dst->str;
 +}
 +
 +static void ini_print_chapter_header(WriterContext *wctx, const char *chapter)
 +{
 +    INIContext *ini = wctx->priv;
 +
 +    av_bprint_clear(&ini->chapter_name);
 +    av_bprintf(&ini->chapter_name, "%s", chapter);
 +
 +    if (wctx->nb_chapter)
 +        printf("\n");
 +}
 +
 +static void ini_print_section_header(WriterContext *wctx, const char *section)
 +{
 +    INIContext *ini = wctx->priv;
 +    int n = wctx->is_packets_and_frames ? wctx->nb_section_packet_frame
 +                                        : wctx->nb_section;
 +    if (wctx->nb_section)
 +        printf("\n");
 +    av_bprint_clear(&ini->section_name);
 +
 +    if (ini->hierarchical && wctx->multiple_sections)
 +        av_bprintf(&ini->section_name, "%s.", ini->chapter_name.str);
 +    av_bprintf(&ini->section_name, "%s", section);
 +
 +    if (wctx->multiple_sections)
 +        av_bprintf(&ini->section_name, ".%d", n);
 +    printf("[%s]\n", ini->section_name.str);
 +}
 +
 +static void ini_print_str(WriterContext *wctx, const char *key, const char *value)
 +{
 +    AVBPrint buf;
 +
 +    av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
 +    printf("%s=", ini_escape_str(&buf, key));
 +    av_bprint_clear(&buf);
 +    printf("%s\n", ini_escape_str(&buf, value));
 +    av_bprint_finalize(&buf, NULL);
 +}
 +
 +static void ini_print_int(WriterContext *wctx, const char *key, long long int value)
 +{
 +    printf("%s=%lld\n", key, value);
 +}
 +
 +static void ini_show_tags(WriterContext *wctx, AVDictionary *dict)
 +{
 +    INIContext *ini = wctx->priv;
 +    AVDictionaryEntry *tag = NULL;
 +    int is_first = 1;
 +
 +    while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) {
 +        if (is_first) {
 +            printf("\n[%s.tags]\n", ini->section_name.str);
 +            is_first = 0;
 +        }
 +        writer_print_string(wctx, tag->key, tag->value, 0);
 +    }
 +}
 +
 +static const Writer ini_writer = {
 +    .name                  = "ini",
 +    .priv_size             = sizeof(INIContext),
 +    .init                  = ini_init,
 +    .uninit                = ini_uninit,
 +    .print_header          = ini_print_header,
 +    .print_chapter_header  = ini_print_chapter_header,
 +    .print_section_header  = ini_print_section_header,
 +    .print_integer         = ini_print_int,
 +    .print_string          = ini_print_str,
 +    .show_tags             = ini_show_tags,
 +    .flags = WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS|WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER,
 +};
 +
 +/* JSON output */
 +
 +typedef struct {
 +    const AVClass *class;
 +    int indent_level;
 +    int compact;
 +    const char *item_sep, *item_start_end;
 +} JSONContext;
 +
 +#undef OFFSET
 +#define OFFSET(x) offsetof(JSONContext, x)
 +
 +static const AVOption json_options[]= {
 +    { "compact", "enable compact output", OFFSET(compact), AV_OPT_TYPE_INT, {.dbl=0}, 0, 1 },
 +    { "c",       "enable compact output", OFFSET(compact), AV_OPT_TYPE_INT, {.dbl=0}, 0, 1 },
 +    { NULL }
 +};
 +
 +static const char *json_get_name(void *ctx)
 +{
 +    return "json";
 +}
 +
 +static const AVClass json_class = {
 +    "JSONContext",
 +    json_get_name,
 +    json_options
 +};
 +
 +static av_cold int json_init(WriterContext *wctx, const char *args, void *opaque)
 +{
 +    JSONContext *json = wctx->priv;
 +    int err;
 +
 +    json->class = &json_class;
 +    av_opt_set_defaults(json);
 +
 +    if (args &&
 +        (err = (av_set_options_string(json, args, "=", ":"))) < 0) {
 +        av_log(wctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
 +        return err;
 +    }
 +
 +    json->item_sep       = json->compact ? ", " : ",\n";
 +    json->item_start_end = json->compact ? " "  : "\n";
 +
 +    return 0;
 +}
 +
 +static const char *json_escape_str(AVBPrint *dst, const char *src, void *log_ctx)
 +{
 +    static const char json_escape[] = {'"', '\\', '\b', '\f', '\n', '\r', '\t', 0};
 +    static const char json_subst[]  = {'"', '\\',  'b',  'f',  'n',  'r',  't', 0};
 +    const char *p;
 +
 +    for (p = src; *p; p++) {
 +        char *s = strchr(json_escape, *p);
 +        if (s) {
 +            av_bprint_chars(dst, '\\', 1);
 +            av_bprint_chars(dst, json_subst[s - json_escape], 1);
 +        } else if ((unsigned char)*p < 32) {
 +            av_bprintf(dst, "\\u00%02x", *p & 0xff);
 +        } else {
 +            av_bprint_chars(dst, *p, 1);
 +        }
 +    }
 +    return dst->str;
 +}
 +
 +static void json_print_header(WriterContext *wctx)
 +{
 +    JSONContext *json = wctx->priv;
 +    printf("{");
 +    json->indent_level++;
 +}
 +
 +static void json_print_footer(WriterContext *wctx)
 +{
 +    JSONContext *json = wctx->priv;
 +    json->indent_level--;
 +    printf("\n}\n");
 +}
 +
 +#define JSON_INDENT() printf("%*c", json->indent_level * 4, ' ')
 +
 +static void json_print_chapter_header(WriterContext *wctx, const char *chapter)
 +{
 +    JSONContext *json = wctx->priv;
 +    AVBPrint buf;
 +
 +    if (wctx->nb_chapter)
 +        printf(",");
 +    printf("\n");
 +    if (wctx->multiple_sections) {
 +        JSON_INDENT();
 +        av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
 +        printf("\"%s\": [\n", json_escape_str(&buf, chapter, wctx));
 +        av_bprint_finalize(&buf, NULL);
 +        json->indent_level++;
 +    }
 +}
 +
 +static void json_print_chapter_footer(WriterContext *wctx, const char *chapter)
 +{
 +    JSONContext *json = wctx->priv;
 +
 +    if (wctx->multiple_sections) {
 +        printf("\n");
 +        json->indent_level--;
 +        JSON_INDENT();
 +        printf("]");
 +    }
 +}
 +
 +static void json_print_section_header(WriterContext *wctx, const char *section)
 +{
 +    JSONContext *json = wctx->priv;
 +
 +    if (wctx->nb_section)
 +        printf(",\n");
 +    JSON_INDENT();
 +    if (!wctx->multiple_sections)
 +        printf("\"%s\": ", section);
 +    printf("{%s", json->item_start_end);
 +    json->indent_level++;
 +    /* this is required so the parser can distinguish between packets and frames */
 +    if (wctx->is_packets_and_frames) {
 +        if (!json->compact)
 +            JSON_INDENT();
 +        printf("\"type\": \"%s\"%s", section, json->item_sep);
 +    }
 +}
 +
 +static void json_print_section_footer(WriterContext *wctx, const char *section)
 +{
 +    JSONContext *json = wctx->priv;
 +
 +    printf("%s", json->item_start_end);
 +    json->indent_level--;
 +    if (!json->compact)
 +        JSON_INDENT();
 +    printf("}");
 +}
 +
 +static inline void json_print_item_str(WriterContext *wctx,
 +                                       const char *key, const char *value)
 +{
 +    AVBPrint buf;
 +
 +    av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
 +    printf("\"%s\":", json_escape_str(&buf, key,   wctx));
 +    av_bprint_clear(&buf);
 +    printf(" \"%s\"", json_escape_str(&buf, value, wctx));
 +    av_bprint_finalize(&buf, NULL);
 +}
 +
 +static void json_print_str(WriterContext *wctx, const char *key, const char *value)
 +{
 +    JSONContext *json = wctx->priv;
 +
 +    if (wctx->nb_item) printf("%s", json->item_sep);
 +    if (!json->compact)
 +        JSON_INDENT();
 +    json_print_item_str(wctx, key, value);
 +}
 +
 +static void json_print_int(WriterContext *wctx, const char *key, long long int value)
 +{
 +    JSONContext *json = wctx->priv;
 +    AVBPrint buf;
 +
 +    if (wctx->nb_item) printf("%s", json->item_sep);
 +    if (!json->compact)
 +        JSON_INDENT();
 +
 +    av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
 +    printf("\"%s\": %lld", json_escape_str(&buf, key, wctx), value);
 +    av_bprint_finalize(&buf, NULL);
 +}
 +
 +static void json_show_tags(WriterContext *wctx, AVDictionary *dict)
 +{
 +    JSONContext *json = wctx->priv;
 +    AVDictionaryEntry *tag = NULL;
 +    int is_first = 1;
 +    if (!dict)
 +        return;
 +    printf("%s", json->item_sep);
 +    if (!json->compact)
 +        JSON_INDENT();
 +    printf("\"tags\": {%s", json->item_start_end);
 +    json->indent_level++;
 +    while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) {
 +        if (is_first) is_first = 0;
 +        else          printf("%s", json->item_sep);
 +        if (!json->compact)
 +            JSON_INDENT();
 +        json_print_item_str(wctx, tag->key, tag->value);
 +    }
 +    json->indent_level--;
 +    printf("%s", json->item_start_end);
 +    if (!json->compact)
 +        JSON_INDENT();
 +    printf("}");
 +}
 +
 +static const Writer json_writer = {
 +    .name                 = "json",
 +    .priv_size            = sizeof(JSONContext),
 +    .init                 = json_init,
 +    .print_header         = json_print_header,
 +    .print_footer         = json_print_footer,
 +    .print_chapter_header = json_print_chapter_header,
 +    .print_chapter_footer = json_print_chapter_footer,
 +    .print_section_header = json_print_section_header,
 +    .print_section_footer = json_print_section_footer,
 +    .print_integer        = json_print_int,
 +    .print_string         = json_print_str,
 +    .show_tags            = json_show_tags,
 +    .flags = WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER,
 +};
 +
 +/* XML output */
 +
 +typedef struct {
 +    const AVClass *class;
 +    int within_tag;
 +    int indent_level;
 +    int fully_qualified;
 +    int xsd_strict;
 +} XMLContext;
 +
 +#undef OFFSET
 +#define OFFSET(x) offsetof(XMLContext, x)
 +
 +static const AVOption xml_options[] = {
 +    {"fully_qualified", "specify if the output should be fully qualified", OFFSET(fully_qualified), AV_OPT_TYPE_INT, {.dbl=0},  0, 1 },
 +    {"q",               "specify if the output should be fully qualified", OFFSET(fully_qualified), AV_OPT_TYPE_INT, {.dbl=0},  0, 1 },
 +    {"xsd_strict",      "ensure that the output is XSD compliant",         OFFSET(xsd_strict),      AV_OPT_TYPE_INT, {.dbl=0},  0, 1 },
 +    {"x",               "ensure that the output is XSD compliant",         OFFSET(xsd_strict),      AV_OPT_TYPE_INT, {.dbl=0},  0, 1 },
 +    {NULL},
 +};
 +
 +static const char *xml_get_name(void *ctx)
 +{
 +    return "xml";
 +}
 +
 +static const AVClass xml_class = {
 +    "XMLContext",
 +    xml_get_name,
 +    xml_options
 +};
 +
 +static av_cold int xml_init(WriterContext *wctx, const char *args, void *opaque)
 +{
 +    XMLContext *xml = wctx->priv;
 +    int err;
 +
 +    xml->class = &xml_class;
 +    av_opt_set_defaults(xml);
 +
 +    if (args &&
 +        (err = (av_set_options_string(xml, args, "=", ":"))) < 0) {
 +        av_log(wctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
 +        return err;
 +    }
 +
 +    if (xml->xsd_strict) {
 +        xml->fully_qualified = 1;
 +#define CHECK_COMPLIANCE(opt, opt_name)                                 \
 +        if (opt) {                                                      \
 +            av_log(wctx, AV_LOG_ERROR,                                  \
 +                   "XSD-compliant output selected but option '%s' was selected, XML output may be non-compliant.\n" \
 +                   "You need to disable such option with '-no%s'\n", opt_name, opt_name); \
 +            return AVERROR(EINVAL);                                     \
 +        }
 +        CHECK_COMPLIANCE(show_private_data, "private");
 +        CHECK_COMPLIANCE(show_value_unit,   "unit");
 +        CHECK_COMPLIANCE(use_value_prefix,  "prefix");
 +
 +        if (do_show_frames && do_show_packets) {
 +            av_log(wctx, AV_LOG_ERROR,
 +                   "Interleaved frames and packets are not allowed in XSD. "
 +                   "Select only one between the -show_frames and the -show_packets options.\n");
 +            return AVERROR(EINVAL);
 +        }
 +    }
 +
 +    return 0;
 +}
 +
 +static const char *xml_escape_str(AVBPrint *dst, const char *src, void *log_ctx)
 +{
 +    const char *p;
 +
 +    for (p = src; *p; p++) {
 +        switch (*p) {
 +        case '&' : av_bprintf(dst, "%s", "&amp;");  break;
 +        case '<' : av_bprintf(dst, "%s", "&lt;");   break;
 +        case '>' : av_bprintf(dst, "%s", "&gt;");   break;
 +        case '\"': av_bprintf(dst, "%s", "&quot;"); break;
 +        case '\'': av_bprintf(dst, "%s", "&apos;"); break;
 +        default: av_bprint_chars(dst, *p, 1);
 +        }
 +    }
 +
 +    return dst->str;
 +}
 +
 +static void xml_print_header(WriterContext *wctx)
 +{
 +    XMLContext *xml = wctx->priv;
 +    const char *qual = " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' "
 +        "xmlns:ffprobe='http://www.ffmpeg.org/schema/ffprobe' "
 +        "xsi:schemaLocation='http://www.ffmpeg.org/schema/ffprobe ffprobe.xsd'";
 +
 +    printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
 +    printf("<%sffprobe%s>\n",
 +           xml->fully_qualified ? "ffprobe:" : "",
 +           xml->fully_qualified ? qual : "");
 +
 +    xml->indent_level++;
 +}
 +
 +static void xml_print_footer(WriterContext *wctx)
 +{
 +    XMLContext *xml = wctx->priv;
 +
 +    xml->indent_level--;
 +    printf("</%sffprobe>\n", xml->fully_qualified ? "ffprobe:" : "");
 +}
 +
 +#define XML_INDENT() printf("%*c", xml->indent_level * 4, ' ')
 +
 +static void xml_print_chapter_header(WriterContext *wctx, const char *chapter)
 +{
 +    XMLContext *xml = wctx->priv;
 +
 +    if (wctx->nb_chapter)
 +        printf("\n");
 +    if (wctx->multiple_sections) {
 +        XML_INDENT(); printf("<%s>\n", chapter);
 +        xml->indent_level++;
 +    }
 +}
 +
 +static void xml_print_chapter_footer(WriterContext *wctx, const char *chapter)
 +{
 +    XMLContext *xml = wctx->priv;
 +
 +    if (wctx->multiple_sections) {
 +        xml->indent_level--;
 +        XML_INDENT(); printf("</%s>\n", chapter);
 +    }
 +}
 +
 +static void xml_print_section_header(WriterContext *wctx, const char *section)
 +{
 +    XMLContext *xml = wctx->priv;
 +
 +    XML_INDENT(); printf("<%s ", section);
 +    xml->within_tag = 1;
 +}
 +
 +static void xml_print_section_footer(WriterContext *wctx, const char *section)
 +{
 +    XMLContext *xml = wctx->priv;
 +
 +    if (xml->within_tag)
 +        printf("/>\n");
 +    else {
 +        XML_INDENT(); printf("</%s>\n", section);
 +    }
 +}
 +
 +static void xml_print_str(WriterContext *wctx, const char *key, const char *value)
 +{
 +    AVBPrint buf;
 +
 +    if (wctx->nb_item)
 +        printf(" ");
 +    av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
 +    printf("%s=\"%s\"", key, xml_escape_str(&buf, value, wctx));
 +    av_bprint_finalize(&buf, NULL);
 +}
 +
 +static void xml_print_int(WriterContext *wctx, const char *key, long long int value)
 +{
 +    if (wctx->nb_item)
 +        printf(" ");
 +    printf("%s=\"%lld\"", key, value);
 +}
 +
 +static void xml_show_tags(WriterContext *wctx, AVDictionary *dict)
 +{
 +    XMLContext *xml = wctx->priv;
 +    AVDictionaryEntry *tag = NULL;
 +    int is_first = 1;
 +    AVBPrint buf;
 +
 +    av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED);
 +    xml->indent_level++;
 +    while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) {
 +        if (is_first) {
 +            /* close section tag */
 +            printf(">\n");
 +            xml->within_tag = 0;
 +            is_first = 0;
 +        }
 +        XML_INDENT();
 +
 +        av_bprint_clear(&buf);
 +        printf("<tag key=\"%s\"", xml_escape_str(&buf, tag->key, wctx));
 +        av_bprint_clear(&buf);
 +        printf(" value=\"%s\"/>\n", xml_escape_str(&buf, tag->value, wctx));
 +    }
 +    av_bprint_finalize(&buf, NULL);
 +    xml->indent_level--;
 +}
 +
 +static Writer xml_writer = {
 +    .name                 = "xml",
 +    .priv_size            = sizeof(XMLContext),
 +    .init                 = xml_init,
 +    .print_header         = xml_print_header,
 +    .print_footer         = xml_print_footer,
 +    .print_chapter_header = xml_print_chapter_header,
 +    .print_chapter_footer = xml_print_chapter_footer,
 +    .print_section_header = xml_print_section_header,
 +    .print_section_footer = xml_print_section_footer,
 +    .print_integer        = xml_print_int,
 +    .print_string         = xml_print_str,
 +    .show_tags            = xml_show_tags,
 +    .flags = WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER,
 +};
 +
 +static void writer_register_all(void)
 +{
 +    static int initialized;
 +
 +    if (initialized)
 +        return;
 +    initialized = 1;
 +
 +    writer_register(&default_writer);
 +    writer_register(&compact_writer);
 +    writer_register(&csv_writer);
 +    writer_register(&flat_writer);
 +    writer_register(&ini_writer);
 +    writer_register(&json_writer);
 +    writer_register(&xml_writer);
 +}
 +
 +#define print_fmt(k, f, ...) do {              \
 +    av_bprint_clear(&pbuf);                    \
 +    av_bprintf(&pbuf, f, __VA_ARGS__);         \
 +    writer_print_string(w, k, pbuf.str, 0);    \
 +} while (0)
 +
 +#define print_int(k, v)         writer_print_integer(w, k, v)
 +#define print_q(k, v, s)        writer_print_rational(w, k, v, s)
 +#define print_str(k, v)         writer_print_string(w, k, v, 0)
 +#define print_str_opt(k, v)     writer_print_string(w, k, v, 1)
 +#define print_time(k, v, tb)    writer_print_time(w, k, v, tb, 0)
 +#define print_ts(k, v)          writer_print_ts(w, k, v, 0)
 +#define print_duration_time(k, v, tb) writer_print_time(w, k, v, tb, 1)
 +#define print_duration_ts(k, v)       writer_print_ts(w, k, v, 1)
 +#define print_val(k, v, u)      writer_print_string(w, k, \
 +    value_string(val_str, sizeof(val_str), (struct unit_value){.val.i = v, .unit=u}), 0)
 +#define print_section_header(s) writer_print_section_header(w, s)
 +#define print_section_footer(s) writer_print_section_footer(w, s)
 +#define show_tags(metadata)     writer_show_tags(w, metadata)
 +
 +static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pkt, int packet_idx)
 +{
 +    char val_str[128];
 +    AVStream *st = fmt_ctx->streams[pkt->stream_index];
 +    AVBPrint pbuf;
 +    const char *s;
 +
 +    av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
 +
 +    print_section_header("packet");
 +    s = av_get_media_type_string(st->codec->codec_type);
 +    if (s) print_str    ("codec_type", s);
 +    else   print_str_opt("codec_type", "unknown");
 +    print_int("stream_index",     pkt->stream_index);
 +    print_ts  ("pts",             pkt->pts);
 +    print_time("pts_time",        pkt->pts, &st->time_base);
 +    print_ts  ("dts",             pkt->dts);
 +    print_time("dts_time",        pkt->dts, &st->time_base);
 +    print_duration_ts("duration",        pkt->duration);
 +    print_duration_time("duration_time", pkt->duration, &st->time_base);
 +    print_duration_ts("convergence_duration", pkt->convergence_duration);
 +    print_duration_time("convergence_duration_time", pkt->convergence_duration, &st->time_base);
 +    print_val("size",             pkt->size, unit_byte_str);
 +    if (pkt->pos != -1) print_fmt    ("pos", "%"PRId64, pkt->pos);
 +    else                print_str_opt("pos", "N/A");
 +    print_fmt("flags", "%c",      pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_');
 +    if (do_show_data)
 +        writer_print_data(w, "data", pkt->data, pkt->size);
 +    print_section_footer("packet");
 +
 +    av_bprint_finalize(&pbuf, NULL);
 +    fflush(stdout);
 +}
 +
 +static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,
 +                       AVFormatContext *fmt_ctx)
 +{
 +    AVBPrint pbuf;
 +    const char *s;
 +
 +    av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
 +
 +    print_section_header("frame");
 +
 +    s = av_get_media_type_string(stream->codec->codec_type);
 +    if (s) print_str    ("media_type", s);
 +    else   print_str_opt("media_type", "unknown");
 +    print_int("key_frame",              frame->key_frame);
 +    print_ts  ("pkt_pts",               frame->pkt_pts);
 +    print_time("pkt_pts_time",          frame->pkt_pts, &stream->time_base);
 +    print_ts  ("pkt_dts",               frame->pkt_dts);
 +    print_time("pkt_dts_time",          frame->pkt_dts, &stream->time_base);
 +    print_duration_ts  ("pkt_duration",      frame->pkt_duration);
 +    print_duration_time("pkt_duration_time", frame->pkt_duration, &stream->time_base);
 +    if (frame->pkt_pos != -1) print_fmt    ("pkt_pos", "%"PRId64, frame->pkt_pos);
 +    else                      print_str_opt("pkt_pos", "N/A");
 +
 +    switch (stream->codec->codec_type) {
 +        AVRational sar;
 +
 +    case AVMEDIA_TYPE_VIDEO:
 +        print_int("width",                  frame->width);
 +        print_int("height",                 frame->height);
 +        s = av_get_pix_fmt_name(frame->format);
 +        if (s) print_str    ("pix_fmt", s);
 +        else   print_str_opt("pix_fmt", "unknown");
 +        sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, frame);
 +        if (sar.num) {
 +            print_q("sample_aspect_ratio", sar, ':');
 +        } else {
 +            print_str_opt("sample_aspect_ratio", "N/A");
 +        }
 +        print_fmt("pict_type",              "%c", av_get_picture_type_char(frame->pict_type));
 +        print_int("coded_picture_number",   frame->coded_picture_number);
 +        print_int("display_picture_number", frame->display_picture_number);
 +        print_int("interlaced_frame",       frame->interlaced_frame);
 +        print_int("top_field_first",        frame->top_field_first);
 +        print_int("repeat_pict",            frame->repeat_pict);
 +        print_int("reference",              frame->reference);
 +        break;
 +
 +    case AVMEDIA_TYPE_AUDIO:
 +        s = av_get_sample_fmt_name(frame->format);
 +        if (s) print_str    ("sample_fmt", s);
 +        else   print_str_opt("sample_fmt", "unknown");
 +        print_int("nb_samples",         frame->nb_samples);
 +        print_int("channels", av_frame_get_channels(frame));
 +        if (av_frame_get_channel_layout(frame)) {
 +            av_bprint_clear(&pbuf);
 +            av_bprint_channel_layout(&pbuf, av_frame_get_channels(frame),
 +                                     av_frame_get_channel_layout(frame));
 +            print_str    ("channel_layout", pbuf.str);
 +        } else
 +            print_str_opt("channel_layout", "unknown");
 +        break;
 +    }
 +    show_tags(av_frame_get_metadata(frame));
 +
 +    print_section_footer("frame");
 +
 +    av_bprint_finalize(&pbuf, NULL);
 +    fflush(stdout);
 +}
 +
 +static av_always_inline int process_frame(WriterContext *w,
 +                                          AVFormatContext *fmt_ctx,
 +                                          AVFrame *frame, AVPacket *pkt)
 +{
 +    AVCodecContext *dec_ctx = fmt_ctx->streams[pkt->stream_index]->codec;
 +    int ret = 0, got_frame = 0;
 +
 +    avcodec_get_frame_defaults(frame);
 +    if (dec_ctx->codec) {
 +        switch (dec_ctx->codec_type) {
 +        case AVMEDIA_TYPE_VIDEO:
 +            ret = avcodec_decode_video2(dec_ctx, frame, &got_frame, pkt);
 +            break;
 +
 +        case AVMEDIA_TYPE_AUDIO:
 +            ret = avcodec_decode_audio4(dec_ctx, frame, &got_frame, pkt);
 +            break;
 +        }
 +    }
 +
 +    if (ret < 0)
 +        return ret;
 +    ret = FFMIN(ret, pkt->size); /* guard against bogus return values */
 +    pkt->data += ret;
 +    pkt->size -= ret;
 +    if (got_frame) {
 +        nb_streams_frames[pkt->stream_index]++;
 +        if (do_show_frames)
 +            show_frame(w, frame, fmt_ctx->streams[pkt->stream_index], fmt_ctx);
 +    }
 +    return got_frame;
 +}
 +
 +static void read_packets(WriterContext *w, AVFormatContext *fmt_ctx)
 +{
 +    AVPacket pkt, pkt1;
 +    AVFrame frame;
 +    int i = 0;
 +
 +    av_init_packet(&pkt);
 +
 +    while (!av_read_frame(fmt_ctx, &pkt)) {
 +        if (do_read_packets) {
 +            if (do_show_packets)
 +                show_packet(w, fmt_ctx, &pkt, i++);
 +            nb_streams_packets[pkt.stream_index]++;
 +        }
 +        if (do_read_frames) {
 +            pkt1 = pkt;
 +            while (pkt1.size && process_frame(w, fmt_ctx, &frame, &pkt1) > 0);
 +        }
 +        av_free_packet(&pkt);
 +    }
 +    av_init_packet(&pkt);
 +    pkt.data = NULL;
 +    pkt.size = 0;
 +    //Flush remaining frames that are cached in the decoder
 +    for (i = 0; i < fmt_ctx->nb_streams; i++) {
 +        pkt.stream_index = i;
 +        if (do_read_frames)
 +            while (process_frame(w, fmt_ctx, &frame, &pkt) > 0);
 +    }
 +}
 +
 +static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx)
 +{
 +    AVStream *stream = fmt_ctx->streams[stream_idx];
 +    AVCodecContext *dec_ctx;
 +    AVCodec *dec;
 +    char val_str[128];
 +    const char *s;
 +    AVRational sar, dar;
 +    AVBPrint pbuf;
 +
 +    av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
 +
 +    print_section_header("stream");
 +
 +    print_int("index", stream->index);
 +
 +    if ((dec_ctx = stream->codec)) {
 +        const char *profile = NULL;
 +        if ((dec = dec_ctx->codec)) {
 +            print_str("codec_name",      dec->name);
 +            print_str("codec_long_name", dec->long_name);
 +        } else {
 +            print_str_opt("codec_name",      "unknown");
 +            print_str_opt("codec_long_name", "unknown");
 +        }
 +
 +        if (dec && (profile = av_get_profile_name(dec, dec_ctx->profile)))
 +            print_str("profile", profile);
 +        else
 +            print_str_opt("profile", "unknown");
 +
 +        s = av_get_media_type_string(dec_ctx->codec_type);
 +        if (s) print_str    ("codec_type", s);
 +        else   print_str_opt("codec_type", "unknown");
 +        print_q("codec_time_base", dec_ctx->time_base, '/');
 +
 +        /* print AVI/FourCC tag */
 +        av_get_codec_tag_string(val_str, sizeof(val_str), dec_ctx->codec_tag);
 +        print_str("codec_tag_string",    val_str);
 +        print_fmt("codec_tag", "0x%04x", dec_ctx->codec_tag);
 +
 +        switch (dec_ctx->codec_type) {
 +        case AVMEDIA_TYPE_VIDEO:
 +            print_int("width",        dec_ctx->width);
 +            print_int("height",       dec_ctx->height);
 +            print_int("has_b_frames", dec_ctx->has_b_frames);
 +            sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL);
 +            if (sar.den) {
 +                print_q("sample_aspect_ratio", sar, ':');
 +                av_reduce(&dar.num, &dar.den,
 +                          dec_ctx->width  * sar.num,
 +                          dec_ctx->height * sar.den,
 +                          1024*1024);
 +                print_q("display_aspect_ratio", dar, ':');
 +            } else {
 +                print_str_opt("sample_aspect_ratio", "N/A");
 +                print_str_opt("display_aspect_ratio", "N/A");
 +            }
 +            s = av_get_pix_fmt_name(dec_ctx->pix_fmt);
 +            if (s) print_str    ("pix_fmt", s);
 +            else   print_str_opt("pix_fmt", "unknown");
 +            print_int("level",   dec_ctx->level);
 +            if (dec_ctx->timecode_frame_start >= 0) {
 +                char tcbuf[AV_TIMECODE_STR_SIZE];
 +                av_timecode_make_mpeg_tc_string(tcbuf, dec_ctx->timecode_frame_start);
 +                print_str("timecode", tcbuf);
 +            } else {
 +                print_str_opt("timecode", "N/A");
 +            }
 +            break;
 +
 +        case AVMEDIA_TYPE_AUDIO:
 +            s = av_get_sample_fmt_name(dec_ctx->sample_fmt);
 +            if (s) print_str    ("sample_fmt", s);
 +            else   print_str_opt("sample_fmt", "unknown");
 +            print_val("sample_rate",     dec_ctx->sample_rate, unit_hertz_str);
 +            print_int("channels",        dec_ctx->channels);
 +            print_int("bits_per_sample", av_get_bits_per_sample(dec_ctx->codec_id));
 +            break;
 +        }
 +    } else {
 +        print_str_opt("codec_type", "unknown");
 +    }
 +    if (dec_ctx->codec && dec_ctx->codec->priv_class && show_private_data) {
 +        const AVOption *opt = NULL;
 +        while (opt = av_opt_next(dec_ctx->priv_data,opt)) {
 +            uint8_t *str;
 +            if (opt->flags) continue;
 +            if (av_opt_get(dec_ctx->priv_data, opt->name, 0, &str) >= 0) {
 +                print_str(opt->name, str);
 +                av_free(str);
 +            }
 +        }
 +    }
 +
 +    if (fmt_ctx->iformat->flags & AVFMT_SHOW_IDS) print_fmt    ("id", "0x%x", stream->id);
 +    else                                          print_str_opt("id", "N/A");
 +    print_q("r_frame_rate",   stream->r_frame_rate,   '/');
 +    print_q("avg_frame_rate", stream->avg_frame_rate, '/');
 +    print_q("time_base",      stream->time_base,      '/');
 +    print_time("start_time",    stream->start_time, &stream->time_base);
 +    print_time("duration",      stream->duration,   &stream->time_base);
 +    if (dec_ctx->bit_rate > 0) print_val    ("bit_rate", dec_ctx->bit_rate, unit_bit_per_second_str);
 +    else                       print_str_opt("bit_rate", "N/A");
 +    if (stream->nb_frames) print_fmt    ("nb_frames", "%"PRId64, stream->nb_frames);
 +    else                   print_str_opt("nb_frames", "N/A");
 +    if (nb_streams_frames[stream_idx])  print_fmt    ("nb_read_frames", "%"PRIu64, nb_streams_frames[stream_idx]);
 +    else                                print_str_opt("nb_read_frames", "N/A");
 +    if (nb_streams_packets[stream_idx]) print_fmt    ("nb_read_packets", "%"PRIu64, nb_streams_packets[stream_idx]);
 +    else                                print_str_opt("nb_read_packets", "N/A");
 +    if (do_show_data)
 +        writer_print_data(w, "extradata", dec_ctx->extradata,
 +                                          dec_ctx->extradata_size);
 +    show_tags(stream->metadata);
 +
 +    print_section_footer("stream");
 +    av_bprint_finalize(&pbuf, NULL);
 +    fflush(stdout);
 +}
 +
 +static void show_streams(WriterContext *w, AVFormatContext *fmt_ctx)
 +{
 +    int i;
 +    for (i = 0; i < fmt_ctx->nb_streams; i++)
 +        show_stream(w, fmt_ctx, i);
 +}
 +
 +static void show_format(WriterContext *w, AVFormatContext *fmt_ctx)
 +{
 +    char val_str[128];
 +    int64_t size = fmt_ctx->pb ? avio_size(fmt_ctx->pb) : -1;
 +
 +    print_section_header("format");
 +    print_str("filename",         fmt_ctx->filename);
 +    print_int("nb_streams",       fmt_ctx->nb_streams);
 +    print_str("format_name",      fmt_ctx->iformat->name);
 +    print_str("format_long_name", fmt_ctx->iformat->long_name);
 +    print_time("start_time",      fmt_ctx->start_time, &AV_TIME_BASE_Q);
 +    print_time("duration",        fmt_ctx->duration,   &AV_TIME_BASE_Q);
 +    if (size >= 0) print_val    ("size", size, unit_byte_str);
 +    else           print_str_opt("size", "N/A");
 +    if (fmt_ctx->bit_rate > 0) print_val    ("bit_rate", fmt_ctx->bit_rate, unit_bit_per_second_str);
 +    else                       print_str_opt("bit_rate", "N/A");
 +    show_tags(fmt_ctx->metadata);
 +    print_section_footer("format");
 +    fflush(stdout);
 +}
 +
 +static void show_error(WriterContext *w, int err)
 +{
 +    char errbuf[128];
 +    const char *errbuf_ptr = errbuf;
 +
 +    if (av_strerror(err, errbuf, sizeof(errbuf)) < 0)
 +        errbuf_ptr = strerror(AVUNERROR(err));
 +
 +    writer_print_chapter_header(w, "error");
 +    print_section_header("error");
 +    print_int("code", err);
 +    print_str("string", errbuf_ptr);
 +    print_section_footer("error");
 +    writer_print_chapter_footer(w, "error");
 +}
 +
 +static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
 +{
 +    int err, i;
 +    AVFormatContext *fmt_ctx = NULL;
 +    AVDictionaryEntry *t;
 +
 +    if ((err = avformat_open_input(&fmt_ctx, filename,
 +                                   iformat, &format_opts)) < 0) {
 +        print_error(filename, err);
 +        return err;
 +    }
 +    if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
 +        av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
 +        return AVERROR_OPTION_NOT_FOUND;
 +    }
 +
 +
 +    /* fill the streams in the format context */
 +    if ((err = avformat_find_stream_info(fmt_ctx, NULL)) < 0) {
 +        print_error(filename, err);
 +        return err;
 +    }
 +
 +    av_dump_format(fmt_ctx, 0, filename, 0);
 +
 +    /* bind a decoder to each input stream */
 +    for (i = 0; i < fmt_ctx->nb_streams; i++) {
 +        AVStream *stream = fmt_ctx->streams[i];
 +        AVCodec *codec;
 +
-         if (fmt_ctx->streams[i]->codec->codec_id != CODEC_ID_NONE)
++        if (stream->codec->codec_id == AV_CODEC_ID_PROBE) {
 +            av_log(NULL, AV_LOG_ERROR,
 +                   "Failed to probe codec for input stream %d\n",
 +                    stream->index);
 +        } else if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) {
 +            av_log(NULL, AV_LOG_ERROR,
 +                    "Unsupported codec with id %d for input stream %d\n",
 +                    stream->codec->codec_id, stream->index);
 +        } else if (avcodec_open2(stream->codec, codec, NULL) < 0) {
 +            av_log(NULL, AV_LOG_ERROR, "Error while opening codec for input stream %d\n",
 +                   stream->index);
 +        }
 +    }
 +
 +    *fmt_ctx_ptr = fmt_ctx;
 +    return 0;
 +}
 +
 +static void close_input_file(AVFormatContext **ctx_ptr)
 +{
 +    int i;
 +    AVFormatContext *fmt_ctx = *ctx_ptr;
 +
 +    /* close decoder for each stream */
 +    for (i = 0; i < fmt_ctx->nb_streams; i++)
++        if (fmt_ctx->streams[i]->codec->codec_id != AV_CODEC_ID_NONE)
 +            avcodec_close(fmt_ctx->streams[i]->codec);
 +
 +    avformat_close_input(ctx_ptr);
 +}
 +
 +#define PRINT_CHAPTER(name) do {                                        \
 +    if (do_show_ ## name) {                                             \
 +        writer_print_chapter_header(wctx, #name);                       \
 +        show_ ## name (wctx, fmt_ctx);                                  \
 +        writer_print_chapter_footer(wctx, #name);                       \
 +    }                                                                   \
 +} while (0)
 +
 +static int probe_file(WriterContext *wctx, const char *filename)
 +{
 +    AVFormatContext *fmt_ctx;
 +    int ret;
 +
 +    do_read_frames = do_show_frames || do_count_frames;
 +    do_read_packets = do_show_packets || do_count_packets;
 +
 +    ret = open_input_file(&fmt_ctx, filename);
 +    if (ret >= 0) {
 +        nb_streams_frames  = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_frames));
 +        nb_streams_packets = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_packets));
 +        if (do_read_frames || do_read_packets) {
 +            const char *chapter;
 +            if (do_show_frames && do_show_packets &&
 +                wctx->writer->flags & WRITER_FLAG_PUT_PACKETS_AND_FRAMES_IN_SAME_CHAPTER)
 +                chapter = "packets_and_frames";
 +            else if (do_show_packets && !do_show_frames)
 +                chapter = "packets";
 +            else // (!do_show_packets && do_show_frames)
 +                chapter = "frames";
 +            if (do_show_frames || do_show_packets)
 +                writer_print_chapter_header(wctx, chapter);
 +            read_packets(wctx, fmt_ctx);
 +            if (do_show_frames || do_show_packets)
 +                writer_print_chapter_footer(wctx, chapter);
 +        }
 +        PRINT_CHAPTER(streams);
 +        PRINT_CHAPTER(format);
 +        close_input_file(&fmt_ctx);
 +        av_freep(&nb_streams_frames);
 +        av_freep(&nb_streams_packets);
 +    }
 +    return ret;
 +}
 +
 +static void show_usage(void)
 +{
 +    av_log(NULL, AV_LOG_INFO, "Simple multimedia streams analyzer\n");
 +    av_log(NULL, AV_LOG_INFO, "usage: %s [OPTIONS] [INPUT_FILE]\n", program_name);
 +    av_log(NULL, AV_LOG_INFO, "\n");
 +}
 +
 +static void ffprobe_show_program_version(WriterContext *w)
 +{
 +    AVBPrint pbuf;
 +    av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
 +
 +    writer_print_chapter_header(w, "program_version");
 +    print_section_header("program_version");
 +    print_str("version", FFMPEG_VERSION);
 +    print_fmt("copyright", "Copyright (c) %d-%d the FFmpeg developers",
 +              program_birth_year, this_year);
 +    print_str("build_date", __DATE__);
 +    print_str("build_time", __TIME__);
 +    print_str("compiler_ident", CC_IDENT);
 +    print_str("configuration", FFMPEG_CONFIGURATION);
 +    print_section_footer("program_version");
 +    writer_print_chapter_footer(w, "program_version");
 +
 +    av_bprint_finalize(&pbuf, NULL);
 +}
 +
 +#define SHOW_LIB_VERSION(libname, LIBNAME)                              \
 +    do {                                                                \
 +        if (CONFIG_##LIBNAME) {                                         \
 +            unsigned int version = libname##_version();                 \
 +            print_section_header("library_version");                    \
 +            print_str("name",    "lib" #libname);                       \
 +            print_int("major",   LIB##LIBNAME##_VERSION_MAJOR);         \
 +            print_int("minor",   LIB##LIBNAME##_VERSION_MINOR);         \
 +            print_int("micro",   LIB##LIBNAME##_VERSION_MICRO);         \
 +            print_int("version", version);                              \
 +            print_section_footer("library_version");                    \
 +        }                                                               \
 +    } while (0)
 +
 +static void ffprobe_show_library_versions(WriterContext *w)
 +{
 +    writer_print_chapter_header(w, "library_versions");
 +    SHOW_LIB_VERSION(avutil,     AVUTIL);
 +    SHOW_LIB_VERSION(avcodec,    AVCODEC);
 +    SHOW_LIB_VERSION(avformat,   AVFORMAT);
 +    SHOW_LIB_VERSION(avdevice,   AVDEVICE);
 +    SHOW_LIB_VERSION(avfilter,   AVFILTER);
 +    SHOW_LIB_VERSION(swscale,    SWSCALE);
 +    SHOW_LIB_VERSION(swresample, SWRESAMPLE);
 +    SHOW_LIB_VERSION(postproc,   POSTPROC);
 +    writer_print_chapter_footer(w, "library_versions");
 +}
 +
 +static int opt_format(const char *opt, const char *arg)
 +{
 +    iformat = av_find_input_format(arg);
 +    if (!iformat) {
 +        av_log(NULL, AV_LOG_ERROR, "Unknown input format: %s\n", arg);
 +        return AVERROR(EINVAL);
 +    }
 +    return 0;
 +}
 +
 +static int opt_show_format_entry(const char *opt, const char *arg)
 +{
 +    do_show_format = 1;
 +    av_dict_set(&fmt_entries_to_show, arg, "", 0);
 +    return 0;
 +}
 +
 +static void opt_input_file(void *optctx, const char *arg)
 +{
 +    if (input_filename) {
 +        av_log(NULL, AV_LOG_ERROR,
 +                "Argument '%s' provided as input filename, but '%s' was already specified.\n",
 +                arg, input_filename);
 +        exit(1);
 +    }
 +    if (!strcmp(arg, "-"))
 +        arg = "pipe:";
 +    input_filename = arg;
 +}
 +
 +static int opt_help(const char *opt, const char *arg)
 +{
 +    av_log_set_callback(log_callback_help);
 +    show_usage();
 +    show_help_options(options, "Main options:\n", 0, 0);
 +    printf("\n");
 +
 +    show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
 +
 +    return 0;
 +}
 +
 +static int opt_pretty(const char *opt, const char *arg)
 +{
 +    show_value_unit              = 1;
 +    use_value_prefix             = 1;
 +    use_byte_value_binary_prefix = 1;
 +    use_value_sexagesimal_format = 1;
 +    return 0;
 +}
 +
 +static int opt_show_versions(const char *opt, const char *arg)
 +{
 +    do_show_program_version  = 1;
 +    do_show_library_versions = 1;
 +    return 0;
 +}
 +
 +static const OptionDef real_options[] = {
 +#include "cmdutils_common_opts.h"
 +    { "f", HAS_ARG, {(void*)opt_format}, "force format", "format" },
 +    { "unit", OPT_BOOL, {(void*)&show_value_unit}, "show unit of the displayed values" },
 +    { "prefix", OPT_BOOL, {(void*)&use_value_prefix}, "use SI prefixes for the displayed values" },
 +    { "byte_binary_prefix", OPT_BOOL, {(void*)&use_byte_value_binary_prefix},
 +      "use binary prefixes for byte units" },
 +    { "sexagesimal", OPT_BOOL,  {(void*)&use_value_sexagesimal_format},
 +      "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
 +    { "pretty", 0, {(void*)&opt_pretty},
 +      "prettify the format of displayed values, make it more human readable" },
 +    { "print_format", OPT_STRING | HAS_ARG, {(void*)&print_format},
 +      "set the output printing format (available formats are: default, compact, csv, flat, ini, json, xml)", "format" },
 +    { "of", OPT_STRING | HAS_ARG, {(void*)&print_format}, "alias for -print_format", "format" },
 +    { "show_data",    OPT_BOOL, {(void*)&do_show_data}, "show packets data" },
 +    { "show_error",   OPT_BOOL, {(void*)&do_show_error} ,  "show probing error" },
 +    { "show_format",  OPT_BOOL, {(void*)&do_show_format} , "show format/container info" },
 +    { "show_frames",  OPT_BOOL, {(void*)&do_show_frames} , "show frames info" },
 +    { "show_format_entry", HAS_ARG, {(void*)opt_show_format_entry},
 +      "show a particular entry from the format/container info", "entry" },
 +    { "show_packets", OPT_BOOL, {(void*)&do_show_packets}, "show packets info" },
 +    { "show_streams", OPT_BOOL, {(void*)&do_show_streams}, "show streams info" },
 +    { "count_frames", OPT_BOOL, {(void*)&do_count_frames}, "count the number of frames per stream" },
 +    { "count_packets", OPT_BOOL, {(void*)&do_count_packets}, "count the number of packets per stream" },
 +    { "show_program_version",  OPT_BOOL, {(void*)&do_show_program_version},  "show ffprobe version" },
 +    { "show_library_versions", OPT_BOOL, {(void*)&do_show_library_versions}, "show library versions" },
 +    { "show_versions",         0, {(void*)&opt_show_versions}, "show program and library versions" },
 +    { "show_private_data", OPT_BOOL, {(void*)&show_private_data}, "show private data" },
 +    { "private",           OPT_BOOL, {(void*)&show_private_data}, "same as show_private_data" },
 +    { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
 +    { "i", HAS_ARG, {(void *)opt_input_file}, "read specified file", "input_file"},
 +    { NULL, },
 +};
 +
 +int main(int argc, char **argv)
 +{
 +    const Writer *w;
 +    WriterContext *wctx;
 +    char *buf;
 +    char *w_name = NULL, *w_args = NULL;
 +    int ret;
 +
 +    av_log_set_flags(AV_LOG_SKIP_REPEATED);
 +    options = real_options;
 +    parse_loglevel(argc, argv, options);
 +    av_register_all();
 +    avformat_network_init();
 +    init_opts();
 +#if CONFIG_AVDEVICE
 +    avdevice_register_all();
 +#endif
 +
 +    show_banner(argc, argv, options);
 +    parse_options(NULL, argc, argv, options, opt_input_file);
 +
 +    writer_register_all();
 +
 +    if (!print_format)
 +        print_format = av_strdup("default");
 +    w_name = av_strtok(print_format, "=", &buf);
 +    w_args = buf;
 +
 +    w = writer_get_by_name(w_name);
 +    if (!w) {
 +        av_log(NULL, AV_LOG_ERROR, "Unknown output format with name '%s'\n", w_name);
 +        ret = AVERROR(EINVAL);
 +        goto end;
 +    }
 +
 +    if ((ret = writer_open(&wctx, w, w_args, NULL)) >= 0) {
 +        writer_print_header(wctx);
 +
 +        if (do_show_program_version)
 +            ffprobe_show_program_version(wctx);
 +        if (do_show_library_versions)
 +            ffprobe_show_library_versions(wctx);
 +
 +        if (!input_filename &&
 +            ((do_show_format || do_show_streams || do_show_packets || do_show_error) ||
 +             (!do_show_program_version && !do_show_library_versions))) {
 +            show_usage();
 +            av_log(NULL, AV_LOG_ERROR, "You have to specify one input file.\n");
 +            av_log(NULL, AV_LOG_ERROR, "Use -h to get full help or, even better, run 'man %s'.\n", program_name);
 +            ret = AVERROR(EINVAL);
 +        } else if (input_filename) {
 +            ret = probe_file(wctx, input_filename);
 +            if (ret < 0 && do_show_error)
 +                show_error(wctx, ret);
 +        }
 +
 +        writer_print_footer(wctx);
 +        writer_close(&wctx);
 +    }
 +
 +end:
 +    av_freep(&print_format);
 +
 +    uninit_opts();
 +    av_dict_free(&fmt_entries_to_show);
 +
 +    avformat_network_deinit();
 +
 +    return ret;
 +}
diff --cc ffserver.c
@@@ -3937,9 -3922,9 +3937,9 @@@ static int ffserver_opt_default(const c
      return ret;
  }
  
 -static int avserver_opt_preset(const char *arg,
 +static int ffserver_opt_preset(const char *arg,
                         AVCodecContext *avctx, int type,
-                        enum CodecID *audio_id, enum CodecID *video_id)
+                        enum AVCodecID *audio_id, enum AVCodecID *video_id)
  {
      FILE *f=NULL;
      char filename[1000], tmp[1000], tmp2[1000], line[1000];
@@@ -4228,12 -4213,11 +4228,12 @@@ static int parse_ffconfig(const char *f
                      }
                  }
  
 -                stream->fmt = avserver_guess_format(NULL, stream->filename, NULL);
 +                stream->fmt = ffserver_guess_format(NULL, stream->filename, NULL);
                  avcodec_get_context_defaults3(&video_enc, NULL);
                  avcodec_get_context_defaults3(&audio_enc, NULL);
-                 audio_id = CODEC_ID_NONE;
-                 video_id = CODEC_ID_NONE;
 +
+                 audio_id = AV_CODEC_ID_NONE;
+                 video_id = AV_CODEC_ID_NONE;
                  if (stream->fmt) {
                      audio_id = stream->fmt->audio_codec;
                      video_id = stream->fmt->video_codec;
Simple merge
Simple merge
@@@ -187,17 -176,20 +187,17 @@@ static av_cold int eightsvx_decode_init
  
      if (avctx->channels < 1 || avctx->channels > 2) {
          av_log(avctx, AV_LOG_ERROR, "8SVX does not support more than 2 channels\n");
 -        return AVERROR(EINVAL);
 +        return AVERROR_INVALIDDATA;
      }
  
 -    switch(avctx->codec->id) {
 -        case AV_CODEC_ID_8SVX_FIB:
 -          esc->table = fibonacci;
 -          break;
 -        case AV_CODEC_ID_8SVX_EXP:
 -          esc->table = exponential;
 -          break;
 -        case AV_CODEC_ID_PCM_S8_PLANAR:
 -            break;
 -        default:
 -          return -1;
 +    switch (avctx->codec->id) {
-     case CODEC_ID_8SVX_FIB: esc->table = fibonacci;    break;
-     case CODEC_ID_8SVX_EXP: esc->table = exponential;  break;
-     case CODEC_ID_PCM_S8_PLANAR:
-     case CODEC_ID_8SVX_RAW: esc->table = NULL;         break;
++    case AV_CODEC_ID_8SVX_FIB: esc->table = fibonacci;    break;
++    case AV_CODEC_ID_8SVX_EXP: esc->table = exponential;  break;
++    case AV_CODEC_ID_PCM_S8_PLANAR:
++    case AV_CODEC_ID_8SVX_RAW: esc->table = NULL;         break;
 +    default:
 +        av_log(avctx, AV_LOG_ERROR, "Invalid codec id %d.\n", avctx->codec->id);
 +        return AVERROR_INVALIDDATA;
      }
      avctx->sample_fmt = AV_SAMPLE_FMT_U8;
  
@@@ -222,29 -212,27 +222,29 @@@ static av_cold int eightsvx_decode_clos
  AVCodec ff_eightsvx_fib_decoder = {
    .name           = "8svx_fib",
    .type           = AVMEDIA_TYPE_AUDIO,
-   .id             = CODEC_ID_8SVX_FIB,
+   .id             = AV_CODEC_ID_8SVX_FIB,
    .priv_data_size = sizeof (EightSvxContext),
    .init           = eightsvx_decode_init,
 -  .close          = eightsvx_decode_close,
    .decode         = eightsvx_decode_frame,
 -  .capabilities   = CODEC_CAP_DELAY | CODEC_CAP_DR1,
 +  .close          = eightsvx_decode_close,
 +  .capabilities   = CODEC_CAP_DR1,
    .long_name      = NULL_IF_CONFIG_SMALL("8SVX fibonacci"),
  };
 -
 +#endif
 +#if CONFIG_EIGHTSVX_EXP_DECODER
  AVCodec ff_eightsvx_exp_decoder = {
    .name           = "8svx_exp",
    .type           = AVMEDIA_TYPE_AUDIO,
-   .id             = CODEC_ID_8SVX_EXP,
+   .id             = AV_CODEC_ID_8SVX_EXP,
    .priv_data_size = sizeof (EightSvxContext),
    .init           = eightsvx_decode_init,
 -  .close          = eightsvx_decode_close,
    .decode         = eightsvx_decode_frame,
 -  .capabilities   = CODEC_CAP_DELAY | CODEC_CAP_DR1,
 +  .close          = eightsvx_decode_close,
 +  .capabilities   = CODEC_CAP_DR1,
    .long_name      = NULL_IF_CONFIG_SMALL("8SVX exponential"),
  };
 -
 +#endif
 +#if CONFIG_PCM_S8_PLANAR_DECODER
  AVCodec ff_pcm_s8_planar_decoder = {
      .name           = "pcm_s8_planar",
      .type           = AVMEDIA_TYPE_AUDIO,
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -418,12 -421,9 +418,12 @@@ static int get_nb_samples(AVCodecContex
  
      *coded_samples = 0;
  
 +    if(ch <= 0)
 +        return 0;
 +
      switch (avctx->codec->id) {
      /* constant, only check buf_size */
-     case CODEC_ID_ADPCM_EA_XAS:
+     case AV_CODEC_ID_ADPCM_EA_XAS:
          if (buf_size < 76 * ch)
              return 0;
          nb_samples = 128;
@@@ -102,17 -100,16 +102,17 @@@ static av_cold int adpcm_encode_init(AV
          /* seems frame_size isn't taken into account...
             have to buffer the samples :-( */
          avctx->block_align = BLKSIZE;
 +        avctx->bits_per_coded_sample = 4;
          break;
-     case CODEC_ID_ADPCM_IMA_QT:
+     case AV_CODEC_ID_ADPCM_IMA_QT:
          avctx->frame_size  = 64;
          avctx->block_align = 34 * avctx->channels;
          break;
-     case CODEC_ID_ADPCM_MS:
+     case AV_CODEC_ID_ADPCM_MS:
          /* each 16 bits sample gives one nibble
             and we have 7 bytes per channel overhead */
 -        avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 /
 -                             avctx->channels + 2;
 +        avctx->frame_size = (BLKSIZE - 7 * avctx->channels) * 2 / avctx->channels + 2;
 +        avctx->bits_per_coded_sample = 4;
          avctx->block_align    = BLKSIZE;
          if (!(avctx->extradata = av_malloc(32 + FF_INPUT_BUFFER_PADDING_SIZE)))
              goto error;
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -50,13 -49,13 +50,13 @@@ static void ff_h264_pred_init_neon(H264
  
      if (high_depth)
          return;
 -
 +    if(chroma_format_idc == 1){
      h->pred8x8[VERT_PRED8x8     ] = ff_pred8x8_vert_neon;
      h->pred8x8[HOR_PRED8x8      ] = ff_pred8x8_hor_neon;
-     if (codec_id != CODEC_ID_VP8)
+     if (codec_id != AV_CODEC_ID_VP8)
          h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_neon;
      h->pred8x8[DC_128_PRED8x8   ] = ff_pred8x8_128_dc_neon;
-     if (codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8) {
+     if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP8) {
          h->pred8x8[DC_PRED8x8     ] = ff_pred8x8_dc_neon;
          h->pred8x8[LEFT_DC_PRED8x8] = ff_pred8x8_left_dc_neon;
          h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_neon;
@@@ -73,9 -71,8 +73,9 @@@
      h->pred16x16[LEFT_DC_PRED8x8] = ff_pred16x16_left_dc_neon;
      h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon;
      h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_neon;
-     if (codec_id != CODEC_ID_SVQ3 && codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8)
+     if (codec_id != AV_CODEC_ID_SVQ3 && codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP8)
          h->pred16x16[PLANE_PRED8x8  ] = ff_pred16x16_plane_neon;
 +#endif // HAVE_NEON
  }
  
  void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, int bit_depth, const int chroma_format_idc)
Simple merge
@@@ -70,8 -56,7 +70,8 @@@ AVCodec ff_ass_decoder = 
      .name         = "ass",
      .long_name    = NULL_IF_CONFIG_SMALL("SSA (SubStation Alpha) subtitle"),
      .type         = AVMEDIA_TYPE_SUBTITLE,
-     .id           = CODEC_ID_SSA,
+     .id           = AV_CODEC_ID_SSA,
      .init         = ass_decode_init,
      .decode       = ass_decode_frame,
 +    .close        = ass_decode_close,
  };
Simple merge
@@@ -550,9 -555,10 +550,9 @@@ static av_cold int decode_init(AVCodecC
      ff_init_scantable(a->dsp.idct_permutation, &a->scantable, scantab);
      avctx->pix_fmt= PIX_FMT_YUV420P;
  
 -    a->inv_qscale= avctx->extradata[0];
 -    if(a->inv_qscale == 0){
 +    if(avctx->extradata_size < 1 || (a->inv_qscale= avctx->extradata[0]) == 0){
          av_log(avctx, AV_LOG_ERROR, "illegal qscale 0\n");
-         if(avctx->codec_id == CODEC_ID_ASV1)
+         if(avctx->codec_id == AV_CODEC_ID_ASV1)
              a->inv_qscale= 6;
          else
              a->inv_qscale= 10;
Simple merge
Simple merge
Simple merge
   *
   * If you add a codec ID to this list, add it so that
   * 1. no value of a existing codec ID changes (that would break ABI),
 - * 2. it is as close as possible to similar codecs.
 + * 2. Give it a value which when taken as ASCII is recognized uniquely by a human as this specific codec.
 + *    This ensures that 2 forks can independently add CodecIDs without producing conflicts.
   */
- enum CodecID {
-     CODEC_ID_NONE,
+ enum AVCodecID {
+     AV_CODEC_ID_NONE,
  
      /* video codecs */
-     CODEC_ID_MPEG1VIDEO,
-     CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
-     CODEC_ID_MPEG2VIDEO_XVMC,
-     CODEC_ID_H261,
-     CODEC_ID_H263,
-     CODEC_ID_RV10,
-     CODEC_ID_RV20,
-     CODEC_ID_MJPEG,
-     CODEC_ID_MJPEGB,
-     CODEC_ID_LJPEG,
-     CODEC_ID_SP5X,
-     CODEC_ID_JPEGLS,
-     CODEC_ID_MPEG4,
-     CODEC_ID_RAWVIDEO,
-     CODEC_ID_MSMPEG4V1,
-     CODEC_ID_MSMPEG4V2,
-     CODEC_ID_MSMPEG4V3,
-     CODEC_ID_WMV1,
-     CODEC_ID_WMV2,
-     CODEC_ID_H263P,
-     CODEC_ID_H263I,
-     CODEC_ID_FLV1,
-     CODEC_ID_SVQ1,
-     CODEC_ID_SVQ3,
-     CODEC_ID_DVVIDEO,
-     CODEC_ID_HUFFYUV,
-     CODEC_ID_CYUV,
-     CODEC_ID_H264,
-     CODEC_ID_INDEO3,
-     CODEC_ID_VP3,
-     CODEC_ID_THEORA,
-     CODEC_ID_ASV1,
-     CODEC_ID_ASV2,
-     CODEC_ID_FFV1,
-     CODEC_ID_4XM,
-     CODEC_ID_VCR1,
-     CODEC_ID_CLJR,
-     CODEC_ID_MDEC,
-     CODEC_ID_ROQ,
-     CODEC_ID_INTERPLAY_VIDEO,
-     CODEC_ID_XAN_WC3,
-     CODEC_ID_XAN_WC4,
-     CODEC_ID_RPZA,
-     CODEC_ID_CINEPAK,
-     CODEC_ID_WS_VQA,
-     CODEC_ID_MSRLE,
-     CODEC_ID_MSVIDEO1,
-     CODEC_ID_IDCIN,
-     CODEC_ID_8BPS,
-     CODEC_ID_SMC,
-     CODEC_ID_FLIC,
-     CODEC_ID_TRUEMOTION1,
-     CODEC_ID_VMDVIDEO,
-     CODEC_ID_MSZH,
-     CODEC_ID_ZLIB,
-     CODEC_ID_QTRLE,
-     CODEC_ID_SNOW,
-     CODEC_ID_TSCC,
-     CODEC_ID_ULTI,
-     CODEC_ID_QDRAW,
-     CODEC_ID_VIXL,
-     CODEC_ID_QPEG,
-     CODEC_ID_PNG,
-     CODEC_ID_PPM,
-     CODEC_ID_PBM,
-     CODEC_ID_PGM,
-     CODEC_ID_PGMYUV,
-     CODEC_ID_PAM,
-     CODEC_ID_FFVHUFF,
-     CODEC_ID_RV30,
-     CODEC_ID_RV40,
-     CODEC_ID_VC1,
-     CODEC_ID_WMV3,
-     CODEC_ID_LOCO,
-     CODEC_ID_WNV1,
-     CODEC_ID_AASC,
-     CODEC_ID_INDEO2,
-     CODEC_ID_FRAPS,
-     CODEC_ID_TRUEMOTION2,
-     CODEC_ID_BMP,
-     CODEC_ID_CSCD,
-     CODEC_ID_MMVIDEO,
-     CODEC_ID_ZMBV,
-     CODEC_ID_AVS,
-     CODEC_ID_SMACKVIDEO,
-     CODEC_ID_NUV,
-     CODEC_ID_KMVC,
-     CODEC_ID_FLASHSV,
-     CODEC_ID_CAVS,
-     CODEC_ID_JPEG2000,
-     CODEC_ID_VMNC,
-     CODEC_ID_VP5,
-     CODEC_ID_VP6,
-     CODEC_ID_VP6F,
-     CODEC_ID_TARGA,
-     CODEC_ID_DSICINVIDEO,
-     CODEC_ID_TIERTEXSEQVIDEO,
-     CODEC_ID_TIFF,
-     CODEC_ID_GIF,
-     CODEC_ID_DXA,
-     CODEC_ID_DNXHD,
-     CODEC_ID_THP,
-     CODEC_ID_SGI,
-     CODEC_ID_C93,
-     CODEC_ID_BETHSOFTVID,
-     CODEC_ID_PTX,
-     CODEC_ID_TXD,
-     CODEC_ID_VP6A,
-     CODEC_ID_AMV,
-     CODEC_ID_VB,
-     CODEC_ID_PCX,
-     CODEC_ID_SUNRAST,
-     CODEC_ID_INDEO4,
-     CODEC_ID_INDEO5,
-     CODEC_ID_MIMIC,
-     CODEC_ID_RL2,
-     CODEC_ID_ESCAPE124,
-     CODEC_ID_DIRAC,
-     CODEC_ID_BFI,
-     CODEC_ID_CMV,
-     CODEC_ID_MOTIONPIXELS,
-     CODEC_ID_TGV,
-     CODEC_ID_TGQ,
-     CODEC_ID_TQI,
-     CODEC_ID_AURA,
-     CODEC_ID_AURA2,
-     CODEC_ID_V210X,
-     CODEC_ID_TMV,
-     CODEC_ID_V210,
-     CODEC_ID_DPX,
-     CODEC_ID_MAD,
-     CODEC_ID_FRWU,
-     CODEC_ID_FLASHSV2,
-     CODEC_ID_CDGRAPHICS,
-     CODEC_ID_R210,
-     CODEC_ID_ANM,
-     CODEC_ID_BINKVIDEO,
-     CODEC_ID_IFF_ILBM,
-     CODEC_ID_IFF_BYTERUN1,
-     CODEC_ID_KGV1,
-     CODEC_ID_YOP,
-     CODEC_ID_VP8,
-     CODEC_ID_PICTOR,
-     CODEC_ID_ANSI,
-     CODEC_ID_A64_MULTI,
-     CODEC_ID_A64_MULTI5,
-     CODEC_ID_R10K,
-     CODEC_ID_MXPEG,
-     CODEC_ID_LAGARITH,
-     CODEC_ID_PRORES,
-     CODEC_ID_JV,
-     CODEC_ID_DFA,
-     CODEC_ID_WMV3IMAGE,
-     CODEC_ID_VC1IMAGE,
-     CODEC_ID_UTVIDEO,
-     CODEC_ID_BMV_VIDEO,
-     CODEC_ID_VBLE,
-     CODEC_ID_DXTORY,
-     CODEC_ID_V410,
-     CODEC_ID_XWD,
-     CODEC_ID_CDXL,
-     CODEC_ID_XBM,
-     CODEC_ID_ZEROCODEC,
-     CODEC_ID_MSS1,
-     CODEC_ID_MSA1,
-     CODEC_ID_TSCC2,
-     CODEC_ID_MTS2,
-     CODEC_ID_CLLC,
-     CODEC_ID_Y41P       = MKBETAG('Y','4','1','P'),
-     CODEC_ID_ESCAPE130  = MKBETAG('E','1','3','0'),
-     CODEC_ID_EXR        = MKBETAG('0','E','X','R'),
-     CODEC_ID_AVRP       = MKBETAG('A','V','R','P'),
-     CODEC_ID_G2M        = MKBETAG( 0 ,'G','2','M'),
-     CODEC_ID_AVUI       = MKBETAG('A','V','U','I'),
-     CODEC_ID_AYUV       = MKBETAG('A','Y','U','V'),
-     CODEC_ID_V308       = MKBETAG('V','3','0','8'),
-     CODEC_ID_V408       = MKBETAG('V','4','0','8'),
-     CODEC_ID_YUV4       = MKBETAG('Y','U','V','4'),
-     CODEC_ID_SANM       = MKBETAG('S','A','N','M'),
-     CODEC_ID_PAF_VIDEO  = MKBETAG('P','A','F','V'),
+     AV_CODEC_ID_MPEG1VIDEO,
+     AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
+     AV_CODEC_ID_MPEG2VIDEO_XVMC,
+     AV_CODEC_ID_H261,
+     AV_CODEC_ID_H263,
+     AV_CODEC_ID_RV10,
+     AV_CODEC_ID_RV20,
+     AV_CODEC_ID_MJPEG,
+     AV_CODEC_ID_MJPEGB,
+     AV_CODEC_ID_LJPEG,
+     AV_CODEC_ID_SP5X,
+     AV_CODEC_ID_JPEGLS,
+     AV_CODEC_ID_MPEG4,
+     AV_CODEC_ID_RAWVIDEO,
+     AV_CODEC_ID_MSMPEG4V1,
+     AV_CODEC_ID_MSMPEG4V2,
+     AV_CODEC_ID_MSMPEG4V3,
+     AV_CODEC_ID_WMV1,
+     AV_CODEC_ID_WMV2,
+     AV_CODEC_ID_H263P,
+     AV_CODEC_ID_H263I,
+     AV_CODEC_ID_FLV1,
+     AV_CODEC_ID_SVQ1,
+     AV_CODEC_ID_SVQ3,
+     AV_CODEC_ID_DVVIDEO,
+     AV_CODEC_ID_HUFFYUV,
+     AV_CODEC_ID_CYUV,
+     AV_CODEC_ID_H264,
+     AV_CODEC_ID_INDEO3,
+     AV_CODEC_ID_VP3,
+     AV_CODEC_ID_THEORA,
+     AV_CODEC_ID_ASV1,
+     AV_CODEC_ID_ASV2,
+     AV_CODEC_ID_FFV1,
+     AV_CODEC_ID_4XM,
+     AV_CODEC_ID_VCR1,
+     AV_CODEC_ID_CLJR,
+     AV_CODEC_ID_MDEC,
+     AV_CODEC_ID_ROQ,
+     AV_CODEC_ID_INTERPLAY_VIDEO,
+     AV_CODEC_ID_XAN_WC3,
+     AV_CODEC_ID_XAN_WC4,
+     AV_CODEC_ID_RPZA,
+     AV_CODEC_ID_CINEPAK,
+     AV_CODEC_ID_WS_VQA,
+     AV_CODEC_ID_MSRLE,
+     AV_CODEC_ID_MSVIDEO1,
+     AV_CODEC_ID_IDCIN,
+     AV_CODEC_ID_8BPS,
+     AV_CODEC_ID_SMC,
+     AV_CODEC_ID_FLIC,
+     AV_CODEC_ID_TRUEMOTION1,
+     AV_CODEC_ID_VMDVIDEO,
+     AV_CODEC_ID_MSZH,
+     AV_CODEC_ID_ZLIB,
+     AV_CODEC_ID_QTRLE,
+     AV_CODEC_ID_SNOW,
+     AV_CODEC_ID_TSCC,
+     AV_CODEC_ID_ULTI,
+     AV_CODEC_ID_QDRAW,
+     AV_CODEC_ID_VIXL,
+     AV_CODEC_ID_QPEG,
+     AV_CODEC_ID_PNG,
+     AV_CODEC_ID_PPM,
+     AV_CODEC_ID_PBM,
+     AV_CODEC_ID_PGM,
+     AV_CODEC_ID_PGMYUV,
+     AV_CODEC_ID_PAM,
+     AV_CODEC_ID_FFVHUFF,
+     AV_CODEC_ID_RV30,
+     AV_CODEC_ID_RV40,
+     AV_CODEC_ID_VC1,
+     AV_CODEC_ID_WMV3,
+     AV_CODEC_ID_LOCO,
+     AV_CODEC_ID_WNV1,
+     AV_CODEC_ID_AASC,
+     AV_CODEC_ID_INDEO2,
+     AV_CODEC_ID_FRAPS,
+     AV_CODEC_ID_TRUEMOTION2,
+     AV_CODEC_ID_BMP,
+     AV_CODEC_ID_CSCD,
+     AV_CODEC_ID_MMVIDEO,
+     AV_CODEC_ID_ZMBV,
+     AV_CODEC_ID_AVS,
+     AV_CODEC_ID_SMACKVIDEO,
+     AV_CODEC_ID_NUV,
+     AV_CODEC_ID_KMVC,
+     AV_CODEC_ID_FLASHSV,
+     AV_CODEC_ID_CAVS,
+     AV_CODEC_ID_JPEG2000,
+     AV_CODEC_ID_VMNC,
+     AV_CODEC_ID_VP5,
+     AV_CODEC_ID_VP6,
+     AV_CODEC_ID_VP6F,
+     AV_CODEC_ID_TARGA,
+     AV_CODEC_ID_DSICINVIDEO,
+     AV_CODEC_ID_TIERTEXSEQVIDEO,
+     AV_CODEC_ID_TIFF,
+     AV_CODEC_ID_GIF,
+     AV_CODEC_ID_DXA,
+     AV_CODEC_ID_DNXHD,
+     AV_CODEC_ID_THP,
+     AV_CODEC_ID_SGI,
+     AV_CODEC_ID_C93,
+     AV_CODEC_ID_BETHSOFTVID,
+     AV_CODEC_ID_PTX,
+     AV_CODEC_ID_TXD,
+     AV_CODEC_ID_VP6A,
+     AV_CODEC_ID_AMV,
+     AV_CODEC_ID_VB,
+     AV_CODEC_ID_PCX,
+     AV_CODEC_ID_SUNRAST,
+     AV_CODEC_ID_INDEO4,
+     AV_CODEC_ID_INDEO5,
+     AV_CODEC_ID_MIMIC,
+     AV_CODEC_ID_RL2,
+     AV_CODEC_ID_ESCAPE124,
+     AV_CODEC_ID_DIRAC,
+     AV_CODEC_ID_BFI,
+     AV_CODEC_ID_CMV,
+     AV_CODEC_ID_MOTIONPIXELS,
+     AV_CODEC_ID_TGV,
+     AV_CODEC_ID_TGQ,
+     AV_CODEC_ID_TQI,
+     AV_CODEC_ID_AURA,
+     AV_CODEC_ID_AURA2,
+     AV_CODEC_ID_V210X,
+     AV_CODEC_ID_TMV,
+     AV_CODEC_ID_V210,
+     AV_CODEC_ID_DPX,
+     AV_CODEC_ID_MAD,
+     AV_CODEC_ID_FRWU,
+     AV_CODEC_ID_FLASHSV2,
+     AV_CODEC_ID_CDGRAPHICS,
+     AV_CODEC_ID_R210,
+     AV_CODEC_ID_ANM,
+     AV_CODEC_ID_BINKVIDEO,
+     AV_CODEC_ID_IFF_ILBM,
+     AV_CODEC_ID_IFF_BYTERUN1,
+     AV_CODEC_ID_KGV1,
+     AV_CODEC_ID_YOP,
+     AV_CODEC_ID_VP8,
+     AV_CODEC_ID_PICTOR,
+     AV_CODEC_ID_ANSI,
+     AV_CODEC_ID_A64_MULTI,
+     AV_CODEC_ID_A64_MULTI5,
+     AV_CODEC_ID_R10K,
+     AV_CODEC_ID_MXPEG,
+     AV_CODEC_ID_LAGARITH,
+     AV_CODEC_ID_PRORES,
+     AV_CODEC_ID_JV,
+     AV_CODEC_ID_DFA,
+     AV_CODEC_ID_WMV3IMAGE,
+     AV_CODEC_ID_VC1IMAGE,
+     AV_CODEC_ID_UTVIDEO,
+     AV_CODEC_ID_BMV_VIDEO,
+     AV_CODEC_ID_VBLE,
+     AV_CODEC_ID_DXTORY,
+     AV_CODEC_ID_V410,
+     AV_CODEC_ID_XWD,
+     AV_CODEC_ID_CDXL,
+     AV_CODEC_ID_XBM,
+     AV_CODEC_ID_ZEROCODEC,
+     AV_CODEC_ID_MSS1,
+     AV_CODEC_ID_MSA1,
+     AV_CODEC_ID_TSCC2,
+     AV_CODEC_ID_MTS2,
+     AV_CODEC_ID_CLLC,
++    AV_CODEC_ID_Y41P       = MKBETAG('Y','4','1','P'),
++    AV_CODEC_ID_ESCAPE130  = MKBETAG('E','1','3','0'),
++    AV_CODEC_ID_EXR        = MKBETAG('0','E','X','R'),
++    AV_CODEC_ID_AVRP       = MKBETAG('A','V','R','P'),
++
++    AV_CODEC_ID_G2M        = MKBETAG( 0 ,'G','2','M'),
++    AV_CODEC_ID_AVUI       = MKBETAG('A','V','U','I'),
++    AV_CODEC_ID_AYUV       = MKBETAG('A','Y','U','V'),
++    AV_CODEC_ID_V308       = MKBETAG('V','3','0','8'),
++    AV_CODEC_ID_V408       = MKBETAG('V','4','0','8'),
++    AV_CODEC_ID_YUV4       = MKBETAG('Y','U','V','4'),
++    AV_CODEC_ID_SANM       = MKBETAG('S','A','N','M'),
++    AV_CODEC_ID_PAF_VIDEO  = MKBETAG('P','A','F','V'),
  
      /* various PCM "codecs" */
-     CODEC_ID_FIRST_AUDIO = 0x10000,     ///< A dummy id pointing at the start of audio codecs
-     CODEC_ID_PCM_S16LE = 0x10000,
-     CODEC_ID_PCM_S16BE,
-     CODEC_ID_PCM_U16LE,
-     CODEC_ID_PCM_U16BE,
-     CODEC_ID_PCM_S8,
-     CODEC_ID_PCM_U8,
-     CODEC_ID_PCM_MULAW,
-     CODEC_ID_PCM_ALAW,
-     CODEC_ID_PCM_S32LE,
-     CODEC_ID_PCM_S32BE,
-     CODEC_ID_PCM_U32LE,
-     CODEC_ID_PCM_U32BE,
-     CODEC_ID_PCM_S24LE,
-     CODEC_ID_PCM_S24BE,
-     CODEC_ID_PCM_U24LE,
-     CODEC_ID_PCM_U24BE,
-     CODEC_ID_PCM_S24DAUD,
-     CODEC_ID_PCM_ZORK,
-     CODEC_ID_PCM_S16LE_PLANAR,
-     CODEC_ID_PCM_DVD,
-     CODEC_ID_PCM_F32BE,
-     CODEC_ID_PCM_F32LE,
-     CODEC_ID_PCM_F64BE,
-     CODEC_ID_PCM_F64LE,
-     CODEC_ID_PCM_BLURAY,
-     CODEC_ID_PCM_LXF,
-     CODEC_ID_S302M,
-     CODEC_ID_PCM_S8_PLANAR,
+     AV_CODEC_ID_FIRST_AUDIO = 0x10000,     ///< A dummy id pointing at the start of audio codecs
+     AV_CODEC_ID_PCM_S16LE = 0x10000,
+     AV_CODEC_ID_PCM_S16BE,
+     AV_CODEC_ID_PCM_U16LE,
+     AV_CODEC_ID_PCM_U16BE,
+     AV_CODEC_ID_PCM_S8,
+     AV_CODEC_ID_PCM_U8,
+     AV_CODEC_ID_PCM_MULAW,
+     AV_CODEC_ID_PCM_ALAW,
+     AV_CODEC_ID_PCM_S32LE,
+     AV_CODEC_ID_PCM_S32BE,
+     AV_CODEC_ID_PCM_U32LE,
+     AV_CODEC_ID_PCM_U32BE,
+     AV_CODEC_ID_PCM_S24LE,
+     AV_CODEC_ID_PCM_S24BE,
+     AV_CODEC_ID_PCM_U24LE,
+     AV_CODEC_ID_PCM_U24BE,
+     AV_CODEC_ID_PCM_S24DAUD,
+     AV_CODEC_ID_PCM_ZORK,
+     AV_CODEC_ID_PCM_S16LE_PLANAR,
+     AV_CODEC_ID_PCM_DVD,
+     AV_CODEC_ID_PCM_F32BE,
+     AV_CODEC_ID_PCM_F32LE,
+     AV_CODEC_ID_PCM_F64BE,
+     AV_CODEC_ID_PCM_F64LE,
+     AV_CODEC_ID_PCM_BLURAY,
+     AV_CODEC_ID_PCM_LXF,
+     AV_CODEC_ID_S302M,
+     AV_CODEC_ID_PCM_S8_PLANAR,
  
      /* various ADPCM codecs */
-     CODEC_ID_ADPCM_IMA_QT = 0x11000,
-     CODEC_ID_ADPCM_IMA_WAV,
-     CODEC_ID_ADPCM_IMA_DK3,
-     CODEC_ID_ADPCM_IMA_DK4,
-     CODEC_ID_ADPCM_IMA_WS,
-     CODEC_ID_ADPCM_IMA_SMJPEG,
-     CODEC_ID_ADPCM_MS,
-     CODEC_ID_ADPCM_4XM,
-     CODEC_ID_ADPCM_XA,
-     CODEC_ID_ADPCM_ADX,
-     CODEC_ID_ADPCM_EA,
-     CODEC_ID_ADPCM_G726,
-     CODEC_ID_ADPCM_CT,
-     CODEC_ID_ADPCM_SWF,
-     CODEC_ID_ADPCM_YAMAHA,
-     CODEC_ID_ADPCM_SBPRO_4,
-     CODEC_ID_ADPCM_SBPRO_3,
-     CODEC_ID_ADPCM_SBPRO_2,
-     CODEC_ID_ADPCM_THP,
-     CODEC_ID_ADPCM_IMA_AMV,
-     CODEC_ID_ADPCM_EA_R1,
-     CODEC_ID_ADPCM_EA_R3,
-     CODEC_ID_ADPCM_EA_R2,
-     CODEC_ID_ADPCM_IMA_EA_SEAD,
-     CODEC_ID_ADPCM_IMA_EA_EACS,
-     CODEC_ID_ADPCM_EA_XAS,
-     CODEC_ID_ADPCM_EA_MAXIS_XA,
-     CODEC_ID_ADPCM_IMA_ISS,
-     CODEC_ID_ADPCM_G722,
-     CODEC_ID_ADPCM_IMA_APC,
-     CODEC_ID_VIMA       = MKBETAG('V','I','M','A'),
+     AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
+     AV_CODEC_ID_ADPCM_IMA_WAV,
+     AV_CODEC_ID_ADPCM_IMA_DK3,
+     AV_CODEC_ID_ADPCM_IMA_DK4,
+     AV_CODEC_ID_ADPCM_IMA_WS,
+     AV_CODEC_ID_ADPCM_IMA_SMJPEG,
+     AV_CODEC_ID_ADPCM_MS,
+     AV_CODEC_ID_ADPCM_4XM,
+     AV_CODEC_ID_ADPCM_XA,
+     AV_CODEC_ID_ADPCM_ADX,
+     AV_CODEC_ID_ADPCM_EA,
+     AV_CODEC_ID_ADPCM_G726,
+     AV_CODEC_ID_ADPCM_CT,
+     AV_CODEC_ID_ADPCM_SWF,
+     AV_CODEC_ID_ADPCM_YAMAHA,
+     AV_CODEC_ID_ADPCM_SBPRO_4,
+     AV_CODEC_ID_ADPCM_SBPRO_3,
+     AV_CODEC_ID_ADPCM_SBPRO_2,
+     AV_CODEC_ID_ADPCM_THP,
+     AV_CODEC_ID_ADPCM_IMA_AMV,
+     AV_CODEC_ID_ADPCM_EA_R1,
+     AV_CODEC_ID_ADPCM_EA_R3,
+     AV_CODEC_ID_ADPCM_EA_R2,
+     AV_CODEC_ID_ADPCM_IMA_EA_SEAD,
+     AV_CODEC_ID_ADPCM_IMA_EA_EACS,
+     AV_CODEC_ID_ADPCM_EA_XAS,
+     AV_CODEC_ID_ADPCM_EA_MAXIS_XA,
+     AV_CODEC_ID_ADPCM_IMA_ISS,
+     AV_CODEC_ID_ADPCM_G722,
+     AV_CODEC_ID_ADPCM_IMA_APC,
++    AV_CODEC_ID_VIMA       = MKBETAG('V','I','M','A'),
  
      /* AMR */
-     CODEC_ID_AMR_NB = 0x12000,
-     CODEC_ID_AMR_WB,
+     AV_CODEC_ID_AMR_NB = 0x12000,
+     AV_CODEC_ID_AMR_WB,
  
      /* RealAudio codecs*/
-     CODEC_ID_RA_144 = 0x13000,
-     CODEC_ID_RA_288,
+     AV_CODEC_ID_RA_144 = 0x13000,
+     AV_CODEC_ID_RA_288,
  
      /* various DPCM codecs */
-     CODEC_ID_ROQ_DPCM = 0x14000,
-     CODEC_ID_INTERPLAY_DPCM,
-     CODEC_ID_XAN_DPCM,
-     CODEC_ID_SOL_DPCM,
+     AV_CODEC_ID_ROQ_DPCM = 0x14000,
+     AV_CODEC_ID_INTERPLAY_DPCM,
+     AV_CODEC_ID_XAN_DPCM,
+     AV_CODEC_ID_SOL_DPCM,
  
      /* audio codecs */
-     CODEC_ID_MP2 = 0x15000,
-     CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
-     CODEC_ID_AAC,
-     CODEC_ID_AC3,
-     CODEC_ID_DTS,
-     CODEC_ID_VORBIS,
-     CODEC_ID_DVAUDIO,
-     CODEC_ID_WMAV1,
-     CODEC_ID_WMAV2,
-     CODEC_ID_MACE3,
-     CODEC_ID_MACE6,
-     CODEC_ID_VMDAUDIO,
-     CODEC_ID_FLAC,
-     CODEC_ID_MP3ADU,
-     CODEC_ID_MP3ON4,
-     CODEC_ID_SHORTEN,
-     CODEC_ID_ALAC,
-     CODEC_ID_WESTWOOD_SND1,
-     CODEC_ID_GSM, ///< as in Berlin toast format
-     CODEC_ID_QDM2,
-     CODEC_ID_COOK,
-     CODEC_ID_TRUESPEECH,
-     CODEC_ID_TTA,
-     CODEC_ID_SMACKAUDIO,
-     CODEC_ID_QCELP,
-     CODEC_ID_WAVPACK,
-     CODEC_ID_DSICINAUDIO,
-     CODEC_ID_IMC,
-     CODEC_ID_MUSEPACK7,
-     CODEC_ID_MLP,
-     CODEC_ID_GSM_MS, /* as found in WAV */
-     CODEC_ID_ATRAC3,
-     CODEC_ID_VOXWARE,
-     CODEC_ID_APE,
-     CODEC_ID_NELLYMOSER,
-     CODEC_ID_MUSEPACK8,
-     CODEC_ID_SPEEX,
-     CODEC_ID_WMAVOICE,
-     CODEC_ID_WMAPRO,
-     CODEC_ID_WMALOSSLESS,
-     CODEC_ID_ATRAC3P,
-     CODEC_ID_EAC3,
-     CODEC_ID_SIPR,
-     CODEC_ID_MP1,
-     CODEC_ID_TWINVQ,
-     CODEC_ID_TRUEHD,
-     CODEC_ID_MP4ALS,
-     CODEC_ID_ATRAC1,
-     CODEC_ID_BINKAUDIO_RDFT,
-     CODEC_ID_BINKAUDIO_DCT,
-     CODEC_ID_AAC_LATM,
-     CODEC_ID_QDMC,
-     CODEC_ID_CELT,
-     CODEC_ID_G723_1,
-     CODEC_ID_G729,
-     CODEC_ID_8SVX_EXP,
-     CODEC_ID_8SVX_FIB,
-     CODEC_ID_BMV_AUDIO,
-     CODEC_ID_RALF,
-     CODEC_ID_IAC,
-     CODEC_ID_ILBC,
-     CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'),
-     CODEC_ID_8SVX_RAW    = MKBETAG('8','S','V','X'),
-     CODEC_ID_SONIC       = MKBETAG('S','O','N','C'),
-     CODEC_ID_SONIC_LS    = MKBETAG('S','O','N','L'),
-     CODEC_ID_PAF_AUDIO   = MKBETAG('P','A','F','A'),
-     CODEC_ID_OPUS        = MKBETAG('O','P','U','S'),
+     AV_CODEC_ID_MP2 = 0x15000,
+     AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
+     AV_CODEC_ID_AAC,
+     AV_CODEC_ID_AC3,
+     AV_CODEC_ID_DTS,
+     AV_CODEC_ID_VORBIS,
+     AV_CODEC_ID_DVAUDIO,
+     AV_CODEC_ID_WMAV1,
+     AV_CODEC_ID_WMAV2,
+     AV_CODEC_ID_MACE3,
+     AV_CODEC_ID_MACE6,
+     AV_CODEC_ID_VMDAUDIO,
+     AV_CODEC_ID_FLAC,
+     AV_CODEC_ID_MP3ADU,
+     AV_CODEC_ID_MP3ON4,
+     AV_CODEC_ID_SHORTEN,
+     AV_CODEC_ID_ALAC,
+     AV_CODEC_ID_WESTWOOD_SND1,
+     AV_CODEC_ID_GSM, ///< as in Berlin toast format
+     AV_CODEC_ID_QDM2,
+     AV_CODEC_ID_COOK,
+     AV_CODEC_ID_TRUESPEECH,
+     AV_CODEC_ID_TTA,
+     AV_CODEC_ID_SMACKAUDIO,
+     AV_CODEC_ID_QCELP,
+     AV_CODEC_ID_WAVPACK,
+     AV_CODEC_ID_DSICINAUDIO,
+     AV_CODEC_ID_IMC,
+     AV_CODEC_ID_MUSEPACK7,
+     AV_CODEC_ID_MLP,
+     AV_CODEC_ID_GSM_MS, /* as found in WAV */
+     AV_CODEC_ID_ATRAC3,
+     AV_CODEC_ID_VOXWARE,
+     AV_CODEC_ID_APE,
+     AV_CODEC_ID_NELLYMOSER,
+     AV_CODEC_ID_MUSEPACK8,
+     AV_CODEC_ID_SPEEX,
+     AV_CODEC_ID_WMAVOICE,
+     AV_CODEC_ID_WMAPRO,
+     AV_CODEC_ID_WMALOSSLESS,
+     AV_CODEC_ID_ATRAC3P,
+     AV_CODEC_ID_EAC3,
+     AV_CODEC_ID_SIPR,
+     AV_CODEC_ID_MP1,
+     AV_CODEC_ID_TWINVQ,
+     AV_CODEC_ID_TRUEHD,
+     AV_CODEC_ID_MP4ALS,
+     AV_CODEC_ID_ATRAC1,
+     AV_CODEC_ID_BINKAUDIO_RDFT,
+     AV_CODEC_ID_BINKAUDIO_DCT,
+     AV_CODEC_ID_AAC_LATM,
+     AV_CODEC_ID_QDMC,
+     AV_CODEC_ID_CELT,
+     AV_CODEC_ID_G723_1,
+     AV_CODEC_ID_G729,
+     AV_CODEC_ID_8SVX_EXP,
+     AV_CODEC_ID_8SVX_FIB,
+     AV_CODEC_ID_BMV_AUDIO,
+     AV_CODEC_ID_RALF,
+     AV_CODEC_ID_IAC,
+     AV_CODEC_ID_ILBC,
++    AV_CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'),
++    AV_CODEC_ID_8SVX_RAW    = MKBETAG('8','S','V','X'),
++    AV_CODEC_ID_SONIC       = MKBETAG('S','O','N','C'),
++    AV_CODEC_ID_SONIC_LS    = MKBETAG('S','O','N','L'),
++    AV_CODEC_ID_PAF_AUDIO   = MKBETAG('P','A','F','A'),
++    AV_CODEC_ID_OPUS        = MKBETAG('O','P','U','S'),
  
      /* subtitle codecs */
-     CODEC_ID_FIRST_SUBTITLE = 0x17000,          ///< A dummy ID pointing at the start of subtitle codecs.
-     CODEC_ID_DVD_SUBTITLE = 0x17000,
-     CODEC_ID_DVB_SUBTITLE,
-     CODEC_ID_TEXT,  ///< raw UTF-8 text
-     CODEC_ID_XSUB,
-     CODEC_ID_SSA,
-     CODEC_ID_MOV_TEXT,
-     CODEC_ID_HDMV_PGS_SUBTITLE,
-     CODEC_ID_DVB_TELETEXT,
-     CODEC_ID_SRT,
-     CODEC_ID_MICRODVD   = MKBETAG('m','D','V','D'),
-     CODEC_ID_EIA_608    = MKBETAG('c','6','0','8'),
-     CODEC_ID_JACOSUB    = MKBETAG('J','S','U','B'),
-     CODEC_ID_SAMI       = MKBETAG('S','A','M','I'),
-     CODEC_ID_REALTEXT   = MKBETAG('R','T','X','T'),
-     CODEC_ID_SUBVIEWER  = MKBETAG('S','u','b','V'),
+     AV_CODEC_ID_FIRST_SUBTITLE = 0x17000,          ///< A dummy ID pointing at the start of subtitle codecs.
+     AV_CODEC_ID_DVD_SUBTITLE = 0x17000,
+     AV_CODEC_ID_DVB_SUBTITLE,
+     AV_CODEC_ID_TEXT,  ///< raw UTF-8 text
+     AV_CODEC_ID_XSUB,
+     AV_CODEC_ID_SSA,
+     AV_CODEC_ID_MOV_TEXT,
+     AV_CODEC_ID_HDMV_PGS_SUBTITLE,
+     AV_CODEC_ID_DVB_TELETEXT,
+     AV_CODEC_ID_SRT,
++    AV_CODEC_ID_MICRODVD   = MKBETAG('m','D','V','D'),
++    AV_CODEC_ID_EIA_608    = MKBETAG('c','6','0','8'),
++    AV_CODEC_ID_JACOSUB    = MKBETAG('J','S','U','B'),
++    AV_CODEC_ID_SAMI       = MKBETAG('S','A','M','I'),
++    AV_CODEC_ID_REALTEXT   = MKBETAG('R','T','X','T'),
++    AV_CODEC_ID_SUBVIEWER  = MKBETAG('S','u','b','V'),
  
      /* other specific kind of codecs (generally used for attachments) */
-     CODEC_ID_FIRST_UNKNOWN = 0x18000,           ///< A dummy ID pointing at the start of various fake codecs.
-     CODEC_ID_TTF = 0x18000,
-     CODEC_ID_BINTEXT    = MKBETAG('B','T','X','T'),
-     CODEC_ID_XBIN       = MKBETAG('X','B','I','N'),
-     CODEC_ID_IDF        = MKBETAG( 0 ,'I','D','F'),
+     AV_CODEC_ID_FIRST_UNKNOWN = 0x18000,           ///< A dummy ID pointing at the start of various fake codecs.
+     AV_CODEC_ID_TTF = 0x18000,
++    AV_CODEC_ID_BINTEXT    = MKBETAG('B','T','X','T'),
++    AV_CODEC_ID_XBIN       = MKBETAG('X','B','I','N'),
++    AV_CODEC_ID_IDF        = MKBETAG( 0 ,'I','D','F'),
  
-     CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it
+     AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
  
-     CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
+     AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
                                  * stream (only used by libavformat) */
-     CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
+     AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
                                  * stream (only used by libavformat) */
-     CODEC_ID_FFMETADATA = 0x21000,   ///< Dummy codec for streams containing only metadata information.
+     AV_CODEC_ID_FFMETADATA = 0x21000,   ///< Dummy codec for streams containing only metadata information.
  };
  
  #if FF_API_OLD_DECODE_AUDIO
@@@ -3440,40 -3219,6 +3444,40 @@@ AVFrame *avcodec_alloc_frame(void)
   */
  void avcodec_get_frame_defaults(AVFrame *pic);
  
-  * codec = avcodec_find_decoder(CODEC_ID_H264);
 +#if FF_API_AVCODEC_OPEN
 +/**
 + * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
 + * function the context has to be allocated.
 + *
 + * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
 + * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
 + * retrieving a codec.
 + *
 + * @warning This function is not thread safe!
 + *
 + * @code
 + * avcodec_register_all();
++ * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
 + * if (!codec)
 + *     exit(1);
 + *
 + * context = avcodec_alloc_context3(codec);
 + *
 + * if (avcodec_open(context, codec) < 0)
 + *     exit(1);
 + * @endcode
 + *
 + * @param avctx The context which will be set up to use the given codec.
 + * @param codec The codec to use within the context.
 + * @return zero on success, a negative value on error
 + * @see avcodec_alloc_context3, avcodec_find_decoder, avcodec_find_encoder, avcodec_close
 + *
 + * @deprecated use avcodec_open2
 + */
 +attribute_deprecated
 +int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
 +#endif
 +
  /**
   * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
   * function the context has to be allocated with avcodec_alloc_context3().
@@@ -4593,17 -4323,9 +4597,17 @@@ void avcodec_default_free_buffers(AVCod
   * @param[in] codec_id the codec
   * @return Number of bits per sample or zero if unknown for the given codec.
   */
- int av_get_bits_per_sample(enum CodecID codec_id);
+ int av_get_bits_per_sample(enum AVCodecID codec_id);
  
  /**
-  * @return  CODEC_ID_PCM_* or CODEC_ID_NONE
 + * Return the PCM codec associated with a sample format.
 + * @param be  endianness, 0 for little, 1 for big,
 + *            -1 (or anything else) for native
- enum CodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be);
++ * @return  AV_CODEC_ID_PCM_* or AV_CODEC_ID_NONE
 + */
++enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be);
 +
 +/**
   * Return codec bits per sample.
   * Only return non-zero if the bits per sample is exactly correct, not an
   * approximation.
@@@ -4765,15 -4481,9 +4769,15 @@@ int av_lockmgr_register(int (*cb)(void 
  /**
   * Get the type of the given codec.
   */
- enum AVMediaType avcodec_get_type(enum CodecID codec_id);
+ enum AVMediaType avcodec_get_type(enum AVCodecID codec_id);
  
  /**
- const char *avcodec_get_name(enum CodecID id);
 + * Get the name of a codec.
 + * @return  a static string identifying the codec; never NULL
 + */
++const char *avcodec_get_name(enum AVCodecID id);
 +
 +/**
   * @return a positive value if s is open (i.e. avcodec_open2() was called on it
   * with no corresponding avcodec_close()), 0 otherwise.
   */
Simple merge
index 41f6d9f,0000000..ba07a58
mode 100644,000000..100644
--- /dev/null
@@@ -1,155 -1,0 +1,155 @@@
-     .id           = CODEC_ID_AVUI,
 +/*
 + * AVID Meridien decoder
 + *
 + * Copyright (c) 2012 Carl Eugen Hoyos
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +#include "avcodec.h"
 +#include "libavutil/intreadwrite.h"
 +
 +static av_cold int avui_decode_init(AVCodecContext *avctx)
 +{
 +    avctx->pix_fmt = PIX_FMT_YUVA422P;
 +
 +    avctx->coded_frame = avcodec_alloc_frame();
 +
 +    if (!avctx->coded_frame) {
 +        av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n");
 +        return AVERROR(ENOMEM);
 +    }
 +
 +    return 0;
 +}
 +
 +static int avui_decode_frame(AVCodecContext *avctx, void *data,
 +                             int *data_size, AVPacket *avpkt)
 +{
 +    AVFrame *pic = avctx->coded_frame;
 +    const uint8_t *src = avpkt->data, *extradata = avctx->extradata;
 +    const uint8_t *srca;
 +    uint8_t *y, *u, *v, *a;
 +    int transparent, interlaced = 1, skip, opaque_length, i, j, k;
 +    uint32_t extradata_size = avctx->extradata_size;
 +
 +    if (pic->data[0])
 +        avctx->release_buffer(avctx, pic);
 +
 +    while (extradata_size >= 24) {
 +        uint32_t atom_size = AV_RB32(extradata);
 +        if (!memcmp(&extradata[4], "APRGAPRG0001", 12)) {
 +            interlaced = extradata[19] != 1;
 +            break;
 +        }
 +        if (atom_size && atom_size <= extradata_size) {
 +            extradata      += atom_size;
 +            extradata_size -= atom_size;
 +        } else {
 +            break;
 +        }
 +    }
 +    if (avctx->height == 486) {
 +        skip = 10;
 +    } else {
 +        skip = 16;
 +    }
 +    opaque_length = 2 * avctx->width * (avctx->height + skip) + 4 * interlaced;
 +    if (avpkt->size < opaque_length) {
 +        av_log(avctx, AV_LOG_ERROR, "Insufficient input data.\n");
 +        return AVERROR(EINVAL);
 +    }
 +    transparent = avctx->bits_per_coded_sample == 32 &&
 +                  avpkt->size >= opaque_length * 2 + 4;
 +    srca = src + opaque_length + 5;
 +
 +    pic->reference = 0;
 +
 +    if (avctx->get_buffer(avctx, pic) < 0) {
 +        av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n");
 +        return AVERROR(ENOMEM);
 +    }
 +
 +    pic->key_frame = 1;
 +    pic->pict_type = AV_PICTURE_TYPE_I;
 +
 +    if (!interlaced) {
 +        src  += avctx->width * skip;
 +        srca += avctx->width * skip;
 +    }
 +
 +    for (i = 0; i < interlaced + 1; i++) {
 +        src  += avctx->width * skip;
 +        srca += avctx->width * skip;
 +        if (interlaced && avctx->height == 486) {
 +            y = pic->data[0] + (1 - i) * pic->linesize[0];
 +            u = pic->data[1] + (1 - i) * pic->linesize[1];
 +            v = pic->data[2] + (1 - i) * pic->linesize[2];
 +            a = pic->data[3] + (1 - i) * pic->linesize[3];
 +        } else {
 +            y = pic->data[0] + i * pic->linesize[0];
 +            u = pic->data[1] + i * pic->linesize[1];
 +            v = pic->data[2] + i * pic->linesize[2];
 +            a = pic->data[3] + i * pic->linesize[3];
 +        }
 +
 +        for (j = 0; j < avctx->height >> interlaced; j++) {
 +            for (k = 0; k < avctx->width >> 1; k++) {
 +                u[    k    ] = *src++;
 +                y[2 * k    ] = *src++;
 +                a[2 * k    ] = 0xFF - (transparent ? *srca++ : 0);
 +                srca++;
 +                v[    k    ] = *src++;
 +                y[2 * k + 1] = *src++;
 +                a[2 * k + 1] = 0xFF - (transparent ? *srca++ : 0);
 +                srca++;
 +            }
 +
 +            y += (interlaced + 1) * pic->linesize[0];
 +            u += (interlaced + 1) * pic->linesize[1];
 +            v += (interlaced + 1) * pic->linesize[2];
 +            a += (interlaced + 1) * pic->linesize[3];
 +        }
 +        src  += 4;
 +        srca += 4;
 +    }
 +    *data_size = sizeof(AVFrame);
 +    *(AVFrame *)data = *pic;
 +
 +    return avpkt->size;
 +}
 +
 +static av_cold int avui_decode_close(AVCodecContext *avctx)
 +{
 +    if (avctx->coded_frame->data[0])
 +        avctx->release_buffer(avctx, avctx->coded_frame);
 +
 +    av_freep(&avctx->coded_frame);
 +
 +    return 0;
 +}
 +
 +AVCodec ff_avui_decoder = {
 +    .name         = "avui",
 +    .type         = AVMEDIA_TYPE_VIDEO,
++    .id           = AV_CODEC_ID_AVUI,
 +    .init         = avui_decode_init,
 +    .decode       = avui_decode_frame,
 +    .close        = avui_decode_close,
 +    .capabilities = CODEC_CAP_DR1,
 +    .long_name &