Revision 36ffabc4

View differences:

libavformat/riff.c
320 320
    { CODEC_ID_NONE,      0 },
321 321
};
322 322

  
323
const AVCodecGuid ff_codec_wav_guids[] = {
324
    {CODEC_ID_AC3,        {0x2C,0x80,0x6D,0xE0,0x46,0xDB,0xCF,0x11,0xB4,0xD1,0x00,0x80,0x5F,0x6C,0xBB,0xEA}},
325
    {CODEC_ID_EAC3,       {0xAF,0x87,0xFB,0xA7,0x02,0x2D,0xFB,0x42,0xA4,0xD4,0x05,0xCD,0x93,0x84,0x3B,0xDD}},
326
    {CODEC_ID_MP2,        {0x2B,0x80,0x6D,0xE0,0x46,0xDB,0xCF,0x11,0xB4,0xD1,0x00,0x80,0x5F,0x6C,0xBB,0xEA}},
327
    {CODEC_ID_NONE}
328
};
329

  
323 330
#if CONFIG_MUXERS
324 331
int64_t ff_start_tag(AVIOContext *pb, const char *tag)
325 332
{
......
590 597
    assert(sizeof(*g) == 16);
591 598
    avio_read(s, *g, sizeof(*g));
592 599
}
600

  
601
enum CodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid)
602
{
603
    int i;
604
    for (i = 0; guids[i].id != CODEC_ID_NONE; i++) {
605
        if (!ff_guidcmp(guids[i].guid, guid))
606
            return guids[i].id;
607
    }
608
    return CODEC_ID_NONE;
609
}
libavformat/riff.h
56 56

  
57 57
typedef uint8_t ff_asf_guid[16];
58 58

  
59
#define FF_PRI_GUID \
60
    "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
61
#define FF_ARG_GUID(g) \
62
    g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7],g[8],g[9],g[10],g[11],g[12],g[13],g[14],g[15]
63

  
59 64
static av_always_inline int ff_guidcmp(const void *g1, const void *g2)
60 65
{
61 66
    return memcmp(g1, g2, sizeof(ff_asf_guid));
......
63 68

  
64 69
void ff_get_guid(AVIOContext *s, ff_asf_guid *g);
65 70

  
71
typedef struct {
72
    enum CodecID id;
73
    ff_asf_guid guid;
74
} AVCodecGuid;
75

  
76
enum CodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid);
77

  
78
extern const AVCodecGuid ff_codec_wav_guids[];
79

  
80
#define FF_MEDIASUBTYPE_BASE_GUID \
81
    0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71
82

  
66 83
#endif /* AVFORMAT_RIFF_H */
libavformat/wtv.c
35 35
#include <strings.h>
36 36

  
37 37
/* Macros for formating GUIDs */
38
#define PRI_GUID \
39
    "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
40
#define ARG_GUID(g) \
41
    g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7],g[8],g[9],g[10],g[11],g[12],g[13],g[14],g[15]
42

  
43 38
#define PRI_PRETTY_GUID \
44 39
    "%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x"
45 40
#define ARG_PRETTY_GUID(g) \
......
266 261
        uint64_t file_length;
267 262
        const uint8_t *name;
268 263
        if (ff_guidcmp(buf, dir_entry_guid)) {
269
            av_log(s, AV_LOG_ERROR, "unknown guid "PRI_GUID", expected dir_entry_guid; "
270
                   "remaining directory entries ignored\n", ARG_GUID(buf));
264
            av_log(s, AV_LOG_ERROR, "unknown guid "FF_PRI_GUID", expected dir_entry_guid; "
265
                   "remaining directory entries ignored\n", FF_ARG_GUID(buf));
271 266
            break;
272 267
        }
273 268
        dir_length  = AV_RL16(buf + 16);
......
328 323
    unsigned int index_entries_allocated_size;
329 324
} WtvContext;
330 325

  
331
typedef struct {
332
    enum CodecID id;
333
    ff_asf_guid guid;
334
} AVCodecGuid;
335

  
336
static enum CodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid)
337
{
338
    int i;
339
    for (i = 0; guids[i].id != CODEC_ID_NONE; i++) {
340
        if (!ff_guidcmp(guids[i].guid, guid))
341
            return guids[i].id;
342
    }
343
    return CODEC_ID_NONE;
344
}
345

  
346 326
/* WTV GUIDs */
347 327
static const ff_asf_guid wtv_guid =
348 328
    {0xB7,0xD8,0x00,0x20,0x37,0x49,0xDA,0x11,0xA6,0x4E,0x00,0x07,0xE9,0x5E,0xAD,0x8D};
