FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/h2645_vui.c
Date: 2024-05-26 22:00:00
Exec Total Coverage
Lines: 34 39 87.2%
Functions: 1 1 100.0%
Branches: 17 22 77.3%

Line Branch Exec Source
1 /*
2 * Common H.264/HEVC VUI Parameter decoding
3 *
4 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
5 * Copyright (C) 2012 - 2013 Guillaume Martres
6 * Copyright (C) 2012 - 2013 Mickael Raulet
7 * Copyright (C) 2012 - 2013 Gildas Cocherel
8 * Copyright (C) 2013 Vittorio Giovara
9 *
10 * This file is part of FFmpeg.
11 *
12 * FFmpeg is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * FFmpeg is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with FFmpeg; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26
27 #include "libavutil/log.h"
28 #include "libavutil/pixdesc.h"
29
30 #include "get_bits.h"
31 #include "golomb.h"
32 #include "h2645data.h"
33 #include "h2645_vui.h"
34
35 #define EXTENDED_SAR 255
36
37 1211 void ff_h2645_decode_common_vui_params(GetBitContext *gb, H2645VUI *vui, void *logctx)
38 {
39 1211 av_log(logctx, AV_LOG_DEBUG, "Decoding VUI\n");
40
41 1211 vui->aspect_ratio_info_present_flag = get_bits1(gb);
42
2/2
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 633 times.
1211 if (vui->aspect_ratio_info_present_flag) {
43 578 vui->aspect_ratio_idc = get_bits(gb, 8);
44
2/2
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 46 times.
578 if (vui->aspect_ratio_idc < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect))
45 532 vui->sar = ff_h2645_pixel_aspect[vui->aspect_ratio_idc];
46
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 else if (vui->aspect_ratio_idc == EXTENDED_SAR) {
47 46 vui->sar.num = get_bits(gb, 16);
48 46 vui->sar.den = get_bits(gb, 16);
49 } else
50 av_log(logctx, AV_LOG_WARNING,
51 "Unknown SAR index: %u.\n", vui->aspect_ratio_idc);
52 } else
53 633 vui->sar = (AVRational){ 0, 1 };
54
55 1211 vui->overscan_info_present_flag = get_bits1(gb);
56
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 1133 times.
1211 if (vui->overscan_info_present_flag)
57 78 vui->overscan_appropriate_flag = get_bits1(gb);
58
59 1211 vui->video_signal_type_present_flag = get_bits1(gb);
60
2/2
✓ Branch 0 taken 245 times.
✓ Branch 1 taken 966 times.
1211 if (vui->video_signal_type_present_flag) {
61 245 vui->video_format = get_bits(gb, 3);
62 245 vui->video_full_range_flag = get_bits1(gb);
63 245 vui->colour_description_present_flag = get_bits1(gb);
64
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 26 times.
245 if (vui->colour_description_present_flag) {
65 219 vui->colour_primaries = get_bits(gb, 8);
66 219 vui->transfer_characteristics = get_bits(gb, 8);
67 219 vui->matrix_coeffs = get_bits(gb, 8);
68
69 // Set invalid values to "unspecified"
70
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 219 times.
219 if (!av_color_primaries_name(vui->colour_primaries))
71 vui->colour_primaries = AVCOL_PRI_UNSPECIFIED;
72
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 219 times.
219 if (!av_color_transfer_name(vui->transfer_characteristics))
73 vui->transfer_characteristics = AVCOL_TRC_UNSPECIFIED;
74
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 219 times.
219 if (!av_color_space_name(vui->matrix_coeffs))
75 vui->matrix_coeffs = AVCOL_SPC_UNSPECIFIED;
76 }
77 }
78
79 1211 vui->chroma_loc_info_present_flag = get_bits1(gb);
80
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 1064 times.
1211 if (vui->chroma_loc_info_present_flag) {
81 147 vui->chroma_sample_loc_type_top_field = get_ue_golomb_31(gb);
82 147 vui->chroma_sample_loc_type_bottom_field = get_ue_golomb_31(gb);
83
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if (vui->chroma_sample_loc_type_top_field <= 5U)
84 147 vui->chroma_location = vui->chroma_sample_loc_type_top_field + 1;
85 else
86 vui->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
87 } else
88 1064 vui->chroma_location = AVCHROMA_LOC_LEFT;
89 1211 }
90