From 2d39b967a05eecdf1ee6f26da564bacd165d8cf1 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 26 Mar 2024 12:32:38 -0400 Subject: [PATCH] MT#55283 fix missing EVS size collision avoidance With hf-only=0 set and cmr=1 also set, we send a blank CMR with each packet, which forces use of HF format packets. This in turn can lead to size collisions (e.g. mode 1 = 18 bytes, + CMR + TOC = 20 bytes, which is the same as mode 2) which can confuse the decoder. Add the required size collision logic. Change-Id: Icd540cfb321b4eaf77a0ed7d08be06d8681b6214 --- lib/codeclib.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/codeclib.c b/lib/codeclib.c index 0736198fb..a3ed7a33e 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -4572,6 +4572,15 @@ static int evs_encoder_input(encoder_t *enc, AVFrame **frame) { bytes += (out - enc->avpkt->data); assert(bytes <= enc->avpkt->size); + + if (toc && !enc->format_options.evs.amr_io && !enc->format_options.evs.hf_only) { + // hf-only=0 but HF packet, check for size collisions and zero-pad if needed + while (evs_mode_from_bytes(bytes) != -1) { + enc->avpkt->data[bytes] = '\0'; + bytes++; + } + } + enc->avpkt->size = bytes; enc->avpkt->pts = (*frame)->pts; enc->avpkt->duration = (*frame)->nb_samples;