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