summaryrefslogtreecommitdiff
path: root/libavcodec/hevc_ps.c
diff options
context:
space:
mode:
authorLinjie Fu <linjie.fu@intel.com>2020-01-15 15:01:28 +0800
committerMark Thompson <sw@jkqxz.net>2020-02-24 00:09:51 +0000
commit0d83fcc07b31c528c4fb95528b8e50c440eefc87 (patch)
treed18d8711b24f8e15646b47c41da74335259230c2 /libavcodec/hevc_ps.c
parentaa6b2e1604c285e16109d0377e0bb5e8b4fbe13e (diff)
lavc/hevc_ps: parse constraint flags for HEVC REXT
Parse all the constraint flags according to ITU-T Rec. H.265 (02/2018). They have to be passed to hw decoders to determine the exact profile for Range Extension HEVC. Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Diffstat (limited to 'libavcodec/hevc_ps.c')
-rw-r--r--libavcodec/hevc_ps.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index a30b8b8022..ea6fd536c6 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -267,7 +267,7 @@ static int decode_profile_tier_level(GetBitContext *gb, AVCodecContext *avctx,
{
int i;
- if (get_bits_left(gb) < 2+1+5 + 32 + 4 + 16 + 16 + 12)
+ if (get_bits_left(gb) < 2+1+5 + 32 + 4 + 43 + 1)
return -1;
ptl->profile_space = get_bits(gb, 2);
@@ -295,9 +295,43 @@ static int decode_profile_tier_level(GetBitContext *gb, AVCodecContext *avctx,
ptl->non_packed_constraint_flag = get_bits1(gb);
ptl->frame_only_constraint_flag = get_bits1(gb);
- skip_bits(gb, 16); // XXX_reserved_zero_44bits[0..15]
- skip_bits(gb, 16); // XXX_reserved_zero_44bits[16..31]
- skip_bits(gb, 12); // XXX_reserved_zero_44bits[32..43]
+#define check_profile_idc(idc) \
+ ptl->profile_idc == idc || ptl->profile_compatibility_flag[idc]
+
+ if (check_profile_idc(4) || check_profile_idc(5) || check_profile_idc(6) ||
+ check_profile_idc(7) || check_profile_idc(8) || check_profile_idc(9) ||
+ check_profile_idc(10)) {
+
+ ptl->max_12bit_constraint_flag = get_bits1(gb);
+ ptl->max_10bit_constraint_flag = get_bits1(gb);
+ ptl->max_8bit_constraint_flag = get_bits1(gb);
+ ptl->max_422chroma_constraint_flag = get_bits1(gb);
+ ptl->max_420chroma_constraint_flag = get_bits1(gb);
+ ptl->max_monochrome_constraint_flag = get_bits1(gb);
+ ptl->intra_constraint_flag = get_bits1(gb);
+ ptl->one_picture_only_constraint_flag = get_bits1(gb);
+ ptl->lower_bit_rate_constraint_flag = get_bits1(gb);
+
+ if (check_profile_idc(5) || check_profile_idc(9) || check_profile_idc(10)) {
+ ptl->max_14bit_constraint_flag = get_bits1(gb);
+ skip_bits_long(gb, 33); // XXX_reserved_zero_33bits[0..32]
+ } else {
+ skip_bits_long(gb, 34); // XXX_reserved_zero_34bits[0..33]
+ }
+ } else if (check_profile_idc(2)) {
+ skip_bits(gb, 7);
+ ptl->one_picture_only_constraint_flag = get_bits1(gb);
+ skip_bits_long(gb, 35); // XXX_reserved_zero_35bits[0..34]
+ } else {
+ skip_bits_long(gb, 43); // XXX_reserved_zero_43bits[0..42]
+ }
+
+ if (check_profile_idc(1) || check_profile_idc(2) || check_profile_idc(3) ||
+ check_profile_idc(4) || check_profile_idc(5) || check_profile_idc(9))
+ ptl->inbld_flag = get_bits1(gb);
+ else
+ skip_bits1(gb);
+#undef check_profile_idc
return 0;
}