Skip to content

Commit

Permalink
dct: bypass table allocation for DCT_II of size 32
Browse files Browse the repository at this point in the history
The size-32 DCT_II has a special implementation which doesn't use
the normal tables.  Skipping allocation of these in this case saves
some memory.

Signed-off-by: Mans Rullgard <mans@mansr.com>
  • Loading branch information
mansr committed May 16, 2011
1 parent 257de5f commit 721d6f2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions libavcodec/dct.c
Expand Up @@ -180,9 +180,14 @@ av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse)
int n = 1 << nbits;
int i;

memset(s, 0, sizeof(*s));

s->nbits = nbits;
s->inverse = inverse;

if (inverse == DCT_II && nbits == 5) {
s->dct_calc = dct32_func;
} else {
ff_init_ff_cos_tabs(nbits+2);

s->costab = ff_cos_tabs[nbits+2];
Expand All @@ -203,9 +208,7 @@ av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse)
case DCT_III: s->dct_calc = ff_dct_calc_III_c; break;
case DST_I : s->dct_calc = ff_dst_calc_I_c; break;
}

if (inverse == DCT_II && nbits == 5)
s->dct_calc = dct32_func;
}

s->dct32 = dct32;
if (HAVE_MMX) ff_dct_init_mmx(s);
Expand Down

0 comments on commit 721d6f2

Please sign in to comment.