[FFmpeg-devel] [PATCH 34/57] avcodec/mpeg12dec: Disable allocating scratchpad buffers when possible
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Wed Jun 12 16:48:30 EEST 2024
They are no longer used by the MPEG-1/2 decoders except when
using lowres.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
libavcodec/mpeg12dec.c | 4 ++++
libavcodec/mpegpicture.h | 10 ++++++++++
2 files changed, 14 insertions(+)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index e0e9a8fb1e..7485b7c65f 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1000,6 +1000,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
if ((ret = ff_mpv_common_init(s)) < 0)
return ret;
+ if (!s->avctx->lowres)
+ ff_mpv_framesize_disable(&s->sc);
}
return 0;
}
@@ -1874,6 +1876,8 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
if ((ret = ff_mpv_common_init(s)) < 0)
return ret;
+ if (!s->avctx->lowres)
+ ff_mpv_framesize_disable(&s->sc);
for (i = 0; i < 64; i++) {
int j = s->idsp.idct_permutation[i];
diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h
index d3f39bbae6..196aa9b744 100644
--- a/libavcodec/mpegpicture.h
+++ b/libavcodec/mpegpicture.h
@@ -21,6 +21,7 @@
#ifndef AVCODEC_MPEGPICTURE_H
#define AVCODEC_MPEGPICTURE_H
+#include <limits.h>
#include <stddef.h>
#include <stdint.h>
@@ -135,6 +136,15 @@ int ff_mpv_pic_check_linesize(void *logctx, const struct AVFrame *f,
int ff_mpv_framesize_alloc(AVCodecContext *avctx,
ScratchpadContext *sc, int linesize);
+/**
+ * Disable allocating the ScratchpadContext's buffers in future calls
+ * to ff_mpv_framesize_alloc().
+ */
+static inline void ff_mpv_framesize_disable(ScratchpadContext *sc)
+{
+ sc->linesize = INT_MAX;
+}
+
void ff_mpv_unref_picture(MPVWorkPicture *pic);
void ff_mpv_workpic_from_pic(MPVWorkPicture *wpic, MPVPicture *pic);
void ff_mpv_replace_picture(MPVWorkPicture *dst, const MPVWorkPicture *src);
--
2.40.1
More information about the ffmpeg-devel
mailing list