From: Michael Niedermayer <michael@niedermayer.cc> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH 3/4] avcodec/ffv1: Basic float16 support Date: Sat, 18 Jan 2025 05:59:59 +0100 Message-ID: <20250118050001.1809058-3-michael@niedermayer.cc> (raw) In-Reply-To: <20250118050001.1809058-1-michael@niedermayer.cc> This can be used as a reference for bitstream and compression improvements Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavcodec/ffv1.h | 2 ++ libavcodec/ffv1dec.c | 12 ++++++++++-- libavcodec/ffv1enc.c | 9 ++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index 576769ae1e0..2c2df154037 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -132,6 +132,8 @@ typedef struct FFV1Context { uint8_t state_transition[256]; uint8_t (*initial_states[MAX_QUANT_TABLES])[32]; int colorspace; + int flt; + int use32bit; diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 5aec6cdce26..def95ff411f 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -508,6 +508,8 @@ static int read_extra_header(FFV1Context *f) f->crcref = 0x7a8c4079; if (f->combined_version >= 0x30003) f->intra = get_symbol(&c, state, 0); + if (f->combined_version >= 0x40004) + f->flt = get_symbol(&c, state, 0); } if (f->version > 2) { @@ -738,11 +740,17 @@ static int read_header(FFV1Context *f) else if (f->avctx->bits_per_raw_sample == 14 && f->transparency) f->avctx->pix_fmt = AV_PIX_FMT_GBRAP14; else if (f->avctx->bits_per_raw_sample == 16 && !f->transparency) { - f->avctx->pix_fmt = AV_PIX_FMT_GBRP16; + if (f->flt) { + f->avctx->pix_fmt = AV_PIX_FMT_GBRPF16; + } else + f->avctx->pix_fmt = AV_PIX_FMT_GBRP16; f->use32bit = 1; } else if (f->avctx->bits_per_raw_sample == 16 && f->transparency) { - f->avctx->pix_fmt = AV_PIX_FMT_GBRAP16; + if (f->flt) { + f->avctx->pix_fmt = AV_PIX_FMT_GBRAPF16; + } else + f->avctx->pix_fmt = AV_PIX_FMT_GBRAP16; f->use32bit = 1; } } else { diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index c952065e443..8e9f41fea8f 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -419,7 +419,7 @@ av_cold int ff_ffv1_write_extradata(AVCodecContext *avctx) if (f->version == 3) { f->micro_version = 4; } else if (f->version == 4) - f->micro_version = 3; + f->micro_version = 4; f->combined_version += f->micro_version; put_symbol(&c, state, f->micro_version, 0); } @@ -867,6 +867,8 @@ av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx, s->bits_per_raw_sample = 14; case AV_PIX_FMT_GBRP16: case AV_PIX_FMT_GBRAP16: + case AV_PIX_FMT_GBRPF16: + case AV_PIX_FMT_GBRAPF16: if (!avctx->bits_per_raw_sample && !s->bits_per_raw_sample) s->bits_per_raw_sample = 16; else if (!s->bits_per_raw_sample) @@ -877,7 +879,11 @@ av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx, if (s->bits_per_raw_sample >= 16) { s->use32bit = 1; } + s->flt = !!(desc->flags & AV_PIX_FMT_FLAG_FLOAT); s->version = FFMAX(s->version, 1); + + if (s->flt) + s->version = FFMAX(s->version, 4); break; default: av_log(avctx, AV_LOG_ERROR, "format %s not supported\n", @@ -1398,6 +1404,7 @@ const FFCodec ff_ffv1_encoder = { AV_PIX_FMT_GRAY9, AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV440P10, AV_PIX_FMT_YUV440P12, + AV_PIX_FMT_GBRPF16, AV_PIX_FMT_NONE }, -- 2.48.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".
next prev parent reply other threads:[~2025-01-18 5:00 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-01-18 4:59 [FFmpeg-devel] [PATCH 1/4] avcodec/ffv1: simplify version checks with combined_version Michael Niedermayer 2025-01-18 4:59 ` [FFmpeg-devel] [PATCH 2/4] avcodec/ffv1enc: dont reset version Michael Niedermayer 2025-01-21 1:52 ` Michael Niedermayer 2025-01-18 4:59 ` Michael Niedermayer [this message] 2025-01-18 5:00 ` [FFmpeg-devel] [PATCH 4/4] avcodec/ffv1: NOT FOR GIT, experiment about float decorrelation Michael Niedermayer 2025-01-18 8:33 ` Lynne 2025-01-18 23:02 ` Michael Niedermayer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250118050001.1809058-3-michael@niedermayer.cc \ --to=michael@niedermayer.cc \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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