Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] decode: add ff_decode_skip_samples function
@ 2023-10-30  5:09 Lynne
       [not found] ` <Nhyz9MY--3-9@lynne.ee-NhyzDNG----9>
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Lynne @ 2023-10-30  5:09 UTC (permalink / raw)
  To: Ffmpeg Devel

[-- Attachment #1: Type: text/plain, Size: 266 bytes --]

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.


[-- Attachment #2: 0001-decode-add-ff_decode_skip_samples-function.patch --]
[-- Type: text/x-diff, Size: 2262 bytes --]

From 41dfcbbacfa9232d2308d0229dcd172309b32f9f Mon Sep 17 00:00:00 2001
From: Lynne <dev@lynne.ee>
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


[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-11-04 23:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-30  5:09 [FFmpeg-devel] [PATCH 1/2] decode: add ff_decode_skip_samples function Lynne
     [not found] ` <Nhyz9MY--3-9@lynne.ee-NhyzDNG----9>
2023-10-30  5:10   ` [FFmpeg-devel] [PATCH 2/2] aacdec: correctly skip padding at the start of frames and during seeking Lynne
2023-10-30  7:38     ` Jean-Baptiste Kempf
     [not found]     ` <7e230234-7cc6-4c31-ae7b-fd86ef616f7a@betaapp.fastmail.com-NhzWMs9----9>
2023-10-30 17:03       ` Lynne
2023-11-04 10:41 ` [FFmpeg-devel] [PATCH 1/2] decode: add ff_decode_skip_samples function Anton Khirnov
2023-11-04 16:22 ` Derek Buitenhuis
2023-11-04 17:32   ` Derek Buitenhuis
2023-11-04 17:41   ` Michael Niedermayer
2023-11-04 20:33   ` Lynne
2023-11-04 23:02   ` Martin Storsjö
2023-11-04 23:27     ` Lynne

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git