Revision e96dc767 libavcodec/ac3enc.c

View differences:

libavcodec/ac3enc.c
1572 1572
static void output_frame_end(AC3EncodeContext *s)
1573 1573
{
1574 1574
    const AVCRC *crc_ctx = av_crc_get_table(AV_CRC_16_ANSI);
1575
    int frame_size_58, pad_bytes, crc1, crc2, crc_inv;
1575
    int frame_size_58, pad_bytes, crc1, crc2_partial, crc2, crc_inv;
1576 1576
    uint8_t *frame;
1577 1577

  
1578 1578
    frame_size_58 = ((s->frame_size >> 2) + (s->frame_size >> 4)) << 1;
......
1594 1594
    AV_WB16(frame + 2, crc1);
1595 1595

  
1596 1596
    /* compute crc2 */
1597
    crc2 = av_bswap16(av_crc(crc_ctx, 0,
1598
                             frame + frame_size_58,
1599
                             s->frame_size - frame_size_58 - 2));
1597
    crc2_partial = av_crc(crc_ctx, 0, frame + frame_size_58,
1598
                          s->frame_size - frame_size_58 - 3);
1599
    crc2 = av_crc(crc_ctx, crc2_partial, frame + s->frame_size - 3, 1);
1600
    /* ensure crc2 does not match sync word by flipping crcrsv bit if needed */
1601
    if (crc2 == 0x770B) {
1602
        frame[s->frame_size - 3] ^= 0x1;
1603
        crc2 = av_crc(crc_ctx, crc2_partial, frame + s->frame_size - 3, 1);
1604
    }
1605
    crc2 = av_bswap16(crc2);
1600 1606
    AV_WB16(frame + s->frame_size - 2, crc2);
1601 1607
}
1602 1608

  

Also available in: Unified diff