summaryrefslogtreecommitdiff
path: root/libavcodec/ffv1enc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2017-06-27 13:09:58 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2017-06-27 13:09:58 +0200
commit0f8d3d8a462c0152ac489dbb013f6df027edd6c4 (patch)
tree35d28ba3ab562bcd141494498b7e8ca10ca8f4be /libavcodec/ffv1enc.c
parenta29c7127297af7f72384cb2a96571853d16e6f82 (diff)
avcodec/ffv1enc: compute the max number of slices and limit by that
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/ffv1enc.c')
-rw-r--r--libavcodec/ffv1enc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 39b52d5a48..c9a885ebfa 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -849,16 +849,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (s->version > 1) {
int plane_count = 1 + 2*s->chroma_planes + s->transparency;
+ int max_h_slices = AV_CEIL_RSHIFT(avctx->width , s->chroma_h_shift);
+ int max_v_slices = AV_CEIL_RSHIFT(avctx->height, s->chroma_v_shift);
s->num_v_slices = (avctx->width > 352 || avctx->height > 288 || !avctx->slices) ? 2 : 1;
- if (avctx->height < 5)
- s->num_v_slices = 1;
+ s->num_v_slices = FFMIN(s->num_v_slices, max_v_slices);
for (; s->num_v_slices < 32; s->num_v_slices++) {
for (s->num_h_slices = s->num_v_slices; s->num_h_slices < 2*s->num_v_slices; s->num_h_slices++) {
int maxw = (avctx->width + s->num_h_slices - 1) / s->num_h_slices;
int maxh = (avctx->height + s->num_v_slices - 1) / s->num_v_slices;
- if (s->num_h_slices > avctx->width || s->num_v_slices > avctx->height)
+ if (s->num_h_slices > max_h_slices || s->num_v_slices > max_v_slices)
continue;
if (maxw * maxh * (int64_t)(s->bits_per_raw_sample+1) * plane_count > 8<<24)
continue;