......
377 357

  
378 358
/* Windows media GUIDs */
379 359

  
380
#define MEDIASUBTYPE_BASE_GUID \
381
    0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71
382

  
383 360
/* Media types */
384 361
static const ff_asf_guid mediatype_audio =
385
    {'a','u','d','s',MEDIASUBTYPE_BASE_GUID};
362
    {'a','u','d','s',FF_MEDIASUBTYPE_BASE_GUID};
386 363
static const ff_asf_guid mediatype_video =
387
    {'v','i','d','s',MEDIASUBTYPE_BASE_GUID};
364
    {'v','i','d','s',FF_MEDIASUBTYPE_BASE_GUID};
388 365
static const ff_asf_guid mediasubtype_mpeg1payload =
389 366
    {0x81,0xEB,0x36,0xE4,0x4F,0x52,0xCE,0x11,0x9F,0x53,0x00,0x20,0xAF,0x0B,0xA7,0x70};
390 367
static const ff_asf_guid mediatype_mpeg2_sections =
......
423 400
    {CODEC_ID_NONE}
424 401
};
425 402

  
426
static const AVCodecGuid audio_guids[] = {
427
    {CODEC_ID_AC3,        {0x2C,0x80,0x6D,0xE0,0x46,0xDB,0xCF,0x11,0xB4,0xD1,0x00,0x80,0x5F,0x6C,0xBB,0xEA}},
428
    {CODEC_ID_EAC3,       {0xAF,0x87,0xFB,0xA7,0x02,0x2D,0xFB,0x42,0xA4,0xD4,0x05,0xCD,0x93,0x84,0x3B,0xDD}},
429
    {CODEC_ID_MP2,        {0x2B,0x80,0x6D,0xE0,0x46,0xDB,0xCF,0x11,0xB4,0xD1,0x00,0x80,0x5F,0x6C,0xBB,0xEA}},
430
    {CODEC_ID_NONE}
431
};
432

  
433 403
static int read_probe(AVProbeData *p)
434 404
{
435 405
    return ff_guidcmp(p->buf, wtv_guid) ? 0 : AVPROBE_SCORE_MAX;
......
562 532
        if (!length)
563 533
            break;
564 534
        if (ff_guidcmp(&guid, metadata_guid)) {
565
            av_log(s, AV_LOG_WARNING, "unknown guid "PRI_GUID", expected metadata_guid; "
566
                   "remaining metadata entries ignored\n", ARG_GUID(guid));
535
            av_log(s, AV_LOG_WARNING, "unknown guid "FF_PRI_GUID", expected metadata_guid; "
536
                   "remaining metadata entries ignored\n", FF_ARG_GUID(guid));
567 537
            break;
568 538
        }
569 539
        avio_get_str16le(pb, INT_MAX, key, sizeof(key));
......
678 648
            ff_get_wav_header(pb, st->codec, size);
679 649
        } else {
680 650
            if (ff_guidcmp(formattype, format_none))
681
                av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
651
                av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype));
682 652
            avio_skip(pb, size);
683 653
        }
684 654

  
685
        if (!memcmp(subtype + 4, (const uint8_t[]){MEDIASUBTYPE_BASE_GUID}, 12)) {
655
        if (!memcmp(subtype + 4, (const uint8_t[]){FF_MEDIASUBTYPE_BASE_GUID}, 12)) {
686 656
            st->codec->codec_id = ff_wav_codec_get_id(AV_RL32(subtype), st->codec->bits_per_coded_sample);
687 657
        } else if (!ff_guidcmp(subtype, mediasubtype_mpeg1payload)) {
688 658
            if (st->codec->extradata && st->codec->extradata_size >= 22)
......
690 660
            else
691 661
                av_log(s, AV_LOG_WARNING, "MPEG1WAVEFORMATEX underflow\n");
692 662
        } else {
693
            st->codec->codec_id = ff_codec_guid_get_id(audio_guids, subtype);
663
            st->codec->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subtype);
694 664
            if (st->codec->codec_id == CODEC_ID_NONE)
695
                av_log(s, AV_LOG_WARNING, "unknown subtype:"PRI_GUID"\n", ARG_GUID(subtype));
665
                av_log(s, AV_LOG_WARNING, "unknown subtype:"FF_PRI_GUID"\n", FF_ARG_GUID(subtype));
696 666
        }
