Signed-off-by: Aneesh Dogra <lionane...@gmail.com> --- libavcodec/v210enc.c | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c index 5861352..043a2d7 100644 --- a/libavcodec/v210enc.c +++ b/libavcodec/v210enc.c @@ -58,14 +58,14 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, 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 < aligned_width * avctx->height * 8 / 3) { av_log(avctx, AV_LOG_ERROR, "output buffer too small\n"); return -1; } + bytestream2_init_writer(&p, buf, buf_size); #define CLIP(v) av_clip(v, 4, 1019) #define WRITE_PIXELS(a, b, c) \ @@ -73,11 +73,13 @@ 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_le32(&p, val); \ } while (0) for (h = 0; h < avctx->height; h++) { uint32_t val; + int line_start_pos = bytestream2_tell_p(&p); + for (w = 0; w < avctx->width - 5; w += 6) { WRITE_PIXELS(u, y, v); WRITE_PIXELS(y, u, y); @@ -89,25 +91,25 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, val = CLIP(*y++); if (w == avctx->width - 2) - bytestream_put_le32(&p, val); + bytestream2_put_le32(&p, val); } if (w < avctx->width - 3) { val |= (CLIP(*u++) << 10) | (CLIP(*y++) << 20); - bytestream_put_le32(&p, val); + bytestream2_put_le32(&p, val); val = CLIP(*v++) | (CLIP(*y++) << 10); - bytestream_put_le32(&p, val); + bytestream2_put_le32(&p, val); } - pdst += stride; - memset(p, 0, pdst - p); - p = pdst; + bytestream2_set_buffer(&p, 0, line_start_pos + stride - bytestream2_tell_p(&p)); + bytestream2_seek_p(&p, stride, SEEK_CUR); + 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) -- 1.7.1 _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel