mirror of
https://github.com/mpv-player/mpv
synced 2025-04-01 23:00:41 +00:00
Use own mp_*_taglists code instead of libavformat internals
Use the version of code under ffmpeg_files/ instead of relying on libavformat source files to be available.
This commit is contained in:
parent
cd4e8dc1fa
commit
9ce0838ffd
@ -26,10 +26,7 @@ extern int lavc_param_atag;
|
||||
extern int lavc_param_audio_global_header;
|
||||
extern int avcodec_initialized;
|
||||
static int compressed_frame_size = 0;
|
||||
#ifdef CONFIG_LIBAVFORMAT
|
||||
#include "libavformat/avformat.h"
|
||||
extern const struct AVCodecTag *mp_wav_taglists[];
|
||||
#endif
|
||||
#include "libmpdemux/mp_taglists.h"
|
||||
|
||||
static int bind_lavc(audio_encoder_t *encoder, muxer_stream_t *mux_a)
|
||||
{
|
||||
@ -133,32 +130,6 @@ static int get_frame_size(audio_encoder_t *encoder)
|
||||
return sz;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_LIBAVFORMAT
|
||||
static uint32_t lavc_find_atag(char *codec)
|
||||
{
|
||||
if(codec == NULL)
|
||||
return 0;
|
||||
|
||||
if(! strcasecmp(codec, "mp2"))
|
||||
return 0x50;
|
||||
|
||||
if(! strcasecmp(codec, "mp3"))
|
||||
return 0x55;
|
||||
|
||||
if(! strcasecmp(codec, "ac3"))
|
||||
return 0x2000;
|
||||
|
||||
if(! strcasecmp(codec, "adpcm_ima_wav"))
|
||||
return 0x11;
|
||||
|
||||
if(! strncasecmp(codec, "bonk", 4))
|
||||
return 0x2048;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int mpae_init_lavc(audio_encoder_t *encoder)
|
||||
{
|
||||
encoder->params.samples_per_frame = encoder->params.sample_rate;
|
||||
@ -184,11 +155,7 @@ int mpae_init_lavc(audio_encoder_t *encoder)
|
||||
}
|
||||
if(lavc_param_atag == 0)
|
||||
{
|
||||
#ifdef CONFIG_LIBAVFORMAT
|
||||
lavc_param_atag = av_codec_get_tag(mp_wav_taglists, lavc_acodec->id);
|
||||
#else
|
||||
lavc_param_atag = lavc_find_atag(lavc_param_acodec);
|
||||
#endif
|
||||
lavc_param_atag = mp_av_codec_get_tag(mp_wav_taglists, lavc_acodec->id);
|
||||
if(!lavc_param_atag)
|
||||
{
|
||||
mp_msg(MSGT_MENCODER, MSGL_FATAL, "Couldn't find wav tag for specified codec, exit\n");
|
||||
|
@ -235,7 +235,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
|
||||
priv->audio_streams++;
|
||||
wf= calloc(sizeof(WAVEFORMATEX) + codec->extradata_size, 1);
|
||||
// For some formats (like PCM) always trust CODEC_ID_* more than codec_tag
|
||||
override_tag= av_codec_get_tag(mp_wav_override_taglists, codec->codec_id);
|
||||
override_tag= mp_av_codec_get_tag(mp_wav_override_taglists, codec->codec_id);
|
||||
if (override_tag)
|
||||
codec->codec_tag= override_tag;
|
||||
// mp4a tag is used for all mp4 files no matter what they actually contain
|
||||
@ -244,7 +244,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
|
||||
if(codec->codec_id == CODEC_ID_ADPCM_IMA_AMV)
|
||||
codec->codec_tag= MKTAG('A','M','V','A');
|
||||
if(!codec->codec_tag)
|
||||
codec->codec_tag= av_codec_get_tag(mp_wav_taglists, codec->codec_id);
|
||||
codec->codec_tag= mp_av_codec_get_tag(mp_wav_taglists, codec->codec_id);
|
||||
wf->wFormatTag= codec->codec_tag;
|
||||
wf->nChannels= codec->channels;
|
||||
wf->nSamplesPerSec= codec->sample_rate;
|
||||
@ -322,7 +322,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
|
||||
}
|
||||
}
|
||||
if(!codec->codec_tag)
|
||||
codec->codec_tag= av_codec_get_tag(mp_bmp_taglists, codec->codec_id);
|
||||
codec->codec_tag= mp_av_codec_get_tag(mp_bmp_taglists, codec->codec_id);
|
||||
bih->biSize= sizeof(BITMAPINFOHEADER) + codec->extradata_size;
|
||||
bih->biWidth= codec->width;
|
||||
bih->biHeight= codec->height;
|
||||
|
@ -19,9 +19,13 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "libavformat/avformat.h"
|
||||
#include "libavformat/riff.h"
|
||||
#include <libavcodec/avcodec.h>
|
||||
|
||||
static const AVCodecTag mp_wav_tags[] = {
|
||||
#include "mp_taglists.h"
|
||||
|
||||
#include "ffmpeg_files/taglists.c"
|
||||
|
||||
static const struct mp_AVCodecTag mp_wav_tags[] = {
|
||||
{ CODEC_ID_RA_144, MKTAG('1', '4', '_', '4')},
|
||||
{ CODEC_ID_RA_288, MKTAG('2', '8', '_', '8')},
|
||||
{ CODEC_ID_ADPCM_4XM, MKTAG('4', 'X', 'M', 'A')},
|
||||
@ -51,9 +55,9 @@ static const AVCodecTag mp_wav_tags[] = {
|
||||
{ 0, 0 },
|
||||
};
|
||||
|
||||
const struct AVCodecTag *mp_wav_taglists[] = {ff_codec_wav_tags, mp_wav_tags, 0};
|
||||
const struct mp_AVCodecTag *mp_wav_taglists[] = {mp_ff_codec_wav_tags, mp_wav_tags, 0};
|
||||
|
||||
static const AVCodecTag mp_wav_override_tags[] = {
|
||||
static const struct mp_AVCodecTag mp_wav_override_tags[] = {
|
||||
{ CODEC_ID_PCM_S8, MKTAG('t', 'w', 'o', 's')},
|
||||
{ CODEC_ID_PCM_U8, 1},
|
||||
{ CODEC_ID_PCM_S16BE, MKTAG('t', 'w', 'o', 's')},
|
||||
@ -65,9 +69,9 @@ static const AVCodecTag mp_wav_override_tags[] = {
|
||||
{ 0, 0 },
|
||||
};
|
||||
|
||||
const struct AVCodecTag *mp_wav_override_taglists[] = {mp_wav_override_tags, 0};
|
||||
const struct mp_AVCodecTag *mp_wav_override_taglists[] = {mp_wav_override_tags, 0};
|
||||
|
||||
static const AVCodecTag mp_bmp_tags[] = {
|
||||
static const struct mp_AVCodecTag mp_bmp_tags[] = {
|
||||
{ CODEC_ID_AMV, MKTAG('A', 'M', 'V', 'V')},
|
||||
{ CODEC_ID_BETHSOFTVID, MKTAG('B', 'E', 'T', 'H')},
|
||||
{ CODEC_ID_BFI, MKTAG('B', 'F', 'I', 'V')},
|
||||
@ -96,4 +100,4 @@ static const AVCodecTag mp_bmp_tags[] = {
|
||||
{ 0, 0 },
|
||||
};
|
||||
|
||||
const struct AVCodecTag *mp_bmp_taglists[] = {ff_codec_bmp_tags, mp_bmp_tags, 0};
|
||||
const struct mp_AVCodecTag *mp_bmp_taglists[] = {mp_ff_codec_bmp_tags, mp_bmp_tags, 0};
|
||||
|
@ -19,10 +19,14 @@
|
||||
#ifndef MPLAYER_MP_TAGLISTS_H
|
||||
#define MPLAYER_MP_TAGLISTS_H
|
||||
|
||||
extern const struct AVCodecTag *mp_wav_taglists[];
|
||||
#include <libavcodec/avcodec.h>
|
||||
|
||||
extern const struct AVCodecTag *mp_wav_override_taglists[];
|
||||
#include "ffmpeg_files/taglists.h"
|
||||
|
||||
extern const struct AVCodecTag *mp_bmp_taglists[];
|
||||
extern const struct mp_AVCodecTag *mp_wav_taglists[];
|
||||
|
||||
extern const struct mp_AVCodecTag *mp_wav_override_taglists[];
|
||||
|
||||
extern const struct mp_AVCodecTag *mp_bmp_taglists[];
|
||||
|
||||
#endif /* MPLAYER_MP_TAGLISTS_H */
|
||||
|
@ -197,7 +197,7 @@ static void fix_parameters(muxer_stream_t *stream)
|
||||
|
||||
if(stream->type == MUXER_TYPE_AUDIO)
|
||||
{
|
||||
ctx->codec_id = av_codec_get_id(mp_wav_taglists, stream->wf->wFormatTag);
|
||||
ctx->codec_id = mp_av_codec_get_id(mp_wav_taglists, stream->wf->wFormatTag);
|
||||
#if 0 //breaks aac in mov at least
|
||||
ctx->codec_tag = codec_get_wav_tag(ctx->codec_id);
|
||||
#endif
|
||||
@ -226,7 +226,7 @@ static void fix_parameters(muxer_stream_t *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_av_codec_get_id(mp_bmp_taglists, stream->bih->biCompression);
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user