[FFmpeg-devel] [PATCH] E-AC-3 spectral extension
Justin Ruggles
justin.ruggles
Tue Aug 4 00:08:52 CEST 2009
Michael Niedermayer wrote:
> On Sun, Aug 02, 2009 at 12:17:39PM -0400, Justin Ruggles wrote:
> [...]
>> --- a/libavcodec/ac3dec.c
>> +++ b/libavcodec/ac3dec.c
>> @@ -822,14 +822,105 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
>>
>> /* 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_in_spx[1] = 1;
>> + } else {
>> + for (ch = 1; ch <= fbw_channels; ch++)
>> + s->channel_in_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);
>> + end_subband = get_bits(gbc, 3);
>> + start_subband = start_subband + 2 + (start_subband >= 6 ? start_subband-5 : 0);
>
> start_subband = get_bits(gbc, 3) + 2;
> if(start_subband > 7)
> start_subband += start_subband - 7;
>
>
>> + end_subband = end_subband < 4 ? end_subband+5 : 2*end_subband+3;
>
> same
> (both just a suggestion of course, i think its more readable)
yeah, those are pretty hard to read.
>> + if (spx_coord_exp == 15)
>> + spx_coord_mant <<= 1;
>> + else
>> + spx_coord_mant += 4;
>
> i would format that like:
>
> if (spx_coord_exp == 15) spx_coord_mant <<= 1;
> else spx_coord_mant += 4;
I don't have a preference. so I'll change it.
> [...]
>> diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
>> index 38c2deb..79ed731 100644
>> --- a/libavcodec/ac3dec.h
>> +++ b/libavcodec/ac3dec.h
>> @@ -42,6 +42,7 @@
>> #define AC3_MAX_COEFS 256
>> #define AC3_BLOCK_SIZE 256
>> #define MAX_BLOCKS 6
>> +#define SPX_MAX_BANDS 17
>>
>> typedef struct {
>> AVCodecContext *avctx; ///< parent context
>> @@ -88,6 +89,23 @@ typedef struct {
>> int cpl_coords[AC3_MAX_CHANNELS][18]; ///< coupling coordinates (cplco)
>> ///@}
>>
>> +///@defgroup spx spectral extension
>> +///@{
>> + int spx_in_use; ///< spectral extension in use (spxinu)
>
>> + uint8_t channel_in_spx[AC3_MAX_CHANNELS]; ///< channel in spectral extension (chinspx)
>
> channel uses spectral extension ?
yes, that sounds better. i've changed the variable name and the comment.
>> + int8_t spx_atten_code[AC3_MAX_CHANNELS]; ///< spx attenuation code (spxattencod)
>> + int spx_start_subband; ///< spx beginning frequency band (spxbegf)
>
>> + int spx_start_freq; ///< spx start frequency bin
>> + int spx_end_freq; ///< spx end frequency bin
>
> what are frequency bins?
MDCT coefficient index. Frequency bin is the term that the (E-)AC-3
spec uses throughout.
>
>> + int spx_copy_start_freq; ///< spx starting frequency for copying (copystartmant)
>
> frequency in hz ?
bin number. fixed.
>> + int num_spx_bands; ///< number of spx bands (nspxbnds)
>
>> + uint8_t spx_band_struct[SPX_MAX_BANDS]; ///< spectral extension band structure (spxbndstrc)
>
> what is a spectral extension band structure?
determines how many subbands are in each band. for each subband, 1
means combine with previous band, 0 means start new band. this is the
same format as the coupling band structure, hence the shared function to
decode it. I just added more information to the current documentation
for decode_band_structure().
Thanks,
Justin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eac3_spx_7.diff
Type: text/x-diff
Size: 20412 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090803/60263ecf/attachment.diff>
More information about the ffmpeg-devel
mailing list