summaryrefslogtreecommitdiff
path: root/libavcodec/sunrast.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-01-30 05:20:58 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-01-30 05:20:58 +0100
commite1492151fb0c1ad2a9efbb2f2413b60113208b61 (patch)
treee4852fd092e2b2346c21e87d8b69987b2b4c2a68 /libavcodec/sunrast.c
parent90bf7c7b41c9e78663ef3da00480f70854072932 (diff)
parent20a7d3178f2370ebd1f548c144bc90d1e1bcd81a (diff)
downloadffmpeg-e1492151fb0c1ad2a9efbb2f2413b60113208b61.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: png: add missing #if HAVE_SSSE3 around function pointer assignment. imdct36: mark SSE functions as using all 16 XMM registers. png: move DSP functions to their own DSP context. sunrast: Add a sample request for TIFF, IFF, and Experimental Rastfile formats. sunrast: Cosmetics sunrast: Remove if (unsigned int < 0) check. sunrast: Replace magic number by a macro. Conflicts: libavcodec/dsputil.c libavcodec/dsputil.h libavcodec/pngdec.c libavcodec/sunrast.c libavcodec/x86/Makefile libavcodec/x86/dsputil_mmx.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/sunrast.c')
-rw-r--r--libavcodec/sunrast.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c
index b602c9dd93..aa12947f5f 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
@@ -55,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, *ptr2 = NULL;
const uint8_t *bufstart = buf;
@@ -74,22 +76,22 @@ 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;
}
- 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_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");
@@ -161,7 +163,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
}
ptr = p->data[1];
- for (x=0; x<len; x++, ptr+=4)
+ for (x = 0; x < len; x++, ptr += 4)
*(uint32_t *)ptr = (0xFF<<24) + (buf[x]<<16) + (buf[len+x]<<8) + buf[len+len+x];
}
@@ -179,11 +181,11 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
/* scanlines are aligned on 16 bit boundaries */
len = (depth * w + 7) >> 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) {
@@ -208,7 +210,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
}
}
} else {
- for (y=0; y<h; y++) {
+ for (y = 0; y < h; y++) {
if (buf_end - buf < len)
break;
memcpy(ptr, buf, len);
@@ -241,7 +243,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, void *data,
av_freep(&ptr_free);
}
- *picture = s->picture;
+ *picture = s->picture;
*data_size = sizeof(AVFrame);
return buf - bufstart;