Skip to content
Snippets Groups Projects
Commit a0737d1f authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Fixes OPUS_GET_LAST_PACKET_DURATION

Calling PLC/FEC with a different size was not updating it
parent 535efb07
No related branches found
No related tags found
No related merge requests found
...@@ -759,6 +759,7 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data, ...@@ -759,6 +759,7 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data,
celt_assert(pcm_count == frame_size); celt_assert(pcm_count == frame_size);
if (OPUS_CHECK_ARRAY(pcm, pcm_count*st->channels)) if (OPUS_CHECK_ARRAY(pcm, pcm_count*st->channels))
OPUS_PRINT_INT(pcm_count); OPUS_PRINT_INT(pcm_count);
st->last_packet_duration = pcm_count;
return pcm_count; return pcm_count;
} else if (len<0) } else if (len<0)
return OPUS_BAD_ARG; return OPUS_BAD_ARG;
...@@ -774,14 +775,19 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data, ...@@ -774,14 +775,19 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data,
if (decode_fec) if (decode_fec)
{ {
int duration_copy;
int ret; int ret;
/* If no FEC can be present, run the PLC (recursive call) */ /* If no FEC can be present, run the PLC (recursive call) */
if (frame_size <= packet_frame_size || packet_mode == MODE_CELT_ONLY || st->mode == MODE_CELT_ONLY) if (frame_size <= packet_frame_size || packet_mode == MODE_CELT_ONLY || st->mode == MODE_CELT_ONLY)
return opus_decode_native(st, NULL, 0, pcm, frame_size, 0, 0, NULL); return opus_decode_native(st, NULL, 0, pcm, frame_size, 0, 0, NULL);
/* Otherwise, run the PLC on everything except the size for which we might have FEC */ /* Otherwise, run the PLC on everything except the size for which we might have FEC */
duration_copy = st->last_packet_duration;
ret = opus_decode_native(st, NULL, 0, pcm, frame_size-packet_frame_size, 0, 0, NULL); ret = opus_decode_native(st, NULL, 0, pcm, frame_size-packet_frame_size, 0, 0, NULL);
if (ret<0) if (ret<0)
{
st->last_packet_duration = duration_copy;
return ret; return ret;
}
celt_assert(ret==frame_size-packet_frame_size); celt_assert(ret==frame_size-packet_frame_size);
/* Complete with FEC */ /* Complete with FEC */
st->mode = packet_mode; st->mode = packet_mode;
...@@ -795,6 +801,7 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data, ...@@ -795,6 +801,7 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data,
else { else {
if (OPUS_CHECK_ARRAY(pcm, frame_size*st->channels)) if (OPUS_CHECK_ARRAY(pcm, frame_size*st->channels))
OPUS_PRINT_INT(frame_size); OPUS_PRINT_INT(frame_size);
st->last_packet_duration = frame_size;
return frame_size; return frame_size;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment