aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Adil Maxson <nathan0n5ire@gmail.com>2011-12-02 11:08:56 -0800
committerRonald S. Bultje <rsbultje@gmail.com>2011-12-03 14:11:39 -0800
commit8f8c785ffc104334ea9be7516936609c4ff48891 (patch)
treeffee524835ea00c9c72e1be1a23cb0ceeae7e280
parent6eedeefe0b324b104e87b3d9049c4e5388807ea1 (diff)
downloadffmpeg-8f8c785ffc104334ea9be7516936609c4ff48891.tar.gz
zmbv.c: coding style clean-up.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
-rw-r--r--libavcodec/zmbv.c191
1 files changed, 101 insertions, 90 deletions
diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
index a9c127ee4f..321348024a 100644
--- a/libavcodec/zmbv.c
+++ b/libavcodec/zmbv.c
@@ -88,8 +88,8 @@ static int zmbv_decode_xor_8(ZmbvContext *c)
output = c->cur;
prev = c->prev;
- if(c->flags & ZMBV_DELTAPAL){
- for(i = 0; i < 768; i++)
+ if (c->flags & ZMBV_DELTAPAL) {
+ for (i = 0; i < 768; i++)
c->pal[i] ^= *src++;
}
@@ -97,9 +97,9 @@ static int zmbv_decode_xor_8(ZmbvContext *c)
src += ((c->bx * c->by * 2 + 3) & ~3);
block = 0;
- for(y = 0; y < c->height; y += c->bh) {
+ for (y = 0; y < c->height; y += c->bh) {
bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
- for(x = 0; x < c->width; x += c->bw) {
+ for (x = 0; x < c->width; x += c->bw) {
uint8_t *out, *tprev;
d = mvec[block] & 1;
@@ -114,12 +114,12 @@ static int zmbv_decode_xor_8(ZmbvContext *c)
tprev = prev + x + dx + dy * c->width;
mx = x + dx;
my = y + dy;
- for(j = 0; j < bh2; j++){
- if((my + j < 0) || (my + j >= c->height)) {
+ for (j = 0; j < bh2; j++) {
+ if (my + j < 0 || my + j >= c->height) {
memset(out, 0, bw2);
} else {
- for(i = 0; i < bw2; i++){
- if((mx + i < 0) || (mx + i >= c->width))
+ for (i = 0; i < bw2; i++) {
+ if (mx + i < 0 || mx + i >= c->width)
out[i] = 0;
else
out[i] = tprev[i];
@@ -129,10 +129,10 @@ static int zmbv_decode_xor_8(ZmbvContext *c)
tprev += c->width;
}
- if(d) { /* apply XOR'ed difference */
+ if (d) { /* apply XOR'ed difference */
out = output + x;
- for(j = 0; j < bh2; j++){
- for(i = 0; i < bw2; i++)
+ for (j = 0; j < bh2; j++) {
+ for (i = 0; i < bw2; i++)
out[i] ^= *src++;
out += c->width;
}
@@ -141,8 +141,9 @@ static int zmbv_decode_xor_8(ZmbvContext *c)
output += c->width * c->bh;
prev += c->width * c->bh;
}
- if(src - c->decomp_buf != c->decomp_len)
- av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n", src-c->decomp_buf, c->decomp_len);
+ if (src - c->decomp_buf != c->decomp_len)
+ av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n",
+ src-c->decomp_buf, c->decomp_len);
return 0;
}
@@ -168,9 +169,9 @@ static int zmbv_decode_xor_16(ZmbvContext *c)
src += ((c->bx * c->by * 2 + 3) & ~3);
block = 0;
- for(y = 0; y < c->height; y += c->bh) {
+ for (y = 0; y < c->height; y += c->bh) {
bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
- for(x = 0; x < c->width; x += c->bw) {
+ for (x = 0; x < c->width; x += c->bw) {
uint16_t *out, *tprev;
d = mvec[block] & 1;
@@ -185,12 +186,12 @@ static int zmbv_decode_xor_16(ZmbvContext *c)
tprev = prev + x + dx + dy * c->width;
mx = x + dx;
my = y + dy;
- for(j = 0; j < bh2; j++){
- if((my + j < 0) || (my + j >= c->height)) {
+ for (j = 0; j < bh2; j++) {
+ if (my + j < 0 || my + j >= c->height) {
memset(out, 0, bw2 * 2);
} else {
- for(i = 0; i < bw2; i++){
- if((mx + i < 0) || (mx + i >= c->width))
+ for (i = 0; i < bw2; i++) {
+ if (mx + i < 0 || mx + i >= c->width)
out[i] = 0;
else
out[i] = tprev[i];
@@ -200,10 +201,10 @@ static int zmbv_decode_xor_16(ZmbvContext *c)
tprev += c->width;
}
- if(d) { /* apply XOR'ed difference */
+ if (d) { /* apply XOR'ed difference */
out = output + x;
- for(j = 0; j < bh2; j++){
- for(i = 0; i < bw2; i++) {
+ for (j = 0; j < bh2; j++){
+ for (i = 0; i < bw2; i++) {
out[i] ^= *((uint16_t*)src);
src += 2;
}
@@ -214,8 +215,9 @@ static int zmbv_decode_xor_16(ZmbvContext *c)
output += c->width * c->bh;
prev += c->width * c->bh;
}
- if(src - c->decomp_buf != c->decomp_len)
- av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n", src-c->decomp_buf, c->decomp_len);
+ if (src - c->decomp_buf != c->decomp_len)
+ av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n",
+ src-c->decomp_buf, c->decomp_len);
return 0;
}
@@ -244,9 +246,9 @@ static int zmbv_decode_xor_24(ZmbvContext *c)
src += ((c->bx * c->by * 2 + 3) & ~3);
block = 0;
- for(y = 0; y < c->height; y += c->bh) {
+ for (y = 0; y < c->height; y += c->bh) {
bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
- for(x = 0; x < c->width; x += c->bw) {
+ for (x = 0; x < c->width; x += c->bw) {
uint8_t *out, *tprev;
d = mvec[block] & 1;
@@ -261,12 +263,12 @@ static int zmbv_decode_xor_24(ZmbvContext *c)
tprev = prev + (x + dx) * 3 + dy * stride;
mx = x + dx;
my = y + dy;
- for(j = 0; j < bh2; j++){
- if((my + j < 0) || (my + j >= c->height)) {
+ for (j = 0; j < bh2; j++) {
+ if (my + j < 0 || my + j >= c->height) {
memset(out, 0, bw2 * 3);
} else {
- for(i = 0; i < bw2; i++){
- if((mx + i < 0) || (mx + i >= c->width)) {
+ for (i = 0; i < bw2; i++){
+ if (mx + i < 0 || mx + i >= c->width) {
out[i * 3 + 0] = 0;
out[i * 3 + 1] = 0;
out[i * 3 + 2] = 0;
@@ -281,10 +283,10 @@ static int zmbv_decode_xor_24(ZmbvContext *c)
tprev += stride;
}
- if(d) { /* apply XOR'ed difference */
+ if (d) { /* apply XOR'ed difference */
out = output + x * 3;
- for(j = 0; j < bh2; j++){
- for(i = 0; i < bw2; i++) {
+ for (j = 0; j < bh2; j++) {
+ for (i = 0; i < bw2; i++) {
out[i * 3 + 0] ^= *src++;
out[i * 3 + 1] ^= *src++;
out[i * 3 + 2] ^= *src++;
@@ -296,8 +298,9 @@ static int zmbv_decode_xor_24(ZmbvContext *c)
output += stride * c->bh;
prev += stride * c->bh;
}
- if(src - c->decomp_buf != c->decomp_len)
- av_log(c->avctx, AV_LOG_ERROR, "Used %i of %i bytes\n", src-c->decomp_buf, c->decomp_len);
+ if (src - c->decomp_buf != c->decomp_len)
+ av_log(c->avctx, AV_LOG_ERROR, "Used %i of %i bytes\n",
+ src-c->decomp_buf, c->decomp_len);
return 0;
}
#endif //ZMBV_ENABLE_24BPP
@@ -324,9 +327,9 @@ static int zmbv_decode_xor_32(ZmbvContext *c)
src += ((c->bx * c->by * 2 + 3) & ~3);
block = 0;
- for(y = 0; y < c->height; y += c->bh) {
+ for (y = 0; y < c->height; y += c->bh) {
bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
- for(x = 0; x < c->width; x += c->bw) {
+ for (x = 0; x < c->width; x += c->bw) {
uint32_t *out, *tprev;
d = mvec[block] & 1;
@@ -341,12 +344,12 @@ static int zmbv_decode_xor_32(ZmbvContext *c)
tprev = prev + x + dx + dy * c->width;
mx = x + dx;
my = y + dy;
- for(j = 0; j < bh2; j++){
- if((my + j < 0) || (my + j >= c->height)) {
+ for (j = 0; j < bh2; j++) {
+ if (my + j < 0 || my + j >= c->height) {
memset(out, 0, bw2 * 4);
} else {
- for(i = 0; i < bw2; i++){
- if((mx + i < 0) || (mx + i >= c->width))
+ for (i = 0; i < bw2; i++){
+ if (mx + i < 0 || mx + i >= c->width)
out[i] = 0;
else
out[i] = tprev[i];
@@ -356,11 +359,11 @@ static int zmbv_decode_xor_32(ZmbvContext *c)
tprev += c->width;
}
- if(d) { /* apply XOR'ed difference */
+ if (d) { /* apply XOR'ed difference */
out = output + x;
- for(j = 0; j < bh2; j++){
- for(i = 0; i < bw2; i++) {
- out[i] ^= *((uint32_t*)src);
+ for (j = 0; j < bh2; j++){
+ for (i = 0; i < bw2; i++) {
+ out[i] ^= *((uint32_t *) src);
src += 4;
}
out += c->width;
@@ -368,10 +371,11 @@ static int zmbv_decode_xor_32(ZmbvContext *c)
}
}
output += c->width * c->bh;
- prev += c->width * c->bh;
+ prev += c->width * c->bh;
}
- if(src - c->decomp_buf != c->decomp_len)
- av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n", src-c->decomp_buf, c->decomp_len);
+ if (src - c->decomp_buf != c->decomp_len)
+ av_log(c->avctx, AV_LOG_ERROR, "Used %ti of %i bytes\n",
+ src-c->decomp_buf, c->decomp_len);
return 0;
}
@@ -401,12 +405,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
int len = buf_size;
int hi_ver, lo_ver;
- if(c->pic.data[0])
+ if (c->pic.data[0])
avctx->release_buffer(avctx, &c->pic);
c->pic.reference = 1;
c->pic.buffer_hints = FF_BUFFER_HINTS_VALID;
- if(avctx->get_buffer(avctx, &c->pic) < 0){
+ if (avctx->get_buffer(avctx, &c->pic) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
@@ -414,7 +418,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
/* parse header */
c->flags = buf[0];
buf++; len--;
- if(c->flags & ZMBV_KEYFRAME) {
+ if (c->flags & ZMBV_KEYFRAME) {
hi_ver = buf[0];
lo_ver = buf[1];
c->comp = buf[2];
@@ -424,21 +428,26 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
buf += 6;
len -= 6;
- av_log(avctx, AV_LOG_DEBUG, "Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n",c->flags,hi_ver,lo_ver,c->comp,c->fmt,c->bw,c->bh);
- if(hi_ver != 0 || lo_ver != 1) {
- av_log(avctx, AV_LOG_ERROR, "Unsupported version %i.%i\n", hi_ver, lo_ver);
+ av_log(avctx, AV_LOG_DEBUG,
+ "Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n",
+ c->flags,hi_ver,lo_ver,c->comp,c->fmt,c->bw,c->bh);
+ if (hi_ver != 0 || lo_ver != 1) {
+ av_log(avctx, AV_LOG_ERROR, "Unsupported version %i.%i\n",
+ hi_ver, lo_ver);
return -1;
}
- if(c->bw == 0 || c->bh == 0) {
- av_log(avctx, AV_LOG_ERROR, "Unsupported block size %ix%i\n", c->bw, c->bh);
+ if (c->bw == 0 || c->bh == 0) {
+ av_log(avctx, AV_LOG_ERROR, "Unsupported block size %ix%i\n",
+ c->bw, c->bh);
return -1;
}
- if(c->comp != 0 && c->comp != 1) {
- av_log(avctx, AV_LOG_ERROR, "Unsupported compression type %i\n", c->comp);
+ if (c->comp != 0 && c->comp != 1) {
+ av_log(avctx, AV_LOG_ERROR, "Unsupported compression type %i\n",
+ c->comp);
return -1;
}
- switch(c->fmt) {
+ switch (c->fmt) {
case ZMBV_FMT_8BPP:
c->bpp = 8;
c->decode_intra = zmbv_decode_intra;
@@ -465,7 +474,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
default:
c->decode_intra = NULL;
c->decode_xor = NULL;
- av_log(avctx, AV_LOG_ERROR, "Unsupported (for now) format %i\n", c->fmt);
+ av_log(avctx, AV_LOG_ERROR,
+ "Unsupported (for now) format %i\n", c->fmt);
return -1;
}
@@ -473,23 +483,23 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
if (zret != Z_OK) {
av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
return -1;
- }
-
- c->cur = av_realloc(c->cur, avctx->width * avctx->height * (c->bpp / 8));
- c->prev = av_realloc(c->prev, avctx->width * avctx->height * (c->bpp / 8));
- c->bx = (c->width + c->bw - 1) / c->bw;
- c->by = (c->height+ c->bh - 1) / c->bh;
- }
-
- if(c->decode_intra == NULL) {
- av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
- return -1;
- }
-
- if(c->comp == 0) { //Uncompressed data
- memcpy(c->decomp_buf, buf, len);
- c->decomp_size = 1;
- } else { // ZLIB-compressed data
+ }
+
+ c->cur = av_realloc(c->cur, avctx->width * avctx->height * (c->bpp / 8));
+ c->prev = av_realloc(c->prev, avctx->width * avctx->height * (c->bpp / 8));
+ c->bx = (c->width + c->bw - 1) / c->bw;
+ c->by = (c->height+ c->bh - 1) / c->bh;
+ }
+
+ if (c->decode_intra == NULL) {
+ av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
+ return -1;
+ }
+
+ if (c->comp == 0) { //Uncompressed data
+ memcpy(c->decomp_buf, buf, len);
+ c->decomp_size = 1;
+ } else { // ZLIB-compressed data
c->zstream.total_in = c->zstream.total_out = 0;
c->zstream.next_in = buf;
c->zstream.avail_in = len;
@@ -498,14 +508,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
inflate(&c->zstream, Z_FINISH);
c->decomp_len = c->zstream.total_out;
}
- if(c->flags & ZMBV_KEYFRAME) {
+ if (c->flags & ZMBV_KEYFRAME) {
c->pic.key_frame = 1;
c->pic.pict_type = AV_PICTURE_TYPE_I;
c->decode_intra(c);
} else {
c->pic.key_frame = 0;
c->pic.pict_type = AV_PICTURE_TYPE_P;
- if(c->decomp_len)
+ if (c->decomp_len)
c->decode_xor(c);
}
@@ -516,10 +526,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
out = c->pic.data[0];
src = c->cur;
- switch(c->fmt) {
+ switch (c->fmt) {
case ZMBV_FMT_8BPP:
- for(j = 0; j < c->height; j++) {
- for(i = 0; i < c->width; i++) {
+ for (j = 0; j < c->height; j++) {
+ for (i = 0; i < c->width; i++) {
out[i * 3 + 0] = c->pal[(*src) * 3 + 0];
out[i * 3 + 1] = c->pal[(*src) * 3 + 1];
out[i * 3 + 2] = c->pal[(*src) * 3 + 2];
@@ -529,8 +539,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
}
break;
case ZMBV_FMT_15BPP:
- for(j = 0; j < c->height; j++) {
- for(i = 0; i < c->width; i++) {
+ for (j = 0; j < c->height; j++) {
+ for (i = 0; i < c->width; i++) {
uint16_t tmp = AV_RL16(src);
src += 2;
out[i * 3 + 0] = (tmp & 0x7C00) >> 7;
@@ -541,8 +551,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
}
break;
case ZMBV_FMT_16BPP:
- for(j = 0; j < c->height; j++) {
- for(i = 0; i < c->width; i++) {
+ for (j = 0; j < c->height; j++) {
+ for (i = 0; i < c->width; i++) {
uint16_t tmp = AV_RL16(src);
src += 2;
out[i * 3 + 0] = (tmp & 0xF800) >> 8;
@@ -554,7 +564,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
break;
#ifdef ZMBV_ENABLE_24BPP
case ZMBV_FMT_24BPP:
- for(j = 0; j < c->height; j++) {
+ for (j = 0; j < c->height; j++) {
memcpy(out, src, c->width * 3);
src += c->width * 3;
out += c->pic.linesize[0];
@@ -562,8 +572,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
break;
#endif //ZMBV_ENABLE_24BPP
case ZMBV_FMT_32BPP:
- for(j = 0; j < c->height; j++) {
- for(i = 0; i < c->width; i++) {
+ for (j = 0; j < c->height; j++) {
+ for (i = 0; i < c->width; i++) {
uint32_t tmp = AV_RL32(src);
src += 4;
AV_WB24(out+(i*3), tmp);
@@ -611,7 +621,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
/* Allocate decompression buffer */
if (c->decomp_size) {
if ((c->decomp_buf = av_malloc(c->decomp_size)) == NULL) {
- av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
+ av_log(avctx, AV_LOG_ERROR,
+ "Can't allocate decompression buffer.\n");
return 1;
}
}