[FFmpeg-devel] [PATCH 2/4] avcodec: set AV_FRAME_FLAG_LOSSLESS where supported
Marton Balint
cus at passwd.hu
Sun Dec 15 02:02:43 EET 2024
Signed-off-by: Marton Balint <cus at passwd.hu>
---
libavcodec/jpeg2000dec.c | 4 ++++
libavcodec/mjpegdec.c | 2 ++
libavcodec/vp9.c | 4 ++++
libavcodec/webp.c | 1 +
4 files changed, 11 insertions(+)
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 84eebfd1b2..df13bea815 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2891,6 +2891,10 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture,
}
}
+ for (int x = 0; x < s->ncomponents && s->codsty[x].transform == FF_DWT53;)
+ if (++x == s->ncomponents)
+ picture->flags |= AV_FRAME_FLAG_LOSSLESS;
+
avctx->execute2(avctx, jpeg2000_decode_tile, picture, NULL, s->numXtiles * s->numYtiles);
jpeg2000_dec_cleanup(s);
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index ef4fc075b2..fefa5e7877 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2561,6 +2561,8 @@ eoi_parser:
}
if ((ret = av_frame_ref(frame, s->picture_ptr)) < 0)
return ret;
+ if (s->lossless)
+ frame->flags |= AV_FRAME_FLAG_LOSSLESS;
*got_frame = 1;
s->got_picture = 0;
diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 8ede2e2eb3..b4b6fd933d 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -1592,6 +1592,10 @@ static int vp9_decode_frame(AVCodecContext *avctx, AVFrame *frame,
f->flags |= AV_FRAME_FLAG_KEY;
else
f->flags &= ~AV_FRAME_FLAG_KEY;
+ if (s->s.h.lossless)
+ f->flags |= AV_FRAME_FLAG_LOSSLESS;
+ else
+ f->flags &= ~AV_FRAME_FLAG_LOSSLESS;
f->pict_type = (s->s.h.keyframe || s->s.h.intraonly) ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
// Non-existent frames have the implicit dimension 0x0 != CUR_FRAME
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index b624458d67..a965e50ac4 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -1191,6 +1191,7 @@ static int vp8_lossless_decode_frame(AVCodecContext *avctx, AVFrame *p,
*got_frame = 1;
p->pict_type = AV_PICTURE_TYPE_I;
p->flags |= AV_FRAME_FLAG_KEY;
+ p->flags |= AV_FRAME_FLAG_LOSSLESS;
ret = data_size;
free_and_return:
--
2.43.0
More information about the ffmpeg-devel
mailing list