Revision a1d0f511 libavcodec/ac3enc.c

View differences:

libavcodec/ac3enc.c
1123 1123

  
1124 1124

  
1125 1125
/**
1126
 * Reduce the bandwidth to reduce the number of bits used for a given SNR offset.
1127
 * This is a second fallback for when bit allocation still fails after exponents
1128
 * have been downgraded.
1129
 * @return non-zero if bandwidth reduction was unsuccessful
1130
 */
1131
static int reduce_bandwidth(AC3EncodeContext *s, int min_bw_code)
1132
{
1133
    int ch;
1134

  
1135
    if (s->bandwidth_code[0] > min_bw_code) {
1136
        for (ch = 0; ch < s->fbw_channels; ch++) {
1137
            s->bandwidth_code[ch]--;
1138
            s->nb_coefs[ch] = s->bandwidth_code[ch] * 3 + 73;
1139
        }
1140
        return 0;
1141
    }
1142
    return -1;
1143
}
1144

  
1145

  
1146
/**
1147 1126
 * Perform bit allocation search.
1148 1127
 * Finds the SNR offset value that maximizes quality and fits in the specified
1149 1128
 * frame size.  Output is the SNR offset and a set of bit allocation pointers
......
1168 1147
            continue;
1169 1148
        }
1170 1149

  
1171
        /* fallback 2: reduce bandwidth */
1172
        /* only do this if the user has not specified a specific cutoff
1173
           frequency */
1174
        if (!s->cutoff && !reduce_bandwidth(s, 0)) {
1175
            process_exponents(s);
1176
            ret = compute_bit_allocation(s);
1177
            continue;
1178
        }
1179

  
1180 1150
        /* fallbacks were not enough... */
1181 1151
        break;
1182 1152
    }

Also available in: Unified diff