summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine SOULIER <asoulier@google.com>2024-04-04 22:57:33 +0000
committerStefano Sabatini <stefasab@gmail.com>2024-04-06 09:55:57 +0200
commit4865ea48cc4e133d98ba35fc46d7762dee38321c (patch)
tree3c354f6be46a499a4d2692a3046abf34a5781a1b
parent6de00dc5f11967c898d3e79e4af3d05ea7c98b13 (diff)
avcodec/liblc3dec: retrieve duration of the last packet from the demuxer
Use the packet duration field to invalid last samples of the last frame.
-rw-r--r--libavcodec/liblc3dec.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/libavcodec/liblc3dec.c b/libavcodec/liblc3dec.c
index 1553552faa..d250ace38a 100644
--- a/libavcodec/liblc3dec.c
+++ b/libavcodec/liblc3dec.c
@@ -34,7 +34,6 @@ typedef struct LibLC3DecContext {
int frame_us, srate_hz, hr_mode;
void *decoder_mem;
lc3_decoder_t decoder[DECODER_MAX_CHANNELS];
- int64_t length;
} LibLC3DecContext;
static av_cold int liblc3_decode_init(AVCodecContext *avctx)
@@ -57,7 +56,6 @@ static av_cold int liblc3_decode_init(AVCodecContext *avctx)
liblc3->srate_hz = avctx->sample_rate;
ep_mode = AV_RL16(avctx->extradata + 2);
liblc3->hr_mode = AV_RL16(avctx->extradata + 4);
- liblc3->length = AV_RL32(avctx->extradata + 6);
if (ep_mode != 0) {
av_log(avctx, AV_LOG_ERROR,
"Error protection mode is not supported.\n");
@@ -126,11 +124,7 @@ static int liblc3_decode(AVCodecContext *avctx, AVFrame *frame,
in += nbytes;
}
- if (liblc3->length > 0) {
- int64_t end_pts = liblc3->length + avctx->delay;
- frame->nb_samples = FFMIN(frame->nb_samples,
- FFMAX(end_pts - frame->pts, 0));
- }
+ frame->nb_samples = FFMIN(frame->nb_samples, avpkt->duration);
*got_frame_ptr = 1;