[FFmpeg-devel] [PATCH] ac3enc: fix bug in stereo rematrixing decision.
Måns Rullgård
mans
Wed Feb 16 00:46:27 CET 2011
Justin Ruggles <justin.ruggles at gmail.com> writes:
> The rematrixing strategy reuse flags are not reset between frames, so they
> need to be initialized for all blocks, not just block 0.
> ---
> libavcodec/ac3enc.c | 5 ++---
> tests/ref/acodec/ac3_fixed | 2 +-
> tests/ref/seek/ac3_rm | 30 ++++++++++++++++++++----------
> 3 files changed, 23 insertions(+), 14 deletions(-)
>
>
> diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
> index 72a6c89..6481992 100644
> --- a/libavcodec/ac3enc.c
> +++ b/libavcodec/ac3enc.c
> @@ -310,9 +310,9 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s)
>
> nb_coefs = FFMIN(s->nb_coefs[0], s->nb_coefs[1]);
>
> - s->blocks[0].new_rematrixing_strategy = 1;
> for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
> block = &s->blocks[blk];
> + block->new_rematrixing_strategy = !blk;
> for (bnd = 0; bnd < 4; bnd++) {
> /* calculate calculate sum of squared coeffs for one band in one block */
> int start = ff_ac3_rematrix_band_tab[bnd];
> @@ -336,8 +336,7 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s)
> block->rematrixing_flags[bnd] = 0;
>
> /* determine if new rematrixing flags will be sent */
> - if (blk &&
> - !block->new_rematrixing_strategy &&
> + if (!block->new_rematrixing_strategy &&
> block->rematrixing_flags[bnd] != block0->rematrixing_flags[bnd]) {
> block->new_rematrixing_strategy = 1;
> }
You could drop the !block->new_rematrixing_strategy condition here.
Writing the same value twice does no harm, and one check less is faster.
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list