diff mbox series

[FFmpeg-devel,RFC,2/3] decode: allow decoders to override skip_samples

Message ID Ne701AP--3-9@lynne.ee
State New
Headers show
Series [FFmpeg-devel,RFC,1/3] aacdec: always skip the first 2048 samples if there's no side data | expand

Checks

Context Check Description
andriy/configure_x86 warning Failed to apply patch

Commit Message

Lynne Sept. 12, 2023, 6:11 a.m. UTC
Very hacky. There must be a better way of doing this.
diff mbox series

Patch

From 843809ac072bbaf9ae0d3d3946723f1fcfb07923 Mon Sep 17 00:00:00 2001
From: Lynne <dev@lynne.ee>
Date: Tue, 12 Sep 2023 08:00:02 +0200
Subject: [PATCH 2/3] decode: allow decoders to override skip_samples

---
 libavcodec/decode.c   | 5 ++++-
 libavcodec/internal.h | 5 +++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 169ee79acd..9e8a4532f2 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -312,7 +312,10 @@  static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t *disca
 
     side = av_frame_get_side_data(frame, AV_FRAME_DATA_SKIP_SAMPLES);
     if (side && side->size >= 10) {
-        avci->skip_samples = AV_RL32(side->data);
+        if (avci->skip_samples_add)
+            avci->skip_samples += AV_RL32(side->data);
+        else
+            avci->skip_samples = AV_RL32(side->data);
         avci->skip_samples = FFMAX(0, avci->skip_samples);
         discard_padding = AV_RL32(side->data + 4);
         av_log(avctx, AV_LOG_DEBUG, "skip %d / discard %d samples due to side data\n",
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 83e0bc3fb2..8f59a117ba 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -118,6 +118,11 @@  typedef struct AVCodecInternal {
      */
     int skip_samples;
 
+    /**
+     * In case there's side data, add it to skip_samples, instead of overriding it.
+     */
+    int skip_samples_add;
+
     /**
      * hwaccel-specific private data
      */
-- 
2.40.1