FFmpeg
Loading...
Searching...
No Matches
h2645_vui.c
Go to the documentation of this file.
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
38{
39 av_log(logctx, AV_LOG_DEBUG, "Decoding VUI\n");
40
43 vui->aspect_ratio_idc = get_bits(gb, 8);
46 else if (vui->aspect_ratio_idc == EXTENDED_SAR) {
47 vui->sar.num = get_bits(gb, 16);
48 vui->sar.den = get_bits(gb, 16);
49 if (!vui->sar.num || !vui->sar.den) {
50 av_log(logctx, AV_LOG_WARNING,
51 "Invalid SAR %d/%d in bitstream, treating as unspecified.\n",
52 vui->sar.num, vui->sar.den);
53 vui->sar = (AVRational){ 0, 1 };
54 }
55 } else
56 av_log(logctx, AV_LOG_WARNING,
57 "Unknown SAR index: %u.\n", vui->aspect_ratio_idc);
58 } else
59 vui->sar = (AVRational){ 0, 1 };
60
64
67 vui->video_format = get_bits(gb, 3);
71 vui->colour_primaries = get_bits(gb, 8);
73 vui->matrix_coeffs = get_bits(gb, 8);
74
75 // Set invalid values to "unspecified"
87 }
88 }
89
96 else
98 } else
100}
#define EXTENDED_SAR
Definition evc_ps.c:25
bitstream reader API header.
static unsigned int get_bits1(GetBitContext *s)
Definition get_bits.h:391
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition get_bits.h:337
exp golomb vlc stuff
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
Definition golomb.h:120
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
void ff_h2645_decode_common_vui_params(GetBitContext *gb, H2645VUI *vui, void *logctx)
Definition h2645_vui.c:37
const AVRational ff_h2645_pixel_aspect[]
Definition h2645data.c:21
const char * av_color_space_name(enum AVColorSpace space)
Definition pixdesc.c:3860
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
Definition pixdesc.c:3827
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
Definition pixdesc.c:3794
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
Definition pixfmt.h:804
@ AVCHROMA_LOC_UNSPECIFIED
Definition pixfmt.h:803
@ AVCOL_PRI_RESERVED
Definition pixfmt.h:646
@ AVCOL_PRI_UNSPECIFIED
Definition pixfmt.h:645
@ AVCOL_PRI_RESERVED0
Definition pixfmt.h:643
@ AVCOL_TRC_RESERVED
Definition pixfmt.h:676
@ AVCOL_TRC_UNSPECIFIED
Definition pixfmt.h:675
@ AVCOL_TRC_RESERVED0
Definition pixfmt.h:673
@ AVCOL_SPC_UNSPECIFIED
Definition pixfmt.h:709
@ AVCOL_SPC_RESERVED
reserved for future use by ITU-T and ISO/IEC just like 15-255 are
Definition pixfmt.h:710
#define FF_ARRAY_ELEMS(a)
Rational number (pair of numerator and denominator).
Definition rational.h:58
int num
Numerator.
Definition rational.h:59
int den
Denominator.
Definition rational.h:60
int overscan_appropriate_flag
Definition h2645_vui.h:33
AVRational sar
Definition h2645_vui.h:28
enum AVColorPrimaries colour_primaries
Definition h2645_vui.h:39
int video_signal_type_present_flag
Definition h2645_vui.h:35
enum AVColorTransferCharacteristic transfer_characteristics
Definition h2645_vui.h:40
int chroma_sample_loc_type_top_field
Definition h2645_vui.h:44
int video_format
Definition h2645_vui.h:36
int chroma_sample_loc_type_bottom_field
Definition h2645_vui.h:45
int chroma_loc_info_present_flag
Definition h2645_vui.h:43
int overscan_info_present_flag
Definition h2645_vui.h:32
int video_full_range_flag
Definition h2645_vui.h:37
enum AVColorSpace matrix_coeffs
Definition h2645_vui.h:41
int colour_description_present_flag
Definition h2645_vui.h:38
int aspect_ratio_info_present_flag
Definition h2645_vui.h:30
int aspect_ratio_idc
Definition h2645_vui.h:29
enum AVChromaLocation chroma_location
Definition h2645_vui.h:46
#define av_log(a,...)