211 lines
5.4 KiB
C
211 lines
5.4 KiB
C
/*
|
|
* Copyright (c) 2025 Quaming Intelligent Technology Co., Ltd.
|
|
*
|
|
* All Rights Reserved.
|
|
* Confidential and Proprietary - Quaming Intelligent Technology Co., Ltd.
|
|
*/
|
|
|
|
#ifndef _QUA_H2645_PARSE_H_
|
|
#define _QUA_H2645_PARSE_H_
|
|
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include "utils/qua_bitread.h"
|
|
#include "utils/qua_h264_pps.h"
|
|
#include "utils/qua_h264_sps.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define MAX_REORDER_TIMES 33
|
|
#define MAX_MARKING_TIMES 35
|
|
|
|
typedef enum {
|
|
QUA_VIDEO_CODING_H264,
|
|
QUA_VIDEO_CODING_H265,
|
|
} qua_video_type_t;
|
|
|
|
typedef enum {
|
|
QUA_H264_NAL_UNSPECIFIED,
|
|
QUA_H264_NAL_SLICE,
|
|
QUA_H264_NAL_DPA,
|
|
QUA_H264_NAL_DPB,
|
|
QUA_H264_NAL_DPC,
|
|
QUA_H264_NAL_IDR_SLICE,
|
|
QUA_H264_NAL_SEI,
|
|
QUA_H264_NAL_SPS,
|
|
QUA_H264_NAL_PPS,
|
|
QUA_H264_NAL_AUD,
|
|
QUA_H264_NAL_END_SEQUENCE,
|
|
QUA_H264_NAL_END_STREAM,
|
|
QUA_H264_NAL_FILLER_DATA,
|
|
QUA_H264_NAL_SPS_EXT,
|
|
QUA_H264_NAL_PREFIX,
|
|
QUA_H264_NAL_SUB_SPS,
|
|
QUA_H264_NAL_DPS,
|
|
QUA_H264_NAL_RESERVED17,
|
|
QUA_H264_NAL_RESERVED18,
|
|
QUA_H264_NAL_AUXILIARY_SLICE,
|
|
QUA_H264_NAL_EXTEN_SLICE,
|
|
QUA_H264_NAL_DEPTH_EXTEN_SLICE,
|
|
QUA_H264_NAL_RESERVED22,
|
|
QUA_H264_NAL_RESERVED23,
|
|
QUA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set_id;
|
|
uint32_t colour_plane_id;
|
|
uint32_t frame_num;
|
|
int32_t field_pic_flag;
|
|
int32_t bottom_field_flag;
|
|
int32_t structure;
|
|
int32_t mb_aff_frame_flag;
|
|
int32_t pic_order_cnt_lsb;
|
|
int32_t delta_pic_order_cnt_bottom;
|
|
int32_t delta_pic_order_cnt[2];
|
|
uint32_t poc_used_bitlen;
|
|
int32_t redundant_pic_cnt;
|
|
int32_t direct_spatial_mv_pred_flag;
|
|
int32_t num_ref_idx_active[2];
|
|
int32_t num_ref_idx_override_flag;
|
|
int32_t ref_pic_list_reordering_flag[2];
|
|
int32_t reordering_of_pic_nums_idc[2][MAX_REORDER_TIMES];
|
|
int32_t abs_diff_pic_num_minus1[2][MAX_REORDER_TIMES];
|
|
int32_t long_term_pic_idx[2][MAX_REORDER_TIMES];
|
|
uint32_t drpm_used_bitlen;
|
|
int32_t no_output_of_prior_pics_flag;
|
|
int32_t long_term_refrence_flag;
|
|
int32_t adaptive_ref_pic_buffering_flag;
|
|
|
|
qua_h264_sps_t active_sps;
|
|
qua_h264_pps_t active_pps;
|
|
uint32_t RefPicListX[2][MAX_REORDER_TIMES];
|
|
uint32_t refIdxLX[2];
|
|
} qua_h264_slice_t;
|
|
|
|
typedef struct {
|
|
union {
|
|
qua_h264_slice_t h264_slice;
|
|
};
|
|
} qua_slice_t;
|
|
|
|
typedef struct {
|
|
uint8_t forbidden_zero_bit;
|
|
uint8_t nal_ref_idc;
|
|
uint8_t nal_unit_type;
|
|
} qua_h264_nalu_t;
|
|
|
|
typedef struct {
|
|
uint8_t forbidden_zero_bit;
|
|
uint8_t nal_unit_type;
|
|
uint8_t nuh_layer_id;
|
|
uint8_t nuh_temporal_id_plus1;
|
|
} qua_h265_nalu_t;
|
|
|
|
typedef struct {
|
|
bitread_ctx_t bit_ctx;
|
|
union {
|
|
qua_h264_nalu_t h264_nalu;
|
|
qua_h265_nalu_t h265_nalu;
|
|
};
|
|
} qua_nalu_t;
|
|
|
|
int32_t qua_h2645_extract_nalu(uint8_t *data, size_t size, size_t *nalSize);
|
|
int32_t qua_h2645_split_codec_nal(uint8_t *data, size_t size, size_t *nalSize);
|
|
int32_t qua_parse_nal_header(qua_video_type_t type, uint8_t *nal);
|
|
int32_t qua_parse_one_nalu(qua_video_type_t type, uint8_t *nal_data, uint32_t nalu_size, qua_nalu_t *nalu);
|
|
int32_t qua_parse_slice_header(qua_video_type_t type, qua_nalu_t *nalu, qua_slice_t *slice);
|
|
void check_refer_picture_lists(qua_slice_t *slice, int32_t *slice_num_pic_refs);
|
|
|
|
const char *qua_hevc_nal_unit_name(int nal_type);
|
|
const char *qua_h264_nal_unit_name(int nal_type);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|