[vlc-commits] packetizer: hevc_nal: expose all profiles

Francois Cartegnie git at videolan.org
Thu Sep 12 15:20:03 CEST 2019


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Sep 11 19:02:09 2019 +0200| [b525b27e85f1f2cec0fe9b38e08f5dee698a893e] | committer: Francois Cartegnie

packetizer: hevc_nal: expose all profiles

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b525b27e85f1f2cec0fe9b38e08f5dee698a893e
---

 modules/packetizer/hevc_nal.c |  48 +++++++++++++++++
 modules/packetizer/hevc_nal.h | 118 +++++++++++++++++++++++++++++++++++-------
 2 files changed, 146 insertions(+), 20 deletions(-)

diff --git a/modules/packetizer/hevc_nal.c b/modules/packetizer/hevc_nal.c
index f9a7c05b12..309c6d0e7c 100644
--- a/modules/packetizer/hevc_nal.c
+++ b/modules/packetizer/hevc_nal.c
@@ -1363,6 +1363,54 @@ bool hevc_get_profile_level(const es_format_t *p_fmt, uint8_t *pi_profile,
     return true;
 }
 
+static unsigned hevc_make_indication( const hevc_inner_profile_tier_level_t *p )
+{
+    uint8_t flags[] =
+    {
+        p->idc4to7.max_14bit_constraint_flag,
+        p->idc4to7.max_12bit_constraint_flag,
+        p->idc4to7.max_10bit_constraint_flag,
+        p->idc4to7.max_8bit_constraint_flag,
+        p->idc4to7.max_422chroma_constraint_flag,
+        p->idc4to7.max_420chroma_constraint_flag,
+        p->idc4to7.max_monochrome_constraint_flag,
+        p->idc4to7.intra_constraint_flag,
+        p->idc4to7.one_picture_only_constraint_flag,
+        p->idc4to7.lower_bit_rate_constraint_flag,
+    };
+    unsigned indication = 0;
+    for( size_t i=0; i<ARRAY_SIZE(flags); i++ )
+    {
+        if( flags[i] )
+            indication |= (1 << (ARRAY_SIZE(flags) - 1 - i));
+    }
+    return indication;
+}
+
+enum vlc_hevc_profile_e hevc_get_vlc_profile( const hevc_sequence_parameter_set_t *p_sps )
+{
+    unsigned indication = 0;
+    enum hevc_general_profile_idc_e profile = p_sps->profile_tier_level.general.profile_idc;
+    switch( profile )
+    {
+        case HEVC_PROFILE_IDC_REXT:
+            indication = hevc_make_indication( &p_sps->profile_tier_level.general ) & 0x1FF;
+            break;
+        case HEVC_PROFILE_IDC_HIGH_THROUGHPUT:
+        case HEVC_PROFILE_IDC_SCREEN_EXTENDED:
+            indication = hevc_make_indication( &p_sps->profile_tier_level.general );
+            break;
+        default:
+            break;
+    }
+
+    /* all intras have insignifiant lowest bit */
+    if( p_sps->profile_tier_level.general.idc4to7.intra_constraint_flag )
+        indication &= ~1;
+
+    return (indication << HEVC_INDICATION_SHIFT) | profile;
+}
+
 /*
  * HEVCDecoderConfigurationRecord operations
  */
diff --git a/modules/packetizer/hevc_nal.h b/modules/packetizer/hevc_nal.h
index 0d0303d771..8abe6d57d2 100644
--- a/modules/packetizer/hevc_nal.h
+++ b/modules/packetizer/hevc_nal.h
@@ -61,26 +61,102 @@ enum hevc_level_idc_e
 };
 
 /* Values built from 9 bits mapping of the A-2 bitstream indications for conformance */
