Coverage Report

Created: 2025-07-11 06:16

/src/vlc/modules/packetizer/h26x_nal_common.h
Line
Count
Source (jump to first uncovered line)
1
/*****************************************************************************
2
 * h26x_nal_common.h: h26x shared code
3
 *****************************************************************************
4
 * Copyright © 2010-2024 VideoLabs, VideoLAN and VLC Authors
5
 *
6
 * This program is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU Lesser General Public License as published by
8
 * the Free Software Foundation; either version 2.1 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License
17
 * along with this program; if not, write to the Free Software Foundation,
18
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19
 *****************************************************************************/
20
#ifndef H26X_NAL_COMMON_H
21
# define H26X_NAL_COMMON_H
22
23
#include <vlc_common.h>
24
#include "iso_color_tables.h"
25
26
typedef uint8_t  nal_u1_t;
27
typedef uint8_t  nal_u2_t;
28
typedef uint8_t  nal_u3_t;
29
typedef uint8_t  nal_u4_t;
30
typedef uint8_t  nal_u5_t;
31
typedef uint8_t  nal_u6_t;
32
typedef uint8_t  nal_u7_t;
33
typedef uint8_t  nal_u8_t;
34
typedef int32_t  nal_se_t;
35
typedef uint32_t nal_ue_t;
36
37
typedef struct
38
{
39
    nal_ue_t left_offset;
40
    nal_ue_t right_offset;
41
    nal_ue_t top_offset;
42
    nal_ue_t bottom_offset;
43
} h26x_conf_window_t;
44
45
static inline
46
bool h26x_get_picture_size( nal_u2_t chroma_format_idc,
47
                            nal_ue_t pic_width_in_luma_samples,
48
                            nal_ue_t pic_height_in_luma_samples,
49
                            const h26x_conf_window_t *conf_win,
50
                            unsigned *p_ox, unsigned *p_oy,
51
                            unsigned *p_w, unsigned *p_h,
52
                            unsigned *p_vw, unsigned *p_vh )
53
0
{
54
0
    unsigned ox, oy, w, h, vw, vh;
55
0
    w = vw = pic_width_in_luma_samples;
56
0
    h = vh = pic_height_in_luma_samples;
57
58
0
    static const uint8_t SubWidthHeight[4][2] = { {1, 1}, {2, 2}, {2, 1}, {1, 1} };
59
60
0
    ox = conf_win->left_offset * SubWidthHeight[chroma_format_idc][0];
61
0
    oy = conf_win->top_offset * SubWidthHeight[chroma_format_idc][1];
62
63
0
    vw -= (conf_win->left_offset +  conf_win->right_offset) *
64
0
          SubWidthHeight[chroma_format_idc][0];
65
0
    vh -= (conf_win->bottom_offset + conf_win->top_offset) *
66
0
          SubWidthHeight[chroma_format_idc][1];
67
68
0
    if ( vw > w || vh > h )
69
0
        return false;
70
71
0
    *p_ox = ox; *p_oy = oy;
72
0
    *p_w = w; *p_h = h;
73
0
    *p_vw = vw; *p_vh = vh;
74
0
    return true;
75
0
}
Unexecuted instantiation: hevc_nal.c:h26x_get_picture_size
Unexecuted instantiation: mpeg4video.c:h26x_get_picture_size
Unexecuted instantiation: mpegvideo.c:h26x_get_picture_size
76
77
typedef struct
78
{
79
    nal_u8_t aspect_ratio_idc;
80
    uint16_t sar_width;
81
    uint16_t sar_height;
82
} h26x_aspect_ratio_t;
83
84
static inline
85
bool h26x_get_aspect_ratio( const h26x_aspect_ratio_t *ar,
86
                            unsigned *num, unsigned *den )
87
0
{
88
0
    if( ar->aspect_ratio_idc != 255 )
89
0
    {
90
0
        static const uint8_t ar_table[16][2] =
91
0
            {
92
0
             {    1,      1 },
93
0
             {   12,     11 },
94
0
             {   10,     11 },
95
0
             {   16,     11 },
96
0
             {   40,     33 },
97
0
             {   24,     11 },
98
0
             {   20,     11 },
99
0
             {   32,     11 },
100
0
             {   80,     33 },
101
0
             {   18,     11 },
102
0
             {   15,     11 },
103
0
             {   64,     33 },
104
0
             {  160,     99 },
105
0
             {    4,      3 },
106
0
             {    3,      2 },
107
0
             {    2,      1 },
108
0
             };
109
0
        if( ar->aspect_ratio_idc == 0 ||
110
0
            ar->aspect_ratio_idc >= 17 )
111
0
            return false;
112
0
        *num = ar_table[ar->aspect_ratio_idc - 1][0];
113
0
        *den = ar_table[ar->aspect_ratio_idc - 1][1];
114
0
    }
115
0
    else
116
0
    {
117
0
        *num = ar->sar_width;
118
0
        *den = ar->sar_height;
119
0
    }
120
0
    return true;
121
0
}
Unexecuted instantiation: hevc_nal.c:h26x_get_aspect_ratio
Unexecuted instantiation: mpeg4video.c:h26x_get_aspect_ratio
Unexecuted instantiation: mpegvideo.c:h26x_get_aspect_ratio
122
123
typedef struct
124
{
125
    nal_u8_t colour_primaries;
126
    nal_u8_t transfer_characteristics;
127
    nal_u8_t matrix_coeffs;
128
    nal_u1_t full_range_flag;
129
} h26x_colour_description_t;
130
131
static inline
132
bool h26x_get_colorimetry( const h26x_colour_description_t *colour,
133
                           video_color_primaries_t *p_primaries,
134
                           video_transfer_func_t *p_transfer,
135
                           video_color_space_t *p_colorspace,
136
                           video_color_range_t *p_full_range )
137
0
{
138
0
    *p_primaries =
139
0
        iso_23001_8_cp_to_vlc_primaries( colour->colour_primaries );
140
0
    *p_transfer =
141
0
        iso_23001_8_tc_to_vlc_xfer( colour->transfer_characteristics );
142
0
    *p_colorspace =
143
0
        iso_23001_8_mc_to_vlc_coeffs( colour->matrix_coeffs );
144
0
    *p_full_range = colour->full_range_flag ? COLOR_RANGE_FULL : COLOR_RANGE_LIMITED;
145
0
    return true;
146
0
}
Unexecuted instantiation: hevc_nal.c:h26x_get_colorimetry
Unexecuted instantiation: mpeg4video.c:h26x_get_colorimetry
Unexecuted instantiation: mpegvideo.c:h26x_get_colorimetry
147
148
#endif