[Ffmpeg-devel] [RFC] IMC decoder
Benjamin Larsson
banan
Mon Oct 30 10:39:24 CET 2006
Kostya skrev:
> On Mon, Oct 30, 2006 at 01:26:51AM +0100, Michael Niedermayer wrote:
>
>> Hi
>>
>> On Sun, Oct 29, 2006 at 08:35:11AM +0200, Kostya wrote:
>>
>>> Here is Intel Music Codec decoder RE'd by Maxim Poliakovski, FFmpeg'ized
>>> by Benjamin Larsson, cleaned and fixed by me.
>>>
First thanks for cleaning up my code. And here are some comments.
>>
>> ------------------------------------------------------------------------
>>
>> Index: Changelog
>> ===================================================================
>> --- Changelog (revision 6830)
>> +++ Changelog (working copy)
>> @@ -65,6 +65,7 @@
>> - MTV demuxer
>> - TIFF picture decoder
>> - GIF picture decoder
>> +- Intel Music decoder
>>
I think that the official name of the codec is "Intel Music Coder".
>>
>> [...]
>>
>> +
>> +/**
>> + * @file imc.c IMC - Intel Music Codec
>>
s/Codec/Coder/
>> + * A mdct based codec using a 256 points large transform
>> + * divied into 32 bands with some mix of scale factors.
>> + * Only mono is supported.
>> + *
>> + */[...]
[...]
>> +typedef struct {
>> + float old_floor[BANDS];
>> + float flcoeffs1[BANDS];
>> + float flcoeffs2[BANDS];
>> + float flcoeffs3[BANDS];
>> + float flcoeffs4[BANDS];
>> + float flcoeffs5[BANDS];
>> + float flcoeffs6[BANDS];
>> + float CWdecoded[COEFFS];
>> +
>> + /** MDCT tables */
>> + //@{
>> + float mdct_sine_window[COEFFS];
>> + float post_coef1[COEFFS];
>> + float post_coef2[COEFFS];
>> + float pre_coef1[COEFFS];
>> + float pre_coef2[COEFFS];
>> + float last_fft_im[COEFFS];
>>
last_fft_im is the old non overlapped non windowed samples that is used
in the last part of the mdct so the last_fft_im name might not be the best.
And the coef part of the twiddle factors (post/pre_*) could be renamed
*_sin or *_cos depending on what they are.
>> +
>> +void imc_imdct256(IMCContext *q) {
>> + int i;
>> + float re, im;
>> +
>> + /* prerotation */
>> + for(i=0; i < COEFFS/2; i++){
>> + q->samples[i].re = -(q->pre_coef1[i] * q->CWdecoded[COEFFS-1-i*2]) -
>> + (q->pre_coef2[i] * q->CWdecoded[i*2]);
>> + q->samples[i].im = (q->pre_coef2[i] * q->CWdecoded[COEFFS-1-i*2]) -
>> + (q->pre_coef1[i] * q->CWdecoded[i*2]);
>> + }
>> +
>> + /* FFT */
>> + ff_fft_permute(&q->fft, q->samples);
>> + ff_fft_calc (&q->fft, q->samples);
>> +
>> + /* postrotation, window and reorder */
>> + for(i = 0; i < COEFFS/2; i++){
>> + re = (q->samples[i].re * q->post_coef1[i]) + (-q->samples[i].im * q->post_coef2[i]);
>> + im = (-q->samples[i].im * q->post_coef1[i]) - (q->samples[i].re * q->post_coef2[i]);
>> + q->out_samples[i*2] = (q->mdct_sine_window[COEFFS-1-i*2] * q->last_fft_im[i]) + (q->mdct_sine_window[i*2] * re);
>> + q->out_samples[COEFFS-1-i*2] = (q->mdct_sine_window[i*2] * q->last_fft_im[i]) - (q->mdct_sine_window[COEFFS-1-i*2] * re);
>> + q->last_fft_im[i] = im;
>> + }
>> +}
>>
This looks alot like the ffmpeg imdct function with the exception of the
postrotation, window and reorder part. The thing that can be tried is to
like the do_imdct_512 function in the soc ac3 decoder. If that doesn't
work then the transforms aren't identical and the code can't be replaced.
>> +
>> +
>> +static int imc_decode_close(AVCodecContext * avctx)
>> +{
>> + IMCContext *q = avctx->priv_data;
>> +
>> + ff_fft_end(&q->fft);
>>
Shouldn't the VLC table be free'd also ?
>> + return 0;
>> +}
>> +
>> +
>> +AVCodec imc_decoder = {
>> + .name = "imc",
>> + .type = CODEC_TYPE_AUDIO,
>> + .id = CODEC_ID_IMC,
>> + .priv_data_size = sizeof(IMCContext),
>> + .init = imc_decode_init,
>> + .close = imc_decode_close,
>> + .decode = imc_decode_frame,
>> +};
>> Index: libavcodec/avcodec.h
>> ===================================================================
>> --- libavcodec/avcodec.h (revision 6830)
>> +++ libavcodec/avcodec.h (working copy)
>> @@ -233,6 +233,7 @@
>> CODEC_ID_QCELP,
>> CODEC_ID_WAVPACK,
>> CODEC_ID_DSICINAUDIO,
>> + CODEC_ID_IMC,
>>
>> /* subtitle codecs */
>> CODEC_ID_DVD_SUBTITLE= 0x17000,
>> @@ -2304,6 +2305,7 @@
>> extern AVCodec dsicinaudio_decoder;
>> extern AVCodec tiertexseqvideo_decoder;
>> extern AVCodec tiff_decoder;
>> +extern AVCodec imc_decoder;
>>
>> /* pcm codecs */
>> #define PCM_CODEC(id, name) \
>> Index: doc/ffmpeg-doc.texi
>> ===================================================================
>> --- doc/ffmpeg-doc.texi (revision 6830)
>> +++ doc/ffmpeg-doc.texi (working copy)
>> @@ -934,6 +934,7 @@
>> @item WavPack Audio @tab @tab X
>> @item Cin Audio @tab @tab X
>> @tab Codec used in Delphine Software games.
>> + at item Intel Music Codec @tab @tab X
>>
s/Codec/Coder/
MvH
Benjamin Larsson
More information about the ffmpeg-devel
mailing list