[FFmpeg-devel] [PATCH] 1D DCT for dsputil
Alex Converse
alex.converse
Fri Jan 8 18:43:48 CET 2010
On Fri, Jan 8, 2010 at 10:12 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Fri, Jan 08, 2010 at 01:02:19AM -0500, Alex Converse wrote:
>> On Tue, Dec 22, 2009 at 8:04 PM, Alex Converse <alex.converse at gmail.com> wrote:
>> > On Tue, Dec 22, 2009 at 6:25 AM, ?<pross at xvid.org> wrote:
>> >> On Mon, Dec 21, 2009 at 02:02:00PM -0500, Daniel Verkamp wrote:
>> >>> Hi,
>> >>>
>> >>> In an effort to get at least some parts of the Bink patch committed, I
>> >>> am splitting it into separable pieces.
>> >>>
>> >>> This is a one-dimensional floating-point DCT used by Bink audio. ?The
>> >>> actual code was written by Peter Ross.
>> >>>
>> >>> The comments I myself have about this code:
>> >>> - Should it be using math.h cos()/sin() or some lookup table approach?
>> >>> - Can there be a test written? (I don't know enough about the math
>> >>> involved to write a sane test...)
>> >>
>> >> Thanks for taking the time to split the patch.
>> >>
>> >> Note that the algorithm here is inefficient. It requires a 2*N FFT,
>> >> whereas there are ways of achieving this with 1*N FFT. Michael posted
>> >> some info on this many months ago.
>> >>
>> >
>> > I had a 1-D 1*N DCT but it generated the transpose (i.e.
>> > uninterleaved). I can dig it up when I come back from xmas holiday if
>> > you are interested.
>> >
>>
>> As promised...
>
> [...]
>> +av_cold int ff_dct_init(DCTContext *s, int nbits, int inverse)
>> +{
>> + ? ?int n = 1 << nbits;
>> +
>> + ? ?s->nbits ? ?= nbits;
>> + ? ?s->inverse ?= inverse;
>> +
>> + ? ?s->data = av_malloc(sizeof(FFTComplex) * 2 * n);
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?^^^^^
>
This should be FFTSample.
>> + ? ?if (!s->data)
>> + ? ? ? ?return -1;
>> +
>> + ? ?if (ff_rdft_init(&s->rdft, nbits+1, inverse) < 0)
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?^^^^^^^
>
> doesnt look like 1*N to me
> am i missing something?
>
The RDFT initializes an FFT of size nbits-1.
av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
{
int n = 1 << nbits;
int i;
const double theta = (trans == RDFT || trans == IRIDFT ? -1 : 1)*2*M_PI/n;
s->nbits = nbits;
s->inverse = trans == IRDFT || trans == IRIDFT;
s->sign_convention = trans == RIDFT || trans == IRIDFT ? 1 : -1;
if (nbits < 4 || nbits > 16)
return -1;
if (ff_fft_init(&s->fft, nbits-1, trans == IRDFT || trans == RIDFT) < 0)
return -1;
ff_init_ff_cos_tabs(nbits);
s->tcos = ff_cos_tabs[nbits];
s->tsin = ff_sin_tabs[nbits]+(trans == RDFT || trans == IRIDFT)*(n>>2);
#if !CONFIG_HARDCODED_TABLES
for (i = 0; i < (n>>2); i++) {
s->tsin[i] = sin(i*theta);
}
#endif
return 0;
}
More information about the ffmpeg-devel
mailing list