Revision 24834c19

View differences:

libavcodec/ac3dec.c
772 772
            s->cpl_in_use[blk] = get_bits1(gbc);
773 773
        if (s->cpl_in_use[blk]) {
774 774
            /* coupling in use */
775
            int cpl_begin_freq, cpl_end_freq;
775
            int cpl_start_subband, cpl_end_subband;
776 776

  
777 777
            if (channel_mode < AC3_CHMODE_STEREO) {
778 778
                av_log(s->avctx, AV_LOG_ERROR, "coupling not allowed in mono or dual-mono\n");
......
801 801

  
802 802
            /* coupling frequency range */
803 803
            /* TODO: modify coupling end freq if spectral extension is used */
804
            cpl_begin_freq = get_bits(gbc, 4);
805
            cpl_end_freq = get_bits(gbc, 4);
806
            if (3 + cpl_end_freq - cpl_begin_freq < 0) {
807
                av_log(s->avctx, AV_LOG_ERROR, "3+cplendf = %d < cplbegf = %d\n", 3+cpl_end_freq, cpl_begin_freq);
804
            cpl_start_subband = get_bits(gbc, 4);
805
            cpl_end_subband = get_bits(gbc, 4);
806
            if (3 + cpl_end_subband - cpl_start_subband < 0) {
807
                av_log(s->avctx, AV_LOG_ERROR, "3+cplendf = %d < cplbegf = %d\n", 3+cpl_end_subband, cpl_start_subband);
808 808
                return -1;
809 809
            }
810
            s->num_cpl_bands = s->num_cpl_subbands = 3 + cpl_end_freq - cpl_begin_freq;
811
            s->start_freq[CPL_CH] = cpl_begin_freq * 12 + 37;
812
            s->end_freq[CPL_CH] = cpl_end_freq * 12 + 73;
810
            s->num_cpl_bands = s->num_cpl_subbands = 3 + cpl_end_subband - cpl_start_subband;
811
            s->start_freq[CPL_CH] = cpl_start_subband * 12 + 37;
812
            s->end_freq[CPL_CH] = cpl_end_subband * 12 + 73;
813 813

  
814 814
            /* coupling band structure */
815 815
            if (!s->eac3 || get_bits1(gbc)) {
......
818 818
                }
819 819
            } else if (!blk) {
820 820
                memcpy(s->cpl_band_struct,
821
                       &ff_eac3_default_cpl_band_struct[cpl_begin_freq+1],
821
                       &ff_eac3_default_cpl_band_struct[cpl_start_subband+1],
822 822
                       s->num_cpl_subbands-1);
823 823
            }
824 824
            s->cpl_band_struct[s->num_cpl_subbands-1] = 0;

Also available in: Unified diff