---
libavformat/gif.c | 50 ++++++++++++++++++++++++++------------------------
1 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/libavformat/gif.c b/libavformat/gif.c
index eb1e9f0..1e7cc76 100644
--- a/libavformat/gif.c
+++ b/libavformat/gif.c
@@ -128,14 +128,14 @@ static int gif_image_write_header(AVIOContext *pb,
/* the global palette */
if (!palette) {
avio_write(pb, (const unsigned char *)gif_clut, 216*3);
- for(i=0;i<((256-216)*3);i++)
+ for (i = 0; i < ((256 - 216) * 3); i++)
avio_w8(pb, 0);
} else {
- for(i=0;i<256;i++) {
+ for (i = 0; i < 256; i++) {
v = palette[i];
avio_w8(pb, (v >> 16) & 0xff);
- avio_w8(pb, (v >> 8) & 0xff);
- avio_w8(pb, (v) & 0xff);
+ avio_w8(pb, (v >> 8) & 0xff);
+ avio_w8(pb, v & 0xff);
}
}
@@ -161,10 +161,11 @@ static int gif_image_write_header(AVIOContext *pb,
/* application extension header */
#ifdef GIF_ADD_APP_HEADER
if (loop_count >= 0 && loop_count <= 65535) {
- avio_w8(pb, 0x21);
- avio_w8(pb, 0xff);
- avio_w8(pb, 0x0b);
- avio_write(pb, "NETSCAPE2.0", sizeof("NETSCAPE2.0") - 1); // bytes 4
to 14
+ avio_w8(pb, 0x21);
+ avio_w8(pb, 0xff);
+ avio_w8(pb, 0x0b);
+ // bytes 4 to 14
+ avio_write(pb, "NETSCAPE2.0", sizeof("NETSCAPE2.0") - 1);
avio_w8(pb, 0x03); // byte 15
avio_w8(pb, 0x01); // byte 16
avio_wl16(pb, (uint16_t)loop_count);
@@ -201,7 +202,7 @@ static int gif_image_write_image(AVIOContext *pb,
avio_w8(pb, 0x08);
- left= width * height;
+ left = width * height;
init_put_bits(&p, buffer, 130);
@@ -210,27 +211,27 @@ static int gif_image_write_image(AVIOContext *pb,
* but it's still the same bitstream between packets (no flush !)
*/
ptr = buf;
- w = width;
- while(left>0) {
+ w = width;
+ while (left > 0) {
put_bits(&p, 9, 0x0100); /* clear code */
- for(i=(left<GIF_CHUNKS)?left:GIF_CHUNKS;i;i--) {
+ for(i = (left < GIF_CHUNKS) ? left : GIF_CHUNKS; i; i--) {
if (pix_fmt == PIX_FMT_RGB24) {
- v = gif_clut_index(ptr[0], ptr[1], ptr[2]);
- ptr+=3;
+ v = gif_clut_index(ptr[0], ptr[1], ptr[2]);
+ ptr += 3;
} else {
v = *ptr++;
}
put_bits(&p, 9, v);
if (--w == 0) {
- w = width;
+ w = width;
buf += linesize;
- ptr = buf;
+ ptr = buf;
}
}
- if(left<=GIF_CHUNKS) {
+ if (left <= GIF_CHUNKS) {
put_bits(&p, 9, 0x101); /* end of stream */
flush_put_bits(&p);
}
@@ -239,7 +240,7 @@ static int gif_image_write_image(AVIOContext *pb,
avio_write(pb, p.buf, put_bits_ptr(&p) - p.buf); /* the actual
buffer */
p.buf_ptr = p.buf; /* dequeue the bytes off the bitstream */
}
- left-=GIF_CHUNKS;
+ left -= GIF_CHUNKS;
}
avio_w8(pb, 0x00); /* end of image block */
@@ -264,11 +265,11 @@ static int gif_write_header(AVFormatContext *s)
if(s->nb_streams > 1)
return -1;
*/
- gif->time = 0;
+ gif->time = 0;
gif->file_time = 0;
video_enc = NULL;
- for(i=0;i<s->nb_streams;i++) {
+ for (i = 0; i < s->nb_streams; i++) {
enc = s->streams[i]->codec;
if (enc->codec_type != AVMEDIA_TYPE_AUDIO)
video_enc = enc;
@@ -278,7 +279,7 @@ static int gif_write_header(AVFormatContext *s)
av_free(gif);
return -1;
} else {
- width = video_enc->width;
+ width = video_enc->width;
height = video_enc->height;
// rate = video_enc->time_base.den;
}
@@ -311,7 +312,7 @@ static int gif_write_video(AVFormatContext *s,
/* XXX: should use delay, in order to be more accurate */
/* instead of using the same rounded value each time */
/* XXX: don't even remember if I really use it for now */
- jiffies = (70*enc->time_base.num/enc->time_base.den) - 1;
+ jiffies = (70 * enc->time_base.num / enc->time_base.den) - 1;
avio_wl16(pb, jiffies);
@@ -346,7 +347,8 @@ static int gif_write_trailer(AVFormatContext *s)
#define OFFSET(x) offsetof(GIFContext, x)
#define ENC AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
- { "loop", "Number of times to loop the output.", OFFSET(loop),
AV_OPT_TYPE_INT, {0}, 0, 65535, ENC },
+ { "loop", "Number of times to loop the output.", OFFSET(loop),
+ AV_OPT_TYPE_INT, { 0 }, 0, 65535, ENC },
{ NULL },
};
@@ -368,5 +370,5 @@ AVOutputFormat ff_gif_muxer = {
.write_header = gif_write_header,
.write_packet = gif_write_packet,
.write_trailer = gif_write_trailer,
- .priv_class = &gif_muxer_class,
+ .priv_class = &gif_muxer_class,
};
--
1.7.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel