FFmpeg
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  } else
50  av_log(logctx, AV_LOG_WARNING,
51  "Unknown SAR index: %u.\n", vui->aspect_ratio_idc);
52  } else
53  vui->sar = (AVRational){ 0, 1 };
54 
58 
61  vui->video_format = get_bits(gb, 3);
65  vui->colour_primaries = get_bits(gb, 8);
66  vui->transfer_characteristics = get_bits(gb, 8);
67  vui->matrix_coeffs = get_bits(gb, 8);
68 
69  // Set invalid values to "unspecified"
76  }
77  }
78 
85  else
87  } else
89 }
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
EXTENDED_SAR
#define EXTENDED_SAR
Definition: h2645_vui.c:35
H2645VUI::matrix_coeffs
enum AVColorSpace matrix_coeffs
Definition: h2645_vui.h:41
pixdesc.h
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:587
H2645VUI::sar
AVRational sar
Definition: h2645_vui.h:28
H2645VUI::colour_primaries
enum AVColorPrimaries colour_primaries
Definition: h2645_vui.h:39
H2645VUI::video_full_range_flag
int video_full_range_flag
Definition: h2645_vui.h:37
H2645VUI::video_signal_type_present_flag
int video_signal_type_present_flag
Definition: h2645_vui.h:35
golomb.h
exp golomb vlc stuff
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:335
H2645VUI::chroma_loc_info_present_flag
int chroma_loc_info_present_flag
Definition: h2645_vui.h:43
av_color_space_name
const char * av_color_space_name(enum AVColorSpace space)
Definition: pixdesc.c:3344
GetBitContext
Definition: get_bits.h:108
H2645VUI::chroma_sample_loc_type_bottom_field
int chroma_sample_loc_type_bottom_field
Definition: h2645_vui.h:45
AVRational::num
int num
Numerator.
Definition: rational.h:59
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
H2645VUI::chroma_sample_loc_type_top_field
int chroma_sample_loc_type_top_field
Definition: h2645_vui.h:44
H2645VUI::overscan_appropriate_flag
int overscan_appropriate_flag
Definition: h2645_vui.h:33
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
get_bits.h
h2645data.h
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:562
H2645VUI::overscan_info_present_flag
int overscan_info_present_flag
Definition: h2645_vui.h:32
H2645VUI::colour_description_present_flag
int colour_description_present_flag
Definition: h2645_vui.h:38
AVCHROMA_LOC_LEFT
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
Definition: pixfmt.h:708
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:388
H2645VUI
Definition: h2645_vui.h:27
av_color_primaries_name
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
Definition: pixdesc.c:3302
H2645VUI::transfer_characteristics
enum AVColorTransferCharacteristic transfer_characteristics
Definition: h2645_vui.h:40
H2645VUI::chroma_location
enum AVChromaLocation chroma_location
Definition: h2645_vui.h:46
AVCHROMA_LOC_UNSPECIFIED
@ AVCHROMA_LOC_UNSPECIFIED
Definition: pixfmt.h:707
H2645VUI::aspect_ratio_idc
int aspect_ratio_idc
Definition: h2645_vui.h:29
log.h
ff_h2645_pixel_aspect
const AVRational ff_h2645_pixel_aspect[]
Definition: h2645data.c:21
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:616
h2645_vui.h
ff_h2645_decode_common_vui_params
void ff_h2645_decode_common_vui_params(GetBitContext *gb, H2645VUI *vui, void *logctx)
Definition: h2645_vui.c:37
U
#define U(x)
Definition: vpx_arith.h:37
get_ue_golomb_31
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
Definition: golomb.h:120
AVRational::den
int den
Denominator.
Definition: rational.h:60
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
H2645VUI::aspect_ratio_info_present_flag
int aspect_ratio_info_present_flag
Definition: h2645_vui.h:30
av_color_transfer_name
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
Definition: pixdesc.c:3323
H2645VUI::video_format
int video_format
Definition: h2645_vui.h:36