-#define HEVC_EXT_PROFILE_MONOCHROME                 0x1F9
-#define HEVC_EXT_PROFILE_MONOCHROME_12              0x139
-#define HEVC_EXT_PROFILE_MONOCHROME_16              0x039
-#define HEVC_EXT_PROFILE_MAIN_12                    0x131
-#define HEVC_EXT_PROFILE_MAIN_422_10                0x1A1
-#define HEVC_EXT_PROFILE_MAIN_422_12                0x121
-#define HEVC_EXT_PROFILE_MAIN_444                   0x1C1
-#define HEVC_EXT_PROFILE_MAIN_444_10                0x181
-#define HEVC_EXT_PROFILE_MAIN_444_12                0x101
-#define HEVC_EXT_PROFILE_MAIN_INTRA                 0x1F4 /* From this one, lowest bit is insignifiant */
-#define HEVC_EXT_PROFILE_MAIN_10_INTRA              0x1B4
-#define HEVC_EXT_PROFILE_MAIN_12_INTRA              0x134
-#define HEVC_EXT_PROFILE_MAIN_422_10_INTRA          0x1A4
-#define HEVC_EXT_PROFILE_MAIN_422_12_INTRA          0x124
-#define HEVC_EXT_PROFILE_MAIN_444_INTRA             0x1C4
-#define HEVC_EXT_PROFILE_MAIN_444_10_INTRA          0x184
-#define HEVC_EXT_PROFILE_MAIN_444_12_INTRA          0x104
-#define HEVC_EXT_PROFILE_MAIN_444_16_INTRA          0x004
-#define HEVC_EXT_PROFILE_MAIN_444_STILL_PICTURE     0x1C6
-#define HEVC_EXT_PROFILE_MAIN_444_16_STILL_PICTURE  0x006
+enum hevc_rext_indication_e
+{
+    HEVC_REXT_INDICATION_MONOCHROME                = 0x1F9,
+    HEVC_REXT_INDICATION_MONOCHROME_10             = 0x1B9,
+    HEVC_REXT_INDICATION_MONOCHROME_12             = 0x139,
+    HEVC_REXT_INDICATION_MONOCHROME_16             = 0x039,
+    HEVC_REXT_INDICATION_MAIN_12                   = 0x131,
+    HEVC_REXT_INDICATION_MAIN_422_10               = 0x1A1,
+    HEVC_REXT_INDICATION_MAIN_422_12               = 0x121,
+    HEVC_REXT_INDICATION_MAIN_444                  = 0x1C1,
+    HEVC_REXT_INDICATION_MAIN_444_10               = 0x181,
+    HEVC_REXT_INDICATION_MAIN_444_12               = 0x101,
+    HEVC_REXT_INDICATION_MAIN_INTRA                = 0x1F4, /* From this one, lowest bit is insignifiant */
+    HEVC_REXT_INDICATION_MAIN_10_INTRA             = 0x1B4,
+    HEVC_REXT_INDICATION_MAIN_12_INTRA             = 0x134,
+    HEVC_REXT_INDICATION_MAIN_422_10_INTRA         = 0x1A4,
+    HEVC_REXT_INDICATION_MAIN_422_12_INTRA         = 0x124,
+    HEVC_REXT_INDICATION_MAIN_444_INTRA            = 0x1C4,
+    HEVC_REXT_INDICATION_MAIN_444_10_INTRA         = 0x184,
+    HEVC_REXT_INDICATION_MAIN_444_12_INTRA         = 0x104,
+    HEVC_REXT_INDICATION_MAIN_444_16_INTRA         = 0x004,
+    HEVC_REXT_INDICATION_MAIN_444_STILL_PICTURE    = 0x1C6,
+    HEVC_REXT_INDICATION_MAIN_444_16_STILL_PICTURE = 0x006,
+};
+
+enum hevc_high_throughput_indication_e
+{
+    HEVC_HIGH_THROUGHPUT_INDICATION_444            = 0x3C1,
+    HEVC_HIGH_THROUGHPUT_INDICATION_444_10         = 0x381,
+    HEVC_HIGH_THROUGHPUT_INDICATION_444_14         = 0x201,
+    HEVC_HIGH_THROUGHPUT_INDICATION_444_16_INTRA   = 0x002, /* lowest bit is insignifiant */
+};
+
+enum hevc_screen_extended_indication_e
+{
+    HEVC_SCREEN_EXTENDED_INDICATION_MAIN                    = 0x3F1,
+    HEVC_SCREEN_EXTENDED_INDICATION_MAIN_10                 = 0x3B1,
+    HEVC_SCREEN_EXTENDED_INDICATION_MAIN_444                = 0x3C1,
+    HEVC_SCREEN_EXTENDED_INDICATION_MAIN_444_10             = 0x381,
+    /* skip HP 444 profiles which are the same */
+    HEVC_SCREEN_EXTENDED_INDICATION_HIGH_THROUGHPUT_444_14  = 0x201,
+};
+
+/* VLC only specific profiles for features testing and special cases.
+   These are not to be stored. */
+#define HEVC_INDICATION_SHIFT 8
+#define MKPROF(a, b) ((HEVC_##a##_INDICATION_##b << HEVC_INDICATION_SHIFT) | HEVC_PROFILE_IDC_##a)
+enum vlc_hevc_profile_e
+{
+    VLC_HEVC_PROFILE_NONE               = HEVC_PROFILE_IDC_NONE,
+    VLC_HEVC_PROFILE_MAIN               = HEVC_PROFILE_IDC_MAIN,
+    VLC_HEVC_PROFILE_MAIN_10            = HEVC_PROFILE_IDC_MAIN_10,
+    VLC_HEVC_PROFILE_MAIN_STILL_PICTURE = HEVC_PROFILE_IDC_MAIN_STILL_PICTURE,
+    /* range extensions */
+    VLC_HEVC_PROFILE_MONOCHROME         = MKPROF(REXT,MONOCHROME),
+    VLC_HEVC_PROFILE_MONOCHROME_10      = MKPROF(REXT,MONOCHROME_10),
+    VLC_HEVC_PROFILE_MONOCHROME_12      = MKPROF(REXT,MONOCHROME_12),
+    VLC_HEVC_PROFILE_MONOCHROME_16      = MKPROF(REXT,MONOCHROME_16),
+    VLC_HEVC_PROFILE_MAIN_12            = MKPROF(REXT,MAIN_12),
+    VLC_HEVC_PROFILE_MAIN_422_10        = MKPROF(REXT,MAIN_422_10),
+    VLC_HEVC_PROFILE_MAIN_422_12        = MKPROF(REXT,MAIN_422_12),
+    VLC_HEVC_PROFILE_MAIN_444           = MKPROF(REXT,MAIN_444),
+    VLC_HEVC_PROFILE_MAIN_444_10        = MKPROF(REXT,MAIN_444_10),
+    VLC_HEVC_PROFILE_MAIN_444_12        = MKPROF(REXT,MAIN_444_12),
+    VLC_HEVC_PROFILE_MAIN_INTRA         = MKPROF(REXT,MAIN_INTRA),
+    VLC_HEVC_PROFILE_MAIN_10_INTRA      = MKPROF(REXT,MAIN_10_INTRA),
+    VLC_HEVC_PROFILE_MAIN_12_INTRA      = MKPROF(REXT,MAIN_12_INTRA),
+    VLC_HEVC_PROFILE_MAIN_422_10_INTRA  = MKPROF(REXT,MAIN_422_10_INTRA),
+    VLC_HEVC_PROFILE_MAIN_422_12_INTRA  = MKPROF(REXT,MAIN_422_12_INTRA),
+    VLC_HEVC_PROFILE_MAIN_444_INTRA     = MKPROF(REXT,MAIN_444_INTRA),
+    VLC_HEVC_PROFILE_MAIN_444_10_INTRA  = MKPROF(REXT,MAIN_444_10_INTRA),
+    VLC_HEVC_PROFILE_MAIN_444_12_INTRA  = MKPROF(REXT,MAIN_444_12_INTRA),
+    VLC_HEVC_PROFILE_MAIN_444_16_INTRA  = MKPROF(REXT,MAIN_444_16_INTRA),
+    VLC_HEVC_PROFILE_MAIN_444_STILL_PICTURE = MKPROF(REXT,MAIN_444_STILL_PICTURE),
+    VLC_HEVC_PROFILE_MAIN_444_16_STILL_PICTURE = MKPROF(REXT,MAIN_444_16_STILL_PICTURE),
+    /* high thoughput */
+    VLC_HEVC_PROFILE_HIGH_THROUGHPUT_444 = MKPROF(HIGH_THROUGHPUT,444),
+    VLC_HEVC_PROFILE_HIGH_THROUGHPUT_444_10 = MKPROF(HIGH_THROUGHPUT,444_10),
+    VLC_HEVC_PROFILE_HIGH_THROUGHPUT_444_14 = MKPROF(HIGH_THROUGHPUT,444_14),
+    VLC_HEVC_PROFILE_HIGH_THROUGHPUT_444_16_INTRA = MKPROF(HIGH_THROUGHPUT,444_16_INTRA),
+    /**/
+    VLC_HEVC_PROFILE_MULTIVIEW_MAIN     = HEVC_PROFILE_IDC_MULTIVIEW_MAIN,
+    VLC_HEVC_PROFILE_SCALABLE_MAIN      = HEVC_PROFILE_IDC_SCALABLE_MAIN,
+    VLC_HEVC_PROFILE_3D_MAIN            = HEVC_PROFILE_IDC_3D_MAIN,
+    /* screen extended */
+    VLC_HEVC_PROFILE_SCREEN_EXTENDED_MAIN                   = MKPROF(SCREEN_EXTENDED,MAIN),
+    VLC_HEVC_PROFILE_SCREEN_EXTENDED_MAIN_10                = MKPROF(SCREEN_EXTENDED,MAIN_10),
+    VLC_HEVC_PROFILE_SCREEN_EXTENDED_MAIN_444               = MKPROF(SCREEN_EXTENDED,MAIN_444),
+    VLC_HEVC_PROFILE_SCREEN_EXTENDED_MAIN_444_10            = MKPROF(SCREEN_EXTENDED,MAIN_444_10),
+    VLC_HEVC_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444_14 = MKPROF(SCREEN_EXTENDED,HIGH_THROUGHPUT_444_14),
+    /* scalable rext */
+    VLC_HEVC_PROFILE_SCALABLE_REXT      = 10,
+};
+#undef MKPROF
+/* vlc_hevc_profile helpers */
+#define vlc_hevc_profile_is_Intra(p) (p && (1 << (2+HEVC_INDICATION_SHIFT)))
 
 /* NAL types from https://www.itu.int/rec/T-REC-H.265-201504-I */
 enum hevc_nal_unit_type_e
@@ -201,6 +277,8 @@ uint8_t hevc_get_slice_pps_id( const hevc_slice_segment_header_t * );
 bool hevc_get_xps_id(const uint8_t *p_nalbuf, size_t i_nalbuf, uint8_t *pi_id);
 bool hevc_get_sps_profile_tier_level( const hevc_sequence_parameter_set_t *,
                                       uint8_t *pi_profile, uint8_t *pi_level );
+enum vlc_hevc_profile_e
+     hevc_get_vlc_profile( const hevc_sequence_parameter_set_t * );
 bool hevc_get_picture_size( const hevc_sequence_parameter_set_t *, unsigned *p_w, unsigned *p_h,
                             unsigned *p_vw, unsigned *p_vh );
 bool hevc_get_frame_rate( const hevc_sequence_parameter_set_t *,



More information about the vlc-commits mailing list