Revision 7caf0cc6 libavformat/riff.c

View differences:

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);

Also available in: Unified diff