[FFmpeg-cvslog] avcodec/diracdsp: use av_clip_uintp2

James Almer git at videolan.org
Thu Jan 21 17:19:32 CET 2016


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Thu Jan 21 13:13:54 2016 -0300| [033e7dbd31c5956f4c18d099cac7a5869b7c29e8] | committer: James Almer

avcodec/diracdsp: use av_clip_uintp2

Reviewed-by: Rostislav Pehlivanov <atomnuker at gmail.com>
Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=033e7dbd31c5956f4c18d099cac7a5869b7c29e8
---

 libavcodec/diracdsp.c |   50 +++++++++++++++++++------------------------------
 1 file changed, 19 insertions(+), 31 deletions(-)

diff --git a/libavcodec/diracdsp.c b/libavcodec/diracdsp.c
index 6c75f9a..12f27ce 100644
--- a/libavcodec/diracdsp.c
+++ b/libavcodec/diracdsp.c
@@ -151,39 +151,27 @@ static void put_signed_rect_clamped_8bit_c(uint8_t *dst, int dst_stride, const u
     }
 }
 
-static void put_signed_rect_clamped_10bit_c(uint8_t *_dst, int dst_stride, const uint8_t *_src, int src_stride, int width, int height)
-{
-    int x, y;
-    uint16_t *dst = (uint16_t *)_dst;
-    int32_t *src = (int32_t *)_src;
-    for (y = 0; y < height; y++) {
-        for (x = 0; x < width; x+=4) {
-            dst[x  ] = av_clip(src[x  ] + 512, 0, (1 << 10) - 1);
-            dst[x+1] = av_clip(src[x+1] + 512, 0, (1 << 10) - 1);
-            dst[x+2] = av_clip(src[x+2] + 512, 0, (1 << 10) - 1);
-            dst[x+3] = av_clip(src[x+3] + 512, 0, (1 << 10) - 1);
-        }
-        dst += dst_stride >> 1;
-        src += src_stride >> 2;
-    }
+#define PUT_SIGNED_RECT_CLAMPED(PX)                                                                     \
+static void put_signed_rect_clamped_ ## PX ## bit_c(uint8_t *_dst, int dst_stride, const uint8_t *_src, \
+                                                  int src_stride, int width, int height)                \
+{                                                                                                       \
+    int x, y;                                                                                           \
+    uint16_t *dst = (uint16_t *)_dst;                                                                   \
+    int32_t *src = (int32_t *)_src;                                                                     \
+    for (y = 0; y < height; y++) {                                                                      \
+        for (x = 0; x < width; x+=4) {                                                                  \
+            dst[x  ] = av_clip_uintp2(src[x  ] + (1 << (PX - 1)), PX);                                  \
+            dst[x+1] = av_clip_uintp2(src[x+1] + (1 << (PX - 1)), PX);                                  \
+            dst[x+2] = av_clip_uintp2(src[x+2] + (1 << (PX - 1)), PX);                                  \
+            dst[x+3] = av_clip_uintp2(src[x+3] + (1 << (PX - 1)), PX);                                  \
+        }                                                                                               \
+        dst += dst_stride >> 1;                                                                         \
+        src += src_stride >> 2;                                                                         \
+    }                                                                                                   \
 }
 
-static void put_signed_rect_clamped_12bit_c(uint8_t *_dst, int dst_stride, const uint8_t *_src, int src_stride, int width, int height)
-{
-    int x, y;
-    uint16_t *dst = (uint16_t *)_dst;
-    int32_t *src = (int32_t *)_src;
-    for (y = 0; y < height; y++) {
-        for (x = 0; x < width; x+=4) {
-            dst[x  ] = av_clip(src[x  ] + 2048, 0, (1 << 12) - 1);
-            dst[x+1] = av_clip(src[x+1] + 2048, 0, (1 << 12) - 1);
-            dst[x+2] = av_clip(src[x+2] + 2048, 0, (1 << 12) - 1);
-            dst[x+3] = av_clip(src[x+3] + 2048, 0, (1 << 12) - 1);
-        }
-        dst += dst_stride >> 1;
-        src += src_stride >> 2;
-    }
-}
+PUT_SIGNED_RECT_CLAMPED(10)
+PUT_SIGNED_RECT_CLAMPED(12)
 
 static void add_rect_clamped_c(uint8_t *dst, const uint16_t *src, int stride,
                                const int16_t *idwt, int idwt_stride,



More information about the ffmpeg-cvslog mailing list