[FFmpeg-devel] [PATCH] WMA Voice decoder

Ronald S. Bultje rsbultje
Sat Jan 30 00:51:11 CET 2010


Hi,

On Sat, Jan 23, 2010 at 12:06 AM, Vitor Sessak <vitor1001 at gmail.com> wrote:
[..]

Getitng there on adapting the patch, a few things remaining...

>> +static int synth_superframe(AVCodecContext *ctx,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ?float *samples, int *data_size)
>> +{
>> + ? ?WMAVoiceContext *s = ctx->priv_data;
>> + ? ?GetBitContext *gb = &s->gb, s_gb;
>> + ? ?int n, res, n_samples = 480;
>> + ? ?double lsps[MAX_FRAMES][MAX_LSPS];
>> + ? ?const double *mean_lsf = s->lsps == 16 ?
>> + ? ? ? ?ff_wmavoice_mean_lsf16[s->lsp_def_mode] :
>> ff_wmavoice_mean_lsf10[s->lsp_def_mode];
>> + ? ?float excitation[MAX_SIGNAL_HISTORY + MAX_SFRAMESIZE];
>> + ? ?float synth[MAX_LSPS + MAX_SFRAMESIZE];
>> +
>> + ? ?memcpy(synth, ? ? ?s->synth_history,
>> + ? ? ? ? ? s->lsps ? ? ? ? ? ? * sizeof(float));
>> + ? ?memcpy(excitation, s->excitation_history,
>> + ? ? ? ? ? s->history_nsamples * sizeof(float));
>
> I slightly prefer (one memcpy less) instead of
>
> memcpy(synth, s->synth_hist, mem_size);
> decode(synth);
> memcpy(s->synth_hist, synth + size - mem_size, mem_size);
>
> doing
>
> decode(s->synth);
> memmove(s->synth, s->synth + size, mem_size);

Anyone have an opinion here? I don't care much either way, but do we
generally like less memory allocated for more memcpy()s or the other
way around? We're talking little here btw, this is +/- an extra
480entries x 4 bytes x 2 structs =~ 4 kB memory, I could statically
allocate them as part of WMAVoiceContext to keep the amount of
av_malloc()s low. If fragmentation is an issue, I can also allocate
them separately, but then I unfortunately need to add a _close()
function also (+=10LOC).

Ronald



More information about the ffmpeg-devel mailing list