FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/h2645_vui.c
Date: 2023-01-27 00:32:08
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 1068 void ff_h2645_decode_common_vui_params(GetBitContext *gb, H2645VUI *vui, void *logctx)
38 {
39 int aspect_ratio_info_present_flag;
40
41 1068 av_log(logctx, AV_LOG_DEBUG, "Decoding VUI\n");
42
43 1068 aspect_ratio_info_present_flag = get_bits1(gb);
44
2/2
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 536 times.
1068 if (aspect_ratio_info_present_flag) {
45 532 uint8_t aspect_ratio_idc = get_bits(gb, 8);
46
2/2
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 40 times.
532 if (aspect_ratio_idc < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect))
47 492 vui->sar = ff_h2645_pixel_aspect[aspect_ratio_idc];
48
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 else if (aspect_ratio_idc == EXTENDED_SAR) {
49 40 vui->sar.num = get_bits(gb, 16);
50 40 vui->sar.den = get_bits(gb, 16);
51 } else
52 av_log(logctx, AV_LOG_WARNING,
53 "Unknown SAR index: %u.\n", aspect_ratio_idc);
54 } else
55 536 vui->sar = (AVRational){ 0, 1 };
56
57 1068 vui->overscan_info_present_flag = get_bits1(gb);
58
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 990 times.
1068 if (vui->overscan_info_present_flag)
59 78 vui->overscan_appropriate_flag = get_bits1(gb);
60
61 1068 vui->video_signal_type_present_flag = get_bits1(gb);
62
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 856 times.
1068 if (vui->video_signal_type_present_flag) {
63 212 vui->video_format = get_bits(gb, 3);
64 212 vui->video_full_range_flag = get_bits1(gb);
65 212 vui->colour_description_present_flag = get_bits1(gb);
66
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 26 times.
212 if (vui->colour_description_present_flag) {
67 186 vui->colour_primaries = get_bits(gb, 8);
68 186 vui->transfer_characteristics = get_bits(gb, 8);
69 186 vui->matrix_coeffs = get_bits(gb, 8);
70
71 // Set invalid values to "unspecified"
72
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 186 times.
186 if (!av_color_primaries_name(vui->colour_primaries))
73 vui->colour_primaries = AVCOL_PRI_UNSPECIFIED;
74
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 186 times.
186 if (!av_color_transfer_name(vui->transfer_characteristics))
75 vui->transfer_characteristics = AVCOL_TRC_UNSPECIFIED;
76
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 186 times.
186 if (!av_color_space_name(vui->matrix_coeffs))
77 vui->matrix_coeffs = AVCOL_SPC_UNSPECIFIED;
78 }
79 }
80
81 1068 vui->chroma_loc_info_present_flag = get_bits1(gb);
82
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 934 times.
1068 if (vui->chroma_loc_info_present_flag) {
83 134 vui->chroma_sample_loc_type_top_field = get_ue_golomb_31(gb);
84 134 vui->chroma_sample_loc_type_bottom_field = get_ue_golomb_31(gb);
85
1/2
✓ Branch 0 taken 134 times.
✗ Branch 1 not taken.
134 if (vui->chroma_sample_loc_type_top_field <= 5U)
86 134 vui->chroma_location = vui->chroma_sample_loc_type_top_field + 1;
87 else
88 vui->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
89 } else
90 934 vui->chroma_location = AVCHROMA_LOC_LEFT;
91 1068 }
92