Revision 67d979fe libavcodec/ac3enc.c

View differences:

libavcodec/ac3enc.c
914 914
/**
915 915
 * Write the AC-3 frame header to the output bitstream.
916 916
 */
917
static void output_frame_header(AC3EncodeContext *s, unsigned char *frame)
917
static void output_frame_header(AC3EncodeContext *s)
918 918
{
919
    init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE);
920

  
921 919
    put_bits(&s->pb, 16, 0x0b77);   /* frame header */
922 920
    put_bits(&s->pb, 16, 0);        /* crc1: will be filled later */
923 921
    put_bits(&s->pb, 2,  s->bit_alloc.sr_code);
......
1295 1293

  
1296 1294

  
1297 1295
/**
1296
 * Write the frame to the output bitstream.
1297
 */
1298
static void output_frame(AC3EncodeContext *s,
1299
                         unsigned char *frame,
1300
                         uint8_t exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS],
1301
                         uint8_t encoded_exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS],
1302
                         uint8_t bap[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS],
1303
                         int32_t mdct_coef[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS],
1304
                         int8_t exp_shift[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS])
1305
{
1306
    int blk;
1307

  
1308
    init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE);
1309

  
1310
    output_frame_header(s);
1311

  
1312
    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
1313
        output_audio_block(s, exp_strategy[blk], encoded_exp[blk],
1314
                           bap[blk], mdct_coef[blk], exp_shift[blk], blk);
1315
    }
1316

  
1317
    output_frame_end(s);
1318
}
1319

  
1320

  
1321
/**
1298 1322
 * Encode a single AC-3 frame.
1299 1323
 */
1300 1324
static int ac3_encode_frame(AVCodecContext *avctx,
......
1302 1326
{
1303 1327
    AC3EncodeContext *s = avctx->priv_data;
1304 1328
    const int16_t *samples = data;
1305
    int blk;
1306 1329
    int16_t planar_samples[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE+AC3_FRAME_SIZE];
1307 1330
    int32_t mdct_coef[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];
1308 1331
    uint8_t exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];
......
1323 1346

  
1324 1347
    compute_bit_allocation(s, bap, encoded_exp, exp_strategy, frame_bits);
1325 1348

  
1326
    output_frame_header(s, frame);
1327

  
1328
    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
1329
        output_audio_block(s, exp_strategy[blk], encoded_exp[blk],
1330
                           bap[blk], mdct_coef[blk], exp_shift[blk], blk);
1331
    }
1332

  
1333
    output_frame_end(s);
1349
    output_frame(s, frame, exp_strategy, encoded_exp, bap, mdct_coef, exp_shift);
1334 1350

  
1335 1351
    return s->frame_size;
1336 1352
}

Also available in: Unified diff