diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-10-14 22:28:09 +0300 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-10-14 22:33:09 +0300 |
commit | c3b6850e81d32f4ab17b0fc77eb96279e8f6a033 (patch) | |
tree | fe4df54cd519c467b4859e696d27310b44245915 | |
parent | 7a669a64073839a0d014f20a691014e332faaf69 (diff) | |
download | mpv-c3b6850e81d32f4ab17b0fc77eb96279e8f6a033.tar.bz2 mpv-c3b6850e81d32f4ab17b0fc77eb96279e8f6a033.tar.xz |
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.
-rw-r--r-- | libaf/af_lavcac3enc.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/libaf/af_lavcac3enc.c b/libaf/af_lavcac3enc.c index 59eb08ac3b..10a9eb58c8 100644 --- a/libaf/af_lavcac3enc.c +++ b/libaf/af_lavcac3enc.c @@ -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 || |