From patchwork Thu Apr 4 22:57:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Soulier X-Patchwork-Id: 47809 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp636029pzd; Thu, 4 Apr 2024 15:57:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVJkK1BMDmu48rf5c5ueaw+qF8MLUMeD0dm6pM8YJUxFE/oXtplclXuzBQCEXHqUiirkPguBRWUBlk8Ms2ISwZYa/Lk8ikpSMKi0g== X-Google-Smtp-Source: AGHT+IE7KAVmZ/g6M4mfoXLK344n0c1lcKZXZ2j+Xc5paTQ52fMFMQhkdwjJzal4i5phJSs0oAlT X-Received: by 2002:a17:907:2982:b0:a51:93bb:89c9 with SMTP id eu2-20020a170907298200b00a5193bb89c9mr1138195ejc.6.1712271469735; Thu, 04 Apr 2024 15:57:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712271469; cv=none; d=google.com; s=arc-20160816; b=PUfYux0s6W9m624AI6OZH+NA0KTqc2VaYRI/rMMxlNuTbCqTkbfbvd5LF1Mar/dBBr zlCK+JmKBIhpPzC4tnbVx3G1wjID0zsdQPb8ftXOb9RHG/H2fjCY9/g3S1pX87LH0XmI oO8Ci97FtTOwf8ue+g00IqdiLBp/xr8jbnziiXFqUMwnzcclyHvYFOQdjeupN8QPCNeo eJwKBhUteL8c39ESubuH2r0UOKot7jFK3U70jrp7Cz4cTK4hNMJCIAK9ApcsF3cBQQPd n6N7/hJx4To9V7/1mE4Z7RG3U2ib7bgficg15VS8bXavE/kjSmt2mLGjSU2iM4VG0CNz XRBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:to:message-id:mime-version:date :delivered-to; bh=EiB9h/O1CWkKb+3XHhoSj7qGSRHtKeHrU+qH0ZiHUMk=; fh=eZJQwGgFNmhG1aNRPvwNmWJ7Br90d3O+ZTyD+wYtFmA=; b=Im2HzDC46IJPY+O7ucWBOb6ZFqICCWL+KYg/d2WpA7TzdNqREKkgNOIdi6sazVd0mQ KQlKqpH3M/fnKuNZ3oMji2Vx8qxjqTqZ0mHigep9AbjhA0ap0ysn//srmHsN2JD2nIBk e2SUBIeC4oF8k53oivUj5aDbvIBjMU0NtVSdtgG6NRLCsbWaE7T4MhXMG+GcHgxNHiPE 80ayVOQtgpF53KthRfOCK4g4BzZR00asFzgkV2l/yS68ALwEJ7Ml3kneEfx9v7z7msMp GUCY2Y3GvBRxfju3nF/pOgLaY74aa4i3rU0T4CNSqNhSu2Q6djZWgb2KA9OQM8aRFLMh /KCw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t21-20020a1709060c5500b00a51943e373csi91314ejf.868.2024.04.04.15.57.49; Thu, 04 Apr 2024 15:57:49 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 581E168D140; Fri, 5 Apr 2024 01:57:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E71F868C0CB for ; Fri, 5 Apr 2024 01:57:38 +0300 (EEST) Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-ddaf165a8d9so2713140276.1 for ; Thu, 04 Apr 2024 15:57:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712271457; x=1712876257; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=4FaBjlAq+OyFRhJnXjMKgEEDqy5ICazLa/0st40ttQ8=; b=MPbDkklAKKJQF4UHMl0ckB5I8b9gGZiJ5It2TatrUUM1Z8DdX45ld+2VVpdA590LE/ hkn5m+QZBlf33EmyfWqgVY5cpe/Z3Ktk/8yRuWUxkv+Slz43q9a+U8I9mIUfYzGWhkX9 KxUsHDASVzf7Q9A/mrK2tJkYaukwUm1PYLLK/hK2zMP8MC9gJvKRdT+T9ZZZ8dvy3l/4 l5AQkKbILwbzeGRYAb1WwJi162btwr8Wgm9fdbqytiiw1h4EpREZnU+Gfr6vLEboc49N LPtsidYdYtNJVcBAAReNan5NyFJ7BdsenH82zXeQ6w2ixJ9ZClpHm4wVRaLOQYPTxzMz NPXQ== X-Gm-Message-State: AOJu0YyBPPaDJQHrMizNQWq/cCpmxwoQ5nm3tHfVLPGZFEpC5YjCdiAE 6l/DYhcdOdVt7uK156N0tjtSn0Q2UyBZ3tWktwqaN7i9bnnQSakZCZHUMwL7n8KmsUa+0Tc/1Cx ayszsRMKWfnzFoN4yyL1J4kTXOUn8DGlQRcKfBDVCrAv+nFxMBRH3tnapV+nQpYFCXPXOn//Ert 8xVrhVH7HXkJzXQr5mbuIWu8pZWAM0UBO7su+cQZHEMnab X-Received: from asoulier-us.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:f79]) (user=asoulier job=sendgmr) by 2002:a25:8291:0:b0:dcd:4286:4498 with SMTP id r17-20020a258291000000b00dcd42864498mr110731ybk.6.1712271457234; Thu, 04 Apr 2024 15:57:37 -0700 (PDT) Date: Thu, 4 Apr 2024 22:57:33 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240404225734.3036715-1-asoulier@google.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/liblc3dec: Retrieve duration of the last packet from the demux X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Antoine Soulier via ffmpeg-devel From: Antoine Soulier Reply-To: FFmpeg development discussions and patches Cc: Antoine Soulier Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: LYmOtNZOLOXO From: Antoine SOULIER 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;