[FFmpeg-devel] [PATCH] wmapro decoder

Diego Biurrun diego
Sun Aug 2 15:34:13 CEST 2009


On Sun, Aug 02, 2009 at 03:11:50PM +0200, Sascha Sommer wrote:
> 
> --- libavcodec/wmaprodec.c	(revision 19563)
> +++ libavcodec/wmaprodec.c	(working copy)
> @@ -1,4 +1,245 @@
> +
>  /**
> + * @file  libavcodec/wmaprodec.c
> + * @brief wmapro decoder implementation
> + * Wmapro is an MDCT based codec comparable to wma standard or AAC.

Please settle on a consistent spelling for wma/wmapro.

> + * The decoding therefore consist of the following steps:

consistS

> + * - reconstruction of per channel data

per-channel

> + * The coefficients that cary the audio signal in the frequency domain

carry

> + * are transmitted as huffman coded vectors with 4, 2 and 1 elements.

huffman-coded

> + * In addition to that, the encoder can switch to a run level coding scheme

runlevel

> + * by transmitting subframen_length / 128 zero coefficients.

subframe_length?

> + * between the subframes of a channel. Scale factors are initially DPCM coded.

DPCM-coded

> + * Once scale factors are shared, the differences are transmitted as run
> + * level codes.

runlevel

Commit with the suggested changes.

> +static VLC              sf_vlc;           ///< scale factor dpcm vlc

DPCM

> +    DSPContext       dsp;                           ///< accelerated dsp functions

DSP

> +    DECLARE_ALIGNED_16(float, tmp[WMAPRO_BLOCK_MAX_SIZE]); ///< imdct output buffer

IMDCT

> +static void av_cold dump_context(WMA3DecodeContext *s)
> +{
> +#define PRINT(a,b)     av_log(s->avctx,AV_LOG_DEBUG," %s = %d\n", a, b);
> +#define PRINT_HEX(a,b) av_log(s->avctx,AV_LOG_DEBUG," %s = %x\n", a, b);

Spaces after commas aid readability :)

> @@ -20,6 +256,374 @@
>  
> +        for (i=0 ; i<avctx->extradata_size ; i++)

K&R style please, i.e.

  for (i = 0; i < avctx->extradata_size; i++)

same below

> +    s->skip_frame = 1; /** skip first frame */
> +    s->packet_loss = 1;
> +    s->len_prefix = (s->decode_flags & 0x40);

align

> +        av_log(avctx, AV_LOG_ERROR, "invalid number of subframes %i\n",
> +                      s->max_num_subframes);

indentation

> +    INIT_VLC_STATIC(&sf_vlc, SCALEVLCBITS, HUFF_SCALE_SIZE,
> +                 scale_huffbits, 1, 1,
> +                 scale_huffcodes, 2, 2, 616);
> +
> +    INIT_VLC_STATIC(&sf_rl_vlc, VLCBITS, HUFF_SCALE_RL_SIZE,
> +                 scale_rl_huffbits, 1, 1,
> +                 scale_rl_huffcodes, 4, 4, 1406);
> +
> +    INIT_VLC_STATIC(&coef_vlc[0], VLCBITS, HUFF_COEF0_SIZE,
> +                 coef0_huffbits, 1, 1,
> +                 coef0_huffcodes, 4, 4, 2108);
> +
> +    INIT_VLC_STATIC(&coef_vlc[1], VLCBITS, HUFF_COEF1_SIZE,
> +                 coef1_huffbits, 1, 1,
> +                 coef1_huffcodes, 4, 4, 3912);
> +
> +    INIT_VLC_STATIC(&vec4_vlc, VLCBITS, HUFF_VEC4_SIZE,
> +                 vec4_huffbits, 1, 1,
> +                 vec4_huffcodes, 2, 2, 604);
> +
> +    INIT_VLC_STATIC(&vec2_vlc, VLCBITS, HUFF_VEC2_SIZE,
> +                 vec2_huffbits, 1, 1,
> +                 vec2_huffcodes, 2, 2, 562);
> +
> +    INIT_VLC_STATIC(&vec1_vlc, VLCBITS, HUFF_VEC1_SIZE,
> +                 vec1_huffbits, 1, 1,
> +                 vec1_huffcodes, 2, 2, 562);

indentation

> +            if ( offset > s->sfb_offsets[i][band - 1] )

Drop the spaces after the ( and before the ).

> +        s->sfb_offsets[i][band - 1] = subframe_len;
> +        s->num_sfb[i] = band - 1;

align

There are many more opportunities for alignment below.

> +    for (i=0 ; i<WMAPRO_BLOCK_SIZES ; i++) {
> +        const int n = 1 << (WMAPRO_BLOCK_MAX_BITS - i);
> +        const int win_idx = WMAPRO_BLOCK_MAX_BITS - i - 7;

const int n       = 1 << (WMAPRO_BLOCK_MAX_BITS - i);
const int win_idx =       WMAPRO_BLOCK_MAX_BITS - i - 7;

> +    /* should never consume more than 3073 bits (256 iterations for the
> +     * while loop when always the minimum amount of 128 samples is substracted
> +     * from missing samples in the 8 channel case)

Capitalize, end in period.

> +        if (get_bits1(&s->gb)) {
> +            av_log_ask_for_sample(s->avctx,
> +                   "unsupported channel transform bit\n");

indentation

> +                    if (!s->channel[channel_idx].grouped
> +                       && get_bits1(&s->gb)) {

indentation

> +AVCodec wmapro_decoder =
> +{

AVCodec wmapro_decoder = {

> --- doc/general.texi	(revision 19563)
> +++ doc/general.texi	(working copy)
> @@ -617,6 +617,7 @@
>  @item Westwood Audio (SND1)  @tab     @tab  X
>  @item Windows Media Audio 1  @tab  X  @tab  X
>  @item Windows Media Audio 2  @tab  X  @tab  X
> + at item Windows Media Audio Pro @tab     @tab  X
>  @end multitable

nit: Align the @tab.

Diego



More information about the ffmpeg-devel mailing list