697 667
        return st;
698 668
    } else if (!ff_guidcmp(mediatype, mediatype_video)) {
......
707 677
            avio_skip(pb, FFMAX(size - consumed, 0));
708 678
        } else {
709 679
            if (ff_guidcmp(formattype, format_none))
710
                av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
680
                av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype));
711 681
            avio_skip(pb, size);
712 682
        }
713 683

  
714
        if (!memcmp(subtype + 4, (const uint8_t[]){MEDIASUBTYPE_BASE_GUID}, 12)) {
684
        if (!memcmp(subtype + 4, (const uint8_t[]){FF_MEDIASUBTYPE_BASE_GUID}, 12)) {
715 685
            st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(subtype));
716 686
        } else {
717 687
            st->codec->codec_id = ff_codec_guid_get_id(video_guids, subtype);
718 688
        }
719 689
        if (st->codec->codec_id == CODEC_ID_NONE)
720
            av_log(s, AV_LOG_WARNING, "unknown subtype:"PRI_GUID"\n", ARG_GUID(subtype));
690
            av_log(s, AV_LOG_WARNING, "unknown subtype:"FF_PRI_GUID"\n", FF_ARG_GUID(subtype));
721 691
        return st;
722 692
    } else if (!ff_guidcmp(mediatype, mediatype_mpeg2_pes) &&
723 693
               !ff_guidcmp(subtype, mediasubtype_dvb_subtitle)) {
......
725 695
        if (!st)
726 696
            return NULL;
727 697
        if (ff_guidcmp(formattype, format_none))
728
            av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
698
            av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype));
729 699
        avio_skip(pb, size);
730 700
        st->codec->codec_id = CODEC_ID_DVB_SUBTITLE;
731 701
        return st;
......
735 705
        if (!st)
736 706
            return NULL;
737 707
        if (ff_guidcmp(formattype, format_none))
738
            av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
708
            av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype));
739 709
        avio_skip(pb, size);
740 710
        st->codec->codec_id   = CODEC_ID_DVB_TELETEXT;
741 711
        return st;
742 712
    } else if (!ff_guidcmp(mediatype, mediatype_mpeg2_sections) &&
743 713
               !ff_guidcmp(subtype, mediasubtype_mpeg2_sections)) {
744 714
        if (ff_guidcmp(formattype, format_none))
745
            av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype));
715
            av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype));
746 716
        avio_skip(pb, size);
747 717
        return NULL;
748 718
    }
749 719

  
750
    av_log(s, AV_LOG_WARNING, "unknown media type, mediatype:"PRI_GUID
751
                              ", subtype:"PRI_GUID", formattype:"PRI_GUID"\n",
752
                              ARG_GUID(mediatype), ARG_GUID(subtype), ARG_GUID(formattype));
720
    av_log(s, AV_LOG_WARNING, "unknown media type, mediatype:"FF_PRI_GUID
721
                              ", subtype:"FF_PRI_GUID", formattype:"FF_PRI_GUID"\n",
722
                              FF_ARG_GUID(mediatype), FF_ARG_GUID(subtype), FF_ARG_GUID(formattype));
753 723
    avio_skip(pb, size);
754 724
    return NULL;
755 725
}
......
921 891
            !ff_guidcmp(g, (const ff_asf_guid){0xA1,0xC3,0xD2,0xC2,0x7E,0x9A,0xDA,0x11,0x8B,0xF7,0x00,0x07,0xE9,0x5E,0xAD,0x8D})) {
922 892
            //ignore known guids
923 893
        } else
924
            av_log(s, AV_LOG_WARNING, "unsupported chunk:"PRI_GUID"\n", ARG_GUID(g));
894
            av_log(s, AV_LOG_WARNING, "unsupported chunk:"FF_PRI_GUID"\n", FF_ARG_GUID(g));
925 895

  
926 896
        avio_skip(pb, WTV_PAD8(len) - consumed);
927 897
    }

Also available in: Unified diff