aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/qpeg.c
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2005-12-22 01:10:11 +0000
committerDiego Biurrun <diego@biurrun.de>2005-12-22 01:10:11 +0000
commitbb270c0896b39e1ae9277355e3c120ed3feb64a3 (patch)
treefc2fc2b1216d19acb3879abb6ea5a3b400f43fe4 /libavcodec/qpeg.c
parent50827fcf44f34521df4708cdb633809b56fb9df3 (diff)
downloadffmpeg-bb270c0896b39e1ae9277355e3c120ed3feb64a3.tar.gz
COSMETICS: tabs --> spaces, some prettyprinting
Originally committed as revision 4764 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/qpeg.c')
-rw-r--r--libavcodec/qpeg.c306
1 files changed, 153 insertions, 153 deletions
diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c
index 56a8d0e0d7..6b2daa8721 100644
--- a/libavcodec/qpeg.c
+++ b/libavcodec/qpeg.c
@@ -33,7 +33,7 @@ typedef struct QpegContext{
} QpegContext;
static void qpeg_decode_intra(uint8_t *src, uint8_t *dst, int size,
- int stride, int width, int height)
+ int stride, int width, int height)
{
int i;
int code;
@@ -47,64 +47,64 @@ static void qpeg_decode_intra(uint8_t *src, uint8_t *dst, int size,
dst = dst + height * stride;
while((size > 0) && (rows_to_go > 0)) {
- code = *src++;
- size--;
- run = copy = 0;
- if(code == 0xFC) /* end-of-picture code */
- break;
- if(code >= 0xF8) { /* very long run */
- c0 = *src++;
- c1 = *src++;
- size -= 2;
- run = ((code & 0x7) << 16) + (c0 << 8) + c1 + 2;
- } else if (code >= 0xF0) { /* long run */
- c0 = *src++;
- size--;
- run = ((code & 0xF) << 8) + c0 + 2;
- } else if (code >= 0xE0) { /* short run */
- run = (code & 0x1F) + 2;
- } else if (code >= 0xC0) { /* very long copy */
- c0 = *src++;
- c1 = *src++;
- size -= 2;
- copy = ((code & 0x3F) << 16) + (c0 << 8) + c1 + 1;
- } else if (code >= 0x80) { /* long copy */
- c0 = *src++;
- size--;
- copy = ((code & 0x7F) << 8) + c0 + 1;
- } else { /* short copy */
- copy = code + 1;
- }
-
- /* perform actual run or copy */
- if(run) {
- int p;
-
- p = *src++;
- size--;
- for(i = 0; i < run; i++) {
- dst[filled++] = p;
- if (filled >= width) {
- filled = 0;
- dst -= stride;
+ code = *src++;
+ size--;
+ run = copy = 0;
+ if(code == 0xFC) /* end-of-picture code */
+ break;
+ if(code >= 0xF8) { /* very long run */
+ c0 = *src++;
+ c1 = *src++;
+ size -= 2;
+ run = ((code & 0x7) << 16) + (c0 << 8) + c1 + 2;
+ } else if (code >= 0xF0) { /* long run */
+ c0 = *src++;
+ size--;
+ run = ((code & 0xF) << 8) + c0 + 2;
+ } else if (code >= 0xE0) { /* short run */
+ run = (code & 0x1F) + 2;
+ } else if (code >= 0xC0) { /* very long copy */
+ c0 = *src++;
+ c1 = *src++;
+ size -= 2;
+ copy = ((code & 0x3F) << 16) + (c0 << 8) + c1 + 1;
+ } else if (code >= 0x80) { /* long copy */
+ c0 = *src++;
+ size--;
+ copy = ((code & 0x7F) << 8) + c0 + 1;
+ } else { /* short copy */
+ copy = code + 1;
+ }
+
+ /* perform actual run or copy */
+ if(run) {
+ int p;
+
+ p = *src++;
+ size--;
+ for(i = 0; i < run; i++) {
+ dst[filled++] = p;
+ if (filled >= width) {
+ filled = 0;
+ dst -= stride;
rows_to_go--;
if(rows_to_go <= 0)
break;
- }
- }
- } else {
+ }
+ }
+ } else {
size -= copy;
- for(i = 0; i < copy; i++) {
- dst[filled++] = *src++;
- if (filled >= width) {
- filled = 0;
- dst -= stride;
+ for(i = 0; i < copy; i++) {
+ dst[filled++] = *src++;
+ if (filled >= width) {
+ filled = 0;
+ dst -= stride;
rows_to_go--;
if(rows_to_go <= 0)
break;
- }
- }
- }
+ }
+ }
+ }
}
}
@@ -115,8 +115,8 @@ static int qpeg_table_w[16] =
/* Decodes delta frames */
static void qpeg_decode_inter(uint8_t *src, uint8_t *dst, int size,
- int stride, int width, int height,
- int delta, uint8_t *ctable, uint8_t *refdata)
+ int stride, int width, int height,
+ int delta, uint8_t *ctable, uint8_t *refdata)
{
int i, j;
int code;
@@ -126,7 +126,7 @@ static void qpeg_decode_inter(uint8_t *src, uint8_t *dst, int size,
/* copy prev frame */
for(i = 0; i < height; i++)
- memcpy(refdata + (i * width), dst + (i * stride), width);
+ memcpy(refdata + (i * width), dst + (i * stride), width);
orig_height = height;
blkdata = src - 0x86;
@@ -134,36 +134,36 @@ static void qpeg_decode_inter(uint8_t *src, uint8_t *dst, int size,
dst = dst + height * stride;
while((size > 0) && (height >= 0)) {
- code = *src++;
- size--;
-
- if(delta) {
- /* motion compensation */
- while((code & 0xF0) == 0xF0) {
- if(delta == 1) {
- int me_idx;
- int me_w, me_h, me_x, me_y;
- uint8_t *me_plane;
- int corr, val;
-
- /* get block size by index */
- me_idx = code & 0xF;
- me_w = qpeg_table_w[me_idx];
- me_h = qpeg_table_h[me_idx];
-
- /* extract motion vector */
- corr = *src++;
- size--;
-
- val = corr >> 4;
- if(val > 7)
- val -= 16;
- me_x = val;
-
- val = corr & 0xF;
- if(val > 7)
- val -= 16;
- me_y = val;
+ code = *src++;
+ size--;
+
+ if(delta) {
+ /* motion compensation */
+ while((code & 0xF0) == 0xF0) {
+ if(delta == 1) {
+ int me_idx;
+ int me_w, me_h, me_x, me_y;
+ uint8_t *me_plane;
+ int corr, val;
+
+ /* get block size by index */
+ me_idx = code & 0xF;
+ me_w = qpeg_table_w[me_idx];
+ me_h = qpeg_table_h[me_idx];
+
+ /* extract motion vector */
+ corr = *src++;
+ size--;
+
+ val = corr >> 4;
+ if(val > 7)
+ val -= 16;
+ me_x = val;
+
+ val = corr & 0xF;
+ if(val > 7)
+ val -= 16;
+ me_y = val;
/* check motion vector */
if ((me_x + filled < 0) || (me_x + me_w + filled > width) ||
@@ -178,73 +178,73 @@ static void qpeg_decode_inter(uint8_t *src, uint8_t *dst, int size,
for(i = 0; i < me_w; i++)
dst[filled + i - (j * stride)] = me_plane[i - (j * width)];
}
- }
- }
- code = *src++;
- size--;
- }
- }
-
- if(code == 0xE0) /* end-of-picture code */
- break;
- if(code > 0xE0) { /* run code: 0xE1..0xFF */
- int p;
-
- code &= 0x1F;
- p = *src++;
- size--;
- for(i = 0; i <= code; i++) {
- dst[filled++] = p;
- if(filled >= width) {
- filled = 0;
- dst -= stride;
- height--;
- }
- }
- } else if(code >= 0xC0) { /* copy code: 0xC0..0xDF */
- code &= 0x1F;
-
- for(i = 0; i <= code; i++) {
- dst[filled++] = *src++;
- if(filled >= width) {
- filled = 0;
- dst -= stride;
- height--;
- }
- }
- size -= code + 1;
- } else if(code >= 0x80) { /* skip code: 0x80..0xBF */
- int skip;
-
- code &= 0x3F;
- /* codes 0x80 and 0x81 are actually escape codes,
- skip value minus constant is in the next byte */
- if(!code)
- skip = (*src++) + 64;
- else if(code == 1)
- skip = (*src++) + 320;
- else
- skip = code;
- filled += skip;
- while( filled >= width) {
- filled -= width;
- dst -= stride;
- height--;
+ }
+ }
+ code = *src++;
+ size--;
+ }
+ }
+
+ if(code == 0xE0) /* end-of-picture code */
+ break;
+ if(code > 0xE0) { /* run code: 0xE1..0xFF */
+ int p;
+
+ code &= 0x1F;
+ p = *src++;
+ size--;
+ for(i = 0; i <= code; i++) {
+ dst[filled++] = p;
+ if(filled >= width) {
+ filled = 0;
+ dst -= stride;
+ height--;
+ }
+ }
+ } else if(code >= 0xC0) { /* copy code: 0xC0..0xDF */
+ code &= 0x1F;
+
+ for(i = 0; i <= code; i++) {
+ dst[filled++] = *src++;
+ if(filled >= width) {
+ filled = 0;
+ dst -= stride;
+ height--;
+ }
+ }
+ size -= code + 1;
+ } else if(code >= 0x80) { /* skip code: 0x80..0xBF */
+ int skip;
+
+ code &= 0x3F;
+ /* codes 0x80 and 0x81 are actually escape codes,
+ skip value minus constant is in the next byte */
+ if(!code)
+ skip = (*src++) + 64;
+ else if(code == 1)
+ skip = (*src++) + 320;
+ else
+ skip = code;
+ filled += skip;
+ while( filled >= width) {
+ filled -= width;
+ dst -= stride;
+ height--;
if(height < 0)
break;
- }
- } else {
- /* zero code treated as one-pixel skip */
- if(code)
- dst[filled++] = ctable[code & 0x7F];
- else
- filled++;
- if(filled >= width) {
- filled = 0;
- dst -= stride;
- height--;
- }
- }
+ }
+ } else {
+ /* zero code treated as one-pixel skip */
+ if(code)
+ dst[filled++] = ctable[code & 0x7F];
+ else
+ filled++;
+ if(filled >= width) {
+ filled = 0;
+ dst -= stride;
+ height--;
+ }
+ }
}
}
@@ -267,10 +267,10 @@ static int decode_frame(AVCodecContext *avctx,
}
outdata = a->pic.data[0];
if(buf[0x85] == 0x10) {
- qpeg_decode_intra(buf+0x86, outdata, buf_size - 0x86, a->pic.linesize[0], avctx->width, avctx->height);
+ qpeg_decode_intra(buf+0x86, outdata, buf_size - 0x86, a->pic.linesize[0], avctx->width, avctx->height);
} else {
- delta = buf[0x85];
- qpeg_decode_inter(buf+0x86, outdata, buf_size - 0x86, a->pic.linesize[0], avctx->width, avctx->height, delta, buf + 4, a->refdata);
+ delta = buf[0x85];
+ qpeg_decode_inter(buf+0x86, outdata, buf_size - 0x86, a->pic.linesize[0], avctx->width, avctx->height, delta, buf + 4, a->refdata);
}
/* make the palette available on the way out */