[FFmpeg-devel] [PATCH 4/4] proresenc_kostya: properly account for alpha
Christophe Gisquet
christophe.gisquet at gmail.com
Tue Aug 12 00:06:10 CEST 2014
The packet buffer allocation considered as dct-coded, while it is
actually run-coded and thus requires a larger buffer.
---
libavcodec/proresenc_kostya.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 2cd33ce..443ea76 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -1232,16 +1232,23 @@ static av_cold int encode_init(AVCodecContext *avctx)
ctx->bits_per_mb = ls * 8;
if (ctx->chroma_factor == CFACTOR_Y444)
ctx->bits_per_mb += ls * 4;
- if (ctx->num_planes == 4)
- ctx->bits_per_mb += ls * 4;
}
ctx->frame_size_upper_bound = ctx->pictures_per_frame *
ctx->slices_per_picture *
- (2 + 2 * ctx->num_planes +
+ (2 + 2 * FFMIN(3, ctx->num_planes) +
(mps * ctx->bits_per_mb) / 8)
+ 200;
+ if (ctx->alpha_bits) {
+ // alpha plane is run-coded and might run over bit budget
+ ctx->frame_size_upper_bound += (ctx->pictures_per_frame *
+ ctx->slices_per_picture *
+ ctx->mbs_per_slice *
+ 256 * (1 + ctx->alpha_bits+1)
+ + 7) >> 3;
+ }
+
avctx->codec_tag = ctx->profile_info->tag;
av_log(avctx, AV_LOG_DEBUG,
--
1.9.2.msysgit.0
More information about the ffmpeg-devel
mailing list