diff options
author | Diego Biurrun <diego@biurrun.de> | 2013-12-20 13:58:18 +0100 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2014-03-13 08:12:44 -0700 |
commit | 635ec127d4bc0c49ae0ac4a50acd3da1ca8c2150 (patch) | |
tree | 3ed7ea1ac0b1beb9dbcaec0eb7c5d57ec6e25ce7 /libavcodec | |
parent | bb12c2e9c00e3d3c393885849b8fa31cd849dc92 (diff) | |
download | ffmpeg-635ec127d4bc0c49ae0ac4a50acd3da1ca8c2150.tar.gz |
dsputil: Merge variable declarations and initializations
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/dsputil.c | 105 | ||||
-rw-r--r-- | libavcodec/dsputil_template.c | 3 |
2 files changed, 35 insertions, 73 deletions
diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 8a4594ea8f..bfc6303082 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -106,21 +106,18 @@ static const uint8_t idct_sse2_row_perm[8] = { 0, 4, 1, 5, 2, 6, 3, 7 }; av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable) { - int i; - int end; + int i, end; st->scantable = src_scantable; for (i = 0; i < 64; i++) { - int j; - j = src_scantable[i]; + int j = src_scantable[i]; st->permutated[i] = permutation[j]; } end = -1; for (i = 0; i < 64; i++) { - int j; - j = st->permutated[i]; + int j = st->permutated[i]; if (j > end) end = j; st->raster_end[i] = end; @@ -165,9 +162,8 @@ av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation, static int pix_sum_c(uint8_t *pix, int line_size) { - int s, i, j; + int s = 0, i, j; - s = 0; for (i = 0; i < 16; i++) { for (j = 0; j < 16; j += 8) { s += pix[0]; @@ -187,10 +183,9 @@ static int pix_sum_c(uint8_t *pix, int line_size) static int pix_norm1_c(uint8_t *pix, int line_size) { - int s, i, j; + int s = 0, i, j; uint32_t *sq = ff_squareTbl + 256; - s = 0; for (i = 0; i < 16; i++) { for (j = 0; j < 16; j += 8) { #if 0 @@ -259,10 +254,9 @@ static void bswap16_buf(uint16_t *dst, const uint16_t *src, int len) static int sse4_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) { - int s, i; + int s = 0, i; uint32_t *sq = ff_squareTbl + 256; - s = 0; for (i = 0; i < h; i++) { s += sq[pix1[0] - pix2[0]]; s += sq[pix1[1] - pix2[1]]; @@ -276,10 +270,9 @@ static int sse4_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) static int sse8_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) { - int s, i; + int s = 0, i; uint32_t *sq = ff_squareTbl + 256; - s = 0; for (i = 0; i < h; i++) { s += sq[pix1[0] - pix2[0]]; s += sq[pix1[1] - pix2[1]]; @@ -297,10 +290,9 @@ static int sse8_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) static int sse16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) { - int s, i; + int s = 0, i; uint32_t *sq = ff_squareTbl + 256; - s = 0; for (i = 0; i < h; i++) { s += sq[pix1[0] - pix2[0]]; s += sq[pix1[1] - pix2[1]]; @@ -498,12 +490,12 @@ void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy, vx = ox; vy = oy; for (x = 0; x < 8; x++) { // FIXME: optimize - int src_x, src_y, frac_x, frac_y, index; + int index; + int src_x = vx >> 16; + int src_y = vy >> 16; + int frac_x = src_x & (s - 1); + int frac_y = src_y & (s - 1); - src_x = vx >> 16; - src_y = vy >> 16; - frac_x = src_x & (s - 1); - frac_y = src_y & (s - 1); src_x >>= shift; src_y >>= shift; @@ -1644,9 +1636,8 @@ static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride) static inline int pix_abs16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) { - int s, i; + int s = 0, i; - s = 0; for (i = 0; i < h; i++) { s += abs(pix1[0] - pix2[0]); s += abs(pix1[1] - pix2[1]); @@ -1673,9 +1664,8 @@ static inline int pix_abs16_c(void *v, uint8_t *pix1, uint8_t *pix2, static int pix_abs16_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) { - int s, i; + int s = 0, i; - s = 0; for (i = 0; i < h; i++) { s += abs(pix1[0] - avg2(pix2[0], pix2[1])); s += abs(pix1[1] - avg2(pix2[1], pix2[2])); @@ -1702,10 +1692,9 @@ static int pix_abs16_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, static int pix_abs16_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) { - int s, i; + int s = 0, i; uint8_t *pix3 = pix2 + line_size; - s = 0; for (i = 0; i < h; i++) { s += abs(pix1[0] - avg2(pix2[0], pix3[0])); s += abs(pix1[1] - avg2(pix2[1], pix3[1])); @@ -1733,10 +1722,9 @@ static int pix_abs16_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, static int pix_abs16_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) { - int s, i; + int s = 0, i; uint8_t *pix3 = pix2 + line_size; - s = 0; for (i = 0; i < h; i++) { s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1])); s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2])); @@ -1764,9 +1752,8 @@ static int pix_abs16_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, static inline int pix_abs8_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) { - int s, i; + int s = 0, i; - s = 0; for (i = 0; i < h; i++) { s += abs(pix1[0] - pix2[0]); s += abs(pix1[1] - pix2[1]); @@ -1785,9 +1772,8 @@ static inline int pix_abs8_c(void *v, uint8_t *pix1, uint8_t *pix2, static int pix_abs8_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) { - int s, i; + int s = 0, i; - s = 0; for (i = 0; i < h; i++) { s += abs(pix1[0] - avg2(pix2[0], pix2[1])); s += abs(pix1[1] - avg2(pix2[1], pix2[2])); @@ -1806,10 +1792,9 @@ static int pix_abs8_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, static int pix_abs8_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) { - int s, i; + int s = 0, i; uint8_t *pix3 = pix2 + line_size; - s = 0; for (i = 0; i < h; i++) { s += abs(pix1[0] - avg2(pix2[0], pix3[0])); s += abs(pix1[1] - avg2(pix2[1], pix3[1])); @@ -1829,10 +1814,9 @@ static int pix_abs8_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, static int pix_abs8_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) { - int s, i; + int s = 0, i; uint8_t *pix3 = pix2 + line_size; - s = 0; for (i = 0; i < h; i++) { s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1])); s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2])); @@ -1852,9 +1836,7 @@ static int pix_abs8_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, static int nsse16_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h) { MpegEncContext *c = v; - int score1 = 0; - int score2 = 0; - int x, y; + int score1 = 0, score2 = 0, x, y; for (y = 0; y < h; y++) { for (x = 0; x < 16; x++) @@ -1879,9 +1861,7 @@ static int nsse16_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h) static int nsse8_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h) { MpegEncContext *c = v; - int score1 = 0; - int score2 = 0; - int x, y; + int score1 = 0, score2 = 0, x, y; for (y = 0; y < h; y++) { for (x = 0; x < 8; x++) @@ -2109,12 +2089,7 @@ static void add_hfyu_left_prediction_bgr32_c(uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha) { - int i; - int r, g, b, a; - r = *red; - g = *green; - b = *blue; - a = *alpha; + int i, r = *red, g = *green, b = *blue, a = *alpha; for (i = 0; i < w; i++) { b += src[4 * i + B]; @@ -2156,9 +2131,7 @@ static void add_hfyu_left_prediction_bgr32_c(uint8_t *dst, const uint8_t *src, static int hadamard8_diff8x8_c(/* MpegEncContext */ void *s, uint8_t *dst, uint8_t *src, int stride, int h) { - int i; - int temp[64]; - int sum = 0; + int i, temp[64], sum = 0; assert(h == 8); @@ -2210,9 +2183,7 @@ static int hadamard8_diff8x8_c(/* MpegEncContext */ void *s, uint8_t *dst, static int hadamard8_intra8x8_c(/* MpegEncContext */ void *s, uint8_t *src, uint8_t *dummy, int stride, int h) { - int i; - int temp[64]; - int sum = 0; + int i, temp[64], sum = 0; assert(h == 8); @@ -2308,8 +2279,7 @@ static int dct264_sad8x8_c(/* MpegEncContext */ void *c, uint8_t *src1, { MpegEncContext *const s = (MpegEncContext *) c; int16_t dct[8][8]; - int i; - int sum = 0; + int i, sum = 0; s->dsp.diff_pixels(dct[0], src1, src2, stride); @@ -2384,8 +2354,7 @@ static int rd8x8_c(/* MpegEncContext */ void *c, uint8_t *src1, uint8_t *src2, LOCAL_ALIGNED_16(uint8_t, lsrc2, [64]); int i, last, run, bits, level, distortion, start_i; const int esc_length = s->ac_esc_length; - uint8_t *length; - uint8_t *last_length; + uint8_t *length, *last_length; assert(h == 8); @@ -2461,8 +2430,7 @@ static int bit8x8_c(/* MpegEncContext */ void *c, uint8_t *src1, uint8_t *src2, LOCAL_ALIGNED_16(int16_t, temp, [64]); int i, last, run, bits, level, start_i; const int esc_length = s->ac_esc_length; - uint8_t *length; - uint8_t *last_length; + uint8_t *length, *last_length; assert(h == 8); @@ -2521,8 +2489,7 @@ static int vsad_intra ## size ## _c(/* MpegEncContext */ void *c, \ uint8_t *s, uint8_t *dummy, \ int stride, int h) \ { \ - int score = 0; \ - int x, y; \ + int score = 0, x, y; \ \ for (y = 1; y < h; y++) { \ for (x = 0; x < size; x += 4) { \ @@ -2542,8 +2509,7 @@ VSAD_INTRA(16) static int vsad16_c(/* MpegEncContext */ void *c, uint8_t *s1, uint8_t *s2, int stride, int h) { - int score = 0; - int x, y; + int score = 0, x, y; for (y = 1; y < h; y++) { for (x = 0; x < 16; x++) @@ -2561,8 +2527,7 @@ static int vsse_intra ## size ## _c(/* MpegEncContext */ void *c, \ uint8_t *s, uint8_t *dummy, \ int stride, int h) \ { \ - int score = 0; \ - int x, y; \ + int score = 0, x, y; \ \ for (y = 1; y < h; y++) { \ for (x = 0; x < size; x += 4) { \ @@ -2582,8 +2547,7 @@ VSSE_INTRA(16) static int vsse16_c(/* MpegEncContext */ void *c, uint8_t *s1, uint8_t *s2, int stride, int h) { - int score = 0; - int x, y; + int score = 0, x, y; for (y = 1; y < h; y++) { for (x = 0; x < 16; x++) @@ -2598,8 +2562,7 @@ static int vsse16_c(/* MpegEncContext */ void *c, uint8_t *s1, uint8_t *s2, static int ssd_int8_vs_int16_c(const int8_t *pix1, const int16_t *pix2, int size) { - int score = 0; - int i; + int score = 0, i; for (i = 0; i < size; i++) score += (pix1[i] - pix2[i]) * (pix1[i] - pix2[i]); diff --git a/libavcodec/dsputil_template.c b/libavcodec/dsputil_template.c index 3a6d27fa39..98564ebb68 100644 --- a/libavcodec/dsputil_template.c +++ b/libavcodec/dsputil_template.c @@ -36,11 +36,10 @@ static void FUNCC(draw_edges)(uint8_t *_buf, int _wrap, int width, int height, i { pixel *buf = (pixel*)_buf; int wrap = _wrap / sizeof(pixel); - pixel *ptr, *last_line; + pixel *ptr = buf, *last_line; int i; /* left and right */ - ptr = buf; for(i=0;i<height;i++) { memset(ptr - w, ptr[0], w); memset(ptr + width, ptr[width-1], w); |