Files
gst-nvvideo4linux2/gst-v4l2/gstv4l2h26xparser.h
svcmobrel-release 030ffa51d5 Updating prebuilts and/or headers
ed8273ff6102bb0b4fa7975a401b12b3e95a7187 - nvbufsurface.h
270379cd6bd312a0164ae9763879548928114222 - v4l2_nv_extensions.h
d27a433ddeaefb9f42d0312c23472514b0cd6a45 - gst-nvcustomevent.h
3f7cafe5beb4395caf2e1591bf0a835e5076031a - gst-v4l2/gstv4l2object.h
e8e973c103725b65232d32817e0305d12d6ff309 - gst-v4l2/gstv4l2h264enc.c
c2099692cdb374440c2a040cb6ad01bbc1549ce5 - gst-v4l2/gstv4l2h26xparser.h
a002edef13a3bbbdc41e42a7fca40e574ad1bb3e - gst-v4l2/v4l2-utils.c
5948d70c07e87f9b1dc403789dcbed6acfa47ad9 - gst-v4l2/gstv4l2av1enc.c
4e79cf75c4fa29791e1f5141318dc8aec13a7835 - gst-v4l2/nalutils.h
9f726e4439379bb399f29c68736242f21dab3dd0 - gst-v4l2/gstv4l2allocator.c
49a66f0ce02abc71f33e096a65645ddedf5c7f46 - gst-v4l2/gstv4l2bufferpool.c
b827fd6cb1e3b8ecebd6a07f8556e846e26cba17 - gst-v4l2/gstv4l2allocator.h
dc1a3f7292873f1f71dc27300f97f3ab918ed79f - gst-v4l2/gstv4l2h265enc.c
65de802e5f162aa04518b7ade5841cc3ced01111 - gst-v4l2/Makefile
c81eacb7d88c4fb839506dd70055e30d7a9feeec - gst-v4l2/v4l2-utils.h
39fcb2f599e6906ab0fd7ab9a46fef3ea58a8cab - gst-v4l2/gstv4l2vp8enc.h
d89a680415f6ff5acec2571cde0fce9054d8e81f - gst-v4l2/gstv4l2vp9enc.h
bb104683f5e4f7402e3f765a891e149edc794e02 - gst-v4l2/gstv4l2h264enc.h
71be284b547ee68fb0e2cd14b0aeb14734a915a1 - gst-v4l2/gstv4l2bufferpool.h
02d142337f4b96fcb0c9f2405a3cbe90c5917cca - gst-v4l2/gstv4l2vp9enc.c
73b03969d7ae0a8adb374c93999c43af88ea93b2 - gst-v4l2/v4l2_calls.c
b1cd923335aa60985ff9866fba91a2068e8671c7 - gst-v4l2/LICENSE.gst-nvvideo4linux2
b52a5ee4c739818736b9a3683442df285ebe9eda - gst-v4l2/gstv4l2videodec.c
cbc84dccd2506afa4c8f03849c95bb28c83ef4a3 - gst-v4l2/gstv4l2av1enc.h
21a860247c06670e4619b8eaae1d92db31bdd3e8 - gst-v4l2/gstv4l2.c
489fde70531590e94d1d211a42f10f81ae68d2b9 - gst-v4l2/gstv4l2videoenc.h
d29e3a719400c3cb27314366d48ec792a3c12363 - gst-v4l2/gstv4l2h265enc.h
5ecd059e5ef9be4014eface37e5e2f7598960f4e - gst-v4l2/nalutils.c
807bc9859585a540b0f85e98f147756aab24e1bd - gst-v4l2/gstv4l2vp8enc.c
99d65d620807b5ba1ca29a838e032940c9b019cc - gst-v4l2/sei_parse.c
398c24d1eef98ec9003a06587bc3784050602cd2 - gst-v4l2/gstv4l2h26xparser.c
d5952b0286c34bf13fbf5e09fe552ced0da49368 - gst-v4l2/gstv4l2videodec.h
9681f7b98dfdfbc4d845f9ce7f11c3692b923195 - gst-v4l2/gstv4l2videoenc.c
884e5b97b9fa8d07b6153e6efe6999884922b813 - gst-v4l2/gstv4l2object.c
e864ee6647f3572b144403d799f68152e9900da1 - gst-v4l2/gst/gettext.h
20c4f7c0cb89c83256650bc3353ed82154cf3a9d - gst-v4l2/gst/gst-i18n-plugin.h
499a9feb17ceabf1f1443923dffa1e0180bf5972 - gst-v4l2/gst/glib-compat-private.h
a745675b051a2b8434a430c80fde3f245864ca89 - gst-v4l2/ext/v4l2-common.h
1636366b5a062e4bc1791b7bc3012ccf5635b363 - gst-v4l2/ext/v4l2-controls.h
72a34a694337f8f6da3bb94c9faced6730cbd2fc - gst-v4l2/ext/types-compat.h
522ab8fc8531a2c758b9278d29642f5b763fd3e7 - gst-v4l2/ext/videodev2.h

