summaryrefslogtreecommitdiff
path: root/libavcodec/v210enc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-02-11 01:22:22 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-02-11 01:22:22 +0100
commita78f6b8cb98611a846a68f4bbb77e78fd5c175bf (patch)
tree45d4339cefc60f61310bd23b8d7cf7d0bf1f88b6 /libavcodec/v210enc.c
parent394d41ee30b0c4a38a8d33b65e28facfef15d465 (diff)
parentf98ede7e610da644d3e5d553fc5d7102cf1ccde7 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: (38 commits) v210enc: remove redundant check for pix_fmt wavpack: allow user to disable CRC checking v210enc: Use Bytestream2 functions cafdec: Check return value of avio_seek and avoid modifying state if it fails yop: Check return value of avio_seek and avoid modifying state if it fails tta: Check return value of avio_seek and avoid modifying state if it fails tmv: Check return value of avio_seek and avoid modifying state if it fails r3d: Check return value of avio_seek and avoid modifying state if it fails nsvdec: Check return value of avio_seek and avoid modifying state if it fails mpc8: Check return value of avio_seek and avoid modifying state if it fails jvdec: Check return value of avio_seek and avoid modifying state if it fails filmstripdec: Check return value of avio_seek and avoid modifying state if it fails ffmdec: Check return value of avio_seek and avoid modifying state if it fails dv: Check return value of avio_seek and avoid modifying state if it fails bink: Check return value of avio_seek and avoid modifying state if it fails Check AVCodec.pix_fmts in avcodec_open2() svq3: Prevent illegal reads while parsing extradata. remove ParseContext1 vc1: use ff_parse_close mpegvideo parser: move specific fields into private context ... Conflicts: libavcodec/4xm.c libavcodec/aacdec.c libavcodec/h264.c libavcodec/h264.h libavcodec/h264_cabac.c libavcodec/h264_cavlc.c libavcodec/mpeg4video_parser.c libavcodec/svq3.c libavcodec/v210enc.c libavformat/cafdec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/v210enc.c')
-rw-r--r--libavcodec/v210enc.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index a2efb5e83f..2bf60d7bfc 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -31,11 +31,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
- if (avctx->pix_fmt != PIX_FMT_YUV422P10) {
- av_log(avctx, AV_LOG_ERROR, "v210 needs YUV422P10\n");
- return -1;
- }
-
if (avctx->bits_per_raw_sample != 10)
av_log(avctx, AV_LOG_WARNING, "bits per raw sample: %d != 10-bit\n",
avctx->bits_per_raw_sample);
@@ -55,18 +50,20 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
const AVFrame *pic = data;
int aligned_width = ((avctx->width + 47) / 48) * 48;
int stride = aligned_width * 8 / 3;
+ int line_padding = stride - ((avctx->width * 8 + 11) / 12) * 4;
int h, w;
const uint16_t *y = (const uint16_t*)pic->data[0];
const uint16_t *u = (const uint16_t*)pic->data[1];
const uint16_t *v = (const uint16_t*)pic->data[2];
- uint8_t *p = buf;
- uint8_t *pdst = buf;
+ PutByteContext p;
if (buf_size < avctx->height * stride) {
av_log(avctx, AV_LOG_ERROR, "output buffer too small\n");
return AVERROR(ENOMEM);
}
+ bytestream2_init_writer(&p, buf, buf_size);
+
#define CLIP(v) av_clip(v, 4, 1019)
#define WRITE_PIXELS(a, b, c) \
@@ -74,7 +71,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
val = CLIP(*a++); \
val |= (CLIP(*b++) << 10) | \
(CLIP(*c++) << 20); \
- bytestream_put_le32(&p, val); \
+ bytestream2_put_le32u(&p, val); \
} while (0)
for (h = 0; h < avctx->height; h++) {
@@ -90,25 +87,24 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
val = CLIP(*y++);
if (w == avctx->width - 2)
- bytestream_put_le32(&p, val);
+ bytestream2_put_le32u(&p, val);
if (w < avctx->width - 3) {
val |= (CLIP(*u++) << 10) | (CLIP(*y++) << 20);
- bytestream_put_le32(&p, val);
+ bytestream2_put_le32u(&p, val);
val = CLIP(*v++) | (CLIP(*y++) << 10);
- bytestream_put_le32(&p, val);
+ bytestream2_put_le32u(&p, val);
}
}
- pdst += stride;
- memset(p, 0, pdst - p);
- p = pdst;
+ bytestream2_set_buffer(&p, 0, line_padding);
+
y += pic->linesize[0] / 2 - avctx->width;
u += pic->linesize[1] / 2 - avctx->width / 2;
v += pic->linesize[2] / 2 - avctx->width / 2;
}
- return p - buf;
+ return bytestream2_tell_p(&p);
}
static av_cold int encode_close(AVCodecContext *avctx)