Use the packet duration field to invalid last samples of the last frame.
Unified · Split
| @@ -34,7 +34,6 @@ typedef struct LibLC3DecContext { · 33 unmodified lines | ||
| 34 | 34 | int frame_us, srate_hz, hr_mode; |
| 35 | 35 | void *decoder_mem; |
| 36 | 36 | lc3_decoder_t decoder[DECODER_MAX_CHANNELS]; |
| 37 | − int64_t length; | |
| 38 | 37 | } LibLC3DecContext; |
| 39 | 38 | |
| 40 | 39 | static av_cold int liblc3_decode_init(AVCodecContext *avctx) |
| @@ -57,7 +56,6 @@ static av_cold int liblc3_decode_init(AVCodecContext *avctx) · 16 unmodified lines | ||
| 57 | 56 | liblc3->srate_hz = avctx->sample_rate; |
| 58 | 57 | ep_mode = AV_RL16(avctx->extradata + 2); |
| 59 | 58 | liblc3->hr_mode = AV_RL16(avctx->extradata + 4); |
| 60 | − liblc3->length = AV_RL32(avctx->extradata + 6); | |
| 61 | 59 | if (ep_mode != 0) { |
| 62 | 60 | av_log(avctx, AV_LOG_ERROR, |
| 63 | 61 | "Error protection mode is not supported.\n"); |
| @@ -126,11 +124,7 @@ static int liblc3_decode(AVCodecContext *avctx, AVFrame *frame, · 62 unmodified lines | ||
| 126 | 124 | in += nbytes; |
| 127 | 125 | } |
| 128 | 126 | |
| 129 | − if (liblc3->length > 0) { | |
| 130 | − int64_t end_pts = liblc3->length + avctx->delay; | |
| 131 | − frame->nb_samples = FFMIN(frame->nb_samples, | |
| 132 | − FFMAX(end_pts - frame->pts, 0)); | |
| 133 | − } | |
| 127 | + frame->nb_samples = FFMIN(frame->nb_samples, avpkt->duration); | |
| 134 | 128 | |
| 135 | 129 | *got_frame_ptr = 1; |
| 136 | 130 | |