Revision 09c2b942 libavformat/matroska.c

View differences:

libavformat/matroska.c
223 223
    {"A_DTS"            , CODEC_ID_DTS},
224 224
    {"A_VORBIS"         , CODEC_ID_VORBIS},
225 225
    {"A_AAC/MPEG2/"     , CODEC_ID_AAC},
226
    {"A_AAC/MPEG4/"     , CODEC_ID_AAC},
226
    {"A_AAC/MPEG4/"     , CODEC_ID_MPEG4AAC},
227 227
    {"A_WAVPACK4"       , CODEC_ID_WAVPACK},
228 228
    {NULL               , CODEC_ID_NONE}
229 229
/* TODO: AC3-9/10 (?), Real, Musepack, Quicktime */
......
2022 2022
    return res;
2023 2023
}
2024 2024

  
2025
#define ARRAY_SIZE(x)  (sizeof(x)/sizeof(*x))
2026

  
2027
static int
2028
matroska_aac_profile (char *codec_id)
2029
{
2030
    static const char *aac_profiles[] = {
2031
        "MAIN", "LC", "SSR"
2032
    };
2033
    int profile;
2034

  
2035
    for (profile=0; profile<ARRAY_SIZE(aac_profiles); profile++)
2036
        if (strstr(codec_id, aac_profiles[profile]))
2037
            break;
2038
    return profile + 1;
2039
}
2040

  
2041
static int
2042
matroska_aac_sri (int samplerate)
2043
{
2044
    static const int aac_sample_rates[] = {
2045
        96000, 88200, 64000, 48000, 44100, 32000,
2046
        24000, 22050, 16000, 12000, 11025,  8000,
2047
    };
2048
    int sri;
2049

  
2050
    for (sri=0; sri<ARRAY_SIZE(aac_sample_rates); sri++)
2051
        if (aac_sample_rates[sri] == samplerate)
2052
            break;
2053
    return sri;
2054
}
2055

  
2025 2056
static int
2026 2057
matroska_read_header (AVFormatContext    *s,
2027 2058
                      AVFormatParameters *ap)
......
2164 2195

  
2165 2196
        for (i = 0; i < matroska->num_tracks; i++) {
2166 2197
            enum CodecID codec_id = CODEC_ID_NONE;
2167
            void *extradata = NULL;
2198
            uint8_t *extradata = NULL;
2168 2199
            int extradata_size = 0;
2169 2200
            track = matroska->tracks[i];
2170 2201

  
......
2175 2206
                continue;
2176 2207

  
2177 2208
            for(j=0; codec_tags[j].str; j++){
2178
                if(!strcmp(codec_tags[j].str, track->codec_id)){
2209
                if(!strncmp(codec_tags[j].str, track->codec_id,
2210
                            strlen(codec_tags[j].str))){
2179 2211
                    codec_id= codec_tags[j].id;
2180 2212
                    break;
2181 2213
                }
......
2214 2246

  
2215 2247
            }
2216 2248

  
2249
            if (codec_id==CODEC_ID_AAC || codec_id==CODEC_ID_MPEG4AAC) {
2250
                MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *) track;
2251
                int profile = matroska_aac_profile(track->codec_id);
2252
                int sri = matroska_aac_sri(audiotrack->internal_samplerate);
2253
                extradata = av_malloc(5);
2254
                if (extradata == NULL)
2255
                    return AVERROR_NOMEM;
2256
                extradata[0] = (profile << 3) | ((sri&0x0E) >> 1);
2257
                extradata[1] = ((sri&0x01) << 7) | (audiotrack->channels<<3);
2258
                if (strstr(track->codec_id, "SBR")) {
2259
                    sri = matroska_aac_sri(audiotrack->samplerate);
2260
                    extradata[2] = 0x56;
2261
                    extradata[3] = 0xE5;
2262
                    extradata[4] = 0x80 | (sri<<3);
2263
                    extradata_size = 5;
2264
                } else {
2265
                    extradata_size = 2;
2266
                }
2267
            }
2268

  
2217 2269
            if (codec_id == CODEC_ID_NONE) {
2218 2270
                av_log(matroska->ctx, AV_LOG_INFO,
2219 2271
                       "Unknown/unsupported CodecID %s.\n",

Also available in: Unified diff