cleanup codec_id mapping (untested)

Originally committed as revision 5195 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Michael Niedermayer 19 years ago
parent f444b977a5
commit 70596d04a8
  1. 139
      libavformat/matroska.c

@ -182,32 +182,46 @@ typedef enum {
* Matroska Codec IDs. Strings.
*/
typedef struct CodecTags{
char *str;
enum CodecID id;
}CodecTags;
#define MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC "V_MS/VFW/FOURCC"
#define MATROSKA_CODEC_ID_VIDEO_UNCOMPRESSED "V_UNCOMPRESSED"
#define MATROSKA_CODEC_ID_VIDEO_MPEG4_SP "V_MPEG4/ISO/SP"
#define MATROSKA_CODEC_ID_VIDEO_MPEG4_ASP "V_MPEG4/ISO/ASP"
#define MATROSKA_CODEC_ID_VIDEO_MPEG4_AP "V_MPEG4/ISO/AP"
#define MATROSKA_CODEC_ID_VIDEO_MPEG4_AVC "V_MPEG4/ISO/AVC"
#define MATROSKA_CODEC_ID_VIDEO_MSMPEG4V3 "V_MPEG4/MS/V3"
#define MATROSKA_CODEC_ID_VIDEO_MPEG1 "V_MPEG1"
#define MATROSKA_CODEC_ID_VIDEO_MPEG2 "V_MPEG2"
#define MATROSKA_CODEC_ID_VIDEO_MJPEG "V_MJPEG"
#define MATROSKA_CODEC_ID_AUDIO_ACM "A_MS/ACM"
CodecTags codec_tags[]={
// {"V_MS/VFW/FOURCC" , CODEC_ID_NONE},
{"V_UNCOMPRESSED" , CODEC_ID_RAWVIDEO},
{"V_MPEG4/ISO/SP" , CODEC_ID_MPEG4},
{"V_MPEG4/ISO/ASP" , CODEC_ID_MPEG4},
{"V_MPEG4/ISO/AP" , CODEC_ID_MPEG4},
{"V_MPEG4/ISO/AVC" , CODEC_ID_H264},
{"V_MPEG4/MS/V3" , CODEC_ID_MSMPEG4V3},
{"V_MPEG1" , CODEC_ID_MPEG1VIDEO},
{"V_MPEG2" , CODEC_ID_MPEG2VIDEO},
{"V_MJPEG" , CODEC_ID_MJPEG},
{"V_REAL/RV10" , CODEC_ID_RV10},
{"V_REAL/RV20" , CODEC_ID_RV20},
{"V_REAL/RV30" , CODEC_ID_RV30},
{"V_REAL/RV40" , CODEC_ID_RV40},
/* TODO: Real/Quicktime */
#define MATROSKA_CODEC_ID_AUDIO_ACM "A_MS/ACM"
#define MATROSKA_CODEC_ID_AUDIO_MPEG1_L1 "A_MPEG/L1"
#define MATROSKA_CODEC_ID_AUDIO_MPEG1_L2 "A_MPEG/L2"
#define MATROSKA_CODEC_ID_AUDIO_MPEG1_L3 "A_MPEG/L3"
#define MATROSKA_CODEC_ID_AUDIO_PCM_INT_BE "A_PCM/INT/BIG"
#define MATROSKA_CODEC_ID_AUDIO_PCM_INT_LE "A_PCM/INT/LIT"
#define MATROSKA_CODEC_ID_AUDIO_PCM_FLOAT "A_PCM/FLOAT/IEEE"
#define MATROSKA_CODEC_ID_AUDIO_AC3 "A_AC3"
#define MATROSKA_CODEC_ID_AUDIO_DTS "A_DTS"
#define MATROSKA_CODEC_ID_AUDIO_VORBIS "A_VORBIS"
#define MATROSKA_CODEC_ID_AUDIO_ACM "A_MS/ACM"
#define MATROSKA_CODEC_ID_AUDIO_MPEG2 "A_AAC/MPEG2/"
#define MATROSKA_CODEC_ID_AUDIO_MPEG4 "A_AAC/MPEG4/"
// {"A_MS/ACM" , CODEC_ID_NONE},
{"A_MPEG/L1" , CODEC_ID_MP3},
{"A_MPEG/L2" , CODEC_ID_MP3},
{"A_MPEG/L3" , CODEC_ID_MP3},
{"A_PCM/INT/BIG" , CODEC_ID_PCM_U16BE},
{"A_PCM/INT/LIT" , CODEC_ID_PCM_U16LE},
// {"A_PCM/FLOAT/IEEE" , CODEC_ID_NONE},
{"A_AC3" , CODEC_ID_AC3},
{"A_DTS" , CODEC_ID_DTS},
{"A_VORBIS" , CODEC_ID_VORBIS},
{"A_AAC/MPEG2/" , CODEC_ID_AAC},
{"A_AAC/MPEG4/" , CODEC_ID_AAC},
{NULL , CODEC_ID_NONE}
/* TODO: AC3-9/10 (?), Real, Musepack, Quicktime */
};
/* max. depth in the EBML tree structure */
#define EBML_MAX_DEPTH 16
@ -2125,14 +2139,14 @@ matroska_read_header (AVFormatContext *s,
/* Have we found a cluster? */
if (res == 1) {
int i;
enum CodecID codec_id;
int i, j;
enum CodecID codec_id= CODEC_ID_NONE;
MatroskaTrack *track;
AVStream *st;
void *extradata = NULL;
int extradata_size = 0;
for (i = 0; i < matroska->num_tracks; i++) {
void *extradata = NULL;
int extradata_size = 0;
track = matroska->tracks[i];
/* libavformat does not really support subtitles.
@ -2141,6 +2155,13 @@ matroska_read_header (AVFormatContext *s,
(track->codec_id == NULL))
continue;
for(j=0; codec_tags[j].str; j++){
if(!strcmp(codec_tags[j].str, track->codec_id)){
codec_id= codec_tags[j].id;
break;
}
}
/* Set the FourCC from the CodecID. */
/* This is the MS compatibility mode which stores a
* BITMAPINFOHEADER in the CodecPrivate. */
@ -2156,27 +2177,7 @@ matroska_read_header (AVFormatContext *s,
(p[2] << 16) | (p[1] << 8) | p[0];
codec_id = codec_get_bmp_id(((MatroskaVideoTrack *)track)->fourcc);
} else if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_VIDEO_MPEG4_SP) ||
!strcmp(track->codec_id,
MATROSKA_CODEC_ID_VIDEO_MPEG4_ASP) ||
!strcmp(track->codec_id,
MATROSKA_CODEC_ID_VIDEO_MPEG4_AP))
codec_id = CODEC_ID_MPEG4;
else if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_VIDEO_MPEG4_AVC))
codec_id = CODEC_ID_H264;
/* else if (!strcmp(track->codec_id, */
/* MATROSKA_CODEC_ID_VIDEO_UNCOMPRESSED)) */
/* codec_id = CODEC_ID_???; */
else if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_VIDEO_MSMPEG4V3))
codec_id = CODEC_ID_MSMPEG4V3;
else if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_VIDEO_MPEG1) ||
!strcmp(track->codec_id,
MATROSKA_CODEC_ID_VIDEO_MPEG2))
codec_id = CODEC_ID_MPEG2VIDEO;
}
/* This is the MS compatibility mode which stores a
* WAVEFORMATEX in the CodecPrivate. */
@ -2192,49 +2193,7 @@ matroska_read_header (AVFormatContext *s,
tag = (p[1] << 8) | p[0];
codec_id = codec_get_wav_id(tag);
} else if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_AUDIO_MPEG1_L1) ||
!strcmp(track->codec_id,
MATROSKA_CODEC_ID_AUDIO_MPEG1_L2) ||
!strcmp(track->codec_id,
MATROSKA_CODEC_ID_AUDIO_MPEG1_L3))
codec_id = CODEC_ID_MP3;
else if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_AUDIO_PCM_INT_BE))
codec_id = CODEC_ID_PCM_U16BE;
else if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_AUDIO_PCM_INT_LE))
codec_id = CODEC_ID_PCM_U16LE;
/* else if (!strcmp(track->codec_id, */
/* MATROSKA_CODEC_ID_AUDIO_PCM_FLOAT)) */
/* codec_id = CODEC_ID_PCM_???; */
else if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_AUDIO_AC3))
codec_id = CODEC_ID_AC3;
else if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_AUDIO_DTS))
codec_id = CODEC_ID_DTS;
/* No such codec id so far. */
/* else if (!strcmp(track->codec_id, */
/* MATROSKA_CODEC_ID_AUDIO_DTS)) */
/* codec_id = CODEC_ID_DTS; */
else if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_AUDIO_VORBIS)) {
extradata_size = track->codec_priv_size;
if(extradata_size) {
extradata = av_malloc(extradata_size);
if(extradata == NULL)
return AVERROR_NOMEM;
memcpy(extradata, track->codec_priv, extradata_size);
}
codec_id = CODEC_ID_VORBIS;
} else if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_AUDIO_MPEG2) ||
!strcmp(track->codec_id,
MATROSKA_CODEC_ID_AUDIO_MPEG4))
codec_id = CODEC_ID_AAC;
else
codec_id = CODEC_ID_NONE;
}
if (codec_id == CODEC_ID_NONE) {
av_log(matroska->ctx, AV_LOG_INFO,

Loading…
Cancel
Save