Revision 7caf0cc6

View differences:

libavformat/aiff.c
23 23
#include "riff.h"
24 24
#include "intfloat_readwrite.h"
25 25

  
26
static const CodecTag codec_aiff_tags[] = {
26
static const AVCodecTag codec_aiff_tags[] = {
27 27
    { CODEC_ID_PCM_S16BE, MKTAG('N','O','N','E') },
28 28
    { CODEC_ID_PCM_S8, MKTAG('N','O','N','E') },
29 29
    { CODEC_ID_PCM_S24BE, MKTAG('N','O','N','E') },
libavformat/asf-enc.c
187 187
                2*PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS \
188 188
                )
189 189

  
190
static const AVCodecTag codec_asf_bmp_tags[] = {
191
    { CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
192
    { CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
193
    { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },
194
    { CODEC_ID_NONE, 0 },
195
};
196

  
190 197
static int preroll_time = 2000;
191 198

  
192 199
static const uint8_t error_spread_ADPCM_G726[] = { 0x01, 0x90, 0x01, 0x90, 0x01, 0x01, 0x00, 0x00 };
......
842 849
    asf_write_packet,
843 850
    asf_write_trailer,
844 851
    .flags = AVFMT_GLOBALHEADER,
852
    .codec_tag= {codec_asf_bmp_tags, codec_bmp_tags, codec_wav_tags},
845 853
};
846 854
#endif
847 855

  
......
862 870
    asf_write_packet,
863 871
    asf_write_trailer,
864 872
    .flags = AVFMT_GLOBALHEADER,
873
    .codec_tag= {codec_asf_bmp_tags, codec_bmp_tags, codec_wav_tags},
865 874
};
866 875
#endif //CONFIG_ASF_STREAM_MUXER
libavformat/au.c
35 35
#define AU_UNKOWN_SIZE ((uint32_t)(~0))
36 36

  
37 37
/* The ffmpeg codecs we support, and the IDs they have in the file */
38
static const CodecTag codec_au_tags[] = {
38
static const AVCodecTag codec_au_tags[] = {
39 39
    { CODEC_ID_PCM_MULAW, 1 },
40 40
    { CODEC_ID_PCM_S16BE, 3 },
41 41
    { CODEC_ID_PCM_ALAW, 27 },
libavformat/avformat.h
25 25
extern "C" {
26 26
#endif
27 27

  
28
#define LIBAVFORMAT_VERSION_INT ((51<<16)+(7<<8)+0)
29
#define LIBAVFORMAT_VERSION     51.7.0
28
#define LIBAVFORMAT_VERSION_INT ((51<<16)+(8<<8)+0)
29
#define LIBAVFORMAT_VERSION     51.8.0
30 30
#define LIBAVFORMAT_BUILD       LIBAVFORMAT_VERSION_INT
31 31

  
32 32
#define LIBAVFORMAT_IDENT       "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
......
96 96
/*************************************************/
97 97
/* input/output formats */
98 98

  
99
struct AVCodecTag;
100

  
99 101
struct AVFormatContext;
100 102

  
101 103
/* this structure contains the data a format has to probe a file */
......
155 157
    /* currently only used to set pixel format if not YUV420P */
156 158
    int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
157 159
    int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush);
160

  
161
    /**
162
     * list of supported codec_id-codec_tag pairs, ordered by "better choice first"
163
     * the arrays are all CODEC_ID_NONE terminated
164
     */
165
    const struct AVCodecTag *codec_tag[4];
166

  
158 167
    /* private fields */
159 168
    struct AVOutputFormat *next;
160 169
} AVOutputFormat;
......
210 219
       (RTSP) */
211 220
    int (*read_pause)(struct AVFormatContext *);
212 221

  
222
    const struct AVCodecTag *codec_tag[4];
223

  
213 224
    /* private fields */
214 225
    struct AVInputFormat *next;
215 226
} AVInputFormat;
......
396 407

  
397 408
void av_register_all(void);
398 409

  
410
/* codec tag <-> codec id */
411
enum CodecID av_codec_get_id(const struct AVCodecTag *tags[4], unsigned int tag);
412
unsigned int av_codec_get_tag(const struct AVCodecTag *tags[4], enum CodecID id);
413

  
399 414
/* media file input */
400 415
AVInputFormat *av_find_input_format(const char *short_name);
401 416
AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
libavformat/avienc.c
575 575
    avi_write_header,
576 576
    avi_write_packet,
577 577
    avi_write_trailer,
578
    .codec_tag= {codec_bmp_tags, codec_wav_tags},
578 579
};
579 580
#endif //CONFIG_AVI_MUXER
libavformat/flvenc.c
25 25
#undef NDEBUG
26 26
#include <assert.h>
27 27

  
28
static const CodecTag flv_video_codec_ids[] = {
28
static const AVCodecTag flv_video_codec_ids[] = {
29 29
    {CODEC_ID_FLV1,    FLV_CODECID_H263  },
30 30
    {CODEC_ID_FLASHSV, FLV_CODECID_SCREEN},
31 31
    {CODEC_ID_VP6F,    FLV_CODECID_VP6   },
......
33 33
    {CODEC_ID_NONE,    0}
34 34
};
35 35

  
36
static const CodecTag flv_audio_codec_ids[] = {
36
static const AVCodecTag flv_audio_codec_ids[] = {
37 37
    {CODEC_ID_MP3,       FLV_CODECID_MP3    >> FLV_AUDIO_CODECID_OFFSET},
38 38
    {CODEC_ID_PCM_S8,    FLV_CODECID_PCM_BE >> FLV_AUDIO_CODECID_OFFSET},
39 39
    {CODEC_ID_PCM_S16BE, FLV_CODECID_PCM_BE >> FLV_AUDIO_CODECID_OFFSET},
libavformat/gxfenc.c
85 85
    { 720,  6 },
86 86
};
87 87

  
88
static const CodecTag gxf_media_types[] = {
88
static const AVCodecTag gxf_media_types[] = {
89 89
    { CODEC_ID_MJPEG     ,   3 }, /* NTSC */
90 90
    { CODEC_ID_MJPEG     ,   4 }, /* PAL */
91 91
    { CODEC_ID_PCM_S24LE ,   9 },
libavformat/isom.c
26 26
#include "isom.h"
27 27

  
28 28
/* http://gpac.sourceforge.net/tutorial/mediatypes.htm */
29
const CodecTag ff_mov_obj_type[] = {
29
const AVCodecTag ff_mov_obj_type[] = {
30 30
    { CODEC_ID_MPEG4     ,  32 },
31 31
    { CODEC_ID_H264      ,  33 },
32 32
    { CODEC_ID_AAC       ,  64 },
libavformat/isom.h
25 25
#define FFMPEG_ISOM_H
26 26

  
27 27
/* isom.c */
28
extern const CodecTag ff_mov_obj_type[];
28
extern const AVCodecTag ff_mov_obj_type[];
29 29

  
30 30
int ff_mov_iso639_to_lang(const char *lang, int mp4);
31 31
int ff_mov_lang_to_iso639(int code, char *to);
libavformat/libnut.c
10 10
    nut_stream_header_t * s;
11 11
} NUTContext;
12 12

  
13
static const CodecTag nut_tags[] = {
13
static const AVCodecTag nut_tags[] = {
14 14
    { CODEC_ID_MPEG4,  MKTAG('m', 'p', '4', 'v') },
15 15
    { CODEC_ID_MP3,    MKTAG('m', 'p', '3', ' ') },
16 16
    { CODEC_ID_VORBIS, MKTAG('v', 'r', 'b', 's') },
libavformat/mov.c
66 66
#undef NDEBUG
67 67
#include <assert.h>
68 68

  
69
static const CodecTag mov_video_tags[] = {
69
static const AVCodecTag mov_video_tags[] = {
70 70
/*  { CODEC_ID_, MKTAG('c', 'v', 'i', 'd') }, *//* Cinepak */
71 71
/*  { CODEC_ID_H263, MKTAG('r', 'a', 'w', ' ') }, *//* Uncompressed RGB */
72 72
/*  { CODEC_ID_H263, MKTAG('Y', 'u', 'v', '2') }, *//* Uncompressed YUV422 */
......
127 127
    { CODEC_ID_NONE, 0 },
128 128
};
129 129

  
130
static const CodecTag mov_audio_tags[] = {
130
static const AVCodecTag mov_audio_tags[] = {
131 131
    { CODEC_ID_PCM_S32BE, MKTAG('i', 'n', '3', '2') },
132 132
    { CODEC_ID_PCM_S24BE, MKTAG('i', 'n', '2', '4') },
133 133
    { CODEC_ID_PCM_S16BE, MKTAG('N', 'O', 'N', 'E') }, /* uncompressed */
libavformat/movenc.c
322 322
    return updateSize (pb, pos);
323 323
}
324 324

  
325
static const CodecTag codec_movaudio_tags[] = {
325
static const AVCodecTag codec_movaudio_tags[] = {
326 326
    { CODEC_ID_PCM_MULAW, MKTAG('u', 'l', 'a', 'w') },
327 327
    { CODEC_ID_PCM_ALAW, MKTAG('a', 'l', 'a', 'w') },
328 328
    { CODEC_ID_ADPCM_IMA_QT, MKTAG('i', 'm', 'a', '4') },
......
526 526
    return updateSize(pb, pos);
527 527
}
528 528

  
529
static const CodecTag codec_movvideo_tags[] = {
529
static const AVCodecTag codec_movvideo_tags[] = {
530 530
    { CODEC_ID_SVQ1, MKTAG('S', 'V', 'Q', '1') },
531 531
    { CODEC_ID_SVQ3, MKTAG('S', 'V', 'Q', '3') },
532 532
    { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
libavformat/nsvdec.c
183 183
    //DVDemuxContext* dv_demux;
184 184
} NSVContext;
185 185

  
186
static const CodecTag nsv_codec_video_tags[] = {
186
static const AVCodecTag nsv_codec_video_tags[] = {
187 187
    { CODEC_ID_VP3, MKTAG('V', 'P', '3', ' ') },
188 188
    { CODEC_ID_VP3, MKTAG('V', 'P', '3', '0') },
189 189
    { CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') },
......
202 202
    { 0, 0 },
203 203
};
204 204

  
205
static const CodecTag nsv_codec_audio_tags[] = {
205
static const AVCodecTag nsv_codec_audio_tags[] = {
206 206
    { CODEC_ID_MP3, MKTAG('M', 'P', '3', ' ') },
207 207
    { CODEC_ID_AAC, MKTAG('A', 'A', 'C', ' ') },
208 208
    { CODEC_ID_AAC, MKTAG('A', 'A', 'C', 'P') }, /* _CUTTED__MUXED_2 Heads - Out Of The City.nsv */
libavformat/riff.c
22 22
#include "avformat.h"
23 23
#include "avcodec.h"
24 24
#include "riff.h"
25
#include "allformats.h" // for asf_muxer
25 26

  
26 27
/* Note: when encoding, the first matching tag is used, so order is
27 28
   important if multiple tags possible for a given codec. */
28
const CodecTag codec_bmp_tags[] = {
29
const AVCodecTag codec_bmp_tags[] = {
29 30
    { CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
30 31
    { CODEC_ID_H264, MKTAG('h', '2', '6', '4') },
31 32
    { CODEC_ID_H264, MKTAG('X', '2', '6', '4') },
......
42 43
    { CODEC_ID_H263P, MKTAG('U', '2', '6', '3') },
43 44
    { CODEC_ID_H263P, MKTAG('v', 'i', 'v', '1') },
44 45

  
45
    { CODEC_ID_MPEG4, MKTAG('F', 'M', 'P', '4')},
46
    { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X'), .invalid_asf = 1 },
47
    { CODEC_ID_MPEG4, MKTAG('D', 'X', '5', '0'), .invalid_asf = 1 },
48
    { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D'), .invalid_asf = 1 },
46
    { CODEC_ID_MPEG4, MKTAG('F', 'M', 'P', '4') },
47
    { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') },
48
    { CODEC_ID_MPEG4, MKTAG('D', 'X', '5', '0') },
49
    { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') },
49 50
    { CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
50 51
    { CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
51 52
    { CODEC_ID_MPEG4, MKTAG(0x04, 0, 0, 0) }, /* some broken avi use this */
......
60 61

  
61 62
    { CODEC_ID_MPEG4, MKTAG('R', 'M', 'P', '4') },
62 63

  
63
    { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3'), .invalid_asf = 1 }, /* default signature when using MSMPEG4 */
64
    { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') }, /* default signature when using MSMPEG4 */
64 65
    { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },
65 66

  
66 67
    /* added based on MPlayer */
......
168 169
    { CODEC_ID_NONE, 0 },
169 170
};
170 171

  
171
const CodecTag codec_wav_tags[] = {
172
const AVCodecTag codec_wav_tags[] = {
172 173
    { CODEC_ID_MP2, 0x50 },
173 174
    { CODEC_ID_MP3, 0x55 },
174 175
    { CODEC_ID_AC3, 0x2000 },
......
206 207
    { 0, 0 },
207 208
};
208 209

  
209
unsigned int codec_get_tag(const CodecTag *tags, int id)
210
unsigned int codec_get_tag(const AVCodecTag *tags, int id)
210 211
{
211 212
    while (tags->id != CODEC_ID_NONE) {
212 213
        if (tags->id == id)
......
216 217
    return 0;
217 218
}
218 219

  
219
unsigned int codec_get_asf_tag(const CodecTag *tags, unsigned int id)
220
{
221
    while (tags->id != CODEC_ID_NONE) {
222
        if (!tags->invalid_asf && tags->id == id)
223
            return tags->tag;
224
        tags++;
225
    }
226
    return 0;
227
}
228

  
229
enum CodecID codec_get_id(const CodecTag *tags, unsigned int tag)
220
enum CodecID codec_get_id(const AVCodecTag *tags, unsigned int tag)
230 221
{
231 222
    while (tags->id != CODEC_ID_NONE) {
232 223
        if(   toupper((tag >> 0)&0xFF) == toupper((tags->tag >> 0)&0xFF)
......
239 230
    return CODEC_ID_NONE;
240 231
}
241 232

  
233
unsigned int av_codec_get_tag(const AVCodecTag *tags[4], enum CodecID id)
234
{
235
    int i;
236
    for(i=0; i<4 && tags[i]; i++){
237
        int tag= codec_get_tag(tags[i], id);
238
        if(tag) return tag;
239
    }
240
    return 0;
241
}
242

  
243
enum CodecID av_codec_get_id(const AVCodecTag *tags[4], unsigned int tag)
244
{
245
    int i;
246
    for(i=0; i<4 && tags[i]; i++){
247
        enum CodecID id= codec_get_id(tags[i], tag);
248
        if(id!=CODEC_ID_NONE) return id;
249
    }
250
    return CODEC_ID_NONE;
251
}
252

  
242 253
unsigned int codec_get_bmp_tag(int id)
243 254
{
244 255
    return codec_get_tag(codec_bmp_tags, id);
......
367 378
}
368 379

  
369 380
/* BITMAPINFOHEADER header */
370
void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const CodecTag *tags, int for_asf)
381
void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf)
371 382
{
372 383
    put_le32(pb, 40 + enc->extradata_size); /* size */
373 384
    put_le32(pb, enc->width);
......
376 387

  
377 388
    put_le16(pb, enc->bits_per_sample ? enc->bits_per_sample : 24); /* depth */
378 389
    /* compression type */
379
    put_le32(pb, for_asf ? (enc->codec_tag ? enc->codec_tag : codec_get_asf_tag(tags, enc->codec_id)) : enc->codec_tag); //
390
    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); //
380 391
    put_le32(pb, enc->width * enc->height * 3);
381 392
    put_le32(pb, 0);
382 393
    put_le32(pb, 0);
libavformat/riff.h
19 19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
 */
21 21

  
22
/**
23
 * @file riff.h
24
 * internal header for RIFF based (de)muxers
25
 * do NOT include this in end user applications
26
 */
27

  
22 28
#ifndef FF_RIFF_H
23 29
#define FF_RIFF_H
24 30

  
25 31
offset_t start_tag(ByteIOContext *pb, const char *tag);
26 32
void end_tag(ByteIOContext *pb, offset_t start);
27 33

  
28
typedef struct CodecTag {
34
typedef struct AVCodecTag {
29 35
    int id;
30 36
    unsigned int tag;
31
    unsigned int invalid_asf : 1;
32
} CodecTag;
37
} AVCodecTag;
33 38

  
34
void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const CodecTag *tags, int for_asf);
39
void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf);
35 40
int put_wav_header(ByteIOContext *pb, AVCodecContext *enc);
36 41
int wav_codec_get_id(unsigned int tag, int bps);
37 42
void get_wav_header(ByteIOContext *pb, AVCodecContext *codec, int size);
38 43

  
39
extern const CodecTag codec_bmp_tags[];
40
extern const CodecTag codec_wav_tags[];
44
extern const AVCodecTag codec_bmp_tags[];
45
extern const AVCodecTag codec_wav_tags[];
41 46

  
42
unsigned int codec_get_tag(const CodecTag *tags, int id);
43
enum CodecID codec_get_id(const CodecTag *tags, unsigned int tag);
44
unsigned int codec_get_bmp_tag(int id);
45
unsigned int codec_get_wav_tag(int id);
46
enum CodecID codec_get_bmp_id(unsigned int tag);
47
enum CodecID codec_get_wav_id(unsigned int tag);
48
unsigned int codec_get_asf_tag(const CodecTag *tags, unsigned int id);
47
unsigned int codec_get_tag(const AVCodecTag *tags, int id);
48
enum CodecID codec_get_id(const AVCodecTag *tags, unsigned int tag);
49
unsigned int codec_get_bmp_tag(int id) attribute_deprecated; //use av_codec_get_tag
50
unsigned int codec_get_wav_tag(int id) attribute_deprecated; //use av_codec_get_tag
51
enum CodecID codec_get_bmp_id(unsigned int tag) attribute_deprecated; //use av_codec_get_id
52
enum CodecID codec_get_wav_id(unsigned int tag) attribute_deprecated; //use av_codec_get_id
49 53
void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale);
50 54

  
51 55
#endif
libavformat/swf.c
80 80
    int audio_type;
81 81
} SWFContext;
82 82

  
83
static const CodecTag swf_codec_tags[] = {
83
static const AVCodecTag swf_codec_tags[] = {
84 84
    {CODEC_ID_FLV1, 0x02},
85 85
    {CODEC_ID_VP6F, 0x04},
86 86
    {0, 0},
libavformat/voc.c
23 23

  
24 24
const unsigned char voc_magic[21] = "Creative Voice File\x1A";
25 25

  
26
const CodecTag voc_codec_tags[] = {
26
const AVCodecTag voc_codec_tags[] = {
27 27
    {CODEC_ID_PCM_U8,        0x00},
28 28
    {CODEC_ID_ADPCM_SBPRO_4, 0x01},
29 29
    {CODEC_ID_ADPCM_SBPRO_3, 0x02},
libavformat/voc.h
43 43
} voc_type_t;
44 44

  
45 45
extern const unsigned char voc_magic[21];
46
extern const CodecTag voc_codec_tags[];
46
extern const AVCodecTag voc_codec_tags[];
47 47

  
48 48
int voc_get_packet(AVFormatContext *s, AVPacket *pkt,
49 49
                   AVStream *st, int max_size);
libavformat/wav.c
235 235
    wav_read_packet,
236 236
    wav_read_close,
237 237
    wav_read_seek,
238
    .codec_tag= {codec_wav_tags},
238 239
};
239 240
#endif
240 241
#ifdef CONFIG_WAV_MUXER
......
249 250
    wav_write_header,
250 251
    wav_write_packet,
251 252
    wav_write_trailer,
253
    .codec_tag= {codec_wav_tags},
252 254
};
253 255
#endif

Also available in: Unified diff