diff options
author | Paul B Mahol <onemda@gmail.com> | 2012-06-14 23:18:07 +0000 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2012-06-15 00:53:34 +0000 |
commit | a09ae4ef654b409cc21d3cae4d691988164888c6 (patch) | |
tree | a6686c48091522e5c8d3264b46cdb38fedaa418d | |
parent | 59c122b3b0a00808e3c4f534927755d89e7baa62 (diff) | |
download | ffmpeg-a09ae4ef654b409cc21d3cae4d691988164888c6.tar.gz |
Remove duplicated png and mng signatures.
Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
-rw-r--r-- | libavcodec/png.c | 3 | ||||
-rw-r--r-- | libavcodec/png.h | 4 | ||||
-rw-r--r-- | libavcodec/png_parser.c | 4 | ||||
-rw-r--r-- | libavcodec/pngdec.c | 10 | ||||
-rw-r--r-- | libavcodec/pngenc.c | 2 |
5 files changed, 10 insertions, 13 deletions
diff --git a/libavcodec/png.c b/libavcodec/png.c index 332701c68a..a4287bd7e2 100644 --- a/libavcodec/png.c +++ b/libavcodec/png.c @@ -21,9 +21,6 @@ #include "avcodec.h" #include "png.h" -const uint8_t ff_pngsig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; -const uint8_t ff_mngsig[8] = {138, 77, 78, 71, 13, 10, 26, 10}; - /* Mask to determine which y pixels are valid in a pass */ const uint8_t ff_png_pass_ymask[NB_PASSES] = { 0x80, 0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, diff --git a/libavcodec/png.h b/libavcodec/png.h index 4b30ba3735..948c2f714f 100644 --- a/libavcodec/png.h +++ b/libavcodec/png.h @@ -49,8 +49,8 @@ #define NB_PASSES 7 -extern const uint8_t ff_pngsig[8]; -extern const uint8_t ff_mngsig[8]; +#define PNGSIG 0x89504e470d0a1a0a +#define MNGSIG 0x8a4d4e470d0a1a0a /* Mask to determine which y pixels are valid in a pass */ extern const uint8_t ff_png_pass_ymask[NB_PASSES]; diff --git a/libavcodec/png_parser.c b/libavcodec/png_parser.c index 722889bdeb..877b894e4d 100644 --- a/libavcodec/png_parser.c +++ b/libavcodec/png_parser.c @@ -25,9 +25,7 @@ */ #include "parser.h" - -#define PNGSIG 0x89504e470d0a1a0a -#define MNGSIG 0x8a4d4e470d0a1a0a +#include "png.h" typedef struct PNGParseContext { diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index e55a3823c0..5bfe07ba5d 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -395,21 +395,23 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p; uint8_t *crow_buf_base = NULL; uint32_t tag, length; + int64_t sig; int ret; FFSWAP(AVFrame *, s->current_picture, s->last_picture); avctx->coded_frame= s->current_picture; p = s->current_picture; + bytestream2_init(&s->gb, buf, buf_size); + /* check signature */ - if (buf_size < 8 || - memcmp(buf, ff_pngsig, 8) != 0 && - memcmp(buf, ff_mngsig, 8) != 0) { + sig = bytestream2_get_be64(&s->gb); + if (sig != PNGSIG && + sig != MNGSIG) { av_log(avctx, AV_LOG_ERROR, "Missing png signature\n"); return -1; } - bytestream2_init(&s->gb, buf + 8, buf_size - 8); s->y= s->state=0; // memset(s, 0, sizeof(PNGDecContext)); diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index 1d362b577e..a29d3c95cf 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -322,7 +322,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } /* write png header */ - memcpy(s->bytestream, ff_pngsig, 8); + AV_WB64(s->bytestream, PNGSIG); s->bytestream += 8; AV_WB32(s->buf, avctx->width); |