summaryrefslogtreecommitdiffstats
path: root/libavcodec/proresenc_anatoliy.c
diff options
context:
space:
mode:
authorMartin Vignali <martin.vignali@gmail.com>2019-02-09 18:16:50 +0100
committerMartin Vignali <martin.vignali@gmail.com>2019-02-23 13:21:21 +0100
commit2016f9c3bc23a65deb566a36d210328c90d6db33 (patch)
tree28e4afa35df6408651e3f7d2f6572ef9e7757d8f /libavcodec/proresenc_anatoliy.c
parent6cc8cfe30c09b1776b935988fcdedf0333602f8e (diff)
downloadffmpeg-streaming-2016f9c3bc23a65deb566a36d210328c90d6db33.zip
ffmpeg-streaming-2016f9c3bc23a65deb566a36d210328c90d6db33.tar.gz
avcodec/proresenc_aw : move picture encoding after frame header write
Diffstat (limited to 'libavcodec/proresenc_anatoliy.c')
-rw-r--r--libavcodec/proresenc_anatoliy.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index afd1fa6..061621d 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -683,7 +683,7 @@ static int prores_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
ProresContext *ctx = avctx->priv_data;
int header_size = 148;
uint8_t *buf;
- int pic_size, ret;
+ int compress_frame_size, pic_size, ret;
uint8_t frame_flags;
int frame_size = FFALIGN(avctx->width, 16) * FFALIGN(avctx->height, 16)*16 + 500 + AV_INPUT_BUFFER_MIN_SIZE; //FIXME choose tighter limit
@@ -692,13 +692,9 @@ static int prores_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return ret;
buf = pkt->data;
- pic_size = prores_encode_picture(avctx, pict, buf + header_size + 8,
- pkt->size - header_size - 8);
- if (pic_size < 0) {
- return pic_size;
- }
+ compress_frame_size = 8 + header_size;
- bytestream_put_be32(&buf, pic_size + 8 + header_size);
+ bytestream_put_be32(&buf, compress_frame_size);/* frame size will be update after picture(s) encoding */
bytestream_put_buffer(&buf, "icpf", 4);
bytestream_put_be16(&buf, header_size);
@@ -730,8 +726,16 @@ static int prores_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
bytestream_put_buffer(&buf, QMAT_LUMA[avctx->profile], 64);
bytestream_put_buffer(&buf, QMAT_CHROMA[avctx->profile], 64);
+ pic_size = prores_encode_picture(avctx, pict, buf,
+ pkt->size - compress_frame_size);
+ if (pic_size < 0) {
+ return pic_size;
+ }
+ compress_frame_size += pic_size;
+
+ AV_WB32(pkt->data, compress_frame_size);/* update frame size */
pkt->flags |= AV_PKT_FLAG_KEY;
- pkt->size = pic_size + 8 + header_size;
+ pkt->size = compress_frame_size;
*got_packet = 1;
return 0;
OpenPOWER on IntegriCloud