[FFmpeg-devel] [PATCH v1 2/2] avcodec/hapdec: simplify the calculation of slice start and end
lance.lmwang at gmail.com
lance.lmwang at gmail.com
Mon Oct 21 03:48:14 EEST 2019
From: Limin Wang <lance.lmwang at gmail.com>
Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
libavcodec/hapdec.c | 19 +++----------------
1 file changed, 3 insertions(+), 16 deletions(-)
diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c
index 8c845770cf..dd325bb51a 100644
--- a/libavcodec/hapdec.c
+++ b/libavcodec/hapdec.c
@@ -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;
--
2.21.0
More information about the ffmpeg-devel
mailing list