Merge commit 'de1f8ead8993512925a3ee6c7491473414419e55'
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 17 Nov 2014 10:41:35 +0000 (11:41 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 17 Nov 2014 10:41:35 +0000 (11:41 +0100)
* commit 'de1f8ead8993512925a3ee6c7491473414419e55':
  hevcdsp_template: templatize transquant_bypass

Conflicts:
libavcodec/hevcdsp_template.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/hevcdsp_template.c

@@@ -59,103 -57,48 +59,76 @@@ static av_always_inline void FUNC(trans
      }
  }
  
- static void FUNC(transform_add8x8)(uint8_t *_dst, int16_t *coeffs,
 -static void FUNC(transquant_bypass4x4)(uint8_t *_dst, int16_t *coeffs,
++static void FUNC(transform_add4x4)(uint8_t *_dst, int16_t *coeffs,
                                         ptrdiff_t stride)
  {
-     int x, y;
-     pixel *dst = (pixel *)_dst;
-     stride /= sizeof(pixel);
+     FUNC(transquant_bypass)(_dst, coeffs, stride, 4);
+ }
  
-     for (y = 0; y < 8; y++) {
-         for (x = 0; x < 8; x++) {
-             dst[x] = av_clip_pixel(dst[x] + *coeffs);
-             coeffs++;
-         }
-         dst += stride;
-     }
 -static void FUNC(transquant_bypass8x8)(uint8_t *_dst, int16_t *coeffs,
++static void FUNC(transform_add8x8)(uint8_t *_dst, int16_t *coeffs,
+                                        ptrdiff_t stride)
+ {
+     FUNC(transquant_bypass)(_dst, coeffs, stride, 8);
  }
  
 -static void FUNC(transquant_bypass16x16)(uint8_t *_dst, int16_t *coeffs,
 +static void FUNC(transform_add16x16)(uint8_t *_dst, int16_t *coeffs,
                                           ptrdiff_t stride)
  {
-     int x, y;
-     pixel *dst = (pixel *)_dst;
-     stride /= sizeof(pixel);
-     for (y = 0; y < 16; y++) {
-         for (x = 0; x < 16; x++) {
-             dst[x] = av_clip_pixel(dst[x] + *coeffs);
-             coeffs++;
-         }
-         dst += stride;
-     }
+     FUNC(transquant_bypass)(_dst, coeffs, stride, 16);
  }
  
 -static void FUNC(transquant_bypass32x32)(uint8_t *_dst, int16_t *coeffs,
 +static void FUNC(transform_add32x32)(uint8_t *_dst, int16_t *coeffs,
                                           ptrdiff_t stride)
  {
-     int x, y;
-     pixel *dst = (pixel *)_dst;
-     stride /= sizeof(pixel);
-     for (y = 0; y < 32; y++) {
-         for (x = 0; x < 32; x++) {
-             dst[x] = av_clip_pixel(dst[x] + *coeffs);
-             coeffs++;
-         }
-         dst += stride;
-     }
+     FUNC(transquant_bypass)(_dst, coeffs, stride, 32);
  }
  
 -static void FUNC(transform_skip)(uint8_t *_dst, int16_t *coeffs,
 -                                 ptrdiff_t stride)
 +
 +static void FUNC(transform_rdpcm)(int16_t *_coeffs, int16_t log2_size, int mode)
  {
 -    pixel *dst = (pixel *)_dst;
 -    int shift  = 13 - BIT_DEPTH;
 -#if BIT_DEPTH <= 13
 -    int offset = 1 << (shift - 1);
 -#else
 -    int offset = 0;
 -#endif
 +    int16_t *coeffs = (int16_t *) _coeffs;
      int x, y;
 +    int size = 1 << log2_size;
 +
 +    if (mode) {
 +        coeffs += size;
 +        for (y = 0; y < size - 1; y++) {
 +            for (x = 0; x < size; x++)
 +                coeffs[x] += coeffs[x - size];
 +            coeffs += size;
 +        }
 +    } else {
 +        for (y = 0; y < size; y++) {
 +            for (x = 1; x < size; x++)
 +                coeffs[x] += coeffs[x - 1];
 +            coeffs += size;
 +        }
 +    }
 +}
  
 -    stride /= sizeof(pixel);
 +static void FUNC(transform_skip)(int16_t *_coeffs, int16_t log2_size)
 +{
 +    int shift  = 15 - BIT_DEPTH - log2_size;
 +    int x, y;
 +    int size = 1 << log2_size;
 +    int16_t *coeffs = _coeffs;
  
 -    for (y = 0; y < 4 * 4; y += 4) {
 -        for (x = 0; x < 4; x++)
 -            dst[x] = av_clip_pixel(dst[x] + ((coeffs[y + x] + offset) >> shift));
 -        dst += stride;
 +
 +    if (shift > 0) {
 +        int offset = 1 << (shift - 1);
 +        for (y = 0; y < size; y++) {
 +            for (x = 0; x < size; x++) {
 +                *coeffs = (*coeffs + offset) >> shift;
 +                coeffs++;
 +            }
 +        }
 +    } else {
 +        for (y = 0; y < size; y++) {
 +            for (x = 0; x < size; x++) {
 +                *coeffs = *coeffs << -shift;
 +                coeffs++;
 +            }
 +        }
      }
  }