[FFmpeg-devel] [PATCH] atrac decoder

Michael Niedermayer michaelni
Tue Aug 11 18:43:37 CEST 2009


On Mon, Aug 10, 2009 at 11:10:40PM +0200, Benjamin Larsson wrote:
> Michael Niedermayer wrote:
> > On Mon, Jun 08, 2009 at 09:40:18PM +0200, Benjamin Larsson wrote:
[...]
> > 
> > [...]
> >> +static void at1_imdct_transform(ATRAC1Context *q, float *spec, float *out, int nbits, int reverse_spectrum)
> >> +{
> >> +    float* window;
> >> +    MDCTContext* mdct_context;
> >> +    int transf_size = 1 << nbits;
> >> +
> >> +    switch(nbits) {
> >> +        case 5:
> >> +            window = short_window;
> >> +            mdct_context = &q->mdct_ctx[0];
> >> +            break;
> >> +        case 7:
> >> +            window = mid_window;
> >> +            mdct_context = &q->mdct_ctx[1];
> >> +            break;
> >> +        case 8:
> >> +        default:
> >> +            window = long_window;
> >> +            mdct_context = &q->mdct_ctx[2];
> >> +    }
> >> +
> > 
> >> +    if (reverse_spectrum) {
> >> +        int i;
> >> +        for (i=0; i<transf_size/2; i++)
> >> +            FFSWAP(float, spec[i], spec[transf_size-1-i]);
> >> +    }
> > 
> > i think that can be avoided by decong in reverse order ...
> > 
> 
> 
> Would be possible if there where no short blocks. The logic to untangle
> those are not worth it.

elabrate please


> 
> > 
> >> +
> >> +    ff_imdct_calc(mdct_context,out,spec);
> > 
> > cant imdct_half be used?
> > 
> 
> Changed to
> 
> memset
> fmul
> fmul_rev
> memset
> 
> It was slightly faster and uses less memory.

you still use the full imdct


[...]
> > 
> > [...]
> >> +
> >> +static int at1_unpack_dequant(GetBitContext* gb, AT1SUContext* su, float spec[AT1_SU_SAMPLES])
> >> +{
> >> +    int bits_used, band_num, bfu_num, i;
> >> +
> >> +    /* parse the info byte (2nd byte) telling how much BFUs were coded */
> >> +    su->num_bfus = bfu_amount_tab1[get_bits(gb, 3)];
> >> +
> >> +    /* calc number of consumed bits:
> >> +        num_BFUs * (idwl(4bits) + idsf(6bits)) + bsm(8bits) + info_byte(8bits)
> >> +        + info_byte_copy(8bits) + bsm_copy(8bits) */
> >> +    bits_used = su->num_bfus * 10 + 32 +
> >> +                bfu_amount_tab2[get_bits(gb, 2)] * 4 +
> >> +                bfu_amount_tab3[get_bits(gb, 3)] * 6;
> >> +
> >> +    /* get word length index (idwl) for each BFU */
> >> +    for (i=0 ; i<su->num_bfus ; i++)
> >> +        su->idwls[i] = get_bits(gb, 4);
> >> +
> >> +    /* get scalefactor index (idsf) for each BFU */
> >> +    for (i=0 ; i<su->num_bfus ; i++)
> >> +        su->idsfs[i] = get_bits(gb, 6);
> >> +
> >> +    /* zero idwl/idsf for empty BFUs */
> >> +    for (i = su->num_bfus; i < AT1_MAX_BFU; i++)
> >> +        su->idwls[i] = su->idsfs[i] = 0;
> >> +
> >> +    /* read in the spectral data and reconstruct MDCT spectrum of this channel */
> >> +    for (band_num=0 ; band_num<AT1_QMF_BANDS ; band_num++) {
> >> +        for (bfu_num=bfu_bands_t[band_num] ; bfu_num<bfu_bands_t[band_num+1] ; bfu_num++) {
> >> +            int         pos;
> >> +
> >> +            int num_specs = specs_per_bfu[bfu_num];
> > 
> >> +            int word_len = idwl2wordlen[su->idwls[bfu_num]];
> > 
> > that remaping could be done outside the loops
> 
> 
> I think I understood this one time, now I just don't see how that could
> be done.

for all bfu_num
    table[bfu_num] = idwl2wordlen[get_bits()];

...
for (band_num=0 ; band_num<AT1_QMF_BANDS ; band_num++) {
    for (bfu_num=bfu_bands_t[band_num] ; bfu_num<bfu_bands_t[band_num+1] ; bfu_num++) {
        int         pos;

        int num_specs = specs_per_bfu[bfu_num];
        int word_len = table[bfu_num];


[...]

> +/* idwl to wordlen translation table */
> +static const uint8_t idwl2wordlen[16]= {0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};

doxy

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

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- 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/20090811/efc2cac4/attachment.pgp>



More information about the ffmpeg-devel mailing list