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

Submitted by lance.lmwang@gmail.com on Oct. 21, 2019, 12:48 a.m.

Details

Message ID 20191021004814.13935-1-lance.lmwang@gmail.com
State New
Headers show

Commit Message

lance.lmwang@gmail.com Oct. 21, 2019, 12:48 a.m.
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/dds.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

Comments

lance.lmwang@gmail.com Oct. 29, 2019, 2:49 p.m.
ping

On Mon, Oct 21, 2019 at 08:48:13AM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@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
>
Michael Niedermayer Oct. 30, 2019, 3:07 p.m.
On Tue, Oct 29, 2019 at 10:49:49PM +0800, Limin Wang wrote:
> 
> ping

probably ok if tested with a range of vertical sizes and threads

thx

[...]
lance.lmwang@gmail.com Oct. 31, 2019, 1:23 a.m.
On Wed, Oct 30, 2019 at 04:07:22PM +0100, Michael Niedermayer wrote:
> On Tue, Oct 29, 2019 at 10:49:49PM +0800, Limin Wang wrote:
> > 
> > ping
> 
> probably ok if tested with a range of vertical sizes and threads

I have tested with fate with below command from thread 1 to 16:
make fate-dds  SAMPLES=../fate-suite thread_type=frame+slice threads=[1,16]

The next patch for hapdec:
make fate-hap  SAMPLES=../fate-suite thread_type=frame+slice threads=[1,16]


> 
> thx
> 
> [...]
> 
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Many things microsoft did are stupid, but not doing something just because
> microsoft did it is even more stupid. If everything ms did were stupid they
> would be bankrupt already.



> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

Patch hide | download patch | download mbox

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;