mimic: cosmetics, reformat

This commit is contained in:
Anton Khirnov 2012-12-26 10:11:12 +01:00
parent 04e1249609
commit a0cabd0a27
1 changed files with 56 additions and 53 deletions

View File

@ -131,7 +131,8 @@ static int mimic_decode_update_thread_context(AVCodecContext *avctx, const AVCod
{ {
MimicContext *dst = avctx->priv_data, *src = avctx_from->priv_data; MimicContext *dst = avctx->priv_data, *src = avctx_from->priv_data;
if (avctx == avctx_from) return 0; if (avctx == avctx_from)
return 0;
dst->cur_index = src->next_cur_index; dst->cur_index = src->next_cur_index;
dst->prev_index = src->next_prev_index; dst->prev_index = src->next_prev_index;
@ -232,25 +233,23 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
for (plane = 0; plane < 3; plane++) { for (plane = 0; plane < 3; plane++) {
const int is_chroma = !!plane; const int is_chroma = !!plane;
const int qscale = av_clip(10000-quality,is_chroma?1000:2000,10000)<<2; const int qscale = av_clip(10000 - quality, is_chroma ? 1000 : 2000,
10000) << 2;
const int stride = ctx->flipped_ptrs[ctx->cur_index ].linesize[plane]; const int stride = ctx->flipped_ptrs[ctx->cur_index ].linesize[plane];
const uint8_t *src = ctx->flipped_ptrs[ctx->prev_index].data[plane]; const uint8_t *src = ctx->flipped_ptrs[ctx->prev_index].data[plane];
uint8_t *dst = ctx->flipped_ptrs[ctx->cur_index ].data[plane]; uint8_t *dst = ctx->flipped_ptrs[ctx->cur_index ].data[plane];
for (y = 0; y < ctx->num_vblocks[plane]; y++) { for (y = 0; y < ctx->num_vblocks[plane]; y++) {
for (x = 0; x < ctx->num_hblocks[plane]; x++) { for (x = 0; x < ctx->num_hblocks[plane]; x++) {
/* Check for a change condition in the current block. /* Check for a change condition in the current block.
* - iframes always change. * - iframes always change.
* - Luma plane changes on get_bits1 == 0 * - Luma plane changes on get_bits1 == 0
* - Chroma planes change on get_bits1 == 1 */ * - Chroma planes change on get_bits1 == 1 */
if (is_iframe || get_bits1(&ctx->gb) == is_chroma) { if (is_iframe || get_bits1(&ctx->gb) == is_chroma) {
/* Luma planes may use a backreference from the 15 last /* Luma planes may use a backreference from the 15 last
* frames preceding the previous. (get_bits1 == 1) * frames preceding the previous. (get_bits1 == 1)
* Chroma planes don't use backreferences. */ * Chroma planes don't use backreferences. */
if (is_chroma || is_iframe || !get_bits1(&ctx->gb)) { if (is_chroma || is_iframe || !get_bits1(&ctx->gb)) {
if (!vlc_decode_block(ctx, num_coeffs, qscale)) if (!vlc_decode_block(ctx, num_coeffs, qscale))
return 0; return 0;
ctx->dsp.idct_put(dst, stride, ctx->dct_block); ctx->dsp.idct_put(dst, stride, ctx->dct_block);
@ -260,7 +259,8 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
uint8_t *p = ctx->flipped_ptrs[index].data[0]; uint8_t *p = ctx->flipped_ptrs[index].data[0];
if (index != ctx->cur_index && p) { if (index != ctx->cur_index && p) {
ff_thread_await_progress(&ctx->buf_ptrs[index], cur_row, 0); ff_thread_await_progress(&ctx->buf_ptrs[index],
cur_row, 0);
p += src - p += src -
ctx->flipped_ptrs[ctx->prev_index].data[plane]; ctx->flipped_ptrs[ctx->prev_index].data[plane];
ctx->dsp.put_pixels_tab[1][0](dst, p, stride, 8); ctx->dsp.put_pixels_tab[1][0](dst, p, stride, 8);
@ -270,7 +270,8 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
} }
} }
} else { } else {
ff_thread_await_progress(&ctx->buf_ptrs[ctx->prev_index], cur_row, 0); ff_thread_await_progress(&ctx->buf_ptrs[ctx->prev_index],
cur_row, 0);
ctx->dsp.put_pixels_tab[1][0](dst, src, stride, 8); ctx->dsp.put_pixels_tab[1][0](dst, src, stride, 8);
} }
src += 8; src += 8;
@ -279,7 +280,8 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
src += (stride - ctx->num_hblocks[plane]) << 3; src += (stride - ctx->num_hblocks[plane]) << 3;
dst += (stride - ctx->num_hblocks[plane]) << 3; dst += (stride - ctx->num_hblocks[plane]) << 3;
ff_thread_report_progress(&ctx->buf_ptrs[ctx->cur_index], cur_row++, 0); ff_thread_report_progress(&ctx->buf_ptrs[ctx->cur_index],
cur_row++, 0);
} }
} }
@ -305,12 +307,12 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data,
{ {
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
int swap_buf_size = buf_size - MIMIC_HEADER_SIZE;
MimicContext *ctx = avctx->priv_data; MimicContext *ctx = avctx->priv_data;
GetByteContext gb; GetByteContext gb;
int is_pframe; int is_pframe;
int width, height; int width, height;
int quality, num_coeffs; int quality, num_coeffs;
int swap_buf_size = buf_size - MIMIC_HEADER_SIZE;
int res; int res;
if (buf_size <= MIMIC_HEADER_SIZE) { if (buf_size <= MIMIC_HEADER_SIZE) {
@ -356,7 +358,8 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data,
} }
ctx->buf_ptrs[ctx->cur_index].reference = 1; ctx->buf_ptrs[ctx->cur_index].reference = 1;
ctx->buf_ptrs[ctx->cur_index].pict_type = is_pframe ? AV_PICTURE_TYPE_P:AV_PICTURE_TYPE_I; ctx->buf_ptrs[ctx->cur_index].pict_type = is_pframe ? AV_PICTURE_TYPE_P :
AV_PICTURE_TYPE_I;
if (ff_thread_get_buffer(avctx, &ctx->buf_ptrs[ctx->cur_index])) { if (ff_thread_get_buffer(avctx, &ctx->buf_ptrs[ctx->cur_index])) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1; return -1;