Revision 8bb5d1c3 libavformat/caf.c

View differences:

libavformat/caf.c
56 56
  /*{ MPEG4TwinVQ               MKBETAG('t','w','v','q') },*/
57 57
    { CODEC_ID_NONE,            0 },
58 58
};
59

  
60
typedef struct CafChannelLayout {
61
    int64_t  channel_layout;
62
    uint32_t layout_tag;
63
} CafChannelLayout;
64

  
65
static const CafChannelLayout caf_channel_layout[] = {
66
    { AV_CH_LAYOUT_MONO,                         (100<<16) | 1}, //< kCAFChannelLayoutTag_Mono
67
    { AV_CH_LAYOUT_STEREO,                       (101<<16) | 2}, //< kCAFChannelLayoutTag_Stereo
68
    { AV_CH_LAYOUT_STEREO,                       (102<<16) | 2}, //< kCAFChannelLayoutTag_StereoHeadphones
69
    { AV_CH_LAYOUT_2_1,                          (131<<16) | 3}, //< kCAFChannelLayoutTag_ITU_2_1
70
    { AV_CH_LAYOUT_2_2,                          (132<<16) | 4}, //< kCAFChannelLayoutTag_ITU_2_2
71
    { AV_CH_LAYOUT_QUAD,                         (108<<16) | 4}, //< kCAFChannelLayoutTag_Quadraphonic
72
    { AV_CH_LAYOUT_SURROUND,                     (113<<16) | 3}, //< kCAFChannelLayoutTag_MPEG_3_0_A
73
    { AV_CH_LAYOUT_4POINT0,                      (115<<16) | 4}, //< kCAFChannelLayoutTag_MPEG_4_0_A
74
    { AV_CH_LAYOUT_5POINT0_BACK,                 (117<<16) | 5}, //< kCAFChannelLayoutTag_MPEG_5_0_A
75
    { AV_CH_LAYOUT_5POINT0,                      (117<<16) | 5}, //< kCAFChannelLayoutTag_MPEG_5_0_A
76
    { AV_CH_LAYOUT_5POINT1_BACK,                 (121<<16) | 6}, //< kCAFChannelLayoutTag_MPEG_5_1_A
77
    { AV_CH_LAYOUT_5POINT1,                      (121<<16) | 6}, //< kCAFChannelLayoutTag_MPEG_5_1_A
78
    { AV_CH_LAYOUT_7POINT1,                      (128<<16) | 8}, //< kCAFChannelLayoutTag_MPEG_7_1_C
79
    { AV_CH_LAYOUT_7POINT1_WIDE,                 (126<<16) | 8}, //< kCAFChannelLayoutTag_MPEG_7_1_A
80
    { AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY,   (133<<16) | 3}, //< kCAFChannelLayoutTag_DVD_4
81
    { AV_CH_LAYOUT_2_1|AV_CH_LOW_FREQUENCY,      (134<<16) | 4}, //< kCAFChannelLayoutTag_DVD_5
82
    { AV_CH_LAYOUT_2_2|AV_CH_LOW_FREQUENCY,      (135<<16) | 4}, //< kCAFChannelLayoutTag_DVD_6
83
    { AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY, (136<<16) | 4}, //< kCAFChannelLayoutTag_DVD_10
84
    { AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY,  (137<<16) | 5}, //< kCAFChannelLayoutTag_DVD_11
85
    { 0, 0},
86
};
87

  
88
void ff_read_chan_chunk(AVFormatContext *s, int64_t size, AVCodecContext *codec)
89
{
90
    uint32_t layout_tag;
91
    AVIOContext *pb = s->pb;
92
    const CafChannelLayout *caf_layout = caf_channel_layout;
93
    if (size != 12) {
94
        // Channel descriptions not implemented
95
        av_log_ask_for_sample(s, "Unimplemented channel layout.");
96
        avio_skip(pb, size);
97
        return;
98
    }
99
    layout_tag = avio_rb32(pb);
100
    if (layout_tag == 0x10000) { //< kCAFChannelLayoutTag_UseChannelBitmap
101
        codec->channel_layout = avio_rb32(pb);
102
        avio_skip(pb, 4);
103
        return;
104
    }
105
    while (caf_layout->channel_layout) {
106
        if (layout_tag == caf_layout->layout_tag) {
107
            codec->channel_layout = caf_layout->channel_layout;
108
            break;
109
        }
110
        caf_layout++;
111
    }
112
    if (!codec->channel_layout)
113
        av_log(s, AV_LOG_WARNING, "Unknown channel layout.");
114
    avio_skip(pb, 8);
115
}
116

  

Also available in: Unified diff