[FFmpeg-devel] [PATCH 2/2] avcodec/dds: fix for missing pixels at the bottom of frames

Michael Niedermayer michael at niedermayer.cc
Wed Jul 22 23:20:46 CEST 2015


On Wed, Jul 22, 2015 at 09:46:25PM +0100, Tom Butterworth wrote:
> A bug was introduced in 6b2b26e7af3ede0abfb46eb5725c26d1083f50bc whereby when
> frame height wasn't divisible by the number of threads, pixels would be omitted
> from the bottom rows during decode.
> ---
>  libavcodec/dds.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/dds.c b/libavcodec/dds.c
> index a01ed7d..7e1d60a 100644
> --- a/libavcodec/dds.c
> +++ b/libavcodec/dds.c
> @@ -106,6 +106,7 @@ typedef struct DDSContext {
>      const uint8_t *tex_data; // Compressed texture
>      int tex_ratio;           // Compression ratio
>      int slice_size;          // Optimal slice size
> +    int slice_count;         // Number of slices for threaded operations
>  
>      /* Pointer to the selected compress or decompress function. */
>      int (*tex_funct)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
> @@ -425,7 +426,12 @@ static int decompress_texture_thread(AVCodecContext *avctx, void *arg,
>      int start_slice, end_slice;
>  
>      start_slice = slice * ctx->slice_size;
> -    end_slice   = FFMIN(start_slice + ctx->slice_size, avctx->coded_height);
> +    /* If the frame height isn't divisible by the number of slices then the
> +     * last slice must cover more rows than ctx->slice_size */
> +    if (slice == ctx->slice_count - 1)
> +        end_slice = avctx->coded_height;
> +    else
> +        end_slice = FFMIN(start_slice + ctx->slice_size, avctx->coded_height);
>  
>      start_slice /= TEXTURE_BLOCK_H;
>      end_slice   /= TEXTURE_BLOCK_H;
> @@ -633,13 +639,13 @@ static int dds_decode(AVCodecContext *avctx, void *data,
>          return ret;
>  
>      if (ctx->compressed) {
> -        int slices = FFMIN(avctx->thread_count,
> -                           avctx->coded_height / TEXTURE_BLOCK_H);
> -        ctx->slice_size = avctx->coded_height / slices;
> +        ctx->slice_count = av_clip(avctx->thread_count, 1,
> +                                   avctx->coded_height / TEXTURE_BLOCK_H);
> +        ctx->slice_size = avctx->coded_height / ctx->slice_count;

as with the hap patch, doesnt this result in possibly significantly
larger last slice (which could cause the thread executing that to
take much longer then the other threads thus slowing things down
compared to slices with more similar sizes ?


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150722/8825190b/attachment.sig>


More information about the ffmpeg-devel mailing list