Revision 98e34e71 libavcodec/ac3enc.c

View differences:

libavcodec/ac3enc.c
1055 1055
{
1056 1056
    int ch;
1057 1057
    int bits_left;
1058
    int snr_offset;
1058
    int snr_offset, snr_incr;
1059 1059

  
1060 1060
    bits_left = 8 * s->frame_size - (s->frame_bits + s->exponent_bits);
1061 1061

  
......
1069 1069
        return AVERROR(EINVAL);
1070 1070

  
1071 1071
    FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer);
1072
    for (snr_incr = 64; snr_incr > 0; snr_incr >>= 2) {
1072 1073
    while (snr_offset + 64 <= 1023 &&
1073
           bit_alloc(s, snr_offset + 64) <= bits_left) {
1074
        snr_offset += 64;
1074
           bit_alloc(s, snr_offset + snr_incr) <= bits_left) {
1075
        snr_offset += snr_incr;
1075 1076
        FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer);
1076 1077
    }
1077
    while (snr_offset + 16 <= 1023 &&
1078
           bit_alloc(s, snr_offset + 16) <= bits_left) {
1079
        snr_offset += 16;
1080
        FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer);
1081
    }
1082
    while (snr_offset + 4 <= 1023 &&
1083
           bit_alloc(s, snr_offset + 4) <= bits_left) {
1084
        snr_offset += 4;
1085
        FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer);
1086
    }
1087
    while (snr_offset + 1 <= 1023 &&
1088
           bit_alloc(s, snr_offset + 1) <= bits_left) {
1089
        snr_offset++;
1090
        FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer);
1091 1078
    }
1092 1079
    FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer);
1093 1080
    reset_block_bap(s);

Also available in: Unified diff