[FFmpeg-cvslog] v210enc:clip values according to specifications

Baptiste Coudurier git at videolan.org
Sun May 8 19:51:05 CEST 2011


ffmpeg | branch: master | Baptiste Coudurier <baptiste.coudurier at gmail.com> | Sun May  8 17:58:20 2011 +0200| [74bf9d62311a96a67f01269779d92386a15ce592] | committer: Michael Niedermayer

v210enc:clip values according to specifications
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavcodec/v210enc.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index 77a97cf..d1b3d9f 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -66,11 +66,13 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
         return -1;
     }
 
+#define CLIP(v) av_clip(v, 4, 1019)
+
 #define WRITE_PIXELS(a, b, c)           \
     do {                                \
-        val =   *a++;             \
-        val |= (*b++ << 10) |     \
-               (*c++ << 20);      \
+        val =   CLIP(*a++);             \
+        val |= (CLIP(*b++) << 10) |     \
+               (CLIP(*c++) << 20);      \
         bytestream_put_le32(&p, val);   \
     } while (0)
 
@@ -85,15 +87,15 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
         if (w < avctx->width - 1) {
             WRITE_PIXELS(u, y, v);
 
-            val =   *y++;
+            val = CLIP(*y++);
             if (w == avctx->width - 2)
                 bytestream_put_le32(&p, val);
         }
         if (w < avctx->width - 3) {
-            val |= (*u++ << 10) | (*y++ << 20);
+            val |= (CLIP(*u++) << 10) | (CLIP(*y++) << 20);
             bytestream_put_le32(&p, val);
 
-            val = *v++ | (*y++ << 10);
+            val = CLIP(*v++) | (CLIP(*y++) << 10);
             bytestream_put_le32(&p, val);
         }
 



More information about the ffmpeg-cvslog mailing list