FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/h2645_vui.c
Date: 2024-11-20 23:03:26
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 1237 void ff_h2645_decode_common_vui_params(GetBitContext *gb, H2645VUI *vui, void *logctx)
38 {
39 1237 av_log(logctx, AV_LOG_DEBUG, "Decoding VUI\n");
40
41 1237 vui->aspect_ratio_info_present_flag = get_bits1(gb);
42
2/2
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 645 times.
1237 if (vui->aspect_ratio_info_present_flag) {
43 592 vui->aspect_ratio_idc = get_bits(gb, 8);
44
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 46 times.
592 if (vui->aspect_ratio_idc < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect))
45 546 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 645 vui->sar = (AVRational){ 0, 1 };
54
55 1237 vui->overscan_info_present_flag = get_bits1(gb);
56
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 1159 times.
1237 if (vui->overscan_info_present_flag)
57 78 vui->overscan_appropriate_flag = get_bits1(gb);
58
59 1237 vui->video_signal_type_present_flag = get_bits1(gb);
60
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 984 times.
1237 if (vui->video_signal_type_present_flag) {
61 253 vui->video_format = get_bits(gb, 3);
62 253 vui->video_full_range_flag = get_bits1(gb);
63 253 vui->colour_description_present_flag = get_bits1(gb);
64
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 26 times.
253 if (vui->colour_description_present_flag) {
65 227 vui->colour_primaries = get_bits(gb, 8);
66 227 vui->transfer_characteristics = get_bits(gb, 8);
67 227 vui->matrix_coeffs = get_bits(gb, 8);
68
69 // Set invalid values to "unspecified"
70
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 227 times.
227 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 227 times.
227 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 227 times.
227 if (!av_color_space_name(vui->matrix_coeffs))
75 vui->matrix_coeffs = AVCOL_SPC_UNSPECIFIED;
76 }
77 }
78
79 1237 vui->chroma_loc_info_present_flag = get_bits1(gb);
80
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 1090 times.
1237 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 1090 vui->chroma_location = AVCHROMA_LOC_LEFT;
89 1237 }
90