diff mbox series

[FFmpeg-devel,11/27] avformat/icoenc: Simplify writing bitmask

Message ID AM7PR03MB6660B167C9637A60F2CD1CDA8FA39@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 7d5e27b473a1ba013a9eb63f57e1e2e445200f6f
Headers show
Series [FFmpeg-devel,01/27] avformat/astenc: Simplify writing padding
Related show

Commit Message

Andreas Rheinhardt Sept. 23, 2021, 3:28 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
I am pretty certain that the size of said bitmask should
be (par->height * par->width + 7) / 8 (or maybe
par->height * ((par->width + 7) / 8)), but not what it is now.

 libavformat/icoenc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/icoenc.c b/libavformat/icoenc.c
index ee793137fd..21966f3921 100644
--- a/libavformat/icoenc.c
+++ b/libavformat/icoenc.c
@@ -31,6 +31,7 @@ 
 #include "libavcodec/codec_id.h"
 
 #include "avformat.h"
+#include "avio_internal.h"
 
 typedef struct {
     int offset;
@@ -119,7 +120,6 @@  static int ico_write_packet(AVFormatContext *s, AVPacket *pkt)
     IcoImage *image;
     AVIOContext *pb = s->pb;
     AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar;
-    int i;
 
     if (ico->current_image >= ico->nb_images) {
         av_log(s, AV_LOG_ERROR, "ICO already contains %d images\n", ico->current_image);
@@ -150,8 +150,8 @@  static int ico_write_packet(AVFormatContext *s, AVPacket *pkt)
         avio_wl32(pb, AV_RL32(pkt->data + 22) * 2); // rewrite height as 2 * height
         avio_write(pb, pkt->data + 26, pkt->size - 26);
 
-        for (i = 0; i < par->height * (par->width + 7) / 8; ++i)
-            avio_w8(pb, 0x00); // Write bitmask (opaque)
+        // Write bitmask (opaque)
+        ffio_fill(pb, 0x00, par->height * (par->width + 7) / 8);
     }
 
     return 0;