* Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* Description:
* Author: huawei
* Create: 2020-4-1
*/
#ifndef HI_VDEC_H_
#define HI_VDEC_H_
#include "hi_dvpp_common.h"
#include "hi_dvpp_vb.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
#define VDEC_MAX_CHN_NUM 256
#define HI_ERR_VDEC_INVALID_CHN_ID 0xA0058002
#define HI_ERR_VDEC_ILLEGAL_PARAM 0xA0058003
#define HI_ERR_VDEC_EXIST 0xA0058004
#define HI_ERR_VDEC_UNEXIST 0xA0058005
#define HI_ERR_VDEC_NULL_PTR 0xA0058006
#define HI_ERR_VDEC_NOT_CFG 0xA0058007
#define HI_ERR_VDEC_NOT_SUPPORT 0xA0058008
#define HI_ERR_VDEC_NOT_PERM 0xA0058009
#define HI_ERR_VDEC_NO_MEM 0xA005800C
#define HI_ERR_VDEC_NO_BUF 0xA005800D
#define HI_ERR_VDEC_BUF_EMPTY 0xA005800E
#define HI_ERR_VDEC_BUF_FULL 0xA005800F
#define HI_ERR_VDEC_SYS_NOT_READY 0xA0058010
#define HI_ERR_VDEC_BAD_ADDR 0xA0058011
#define HI_ERR_VDEC_BUSY 0xA0058012
#define HI_ERR_VDEC_SYS_ERROR 0xA0058015
typedef hi_s32 hi_vdec_chn;
typedef enum {
HI_VDEC_SEND_MODE_STREAM = 0,
HI_VDEC_SEND_MODE_FRAME,
HI_VDEC_SEND_MODE_COMPAT,
HI_VDEC_SEND_MODE_BUTT
} hi_vdec_send_mode;
typedef enum {
HI_VIDEO_DEC_MODE_IPB = 0,
HI_VIDEO_DEC_MODE_IP,
HI_VIDEO_DEC_MODE_I,
HI_VIDEO_DEC_MODE_BUTT
} hi_video_dec_mode;
typedef enum {
HI_VDEC_FRAME_TYPE_I = 0,
HI_VDEC_FRAME_TYPE_P = 1,
HI_VDEC_FRAME_TYPE_B = 2,
HI_VDEC_FRAME_TYPE_BUTT
} hi_vdec_frame_type;
typedef enum {
HI_QUICK_MARK_ADAPT = 0,
HI_QUICK_MARK_FORCE,
HI_QUICK_MARK_NONE,
HI_QUICK_MARK_BUTT
} hi_quick_mark_mode;
typedef struct {
hi_vdec_frame_type frame_type;
hi_u32 err_rate;
hi_u32 poc;
} hi_vdec_video_supplement_info;
typedef struct {
hi_payload_type type;
union {
hi_vdec_video_supplement_info video_supplement_info;
};
} hi_vdec_supplement_info;
typedef struct {
hi_s32 set_pic_size_err;
hi_s32 set_protocol_num_err;
hi_s32 set_ref_num_err;
hi_s32 set_pic_buf_size_err;
hi_s32 format_err;
hi_s32 stream_unsupport;
hi_s32 pack_err;
hi_s32 stream_size_over;
hi_s32 stream_not_release;
} hi_vdec_dec_err;
typedef struct {
hi_payload_type type;
hi_u32 left_stream_bytes;
hi_u32 left_stream_frames;
hi_u32 left_decoded_frames;
hi_bool is_started;
hi_u32 recv_stream_frames;
hi_u32 dec_stream_frames;
hi_vdec_dec_err dec_err;
hi_u32 width;
hi_u32 height;
hi_u64 latest_frame_pts;
} hi_vdec_chn_status;
typedef struct {
hi_u32 ref_frame_num;
hi_bool temporal_mvp_en;
hi_u32 tmv_buf_size;
} hi_vdec_video_attr;
typedef struct {
hi_payload_type type;
hi_vdec_send_mode mode;
hi_u32 pic_width;
hi_u32 pic_height;
hi_u32 stream_buf_size;
hi_u32 frame_buf_size;
hi_u32 frame_buf_cnt;
union {
hi_vdec_video_attr video_attr;
};
} hi_vdec_chn_attr;
typedef struct {
hi_bool end_of_frame;
hi_bool end_of_stream;
hi_bool need_display;
hi_u64 pts;
hi_u64 private_data;
hi_u32 len;
hi_u8 *ATTRIBUTE addr;
} hi_vdec_stream;
typedef struct {
hi_bool composite_dec_en;
hi_bool slice_input_en;
hi_s32 err_threshold;
hi_video_dec_mode dec_mode;
hi_video_out_order out_order;
hi_compress_mode compress_mode;
hi_video_format video_format;
hi_quick_mark_mode quick_mark_mode;
} hi_vdec_video_param;
typedef struct {
hi_pixel_format pixel_format;
hi_u32 alpha;
} hi_vdec_pic_param;
typedef struct {
hi_payload_type type;
hi_u32 display_frame_num;
union {
hi_vdec_video_param video_param;
hi_vdec_pic_param pic_param;
};
} hi_vdec_chn_param;
typedef struct {
hi_u32 width;
hi_u32 height;
hi_u32 width_stride;
hi_u32 height_stride;
hi_pixel_format pixel_format;
hi_u64 vir_addr;
hi_u32 buffer_size;
hi_s16 offset_top;
hi_s16 offset_bottom;
hi_s16 offset_left;
hi_s16 offset_right;
} hi_vdec_pic_info;
typedef struct {
hi_s32 max_slice_num;
hi_s32 max_sps_num;
hi_s32 max_pps_num;
} hi_h264_protocol_param;
typedef struct {
hi_s32 max_slice_segment_num;
hi_s32 max_vps_num;
hi_s32 max_sps_num;
hi_s32 max_pps_num;
} hi_h265_protocol_param;
typedef struct {
hi_payload_type type;
union {
hi_h264_protocol_param h264_param;
hi_h265_protocol_param h265_param;
};
} hi_vdec_protocol_param;
typedef enum {
YUVOUT_ALIGN_DOWN = 0,
YUVOUT_ALIGN_UP = 1,
YUVOUT_ALIGN_DOWN_COMPAT = 2,
} hi_jpegd_precision_mode;
* @brief get video decoder picture buffer size
* @param [in] type: video type [PT_H264/PT_H265]
* @param [in] buf_attr: pointer of picture buffer attribute
* @return : video decoder picture buffer size
*/
hi_u32 hi_vdec_get_pic_buf_size(hi_payload_type type, hi_pic_buf_attr *buf_attr);
* @brief get video decoder tmv buffer size
* @param [in] type: video type [PT_H264/PT_H265]
* @param [in] width: video width
* @param [in] height: video height
* @return : video decoder tmv buffer size
*/
hi_u32 hi_vdec_get_tmv_buf_size(hi_payload_type type, hi_u32 width, hi_u32 height);
* @brief create video decoder channel
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @param [in] attr: pointer of video decoder channel attribute
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_vdec_create_chn(hi_vdec_chn chn, const hi_vdec_chn_attr *attr);
* @brief destroy video decoder channel
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_vdec_destroy_chn(hi_vdec_chn chn);
* @brief set video decoder channel attribute
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @param [in] attr: pointer of video decoder channel attribute
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_vdec_set_chn_attr(hi_vdec_chn chn, const hi_vdec_chn_attr *attr);
* @brief get video decoder channel attribute
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @param [out] attr: pointer of video decoder channel attribute
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_vdec_get_chn_attr(hi_vdec_chn chn, hi_vdec_chn_attr *attr);
* @brief set video decoder channel protocol param
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @param [in] protocol_param: pointer of video decoder protocol param
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_vdec_set_protocol_param(hi_vdec_chn chn, const hi_vdec_protocol_param *protocol_param);
* @brief get video decoder channel protocol param
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @param [out] protocol_param: pointer of video decoder protocol param
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_vdec_get_protocol_param(hi_vdec_chn chn, hi_vdec_protocol_param *protocol_param);
* @brief video decoder channel start receive stream
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_vdec_start_recv_stream(hi_vdec_chn chn);
* @brief video decoder channel stop receive stream
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_vdec_stop_recv_stream(hi_vdec_chn chn);
* @brief query video decoder channel status
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @param [out] status: pointer of video decoder channel status struct
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_vdec_query_status(hi_vdec_chn chn, hi_vdec_chn_status *status);
* @brief reset video decoder channel status
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_vdec_reset_chn(hi_vdec_chn chn);
* @brief set video decoder channel parameter
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @param [in] chn_param: pointer of video decoder channel parameter struct
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_vdec_set_chn_param(hi_vdec_chn chn, const hi_vdec_chn_param *chn_param);
* @brief get video decoder channel parameter
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @param [out] chn_param: pointer of video decoder channel parameter struct
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_vdec_get_chn_param(hi_vdec_chn chn, hi_vdec_chn_param *chn_param);
* @brief send stream and outbuffer to video decoder channel
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @param [in] stream: pointer of stream struct
* @param [in] vdec_pic_info: pointer of vdec_pic_info struct
* @param [in] milli_sec: -1 is block,0 is no block,other positive number is timeout
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_vdec_send_stream(hi_vdec_chn chn, const hi_vdec_stream *stream, hi_vdec_pic_info *vdec_pic_info,
hi_s32 milli_sec);
* @brief get frame from video decoder channel
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @param [in] milli_sec: -1 is block,0 is no block,other positive number is timeout
* @param [out] frame_info: pointer of frame info struct
* @param [out] supplement: pointer of supplement info struct
* @param [out] stream: pointer of stream struct
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_vdec_get_frame(hi_vdec_chn chn, hi_video_frame_info *frame_info, hi_vdec_supplement_info *supplement,
hi_vdec_stream *stream, hi_s32 milli_sec);
* @brief release frame from video decoder channel
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @param [in] frame_info: pointer of frame info struct
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_vdec_release_frame(hi_vdec_chn chn, const hi_video_frame_info *frame_info);
* @brief get video decoder channel fd
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @return success: return fd
* fail: return negative number
*/
hi_s32 hi_mpi_vdec_get_fd(hi_vdec_chn chn);
* @brief close video decoder channel fd
* @param [in] chn: video decoder channel id [0, VDEC_MAX_CHN_NUM)
* @return success: return 0
* fail: return -1
*/
hi_s32 hi_mpi_vdec_close_fd(hi_vdec_chn chn);
* @brief get input image's information parsed by dvpp
* @param [in] img_type: payload type of input image
* @param [in] stream: stream info pointer
* @param [out] img_info: parsed image info pointer
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_dvpp_get_image_info(hi_payload_type img_type, const hi_vdec_stream *stream, hi_img_info *img_info);
* @brief set jpegd decoder channel precision mode
* @param [in] chn: jpegd decoder channel id [0, VDEC_MAX_CHN_NUM)
* @param [in] mode: jpegd decoder channel precision mode struct
* @return success: return 0
* fail: return error number
*/
hi_s32 hi_mpi_vdec_set_jpegd_precision_mode(hi_vdec_chn chn, const hi_jpegd_precision_mode mode);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif