diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2018-02-26 17:26:07 +0100 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2018-03-05 13:22:12 -0500 |
commit | 9f25fcdfc9959bc8fd1154d233b567b36b06e278 (patch) | |
tree | 4e7a26b5392ec346690cfa6d113694d262d04693 /gst-libs | |
parent | 977af86e8b413f953e24c830f1346b741c627e95 (diff) |
h265parse: add support for 'Format range extensions profiles'
Those profiles have been introduced in version 2 of the HEVC spec
(A.3.5).
https://bugzilla.gnome.org/show_bug.cgi?id=793876
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/codecparsers/gsth265parser.c | 87 | ||||
-rw-r--r-- | gst-libs/gst/codecparsers/gsth265parser.h | 42 |
2 files changed, 127 insertions, 2 deletions
diff --git a/gst-libs/gst/codecparsers/gsth265parser.c b/gst-libs/gst/codecparsers/gsth265parser.c index 01f9d587a..495f42066 100644 --- a/gst-libs/gst/codecparsers/gsth265parser.c +++ b/gst-libs/gst/codecparsers/gsth265parser.c @@ -2642,6 +2642,88 @@ gst_h265_quant_matrix_8x8_get_raster_from_uprightdiagonal (guint8 out_quant[64], out_quant[uprightdiagonal_8x8[i]] = quant[i]; } +typedef struct +{ + GstH265Profile profile; + + guint8 max_12bit_constraint_flag; + guint8 max_10bit_constraint_flag; + guint8 max_8bit_constraint_flag; + guint8 max_422chroma_constraint_flag; + guint8 max_420chroma_constraint_flag; + guint8 max_monochrome_constraint_flag; + guint8 intra_constraint_flag; + guint8 one_picture_only_constraint_flag; + gboolean lower_bit_rate_constraint_flag_set; +} FormatRangeExtensionProfile; + +static GstH265Profile +get_format_range_extension_profile (GstH265ProfileTierLevel * ptl) +{ + /* See Table A.2 for the definition of those formats */ + FormatRangeExtensionProfile profiles[] = { + {GST_H265_PROFILE_MONOCHROME, 1, 1, 1, 1, 1, 1, 0, 0, TRUE}, + {GST_H265_PROFILE_MONOCHROME_12, 1, 0, 0, 1, 1, 1, 0, 0, TRUE}, + {GST_H265_PROFILE_MONOCHROME_16, 0, 0, 0, 1, 1, 1, 0, 0, TRUE}, + {GST_H265_PROFILE_MAIN_12, 1, 0, 0, 1, 1, 0, 0, 0, TRUE}, + {GST_H265_PROFILE_MAIN_422_10, 1, 1, 0, 1, 0, 0, 0, 0, TRUE}, + {GST_H265_PROFILE_MAIN_422_12, 1, 0, 0, 1, 0, 0, 0, 0, TRUE}, + {GST_H265_PROFILE_MAIN_444, 1, 1, 1, 0, 0, 0, 0, 0, TRUE}, + {GST_H265_PROFILE_MAIN_444_10, 1, 1, 0, 0, 0, 0, 0, 0, TRUE}, + {GST_H265_PROFILE_MAIN_444_12, 1, 0, 0, 0, 0, 0, 0, 0, TRUE}, + {GST_H265_PROFILE_MAIN_INTRA, 1, 1, 1, 1, 1, 0, 1, 0, FALSE}, + {GST_H265_PROFILE_MAIN_10_INTRA, 1, 1, 0, 1, 1, 0, 1, 0, FALSE}, + {GST_H265_PROFILE_MAIN_12_INTRA, 1, 0, 0, 1, 1, 0, 1, 0, FALSE}, + {GST_H265_PROFILE_MAIN_422_10_INTRA, 1, 1, 0, 1, 0, 0, 1, 0, FALSE}, + {GST_H265_PROFILE_MAIN_422_12_INTRA, 1, 0, 0, 1, 0, 0, 1, 0, FALSE}, + {GST_H265_PROFILE_MAIN_444_INTRA, 1, 1, 1, 0, 0, 0, 1, 0, FALSE}, + {GST_H265_PROFILE_MAIN_444_10_INTRA, 1, 1, 0, 0, 0, 0, 1, 0, FALSE}, + {GST_H265_PROFILE_MAIN_444_12_INTRA, 1, 0, 0, 0, 0, 0, 1, 0, FALSE}, + {GST_H265_PROFILE_MAIN_444_16_INTRA, 0, 0, 0, 0, 0, 0, 1, 0, FALSE}, + {GST_H265_PROFILE_MAIN_444_STILL_PICTURE, 1, 1, 1, 0, 0, 0, 1, 1, FALSE}, + {GST_H265_PROFILE_MAIN_444_16_STILL_PICTURE, 0, 0, 0, 0, 0, 0, 1, 1, FALSE}, + }; + guint i; + + for (i = 0; i < G_N_ELEMENTS (profiles); i++) { + FormatRangeExtensionProfile p = profiles[i]; + + if (p.max_12bit_constraint_flag != ptl->max_12bit_constraint_flag) + continue; + if (p.max_10bit_constraint_flag != ptl->max_10bit_constraint_flag) + continue; + if (p.max_8bit_constraint_flag != ptl->max_8bit_constraint_flag) + continue; + if (p.max_422chroma_constraint_flag != ptl->max_422chroma_constraint_flag) + continue; + if (p.max_420chroma_constraint_flag != ptl->max_420chroma_constraint_flag) + continue; + if (p.max_monochrome_constraint_flag != ptl->max_monochrome_constraint_flag) + continue; + if (p.intra_constraint_flag != ptl->intra_constraint_flag) + continue; + if (p.one_picture_only_constraint_flag != + ptl->one_picture_only_constraint_flag) + continue; + if (p.lower_bit_rate_constraint_flag_set + && !ptl->lower_bit_rate_constraint_flag) + continue; + + return p.profile; + } + + return GST_H265_PROFILE_INVALID; +} + +/** + * gst_h265_profile_tier_level_get_profile: + * @ptl: a #GstH265ProfileTierLevel + * + * Return the H265 profile defined in @ptl. + * + * Returns: a #GstH265Profile + * Since: 1.14 + */ GstH265Profile gst_h265_profile_tier_level_get_profile (GstH265ProfileTierLevel * ptl) { @@ -2657,8 +2739,11 @@ gst_h265_profile_tier_level_get_profile (GstH265ProfileTierLevel * ptl) || ptl->profile_compatibility_flag[3]) return GST_H265_PROFILE_MAIN_STILL_PICTURE; + if (ptl->profile_idc == GST_H265_PROFILE_IDC_FORMAT_RANGE_EXTENSION + || ptl->profile_compatibility_flag[4]) + return get_format_range_extension_profile (ptl); + /* TODO: - * - GST_H265_PROFILE_IDC_FORMAT_RANGE_EXTENSION * - GST_H265_PROFILE_IDC_HIGH_THROUGHPUT * - GST_H265_PROFILE_IDC_SCREEN_CONTENT_CODING */ diff --git a/gst-libs/gst/codecparsers/gsth265parser.h b/gst-libs/gst/codecparsers/gsth265parser.h index 45c5e5484..985e1b565 100644 --- a/gst-libs/gst/codecparsers/gsth265parser.h +++ b/gst-libs/gst/codecparsers/gsth265parser.h @@ -46,6 +46,26 @@ G_BEGIN_DECLS * @GST_H265_PROFILE_MAIN: Main profile (A.3.2) * @GST_H265_PROFILE_MAIN_10: Main 10 profile (A.3.3) * @GST_H265_PROFILE_MAIN_STILL_PICTURE: Main Still Picture profile (A.3.4) + * @GST_H265_PROFILE_MONOCHROME: Monochrome profile (A.3.4) + * @GST_H265_PROFILE_MONOCHROME_12: Monochrome 12-bits profile (A.3.4) + * @GST_H265_PROFILE_MONOCHROME_16: Monochrome 16-bits profile (A.3.4) + * @GST_H265_PROFILE_MAIN_12: Main profile 12-bits (A.3.4) + * @GST_H265_PROFILE_MAIN_422_10: Main 4:2:2 profile 10-bits (A.3.4) + * @GST_H265_PROFILE_MAIN_422_12: Main 4:2:2 profile 12-bits (A.3.4) + * @GST_H265_PROFILE_MAIN_444: Main 4:4:4 profile (A.3.4) + * @GST_H265_PROFILE_MAIN_444_10: Main 4:4:4 10-bits profile (A.3.4) + * @GST_H265_PROFILE_MAIN_444_12: Main 4:4:4 12-bits profile (A.3.4) + * @GST_H265_PROFILE_MAIN_INTRA: Main Intra profile (A.3.4) + * @GST_H265_PROFILE_MAIN_10_INTRA: Main Intra 10-bits profile (A.3.4) + * @GST_H265_PROFILE_MAIN_12_INTRA: Main Intra 12-bits profile (A.3.4) + * @GST_H265_PROFILE_MAIN_422_10_INTRA: Main Intra 4:2:2 10-bits profile (A.3.4) + * @GST_H265_PROFILE_MAIN_422_12_INTRA: Main Intra 4:2:2 12-bits profile (A.3.4) + * @GST_H265_PROFILE_MAIN_444_INTRA: Main Intra 4:4:4 profile (A.3.4) + * @GST_H265_PROFILE_MAIN_444_10_INTRA: Main Intra 4:4:4 10-bits profile (A.3.4) + * @GST_H265_PROFILE_MAIN_444_12_INTRA: Main Intra 4:4:4 12-bits profile (A.3.4) + * @GST_H265_PROFILE_MAIN_444_16_INTRA: Main Intra 4:4:4 16-bits profile (A.3.4) + * @GST_H265_PROFILE_MAIN_444_STILL_PICTURE: Main 4:4:4 Still Picture profile (A.3.4) + * @GST_H265_PROFILE_MAIN_444_16_STILL_PICTURE: Main 4:4:4 16-bits Still Picture profile (A.3.4) * * H.265 Profiles. * @@ -54,7 +74,27 @@ typedef enum { GST_H265_PROFILE_INVALID = -1, GST_H265_PROFILE_MAIN = 1, GST_H265_PROFILE_MAIN_10 = 2, - GST_H265_PROFILE_MAIN_STILL_PICTURE = 3 + GST_H265_PROFILE_MAIN_STILL_PICTURE = 3, + GST_H265_PROFILE_MONOCHROME, + GST_H265_PROFILE_MONOCHROME_12, + GST_H265_PROFILE_MONOCHROME_16, + GST_H265_PROFILE_MAIN_12, + GST_H265_PROFILE_MAIN_422_10, + GST_H265_PROFILE_MAIN_422_12, + GST_H265_PROFILE_MAIN_444, + GST_H265_PROFILE_MAIN_444_10, + GST_H265_PROFILE_MAIN_444_12, + GST_H265_PROFILE_MAIN_INTRA, + GST_H265_PROFILE_MAIN_10_INTRA, + GST_H265_PROFILE_MAIN_12_INTRA, + GST_H265_PROFILE_MAIN_422_10_INTRA, + GST_H265_PROFILE_MAIN_422_12_INTRA, + GST_H265_PROFILE_MAIN_444_INTRA, + GST_H265_PROFILE_MAIN_444_10_INTRA, + GST_H265_PROFILE_MAIN_444_12_INTRA, + GST_H265_PROFILE_MAIN_444_16_INTRA, + GST_H265_PROFILE_MAIN_444_STILL_PICTURE, + GST_H265_PROFILE_MAIN_444_16_STILL_PICTURE, } GstH265Profile; /** |