Coverage Report

Created: 2026-10-28 08:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ffmpeg/libavcodec/texturedsp_template.c
Line
Count
Source
1
/*
2
 * Texture block compression and decompression
3
 * Copyright (C) 2015 Vittorio Giovara <vittorio.giovara@gmail.com>
4
 *
5
 * This file is part of FFmpeg.
6
 *
7
 * FFmpeg is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * FFmpeg is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with FFmpeg; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 *
21
 */
22
23
#include "avcodec.h"
24
25
static int exec_func(AVCodecContext *avctx, void *arg,
26
                     int slice, int thread_nb)
27
191k
{
28
191k
    const TextureDSPThreadContext *ctx = arg;
29
191k
    uint8_t *d = ctx->tex_data.out;
30
191k
    int w_block = ctx->width  / TEXTURE_BLOCK_W;
31
191k
    int h_block = ctx->height / TEXTURE_BLOCK_H;
32
191k
    int x, y;
33
191k
    int start_slice, end_slice;
34
191k
    int base_blocks_per_slice = h_block / ctx->slice_count;
35
191k
    int remainder_blocks = h_block % ctx->slice_count;
36
37
    /* When the frame height (in blocks) doesn't divide evenly between the
38
     * number of slices, spread the remaining blocks evenly between the first
39
     * operations */
40
191k
    start_slice = slice * base_blocks_per_slice;
41
    /* Add any extra blocks (one per slice) that have been added before this slice */
42
191k
    start_slice += FFMIN(slice, remainder_blocks);
43
44
191k
    end_slice = start_slice + base_blocks_per_slice;
45
    /* Add an extra block if there are still remainder blocks to be accounted for */
46
191k
    if (slice < remainder_blocks)
47
0
        end_slice++;
48
49
97.6M
    for (y = start_slice; y < end_slice; y++) {
50
97.4M
        uint8_t *p = ctx->frame_data.out + y * ctx->stride * TEXTURE_BLOCK_H;
51
97.4M
        int off = y * w_block;
52
1.45G
        for (x = 0; x < w_block; x++) {
53
1.35G
            ctx->TEXTUREDSP_TEX_FUNC(p + x * ctx->raw_ratio, ctx->stride,
54
1.35G
                                     d + (off + x) * ctx->tex_ratio);
55
1.35G
        }
56
97.4M
    }
57
58
191k
    return 0;
59
191k
}
texturedspenc.c:exec_func
Line
Count
Source
27
15.5k
{
28
15.5k
    const TextureDSPThreadContext *ctx = arg;
29
15.5k
    uint8_t *d = ctx->tex_data.out;
30
15.5k
    int w_block = ctx->width  / TEXTURE_BLOCK_W;
31
15.5k
    int h_block = ctx->height / TEXTURE_BLOCK_H;
32
15.5k
    int x, y;
33
15.5k
    int start_slice, end_slice;
34
15.5k
    int base_blocks_per_slice = h_block / ctx->slice_count;
35
15.5k
    int remainder_blocks = h_block % ctx->slice_count;
36
37
    /* When the frame height (in blocks) doesn't divide evenly between the
38
     * number of slices, spread the remaining blocks evenly between the first
39
     * operations */
40
15.5k
    start_slice = slice * base_blocks_per_slice;
41
    /* Add any extra blocks (one per slice) that have been added before this slice */
42
15.5k
    start_slice += FFMIN(slice, remainder_blocks);
43
44
15.5k
    end_slice = start_slice + base_blocks_per_slice;
45
    /* Add an extra block if there are still remainder blocks to be accounted for */
46
15.5k
    if (slice < remainder_blocks)
47
0
        end_slice++;
48
49
645k
    for (y = start_slice; y < end_slice; y++) {
50
630k
        uint8_t *p = ctx->frame_data.out + y * ctx->stride * TEXTURE_BLOCK_H;
51
630k
        int off = y * w_block;
52
13.4M
        for (x = 0; x < w_block; x++) {
53
12.8M
            ctx->TEXTUREDSP_TEX_FUNC(p + x * ctx->raw_ratio, ctx->stride,
54
12.8M
                                     d + (off + x) * ctx->tex_ratio);
55
12.8M
        }
56
630k
    }
57
58
15.5k
    return 0;
59
15.5k
}
texturedsp.c:exec_func
Line
Count
Source
27
176k
{
28
176k
    const TextureDSPThreadContext *ctx = arg;
29
176k
    uint8_t *d = ctx->tex_data.out;
30
176k
    int w_block = ctx->width  / TEXTURE_BLOCK_W;
31
176k
    int h_block = ctx->height / TEXTURE_BLOCK_H;
32
176k
    int x, y;
33
176k
    int start_slice, end_slice;
34
176k
    int base_blocks_per_slice = h_block / ctx->slice_count;
35
176k
    int remainder_blocks = h_block % ctx->slice_count;
36
37
    /* When the frame height (in blocks) doesn't divide evenly between the
38
     * number of slices, spread the remaining blocks evenly between the first
39
     * operations */
40
176k
    start_slice = slice * base_blocks_per_slice;
41
    /* Add any extra blocks (one per slice) that have been added before this slice */
42
176k
    start_slice += FFMIN(slice, remainder_blocks);
43
44
176k
    end_slice = start_slice + base_blocks_per_slice;
45
    /* Add an extra block if there are still remainder blocks to be accounted for */
46
176k
    if (slice < remainder_blocks)
47
0
        end_slice++;
48
49
96.9M
    for (y = start_slice; y < end_slice; y++) {
50
96.8M
        uint8_t *p = ctx->frame_data.out + y * ctx->stride * TEXTURE_BLOCK_H;
51
96.8M
        int off = y * w_block;
52
1.43G
        for (x = 0; x < w_block; x++) {
53
1.34G
            ctx->TEXTUREDSP_TEX_FUNC(p + x * ctx->raw_ratio, ctx->stride,
54
1.34G
                                     d + (off + x) * ctx->tex_ratio);
55
1.34G
        }
56
96.8M
    }
57
58
176k
    return 0;
59
176k
}
60
61
int TEXTUREDSP_FUNC_NAME(AVCodecContext *avctx, TextureDSPThreadContext *ctx)
62
191k
{
63
    return avctx->execute2(avctx, exec_func, ctx, NULL, ctx->slice_count);
64
191k
}
ff_texturedsp_exec_compress_threads
Line
Count
Source
62
15.5k
{
63
    return avctx->execute2(avctx, exec_func, ctx, NULL, ctx->slice_count);
64
15.5k
}
ff_texturedsp_exec_decompress_threads
Line
Count
Source
62
176k
{
63
    return avctx->execute2(avctx, exec_func, ctx, NULL, ctx->slice_count);
64
176k
}