diff mbox

[FFmpeg-devel,2/5] lavc/hevc_ps: parse constraint flags for HEVC REXT

Message ID 1568619164-28013-1-git-send-email-linjie.fu@intel.com
State Accepted
Headers show

Commit Message

Fu, Linjie Sept. 16, 2019, 7:32 a.m. UTC
Parse all the constraint flags according to ITU-T Rec. H.265 (02/2018).

It can be passed to hw decoders to determine the exact profile for Range
Extension HEVC.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
---
 libavcodec/hevc_ps.c | 44 ++++++++++++++++++++++++++++++++++++++++----
 libavcodec/hevc_ps.h | 13 ++++++++++++-
 2 files changed, 52 insertions(+), 5 deletions(-)

Comments

Carl Eugen Hoyos Sept. 16, 2019, 10:06 a.m. UTC | #1
Am Mo., 16. Sept. 2019 um 09:35 Uhr schrieb Linjie Fu <linjie.fu@intel.com>:
>
> Parse all the constraint flags according to ITU-T Rec. H.265 (02/2018).

> It can be passed to hw decoders to determine the exact profile for
> Range Extension HEVC.

I am not a native speaker but I believe this should be more like:
They are needed at least for some hw decoders
or
They have to be passed to hw decoders

Or are the flags not really "needed" for vaapi?


Carl Eugen
Fu, Linjie Sept. 16, 2019, 1:51 p.m. UTC | #2
> -----Original Message-----

> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Carl Eugen Hoyos

> Sent: Monday, September 16, 2019 18:06

> To: FFmpeg development discussions and patches <ffmpeg-

> devel@ffmpeg.org>

> Subject: Re: [FFmpeg-devel] [PATCH 2/5] lavc/hevc_ps: parse constraint flags

> for HEVC REXT

> 

> Am Mo., 16. Sept. 2019 um 09:35 Uhr schrieb Linjie Fu <linjie.fu@intel.com>:

> >

> > Parse all the constraint flags according to ITU-T Rec. H.265 (02/2018).

> 

> > It can be passed to hw decoders to determine the exact profile for

> > Range Extension HEVC.

> 

> I am not a native speaker but I believe this should be more like:

> They are needed at least for some hw decoders

> or

> They have to be passed to hw decoders

> 

> Or are the flags not really "needed" for vaapi?

> 

These flags are needed for VAAPI.
And it could be emphasized in the commit message to make it more clear.

- linjie
diff mbox

Patch

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index abf08b9..82d3b79 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,45 @@  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 ((ptl->profile_idc >=1 && ptl->profile_idc <= 5) || ptl->profile_idc == 9 ||
+        ptl->profile_compatibility_flag[1] || ptl->profile_compatibility_flag[2] ||
+        ptl->profile_compatibility_flag[3] || ptl->profile_compatibility_flag[4] ||
+        ptl->profile_compatibility_flag[5] || ptl->profile_compatibility_flag[9])
+        ptl->inbld_flag = get_bits1(gb);
+    else
+        skip_bits1(gb);
+#undef check_profile_idc
 
     return 0;
 }
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index 2840dc4..8e1bccd 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -177,11 +177,22 @@  typedef struct PTLCommon {
     uint8_t tier_flag;
     uint8_t profile_idc;
     uint8_t profile_compatibility_flag[32];
-    uint8_t level_idc;
     uint8_t progressive_source_flag;
     uint8_t interlaced_source_flag;
     uint8_t non_packed_constraint_flag;
     uint8_t frame_only_constraint_flag;
+    uint8_t max_12bit_constraint_flag;
+    uint8_t max_10bit_constraint_flag;
+    uint8_t max_8bit_constraint_flag;
+    uint8_t max_422chroma_constraint_flag;
+    uint8_t max_420chroma_constraint_flag;
+    uint8_t max_monochrome_constraint_flag;
+    uint8_t intra_constraint_flag;
+    uint8_t one_picture_only_constraint_flag;
+    uint8_t lower_bit_rate_constraint_flag;
+    uint8_t max_14bit_constraint_flag;
+    uint8_t inbld_flag;
+    uint8_t level_idc;
 } PTLCommon;
 
 typedef struct PTL {