[FFmpeg-cvslog] avcodec/mpeg12dec: Disable allocating scratchpad buffers when possible
Andreas Rheinhardt
git at videolan.org
Thu Jun 20 20:00:20 EEST 2024
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Tue Jun 4 11:33:04 2024 +0200| [ba341be09533a077075c71fce5f9dc5b73504234] | committer: Andreas Rheinhardt
avcodec/mpeg12dec: Disable allocating scratchpad buffers when possible
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>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ba341be09533a077075c71fce5f9dc5b73504234
---
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);
More information about the ffmpeg-cvslog
mailing list