Revision 158b3912 libavcodec/aac.c

View differences:

libavcodec/aac.c
86 86
#include "aactab.h"
87 87
#include "aacdectab.h"
88 88
#include "mpeg4audio.h"
89
#include "aac_parser.h"
89 90

  
90 91
#include <assert.h>
91 92
#include <errno.h>
......
384 385

  
385 386
    ac->avccontext = avccontext;
386 387

  
387
    if (avccontext->extradata_size <= 0 ||
388
        decode_audio_specific_config(ac, avccontext->extradata, avccontext->extradata_size))
388
    if (avccontext->extradata_size > 0) {
389
        if(decode_audio_specific_config(ac, avccontext->extradata, avccontext->extradata_size))
390
            return -1;
391
        avccontext->sample_rate = ac->m4ac.sample_rate;
392
    } else if (avccontext->channels > 0) {
393
        enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
394
        memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
395
        if(set_default_channel_config(ac, new_che_pos, avccontext->channels - (avccontext->channels == 8)))
396
            return -1;
397
        if(output_configure(ac, ac->che_pos, new_che_pos))
398
            return -1;
399
        ac->m4ac.sample_rate = avccontext->sample_rate;
400
    } else {
401
        ff_log_missing_feature(ac->avccontext, "Implicit channel configuration is", 0);
389 402
        return -1;
403
    }
390 404

  
391 405
    avccontext->sample_fmt  = SAMPLE_FMT_S16;
392
    avccontext->sample_rate = ac->m4ac.sample_rate;
393 406
    avccontext->frame_size  = 1024;
394 407

  
395 408
    AAC_INIT_VLC_STATIC( 0, 144);
......
1506 1519
    }
1507 1520
}
1508 1521

  
1522
static int parse_adts_frame_header(AACContext * ac, GetBitContext * gb) {
1523

  
1524
    int size;
1525
    AACADTSHeaderInfo hdr_info;
1526

  
1527
    size = ff_aac_parse_header(gb, &hdr_info);
1528
    if (size > 0) {
1529
        if (hdr_info.chan_config)
1530
            ac->m4ac.chan_config = hdr_info.chan_config;
1531
        ac->m4ac.sample_rate     = hdr_info.sample_rate;
1532
        ac->m4ac.sampling_index  = hdr_info.sampling_index;
1533
        ac->m4ac.object_type     = hdr_info.object_type;
1534
    }
1535
    if (hdr_info.num_aac_frames == 1) {
1536
        if (!hdr_info.crc_absent)
1537
            skip_bits(gb, 16);
1538
    } else {
1539
        ff_log_missing_feature(ac->avccontext, "More than one AAC RDB per ADTS frame is", 0);
1540
        return -1;
1541
    }
1542
    return size;
1543
}
1544

  
1509 1545
static int aac_decode_frame(AVCodecContext * avccontext, void * data, int * data_size, const uint8_t * buf, int buf_size) {
1510 1546
    AACContext * ac = avccontext->priv_data;
1511 1547
    GetBitContext gb;
......
1514 1550

  
1515 1551
    init_get_bits(&gb, buf, buf_size*8);
1516 1552

  
1553
    if (show_bits(&gb, 12) == 0xfff) {
1554
        if ((err = parse_adts_frame_header(ac, &gb)) < 0) {
1555
            av_log(avccontext, AV_LOG_ERROR, "Error decoding AAC frame header.\n");
1556
            return -1;
1557
        }
1558
    }
1559

  
1517 1560
    // parse
1518 1561
    while ((elem_type = get_bits(&gb, 3)) != TYPE_END) {
1519 1562
        elem_id = get_bits(&gb, 4);

Also available in: Unified diff