| 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 | 1297 | void ff_h2645_decode_common_vui_params(GetBitContext *gb, H2645VUI *vui, void *logctx) | |
| 38 | { | ||
| 39 | 1297 | av_log(logctx, AV_LOG_DEBUG, "Decoding VUI\n"); | |
| 40 | |||
| 41 | 1297 | vui->aspect_ratio_info_present_flag = get_bits1(gb); | |
| 42 |
2/2✓ Branch 0 taken 628 times.
✓ Branch 1 taken 669 times.
|
1297 | if (vui->aspect_ratio_info_present_flag) { |
| 43 | 628 | vui->aspect_ratio_idc = get_bits(gb, 8); | |
| 44 |
2/2✓ Branch 0 taken 578 times.
✓ Branch 1 taken 50 times.
|
628 | if (vui->aspect_ratio_idc < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect)) |
| 45 | 578 | vui->sar = ff_h2645_pixel_aspect[vui->aspect_ratio_idc]; | |
| 46 |
1/2✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
|
50 | else if (vui->aspect_ratio_idc == EXTENDED_SAR) { |
| 47 | 50 | vui->sar.num = get_bits(gb, 16); | |
| 48 | 50 | 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 | 669 | vui->sar = (AVRational){ 0, 1 }; | |
| 54 | |||
| 55 | 1297 | vui->overscan_info_present_flag = get_bits1(gb); | |
| 56 |
2/2✓ Branch 0 taken 78 times.
✓ Branch 1 taken 1219 times.
|
1297 | if (vui->overscan_info_present_flag) |
| 57 | 78 | vui->overscan_appropriate_flag = get_bits1(gb); | |
| 58 | |||
| 59 | 1297 | vui->video_signal_type_present_flag = get_bits1(gb); | |
| 60 |
2/2✓ Branch 0 taken 282 times.
✓ Branch 1 taken 1015 times.
|
1297 | if (vui->video_signal_type_present_flag) { |
| 61 | 282 | vui->video_format = get_bits(gb, 3); | |
| 62 | 282 | vui->video_full_range_flag = get_bits1(gb); | |
| 63 | 282 | vui->colour_description_present_flag = get_bits1(gb); | |
| 64 |
2/2✓ Branch 0 taken 249 times.
✓ Branch 1 taken 33 times.
|
282 | if (vui->colour_description_present_flag) { |
| 65 | 249 | vui->colour_primaries = get_bits(gb, 8); | |
| 66 | 249 | vui->transfer_characteristics = get_bits(gb, 8); | |
| 67 | 249 | vui->matrix_coeffs = get_bits(gb, 8); | |
| 68 | |||
| 69 | // Set invalid values to "unspecified" | ||
| 70 |
2/2✓ Branch 0 taken 247 times.
✓ Branch 1 taken 2 times.
|
249 | if (vui->colour_primaries == AVCOL_PRI_RESERVED0 || |
| 71 |
2/4✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 247 times.
|
494 | vui->colour_primaries == AVCOL_PRI_RESERVED || |
| 72 | 247 | !av_color_primaries_name(vui->colour_primaries)) | |
| 73 | 2 | vui->colour_primaries = AVCOL_PRI_UNSPECIFIED; | |
| 74 |
2/2✓ Branch 0 taken 247 times.
✓ Branch 1 taken 2 times.
|
249 | if (vui->transfer_characteristics == AVCOL_TRC_RESERVED0 || |
| 75 |
2/4✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 247 times.
|
494 | vui->transfer_characteristics == AVCOL_TRC_RESERVED || |
| 76 | 247 | !av_color_transfer_name(vui->transfer_characteristics)) | |
| 77 | 2 | vui->transfer_characteristics = AVCOL_TRC_UNSPECIFIED; | |
| 78 |
3/4✓ Branch 0 taken 247 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 247 times.
|
496 | if (vui->matrix_coeffs == AVCOL_SPC_RESERVED || |
| 79 | 247 | !av_color_space_name(vui->matrix_coeffs)) | |
| 80 | 2 | vui->matrix_coeffs = AVCOL_SPC_UNSPECIFIED; | |
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | 1297 | vui->chroma_loc_info_present_flag = get_bits1(gb); | |
| 85 |
2/2✓ Branch 0 taken 150 times.
✓ Branch 1 taken 1147 times.
|
1297 | if (vui->chroma_loc_info_present_flag) { |
| 86 | 150 | vui->chroma_sample_loc_type_top_field = get_ue_golomb_31(gb); | |
| 87 | 150 | vui->chroma_sample_loc_type_bottom_field = get_ue_golomb_31(gb); | |
| 88 |
1/2✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
|
150 | if (vui->chroma_sample_loc_type_top_field <= 5U) |
| 89 | 150 | vui->chroma_location = vui->chroma_sample_loc_type_top_field + 1; | |
| 90 | else | ||
| 91 | ✗ | vui->chroma_location = AVCHROMA_LOC_UNSPECIFIED; | |
| 92 | } else | ||
| 93 | 1147 | vui->chroma_location = AVCHROMA_LOC_LEFT; | |
| 94 | 1297 | } | |
| 95 |