Commit 324e8180 authored by Paul B Mahol's avatar Paul B Mahol Committed by Diego Biurrun

8bps: K&R formatting cosmetics

Signed-off-by: 's avatarDiego Biurrun <diego@biurrun.de>
parent 9adf25c1
...@@ -38,13 +38,13 @@ ...@@ -38,13 +38,13 @@
#include "avcodec.h" #include "avcodec.h"
static const enum PixelFormat pixfmt_rgb24[] = {PIX_FMT_BGR24, PIX_FMT_RGB32, PIX_FMT_NONE}; static const enum PixelFormat pixfmt_rgb24[] = {
PIX_FMT_BGR24, PIX_FMT_RGB32, PIX_FMT_NONE };
/* /*
* Decoder context * Decoder context
*/ */
typedef struct EightBpsContext { typedef struct EightBpsContext {
AVCodecContext *avctx; AVCodecContext *avctx;
AVFrame pic; AVFrame pic;
...@@ -60,7 +60,8 @@ typedef struct EightBpsContext { ...@@ -60,7 +60,8 @@ typedef struct EightBpsContext {
* Decode a frame * Decode a frame
* *
*/ */
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) static int decode_frame(AVCodecContext *avctx, void *data,
int *data_size, AVPacket *avpkt)
{ {
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
...@@ -75,12 +76,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac ...@@ -75,12 +76,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
unsigned int planes = c->planes; unsigned int planes = c->planes;
unsigned char *planemap = c->planemap; unsigned char *planemap = c->planemap;
if(c->pic.data[0]) if (c->pic.data[0])
avctx->release_buffer(avctx, &c->pic); avctx->release_buffer(avctx, &c->pic);
c->pic.reference = 0; c->pic.reference = 0;
c->pic.buffer_hints = FF_BUFFER_HINTS_VALID; 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"); av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1; return -1;
} }
...@@ -99,20 +100,22 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac ...@@ -99,20 +100,22 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
lp = encoded + p * (height << 1); lp = encoded + p * (height << 1);
/* Decode a plane */ /* Decode a plane */
for(row = 0; row < height; row++) { for (row = 0; row < height; row++) {
pixptr = c->pic.data[0] + row * c->pic.linesize[0] + planemap[p]; pixptr = c->pic.data[0] + row * c->pic.linesize[0] + planemap[p];
pixptr_end = pixptr + c->pic.linesize[0]; pixptr_end = pixptr + c->pic.linesize[0];
dlen = av_be2ne16(*(const unsigned short *)(lp+row*2)); dlen = av_be2ne16(*(const unsigned short *)(lp + row * 2));
/* Decode a row of this plane */ /* Decode a row of this plane */
while(dlen > 0) { while (dlen > 0) {
if(dp + 1 >= buf+buf_size) return -1; if (dp + 1 >= buf + buf_size)
return -1;
if ((count = *dp++) <= 127) { if ((count = *dp++) <= 127) {
count++; count++;
dlen -= count + 1; dlen -= count + 1;
if (pixptr + count * px_inc > pixptr_end) if (pixptr + count * px_inc > pixptr_end)
break; break;
if(dp + count > buf+buf_size) return -1; if (dp + count > buf + buf_size)
while(count--) { return -1;
while (count--) {
*pixptr = *dp++; *pixptr = *dp++;
pixptr += px_inc; pixptr += px_inc;
} }
...@@ -120,7 +123,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac ...@@ -120,7 +123,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
count = 257 - count; count = 257 - count;
if (pixptr + count * px_inc > pixptr_end) if (pixptr + count * px_inc > pixptr_end)
break; break;
while(count--) { while (count--) {
*pixptr = *dp; *pixptr = *dp;
pixptr += px_inc; pixptr += px_inc;
} }
...@@ -161,7 +164,6 @@ static av_cold int decode_init(AVCodecContext *avctx) ...@@ -161,7 +164,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
EightBpsContext * const c = avctx->priv_data; EightBpsContext * const c = avctx->priv_data;
c->avctx = avctx; c->avctx = avctx;
c->pic.data[0] = NULL; c->pic.data[0] = NULL;
switch (avctx->bits_per_coded_sample) { switch (avctx->bits_per_coded_sample) {
...@@ -193,7 +195,8 @@ static av_cold int decode_init(AVCodecContext *avctx) ...@@ -193,7 +195,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
#endif #endif
break; break;
default: default:
av_log(avctx, AV_LOG_ERROR, "Error: Unsupported color depth: %u.\n", avctx->bits_per_coded_sample); av_log(avctx, AV_LOG_ERROR, "Error: Unsupported color depth: %u.\n",
avctx->bits_per_coded_sample);
return -1; return -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment