[MPlayer-cvslog] r34243 - in trunk: configure libmpcodecs/ae_lavc.c libmpdemux/demux_lavf.c libmpdemux/mp_taglists.c libmpdemux/mp_taglists.h libmpdemux/muxer_lavf.c
reimar
subversion at mplayerhq.hu
Sun Oct 23 14:12:43 CEST 2011
Author: reimar
Date: Sun Oct 23 14:12:43 2011
New Revision: 34243
Log:
Change codec tag/id conversion to not use ff_codec_bmp_tags/ff_codec_wav_tags.
This fixes linking against latest FFmpeg dynamic libs.
Modified:
trunk/configure
trunk/libmpcodecs/ae_lavc.c
trunk/libmpdemux/demux_lavf.c
trunk/libmpdemux/mp_taglists.c
trunk/libmpdemux/mp_taglists.h
trunk/libmpdemux/muxer_lavf.c
Modified: trunk/configure
==============================================================================
--- trunk/configure Sun Oct 23 14:03:40 2011 (r34242)
+++ trunk/configure Sun Oct 23 14:12:43 2011 (r34243)
@@ -7112,7 +7112,8 @@ if test "$_mencoder" = yes ; then
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"
Modified: trunk/libmpcodecs/ae_lavc.c
==============================================================================
--- trunk/libmpcodecs/ae_lavc.c Sun Oct 23 14:03:40 2011 (r34242)
+++ trunk/libmpcodecs/ae_lavc.c Sun Oct 23 14:12:43 2011 (r34243)
@@ -170,7 +170,7 @@ int mpae_init_lavc(audio_encoder_t *enco
}
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");
Modified: trunk/libmpdemux/demux_lavf.c
==============================================================================
--- trunk/libmpdemux/demux_lavf.c Sun Oct 23 14:03:40 2011 (r34242)
+++ trunk/libmpdemux/demux_lavf.c Sun Oct 23 14:12:43 2011 (r34243)
@@ -266,11 +266,7 @@ static void handle_stream(demuxer_t *dem
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 @@ static void handle_stream(demuxer_t *dem
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 @@ static void handle_stream(demuxer_t *dem
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;
Modified: trunk/libmpdemux/mp_taglists.c
==============================================================================
--- trunk/libmpdemux/mp_taglists.c Sun Oct 23 14:03:40 2011 (r34242)
+++ trunk/libmpdemux/mp_taglists.c Sun Oct 23 14:12:43 2011 (r34243)
@@ -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 @@ static const AVCodecTag mp_wav_tags[] =
{ 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 @@ static const AVCodecTag mp_codecid_overr
{ 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 @@ static const AVCodecTag mp_bmp_tags[] =
{ 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);
+}
Modified: trunk/libmpdemux/mp_taglists.h
==============================================================================
--- trunk/libmpdemux/mp_taglists.h Sun Oct 23 14:03:40 2011 (r34242)
+++ trunk/libmpdemux/mp_taglists.h Sun Oct 23 14:12:43 2011 (r34243)
@@ -19,10 +19,9 @@
#ifndef MPLAYER_MP_TAGLISTS_H
#define MPLAYER_MP_TAGLISTS_H
-extern const struct AVCodecTag * const mp_wav_taglists[];
-
-extern const struct AVCodecTag * const mp_codecid_override_taglists[];
+#include <stdint.h>
-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 */
Modified: trunk/libmpdemux/muxer_lavf.c
==============================================================================
--- trunk/libmpdemux/muxer_lavf.c Sun Oct 23 14:03:40 2011 (r34242)
+++ trunk/libmpdemux/muxer_lavf.c Sun Oct 23 14:12:43 2011 (r34243)
@@ -190,7 +190,7 @@ static void fix_parameters(muxer_stream_
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 @@ static void fix_parameters(muxer_stream_
}
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);
More information about the MPlayer-cvslog
mailing list