aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/zmbv.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-12-05 00:11:57 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-12-05 00:11:57 +0100
commit707138593af5c4783035d0b9cc2d7c8cb2137dfa (patch)
tree7ead2e3c73fd33764dede26546b0238bb40d484b /libavcodec/zmbv.c
parent2f8b6e909dd733d9b722a5266ca516a9a5ba67e9 (diff)
parentdc6d0430503ecd7ed0d81276f977b26b4c4bd916 (diff)
downloadffmpeg-707138593af5c4783035d0b9cc2d7c8cb2137dfa.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: adpcmenc: cosmetics: pretty-printing ac3dec: cosmetics: pretty-printing yuv4mpeg: cosmetics: pretty-printing shorten: remove dead initialization roqvideodec: set AVFrame reference before reget_buffer. bmp: fix some 1bit samples. latmdec: add fate test for audio config change oma: PCM support oma: better format detection with small probe buffer oma: clearify ambiguous if condition wavpack: Properly clip samples during lossy decode Code clean-up for crc.c, lfg.c, log.c, random_see.d, rational.c and tree.c. Cleaned pixdesc.c file in libavutil zmbv.c: coding style clean-up. xan.c: coding style clean-up. mpegvideo.c: code cleanup - first 500 lines. Conflicts: Changelog libavcodec/adpcmenc.c libavcodec/bmp.c libavcodec/zmbv.c libavutil/log.c libavutil/pixdesc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/zmbv.c')
-rw-r--r--libavcodec/zmbv.c165
1 files changed, 88 insertions, 77 deletions
diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
index 2eb12e8031..6f89c7e3ad 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 = 3;
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) {
void *decode_intra = NULL;
c->decode_intra= NULL;
hi_ver = buf[0];
@@ -426,21 +430,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;
decode_intra = zmbv_decode_intra;
@@ -466,7 +475,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
break;
default:
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;
}
@@ -476,21 +486,21 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
return -1;
}
- c->cur = av_realloc_f(c->cur, avctx->width * avctx->height, (c->bpp / 8));
+ c->cur = av_realloc_f(c->cur, avctx->width * avctx->height, (c->bpp / 8));
c->prev = av_realloc_f(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->cur || !c->prev)
+ if (!c->cur || !c->prev)
return -1;
c->decode_intra= decode_intra;
}
- if(c->decode_intra == NULL) {
+ 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
+ if (c->comp == 0) { //Uncompressed data
memcpy(c->decomp_buf, buf, len);
c->decomp_size = 1;
} else { // ZLIB-compressed data
@@ -502,14 +512,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);
}
@@ -520,10 +530,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];
@@ -533,8 +543,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;
@@ -545,8 +555,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;
@@ -558,7 +568,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];
@@ -566,8 +576,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);
@@ -616,7 +626,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;
}
}