[FFmpeg-devel] [PATCH] E-AC-3 spectral extension (bump)

Michael Niedermayer michaelni
Fri Mar 26 16:57:30 CET 2010


On Fri, Mar 26, 2010 at 10:19:22AM +0100, Christophe Gisquet wrote:
> Hi,
> 
> 2010/3/25 Michael Niedermayer <michaelni at gmx.at>:
> > iam not 100% happy but this seems to be blocking things so lets drop this
> > optimization idea, it appears minor enough
> 
> So here's another patch, ran through patcheck.
> 
> Best regards,
> Christophe

>  Changelog                 |    1 
>  libavcodec/ac3dec.c       |  118 ++++++++++++++++++++++++++++++++++++++++++----
>  libavcodec/ac3dec.h       |   47 ++++++++++++++++++
>  libavcodec/ac3dec_data.c  |    6 ++
>  libavcodec/ac3dec_data.h  |    1 
>  libavcodec/eac3dec.c      |  106 +++++++++++++++++++++++++++++++++++++----
>  libavcodec/eac3dec_data.c |   39 +++++++++++++++
>  libavcodec/eac3dec_data.h |    1 
>  8 files changed, 298 insertions(+), 21 deletions(-)
> 44607388d178664e2a17918100fb7e7923997c1f  eac3_spx_10.diff
> Index: Changelog
> ===================================================================
> --- Changelog	(revision 22692)
> +++ Changelog	(working copy)
> @@ -66,6 +66,7 @@
>  - VorbisComment writing for FLAC, Ogg FLAC and Ogg Speex files
>  - RTP depacketization of Theora
>  - HTTP Digest authentication
> +- spectral extension support in the E-AC-3 decoder
>  
>  
>  
> Index: libavcodec/ac3dec.c
> ===================================================================
> --- libavcodec/ac3dec.c	(revision 22692)
> +++ libavcodec/ac3dec.c	(working copy)
> @@ -815,15 +815,105 @@
>  
>      /* spectral extension strategy */
>      if (s->eac3 && (!blk || get_bits1(gbc))) {
> -        if (get_bits1(gbc)) {
> -            av_log_missing_feature(s->avctx, "Spectral extension", 1);
> -            return -1;
> +        s->spx_in_use = get_bits1(gbc);
> +        if (s->spx_in_use) {
> +            int copy_start, start_subband, end_subband, start_freq, end_freq;
> +
> +            /* determine which channels use spx */
> +            if (s->channel_mode == AC3_CHMODE_MONO) {
> +                s->channel_uses_spx[1] = 1;
> +            } else {
> +                for (ch = 1; ch <= fbw_channels; ch++)
> +                    s->channel_uses_spx[ch] = get_bits1(gbc);
> +            }
> +
> +            /* get the frequency bins of the spx copy region and the spx start
> +               and end subbands */
> +            copy_start    = get_bits(gbc, 2);
> +            start_subband = get_bits(gbc, 3) + 2;
> +            if (start_subband > 7)
> +                start_subband += start_subband - 7;
> +            end_subband   = get_bits(gbc, 3) + 5;
> +            if (end_subband   > 7)
> +                end_subband   += end_subband   - 7;
> +            copy_start    = copy_start    * 12 + 25;
> +            start_freq    = start_subband * 12 + 25;
> +            end_freq      = end_subband   * 12 + 25;
> +
> +            /* check validity of spx ranges */
> +            if (start_subband >= end_subband) {
> +                av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
> +                       "range (%d >= %d)\n", start_subband, end_subband);
> +                return -1;
> +            }
> +            if (copy_start >= start_freq) {
> +                av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
> +                       "copy start bin (%d >= %d)\n", copy_start, start_freq);
> +                return -1;
> +            }
> +

> +            s->spx_dst_start_freq = copy_start;
> +            s->spx_src_start_freq      = start_freq;
> +            s->spx_dst_end_freq        = end_freq;

vertical align
also the src/dst could beadded to the local 3 vars here

[...]

> +///@defgroup spx spectral extension
> +///@{
> +    int spx_in_use;                             ///< spectral extension in use              (spxinu)
> +    uint8_t channel_uses_spx[AC3_MAX_CHANNELS]; ///< channel uses spectral extension        (chinspx)
> +    int8_t spx_atten_code[AC3_MAX_CHANNELS];    ///< spx attenuation code                   (spxattencod)
> +    int spx_src_start_freq;                         ///< spx start frequency bin
> +    int spx_dst_end_freq;                           ///< spx end frequency bin

align messed up too

i guess you should grep forthe changed var and make sure it still looks ok


> +    int spx_dst_start_freq;                    ///< spx starting frequency bin for copying (copystartmant)
> +                                                ///< the copy region ends at the start of the spx region.

too

[....]
> @@ -492,13 +577,11 @@
>      }
>  
>      /* spectral extension attenuation data */
> -    if (parse_spx_atten_data) {
> -        av_log_missing_feature(s->avctx, "Spectral extension attenuation", 1);
> -        for (ch = 1; ch <= s->fbw_channels; ch++) {
> -            if (get_bits1(gbc)) { // channel has spx attenuation
> -                skip_bits(gbc, 5); // skip spx attenuation code
> -            }
> -        }
> +    for (ch = 1; ch <= s->fbw_channels; ch++) {

> +        if (parse_spx_atten_data && get_bits1(gbc))
> +            s->spx_atten_code[ch] = get_bits(gbc, 5);
> +        else

should have {}
didnt patcheck detect this?

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100326/ec4710ab/attachment.pgp>



More information about the ffmpeg-devel mailing list