1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-22 14:52:43 +00:00

af_lavcac3enc: fix assert failure "s->expect_len <= s->pending_data_size"

The code handling input format negotiation incorrectly used the bps
value of the suggested input format instead of the format it was going
to actually use. As a result the player could abort with the above
assertion failure. Fix.
This commit is contained in:
Uoti Urpala 2010-10-14 22:28:09 +03:00
parent 7a669a6407
commit c3b6850e81

View File

@ -70,17 +70,6 @@ static int control(struct af_instance_s *af, int cmd, void *arg)
if (AF_FORMAT_IS_AC3(data->format) || data->nch < s->min_channel_num)
return AF_DETACH;
s->pending_len = 0;
s->expect_len = AC3_FRAME_SIZE * data->nch * data->bps;
assert(s->expect_len <= s->pending_data_size);
if (s->add_iec61937_header)
af->mul = (double)AC3_FRAME_SIZE * 2 * 2 / s->expect_len;
else
af->mul = (double)AC3_MAX_CODED_FRAME_SIZE / s->expect_len;
mp_msg(MSGT_AFILTER, MSGL_DBG2, "af_lavcac3enc reinit: %d, %d, %f, %d.\n",
data->nch, data->rate, af->mul, s->expect_len);
af->data->format = AF_FORMAT_S16_NE;
if (data->rate == 48000 || data->rate == 44100 || data->rate == 32000)
af->data->rate = data->rate;
@ -93,6 +82,17 @@ static int control(struct af_instance_s *af, int cmd, void *arg)
af->data->bps = 2;
test_output_res = af_test_output(af, data);
s->pending_len = 0;
s->expect_len = AC3_FRAME_SIZE * data->nch * af->data->bps;
assert(s->expect_len <= s->pending_data_size);
if (s->add_iec61937_header)
af->mul = (double)AC3_FRAME_SIZE * 2 * 2 / s->expect_len;
else
af->mul = (double)AC3_MAX_CODED_FRAME_SIZE / s->expect_len;
mp_msg(MSGT_AFILTER, MSGL_DBG2, "af_lavcac3enc reinit: %d, %d, %f, %d.\n",
data->nch, data->rate, af->mul, s->expect_len);
bit_rate = s->bit_rate ? s->bit_rate : default_bit_rate[af->data->nch];
if (s->lavc_actx->channels != af->data->nch ||