ffmpeg | branch: master | Michael Niedermayer <mich...@niedermayer.cc> | Sat 
Jan 18 04:25:42 2025 +0100| [c1b330bf2421cf3400e185ecd65dd69308891f19] | 
committer: Michael Niedermayer

avcodec/ffv1: Basic float16 support

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c1b330bf2421cf3400e185ecd65dd69308891f19
---

 libavcodec/ffv1.h       |  2 ++
 libavcodec/ffv1_parse.c | 12 ++++++++++--
 libavcodec/ffv1enc.c    |  9 ++++++++-
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index 583696a36e..87f0b2c02f 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -134,6 +134,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/ffv1_parse.c b/libavcodec/ffv1_parse.c
index 636e2c62ab..a85b563e98 100644
--- a/libavcodec/ffv1_parse.c
+++ b/libavcodec/ffv1_parse.c
@@ -172,6 +172,8 @@ int ff_ffv1_read_extra_header(FFV1Context *f)
             f->crcref = 0x7a8c4079;
         if (f->combined_version >= 0x30003)
             f->intra = ff_ffv1_get_symbol(&c, state, 0);
+        if (f->combined_version >= 0x40004)
+            f->flt = ff_ffv1_get_symbol(&c, state, 0);
     }
 
     if (f->version > 2) {
@@ -401,10 +403,16 @@ int ff_ffv1_parse_header(FFV1Context *f, RangeCoder *c, 
uint8_t *state)
         else if (f->avctx->bits_per_raw_sample == 14 && f->transparency)
             f->pix_fmt = AV_PIX_FMT_GBRAP14;
         else if (f->avctx->bits_per_raw_sample == 16 && !f->transparency) {
-            f->pix_fmt = AV_PIX_FMT_GBRP16;
+            if (f->flt) {
+                f->pix_fmt = AV_PIX_FMT_GBRPF16;
+            } else
+                f->pix_fmt = AV_PIX_FMT_GBRP16;
             f->use32bit = 1;
         } else if (f->avctx->bits_per_raw_sample == 16 && f->transparency) {
-            f->pix_fmt = AV_PIX_FMT_GBRAP16;
+            if (f->flt) {
+                f->pix_fmt = AV_PIX_FMT_GBRAPF16;
+            } else
+                f->pix_fmt = AV_PIX_FMT_GBRAP16;
             f->use32bit = 1;
         }
     } else {
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 2e3262db54..5c873fa8ba 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",
@@ -1412,6 +1418,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
 
     },

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to