aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/v210enc.c
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2011-05-08 17:58:20 +0200
committerAnton Khirnov <anton@khirnov.net>2011-09-07 12:50:11 +0200
commit635bbecfc300ae49461b8987e2ebbf200ec8d6b6 (patch)
tree3bff55287619fe3a030d145bf91c63c54d7867b3 /libavcodec/v210enc.c
parentd239b83e2e5addea31c5e3277131406c6bfc3283 (diff)
downloadffmpeg-635bbecfc300ae49461b8987e2ebbf200ec8d6b6.tar.gz
v210enc: clip values according to specifications
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavcodec/v210enc.c')
-rw-r--r--libavcodec/v210enc.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index 808ab7d949..58613520a5 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);
}