Commit 7caf0cc6 authored by Michael Niedermayer's avatar Michael Niedermayer

add codec_id <-> codec_tag tables to AVIn/OutputFormat

Originally committed as revision 7593 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 5c4e1928
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "riff.h" #include "riff.h"
#include "intfloat_readwrite.h" #include "intfloat_readwrite.h"
static const CodecTag codec_aiff_tags[] = { static const AVCodecTag codec_aiff_tags[] = {
{ CODEC_ID_PCM_S16BE, MKTAG('N','O','N','E') }, { CODEC_ID_PCM_S16BE, MKTAG('N','O','N','E') },
{ CODEC_ID_PCM_S8, MKTAG('N','O','N','E') }, { CODEC_ID_PCM_S8, MKTAG('N','O','N','E') },
{ CODEC_ID_PCM_S24BE, MKTAG('N','O','N','E') }, { CODEC_ID_PCM_S24BE, MKTAG('N','O','N','E') },
......
...@@ -187,6 +187,13 @@ ...@@ -187,6 +187,13 @@
2*PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS \ 2*PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS \
) )
static const AVCodecTag codec_asf_bmp_tags[] = {
{ CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
{ CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
{ CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },
{ CODEC_ID_NONE, 0 },
};
static int preroll_time = 2000; static int preroll_time = 2000;
static const uint8_t error_spread_ADPCM_G726[] = { 0x01, 0x90, 0x01, 0x90, 0x01, 0x01, 0x00, 0x00 }; static const uint8_t error_spread_ADPCM_G726[] = { 0x01, 0x90, 0x01, 0x90, 0x01, 0x01, 0x00, 0x00 };
...@@ -842,6 +849,7 @@ AVOutputFormat asf_muxer = { ...@@ -842,6 +849,7 @@ AVOutputFormat asf_muxer = {
asf_write_packet, asf_write_packet,
asf_write_trailer, asf_write_trailer,
.flags = AVFMT_GLOBALHEADER, .flags = AVFMT_GLOBALHEADER,
.codec_tag= {codec_asf_bmp_tags, codec_bmp_tags, codec_wav_tags},
}; };
#endif #endif
...@@ -862,5 +870,6 @@ AVOutputFormat asf_stream_muxer = { ...@@ -862,5 +870,6 @@ AVOutputFormat asf_stream_muxer = {
asf_write_packet, asf_write_packet,
asf_write_trailer, asf_write_trailer,
.flags = AVFMT_GLOBALHEADER, .flags = AVFMT_GLOBALHEADER,
.codec_tag= {codec_asf_bmp_tags, codec_bmp_tags, codec_wav_tags},
}; };
#endif //CONFIG_ASF_STREAM_MUXER #endif //CONFIG_ASF_STREAM_MUXER
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#define AU_UNKOWN_SIZE ((uint32_t)(~0)) #define AU_UNKOWN_SIZE ((uint32_t)(~0))
/* The ffmpeg codecs we support, and the IDs they have in the file */ /* The ffmpeg codecs we support, and the IDs they have in the file */
static const CodecTag codec_au_tags[] = { static const AVCodecTag codec_au_tags[] = {
{ CODEC_ID_PCM_MULAW, 1 }, { CODEC_ID_PCM_MULAW, 1 },
{ CODEC_ID_PCM_S16BE, 3 }, { CODEC_ID_PCM_S16BE, 3 },
{ CODEC_ID_PCM_ALAW, 27 }, { CODEC_ID_PCM_ALAW, 27 },
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
extern "C" { extern "C" {
#endif #endif
#define LIBAVFORMAT_VERSION_INT ((51<<16)+(7<<8)+0) #define LIBAVFORMAT_VERSION_INT ((51<<16)+(8<<8)+0)
#define LIBAVFORMAT_VERSION 51.7.0 #define LIBAVFORMAT_VERSION 51.8.0
#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT #define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION) #define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
...@@ -96,6 +96,8 @@ typedef struct AVFrac { ...@@ -96,6 +96,8 @@ typedef struct AVFrac {
/*************************************************/ /*************************************************/
/* input/output formats */ /* input/output formats */
struct AVCodecTag;
struct AVFormatContext; struct AVFormatContext;
/* this structure contains the data a format has to probe a file */ /* this structure contains the data a format has to probe a file */
...@@ -155,6 +157,13 @@ typedef struct AVOutputFormat { ...@@ -155,6 +157,13 @@ typedef struct AVOutputFormat {
/* currently only used to set pixel format if not YUV420P */ /* currently only used to set pixel format if not YUV420P */
int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *); int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush); int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush);
/**
* list of supported codec_id-codec_tag pairs, ordered by "better choice first"
* the arrays are all CODEC_ID_NONE terminated
*/
const struct AVCodecTag *codec_tag[4];
/* private fields */ /* private fields */
struct AVOutputFormat *next; struct AVOutputFormat *next;
} AVOutputFormat; } AVOutputFormat;
...@@ -210,6 +219,8 @@ typedef struct AVInputFormat { ...@@ -210,6 +219,8 @@ typedef struct AVInputFormat {
(RTSP) */ (RTSP) */
int (*read_pause)(struct AVFormatContext *); int (*read_pause)(struct AVFormatContext *);
const struct AVCodecTag *codec_tag[4];
/* private fields */ /* private fields */
struct AVInputFormat *next; struct AVInputFormat *next;
} AVInputFormat; } AVInputFormat;
...@@ -396,6 +407,10 @@ void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); ...@@ -396,6 +407,10 @@ void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
void av_register_all(void); void av_register_all(void);
/* codec tag <-> codec id */
enum CodecID av_codec_get_id(const struct AVCodecTag *tags[4], unsigned int tag);
unsigned int av_codec_get_tag(const struct AVCodecTag *tags[4], enum CodecID id);
/* media file input */ /* media file input */
AVInputFormat *av_find_input_format(const char *short_name); AVInputFormat *av_find_input_format(const char *short_name);
AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened); AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
......
...@@ -575,5 +575,6 @@ AVOutputFormat avi_muxer = { ...@@ -575,5 +575,6 @@ AVOutputFormat avi_muxer = {
avi_write_header, avi_write_header,
avi_write_packet, avi_write_packet,
avi_write_trailer, avi_write_trailer,
.codec_tag= {codec_bmp_tags, codec_wav_tags},
}; };
#endif //CONFIG_AVI_MUXER #endif //CONFIG_AVI_MUXER
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#undef NDEBUG #undef NDEBUG
#include <assert.h> #include <assert.h>
static const CodecTag flv_video_codec_ids[] = { static const AVCodecTag flv_video_codec_ids[] = {
{CODEC_ID_FLV1, FLV_CODECID_H263 }, {CODEC_ID_FLV1, FLV_CODECID_H263 },
{CODEC_ID_FLASHSV, FLV_CODECID_SCREEN}, {CODEC_ID_FLASHSV, FLV_CODECID_SCREEN},
{CODEC_ID_VP6F, FLV_CODECID_VP6 }, {CODEC_ID_VP6F, FLV_CODECID_VP6 },
...@@ -33,7 +33,7 @@ static const CodecTag flv_video_codec_ids[] = { ...@@ -33,7 +33,7 @@ static const CodecTag flv_video_codec_ids[] = {
{CODEC_ID_NONE, 0} {CODEC_ID_NONE, 0}
}; };
static const CodecTag flv_audio_codec_ids[] = { static const AVCodecTag flv_audio_codec_ids[] = {
{CODEC_ID_MP3, FLV_CODECID_MP3 >> FLV_AUDIO_CODECID_OFFSET}, {CODEC_ID_MP3, FLV_CODECID_MP3 >> FLV_AUDIO_CODECID_OFFSET},
{CODEC_ID_PCM_S8, FLV_CODECID_PCM_BE >> FLV_AUDIO_CODECID_OFFSET}, {CODEC_ID_PCM_S8, FLV_CODECID_PCM_BE >> FLV_AUDIO_CODECID_OFFSET},
{CODEC_ID_PCM_S16BE, FLV_CODECID_PCM_BE >> FLV_AUDIO_CODECID_OFFSET}, {CODEC_ID_PCM_S16BE, FLV_CODECID_PCM_BE >> FLV_AUDIO_CODECID_OFFSET},
......
...@@ -85,7 +85,7 @@ static const GXF_Lines gxf_lines_tab[] = { ...@@ -85,7 +85,7 @@ static const GXF_Lines gxf_lines_tab[] = {
{ 720, 6 }, { 720, 6 },
}; };
static const CodecTag gxf_media_types[] = { static const AVCodecTag gxf_media_types[] = {
{ CODEC_ID_MJPEG , 3 }, /* NTSC */ { CODEC_ID_MJPEG , 3 }, /* NTSC */
{ CODEC_ID_MJPEG , 4 }, /* PAL */ { CODEC_ID_MJPEG , 4 }, /* PAL */
{ CODEC_ID_PCM_S24LE , 9 }, { CODEC_ID_PCM_S24LE , 9 },
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "isom.h" #include "isom.h"
/* http://gpac.sourceforge.net/tutorial/mediatypes.htm */ /* http://gpac.sourceforge.net/tutorial/mediatypes.htm */
const CodecTag ff_mov_obj_type[] = { const AVCodecTag ff_mov_obj_type[] = {
{ CODEC_ID_MPEG4 , 32 }, { CODEC_ID_MPEG4 , 32 },
{ CODEC_ID_H264 , 33 }, { CODEC_ID_H264 , 33 },
{ CODEC_ID_AAC , 64 }, { CODEC_ID_AAC , 64 },
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#define FFMPEG_ISOM_H #define FFMPEG_ISOM_H
/* isom.c */ /* isom.c */
extern const CodecTag ff_mov_obj_type[]; extern const AVCodecTag ff_mov_obj_type[];
int ff_mov_iso639_to_lang(const char *lang, int mp4); int ff_mov_iso639_to_lang(const char *lang, int mp4);
int ff_mov_lang_to_iso639(int code, char *to); int ff_mov_lang_to_iso639(int code, char *to);
......
...@@ -10,7 +10,7 @@ typedef struct { ...@@ -10,7 +10,7 @@ typedef struct {
nut_stream_header_t * s; nut_stream_header_t * s;
} NUTContext; } NUTContext;
static const CodecTag nut_tags[] = { static const AVCodecTag nut_tags[] = {
{ CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') }, { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
{ CODEC_ID_MP3, MKTAG('m', 'p', '3', ' ') }, { CODEC_ID_MP3, MKTAG('m', 'p', '3', ' ') },
{ CODEC_ID_VORBIS, MKTAG('v', 'r', 'b', 's') }, { CODEC_ID_VORBIS, MKTAG('v', 'r', 'b', 's') },
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
#undef NDEBUG #undef NDEBUG
#include <assert.h> #include <assert.h>
static const CodecTag mov_video_tags[] = { static const AVCodecTag mov_video_tags[] = {
/* { CODEC_ID_, MKTAG('c', 'v', 'i', 'd') }, *//* Cinepak */ /* { CODEC_ID_, MKTAG('c', 'v', 'i', 'd') }, *//* Cinepak */
/* { CODEC_ID_H263, MKTAG('r', 'a', 'w', ' ') }, *//* Uncompressed RGB */ /* { CODEC_ID_H263, MKTAG('r', 'a', 'w', ' ') }, *//* Uncompressed RGB */
/* { CODEC_ID_H263, MKTAG('Y', 'u', 'v', '2') }, *//* Uncompressed YUV422 */ /* { CODEC_ID_H263, MKTAG('Y', 'u', 'v', '2') }, *//* Uncompressed YUV422 */
...@@ -127,7 +127,7 @@ static const CodecTag mov_video_tags[] = { ...@@ -127,7 +127,7 @@ static const CodecTag mov_video_tags[] = {
{ CODEC_ID_NONE, 0 }, { CODEC_ID_NONE, 0 },
}; };
static const CodecTag mov_audio_tags[] = { static const AVCodecTag mov_audio_tags[] = {
{ CODEC_ID_PCM_S32BE, MKTAG('i', 'n', '3', '2') }, { CODEC_ID_PCM_S32BE, MKTAG('i', 'n', '3', '2') },
{ CODEC_ID_PCM_S24BE, MKTAG('i', 'n', '2', '4') }, { CODEC_ID_PCM_S24BE, MKTAG('i', 'n', '2', '4') },
{ CODEC_ID_PCM_S16BE, MKTAG('N', 'O', 'N', 'E') }, /* uncompressed */ { CODEC_ID_PCM_S16BE, MKTAG('N', 'O', 'N', 'E') }, /* uncompressed */
......
...@@ -322,7 +322,7 @@ static int mov_write_wave_tag(ByteIOContext *pb, MOVTrack* track) ...@@ -322,7 +322,7 @@ static int mov_write_wave_tag(ByteIOContext *pb, MOVTrack* track)
return updateSize (pb, pos); return updateSize (pb, pos);
} }
static const CodecTag codec_movaudio_tags[] = { static const AVCodecTag codec_movaudio_tags[] = {
{ CODEC_ID_PCM_MULAW, MKTAG('u', 'l', 'a', 'w') }, { CODEC_ID_PCM_MULAW, MKTAG('u', 'l', 'a', 'w') },
{ CODEC_ID_PCM_ALAW, MKTAG('a', 'l', 'a', 'w') }, { CODEC_ID_PCM_ALAW, MKTAG('a', 'l', 'a', 'w') },
{ CODEC_ID_ADPCM_IMA_QT, MKTAG('i', 'm', 'a', '4') }, { CODEC_ID_ADPCM_IMA_QT, MKTAG('i', 'm', 'a', '4') },
...@@ -526,7 +526,7 @@ static int mov_write_avcc_tag(ByteIOContext *pb, MOVTrack *track) ...@@ -526,7 +526,7 @@ static int mov_write_avcc_tag(ByteIOContext *pb, MOVTrack *track)
return updateSize(pb, pos); return updateSize(pb, pos);
} }
static const CodecTag codec_movvideo_tags[] = { static const AVCodecTag codec_movvideo_tags[] = {
{ CODEC_ID_SVQ1, MKTAG('S', 'V', 'Q', '1') }, { CODEC_ID_SVQ1, MKTAG('S', 'V', 'Q', '1') },
{ CODEC_ID_SVQ3, MKTAG('S', 'V', 'Q', '3') }, { CODEC_ID_SVQ3, MKTAG('S', 'V', 'Q', '3') },
{ CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') }, { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
......
...@@ -183,7 +183,7 @@ typedef struct { ...@@ -183,7 +183,7 @@ typedef struct {
//DVDemuxContext* dv_demux; //DVDemuxContext* dv_demux;
} NSVContext; } NSVContext;
static const CodecTag nsv_codec_video_tags[] = { static const AVCodecTag nsv_codec_video_tags[] = {
{ CODEC_ID_VP3, MKTAG('V', 'P', '3', ' ') }, { CODEC_ID_VP3, MKTAG('V', 'P', '3', ' ') },
{ CODEC_ID_VP3, MKTAG('V', 'P', '3', '0') }, { CODEC_ID_VP3, MKTAG('V', 'P', '3', '0') },
{ CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') }, { CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') },
...@@ -202,7 +202,7 @@ static const CodecTag nsv_codec_video_tags[] = { ...@@ -202,7 +202,7 @@ static const CodecTag nsv_codec_video_tags[] = {
{ 0, 0 }, { 0, 0 },
}; };
static const CodecTag nsv_codec_audio_tags[] = { static const AVCodecTag nsv_codec_audio_tags[] = {
{ CODEC_ID_MP3, MKTAG('M', 'P', '3', ' ') }, { CODEC_ID_MP3, MKTAG('M', 'P', '3', ' ') },
{ CODEC_ID_AAC, MKTAG('A', 'A', 'C', ' ') }, { CODEC_ID_AAC, MKTAG('A', 'A', 'C', ' ') },
{ CODEC_ID_AAC, MKTAG('A', 'A', 'C', 'P') }, /* _CUTTED__MUXED_2 Heads - Out Of The City.nsv */ { CODEC_ID_AAC, MKTAG('A', 'A', 'C', 'P') }, /* _CUTTED__MUXED_2 Heads - Out Of The City.nsv */
......
...@@ -22,10 +22,11 @@ ...@@ -22,10 +22,11 @@
#include "avformat.h" #include "avformat.h"
#include "avcodec.h" #include "avcodec.h"
#include "riff.h" #include "riff.h"
#include "allformats.h" // for asf_muxer
/* Note: when encoding, the first matching tag is used, so order is /* Note: when encoding, the first matching tag is used, so order is
important if multiple tags possible for a given codec. */ important if multiple tags possible for a given codec. */
const CodecTag codec_bmp_tags[] = { const AVCodecTag codec_bmp_tags[] = {
{ CODEC_ID_H264, MKTAG('H', '2', '6', '4') }, { CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
{ CODEC_ID_H264, MKTAG('h', '2', '6', '4') }, { CODEC_ID_H264, MKTAG('h', '2', '6', '4') },
{ CODEC_ID_H264, MKTAG('X', '2', '6', '4') }, { CODEC_ID_H264, MKTAG('X', '2', '6', '4') },
...@@ -42,10 +43,10 @@ const CodecTag codec_bmp_tags[] = { ...@@ -42,10 +43,10 @@ const CodecTag codec_bmp_tags[] = {
{ CODEC_ID_H263P, MKTAG('U', '2', '6', '3') }, { CODEC_ID_H263P, MKTAG('U', '2', '6', '3') },
{ CODEC_ID_H263P, MKTAG('v', 'i', 'v', '1') }, { CODEC_ID_H263P, MKTAG('v', 'i', 'v', '1') },
{ CODEC_ID_MPEG4, MKTAG('F', 'M', 'P', '4')}, { CODEC_ID_MPEG4, MKTAG('F', 'M', 'P', '4') },
{ CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X'), .invalid_asf = 1 }, { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') },
{ CODEC_ID_MPEG4, MKTAG('D', 'X', '5', '0'), .invalid_asf = 1 }, { CODEC_ID_MPEG4, MKTAG('D', 'X', '5', '0') },
{ CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D'), .invalid_asf = 1 }, { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') },
{ CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') }, { CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
{ CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') }, { CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
{ CODEC_ID_MPEG4, MKTAG(0x04, 0, 0, 0) }, /* some broken avi use this */ { CODEC_ID_MPEG4, MKTAG(0x04, 0, 0, 0) }, /* some broken avi use this */
...@@ -60,7 +61,7 @@ const CodecTag codec_bmp_tags[] = { ...@@ -60,7 +61,7 @@ const CodecTag codec_bmp_tags[] = {
{ CODEC_ID_MPEG4, MKTAG('R', 'M', 'P', '4') }, { CODEC_ID_MPEG4, MKTAG('R', 'M', 'P', '4') },
{ CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3'), .invalid_asf = 1 }, /* default signature when using MSMPEG4 */ { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') }, /* default signature when using MSMPEG4 */
{ CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') }, { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },
/* added based on MPlayer */ /* added based on MPlayer */
...@@ -168,7 +169,7 @@ const CodecTag codec_bmp_tags[] = { ...@@ -168,7 +169,7 @@ const CodecTag codec_bmp_tags[] = {
{ CODEC_ID_NONE, 0 }, { CODEC_ID_NONE, 0 },
}; };
const CodecTag codec_wav_tags[] = { const AVCodecTag codec_wav_tags[] = {
{ CODEC_ID_MP2, 0x50 }, { CODEC_ID_MP2, 0x50 },
{ CODEC_ID_MP3, 0x55 }, { CODEC_ID_MP3, 0x55 },
{ CODEC_ID_AC3, 0x2000 }, { CODEC_ID_AC3, 0x2000 },
...@@ -206,7 +207,7 @@ const CodecTag codec_wav_tags[] = { ...@@ -206,7 +207,7 @@ const CodecTag codec_wav_tags[] = {
{ 0, 0 }, { 0, 0 },
}; };
unsigned int codec_get_tag(const CodecTag *tags, int id) unsigned int codec_get_tag(const AVCodecTag *tags, int id)
{ {
while (tags->id != CODEC_ID_NONE) { while (tags->id != CODEC_ID_NONE) {
if (tags->id == id) if (tags->id == id)
...@@ -216,17 +217,7 @@ unsigned int codec_get_tag(const CodecTag *tags, int id) ...@@ -216,17 +217,7 @@ unsigned int codec_get_tag(const CodecTag *tags, int id)
return 0; return 0;
} }
unsigned int codec_get_asf_tag(const CodecTag *tags, unsigned int id) enum CodecID codec_get_id(const AVCodecTag *tags, unsigned int tag)
{
while (tags->id != CODEC_ID_NONE) {
if (!tags->invalid_asf && tags->id == id)
return tags->tag;
tags++;
}
return 0;
}
enum CodecID codec_get_id(const CodecTag *tags, unsigned int tag)
{ {
while (tags->id != CODEC_ID_NONE) { while (tags->id != CODEC_ID_NONE) {
if( toupper((tag >> 0)&0xFF) == toupper((tags->tag >> 0)&0xFF) if( toupper((tag >> 0)&0xFF) == toupper((tags->tag >> 0)&0xFF)
...@@ -239,6 +230,26 @@ enum CodecID codec_get_id(const CodecTag *tags, unsigned int tag) ...@@ -239,6 +230,26 @@ enum CodecID codec_get_id(const CodecTag *tags, unsigned int tag)
return CODEC_ID_NONE; return CODEC_ID_NONE;
} }
unsigned int av_codec_get_tag(const AVCodecTag *tags[4], enum CodecID id)
{
int i;
for(i=0; i<4 && tags[i]; i++){
int tag= codec_get_tag(tags[i], id);
if(tag) return tag;
}
return 0;
}
enum CodecID av_codec_get_id(const AVCodecTag *tags[4], unsigned int tag)
{
int i;
for(i=0; i<4 && tags[i]; i++){
enum CodecID id= codec_get_id(tags[i], tag);
if(id!=CODEC_ID_NONE) return id;
}
return CODEC_ID_NONE;
}
unsigned int codec_get_bmp_tag(int id) unsigned int codec_get_bmp_tag(int id)
{ {
return codec_get_tag(codec_bmp_tags, id); return codec_get_tag(codec_bmp_tags, id);
...@@ -367,7 +378,7 @@ int put_wav_header(ByteIOContext *pb, AVCodecContext *enc) ...@@ -367,7 +378,7 @@ int put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
} }
/* BITMAPINFOHEADER header */ /* BITMAPINFOHEADER header */
void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const CodecTag *tags, int for_asf) void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf)
{ {
put_le32(pb, 40 + enc->extradata_size); /* size */ put_le32(pb, 40 + enc->extradata_size); /* size */
put_le32(pb, enc->width); put_le32(pb, enc->width);
...@@ -376,7 +387,7 @@ void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const CodecTag *tags ...@@ -376,7 +387,7 @@ void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const CodecTag *tags
put_le16(pb, enc->bits_per_sample ? enc->bits_per_sample : 24); /* depth */ put_le16(pb, enc->bits_per_sample ? enc->bits_per_sample : 24); /* depth */
/* compression type */ /* compression type */
put_le32(pb, for_asf ? (enc->codec_tag ? enc->codec_tag : codec_get_asf_tag(tags, enc->codec_id)) : enc->codec_tag); // put_le32(pb, for_asf ? (enc->codec_tag ? enc->codec_tag : av_codec_get_tag(asf_muxer.codec_tag, enc->codec_id)) : enc->codec_tag); //
put_le32(pb, enc->width * enc->height * 3); put_le32(pb, enc->width * enc->height * 3);
put_le32(pb, 0); put_le32(pb, 0);
put_le32(pb, 0); put_le32(pb, 0);
......
...@@ -19,33 +19,37 @@ ...@@ -19,33 +19,37 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
/**
* @file riff.h
* internal header for RIFF based (de)muxers
* do NOT include this in end user applications
*/
#ifndef FF_RIFF_H #ifndef FF_RIFF_H
#define FF_RIFF_H #define FF_RIFF_H
offset_t start_tag(ByteIOContext *pb, const char *tag); offset_t start_tag(ByteIOContext *pb, const char *tag);
void end_tag(ByteIOContext *pb, offset_t start); void end_tag(ByteIOContext *pb, offset_t start);
typedef struct CodecTag { typedef struct AVCodecTag {
int id; int id;
unsigned int tag; unsigned int tag;
unsigned int invalid_asf : 1; } AVCodecTag;
} CodecTag;
void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const CodecTag *tags, int for_asf); void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf);
int put_wav_header(ByteIOContext *pb, AVCodecContext *enc); int put_wav_header(ByteIOContext *pb, AVCodecContext *enc);
int wav_codec_get_id(unsigned int tag, int bps); int wav_codec_get_id(unsigned int tag, int bps);
void get_wav_header(ByteIOContext *pb, AVCodecContext *codec, int size); void get_wav_header(ByteIOContext *pb, AVCodecContext *codec, int size);
extern const CodecTag codec_bmp_tags[]; extern const AVCodecTag codec_bmp_tags[];
extern const CodecTag codec_wav_tags[]; extern const AVCodecTag codec_wav_tags[];
unsigned int codec_get_tag(const CodecTag *tags, int id); unsigned int codec_get_tag(const AVCodecTag *tags, int id);
enum CodecID codec_get_id(const CodecTag *tags, unsigned int tag); enum CodecID codec_get_id(const AVCodecTag *tags, unsigned int tag);
unsigned int codec_get_bmp_tag(int id); unsigned int codec_get_bmp_tag(int id) attribute_deprecated; //use av_codec_get_tag
unsigned int codec_get_wav_tag(int id); unsigned int codec_get_wav_tag(int id) attribute_deprecated; //use av_codec_get_tag
enum CodecID codec_get_bmp_id(unsigned int tag); enum CodecID codec_get_bmp_id(unsigned int tag) attribute_deprecated; //use av_codec_get_id
enum CodecID codec_get_wav_id(unsigned int tag); enum CodecID codec_get_wav_id(unsigned int tag) attribute_deprecated; //use av_codec_get_id
unsigned int codec_get_asf_tag(const CodecTag *tags, unsigned int id);
void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale); void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale);
#endif #endif
...@@ -80,7 +80,7 @@ typedef struct { ...@@ -80,7 +80,7 @@ typedef struct {
int audio_type; int audio_type;
} SWFContext; } SWFContext;
static const CodecTag swf_codec_tags[] = { static const AVCodecTag swf_codec_tags[] = {
{CODEC_ID_FLV1, 0x02}, {CODEC_ID_FLV1, 0x02},
{CODEC_ID_VP6F, 0x04}, {CODEC_ID_VP6F, 0x04},
{0, 0}, {0, 0},
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
const unsigned char voc_magic[21] = "Creative Voice File\x1A"; const unsigned char voc_magic[21] = "Creative Voice File\x1A";
const CodecTag voc_codec_tags[] = { const AVCodecTag voc_codec_tags[] = {
{CODEC_ID_PCM_U8, 0x00}, {CODEC_ID_PCM_U8, 0x00},
{CODEC_ID_ADPCM_SBPRO_4, 0x01}, {CODEC_ID_ADPCM_SBPRO_4, 0x01},
{CODEC_ID_ADPCM_SBPRO_3, 0x02}, {CODEC_ID_ADPCM_SBPRO_3, 0x02},
......
...@@ -43,7 +43,7 @@ typedef enum voc_type { ...@@ -43,7 +43,7 @@ typedef enum voc_type {
} voc_type_t; } voc_type_t;
extern const unsigned char voc_magic[21]; extern const unsigned char voc_magic[21];
extern const CodecTag voc_codec_tags[]; extern const AVCodecTag voc_codec_tags[];
int voc_get_packet(AVFormatContext *s, AVPacket *pkt, int voc_get_packet(AVFormatContext *s, AVPacket *pkt,
AVStream *st, int max_size); AVStream *st, int max_size);
......
...@@ -235,6 +235,7 @@ AVInputFormat wav_demuxer = { ...@@ -235,6 +235,7 @@ AVInputFormat wav_demuxer = {
wav_read_packet, wav_read_packet,
wav_read_close, wav_read_close,
wav_read_seek, wav_read_seek,
.codec_tag= {codec_wav_tags},
}; };
#endif #endif
#ifdef CONFIG_WAV_MUXER #ifdef CONFIG_WAV_MUXER
...@@ -249,5 +250,6 @@ AVOutputFormat wav_muxer = { ...@@ -249,5 +250,6 @@ AVOutputFormat wav_muxer = {
wav_write_header, wav_write_header,
wav_write_packet, wav_write_packet,
wav_write_trailer, wav_write_trailer,
.codec_tag= {codec_wav_tags},
}; };
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment