Mercurial > mplayer.hg
changeset 34155:505b49b171f4
Change codec tag/id conversion to not use ff_codec_bmp_tags/ff_codec_wav_tags.
This fixes linking against latest FFmpeg dynamic libs.
author | reimar |
---|---|
date | Sun, 23 Oct 2011 12:12:43 +0000 |
parents | a42d4bc441d7 |
children | 758264af214d |
files | configure libmpcodecs/ae_lavc.c libmpdemux/demux_lavf.c libmpdemux/mp_taglists.c libmpdemux/mp_taglists.h libmpdemux/muxer_lavf.c |
diffstat | 6 files changed, 51 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/configure Sun Oct 23 12:03:40 2011 +0000 +++ b/configure Sun Oct 23 12:12:43 2011 +0000 @@ -7112,7 +7112,8 @@ else # mpeg1video for vf_lavc, snow for vf_uspp / vf_mcdeint, libavencoders="$mplayer_encoders MPEG1VIDEO_ENCODER SNOW_ENCODER" - libavmuxers="" + # needed for codec id -> tag conversion + libavmuxers="AVI_MUXER" def_muxers='#define CONFIG_MUXERS 0' fi echores "$_mencoder"
--- a/libmpcodecs/ae_lavc.c Sun Oct 23 12:03:40 2011 +0000 +++ b/libmpcodecs/ae_lavc.c Sun Oct 23 12:12:43 2011 +0000 @@ -170,7 +170,7 @@ } if(lavc_param_atag == 0) { - lavc_param_atag = av_codec_get_tag(mp_wav_taglists, lavc_acodec->id); + lavc_param_atag = mp_codec_id2tag(lavc_acodec->id, 0, 1); if(!lavc_param_atag) { mp_msg(MSGT_MENCODER, MSGL_FATAL, "Couldn't find wav tag for specified codec, exit\n");
--- a/libmpdemux/demux_lavf.c Sun Oct 23 12:03:40 2011 +0000 +++ b/libmpdemux/demux_lavf.c Sun Oct 23 12:12:43 2011 +0000 @@ -266,11 +266,7 @@ int stream_id; AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0); AVDictionaryEntry *title= av_dict_get(st->metadata, "title", NULL, 0); - int g, override_tag = av_codec_get_tag(mp_codecid_override_taglists, - codec->codec_id); - // For some formats (like PCM) always trust CODEC_ID_* more than codec_tag - if (override_tag) - codec->codec_tag = override_tag; + int g; switch(codec->codec_type){ case AVMEDIA_TYPE_AUDIO:{ @@ -282,11 +278,7 @@ stream_type = "audio"; priv->astreams[priv->audio_streams] = i; wf= calloc(sizeof(*wf) + codec->extradata_size, 1); - // mp4a tag is used for all mp4 files no matter what they actually contain - if(codec->codec_tag == MKTAG('m', 'p', '4', 'a')) - codec->codec_tag= 0; - if(!codec->codec_tag) - codec->codec_tag= av_codec_get_tag(mp_wav_taglists, codec->codec_id); + codec->codec_tag = mp_codec_id2tag(codec->codec_id, codec->codec_tag, 1); wf->wFormatTag= codec->codec_tag; wf->nChannels= codec->channels; wf->nSamplesPerSec= codec->sample_rate; @@ -364,11 +356,7 @@ codec->codec_tag= MKTAG(24, 'R', 'G', 'B'); } } - // mp4v is sometimes also used for files containing e.g. mjpeg - if(codec->codec_tag == MKTAG('m', 'p', '4', 'v')) - codec->codec_tag= 0; - if(!codec->codec_tag) - codec->codec_tag= av_codec_get_tag(mp_bmp_taglists, codec->codec_id); + codec->codec_tag = mp_codec_id2tag(codec->codec_id, codec->codec_tag, 0); bih->biSize= sizeof(*bih) + codec->extradata_size; bih->biWidth= codec->width; bih->biHeight= codec->height;
--- a/libmpdemux/mp_taglists.c Sun Oct 23 12:03:40 2011 +0000 +++ b/libmpdemux/mp_taglists.c Sun Oct 23 12:12:43 2011 +0000 @@ -18,9 +18,12 @@ #include "config.h" +#include <stdint.h> +#include "mp_msg.h" #include "mp_taglists.h" #include "libavformat/avformat.h" -#include "libavformat/riff.h" +// for AVCodecTag +#include "libavformat/internal.h" static const AVCodecTag mp_wav_tags[] = { { CODEC_ID_ADPCM_4XM, MKTAG('4', 'X', 'M', 'A')}, @@ -60,7 +63,7 @@ { 0, 0 }, }; -const struct AVCodecTag * const mp_wav_taglists[] = {ff_codec_wav_tags, mp_wav_tags, 0}; +static const struct AVCodecTag * const mp_wav_taglists[] = {mp_wav_tags, 0}; static const AVCodecTag mp_codecid_override_tags[] = { { CODEC_ID_8SVX_EXP, MKTAG('8', 'e', 'x', 'p')}, @@ -93,7 +96,7 @@ { 0, 0 }, }; -const struct AVCodecTag * const mp_codecid_override_taglists[] = +static const struct AVCodecTag * const mp_codecid_override_taglists[] = {mp_codecid_override_tags, 0}; static const AVCodecTag mp_bmp_tags[] = { @@ -133,4 +136,37 @@ { 0, 0 }, }; -const struct AVCodecTag * const mp_bmp_taglists[] = {ff_codec_bmp_tags, mp_bmp_tags, 0}; +static const struct AVCodecTag * const mp_bmp_taglists[] = {mp_bmp_tags, 0}; + +enum CodecID mp_tag2codec_id(uint32_t tag, int audio) +{ + return av_codec_get_id(audio ? mp_wav_taglists : mp_bmp_taglists, tag); +} + +uint32_t mp_codec_id2tag(enum CodecID codec_id, uint32_t old_tag, int audio) +{ + AVOutputFormat *avi_format; + // For some formats (like PCM) always trust CODEC_ID_* more than codec_tag + uint32_t tag = av_codec_get_tag(mp_codecid_override_taglists, codec_id); + if (tag) + return tag; + + // mp4a tag is used for all mp4 files no matter what they actually contain + // mp4v is sometimes also used for files containing e.g. mjpeg + if (audio && old_tag != MKTAG('m', 'p', '4', 'a') || + !audio && old_tag != MKTAG('m', 'p', '4', 'v')) + tag = old_tag; + if (tag) + return tag; + + tag = av_codec_get_tag(audio ? mp_wav_taglists : mp_bmp_taglists, codec_id); + if (tag) + return tag; + + avi_format = av_guess_format("avi", NULL, NULL); + if (!avi_format) { + mp_msg(MSGT_DEMUXER, MSGL_FATAL, "MPlayer cannot work properly without AVI muxer in libavformat!\n"); + return 0; + } + return av_codec_get_tag(avi_format->codec_tag, codec_id); +}
--- a/libmpdemux/mp_taglists.h Sun Oct 23 12:03:40 2011 +0000 +++ b/libmpdemux/mp_taglists.h Sun Oct 23 12:12:43 2011 +0000 @@ -19,10 +19,9 @@ #ifndef MPLAYER_MP_TAGLISTS_H #define MPLAYER_MP_TAGLISTS_H -extern const struct AVCodecTag * const mp_wav_taglists[]; +#include <stdint.h> -extern const struct AVCodecTag * const mp_codecid_override_taglists[]; - -extern const struct AVCodecTag * const mp_bmp_taglists[]; +enum CodecID mp_tag2codec_id(uint32_t tag, int audio); +uint32_t mp_codec_id2tag(enum CodecID codec_id, uint32_t old_tag, int audio); #endif /* MPLAYER_MP_TAGLISTS_H */
--- a/libmpdemux/muxer_lavf.c Sun Oct 23 12:03:40 2011 +0000 +++ b/libmpdemux/muxer_lavf.c Sun Oct 23 12:12:43 2011 +0000 @@ -190,7 +190,7 @@ if(stream->type == MUXER_TYPE_AUDIO) { - ctx->codec_id = av_codec_get_id(mp_wav_taglists, stream->wf->wFormatTag); + ctx->codec_id = mp_tag2codec_id(stream->wf->wFormatTag, 1); #if 0 //breaks aac in mov at least ctx->codec_tag = codec_get_wav_tag(ctx->codec_id); #endif @@ -219,7 +219,7 @@ } else if(stream->type == MUXER_TYPE_VIDEO) { - ctx->codec_id = av_codec_get_id(mp_bmp_taglists, stream->bih->biCompression); + ctx->codec_id = mp_tag2codec_id(stream->bih->biCompression, 0); if(ctx->codec_id <= 0 || force_fourcc) ctx->codec_tag= stream->bih->biCompression; mp_msg(MSGT_MUXER, MSGL_INFO, "VIDEO CODEC ID: %d\n", ctx->codec_id);