diff options
author | Jan Ekström <jeebjp@gmail.com> | 2012-04-20 13:31:26 +0000 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2012-04-20 18:37:34 -0400 |
commit | b5c3f0b9940f964cdcaf33907eee91f9826c00b8 (patch) | |
tree | 58428ddaa9a1509735f82db96fb49f8dcd791260 | |
parent | 7eacd70feac49656d70fce677f4d7b42279338da (diff) | |
download | ffmpeg-b5c3f0b9940f964cdcaf33907eee91f9826c00b8.tar.gz |
utvideo: general cosmetics
General cosmetics, such as keeping lines under 80 characters,
fixing a couple of typos (predition -> prediction) and a
general style fix that was pointed out by Derek when I was having
my sliced multithreading patch in review by him.
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
-rw-r--r-- | libavcodec/utvideo.c | 100 |
1 files changed, 54 insertions, 46 deletions
diff --git a/libavcodec/utvideo.c b/libavcodec/utvideo.c index 378a1f7c16..a3b0d7cf01 100644 --- a/libavcodec/utvideo.c +++ b/libavcodec/utvideo.c @@ -175,9 +175,10 @@ static int decode_plane(UtvideoContext *c, int plane_no, continue; } - memcpy(c->slice_bits, src + slice_data_start + c->slices * 4, slice_size); + memcpy(c->slice_bits, src + slice_data_start + c->slices * 4, + slice_size); memset(c->slice_bits + slice_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); - c->dsp.bswap_buf((uint32_t*)c->slice_bits, (uint32_t*)c->slice_bits, + c->dsp.bswap_buf((uint32_t *) c->slice_bits, (uint32_t *) c->slice_bits, (slice_data_end - slice_data_start + 3) >> 2); init_get_bits(&gb, c->slice_bits, slice_size * 8); @@ -185,7 +186,8 @@ static int decode_plane(UtvideoContext *c, int plane_no, for (j = sstart; j < send; j++) { for (i = 0; i < width * step; i += step) { if (get_bits_left(&gb) <= 0) { - av_log(c->avctx, AV_LOG_ERROR, "Slice decoding ran out of bits\n"); + av_log(c->avctx, AV_LOG_ERROR, + "Slice decoding ran out of bits\n"); goto fail; } pix = get_vlc2(&gb, vlc.table, vlc.bits, 4); @@ -202,8 +204,8 @@ static int decode_plane(UtvideoContext *c, int plane_no, dest += stride; } if (get_bits_left(&gb) > 32) - av_log(c->avctx, AV_LOG_WARNING, "%d bits left after decoding slice\n", - get_bits_left(&gb)); + av_log(c->avctx, AV_LOG_WARNING, + "%d bits left after decoding slice\n", get_bits_left(&gb)); } ff_free_vlc(&vlc); @@ -216,7 +218,8 @@ fail: static const int rgb_order[4] = { 1, 2, 0, 3 }; -static void restore_rgb_planes(uint8_t *src, int step, int stride, int width, int height) +static void restore_rgb_planes(uint8_t *src, int step, int stride, int width, + int height) { int i, j; uint8_t r, g, b; @@ -243,8 +246,9 @@ static void restore_median(uint8_t *src, int step, int stride, const int cmask = ~rmode; for (slice = 0; slice < slices; slice++) { - slice_start = ((slice * height) / slices) & cmask; - slice_height = ((((slice + 1) * height) / slices) & cmask) - slice_start; + slice_start = ((slice * height) / slices) & cmask; + slice_height = ((((slice + 1) * height) / slices) & cmask) - + slice_start; bsrc = src + slice_start * stride; @@ -253,29 +257,29 @@ static void restore_median(uint8_t *src, int step, int stride, A = bsrc[0]; for (i = step; i < width * step; i += step) { bsrc[i] += A; - A = bsrc[i]; + A = bsrc[i]; } bsrc += stride; if (slice_height == 1) continue; - // second line - first element has top predition, the rest uses median - C = bsrc[-stride]; + // second line - first element has top prediction, the rest uses median + C = bsrc[-stride]; bsrc[0] += C; - A = bsrc[0]; + A = bsrc[0]; for (i = step; i < width * step; i += step) { - B = bsrc[i - stride]; + B = bsrc[i - stride]; bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C)); - C = B; - A = bsrc[i]; + C = B; + A = bsrc[i]; } bsrc += stride; // the rest of lines use continuous median prediction for (j = 2; j < slice_height; j++) { for (i = 0; i < width * step; i += step) { - B = bsrc[i - stride]; + B = bsrc[i - stride]; bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C)); - C = B; - A = bsrc[i]; + C = B; + A = bsrc[i]; } bsrc += stride; } @@ -293,67 +297,69 @@ static void restore_median_il(uint8_t *src, int step, int stride, int A, B, C; uint8_t *bsrc; int slice_start, slice_height; - const int cmask = ~(rmode ? 3 : 1); + const int cmask = ~(rmode ? 3 : 1); const int stride2 = stride << 1; for (slice = 0; slice < slices; slice++) { slice_start = ((slice * height) / slices) & cmask; - slice_height = ((((slice + 1) * height) / slices) & cmask) - slice_start; + slice_height = ((((slice + 1) * height) / slices) & cmask) - + slice_start; slice_height >>= 1; bsrc = src + slice_start * stride; // first line - left neighbour prediction bsrc[0] += 0x80; - A = bsrc[0]; + A = bsrc[0]; for (i = step; i < width * step; i += step) { bsrc[i] += A; - A = bsrc[i]; + A = bsrc[i]; } for (i = 0; i < width * step; i += step) { bsrc[stride + i] += A; - A = bsrc[stride + i]; + A = bsrc[stride + i]; } bsrc += stride2; if (slice_height == 1) continue; - // second line - first element has top predition, the rest uses median - C = bsrc[-stride2]; + // second line - first element has top prediction, the rest uses median + C = bsrc[-stride2]; bsrc[0] += C; - A = bsrc[0]; + A = bsrc[0]; for (i = step; i < width * step; i += step) { - B = bsrc[i - stride2]; + B = bsrc[i - stride2]; bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C)); - C = B; - A = bsrc[i]; + C = B; + A = bsrc[i]; } for (i = 0; i < width * step; i += step) { - B = bsrc[i - stride]; + B = bsrc[i - stride]; bsrc[stride + i] += mid_pred(A, B, (uint8_t)(A + B - C)); - C = B; - A = bsrc[stride + i]; + C = B; + A = bsrc[stride + i]; } bsrc += stride2; // the rest of lines use continuous median prediction for (j = 2; j < slice_height; j++) { for (i = 0; i < width * step; i += step) { - B = bsrc[i - stride2]; + B = bsrc[i - stride2]; bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C)); - C = B; - A = bsrc[i]; + C = B; + A = bsrc[i]; } for (i = 0; i < width * step; i += step) { - B = bsrc[i - stride]; + B = bsrc[i - stride]; bsrc[i + stride] += mid_pred(A, B, (uint8_t)(A + B - C)); - C = B; - A = bsrc[i + stride]; + C = B; + A = bsrc[i + stride]; } bsrc += stride2; } } } -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; int buf_size = avpkt->size; @@ -376,7 +382,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac ff_thread_finish_setup(avctx); - /* parse plane structure to retrieve frame flags and validate slice offsets */ + /* parse plane structure to get frame flags and validate slice offsets */ bytestream2_init(&gb, buf, buf_size); for (i = 0; i < c->planes; i++) { plane_start[i] = gb.buffer; @@ -443,8 +449,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac break; case PIX_FMT_YUV420P: for (i = 0; i < 3; i++) { - ret = decode_plane(c, i, c->pic.data[i], 1, - c->pic.linesize[i], avctx->width >> !!i, avctx->height >> !!i, + ret = decode_plane(c, i, c->pic.data[i], 1, c->pic.linesize[i], + avctx->width >> !!i, avctx->height >> !!i, plane_start[i], c->frame_pred == PRED_LEFT); if (ret) return ret; @@ -464,8 +470,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac break; case PIX_FMT_YUV422P: for (i = 0; i < 3; i++) { - ret = decode_plane(c, i, c->pic.data[i], 1, - c->pic.linesize[i], avctx->width >> !!i, avctx->height, + ret = decode_plane(c, i, c->pic.data[i], 1, c->pic.linesize[i], + avctx->width >> !!i, avctx->height, plane_start[i], c->frame_pred == PRED_LEFT); if (ret) return ret; @@ -502,7 +508,8 @@ static av_cold int decode_init(AVCodecContext *avctx) ff_dsputil_init(&c->dsp, avctx); if (avctx->extradata_size < 16) { - av_log(avctx, AV_LOG_ERROR, "Insufficient extradata size %d, should be at least 16\n", + av_log(avctx, AV_LOG_ERROR, + "Insufficient extradata size %d, should be at least 16\n", avctx->extradata_size); return AVERROR_INVALIDDATA; } @@ -510,7 +517,8 @@ static av_cold int decode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_DEBUG, "Encoder version %d.%d.%d.%d\n", avctx->extradata[3], avctx->extradata[2], avctx->extradata[1], avctx->extradata[0]); - av_log(avctx, AV_LOG_DEBUG, "Original format %X\n", AV_RB32(avctx->extradata + 4)); + av_log(avctx, AV_LOG_DEBUG, "Original format %X\n", + AV_RB32(avctx->extradata + 4)); c->frame_info_size = AV_RL32(avctx->extradata + 8); c->flags = AV_RL32(avctx->extradata + 12); |