FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/dv_tablegen.h
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 24 24 100.0%
Functions: 1 1 100.0%
Branches: 12 12 100.0%

Line Branch Exec Source
1 /*
2 * Header file for hardcoded DV tables
3 *
4 * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #ifndef AVCODEC_DV_TABLEGEN_H
24 #define AVCODEC_DV_TABLEGEN_H
25
26 #include <stdint.h>
27 #include "libavutil/attributes.h"
28
29 #include "dvdata.h"
30
31 #if CONFIG_SMALL
32 #define DV_VLC_MAP_RUN_SIZE 15
33 #define DV_VLC_MAP_LEV_SIZE 23
34 #else
35 #define DV_VLC_MAP_RUN_SIZE 64
36 #define DV_VLC_MAP_LEV_SIZE 512 // FIXME sign was removed so this should be /2 but needs check
37 #endif
38
39 /* VLC encoding lookup table */
40 typedef struct dv_vlc_pair {
41 uint32_t vlc;
42 uint32_t size;
43 } dv_vlc_pair;
44
45 #if CONFIG_HARDCODED_TABLES
46 #define dv_vlc_map_tableinit()
47 #include "libavcodec/dv_tables.h"
48 #else
49 static struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE];
50
51 23 static av_cold void dv_vlc_map_tableinit(void)
52 {
53 23 uint32_t code = 0;
54 int i, j;
55
2/2
✓ Branch 0 taken 9407 times.
✓ Branch 1 taken 23 times.
9430 for (int i = 0; i < NB_DV_VLC; i++) {
56 9407 uint32_t cur_code = code >> (32 - ff_dv_vlc_len[i]);
57 9407 code += 1U << (32 - ff_dv_vlc_len[i]);
58
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 9384 times.
9407 if (ff_dv_vlc_run[i] >= DV_VLC_MAP_RUN_SIZE)
59 23 continue;
60 #if CONFIG_SMALL
61 if (ff_dv_vlc_level[i] >= DV_VLC_MAP_LEV_SIZE)
62 continue;
63 #endif
64
65
2/2
✓ Branch 0 taken 667 times.
✓ Branch 1 taken 8717 times.
9384 if (dv_vlc_map[ff_dv_vlc_run[i]][ff_dv_vlc_level[i]].size != 0)
66 667 continue;
67
68 8717 dv_vlc_map[ff_dv_vlc_run[i]][ff_dv_vlc_level[i]].vlc =
69 8717 cur_code << (!!ff_dv_vlc_level[i]);
70 8717 dv_vlc_map[ff_dv_vlc_run[i]][ff_dv_vlc_level[i]].size =
71 8717 ff_dv_vlc_len[i] + (!!ff_dv_vlc_level[i]);
72 }
73
2/2
✓ Branch 0 taken 1472 times.
✓ Branch 1 taken 23 times.
1495 for (i = 0; i < DV_VLC_MAP_RUN_SIZE; i++) {
74 #if CONFIG_SMALL
75 for (j = 1; j < DV_VLC_MAP_LEV_SIZE; j++) {
76 if (dv_vlc_map[i][j].size == 0) {
77 dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc |
78 (dv_vlc_map[i - 1][0].vlc <<
79 dv_vlc_map[0][j].size);
80 dv_vlc_map[i][j].size = dv_vlc_map[i - 1][0].size +
81 dv_vlc_map[0][j].size;
82 }
83 }
84 #else
85
2/2
✓ Branch 0 taken 375360 times.
✓ Branch 1 taken 1472 times.
376832 for (j = 1; j < DV_VLC_MAP_LEV_SIZE / 2; j++) {
86
2/2
✓ Branch 0 taken 368115 times.
✓ Branch 1 taken 7245 times.
375360 if (dv_vlc_map[i][j].size == 0) {
87 368115 dv_vlc_map[i][j].vlc = dv_vlc_map[0][j].vlc |
88 368115 (dv_vlc_map[i - 1][0].vlc <<
89 368115 dv_vlc_map[0][j].size);
90 368115 dv_vlc_map[i][j].size = dv_vlc_map[i - 1][0].size +
91 368115 dv_vlc_map[0][j].size;
92 }
93 375360 dv_vlc_map[i][((uint16_t) (-j)) & 0x1ff].vlc = dv_vlc_map[i][j].vlc | 1;
94 375360 dv_vlc_map[i][((uint16_t) (-j)) & 0x1ff].size = dv_vlc_map[i][j].size;
95 }
96 #endif
97 }
98 23 }
99 #endif /* CONFIG_HARDCODED_TABLES */
100
101 #endif /* AVCODEC_DV_TABLEGEN_H */
102