FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/texturedsp_template.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 19 20 95.0%
Functions: 3 3 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 #include "avcodec.h"
24
25 101 static int exec_func(AVCodecContext *avctx, void *arg,
26 int slice, int thread_nb)
27 {
28 101 const TextureDSPThreadContext *ctx = arg;
29 101 uint8_t *d = ctx->tex_data.out;
30 101 int w_block = ctx->width / TEXTURE_BLOCK_W;
31 101 int h_block = ctx->height / TEXTURE_BLOCK_H;
32 int x, y;
33 int start_slice, end_slice;
34 101 int base_blocks_per_slice = h_block / ctx->slice_count;
35 101 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 101 start_slice = slice * base_blocks_per_slice;
41 /* Add any extra blocks (one per slice) that have been added before this slice */
42 101 start_slice += FFMIN(slice, remainder_blocks);
43
44 101 end_slice = start_slice + base_blocks_per_slice;
45 /* Add an extra block if there are still remainder blocks to be accounted for */
46
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if (slice < remainder_blocks)
47 end_slice++;
48
49
2/2
✓ Branch 0 taken 4742 times.
✓ Branch 1 taken 101 times.
4843 for (y = start_slice; y < end_slice; y++) {
50 4742 uint8_t *p = ctx->frame_data.out + y * ctx->stride * TEXTURE_BLOCK_H;
51 4742 int off = y * w_block;
52
2/2
✓ Branch 0 taken 1283648 times.
✓ Branch 1 taken 4742 times.
1288390 for (x = 0; x < w_block; x++) {
53 1283648 ctx->TEXTUREDSP_TEX_FUNC(p + x * ctx->raw_ratio, ctx->stride,
54 d + (off + x) * ctx->tex_ratio);
55 }
56 }
57
58 101 return 0;
59 }
60
61 101 int TEXTUREDSP_FUNC_NAME(AVCodecContext *avctx, TextureDSPThreadContext *ctx)
62 {
63 101 return avctx->execute2(avctx, exec_func, ctx, NULL, ctx->slice_count);
64 }
65