@@ -246,7 +246,7 @@ static int decompress_chunks_thread(AVCodecContext *avctx, void *arg,
}
static int decompress_texture_thread_internal(AVCodecContext *avctx, void *arg,
- int slice, int thread_nb, int texture_num)
+ int jobnr, int thread_nb, int texture_num)
{
HapContext *ctx = avctx->priv_data;
AVFrame *frame = arg;
@@ -254,21 +254,8 @@ static int decompress_texture_thread_internal(AVCodecContext *avctx, void *arg,
int w_block = avctx->coded_width / TEXTURE_BLOCK_W;
int h_block = avctx->coded_height / TEXTURE_BLOCK_H;
int x, y;
- int start_slice, end_slice;
- int base_blocks_per_slice = h_block / ctx->slice_count;
- int remainder_blocks = h_block % ctx->slice_count;
-
- /* When the frame height (in blocks) doesn't divide evenly between the
- * number of slices, spread the remaining blocks evenly between the first
- * operations */
- start_slice = slice * base_blocks_per_slice;
- /* Add any extra blocks (one per slice) that have been added before this slice */
- start_slice += FFMIN(slice, remainder_blocks);
-
- end_slice = start_slice + base_blocks_per_slice;
- /* Add an extra block if there are still remainder blocks to be accounted for */
- if (slice < remainder_blocks)
- end_slice++;
+ int start_slice = (h_block * jobnr) / ctx->slice_count;
+ int end_slice = (h_block * (jobnr+1)) / ctx->slice_count;
for (y = start_slice; y < end_slice; y++) {
uint8_t *p = frame->data[0] + y * frame->linesize[0] * TEXTURE_BLOCK_H;