FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/texturedsp_template.c
Date: 2023-12-04 05:51:44
Exec Total Coverage
Lines: 17 18 94.4%
Functions: 2 2 100.0%
Branches: 5 6 83.3%

Line Branch Exec 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 78 int TEXTUREDSP_FUNC_NAME(AVCodecContext *avctx, void *arg,
24 int slice, int thread_nb)
25 {
26 78 TextureDSPThreadContext *ctx = arg;
27 78 uint8_t *d = ctx->tex_data.out;
28 78 int w_block = avctx->coded_width / TEXTURE_BLOCK_W;
29 78 int h_block = avctx->coded_height / TEXTURE_BLOCK_H;
30 int x, y;
31 int start_slice, end_slice;
32 78 int base_blocks_per_slice = h_block / ctx->slice_count;
33 78 int remainder_blocks = h_block % ctx->slice_count;
34
35 /* When the frame height (in blocks) doesn't divide evenly between the
36 * number of slices, spread the remaining blocks evenly between the first
37 * operations */
38 78 start_slice = slice * base_blocks_per_slice;
39 /* Add any extra blocks (one per slice) that have been added before this slice */
40 78 start_slice += FFMIN(slice, remainder_blocks);
41
42 78 end_slice = start_slice + base_blocks_per_slice;
43 /* Add an extra block if there are still remainder blocks to be accounted for */
44
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
78 if (slice < remainder_blocks)
45 end_slice++;
46
47
2/2
✓ Branch 0 taken 1672 times.
✓ Branch 1 taken 78 times.
1750 for (y = start_slice; y < end_slice; y++) {
48 1672 uint8_t *p = ctx->frame_data.out + y * ctx->stride * TEXTURE_BLOCK_H;
49 1672 int off = y * w_block;
50
2/2
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 1672 times.
86152 for (x = 0; x < w_block; x++) {
51 84480 ctx->TEXTUREDSP_TEX_FUNC(p + x * ctx->raw_ratio, ctx->stride,
52 d + (off + x) * ctx->tex_ratio);
53 }
54 }
55
56 78 return 0;
57 }
58