* [FFmpeg-devel] [PATCH 1/2] avcodec/mjpegdec: Fix av_frame_unref(NULL)
@ 2024-06-13 2:02 Andreas Rheinhardt
2024-06-13 2:03 ` [FFmpeg-devel] [PATCH 2/2] avcodec/mjpegdec: Mark flush as cold Andreas Rheinhardt
2024-06-13 6:47 ` [FFmpeg-devel] [PATCH 1/2] avcodec/mjpegdec: Fix av_frame_unref(NULL) Michael Niedermayer
0 siblings, 2 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2024-06-13 2:02 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
The smv_frame is only allocated for the SMV decoder, yet
it is unreferenced in the other decoders' flush functions, too.
av_frame_unref(NULL) is not documented to be allowed, it just
happens to work. Avoid it by using a dedicated flush function
for SMV.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mjpegdec.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 1481a7f285..ac2698a3c4 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2977,9 +2977,6 @@ static void decode_flush(AVCodecContext *avctx)
{
MJpegDecodeContext *s = avctx->priv_data;
s->got_picture = 0;
-
- s->smv_next_frame = 0;
- av_frame_unref(s->smv_frame);
}
#if CONFIG_MJPEG_DECODER
@@ -3044,6 +3041,16 @@ const FFCodec ff_thp_decoder = {
#endif
#if CONFIG_SMVJPEG_DECODER
+static av_cold void smv_flush(AVCodecContext *avctx)
+{
+ MJpegDecodeContext *s = avctx->priv_data;
+
+ decode_flush(avctx);
+
+ s->smv_next_frame = 0;
+ av_frame_unref(s->smv_frame);
+}
+
// SMV JPEG just stacks several output frames into one JPEG picture
// we handle that by setting up the cropping parameters appropriately
static void smv_process_frame(AVCodecContext *avctx, AVFrame *frame)
@@ -3112,7 +3119,7 @@ const FFCodec ff_smvjpeg_decoder = {
.init = ff_mjpeg_decode_init,
.close = ff_mjpeg_decode_end,
FF_CODEC_RECEIVE_FRAME_CB(smvjpeg_receive_frame),
- .flush = decode_flush,
+ .flush = smv_flush,
.p.capabilities = AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING |
FF_CODEC_CAP_INIT_CLEANUP,
--
2.40.1
_______________________________________________
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] 3+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avcodec/mjpegdec: Mark flush as cold
2024-06-13 2:02 [FFmpeg-devel] [PATCH 1/2] avcodec/mjpegdec: Fix av_frame_unref(NULL) Andreas Rheinhardt
@ 2024-06-13 2:03 ` Andreas Rheinhardt
2024-06-13 6:47 ` [FFmpeg-devel] [PATCH 1/2] avcodec/mjpegdec: Fix av_frame_unref(NULL) Michael Niedermayer
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Rheinhardt @ 2024-06-13 2:03 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mjpegdec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index ac2698a3c4..d618e53d13 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2973,7 +2973,7 @@ av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
return 0;
}
-static void decode_flush(AVCodecContext *avctx)
+static av_cold void decode_flush(AVCodecContext *avctx)
{
MJpegDecodeContext *s = avctx->priv_data;
s->got_picture = 0;
--
2.40.1
_______________________________________________
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] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mjpegdec: Fix av_frame_unref(NULL)
2024-06-13 2:02 [FFmpeg-devel] [PATCH 1/2] avcodec/mjpegdec: Fix av_frame_unref(NULL) Andreas Rheinhardt
2024-06-13 2:03 ` [FFmpeg-devel] [PATCH 2/2] avcodec/mjpegdec: Mark flush as cold Andreas Rheinhardt
@ 2024-06-13 6:47 ` Michael Niedermayer
1 sibling, 0 replies; 3+ messages in thread
From: Michael Niedermayer @ 2024-06-13 6:47 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 598 bytes --]
On Thu, Jun 13, 2024 at 04:02:52AM +0200, Andreas Rheinhardt wrote:
> The smv_frame is only allocated for the SMV decoder, yet
> it is unreferenced in the other decoders' flush functions, too.
> av_frame_unref(NULL) is not documented to be allowed, it just
> happens to work. Avoid it by using a dedicated flush function
> for SMV.
why not docuement av_frame_unref(NULL) ?
seems simpler if thats the only reason
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I have often repented speaking, but never of holding my tongue.
-- Xenocrates
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: 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] 3+ messages in thread
end of thread, other threads:[~2024-06-13 6:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-13 2:02 [FFmpeg-devel] [PATCH 1/2] avcodec/mjpegdec: Fix av_frame_unref(NULL) Andreas Rheinhardt
2024-06-13 2:03 ` [FFmpeg-devel] [PATCH 2/2] avcodec/mjpegdec: Mark flush as cold Andreas Rheinhardt
2024-06-13 6:47 ` [FFmpeg-devel] [PATCH 1/2] avcodec/mjpegdec: Fix av_frame_unref(NULL) Michael Niedermayer
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