Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] avcodec/liblc3dec: Retrieve duration of the last packet from the demux
@ 2024-04-04 22:57 Antoine Soulier via ffmpeg-devel
  2024-04-04 22:57 ` [FFmpeg-devel] [PATCH 2/2] avformat/lc3: Add file format for LC3/LC3plus transport Antoine Soulier via ffmpeg-devel
  2024-04-06  7:41 ` [FFmpeg-devel] [PATCH 1/2] avcodec/liblc3dec: Retrieve duration of the last packet from the demux Stefano Sabatini
  0 siblings, 2 replies; 4+ messages in thread
From: Antoine Soulier via ffmpeg-devel @ 2024-04-04 22:57 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Antoine Soulier

From: Antoine SOULIER <asoulier@google.com>

Use the packet duration field to invalid last samples of the last frame.
---
 libavcodec/liblc3dec.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/libavcodec/liblc3dec.c b/libavcodec/liblc3dec.c
index 90da28679b..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)
@@ -44,12 +43,12 @@ static av_cold int liblc3_decode_init(AVCodecContext *avctx)
     int ep_mode;
     unsigned decoder_size;
 
-    if (avctx->extradata_size < 10)
+    if (avctx->extradata_size < 6)
         return AVERROR_INVALIDDATA;
     if (channels < 0 || channels > DECODER_MAX_CHANNELS) {
         av_log(avctx, AV_LOG_ERROR,
                "Invalid number of channels %d. Max %d channels are accepted\n",
-               channels, DECODER_MAX_CHANNES);
+               channels, DECODER_MAX_CHANNELS);
         return AVERROR(EINVAL);
     }
 
@@ -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;
 
-- 
2.44.0.478.gd926399ef9-goog

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-06  7:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-04 22:57 [FFmpeg-devel] [PATCH 1/2] avcodec/liblc3dec: Retrieve duration of the last packet from the demux Antoine Soulier via ffmpeg-devel
2024-04-04 22:57 ` [FFmpeg-devel] [PATCH 2/2] avformat/lc3: Add file format for LC3/LC3plus transport Antoine Soulier via ffmpeg-devel
2024-04-06  7:54   ` Stefano Sabatini
2024-04-06  7:41 ` [FFmpeg-devel] [PATCH 1/2] avcodec/liblc3dec: Retrieve duration of the last packet from the demux Stefano Sabatini

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git