From fef3771778dbc9e7a17b7ce773f1b6d9651dff6f Mon Sep 17 00:00:00 2001 From: Aneesh Dogra Date: Sat, 28 Jan 2012 18:34:12 +0530 Subject: sunrast: Replace magic number by a macro. Signed-off-by: Aneesh Dogra Signed-off-by: Ronald S. Bultje --- libavcodec/sunrast.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libavcodec/sunrast.c') diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c index a471aee3ed..b21c26089e 100644 --- a/libavcodec/sunrast.c +++ b/libavcodec/sunrast.c @@ -23,6 +23,8 @@ #include "libavutil/imgutils.h" #include "avcodec.h" +#define RAS_MAGIC 0x59a66a95 + /* The Old and Standard format types indicate that the image data is * uncompressed. There is no difference between the two formats. */ #define RT_OLD 0 @@ -74,7 +76,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data, if (avpkt->size < 32) return AVERROR_INVALIDDATA; - if (AV_RB32(buf) != 0x59a66a95) { + if (AV_RB32(buf) != RAS_MAGIC) { av_log(avctx, AV_LOG_ERROR, "this is not sunras encoded data\n"); return -1; } -- cgit v1.2.3 From 4ffb8e2c14dbbe28014fb9d5cea769d600094e1b Mon Sep 17 00:00:00 2001 From: Aneesh Dogra Date: Sun, 29 Jan 2012 10:55:32 +0530 Subject: sunrast: Remove if (unsigned int < 0) check. Note: This fixes the following GCC warning :- libavcodec/sunrast.c:94: warning: comparison of unsigned expression < 0 is always false. Signed-off-by: Ronald S. Bultje --- libavcodec/sunrast.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libavcodec/sunrast.c') diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c index b21c26089e..c7af1fd126 100644 --- a/libavcodec/sunrast.c +++ b/libavcodec/sunrast.c @@ -93,7 +93,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data, av_log(avctx, AV_LOG_ERROR, "unsupported (compression) type\n"); return -1; } - if (type < RT_OLD || type > RT_FORMAT_IFF) { + if (type > RT_FORMAT_IFF) { av_log(avctx, AV_LOG_ERROR, "invalid (compression) type\n"); return -1; } -- cgit v1.2.3 From 415f358a1f926878fc7bc31715cc6d221e372fa0 Mon Sep 17 00:00:00 2001 From: Aneesh Dogra Date: Sat, 28 Jan 2012 18:34:14 +0530 Subject: sunrast: Cosmetics Signed-off-by: Aneesh Dogra Signed-off-by: Ronald S. Bultje --- libavcodec/sunrast.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'libavcodec/sunrast.c') diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c index c7af1fd126..23f1e6fae9 100644 --- a/libavcodec/sunrast.c +++ b/libavcodec/sunrast.c @@ -57,18 +57,18 @@ static av_cold int sunrast_init(AVCodecContext *avctx) { SUNRASTContext *s = avctx->priv_data; avcodec_get_frame_defaults(&s->picture); - avctx->coded_frame= &s->picture; + avctx->coded_frame = &s->picture; return 0; } static int sunrast_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; - const uint8_t *buf_end = avpkt->data + avpkt->size; + const uint8_t *buf = avpkt->data; + const uint8_t *buf_end = avpkt->data + avpkt->size; SUNRASTContext * const s = avctx->priv_data; - AVFrame *picture = data; - AVFrame * const p = &s->picture; + AVFrame *picture = data; + AVFrame * const p = &s->picture; unsigned int w, h, depth, type, maptype, maplength, stride, x, y, len, alen; uint8_t *ptr; const uint8_t *bufstart = buf; @@ -81,12 +81,12 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data, return -1; } - w = AV_RB32(buf+4); - h = AV_RB32(buf+8); - depth = AV_RB32(buf+12); - type = AV_RB32(buf+20); - maptype = AV_RB32(buf+24); - maplength = AV_RB32(buf+28); + w = AV_RB32(buf + 4); + h = AV_RB32(buf + 8); + depth = AV_RB32(buf + 12); + type = AV_RB32(buf + 20); + maptype = AV_RB32(buf + 24); + maplength = AV_RB32(buf + 28); buf += 32; if (type == RT_FORMAT_TIFF || type == RT_FORMAT_IFF || type == RT_EXPERIMENTAL) { @@ -153,8 +153,8 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data, } ptr = p->data[1]; - for (x=0; x> 3; - alen = len + (len&1); + alen = len + (len & 1); if (type == RT_BYTE_ENCODED) { int value, run; - uint8_t *end = ptr + h*stride; + uint8_t *end = ptr + h * stride; x = 0; while (ptr != end && buf < buf_end) { @@ -193,7 +193,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data, } } } else { - for (y=0; ypicture; + *picture = s->picture; *data_size = sizeof(AVFrame); return buf - bufstart; -- cgit v1.2.3 From f9708e9a0e76d3dfa89f175edde68d8cadb02763 Mon Sep 17 00:00:00 2001 From: Aneesh Dogra Date: Sat, 28 Jan 2012 18:34:15 +0530 Subject: sunrast: Add a sample request for TIFF, IFF, and Experimental Rastfile formats. Signed-off-by: Aneesh Dogra Signed-off-by: Ronald S. Bultje --- libavcodec/sunrast.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libavcodec/sunrast.c') diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c index 23f1e6fae9..601ba6efc9 100644 --- a/libavcodec/sunrast.c +++ b/libavcodec/sunrast.c @@ -90,8 +90,8 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data, buf += 32; if (type == RT_FORMAT_TIFF || type == RT_FORMAT_IFF || type == RT_EXPERIMENTAL) { - av_log(avctx, AV_LOG_ERROR, "unsupported (compression) type\n"); - return -1; + av_log_ask_for_sample(avctx, "unsupported (compression) type\n"); + return AVERROR_PATCHWELCOME; } if (type > RT_FORMAT_IFF) { av_log(avctx, AV_LOG_ERROR, "invalid (compression) type\n"); -- cgit v1.2.3