Advertisement
Guest User

Untitled

a guest
Feb 13th, 2014
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.33 KB | None | 0 0
  1. static void FUNC(put_unweighted_pred)(uint8_t *_dst, ptrdiff_t _dststride,
  2.                                       int16_t *src, ptrdiff_t srcstride,
  3.                                       int width, int height)
  4. {
  5.     int x, y;
  6.     pixel *dst          = (pixel *)_dst;
  7.     ptrdiff_t dststride = _dststride / sizeof(pixel);
  8.  
  9.     int shift = 14 - BIT_DEPTH;
  10. #if BIT_DEPTH < 14
  11.     int offset = 1 << (shift - 1);
  12. #else
  13.     int offset = 0;
  14. #endif
  15.     for (y = 0; y < height; y++) {
  16.         for (x = 0; x < width; x++)
  17.             dst[x] = av_clip_pixel((src[x] + offset) >> shift);
  18.         dst += dststride;
  19.         src += srcstride;
  20.     }
  21. }
  22.  
  23. static void FUNC(put_weighted_pred_avg)(uint8_t *_dst, ptrdiff_t _dststride,
  24.                                         int16_t *src1, int16_t *src2,
  25.                                         ptrdiff_t srcstride,
  26.                                         int width, int height)
  27. {
  28.     int x, y;
  29.     pixel *dst          = (pixel *)_dst;
  30.     ptrdiff_t dststride = _dststride / sizeof(pixel);
  31.  
  32.     int shift = 14 + 1 - BIT_DEPTH;
  33. #if BIT_DEPTH < 14
  34.     int offset = 1 << (shift - 1);
  35. #else
  36.     int offset = 0;
  37. #endif
  38.  
  39.     for (y = 0; y < height; y++) {
  40.         for (x = 0; x < width; x++)
  41.             dst[x] = av_clip_pixel((src1[x] + src2[x] + offset) >> shift);
  42.         dst  += dststride;
  43.         src1 += srcstride;
  44.         src2 += srcstride;
  45.     }
  46. }
  47.  
  48. static void FUNC(weighted_pred)(uint8_t denom, int16_t wlxFlag, int16_t olxFlag,
  49.                                 uint8_t *_dst, ptrdiff_t _dststride,
  50.                                 int16_t *src, ptrdiff_t srcstride,
  51.                                 int width, int height)
  52. {
  53.     int shift, wx, ox, x, y, offset;
  54.     pixel *dst          = (pixel *)_dst;
  55.     ptrdiff_t dststride = _dststride / sizeof(pixel);
  56.  
  57.     shift  = denom + 14 - BIT_DEPTH;
  58.     if (shift >= 1) {
  59.         offset = 1 << (shift - 1);
  60.     } else {
  61.         shift  = 0;
  62.         offset = 0;
  63.     }
  64.     wx     = wlxFlag;
  65.     ox     = olxFlag * (1 << (BIT_DEPTH - 8));
  66.  
  67.     for (y = 0; y < height; y++) {
  68.         for (x = 0; x < width; x++) {
  69.             dst[x] = av_clip_pixel(((src[x] * wx + offset) >> shift) + ox);
  70.         }
  71.         dst += dststride;
  72.         src += srcstride;
  73.     }
  74. }
  75.  
  76. static void FUNC(weighted_pred_avg)(uint8_t denom,
  77.                                     int16_t wl0Flag, int16_t wl1Flag,
  78.                                     int16_t ol0Flag, int16_t ol1Flag,
  79.                                     uint8_t *_dst, ptrdiff_t _dststride,
  80.                                     int16_t *src1, int16_t *src2,
  81.                                     ptrdiff_t srcstride,
  82.                                     int width, int height)
  83. {
  84.     int shift, log2Wd, w0, w1, o0, o1, x, y;
  85.     pixel *dst = (pixel *)_dst;
  86.     ptrdiff_t dststride = _dststride / sizeof(pixel);
  87.  
  88.     shift  = 14 - BIT_DEPTH;
  89.     log2Wd = denom + shift;
  90.     w0     = wl0Flag;
  91.     w1     = wl1Flag;
  92.     o0     = ol0Flag * (1 << (BIT_DEPTH - 8));
  93.     o1     = ol1Flag * (1 << (BIT_DEPTH - 8));
  94.  
  95.     for (y = 0; y < height; y++) {
  96.         for (x = 0; x < width; x++)
  97.             dst[x] = av_clip_pixel((src1[x] * w0 + src2[x] * w1 +
  98.                                     ((o0 + o1 + 1) << log2Wd)) >> (log2Wd + 1));
  99.         dst  += dststride;
  100.         src1 += srcstride;
  101.         src2 += srcstride;
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement