Revision e62ef8f2

View differences:

libavcodec/ac3enc.c
111 111
    int channel_mode;                       ///< channel mode                           (acmod)
112 112
    const uint8_t *channel_map;             ///< channel map used to reorder channels
113 113

  
114
    int cutoff;                             ///< user-specified cutoff frequency, in Hz
114 115
    int bandwidth_code[AC3_MAX_CHANNELS];   ///< bandwidth code (0 to 60)               (chbwcod)
115 116
    int nb_coefs[AC3_MAX_CHANNELS];
116 117

  
......
1691 1692
    s->bit_rate        = avctx->bit_rate;
1692 1693
    s->frame_size_code = i << 1;
1693 1694

  
1695
    /* validate cutoff */
1696
    if (avctx->cutoff < 0) {
1697
        av_log(avctx, AV_LOG_ERROR, "invalid cutoff frequency\n");
1698
        return AVERROR(EINVAL);
1699
    }
1700
    s->cutoff = avctx->cutoff;
1701
    if (s->cutoff > (s->sample_rate >> 1))
1702
        s->cutoff = s->sample_rate >> 1;
1703

  
1694 1704
    return 0;
1695 1705
}
1696 1706

  
......
1700 1710
 * The user can optionally supply a cutoff frequency. Otherwise an appropriate
1701 1711
 * default value will be used.
1702 1712
 */
1703
static av_cold void set_bandwidth(AC3EncodeContext *s, int cutoff)
1713
static av_cold void set_bandwidth(AC3EncodeContext *s)
1704 1714
{
1705 1715
    int ch, bw_code;
1706 1716

  
1707
    if (cutoff) {
1717
    if (s->cutoff) {
1708 1718
        /* calculate bandwidth based on user-specified cutoff frequency */
1709 1719
        int fbw_coeffs;
1710
        cutoff         = av_clip(cutoff, 1, s->sample_rate >> 1);
1711
        fbw_coeffs     = cutoff * 2 * AC3_MAX_COEFS / s->sample_rate;
1720
        fbw_coeffs     = s->cutoff * 2 * AC3_MAX_COEFS / s->sample_rate;
1712 1721
        bw_code        = av_clip((fbw_coeffs - 73) / 3, 0, 60);
1713 1722
    } else {
1714 1723
        /* use default bandwidth setting */
......
1818 1827
    s->samples_written = 0;
1819 1828
    s->frame_size      = s->frame_size_min;
1820 1829

  
1821
    set_bandwidth(s, avctx->cutoff);
1830
    set_bandwidth(s);
1822 1831

  
1823 1832
    exponent_init(s);
1824 1833

  

Also available in: Unified diff