From 9666344ee24d90cc7b398ad34c282983acedb06c Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Thu, 6 Aug 2009 20:03:27 -0600 Subject: [PATCH] Remove hungarian notation. --- libavcodec/lagarith.c | 260 +++++++++++++++++++++++++------------------------- 1 file changed, 128 insertions(+), 132 deletions(-) diff --git a/libavcodec/lagarith.c b/libavcodec/lagarith.c index 5da171312d..bab5256ee2 100644 --- a/libavcodec/lagarith.c +++ b/libavcodec/lagarith.c @@ -57,9 +57,8 @@ typedef struct lag_rac { typedef struct LagarithContext { AVCodecContext *avctx; AVFrame picture; - int i_zeros; - int i_zeros_rem; - int i_frame; + int zeros; + int zeros_rem; } LagarithContext; /** @@ -69,11 +68,11 @@ typedef struct LagarithContext { */ static av_cold int lag_decode_init(AVCodecContext * avctx) { - LagarithContext *p_ctx = avctx->priv_data; + LagarithContext *l = avctx->priv_data; avctx->pix_fmt = PIX_FMT_NONE; - p_ctx->avctx = avctx; + l->avctx = avctx; av_log_set_level(AV_LOG_DEBUG); @@ -141,43 +140,43 @@ static inline int lag_get_rac(struct lag_rac *l) return val; } -void lag_memset(uint8_t * s, uint8_t c, size_t n, int i_step) +void lag_memset(uint8_t * s, uint8_t c, size_t n, int step) { if (n == 0) return; - if (i_step == 1) { + if (step == 1) { memset(s, c, n); return; } - for (int i = 0; i < n * i_step; i += i_step) + for (int i = 0; i < n * step; i += step) s[i] = c; return; } uint8_t *lag_memcpy(uint8_t * dest, const uint8_t * src, size_t n, - int i_step) + int step) { if (n == 0) return dest; - if (i_step == 1) + if (step == 1) return memcpy(dest, src, n); - for (int i = 0; i < n * i_step; i += i_step) + for (int i = 0; i < n * step; i += step) dest[i] = src[i]; return dest; } -static inline int lag_predict(uint8_t * p_src, int i_stride, int i_step) +static inline int lag_predict(uint8_t * src, int stride, int step) { - int T = p_src[-i_stride]; - int L = p_src[-i_step]; - int TL = p_src[-i_stride - i_step]; + int T = src[-stride]; + int L = src[-step]; + int TL = src[-stride - step]; return mid_pred(T, L, L + T - TL); } -static uint32_t lag_decode_prob(GetBitContext * p_gb) +static uint32_t lag_decode_prob(GetBitContext * gb) { unsigned int bit = 0; unsigned int series[] = { 1, 2, 3, 5, 8, 13, 21, 34 }; @@ -188,7 +187,7 @@ static uint32_t lag_decode_prob(GetBitContext * p_gb) for (i = 0; !(prevbit && bit); i++) { prevbit = bit; - bit = get_bits1(p_gb); + bit = get_bits1(gb); if (bit && !prevbit) bits += series[i]; } @@ -196,7 +195,7 @@ static uint32_t lag_decode_prob(GetBitContext * p_gb) if (bits == 0) return 0; - value = get_bits_long(p_gb, bits); + value = get_bits_long(gb, bits); value |= 1 << bits; return value - 1; @@ -214,7 +213,7 @@ static inline uint32_t clp2(uint32_t x) return x + 1; } -static uint32_t lag_read_prob_header(lag_rac * p_rac, GetBitContext * p_gb) +static uint32_t lag_read_prob_header(lag_rac * rac, GetBitContext * gb) { unsigned int freq = 0; unsigned int i, j; @@ -223,17 +222,17 @@ static uint32_t lag_read_prob_header(lag_rac * p_rac, GetBitContext * p_gb) double scale_factor = 0; unsigned int scaled_cumul_prob = 0; - p_rac->prob[0] = 0; + rac->prob[0] = 0; /* Read probabilities from bitstream */ for (i = 1; i < 257; i++) { - p_rac->prob[i] = lag_decode_prob(p_gb); - cumul_prob += p_rac->prob[i]; - if (p_rac->prob[i] == 0) { - freq = lag_decode_prob(p_gb); + rac->prob[i] = lag_decode_prob(gb); + cumul_prob += rac->prob[i]; + if (rac->prob[i] == 0) { + freq = lag_decode_prob(gb); if (i + freq >= 258) freq = 257 - i; for (j = 0; j < freq; j++) - p_rac->prob[++i] = 0; + rac->prob[++i] = 0; } } @@ -243,22 +242,22 @@ static uint32_t lag_read_prob_header(lag_rac * p_rac, GetBitContext * p_gb) scale_factor = temp / (double) cumul_prob; for (i = 1; i < 257; i++) { - p_rac->prob[i] = (unsigned int) (p_rac->prob[i] * scale_factor); - scaled_cumul_prob += p_rac->prob[i]; + rac->prob[i] = (unsigned int) (rac->prob[i] * scale_factor); + scaled_cumul_prob += rac->prob[i]; } scaled_cumul_prob = temp - scaled_cumul_prob; if ((signed int) scaled_cumul_prob < 0) { - av_log(p_rac->avctx, AV_LOG_ERROR, + av_log(rac->avctx, AV_LOG_ERROR, "Scaled cumulative probability is larger than expected!"); return 0; } i = 0; while (scaled_cumul_prob) { - if (p_rac->prob[i + 1]) { - p_rac->prob[i + 1]++; + if (rac->prob[i + 1]) { + rac->prob[i + 1]++; scaled_cumul_prob--; } @@ -278,46 +277,45 @@ static uint32_t lag_read_prob_header(lag_rac * p_rac, GetBitContext * p_gb) for (i = 0; temp; i++) temp >>= 1; - p_rac->scale = i - 1; + rac->scale = i - 1; /* Fill probability array with cumulative probability for each symbol. */ for (i = 1; i < 257; i++) - p_rac->prob[i] += p_rac->prob[i - 1]; + rac->prob[i] += rac->prob[i - 1]; return 0; } -static void lag_pred_line(LagarithContext * l, uint8_t * p_buf, - int i_width, int i_stride, int i_step, - int i_mode) +static void lag_pred_line(LagarithContext * l, uint8_t * buf, + int width, int stride, int step, int mode) { int i = 0; - int width_scaled = i_width * i_step; + int width_scaled = width * step; - if (i_mode == 0) { + if (mode == 0) { /* Left prediction only for first line */ - for (i = i_step; i < width_scaled; i += i_step) - p_buf[i] += p_buf[i - i_step]; - } else if (i_mode == 1) { + for (i = step; i < width_scaled; i += step) + buf[i] += buf[i - step]; + } else if (mode == 1) { /* Second line, left predict first pixel, the rest of the line is median predicted */ /* FIXME: In the case of RGB this pixel is top predicted */ - p_buf[i] += p_buf[width_scaled - i_stride - i_step]; - i += i_step; + buf[i] += buf[width_scaled - stride - step]; + i += step; } else { /* Special case for first pixel in a row */ - int T = p_buf[-i_stride]; + int T = buf[-stride]; /* Left pixel is actually prev_row[width] */ - int L = p_buf[width_scaled - i_stride - i_step]; + int L = buf[width_scaled - stride - step]; /* Top left is 2 rows back, last pixel */ - int TL = p_buf[width_scaled - (2 * i_stride) - i_step]; + int TL = buf[width_scaled - (2 * stride) - step]; - p_buf[i] += mid_pred(T, L, L + T - TL); - i += i_step; + buf[i] += mid_pred(T, L, L + T - TL); + i += step; } while (i < width_scaled) { - p_buf[i] += lag_predict(p_buf + i, i_stride, i_step); - i += i_step; + buf[i] += lag_predict(buf + i, stride, step); + i += step; } @@ -325,111 +323,110 @@ static void lag_pred_line(LagarithContext * l, uint8_t * p_buf, } static int lag_decode_line(LagarithContext * l, lag_rac * rac, - uint8_t * p_dst, int i_width, int i_stride, - int i_step, int i_esc_count) + uint8_t * dst, int width, int stride, + int step, int esc_count) { int i = 0; int ret = 0; - int width_scaled = i_width * i_step; + int width_scaled = width * step; /* Output any zeros remaining from the previous run */ - if (l->i_zeros_rem) { - int count = l->i_zeros_rem; - if (l->i_zeros_rem > i_width) - count = i_width; - lag_memset(p_dst + i, 0, count, i_step); - i += count * i_step; - l->i_zeros_rem -= count; + if (l->zeros_rem) { + int count = l->zeros_rem; + if (l->zeros_rem > width) + count = width; + lag_memset(dst + i, 0, count, step); + i += count * step; + l->zeros_rem -= count; } while (i < width_scaled) { - p_dst[i] = lag_get_rac(rac); + dst[i] = lag_get_rac(rac); ret++; - if (p_dst[i]) - l->i_zeros = 0; + if (dst[i]) + l->zeros = 0; else - l->i_zeros++; + l->zeros++; - i += i_step; - if (i_esc_count && (l->i_zeros == i_esc_count)) { + i += step; + if (esc_count && (l->zeros == esc_count)) { int count; int index = lag_get_rac(rac); ret++; - l->i_zeros = 0; + l->zeros = 0; - l->i_zeros_rem = count = run_table[index]; + l->zeros_rem = count = run_table[index]; - if (i + count * i_step > width_scaled) - count = (width_scaled - i) / i_step; + if (i + count * step > width_scaled) + count = (width_scaled - i) / step; - lag_memset(p_dst + i, 0, count, i_step); - i += count * i_step; - l->i_zeros_rem -= count; + lag_memset(dst + i, 0, count, step); + i += count * step; + l->zeros_rem -= count; } } return ret; } -static int lag_decode_zero_run_line(LagarithContext * l, uint8_t * p_dst, - const uint8_t * p_src, int i_width, - int i_step, int i_esc_count) +static int lag_decode_zero_run_line(LagarithContext * l, uint8_t * dst, + const uint8_t * src, int width, + int step, int esc_count) { - uint8_t mask1 = i_esc_count < 2 ? 0x00 : 0xff; - uint8_t mask2 = i_esc_count < 3 ? 0x00 : 0xff; - uint8_t *p_end = p_dst + (i_width - 2) * i_step; - const uint8_t *p_start = p_src; + uint8_t mask1 = esc_count < 2 ? 0x00 : 0xff; + uint8_t mask2 = esc_count < 3 ? 0x00 : 0xff; + uint8_t *end = dst + (width - 2) * step; + const uint8_t *start = src; int i = 0; uint8_t zero_run = 1; int count; - if (l->i_zeros_rem) { - count = l->i_zeros_rem; - if (count > i_width) - count = i_width; - lag_memset(p_dst, 0, count, i_step); - l->i_zeros_rem -= count; - p_dst += count; + if (l->zeros_rem) { + count = l->zeros_rem; + if (count > width) + count = width; + lag_memset(dst, 0, count, step); + l->zeros_rem -= count; + dst += count; } - while (p_dst < p_end) { + while (dst < end) { i = 0; - while (!zero_run && p_dst + i * i_step < p_end) { + while (!zero_run && dst + i * step < end) { i++; zero_run = - (p_src[i] | (p_src[i + 1] & mask1) | - (p_src[i + 2] & mask2)); + (src[i] | (src[i + 1] & mask1) | (src[i + 2] & mask2)); } if (!zero_run) { i += 3; - lag_memcpy(p_dst, p_src, i, i_step); - p_dst += i; - l->i_zeros_rem = count = run_table[p_src[i]]; - if (p_dst + l->i_zeros_rem * i_step > p_end) { - count = (p_end - p_dst) / i_step; + lag_memcpy(dst, src, i, step); + dst += i; + l->zeros_rem = count = run_table[src[i]]; + if (dst + l->zeros_rem * step > end) { + count = (end - dst) / step; } - lag_memset(p_dst, 0, count, i_step); - p_dst += count; - p_src += i + 1; - l->i_zeros_rem -= count; + lag_memset(dst, 0, count, step); + dst += count; + src += i + 1; + l->zeros_rem -= count; } else { - lag_memcpy(p_dst, p_src, i, i_step); - p_src += i; + lag_memcpy(dst, src, i, step); + src += i; } } - return p_start - p_src; + return start - src; } -static int lag_decode_arith_plane(LagarithContext * l, uint8_t * p_dst, - int i_width, int i_height, int i_stride, - int i_step, const uint8_t * p_src, - int i_src) +static int lag_decode_arith_plane(LagarithContext * l, uint8_t * dst, + int width, int height, int stride, + int step, const uint8_t * src, + int src_size) { - int esc_count = p_src[0]; + int esc_count = src[0]; int i = 0; int read = 0; uint32_t offset = 1; @@ -441,24 +438,24 @@ static int lag_decode_arith_plane(LagarithContext * l, uint8_t * p_dst, if (esc_count < 4) { if (esc_count != 0) { - length = *(const uint32_t *) (p_src + 1); - if (length < i_width * i_height) + length = *(const uint32_t *) (src + 1); + if (length < width * height) offset += 4; else - length = i_width * i_height; + length = width * height; } else - length = i_width * i_height; + length = width * height; - init_get_bits(&gb, p_src + offset, i_src * 8); + init_get_bits(&gb, src + offset, src_size * 8); offset += lag_read_prob_header(&rac, &gb); - lag_rac_init(&rac, &gb, length - i_stride); + lag_rac_init(&rac, &gb, length - stride); - for (i = 0; i < i_height; i++) + for (i = 0; i < height; i++) read += - lag_decode_line(l, &rac, p_dst + (i * i_stride), i_width, - i_stride, i_step, esc_count); + lag_decode_line(l, &rac, dst + (i * stride), width, + stride, step, esc_count); if (read > length) av_log(l->avctx, AV_LOG_WARNING, @@ -468,30 +465,29 @@ static int lag_decode_arith_plane(LagarithContext * l, uint8_t * p_dst, esc_count -= 4; if (esc_count > 0) { /* Zero run coding only, no range coding. */ - for (i = 0; i < i_height; i++) - p_src += - lag_decode_zero_run_line(l, p_dst + (i * i_stride), - p_src, i_width, i_step, - esc_count); + for (i = 0; i < height; i++) + src += + lag_decode_zero_run_line(l, dst + (i * stride), + src, width, step, esc_count); } else { /* Plane is stored uncompressed */ - for (i = 0; i < i_height; i++) { - lag_memcpy(p_dst + (i * i_stride), p_src, i_width, i_step); - p_src += i_width; + for (i = 0; i < height; i++) { + lag_memcpy(dst + (i * stride), src, width, step); + src += width; } } } else if (esc_count == 0xff) { /* Plane is a solid run of 0 bytes */ - memset(p_dst, 0, i_stride * i_height); + memset(dst, 0, stride * height); } else { av_log(l->avctx, AV_LOG_ERROR, "Invalid zero run escape code! (%#x)", esc_count); return -1; } - for (i = 0; i < i_height; i++) { - lag_pred_line(l, p_dst, i_width, i_stride, i_step, i); - p_dst += i_stride; + for (i = 0; i < height; i++) { + lag_pred_line(l, dst, width, stride, step, i); + dst += stride; } return 0; @@ -512,7 +508,7 @@ static int lag_decode_frame(AVCodecContext * avctx, int buf_size = avpkt->size; LagarithContext *l = avctx->priv_data; AVFrame *const p = &l->picture; - uint8_t i_frametype = 0; + uint8_t frametype = 0; uint32_t offset_gu = 0, offset_bv = 0, offset_ry = 9; AVFrame *picture = data; @@ -523,12 +519,12 @@ static int lag_decode_frame(AVCodecContext * avctx, p->reference = 0; p->key_frame = 1; - i_frametype = buf[0]; + frametype = buf[0]; offset_gu = *(const uint32_t *) (buf + 1); offset_bv = *(const uint32_t *) (buf + 5); - switch (i_frametype) { + switch (frametype) { case FRAME_ARITH_YV12: avctx->pix_fmt = PIX_FMT_YUV420P; @@ -549,7 +545,7 @@ static int lag_decode_frame(AVCodecContext * avctx, break; default: av_log(avctx, AV_LOG_ERROR, - "Unsupported Lagarith frame type: %#x\n", i_frametype); + "Unsupported Lagarith frame type: %#x\n", frametype); return -1; } -- 2.11.4.GIT