[FFmpeg-devel] [PATCH v1 1/2] avcodec/dds: simplify the calculation of slice start and end

Limin Wang lance.lmwang at gmail.com
Tue Oct 29 16:49:49 EET 2019


ping

On Mon, Oct 21, 2019 at 08:48:13AM +0800, lance.lmwang at gmail.com wrote:
> From: Limin Wang <lance.lmwang at gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> ---
>  libavcodec/dds.c | 19 +++----------------
>  1 file changed, 3 insertions(+), 16 deletions(-)
> 
> diff --git a/libavcodec/dds.c b/libavcodec/dds.c
> index 9154f692fa..7c0ad9ee72 100644
> --- a/libavcodec/dds.c
> +++ b/libavcodec/dds.c
> @@ -434,7 +434,7 @@ static int parse_pixel_format(AVCodecContext *avctx)
>  }
>  
>  static int decompress_texture_thread(AVCodecContext *avctx, void *arg,
> -                                     int slice, int thread_nb)
> +                                     int jobnr, int thread_nb)
>  {
>      DDSContext *ctx = avctx->priv_data;
>      AVFrame *frame = arg;
> @@ -442,21 +442,8 @@ static int decompress_texture_thread(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