From patchwork Thu Jan 31 09:33:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jannis_wth X-Patchwork-Id: 11924 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 084DF44C289 for ; Thu, 31 Jan 2019 11:32:32 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1EB7068AC07; Thu, 31 Jan 2019 11:32:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 803E168AAD0 for ; Thu, 31 Jan 2019 11:32:13 +0200 (EET) Received: from 127.0.0.1 ([217.232.57.119]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0Le64S-1hVxle1sKK-00pxRP for ; Thu, 31 Jan 2019 10:32:34 +0100 To: ffmpeg-devel@ffmpeg.org References: <0b91ac7f-48f1-369c-f6a7-548050ef86b9@gmail.com> <20190130171937.zo4cxgpn52ywpkly@phare.normalesup.org> <863b4533-1a93-8dac-1541-c823d011e00e@gmail.com> <4556df8a-1c0e-44ef-a30b-c048e79702ca@gmx.de> <9a2a6a45-eeab-25a3-5495-3ed6ef1f29ec@gmail.com> <1a6577fe-11e4-34ff-d638-8ff151dc6729@gmx.de> From: jannis_wth Message-ID: <0c645eff-1915-6b1d-2426-de3a40ed31da@gmx.de> Date: Thu, 31 Jan 2019 10:33:13 +0100 MIME-Version: 1.0 In-Reply-To: <1a6577fe-11e4-34ff-d638-8ff151dc6729@gmx.de> Content-Language: en-GB X-Provags-ID: V03:K1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6fcuPw46QFrdR8oCSX WrdnxsU8Q7VuXIC+Q+m2J7TT/TuTTcbt/tixjuWsVxZYRBRY9kiDrQEa178aA9Fiix79dxezq NdZX5/ysfEYQnHbGJbvmdXVOihcKouFf7Imha4qRTWifm2rIdQM6KZO/8MQXzK Subject: Re: [FFmpeg-devel] [PATCH] avcodec: Allow to query number of consumed bytes using the new API X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 30.01.19 21:42 - jannis_wth: > 30.01.19 21:02 - James Almer: >> I guess avctx->internal->last_pkt_props could work for this, but it may >> not be consistent across decoders. > > avctx->internal->last_pkt_props stores the properties of the last passed > packet, and does not get updated on decoding frames. Since I set the > input-packets size to a constant (size is unknown) this is not very > helpfull.. My bad, avctx->internal->last_pkt_props works as expected. Thank you James. From 2c9eee171e512a25c73c8ed144c8a130abb2d2a4 Mon Sep 17 00:00:00 2001 From: user Date: Thu, 31 Jan 2019 10:28:22 +0100 Subject: [PATCH 1/1] avcodec: Allow to query number of consumed bytes using the new API Currently the only way to get the number of consumed bytes is by using the deprecated decode_audio4() API. This patch adds a simple function to fix this. Signed-off-by: Jannis Kambs --- libavcodec/avcodec.h | 9 +++++++++ libavcodec/utils.c | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index f554c53f0e..43bf84e58b 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -5714,6 +5714,15 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes); */ int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes); +/** + * This function allows to get the number of remaining bytes after + * avcodec_receive_frame() has been called. + * + * @param avctx the codec context + * @return number of remaining bytes from the input AVPacket. + */ +int avcodec_get_remaining_size(AVCodecContext *avctx); + #if FF_API_OLD_BSF typedef struct AVBitStreamFilterContext { void *priv_data; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index d519b16092..998e77524e 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1727,6 +1727,11 @@ int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes) frame_bytes); } +int avcodec_get_remaining_size(AVCodecContext *avctx) +{ + return avctx->internal->last_pkt_props->size; +} + #if !HAVE_THREADS int ff_thread_init(AVCodecContext *s) { -- 2.11.0