diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c index b25615f2a47251e904fd1fd0aa43102133cbba92..3fc0e3185acc2ee48af89fa888f9f513b3cfbc5b 100644 --- a/libavcodec/xbmenc.c +++ b/libavcodec/xbmenc.c @@ -27,11 +27,12 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *p, int *got_packet) { - int i, j, ret, size, linesize; + int i, j, commas, ret, size, linesize; uint8_t *ptr, *buf; linesize = (avctx->width + 7) / 8; - size = avctx->height * (linesize * 7 + 2) + 110; + commas = avctx->height * linesize; + size = avctx->height * (linesize * 7 + 2) + 109; if ((ret = ff_alloc_packet2(avctx, pkt, size, 0)) < 0) return ret; @@ -42,8 +43,11 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, buf += snprintf(buf, 33, "#define image_height %u\n", avctx->height); buf += snprintf(buf, 40, "static unsigned char image_bits[] = {\n"); for (i = 0; i < avctx->height; i++) { - for (j = 0; j < linesize; j++) - buf += snprintf(buf, 7, " 0x%02X,", ff_reverse[*ptr++]); + for (j = 0; j < linesize; j++) { + buf += snprintf(buf, 6, " 0x%02X", ff_reverse[*ptr++]); + if (--commas > 0) + buf += snprintf(buf, 2, ","); + } ptr += p->linesize[0] - linesize; buf += snprintf(buf, 2, "\n"); } diff --git a/tests/ref/lavf/xbm b/tests/ref/lavf/xbm index bc157834ffb98596ae3404270064fec65182fec9..e54d6bc2266c32fb14f7d521438963c5ffd58265 100644 --- a/tests/ref/lavf/xbm +++ b/tests/ref/lavf/xbm @@ -1,3 +1,3 @@ -0629055fd82366317c651a0af4bb82d7 *tests/data/images/xbm/02.xbm +83ed197cc88f382d9253365ffef70ec5 *tests/data/images/xbm/02.xbm tests/data/images/xbm/%02d.xbm CRC=0xc9a20204 -76411 tests/data/images/xbm/02.xbm +76410 tests/data/images/xbm/02.xbm