[FFmpeg-devel] [PATCH] Handle AV_PIX_FMT_PAL8

Ray 229135609 at qq.com
Sun Aug 15 11:43:36 EEST 2021


---
 libavformat/riffenc.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index 971c4a7eb8..69761431da 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -250,15 +250,6 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par,
     avio_wl32(pb, pal_avi ? 1 << par->bits_per_coded_sample : 0);
     avio_wl32(pb, 0);
 
-	if (par->bits_per_coded_sample == 8) {
-		for(int i=0; i<256; i++) {
-			avio_w8(pb,i);
-			avio_w8(pb,i);
-			avio_w8(pb,i);
-			avio_w8(pb,0);
-		}
-	}
-
     if (!ignore_extradata) {
         if (par->extradata_size) {
             avio_write(pb, par->extradata, extradata_size);
@@ -272,6 +263,13 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par,
                     avio_wl32(pb, 0xffffff);
                 else if (i == 1 && pix_fmt == AV_PIX_FMT_MONOBLACK)
                     avio_wl32(pb, 0xffffff);
+                else if (pix_fmt == AV_PIX_FMT_PAL8) {
+                    /* Initialize 8 bpp palette */
+                    avio_w8(pb,i);
+			        avio_w8(pb,i);
+			        avio_w8(pb,i);
+			        avio_w8(pb,0);
+                }
                 else
                     avio_wl32(pb, 0);
             }
-- 
2.30.1 (Apple Git-130)



More information about the ffmpeg-devel mailing list