diff options
author | Clément Bœsch <ubitux@gmail.com> | 2013-04-18 15:01:56 +0400 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2013-04-18 15:42:14 +0400 |
commit | b7a3f143604c0a81e17caf0b502939d5c0d01f3e (patch) | |
tree | f9a37ed5f6e69d9dc14b7cbb410d3b5dc93844bb /libavformat/gif.c | |
parent | 0a0e6877ff3b8f16067d3515509745b467ddadd6 (diff) |
lavf/gif: trim unnecessarily long netscape ext code.
Extension description comments are now placed along the avio calls, the
always defined macro removed, and the always true loop_count check as
well (loop option is bound to 0-65535).
Diffstat (limited to 'libavformat/gif.c')
-rw-r--r-- | libavformat/gif.c | 49 |
1 files changed, 10 insertions, 39 deletions
diff --git a/libavformat/gif.c b/libavformat/gif.c index a6d83ee6ed..9f5fc4c402 100644 --- a/libavformat/gif.c +++ b/libavformat/gif.c @@ -27,12 +27,6 @@ #include "libavutil/log.h" #include "libavutil/opt.h" -/* slows down the decoding (and some browsers don't like it) */ -/* update on the 'some browsers don't like it issue from above: - * this was probably due to missing 'Data Sub-block Terminator' - * (byte 19) in the app_header */ -#define GIF_ADD_APP_HEADER // required to enable looping of animated gif - static int gif_image_write_header(AVIOContext *pb, int width, int height, int loop_count, uint32_t *palette) { @@ -57,39 +51,16 @@ static int gif_image_write_header(AVIOContext *pb, int width, int height, avio_w8(pb, 0); /* aspect ratio */ } - /* update: this is the 'NETSCAPE EXTENSION' that allows for looped animated - * GIF, see http://members.aol.com/royalef/gifabout.htm#net-extension - * - * byte 1 : 33 (hex 0x21) GIF Extension code - * byte 2 : 255 (hex 0xFF) Application Extension Label - * byte 3 : 11 (hex (0x0B) Length of Application Block - * (eleven bytes of data to follow) - * bytes 4 to 11 : "NETSCAPE" - * bytes 12 to 14 : "2.0" - * byte 15 : 3 (hex 0x03) Length of Data Sub-Block - * (three bytes of data to follow) - * byte 16 : 1 (hex 0x01) - * bytes 17 to 18 : 0 to 65535, an unsigned integer in - * lo-hi byte format. This indicate the - * number of iterations the loop should - * be executed. - * bytes 19 : 0 (hex 0x00) a Data Sub-block Terminator - */ - - /* 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); - // 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); - avio_w8(pb, 0x00); // byte 19 - } -#endif + /* "NETSCAPE EXTENSION" for looped animation GIF */ + avio_w8(pb, 0x21); /* GIF Extension code */ + avio_w8(pb, 0xff); /* Application Extension Label */ + avio_w8(pb, 0x0b); /* Length of Application Block */ + avio_write(pb, "NETSCAPE2.0", sizeof("NETSCAPE2.0") - 1); + avio_w8(pb, 0x03); /* Length of Data Sub-Block */ + avio_w8(pb, 0x01); + avio_wl16(pb, (uint16_t)loop_count); + avio_w8(pb, 0x00); /* Data Sub-block Terminator */ + return 0; } |