Change-Id: I20d51e375de708d355ddcee9c38d9d23ef012960
2024-02-26 22:27:31 -08:00

463 lines
13 KiB
C

/*
* Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef __H26X_PARSER_H__
#define __H26X_PARSER_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define H264_MAX_SPS_COUNT 32
typedef enum
{
H264_NAL_UNKNOWN = 0,
H264_NAL_SLICE = 1,
H264_NAL_SLICE_DPA = 2,
H264_NAL_SLICE_DPB = 3,
H264_NAL_SLICE_DPC = 4,
H264_NAL_SLICE_IDR = 5,
H264_NAL_SEI = 6,
H264_NAL_SPS = 7,
H264_NAL_PPS = 8,
H264_NAL_AU_DELIMITER = 9,
H264_NAL_SEQ_END = 10,
H264_NAL_STREAM_END = 11,
H264_NAL_FILLER_DATA = 12,
H264_NAL_SPS_EXT = 13,
H264_NAL_PREFIX_UNIT = 14,
H264_NAL_SUBSET_SPS = 15,
H264_NAL_DEPTH_SPS = 16,
H264_NAL_SLICE_AUX = 19,
H264_NAL_SLICE_EXT = 20,
H264_NAL_SLICE_DEPTH = 21
} H264NalUnitType;
typedef enum
{
H264_NAL_EXTENSION_NONE = 0,
H264_NAL_EXTENSION_SVC,
H264_NAL_EXTENSION_MVC,
} H264NalUnitExtensionType;
typedef enum
{
H264_PARSER_OK,
H264_PARSER_BROKEN_DATA,
H264_PARSER_BROKEN_LINK,
H264_PARSER_ERROR,
H264_PARSER_NO_NAL,
H264_PARSER_NO_NAL_END
} H264ParserResult;
typedef enum
{
H264_FRAME_PACKING_NONE = 6,
H264_FRAME_PACKING_CHECKERBOARD_INTERLEAVING = 0,
H264_FRAME_PACKING_COLUMN_INTERLEAVING = 1,
H264_FRAME_PACKING_ROW_INTERLEAVING = 2,
H264_FRAME_PACKING_SIDE_BY_SIDE = 3,
H264_FRMAE_PACKING_TOP_BOTTOM = 4,
H264_FRAME_PACKING_TEMPORAL_INTERLEAVING = 5
} H264FramePackingType;
typedef enum
{
H264_P_SLICE = 0,
H264_B_SLICE = 1,
H264_I_SLICE = 2,
H264_SP_SLICE = 3,
H264_SI_SLICE = 4,
H264_S_P_SLICE = 5,
H264_S_B_SLICE = 6,
H264_S_I_SLICE = 7,
H264_S_SP_SLICE = 8,
H264_S_SI_SLICE = 9
} H264SliceType;
typedef enum
{
H264_CT_TYPE_PROGRESSIVE = 0,
H264_CT_TYPE_INTERLACED = 1,
H264_CT_TYPE_UNKNOWN = 2,
} CtType;
typedef struct _H264NalParser H264NalParser;
typedef struct _H264NalUnit H264NalUnit;
typedef struct _H264SPS H264SPS;
struct _H264NalUnit
{
guint16 ref_idc;
guint16 type;
/* calculated values */
guint8 idr_pic_flag;
guint size;
guint offset;
guint sc_offset;
gboolean valid;
guint8 *data;
guint8 header_bytes;
guint8 extension_type;
};
struct _H264SPS
{
gint id;
guint8 profile_idc;
guint8 constraint_set0_flag;
guint8 constraint_set1_flag;
guint8 constraint_set2_flag;
guint8 constraint_set3_flag;
guint8 constraint_set4_flag;
guint8 constraint_set5_flag;
guint8 level_idc;
guint8 chroma_format_idc;
guint8 separate_colour_plane_flag;
guint8 bit_depth_luma_minus8;
guint8 bit_depth_chroma_minus8;
guint8 qpprime_y_zero_transform_bypass_flag;
guint8 scaling_matrix_present_flag;
guint8 scaling_lists_4x4[6][16];
guint8 scaling_lists_8x8[6][64];
guint8 log2_max_frame_num_minus4;
guint8 pic_order_cnt_type;
/* if pic_order_cnt_type == 0 */
guint8 log2_max_pic_order_cnt_lsb_minus4;
/* else if pic_order_cnt_type == 1 */
guint8 delta_pic_order_always_zero_flag;
gint32 offset_for_non_ref_pic;
gint32 offset_for_top_to_bottom_field;
guint8 num_ref_frames_in_pic_order_cnt_cycle;
gint32 offset_for_ref_frame[255];
guint32 num_ref_frames;
guint8 gaps_in_frame_num_value_allowed_flag;
guint32 pic_width_in_mbs_minus1;
guint32 pic_height_in_map_units_minus1;
guint8 frame_mbs_only_flag;
guint8 mb_adaptive_frame_field_flag;
guint8 direct_8x8_inference_flag;
guint8 frame_cropping_flag;
/* if frame_cropping_flag */
guint32 frame_crop_left_offset;
guint32 frame_crop_right_offset;
guint32 frame_crop_top_offset;
guint32 frame_crop_bottom_offset;
guint8 vui_parameters_present_flag;
/* calculated values */
guint8 chroma_array_type;
guint32 max_frame_num;
gint width, height;
gint crop_rect_width, crop_rect_height;
gint crop_rect_x, crop_rect_y;
gint fps_num_removed, fps_den_removed; /* FIXME: remove */
gboolean valid;
/* Subset SPS extensions */
guint8 extension_type;
};
struct _H264NalParser
{
/*< private >*/
H264SPS sps[H264_MAX_SPS_COUNT];
H264SPS *last_sps;
};
H264NalParser *h264_nal_parser_new (void);
H264ParserResult h264_parser_identify_nalu (H264NalParser *nalparser,
const guint8 *data, guint offset,
gsize size, H264NalUnit *nalu);
H264ParserResult h264_parser_identify_nalu_unchecked (H264NalParser *nalparser,
const guint8 *data, guint offset,
gsize size, H264NalUnit *nalu);
H264ParserResult h264_parser_parse_sps (H264NalParser *nalparser, H264NalUnit *nalu,
H264SPS *sps, gboolean parse_vui_params);
void h264_nal_parser_free (H264NalParser *nalparser);
H264ParserResult h264_parse_sps (H264NalUnit *nalu,
H264SPS *sps, gboolean parse_vui_params);
void h264_sps_clear (H264SPS *sps);
#define H265_MAX_SUB_LAYERS 8
#define H265_MAX_SPS_COUNT 16
typedef enum
{
H265_NAL_SLICE_TRAIL_N = 0,
H265_NAL_SLICE_TRAIL_R = 1,
H265_NAL_SLICE_TSA_N = 2,
H265_NAL_SLICE_TSA_R = 3,
H265_NAL_SLICE_STSA_N = 4,
H265_NAL_SLICE_STSA_R = 5,
H265_NAL_SLICE_RADL_N = 6,
H265_NAL_SLICE_RADL_R = 7,
H265_NAL_SLICE_RASL_N = 8,
H265_NAL_SLICE_RASL_R = 9,
H265_NAL_SLICE_BLA_W_LP = 16,
H265_NAL_SLICE_BLA_W_RADL = 17,
H265_NAL_SLICE_BLA_N_LP = 18,
H265_NAL_SLICE_IDR_W_RADL = 19,
H265_NAL_SLICE_IDR_N_LP = 20,
H265_NAL_SLICE_CRA_NUT = 21,
H265_NAL_VPS = 32,
H265_NAL_SPS = 33,
H265_NAL_PPS = 34,
H265_NAL_AUD = 35,
H265_NAL_EOS = 36,
H265_NAL_EOB = 37,
H265_NAL_FD = 38,
H265_NAL_PREFIX_SEI = 39,
H265_NAL_SUFFIX_SEI = 40
} H265NalUnitType;
typedef enum
{
H265_PARSER_OK,
H265_PARSER_BROKEN_DATA,
H265_PARSER_BROKEN_LINK,
H265_PARSER_ERROR,
H265_PARSER_NO_NAL,
H265_PARSER_NO_NAL_END
} H265ParserResult;
typedef struct _H265Parser H265Parser;
typedef struct _H265NalUnit H265NalUnit;
typedef struct _H265SPS H265SPS;
typedef struct _H265ProfileTierLevel H265ProfileTierLevel;
struct _H265NalUnit
{
guint8 type;
guint8 layer_id;
guint8 temporal_id_plus1;
/* calculated values */
guint size;
guint offset;
guint sc_offset;
gboolean valid;
guint8 *data;
guint8 header_bytes;
};
struct _H265ProfileTierLevel {
guint8 profile_space;
guint8 tier_flag;
guint8 profile_idc;
guint8 profile_compatibility_flag[32];
guint8 progressive_source_flag;
guint8 interlaced_source_flag;
guint8 non_packed_constraint_flag;
guint8 frame_only_constraint_flag;
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;
guint8 lower_bit_rate_constraint_flag;
guint8 max_14bit_constraint_flag;
guint8 level_idc;
guint8 sub_layer_profile_present_flag[6];
guint8 sub_layer_level_present_flag[6];
guint8 sub_layer_profile_space[6];
guint8 sub_layer_tier_flag[6];
guint8 sub_layer_profile_idc[6];
guint8 sub_layer_profile_compatibility_flag[6][32];
guint8 sub_layer_progressive_source_flag[6];
guint8 sub_layer_interlaced_source_flag[6];
guint8 sub_layer_non_packed_constraint_flag[6];
guint8 sub_layer_frame_only_constraint_flag[6];
guint8 sub_layer_level_idc[6];
};
struct _H265SPS
{
guint8 id;
guint8 max_sub_layers_minus1;
guint8 temporal_id_nesting_flag;
H265ProfileTierLevel profile_tier_level;
guint8 chroma_format_idc;
guint8 separate_colour_plane_flag;
guint16 pic_width_in_luma_samples;
guint16 pic_height_in_luma_samples;
guint8 conformance_window_flag;
/* if conformance_window_flag */
guint32 conf_win_left_offset;
guint32 conf_win_right_offset;
guint32 conf_win_top_offset;
guint32 conf_win_bottom_offset;
guint8 bit_depth_luma_minus8;
guint8 bit_depth_chroma_minus8;
guint8 log2_max_pic_order_cnt_lsb_minus4;
guint8 sub_layer_ordering_info_present_flag;
guint8 max_dec_pic_buffering_minus1[H265_MAX_SUB_LAYERS];
guint8 max_num_reorder_pics[H265_MAX_SUB_LAYERS];
guint8 max_latency_increase_plus1[H265_MAX_SUB_LAYERS];
guint8 log2_min_luma_coding_block_size_minus3;
guint8 log2_diff_max_min_luma_coding_block_size;
guint8 log2_min_transform_block_size_minus2;
guint8 log2_diff_max_min_transform_block_size;
guint8 max_transform_hierarchy_depth_inter;
guint8 max_transform_hierarchy_depth_intra;
guint8 scaling_list_enabled_flag;
/* if scaling_list_enabled_flag */
guint8 scaling_list_data_present_flag;
guint8 amp_enabled_flag;
guint8 sample_adaptive_offset_enabled_flag;
guint8 pcm_enabled_flag;
/* if pcm_enabled_flag */
guint8 pcm_sample_bit_depth_luma_minus1;
guint8 pcm_sample_bit_depth_chroma_minus1;
guint8 log2_min_pcm_luma_coding_block_size_minus3;
guint8 log2_diff_max_min_pcm_luma_coding_block_size;
guint8 pcm_loop_filter_disabled_flag;
guint8 num_short_term_ref_pic_sets;
guint8 long_term_ref_pics_present_flag;
/* if long_term_ref_pics_present_flag */
guint8 num_long_term_ref_pics_sps;
guint16 lt_ref_pic_poc_lsb_sps[32];
guint8 used_by_curr_pic_lt_sps_flag[32];
guint8 temporal_mvp_enabled_flag;
guint8 strong_intra_smoothing_enabled_flag;
guint8 vui_parameters_present_flag;
/* if vui_parameters_present_flat */
guint8 sps_extension_flag;
/* calculated values */
guint8 chroma_array_type;
gint width, height;
gint crop_rect_width, crop_rect_height;
gint crop_rect_x, crop_rect_y;
gint fps_num, fps_den;
gboolean valid;
};
struct _H265Parser
{
/*< private >*/
H265SPS sps[H265_MAX_SPS_COUNT];
H265SPS *last_sps;
};
H265Parser * h265_parser_new (void);
H265ParserResult h265_parser_identify_nalu (H265Parser * parser,
const guint8 * data,
guint offset,
gsize size,
H265NalUnit * nalu);
H265ParserResult h265_parser_identify_nalu_unchecked (H265Parser * parser,
const guint8 * data,
guint offset,
gsize size,
H265NalUnit * nalu);
H265ParserResult h265_parser_identify_nalu_hevc (H265Parser * parser,
const guint8 * data,
guint offset,
gsize size,
guint8 nal_length_size,
H265NalUnit * nalu);
H265ParserResult h265_parser_parse_sps (H265Parser * parser,
H265NalUnit * nalu,
H265SPS * sps,
gboolean parse_vui_params);
void h265_parser_free (H265Parser * parser);
H265ParserResult h265_parse_sps (H265Parser * parser,
H265NalUnit * nalu,
H265SPS * sps,
gboolean parse_vui_params);
G_END_DECLS
#endif