[FFmpeg-devel] [PATCH] libavformat/riffenc: handle gray8 format for uncompressed avi

rui.jiang 229135609 at qq.com
Thu Aug 19 07:07:33 EEST 2021


add palette data in avi header when the input data is raw gray8 pixel data and the output data is 8bit uncompressed avi video

Signed-off-by: rui.jiang <229135609 at qq.com>
---
 libavformat/riffenc.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index 43c8bf957a..d8b767787f 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -266,6 +266,15 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par,
                 else
                     avio_wl32(pb, 0);
             }
+        } else if (pix_fmt == AV_PIX_FMT_GRAY8) {
+            /* Initialize 8 bpp palette */
+            int i;
+            for (i = 0; i < 256; i++) {
+                avio_w8(pb,i);
+                avio_w8(pb,i);
+                avio_w8(pb,i);
+                avio_w8(pb,0);
+            }
         }
     }
 }
-- 
2.30.1 (Apple Git-130)



More information about the ffmpeg-devel mailing list