[libav-devel] [PATCH] flashsv: K&R formatting cosmetics
Vittorio Giovara
vittorio.giovara at gmail.com
Thu Oct 31 10:27:02 CET 2013
From: Luca Barbato <lu_zero at gentoo.org>
Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
---
Patch is ok, I just removed some blank lines.
Vittorio
libavcodec/flashsv.c | 101 ++++++++++++++++++++++++++------------------------
1 file changed, 52 insertions(+), 49 deletions(-)
diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c
index e9749fe..fd0fc43 100644
--- a/libavcodec/flashsv.c
+++ b/libavcodec/flashsv.c
@@ -45,51 +45,50 @@
typedef struct BlockInfo {
uint8_t *pos;
- int size;
+ int size;
} BlockInfo;
typedef struct FlashSVContext {
AVCodecContext *avctx;
- AVFrame frame;
- int image_width, image_height;
- int block_width, block_height;
- uint8_t *tmpblock;
- int block_size;
- z_stream zstream;
- int ver;
+ AVFrame frame;
+ int image_width, image_height;
+ int block_width, block_height;
+ uint8_t *tmpblock;
+ int block_size;
+ z_stream zstream;
+ int ver;
const uint32_t *pal;
- int is_keyframe;
- uint8_t *keyframedata;
- uint8_t *keyframe;
- BlockInfo *blocks;
- uint8_t *deflate_block;
- int deflate_block_size;
- int color_depth;
- int zlibprime_curr, zlibprime_prev;
- int diff_start, diff_height;
+ int is_keyframe;
+ uint8_t *keyframedata;
+ uint8_t *keyframe;
+ BlockInfo *blocks;
+ uint8_t *deflate_block;
+ int deflate_block_size;
+ int color_depth;
+ int zlibprime_curr, zlibprime_prev;
+ int diff_start, diff_height;
} FlashSVContext;
-
static int decode_hybrid(const uint8_t *sptr, uint8_t *dptr, int dx, int dy,
int h, int w, int stride, const uint32_t *pal)
{
int x, y;
const uint8_t *orig_src = sptr;
- for (y = dx+h; y > dx; y--) {
+ for (y = dx + h; y > dx; y--) {
uint8_t *dst = dptr + (y * stride) + dy * 3;
for (x = 0; x < w; x++) {
if (*sptr & 0x80) {
/* 15-bit color */
unsigned c = AV_RB16(sptr) & ~0x8000;
- unsigned b = c & 0x1F;
- unsigned g = (c >> 5) & 0x1F;
- unsigned r = c >> 10;
+ unsigned b = c & 0x1F;
+ unsigned g = (c >> 5) & 0x1F;
+ unsigned r = c >> 10;
/* 000aaabb -> aaabbaaa */
*dst++ = (b << 3) | (b >> 2);
*dst++ = (g << 3) | (g >> 2);
*dst++ = (r << 3) | (r >> 2);
- sptr += 2;
+ sptr += 2;
} else {
/* palette index */
uint32_t c = pal[*sptr++];
@@ -120,7 +119,6 @@ static av_cold int flashsv_decode_init(AVCodecContext *avctx)
return 0;
}
-
static int flashsv2_prime(FlashSVContext *s, uint8_t *src, int size)
{
z_stream zs;
@@ -194,8 +192,8 @@ static int flashsv_decode_block(AVCodecContext *avctx, AVPacket *avpkt,
}
if (s->is_keyframe) {
- s->blocks[blk_idx].pos = s->keyframedata + (get_bits_count(gb) / 8);
- s->blocks[blk_idx].size = block_size;
+ s->blocks[blk_idx].pos = s->keyframedata + (get_bits_count(gb) / 8);
+ s->blocks[blk_idx].size = block_size;
}
if (!s->color_depth) {
/* Flash Screen Video stores the image upside down, so copy
@@ -237,8 +235,8 @@ static int calc_deflate_block_size(int tmpblock_size)
static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
- int buf_size = avpkt->size;
- FlashSVContext *s = avctx->priv_data;
+ int buf_size = avpkt->size;
+ FlashSVContext *s = avctx->priv_data;
int h_blocks, v_blocks, h_part, v_part, i, j, ret;
GetBitContext gb;
@@ -251,10 +249,10 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
init_get_bits(&gb, avpkt->data, buf_size * 8);
/* start to parse the bitstream */
- s->block_width = 16 * (get_bits(&gb, 4) + 1);
- s->image_width = get_bits(&gb, 12);
- s->block_height = 16 * (get_bits(&gb, 4) + 1);
- s->image_height = get_bits(&gb, 12);
+ s->block_width = 16 * (get_bits(&gb, 4) + 1);
+ s->image_width = get_bits(&gb, 12);
+ s->block_height = 16 * (get_bits(&gb, 4) + 1);
+ s->image_height = get_bits(&gb, 12);
if (s->ver == 2) {
skip_bits(&gb, 6);
@@ -281,18 +279,22 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
s->tmpblock = av_realloc(s->tmpblock, tmpblock_size);
if (!s->tmpblock) {
- av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
+ av_log(avctx, AV_LOG_ERROR,
+ "Cannot allocate decompression buffer.\n");
return AVERROR(ENOMEM);
}
if (s->ver == 2) {
s->deflate_block_size = calc_deflate_block_size(tmpblock_size);
if (s->deflate_block_size <= 0) {
- av_log(avctx, AV_LOG_ERROR, "Can't determine deflate buffer size.\n");
+ av_log(avctx, AV_LOG_ERROR,
+ "Cannot determine deflate buffer size.\n");
return -1;
}
- s->deflate_block = av_realloc(s->deflate_block, s->deflate_block_size);
+ s->deflate_block = av_realloc(s->deflate_block,
+ s->deflate_block_size);
if (!s->deflate_block) {
- av_log(avctx, AV_LOG_ERROR, "Can't allocate deflate buffer.\n");
+ av_log(avctx, AV_LOG_ERROR,
+ "Cannot allocate deflate buffer.\n");
return AVERROR(ENOMEM);
}
}
@@ -320,8 +322,8 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
s->keyframedata = av_realloc(s->keyframedata, avpkt->size);
memcpy(s->keyframedata, avpkt->data, avpkt->size);
s->blocks = av_realloc(s->blocks,
- (v_blocks + !!v_part) * (h_blocks + !!h_part)
- * sizeof(s->blocks[0]));
+ (v_blocks + !!v_part) * (h_blocks + !!h_part) *
+ sizeof(s->blocks[0]));
}
av_dlog(avctx, "image: %dx%d block: %dx%d num: %dx%d part: %dx%d\n",
@@ -368,14 +370,15 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
if (s->color_depth != 0 && s->color_depth != 2) {
av_log(avctx, AV_LOG_ERROR,
- "%dx%d invalid color depth %d\n", i, j, s->color_depth);
+ "%dx%d invalid color depth %d\n",
+ i, j, s->color_depth);
return AVERROR_INVALIDDATA;
}
if (has_diff) {
if (!s->keyframe) {
av_log(avctx, AV_LOG_ERROR,
- "inter frame without keyframe\n");
+ "Inter frame without keyframe\n");
return AVERROR_INVALIDDATA;
}
s->diff_start = get_bits(&gb, 8);
@@ -392,14 +395,15 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
if (s->zlibprime_curr) {
int col = get_bits(&gb, 8);
int row = get_bits(&gb, 8);
- av_log(avctx, AV_LOG_DEBUG, "%dx%d zlibprime_curr %dx%d\n", i, j, col, row);
+ av_log(avctx, AV_LOG_DEBUG, "%dx%d zlibprime_curr %dx%d\n",
+ i, j, col, row);
size -= 2;
avpriv_request_sample(avctx, "zlibprime_curr");
return AVERROR_PATCHWELCOME;
}
if (!s->blocks && (s->zlibprime_curr || s->zlibprime_prev)) {
av_log(avctx, AV_LOG_ERROR, "no data available for zlib "
- "priming\n");
+ "priming\n");
return AVERROR_INVALIDDATA;
}
size--; // account for flags byte
@@ -410,8 +414,8 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
int off = (s->image_height - y_pos - 1) * s->frame.linesize[0];
for (k = 0; k < cur_blk_height; k++)
- memcpy(s->frame.data[0] + off - k*s->frame.linesize[0] + x_pos*3,
- s->keyframe + off - k*s->frame.linesize[0] + x_pos*3,
+ memcpy(s->frame.data[0] + off - k * s->frame.linesize[0] + x_pos * 3,
+ s->keyframe + off - k * s->frame.linesize[0] + x_pos * 3,
cur_blk_width * 3);
}
@@ -434,7 +438,8 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
return AVERROR(ENOMEM);
}
}
- memcpy(s->keyframe, s->frame.data[0], s->frame.linesize[0] * avctx->height);
+ memcpy(s->keyframe, s->frame.data[0],
+ s->frame.linesize[0] * avctx->height);
}
if ((ret = av_frame_ref(data, &s->frame)) < 0)
@@ -450,7 +455,6 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
return buf_size;
}
-
static av_cold int flashsv_decode_end(AVCodecContext *avctx)
{
FlashSVContext *s = avctx->priv_data;
@@ -464,7 +468,6 @@ static av_cold int flashsv_decode_end(AVCodecContext *avctx)
return 0;
}
-
#if CONFIG_FLASHSV_DECODER
AVCodec ff_flashsv_decoder = {
.name = "flashsv",
@@ -476,7 +479,7 @@ AVCodec ff_flashsv_decoder = {
.close = flashsv_decode_end,
.decode = flashsv_decode_frame,
.capabilities = CODEC_CAP_DR1,
- .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_BGR24, AV_PIX_FMT_NONE },
+ .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGR24, AV_PIX_FMT_NONE },
};
#endif /* CONFIG_FLASHSV_DECODER */
@@ -539,6 +542,6 @@ AVCodec ff_flashsv2_decoder = {
.close = flashsv2_decode_end,
.decode = flashsv_decode_frame,
.capabilities = CODEC_CAP_DR1,
- .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_BGR24, AV_PIX_FMT_NONE },
+ .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGR24, AV_PIX_FMT_NONE },
};
#endif /* CONFIG_FLASHSV2_DECODER */
--
1.7.9.5
More information about the libav-devel
mailing list