From 2c9eee171e512a25c73c8ed144c8a130abb2d2a4 Mon Sep 17 00:00:00 2001
From: user <user@host>
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 <jannis_wth@gmx.de>
---
libavcodec/avcodec.h | 9 +++++++++
libavcodec/utils.c | 5 +++++
2 files changed, 14 insertions(+)
@@ -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;
@@ -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