Browse Source

v210enc: clip values according to specifications

Signed-off-by: Anton Khirnov <anton@khirnov.net>
tags/n0.9
Baptiste Coudurier Anton Khirnov 14 years ago
parent
commit
635bbecfc3
1 changed files with 8 additions and 6 deletions
  1. +8
    -6
      libavcodec/v210enc.c

+ 8
- 6
libavcodec/v210enc.c View File

@@ -66,11 +66,13 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
return -1; return -1;
} }


#define CLIP(v) av_clip(v, 4, 1019)

#define WRITE_PIXELS(a, b, c) \ #define WRITE_PIXELS(a, b, c) \
do { \ do { \
val = *a++; \
val |= (*b++ << 10) | \
(*c++ << 20); \
val = CLIP(*a++); \
val |= (CLIP(*b++) << 10) | \
(CLIP(*c++) << 20); \
bytestream_put_le32(&p, val); \ bytestream_put_le32(&p, val); \
} while (0) } while (0)


@@ -85,15 +87,15 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
if (w < avctx->width - 1) { if (w < avctx->width - 1) {
WRITE_PIXELS(u, y, v); WRITE_PIXELS(u, y, v);


val = *y++;
val = CLIP(*y++);
if (w == avctx->width - 2) if (w == avctx->width - 2)
bytestream_put_le32(&p, val); bytestream_put_le32(&p, val);
} }
if (w < avctx->width - 3) { if (w < avctx->width - 3) {
val |= (*u++ << 10) | (*y++ << 20);
val |= (CLIP(*u++) << 10) | (CLIP(*y++) << 20);
bytestream_put_le32(&p, val); bytestream_put_le32(&p, val);


val = *v++ | (*y++ << 10);
val = CLIP(*v++) | (CLIP(*y++) << 10);
bytestream_put_le32(&p, val); bytestream_put_le32(&p, val);
} }




Loading…
Cancel
Save