| @@ -924,7 +924,7 @@ static void dnxhd_setup_threads_slices(DNXHDEncContext *ctx) · 923 unmodified lines |
| 924 | 924 | unsigned mb = mb_y * ctx->m.mb_width + mb_x; |
| 925 | 925 | ctx->slice_size[mb_y] += ctx->mb_bits[mb]; |
| 926 | 926 | } |
| 927 | | − ctx->slice_size[mb_y] = (ctx->slice_size[mb_y] + 31) & ~31; |
| 927 | + ctx->slice_size[mb_y] = (ctx->slice_size[mb_y] + 31U) & ~31U; |
| 928 | 928 | ctx->slice_size[mb_y] >>= 3; |
| 929 | 929 | thread_size = ctx->slice_size[mb_y]; |
| 930 | 930 | offset += thread_size; |
| @@ -1220,17 +1220,19 @@ static int dnxhd_encode_fast(AVCodecContext *avctx, DNXHDEncContext *ctx) · 289 unmodified lines |
| 1220 | 1220 | avctx->execute2(avctx, dnxhd_mb_var_thread, |
| 1221 | 1221 | NULL, NULL, ctx->m.mb_height); |
| 1222 | 1222 | radix_sort(ctx->mb_cmp, ctx->mb_cmp_tmp, ctx->m.mb_num); |
| 1223 | +retry: |
| 1223 | 1224 | for (x = 0; x < ctx->m.mb_num && max_bits > ctx->frame_bits; x++) { |
| 1224 | 1225 | int mb = ctx->mb_cmp[x].mb; |
| 1225 | 1226 | int rc = (ctx->qscale * ctx->m.mb_num ) + mb; |
| 1226 | 1227 | max_bits -= ctx->mb_rc[rc].bits - |
| 1227 | 1228 | ctx->mb_rc[rc + ctx->m.mb_num].bits; |
| 1228 | | − ctx->mb_qscale[mb] = ctx->qscale + 1; |
| 1229 | + if (ctx->mb_qscale[mb] < 255) |
| 1230 | + ctx->mb_qscale[mb]++; |
| 1229 | 1231 | ctx->mb_bits[mb] = ctx->mb_rc[rc + ctx->m.mb_num].bits; |
| 1230 | 1232 | } |
| 1231 | 1233 | |
| 1232 | 1234 | if (max_bits > ctx->frame_bits) |
| 1233 | | − return AVERROR(EINVAL); |
| 1235 | + goto retry; |
| 1234 | 1236 | } |
| 1235 | 1237 | return 0; |
| 1236 | 1238 | } |