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 F252247E97 for ; Mon, 30 Oct 2023 05:09:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6307168CC59; Mon, 30 Oct 2023 07:09:36 +0200 (EET) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 32FBB68CA72 for ; Mon, 30 Oct 2023 07:09:29 +0200 (EET) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id 7755B10601A7 for ; Mon, 30 Oct 2023 05:09:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1698642568; 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=Ljq3AYc45x7aGZNvg+99c6J9qKgln4nBQwEMeGj8wRw=; b=PT3xQ8Is1g3oBwBW6pRkCRNolUUnNkGorlnEffXD/khaUvGIfbZJOX8tB4iSeU9p QV3QNAb/b6eQsAJ66OYilq1P8SzN8p8TyDtb4fHa8L75l8A0YvDgU6ZiTR5sLPFYhqT qvyXyYeAOd5cqDdIL8lkOfD6DUJwF/rxX0Ky5AtyGM3SL3DO+GpHq/hKOZJdOzX74a9 0RhAhGAum99F5CZJ2iE71V28npiGs8Os+vGKQMIWss0NoGx44xSJ5FRgM6hEtvyZhpM +hoIligCkJytwClEpanfK0PcH+b0iAoKwrJhBPsSUH2ji2HSbFKlSW9a/jT/ntFvBqe KzF2tSXAjQ== Date: Mon, 30 Oct 2023 06:09:28 +0100 (CET) From: Lynne To: Ffmpeg Devel Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_190042_570178524.1698642568977" 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_190042_570178524.1698642568977 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. The idea is to get rid of skip_samples eventually and replace it with this function. Patch attached. ------=_Part_190042_570178524.1698642568977 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 41dfcbbacfa9232d2308d0229dcd172309b32f9f 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. The idea is to get rid of skip_samples eventually and replace it with this function. --- libavcodec/decode.c | 18 ++++++++++++++++++ libavcodec/decode.h | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index ad39021354..f971723ff7 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -299,6 +299,24 @@ static int64_t guess_correct_pts(AVCodecContext *ctx, return pts; } +int ff_decode_skip_samples(AVCodecContext *avctx, AVFrame *frame, uint32_t base_skip, uint32_t additional) +{ + 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); + AV_WL32(side->data, base_skip); + } + + val += AV_RL32(side->data); + val += additional; + 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..647f091da9 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -155,4 +155,13 @@ 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 base_skip amount of samples to skip if no side data is present + * @param additional amount of samples to skip unconditionally + */ +int ff_decode_skip_samples(AVCodecContext *avctx, AVFrame *frame, + uint32_t base_skip, uint32_t additional); + #endif /* AVCODEC_DECODE_H */ -- 2.42.0 ------=_Part_190042_570178524.1698642568977 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_190042_570178524.1698642568977--