From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 07D4E48439 for ; Mon, 4 Dec 2023 07:51:33 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E770968CC28; Mon, 4 Dec 2023 09:51:30 +0200 (EET) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2FD5568CD0C for ; Mon, 4 Dec 2023 09:51:24 +0200 (EET) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id C18E510602EC for ; Mon, 4 Dec 2023 07:51:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1701676283; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:Sender; bh=TQij4K5wNI5hQIeJUbZ8nkAed4IKHdb+03TdbjbRW8w=; b=EglJGTiUQo64+bEUycQi4RFYPP8GQN6Jqsw0uUswsH/F9zStyelj8klAvCYVOEQw Yd4oXGFuwlsR4zPq7Dyhukv8z5YelMc27Fu7/qaRvHwqOjX/mcp9PoxdaivbWvQDb+t Vxlz0hKl1imXIO581OcP/V9Jt9KdsOE75hXgfG1tXjuYkwCxzYPKQnTm0tBO1HK+4Wf PyoiohRzhebjpoIqk+CwAnCqAcMsW8Q71wIrFvS1EP8JyZMNk64qR6Ty/7yfrqRcxlW hnTyIMEb9bcOwqjA0r1sSA/ob8KuIoTxLIe6WtyyYUFNISzoiP7SuSsSzNrYxvikJLN qn6cKsCbOg== Date: Mon, 4 Dec 2023 08:51:23 +0100 (CET) From: Lynne To: Ffmpeg Devel Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_133391_1299968760.1701676283706" Subject: [FFmpeg-devel] [PATCH 1/2] decode: add ff_decode_skip_samples function 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: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: ------=_Part_133391_1299968760.1701676283706 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit This is a convenience function, which is required to be called by decoders needing to skip samples every time. It automatically creates and increments side data. This function is a simplified version of an earlier patch. It is only able to add additional delay, rather than insert or override any. ------=_Part_133391_1299968760.1701676283706 Content-Type: text/x-diff; charset=us-ascii; name=0001-decode-add-ff_decode_skip_samples-function.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-decode-add-ff_decode_skip_samples-function.patch >From 3045ac286538641076ce4547cda677c3b159877f Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 30 Oct 2023 05:38:17 +0100 Subject: [PATCH 1/2] decode: add ff_decode_skip_samples function This is a convenience function, which is required to be called by decoders needing to skip samples every time. It automatically creates and increments side data. This function is a simplified version of an earlier patch. It is only able to add additional delay, rather than insert or override any. --- libavcodec/decode.c | 17 +++++++++++++++++ libavcodec/decode.h | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 2cfb3fcf97..450d63d947 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -299,6 +299,23 @@ static int64_t guess_correct_pts(AVCodecContext *ctx, return pts; } +int ff_decode_skip_samples(AVCodecContext *avctx, AVFrame *frame, uint32_t skip) +{ + uint32_t val = 0; + AVFrameSideData *side = av_frame_get_side_data(frame, AV_FRAME_DATA_SKIP_SAMPLES); + if (!side) { + side = av_frame_new_side_data(frame, AV_FRAME_DATA_SKIP_SAMPLES, 10); + if (!side) + return AVERROR(ENOMEM); + } + + val += AV_RL32(side->data); + val += skip; + AV_WL32(side->data, val); + + return 0; +} + static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t *discarded_samples) { AVCodecInternal *avci = avctx->internal; diff --git a/libavcodec/decode.h b/libavcodec/decode.h index daf1a67444..c83476208c 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -155,4 +155,12 @@ int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_pr const AVPacketSideData *ff_get_coded_side_data(const AVCodecContext *avctx, enum AVPacketSideDataType type); +/** + * Skip samples in an AVFrame. + * + * @param skip amount of samples to skip unconditionally + */ +int ff_decode_skip_samples(AVCodecContext *avctx, AVFrame *frame, + uint32_t skip); + #endif /* AVCODEC_DECODE_H */ -- 2.43.0 ------=_Part_133391_1299968760.1701676283706 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". ------=_Part_133391_1299968760.1701676283706--