Merge "Decoder: Reduced memory requirements"

This commit is contained in:
Marco Nelissen 2015-08-20 22:43:40 +00:00 committed by Gerrit Code Review
commit fe2bfd392c
20 changed files with 1588 additions and 3042 deletions

View file

@ -78,8 +78,6 @@ IV_API_CALL_STATUS_T ih264d_api_function(iv_obj_t *ps_handle, void *pv_api_ip,vo
typedef enum {
IH264D_VID_HDR_DEC_NUM_FRM_BUF_NOT_SUFFICIENT = IVD_DUMMY_ELEMENT_FOR_CODEC_EXTENSIONS + 1,
IH264D_UNSUPPORTED_LEVEL = IVD_DUMMY_ELEMENT_FOR_CODEC_EXTENSIONS + 2,
IH264D_UNSUPPORTED_NUM_REF_FRAMES = IVD_DUMMY_ELEMENT_FOR_CODEC_EXTENSIONS + 3
}IH264D_ERROR_CODES_T;
@ -87,60 +85,20 @@ typedef enum {
/* Extended Structures */
/*****************************************************************************/
/*****************************************************************************/
/* Get Number of Memory Records */
/* Delete Codec */
/*****************************************************************************/
typedef struct {
iv_num_mem_rec_ip_t s_ivd_num_mem_rec_ip_t;
}ih264d_num_mem_rec_ip_t;
ivd_delete_ip_t s_ivd_delete_ip_t;
}ih264d_delete_ip_t;
typedef struct{
iv_num_mem_rec_op_t s_ivd_num_mem_rec_op_t;
}ih264d_num_mem_rec_op_t;
/*****************************************************************************/
/* Fill Memory Records */
/*****************************************************************************/
typedef struct {
iv_fill_mem_rec_ip_t s_ivd_fill_mem_rec_ip_t;
WORD32 i4_level;
UWORD32 u4_num_reorder_frames;
UWORD32 u4_num_ref_frames;
UWORD32 u4_share_disp_buf;
/* format in which codec has to give out frame data for display */
IV_COLOR_FORMAT_T e_output_format;
/* Number of extra display buffers that will be allocated to handle display pipeline depth */
UWORD32 u4_num_extra_disp_buf;
}ih264d_fill_mem_rec_ip_t;
typedef struct{
iv_fill_mem_rec_op_t s_ivd_fill_mem_rec_op_t;
}ih264d_fill_mem_rec_op_t;
/*****************************************************************************/
/* Retrieve Memory Records */
/*****************************************************************************/
typedef struct {
iv_retrieve_mem_rec_ip_t s_ivd_retrieve_mem_rec_ip_t;
}ih264d_retrieve_mem_rec_ip_t;
typedef struct{
iv_retrieve_mem_rec_op_t s_ivd_retrieve_mem_rec_op_t;
}ih264d_retrieve_mem_rec_op_t;
ivd_delete_op_t s_ivd_delete_op_t;
}ih264d_delete_op_t;
/*****************************************************************************/
@ -149,20 +107,13 @@ typedef struct{
typedef struct {
ivd_init_ip_t s_ivd_init_ip_t;
WORD32 i4_level;
UWORD32 u4_num_reorder_frames;
UWORD32 u4_num_ref_frames;
UWORD32 u4_share_disp_buf;
/* Number of extra display buffers that will be allocated to handle display pipeline depth */
UWORD32 u4_num_extra_disp_buf;
}ih264d_init_ip_t;
ivd_create_ip_t s_ivd_create_ip_t;
}ih264d_create_ip_t;
typedef struct{
ivd_init_op_t s_ivd_init_op_t;
}ih264d_init_op_t;
ivd_create_op_t s_ivd_create_op_t;
}ih264d_create_op_t;
/*****************************************************************************/

File diff suppressed because it is too large Load diff

View file

@ -302,42 +302,6 @@ enum
#define MAX_MBS_LEVEL_11 396
#define MAX_MBS_LEVEL_10 99
/*
| Legend:
| LVL Level*10
| MPR Macroblk processing rate
| MMF Max Mbs/Frm
| MDK Max DbpSize (in kB)
| MDB max DbpSize (in bytes)
| MFS FrmSizeYUV (in bytes)
| MDP Max DBPics
| MDC Ceiling DBPics
| FPS Frame/Second
|
| LVL MPR MMF MDK MDB MFS MDP MDC FPS
| 10 1485 99 148.5 152064 38016 4.00 4.00 15.00
| 11 3000 396 337.5 345600 152064 2.27 3.00 7.58
| 12 6000 396 891 912384 152064 6.00 6.00 15.15
| 13 11880 396 891 912384 152064 6.00 6.00 30.00
| 20 11880 396 891 912384 152064 6.00 6.00 30.00
| 21 19800 792 1782 1824768 304128 6.00 6.00 25.00
| 22 20250 1620 3037.5 3110400 622080 5.00 5.00 12.50
| 30 40500 1620 3037.5 3110400 622080 5.00 5.00 25.00
*/
#define MAX_REF_LEVEL_1_0 4
#define MAX_REF_LEVEL_1_1 3
#define MAX_REF_LEVEL_1_2 6
#define MAX_REF_LEVEL_1_3 6
#define MAX_REF_LEVEL_2_0 6
#define MAX_REF_LEVEL_2_1 6
#define MAX_REF_LEVEL_2_2 5
#define MAX_REF_LEVEL_3_0 5
#define H264_MAX_REF_PICS 16
#define MIN_LEVEL_SUPPORTED 10
#define MAX_LEVEL_SUPPORTED 64
/** NAL Types */
#define SLICE_NAL 1
#define SLICE_DATA_PARTITION_A_NAL 2

View file

@ -869,7 +869,7 @@ WORD32 ih264d_form_mb_part_info_mp(pred_info_pkd_t *ps_pred_pkd,
/* Increment the reference buffer Index */
ps_dec->u4_dma_buf_idx += u2_tot_ref_scratch_size;
if(ps_dec->u4_dma_buf_idx > ps_dec->u4_ref_buf_size)
if(ps_dec->u4_dma_buf_idx > MAX_REF_BUF_SIZE)
return ERROR_NUM_MV;
return OK;

View file

@ -1461,11 +1461,7 @@ void ih264d_transfer_mb_group_data(dec_struct_t * ps_dec,
/* Increment deblock parameters pointer in external memory */
if(ps_dec->u1_separate_parse == 1)
{
ps_dec->ps_deblk_mbn_dec_thrd += u1_num_mbs;
}
else
if(ps_dec->u1_separate_parse == 0)
{
ps_dec->ps_deblk_mbn += u1_num_mbs;
}

View file

@ -76,7 +76,7 @@ WORD32 ih264d_create_pic_buffers(UWORD8 u1_num_of_buf,
WORD32 ih264d_create_mv_bank(void * pv_codec_handle,
UWORD32 u4_wd,
UWORD32 u4_ht);
WORD16 ih264d_get_memory_dec_params(dec_struct_t * ps_dec);
WORD16 ih264d_allocate_dynamic_bufs(dec_struct_t * ps_dec);
#endif /* _IH264D_MEM_REQUEST_H_ */

View file

@ -907,7 +907,7 @@ WORD32 ih264d_mv_pred_ref_tfr_nby2_bmb(dec_struct_t * ps_dec,
ps_dec->i4_submb_ofst += SUB_BLK_SIZE;
/* Restore the slice scratch MbX and MbY context */
ps_cur_mb_info = ps_dec->ps_nmb_info + i;
ps_dec->u2_wait_id = i;
u1_field = ps_cur_mb_info->u1_mb_field_decodingflag;
@ -1536,9 +1536,18 @@ WORD32 ih264d_parse_bslice(dec_struct_t * ps_dec, UWORD16 u2_first_mb_in_slice)
{
WORD32 num_entries;
WORD32 size;
num_entries = MAX_FRAMES;
if((1 >= ps_dec->ps_cur_sps->u1_num_ref_frames) &&
(0 == ps_dec->i4_display_delay))
{
num_entries = 1;
}
num_entries = MIN(MAX_FRAMES, ps_dec->u4_num_ref_frames_at_init);
num_entries = 2 * ((2 * num_entries) + 1);
num_entries = ((2 * num_entries) + 1);
if(BASE_PROFILE_IDC != ps_dec->ps_cur_sps->u1_profile_idc)
{
num_entries *= 2;
}
size = num_entries * sizeof(void *);
size += PAD_MAP_IDX_POC * sizeof(void *);

View file

@ -561,6 +561,10 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm)
ps_seq = ps_dec->pv_scratch_sps_pps;
*ps_seq = ps_dec->ps_sps[u1_seq_parameter_set_id];
if(NULL == ps_dec->ps_cur_sps)
ps_dec->ps_cur_sps = ps_seq;
ps_seq->u1_profile_idc = u1_profile_idc;
ps_seq->u1_level_idc = u1_level_idc;
ps_seq->u1_seq_parameter_set_id = u1_seq_parameter_set_id;
@ -728,12 +732,6 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm)
return ERROR_NUM_REF;
}
ps_seq->u1_num_ref_frames = u4_temp;
if(ps_seq->u1_num_ref_frames > ps_dec->u4_num_ref_frames_at_init)
{
return IH264D_UNSUPPORTED_NUM_REF_FRAMES;
}
COPYTHECONTEXT("SPS: num_ref_frames",ps_seq->u1_num_ref_frames);
ps_seq->u1_gaps_in_frame_num_value_allowed_flag = ih264d_get_bit_h264(
@ -783,49 +781,6 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm)
else
ps_seq->u1_mb_aff_flag = 0;
{
WORD32 frame_height_in_mbs = (2 - ps_seq->u1_frame_mbs_only_flag)
* (pic_height_in_map_units_minus1 + 1);
UWORD32 wdth = (ps_seq->u2_frm_wd_in_mbs) << 4;
UWORD32 hght = (frame_height_in_mbs) << 4;
if((u2_pic_wd < H264_MIN_FRAME_WIDTH)
|| (u2_pic_wd > ps_dec->u4_width_at_init))
{
ivd_video_decode_op_t *ps_out;
/*set width and height in decode output structure*/
ps_out = (ivd_video_decode_op_t *)ps_dec->pv_dec_out;
ps_out->u4_pic_wd = u2_pic_wd;
ps_out->u4_pic_ht = u2_pic_ht;
return IVD_STREAM_WIDTH_HEIGHT_NOT_SUPPORTED;
}
if((u2_pic_ht < H264_MIN_FRAME_HEIGHT)
|| (((0 != ps_seq->u1_frame_mbs_only_flag)
&& (u2_pic_ht * u2_pic_wd
> ps_dec->u4_height_at_init
* ps_dec->u4_width_at_init))
|| ((0 == ps_seq->u1_frame_mbs_only_flag)
&& (ALIGN32(u2_pic_ht)
* u2_pic_wd
> ALIGN32(ps_dec->u4_height_at_init)
* ps_dec->u4_width_at_init))))
{
ivd_video_decode_op_t *ps_out;
/*set width and height in decode output structure*/
ps_out = (ivd_video_decode_op_t *)ps_dec->pv_dec_out;
ps_out->u4_pic_wd = u2_pic_wd;
ps_out->u4_pic_ht = u2_pic_ht;
return IVD_STREAM_WIDTH_HEIGHT_NOT_SUPPORTED;
}
}
ps_seq->u1_direct_8x8_inference_flag = ih264d_get_bit_h264(ps_bitstrm);
COPYTHECONTEXT("SPS: direct_8x8_inference_flag",
@ -946,44 +901,6 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm)
return ret;
}
if(ps_dec->u4_level_at_init < u1_level_idc)
{
UWORD32 u4_num_pic_bufs_reqd, u4_num_reorder_frames,
u4_num_mv_bufs_reqd;
UWORD32 u4_num_pic_bufs_memory, u4_num_mv_bufs_memory;
UWORD32 u4_num_ref_frames;
u4_num_ref_frames = ps_seq->u1_num_ref_frames;
if(1 == ps_seq->u1_vui_parameters_present_flag)
{
u4_num_reorder_frames = ps_seq->s_vui.u4_num_reorder_frames;
}
else
{
u4_num_reorder_frames = ps_dec->u4_num_reorder_frames_at_init;
}
u4_num_pic_bufs_reqd = u4_num_ref_frames + u4_num_reorder_frames + 1;
u4_num_pic_bufs_memory = ih264d_get_numbuf_dpb_bank(ps_dec, u2_frm_wd_y,
u2_frm_ht_y);
u4_num_mv_bufs_reqd = u4_num_ref_frames + 1;
if(u4_num_mv_bufs_reqd < 2)
u4_num_mv_bufs_reqd = 2;
u4_num_mv_bufs_memory = ih264d_get_numbuf_mv_bank(ps_dec, u2_pic_wd,
u2_pic_ht);
if((u4_num_pic_bufs_reqd > u4_num_pic_bufs_memory)
|| (u4_num_mv_bufs_reqd > u4_num_mv_bufs_memory))
{
return IH264D_UNSUPPORTED_LEVEL;
}
}
ps_dec->u2_pic_wd = u2_pic_wd;
ps_dec->u2_pic_ht = u2_pic_ht;

View file

@ -1655,9 +1655,17 @@ WORD32 ih264d_mark_err_slice_skip(dec_struct_t * ps_dec,
WORD32 size;
UWORD8 *pu1_buf;
num_entries = MIN(MAX_FRAMES, ps_dec->u4_num_ref_frames_at_init);
num_entries = 2 * ((2 * num_entries) + 1);
num_entries = MAX_FRAMES;
if((1 >= ps_dec->ps_cur_sps->u1_num_ref_frames) &&
(0 == ps_dec->i4_display_delay))
{
num_entries = 1;
}
num_entries = ((2 * num_entries) + 1);
if(BASE_PROFILE_IDC != ps_dec->ps_cur_sps->u1_profile_idc)
{
num_entries *= 2;
}
size = num_entries * sizeof(void *);
size += PAD_MAP_IDX_POC * sizeof(void *);
@ -2021,8 +2029,17 @@ WORD32 ih264d_parse_pslice(dec_struct_t *ps_dec, UWORD16 u2_first_mb_in_slice)
WORD32 num_entries;
WORD32 size;
num_entries = MIN(MAX_FRAMES, ps_dec->u4_num_ref_frames_at_init);
num_entries = 2 * ((2 * num_entries) + 1);
num_entries = MAX_FRAMES;
if((1 >= ps_dec->ps_cur_sps->u1_num_ref_frames) &&
(0 == ps_dec->i4_display_delay))
{
num_entries = 1;
}
num_entries = ((2 * num_entries) + 1);
if(BASE_PROFILE_IDC != ps_dec->ps_cur_sps->u1_profile_idc)
{
num_entries *= 2;
}
size = num_entries * sizeof(void *);
size += PAD_MAP_IDX_POC * sizeof(void *);

View file

@ -344,15 +344,12 @@ WORD32 ih264d_start_of_pic(dec_struct_t *ps_dec,
ps_dec->ps_nmb_info = ps_dec->ps_frm_mb_info;
if(ps_dec->u1_separate_parse)
{
UWORD16 pic_wd = ps_dec->u4_width_at_init;
UWORD16 pic_ht = ps_dec->u4_height_at_init;
UWORD16 pic_wd;
UWORD16 pic_ht;
UWORD32 num_mbs;
if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid)))
{
pic_wd = ps_dec->u2_pic_wd;
pic_ht = ps_dec->u2_pic_ht;
}
pic_wd = ps_dec->u2_pic_wd;
pic_ht = ps_dec->u2_pic_ht;
num_mbs = (pic_wd * pic_ht) >> 8;
if(ps_dec->pu1_dec_mb_map)
@ -546,18 +543,13 @@ WORD32 ih264d_start_of_pic(dec_struct_t *ps_dec,
<< 2);
ps_dec->ps_cur_mb_row = ps_dec->ps_nbr_mb_row; //[0];
ps_dec->ps_cur_mb_row++; //Increment by 1 ,so that left mb will always be valid
ps_dec->ps_top_mb_row =
ps_dec->ps_nbr_mb_row
+ ((ps_dec->u2_frm_wd_in_mbs + 1)
<< (1
- ps_dec->ps_cur_sps->u1_frame_mbs_only_flag));
ps_dec->ps_top_mb_row++; //Increment by 1 ,so that left mb will always be valid
//Increment by 2 ,so that left mb (mbaff decrements by 2) will always be valid
ps_dec->ps_cur_mb_row += 2;
ps_dec->ps_top_mb_row = ps_dec->ps_nbr_mb_row;
ps_dec->ps_top_mb_row += ((ps_dec->u2_frm_wd_in_mbs + 2) << (1 - ps_dec->ps_cur_sps->u1_frame_mbs_only_flag));
//Increment by 2 ,so that left mb (mbaff decrements by 2) will always be valid
ps_dec->ps_top_mb_row += 2;
ps_dec->pu1_y = ps_dec->pu1_y_scratch[0];
ps_dec->pu1_u = ps_dec->pu1_u_scratch[0];
ps_dec->pu1_v = ps_dec->pu1_v_scratch[0];
ps_dec->u1_yuv_scratch_idx = 0;
/* CHANGED CODE */
ps_dec->ps_mv_cur = ps_dec->s_cur_pic.ps_mv;
ps_dec->ps_mv_top = ps_dec->ps_mv_top_p[0];
@ -566,10 +558,6 @@ WORD32 ih264d_start_of_pic(dec_struct_t *ps_dec,
ps_dec->u1_mb_idx = 0;
/* CHANGED CODE */
ps_dec->ps_mv_left = ps_dec->s_cur_pic.ps_mv;
ps_dec->pu1_yleft = 0;
ps_dec->pu1_uleft = 0;
ps_dec->pu1_vleft = 0;
ps_dec->u1_not_wait_rec = 2;
ps_dec->u2_total_mbs_coded = 0;
ps_dec->i4_submb_ofst = -(SUB_BLK_SIZE);
ps_dec->u4_pred_info_idx = 0;
@ -610,8 +598,6 @@ WORD32 ih264d_start_of_pic(dec_struct_t *ps_dec,
+ ps_dec->u2_frm_wd_in_mbs * BLK8x8SIZE;
ps_dec->ps_deblk_mbn = ps_dec->ps_deblk_pic;
ps_dec->ps_deblk_mbn_curr = ps_dec->ps_deblk_mbn;
ps_dec->ps_deblk_mbn_prev = ps_dec->ps_deblk_mbn + ps_dec->u1_recon_mb_grp;
/* Initialize The Function Pointer Depending Upon the Entropy and MbAff Flag */
{
if(ps_cur_slice->u1_mbaff_frame_flag)
@ -770,7 +756,7 @@ WORD32 ih264d_end_of_pic_dispbuf_mgr(dec_struct_t * ps_dec)
ih264d_reset_ref_bufs(ps_dec->ps_dpb_mgr);
ih264d_release_display_bufs(ps_dec);
}
if(ps_dec->u4_num_reorder_frames_at_init != 0)
if(IVD_DECODE_FRAME_OUT != ps_dec->e_frm_out_mode)
{
ret = ih264d_assign_display_seq(ps_dec);
if(ret != OK)
@ -854,7 +840,7 @@ WORD32 ih264d_end_of_pic_dispbuf_mgr(dec_struct_t * ps_dec)
|| ((TOP_FIELD_ONLY | BOT_FIELD_ONLY)
== ps_dec->u1_top_bottom_decoded))
{
if(ps_dec->u4_num_reorder_frames_at_init == 0)
if(IVD_DECODE_FRAME_OUT == ps_dec->e_frm_out_mode)
{
ret = ih264d_assign_display_seq(ps_dec);
if(ret != OK)
@ -1854,8 +1840,17 @@ WORD32 ih264d_parse_decode_slice(UWORD8 u1_is_idr_slice,
WORD32 size;
UWORD8 *pu1_buf;
num_entries = MIN(MAX_FRAMES, ps_dec->u4_num_ref_frames_at_init);
num_entries = 2 * ((2 * num_entries) + 1);
num_entries = MAX_FRAMES;
if((1 >= ps_dec->ps_cur_sps->u1_num_ref_frames) &&
(0 == ps_dec->i4_display_delay))
{
num_entries = 1;
}
num_entries = ((2 * num_entries) + 1);
if(BASE_PROFILE_IDC != ps_dec->ps_cur_sps->u1_profile_idc)
{
num_entries *= 2;
}
size = num_entries * sizeof(void *);
size += PAD_MAP_IDX_POC * sizeof(void *);

View file

@ -97,7 +97,6 @@ WORD32 ih264d_mv_pred_ref_tfr_nby2_pmb(dec_struct_t * ps_dec,
*ps_mv_pred = ps_dec->s_default_mv_pred;
ps_dec->i4_submb_ofst += SUB_BLK_SIZE;
ps_dec->u2_wait_id = i;
/* Restore the slice scratch MbX and MbY context */
ps_cur_mb_info = ps_dec->ps_nmb_info + i;

View file

@ -581,12 +581,6 @@ typedef struct
typedef struct
{
UWORD8 *pu1_mb_y; /* pointer to N-Mb pad buffer Y (Horz) */
UWORD8 *pu1_mb_u; /* pointer to N-Mb pad buffer U (Horz) */
UWORD8 *pu1_mb_v; /* pointer to N-Mb pad buffer V (Horz) */
UWORD8 *pu1_row_y; /* pointer to row pad buffer Y (Vert) */
UWORD8 *pu1_row_u; /* pointer to row pad buffer U (Vert) */
UWORD8 *pu1_row_v; /* pointer to row pad buffer V (Vert) */
UWORD8 u1_vert_pad_top; /* flip-flop u4_flag remembering pad area (Vert) */
UWORD8 u1_vert_pad_bot; /* flip-flop u4_flag remembering pad area (Vert) */
UWORD8 u1_horz_pad; /* flip-flop u4_flag remembering pad area (Vert) */
@ -594,13 +588,6 @@ typedef struct
UWORD8 u1_pad_len_cr_v; /* vertical pad amount for chroma */
} pad_mgr_t;
typedef struct code_overlay_ctxt
{
UWORD8 u1_pb_slice_type;
UWORD8 u1_entropy_coding_type;
UWORD8 u1_mbaff_frame_flag;
UWORD8 u1_b_direct_flag;
} code_overlay_ctxt_t;
#define ACCEPT_ALL_PICS (0x00)
#define REJECT_CUR_PIC (0x01)
@ -875,16 +862,10 @@ typedef struct _DecStruct
UWORD8 *pu1_left_yuv_dc_csbp;
/* c64x_map.inc takes care of only this part
If you change/add any members above this,
modify c64x_map.inc accordingly */
void **pp_ext_g_table_ptr;
deblkmb_neighbour_t deblk_left_mb[2];
deblkmb_neighbour_t *ps_deblk_top_mb;
neighbouradd_t (*ps_left_mvpred_addr)[2]; /* Left MvPred Address Ping Pong*/
// neighbouradd_t *ps_topMvPredAdd;
/***************************************************************************/
/* Ref_idx contexts are stored in the following way */
@ -964,7 +945,7 @@ typedef struct _DecStruct
pic_buffer_t **ps_ref_pic_buf_lx[2];
/* refIdx to POC mapping */
void **ppv_map_ref_idx_to_poc;
UWORD32 *pu4_defI_wts_ofsts;
void **ppv_map_ref_idx_to_poc_base;
UWORD32 *pu4_wts_ofsts_mat;
UWORD32 *pu4_wt_ofsts;
UWORD32 *pu4_mbaff_wt_mat;
@ -1011,21 +992,8 @@ typedef struct _DecStruct
UWORD32 u4_intra_pred_line_ofst;
/* Scratch ping reconstruction pointers for Y U V */
UWORD8 *pu1_y_scratch[2];
UWORD8 *pu1_u_scratch[2];
UWORD8 *pu1_v_scratch[2];
UWORD8 u1_yuv_scratch_idx;
UWORD8 u1_not_wait_rec;
UWORD8 u1_res_changed;
UWORD8 *pu1_yleft; /** Left Y pointer, used for intra-pred */
UWORD8 *pu1_uleft; /** Left U pointer, used for intra-pred */
UWORD8 *pu1_vleft; /** Left V pointer, used for intra-pred */
UWORD8 u1_y_topleft[2]; /** Left Y pointer, used for intra-pred */
UWORD8 u1_u_topleft[2]; /** Left U pointer, used for intra-pred */
UWORD8 u1_v_topleft[2]; /** Left V pointer, used for intra-pred */
mv_pred_t *ps_mv_cur; /** pointer to current motion vector bank */
mv_pred_t *ps_mv_top; /** pointer to top motion vector bank */
mv_pred_t *ps_mv_top_right2;/** Pointer to top right motion vector bank */
@ -1034,9 +1002,6 @@ typedef struct _DecStruct
UWORD8 u1_mv_top_p;
deblk_mb_t *ps_deblk_mbn;
deblk_mb_t *ps_deblk_mbn_dec_thrd;/*pointer used by parsing when spearaet_parse is 1*/
deblk_mb_t *ps_deblk_mbn_curr;
deblk_mb_t *ps_deblk_mbn_prev;
UWORD8 *pu1_temp_mc_buffer;
@ -1053,13 +1018,6 @@ typedef struct _DecStruct
/* Variables used for gaps in frame number */
UWORD16 u2_prev_ref_frame_num;
UWORD8 u1_vert_up_scale_flag;
iv_mem_rec_t *ps_mem_tab;
UWORD16 u2_wait_id;
void *pi4_ctxt_save_register;
void *pi4_ctxt_save_register_dec;
UWORD8 u1_mb_idx;
struct pic_buffer_t *ps_col_pic;
@ -1099,39 +1057,20 @@ typedef struct _DecStruct
prev_seq_params_t s_prev_seq_params;
UWORD8 u1_cur_mb_fld_dec_flag; /* current Mb fld or Frm */
code_overlay_ctxt_t s_code_overlay_ctxt;
UWORD8 u1_code_overlay;
// WORD8 *pi1_cur_predmodes;
WORD8 pi1_left_pred_mode[8];
UWORD8 u1_topleft_mb_fld;
UWORD8 u1_topleft_mbtype;
UWORD8 u1_topleft_mb_fld_bot;
UWORD8 u1_topleft_mbtype_bot;
UWORD8 u1_deblk_mb_grp;
WORD16 i2_prev_slice_mbx;
WORD16 i2_prev_slice_mby;
UWORD16 u2_top_left_mask;
UWORD16 u2_top_right_mask;
dec_err_status_t * ps_dec_err_status;
UWORD32 *pu4_sos_signal;
UWORD8 u1_mb_idx_mv;
UWORD16 u2_mv_2mb[2];
UWORD32 u4_ref_buf_size;
UWORD32 u4_packet_cnt;
/* to remember the i4_status & input parameters from the sample app */
void *pv_dec_status; // itt_dec_status_t void pointer */
void *pv_dec_params; // itt_dec_prms_t void pointer
void *pv_app_ctxt;
UWORD32 u4_skip_frm_mask;
void *pv_fmt_con_ctxt;
/* for the parallel format conversion */
UWORD8 *pu1_frmt_conv_y[3];
UWORD8 *pu1_frmt_conv_u[3];
UWORD8 *pu1_frmt_conv_v[3];
UWORD8 *pu1_deblk_scr;
UWORD32 u4_deblk_scr_sz;
/* variable for finding the no.of mbs decoded in the current picture */
UWORD16 u2_total_mbs_coded;
@ -1149,11 +1088,6 @@ typedef struct _DecStruct
/* To keep track of whether the last picture was decoded or not */
/* in case of skip mode set by the application */
UWORD8 u1_last_pic_not_decoded;
UWORD32 *pu4_return_remaining_bufs;
/* Used for disabling deblocking of non-reference pictures */
WORD32 i4_set_low_complexity_mode;
WORD32 i4_disable_deblock;
WORD32 e_dec_status;
UWORD32 u4_num_fld_in_frm;
@ -1261,11 +1195,7 @@ typedef struct _DecStruct
UWORD8 u1_chroma_format;
UWORD8 u1_pic_decode_done;
UWORD8 u1_slice_header_done;
UWORD32 u4_level_at_init;
UWORD32 u4_width_at_init;
UWORD32 u4_height_at_init;
WORD32 init_done;
WORD32 process_called;
/******************************************/
/* For the high profile related variables */
@ -1282,12 +1212,14 @@ typedef struct _DecStruct
UWORD8 u1_top_bottom_decoded;
UWORD8 u1_dangling_field;
/*
* For Low Memory case
*/
UWORD32 u4_num_ref_frames_at_init;
UWORD32 u4_num_reorder_frames_at_init;
UWORD32 u4_num_extra_disp_bufs_at_init;
IVD_DISPLAY_FRAME_OUT_MODE_T e_frm_out_mode;
UWORD8 *pu1_bits_buf_static;
UWORD8 *pu1_bits_buf_dynamic;
UWORD32 u4_static_bits_buf_size;
UWORD32 u4_dynamic_bits_buf_size;
UWORD32 u4_num_disp_bufs_requested;
WORD32 i4_display_delay;
UWORD32 u4_slice_start_code_found;
@ -1329,7 +1261,6 @@ typedef struct _DecStruct
UWORD32 u4_fmt_conv_cur_row;
ivd_out_bufdesc_t *ps_out_buffer;
ivd_get_display_frame_op_t s_disp_op;
UWORD32 u4_stop_threads;
UWORD32 u4_output_present;
volatile UWORD16 cur_dec_mb_num;
@ -1410,6 +1341,18 @@ typedef struct _DecStruct
UWORD8 au1_pic_buf_ref_flag[MAX_DISP_BUFS_NEW];
struct pic_buffer_t *ps_pic_buf_base;
UWORD8 *pu1_ref_buff_base;
col_mv_buf_t *ps_col_mv_base;
void *(*pf_aligned_alloc)(void *pv_mem_ctxt, WORD32 alignment, WORD32 size);
void (*pf_aligned_free)(void *pv_mem_ctxt, void *pv_buf);
void *pv_mem_ctxt;
UWORD8 *pu1_pic_buf_base;
UWORD8 *pu1_mv_bank_buf_base;
UWORD8 *pu1_init_dpb_base;
ih264_default_weighted_pred_ft *pf_default_weighted_pred_luma;
ih264_default_weighted_pred_ft *pf_default_weighted_pred_chroma;

View file

@ -534,13 +534,7 @@ WORD32 ih264d_decode_slice_thread(dec_struct_t *ps_dec)
ps_trns_addr->pu1_mb_v = ps_trns_addr->pu1_dest_v;
/**********Number of Mbs in Slice**********/
ps_dec->ps_deblk_mbn_dec_thrd = ps_dec->ps_deblk_pic
+ (u2_first_mb_in_slice << u1_mbaff);
/* Initialise MC and formMbPartInfo fn ptrs one time based on profile_idc */
{
ps_dec->p_mc_dec_thread = ih264d_motion_compensate_bp;
ps_dec->p_form_mb_part_info_thread = ih264d_form_mb_part_info_bp;

File diff suppressed because it is too large Load diff

View file

@ -40,6 +40,8 @@
#include "ih264d_structs.h"
#include "ih264d_parse_cavlc.h"
#define PS_DEC_ALIGNED_FREE(ps_dec, y) \
if(y) {ps_dec->pf_aligned_free(ps_dec->pv_mem_ctxt, ((void *)y)); (y) = NULL;}
void pad_frm_buff_vert(dec_struct_t *ps_dec);
UWORD8 ih264d_is_end_of_pic(UWORD16 u2_frame_num,
@ -90,16 +92,11 @@ WORD32 ih264d_get_next_display_field(dec_struct_t * ps_dec,
void ih264d_release_display_field(dec_struct_t *ps_dec,
ivd_get_display_frame_op_t *pv_disp_op);
void ih264d_close_video_decoder(iv_obj_t *iv_obj_t);
WORD32 ih264d_get_dpb_size_new(UWORD32 u4_level_idc,
UWORD32 width,
UWORD32 height);
WORD32 ih264d_get_dpb_size(dec_seq_params_t *ps_seq);
WORD32 ih264d_get_next_nal_unit(UWORD8 *pu1_buf,
UWORD32 u4_cur_pos,
UWORD32 u4_max_ofst,
UWORD32 *pu4_length_of_start_code);
UWORD32 ih264d_get_numbuf_mv_bank(dec_struct_t *ps_dec, UWORD32 width, UWORD32 height);
WORD32 ih264d_get_numbuf_dpb_bank(dec_struct_t *ps_dec,
UWORD32 u2_frame_wd,
UWORD32 u2_frame_ht);
WORD16 ih264d_free_dynamic_bufs(dec_struct_t * ps_dec);
#endif /* _IH264D_UTILS_H_ */

View file

@ -205,8 +205,9 @@ WORD32 ih264d_parse_vui_parametres(vui_t *ps_vu4,
}
ps_vu4->u1_pic_struct_present_flag = ih264d_get_bits_h264(ps_bitstrm, 1);
u4_bits = ih264d_get_bits_h264(ps_bitstrm, 1);
if(u4_bits)
ps_vu4->u1_bitstream_restriction_flag = ih264d_get_bits_h264(ps_bitstrm, 1);
if(ps_vu4->u1_bitstream_restriction_flag)
{
ps_vu4->u1_mv_over_pic_boundaries_flag = ih264d_get_bits_h264(
ps_bitstrm, 1);
@ -227,6 +228,7 @@ WORD32 ih264d_parse_vui_parametres(vui_t *ps_vu4,
{
/* Setting this to a large value if not present */
ps_vu4->u4_num_reorder_frames = 64;
ps_vu4->u4_max_dec_frame_buffering = 64;
}
return OK;

View file

@ -81,6 +81,7 @@ typedef struct
hrd_t s_vcl_hrd;
UWORD8 u1_low_delay_hrd_flag;
UWORD8 u1_pic_struct_present_flag;
UWORD8 u1_bitstream_restriction_flag;
UWORD8 u1_mv_over_pic_boundaries_flag;
UWORD32 u4_max_bytes_per_pic_denom;
UWORD32 u4_max_bits_per_mb_denom;

View file

@ -65,20 +65,6 @@ typedef enum {
IV_FAIL = 0x1,
}IV_API_CALL_STATUS_T;
/* IV_MEM_TYPE_T: This Enumeration defines the type of memory (Internal/Ext */
/* -ernal) along with the cacheable/non-cacheable attributes */
typedef enum {
IV_NA_MEM_TYPE = 0x7FFFFFFF,
IV_INTERNAL_CACHEABLE_PERSISTENT_MEM = 0x1,
IV_INTERNAL_CACHEABLE_SCRATCH_MEM = 0x2,
IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM = 0x3,
IV_EXTERNAL_CACHEABLE_SCRATCH_MEM = 0x4,
IV_INTERNAL_NONCACHEABLE_PERSISTENT_MEM = 0x5,
IV_INTERNAL_NONCACHEABLE_SCRATCH_MEM = 0x6,
IV_EXTERNAL_NONCACHEABLE_PERSISTENT_MEM = 0x7,
IV_EXTERNAL_NONCACHEABLE_SCRATCH_MEM = 0x8
}IV_MEM_TYPE_T;
/* IV_COLOR_FORMAT_T: This enumeration lists all the color formats which */
/* finds usage in video/image codecs */
@ -150,10 +136,6 @@ typedef enum {
/* IV_API_COMMAND_TYPE_T:API command type */
typedef enum {
IV_CMD_NA = 0x7FFFFFFF,
IV_CMD_GET_NUM_MEM_REC = 0x0,
IV_CMD_FILL_NUM_MEM_REC = 0x1,
IV_CMD_RETRIEVE_MEMREC = 0x2,
IV_CMD_INIT = 0x3,
IV_CMD_DUMMY_ELEMENT = 0x4,
}IV_API_COMMAND_TYPE_T;
@ -180,35 +162,6 @@ typedef struct {
void *pv_codec_handle;
}iv_obj_t;
/* iv_mem_rec_t: This structure defines the memory record holder which will */
/* be used by the codec to communicate its memory requirements to the */
/* application through appropriate API functions */
typedef struct {
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* Pointer to the memory allocated by the application
*/
void *pv_base;
/**
* u4_size of the memory to be allocated
*/
UWORD32 u4_mem_size;
/**
* Alignment of the memory pointer
*/
UWORD32 u4_mem_alignment;
/**
* Nature of the memory to be allocated
*/
IV_MEM_TYPE_T e_mem_type;
}iv_mem_rec_t;
/* IV_YUV_BUF_T: This structure defines attributes for the yuv buffer */
@ -279,141 +232,6 @@ typedef struct {
UWORD32 u4_v_strd;
}iv_yuv_buf_t;
/*****************************************************************************/
/* Get Number of Memory Records */
/*****************************************************************************/
/* IV_API_COMMAND_TYPE_T::e_cmd = IV_CMD_GET_NUM_MEM_REC */
typedef struct {
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* cmd
*/
IV_API_COMMAND_TYPE_T e_cmd;
}iv_num_mem_rec_ip_t;
typedef struct {
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* error code
*/
UWORD32 u4_error_code;
/**
* num_mem_rec
*/
UWORD32 u4_num_mem_rec;
}iv_num_mem_rec_op_t;
/*****************************************************************************/
/* Fill Memory Records */
/*****************************************************************************/
/* IV_API_COMMAND_TYPE_T::e_cmd = IV_CMD_FILL_NUM_MEM_REC */
typedef struct {
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* cmd
*/
IV_API_COMMAND_TYPE_T e_cmd;
/**
* pointer to array of memrecords structures should be filled by codec
with details of memory resource requirements
*/
iv_mem_rec_t *pv_mem_rec_location;
/**
* maximum width for which codec should request memory requirements
*/
UWORD32 u4_max_frm_wd;
/**
* maximum height for which codec should request memory requirements
*/
UWORD32 u4_max_frm_ht;
}iv_fill_mem_rec_ip_t;
typedef struct {
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* error_code
*/
UWORD32 u4_error_code;
/**
* no of memory record structures which are filled by codec
*/
UWORD32 u4_num_mem_rec_filled;
}iv_fill_mem_rec_op_t;
/*****************************************************************************/
/* Retrieve Memory Records */
/*****************************************************************************/
/* IV_API_COMMAND_TYPE_T::e_cmd = IV_CMD_RETRIEVE_MEMREC */
typedef struct {
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* cmd
*/
IV_API_COMMAND_TYPE_T e_cmd;
/**
* array of structures where codec should fill with all resources(memory) with it
*/
iv_mem_rec_t *pv_mem_rec_location;
}iv_retrieve_mem_rec_ip_t;
typedef struct {
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* error_code
*/
UWORD32 u4_error_code;
/**
* no of memory records filled by codec
*/
UWORD32 u4_num_mem_rec_filled;
}iv_retrieve_mem_rec_op_t;
#endif /* _IV_H */

View file

@ -17,24 +17,24 @@
*****************************************************************************
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
*/
/*****************************************************************************/
/* */
/* File Name : ivd.h */
/* */
/* Description : This file contains all the necessary structure and */
/* enumeration definitions needed for the Application */
/* Program Interface(API) of the Ittiam Video Decoders */
/* */
/* List of Functions : None */
/* */
/* Issues / Problems : None */
/* */
/* Revision History : */
/* */
/* DD MM YYYY Author(s) Changes (Describe the changes made) */
/* 26 08 2010 100239(RCY) Draft */
/* */
/*****************************************************************************/
/**
*******************************************************************************
* @file
* ivd.h
*
* @brief
* This file contains all the necessary structure and enumeration
* definitions needed for the Application Program Interface(API) of the
* Ittiam Video Decoders
*
* @author
* 100239(RCY)
*
* @remarks
* None
*
*******************************************************************************
*/
#ifndef _IVD_H
#define _IVD_H
@ -128,7 +128,9 @@ typedef enum {
/* IVD_API_COMMAND_TYPE_T:API command type */
typedef enum {
IVD_CMD_VIDEO_NA = 0x7FFFFFFF,
IVD_CMD_VIDEO_CTL = IV_CMD_DUMMY_ELEMENT + 1,
IVD_CMD_CREATE = IV_CMD_DUMMY_ELEMENT + 1,
IVD_CMD_DELETE,
IVD_CMD_VIDEO_CTL,
IVD_CMD_VIDEO_DECODE,
IVD_CMD_GET_DISPLAY_FRAME,
IVD_CMD_REL_DISPLAY_FRAME,
@ -228,6 +230,7 @@ typedef enum {
IVD_DEC_REF_BUF_NULL = 0x28,
IVD_DEC_FRM_SKIPPED = 0x29,
IVD_RES_CHANGED = 0x2a,
IVD_MEM_ALLOC_FAILED = 0x2b,
IVD_DUMMY_ELEMENT_FOR_CODEC_EXTENSIONS = 0xD0,
}IVD_ERROR_CODES_T;
@ -239,48 +242,127 @@ typedef enum {
/* call */
typedef struct {
/* number of output buffers */
/**
* number of output buffers
*/
UWORD32 u4_num_bufs;
/* list of pointers to output buffers */
/**
*list of pointers to output buffers
*/
UWORD8 *pu1_bufs[IVD_VIDDEC_MAX_IO_BUFFERS];
/* sizes of each output buffer */
/**
* sizes of each output buffer
*/
UWORD32 u4_min_out_buf_size[IVD_VIDDEC_MAX_IO_BUFFERS];
}ivd_out_bufdesc_t;
/*****************************************************************************/
/* Initialize decoder */
/* Create decoder */
/*****************************************************************************/
/* IVD_API_COMMAND_TYPE_T::e_cmd = IVD_CMD_INIT */
/* IVD_API_COMMAND_TYPE_T::e_cmd = IVD_CMD_CREATE */
typedef struct {
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* e_cmd
*/
IVD_API_COMMAND_TYPE_T e_cmd;
/* no memrecords which are allocated on request of codec through
fill mem records */
UWORD32 u4_num_mem_rec;
/* maximum height for which codec should be initialized */
UWORD32 u4_frm_max_wd;
/* maximum width for which codec should be initialized */
UWORD32 u4_frm_max_ht;
/* format in which codec has to give out frame data for display */
/**
* format in which codec has to give out frame data for display
*/
IV_COLOR_FORMAT_T e_output_format;
/* pointer to memrecord array, which contains allocated resources */
iv_mem_rec_t *pv_mem_rec_location;
}ivd_init_ip_t;
/**
* Flag to indicate shared display buffer mode
*/
UWORD32 u4_share_disp_buf;
/**
* Pointer to a function for aligned allocation.
*/
void *(*pf_aligned_alloc)(void *pv_mem_ctxt, WORD32 alignment, WORD32 size);
/**
* Pointer to a function for aligned free.
*/
void (*pf_aligned_free)(void *pv_mem_ctxt, void *pv_buf);
/**
* Pointer to memory context that is needed during alloc/free for custom
* memory managers. This will be passed as first argument to pf_aligned_alloc and
* pf_aligned_free.
* If application is using standard memory functions like
* malloc/aligned_malloc/memalign/free/aligned_free,
* then this is not needed and can be set to NULL
*/
void *pv_mem_ctxt;
}ivd_create_ip_t;
typedef struct{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
UWORD32 u4_error_code;
}ivd_init_op_t;
/**
* u4_error_code
*/
UWORD32 u4_error_code;
/**
* Codec Handle
*/
void *pv_handle;
}ivd_create_op_t;
/*****************************************************************************/
/* Delete decoder */
/*****************************************************************************/
/* IVD_API_COMMAND_TYPE_T::e_cmd = IVD_CMD_DELETE */
typedef struct {
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* cmd
*/
IVD_API_COMMAND_TYPE_T e_cmd;
}ivd_delete_ip_t;
typedef struct{
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* error_code
*/
UWORD32 u4_error_code;
}ivd_delete_op_t;
/*****************************************************************************/
/* Video Decode */
@ -291,37 +373,118 @@ typedef struct{
typedef struct {
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* e_cmd
*/
IVD_API_COMMAND_TYPE_T e_cmd;
/**
* u4_ts
*/
UWORD32 u4_ts;
/**
* u4_num_Bytes
*/
UWORD32 u4_num_Bytes;
/**
* pv_stream_buffer
*/
void *pv_stream_buffer;
/* output buffer desc */
/**
* output buffer desc
*/
ivd_out_bufdesc_t s_out_buffer;
}ivd_video_decode_ip_t;
typedef struct{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* u4_error_code
*/
UWORD32 u4_error_code;
/**
* num_bytes_consumed
*/
UWORD32 u4_num_bytes_consumed;
/**
* pic_wd
*/
UWORD32 u4_pic_wd;
/**
* pic_ht
*/
UWORD32 u4_pic_ht;
/**
* pic_type
*/
IV_PICTURE_CODING_TYPE_T e_pic_type;
/**
* frame_decoded_flag
*/
UWORD32 u4_frame_decoded_flag;
/**
* new_seq
*/
UWORD32 u4_new_seq;
/**
* output_present
*/
UWORD32 u4_output_present;
/**
* progressive_frame_flag
*/
UWORD32 u4_progressive_frame_flag;
/**
* is_ref_flag
*/
UWORD32 u4_is_ref_flag;
/**
* output_format
*/
IV_COLOR_FORMAT_T e_output_format;
/**
* disp_frm_buf
*/
iv_yuv_buf_t s_disp_frm_buf;
/**
* fld_type
*/
IV_FLD_TYPE_T e4_fld_type;
/**
* ts
*/
UWORD32 u4_ts;
/**
* disp_buf_id
*/
UWORD32 u4_disp_buf_id;
}ivd_video_decode_op_t;
@ -335,12 +498,19 @@ typedef struct{
typedef struct
{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* e_cmd
*/
IVD_API_COMMAND_TYPE_T e_cmd;
/* output buffer desc */
/**
* output buffer desc
*/
ivd_out_bufdesc_t s_out_buffer;
}ivd_get_display_frame_ip_t;
@ -348,16 +518,54 @@ typedef struct
typedef struct
{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* error_code
*/
UWORD32 u4_error_code;
/**
* progressive_frame_flag
*/
UWORD32 u4_progressive_frame_flag;
/**
* pic_type
*/
IV_PICTURE_CODING_TYPE_T e_pic_type;
/**
* is_ref_flag
*/
UWORD32 u4_is_ref_flag;
/**
* output_format
*/
IV_COLOR_FORMAT_T e_output_format;
/**
* disp_frm_buf
*/
iv_yuv_buf_t s_disp_frm_buf;
/**
* fld_type
*/
IV_FLD_TYPE_T e4_fld_type;
/**
* ts
*/
UWORD32 u4_ts;
/**
* disp_buf_id
*/
UWORD32 u4_disp_buf_id;
}ivd_get_display_frame_op_t;
@ -370,14 +578,24 @@ typedef struct
typedef struct
{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* cmd
*/
IVD_API_COMMAND_TYPE_T e_cmd;
/**
* num_disp_bufs
*/
UWORD32 num_disp_bufs;
/* output buffer desc */
/**
* output buffer desc
*/
ivd_out_bufdesc_t s_disp_buffer[IVD_VIDDEC_MAX_IO_BUFFERS];
}ivd_set_display_frame_ip_t;
@ -385,8 +603,14 @@ typedef struct
typedef struct
{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* error code
*/
UWORD32 u4_error_code;
}ivd_set_display_frame_op_t;
@ -400,17 +624,33 @@ typedef struct
typedef struct
{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* e_cmd
*/
IVD_API_COMMAND_TYPE_T e_cmd;
/**
* disp_buf_id
*/
UWORD32 u4_disp_buf_id;
}ivd_rel_display_frame_ip_t;
typedef struct
{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* error code
*/
UWORD32 u4_error_code;
}ivd_rel_display_frame_op_t;
@ -423,16 +663,32 @@ typedef struct
typedef struct{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* cmd
*/
IVD_API_COMMAND_TYPE_T e_cmd;
/**
* sub_cmd
*/
IVD_CONTROL_API_COMMAND_TYPE_T e_sub_cmd;
}ivd_ctl_flush_ip_t;
typedef struct{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* error code
*/
UWORD32 u4_error_code;
}ivd_ctl_flush_op_t;
@ -444,16 +700,33 @@ typedef struct{
typedef struct{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* cmd
*/
IVD_API_COMMAND_TYPE_T e_cmd;
/**
* sub_cmd
*/
IVD_CONTROL_API_COMMAND_TYPE_T e_sub_cmd;
}ivd_ctl_reset_ip_t;
typedef struct{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* error code
*/
UWORD32 u4_error_code;
}ivd_ctl_reset_op_t;
@ -468,20 +741,52 @@ typedef struct{
typedef struct {
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* cmd
*/
IVD_API_COMMAND_TYPE_T e_cmd;
/**
* sub_cmd
*/
IVD_CONTROL_API_COMMAND_TYPE_T e_sub_cmd;
/**
* vid_dec_mode
*/
IVD_VIDEO_DECODE_MODE_T e_vid_dec_mode;
/**
* disp_wd
*/
UWORD32 u4_disp_wd;
/**
* frm_skip_mode
*/
IVD_FRAME_SKIP_MODE_T e_frm_skip_mode;
/**
* frm_out_mode
*/
IVD_DISPLAY_FRAME_OUT_MODE_T e_frm_out_mode;
}ivd_ctl_set_config_ip_t;
typedef struct{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* u4_error_code
*/
UWORD32 u4_error_code;
}ivd_ctl_set_config_op_t;
@ -494,26 +799,57 @@ typedef struct{
typedef struct{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* e_cmd
*/
IVD_API_COMMAND_TYPE_T e_cmd;
/**
* sub_cmd
*/
IVD_CONTROL_API_COMMAND_TYPE_T e_sub_cmd;
}ivd_ctl_getbufinfo_ip_t;
typedef struct{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* error code
*/
UWORD32 u4_error_code;
/* no of display buffer sets required by codec */
/**
* no of display buffer sets required by codec
*/
UWORD32 u4_num_disp_bufs;
/* no of input buffers required for codec */
/**
* no of input buffers required for codec
*/
UWORD32 u4_min_num_in_bufs;
/* no of output buffers required for codec */
/**
* no of output buffers required for codec
*/
UWORD32 u4_min_num_out_bufs;
/* sizes of each input buffer required */
/**
* sizes of each input buffer required
*/
UWORD32 u4_min_in_buf_size[IVD_VIDDEC_MAX_IO_BUFFERS];
/* sizes of each output buffer required */
/**
* sizes of each output buffer required
*/
UWORD32 u4_min_out_buf_size[IVD_VIDDEC_MAX_IO_BUFFERS];
}ivd_ctl_getbufinfo_op_t;
@ -528,31 +864,88 @@ typedef struct{
typedef struct{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* cmd
*/
IVD_API_COMMAND_TYPE_T e_cmd;
/**
* sub_cmd
*/
IVD_CONTROL_API_COMMAND_TYPE_T e_sub_cmd;
}ivd_ctl_getstatus_ip_t;
typedef struct{
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* error code
*/
UWORD32 u4_error_code;
/* no of display buffer sets required by codec */
/**
* no of display buffer sets required by codec
*/
UWORD32 u4_num_disp_bufs;
/**
* u4_pic_ht
*/
UWORD32 u4_pic_ht;
/**
* u4_pic_wd
*/
UWORD32 u4_pic_wd;
/**
* frame_rate
*/
UWORD32 u4_frame_rate;
/**
* u4_bit_rate
*/
UWORD32 u4_bit_rate;
/**
* content_type
*/
IV_CONTENT_TYPE_T e_content_type;
/**
* output_chroma_format
*/
IV_COLOR_FORMAT_T e_output_chroma_format;
/* no of input buffers required for codec */
/**
* no of input buffers required for codec
*/
UWORD32 u4_min_num_in_bufs;
/* no of output buffers required for codec */
/**
* no of output buffers required for codec
*/
UWORD32 u4_min_num_out_bufs;
/* sizes of each input buffer required */
/**
* sizes of each input buffer required
*/
UWORD32 u4_min_in_buf_size[IVD_VIDDEC_MAX_IO_BUFFERS];
/* sizes of each output buffer required */
/**
* sizes of each output buffer required
*/
UWORD32 u4_min_out_buf_size[IVD_VIDDEC_MAX_IO_BUFFERS];
}ivd_ctl_getstatus_op_t;
@ -566,18 +959,42 @@ typedef struct{
typedef struct{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* cmd
*/
IVD_API_COMMAND_TYPE_T e_cmd;
/**
* sub_cmd
*/
IVD_CONTROL_API_COMMAND_TYPE_T e_sub_cmd;
/**
* pv_version_buffer
*/
void *pv_version_buffer;
/**
* version_buffer_size
*/
UWORD32 u4_version_buffer_size;
}ivd_ctl_getversioninfo_ip_t;
typedef struct{
/* u4_size of the structure */
/**
* u4_size of the structure
*/
UWORD32 u4_size;
/**
* error code
*/
UWORD32 u4_error_code;
}ivd_ctl_getversioninfo_op_t;

View file

@ -64,7 +64,9 @@
#include <sys/time.h>
#endif
//#define ADAPTIVE_TEST
#define ADAPTIVE_MAX_WD 1920
#define ADAPTIVE_MAX_HT 1088
#define ALIGN8(x) ((((x) + 7) >> 3) << 3)
#define NUM_DISPLAY_BUFFERS 4
@ -211,9 +213,6 @@ typedef struct
UWORD32 display;
UWORD32 full_screen;
UWORD32 fps;
UWORD32 max_wd;
UWORD32 max_ht;
UWORD32 max_level;
UWORD32 u4_strd;
@ -268,9 +267,6 @@ typedef enum
FULLSCREEN,
FPS,
TRACE,
MAX_WD,
MAX_HT,
MAX_LEVEL,
CONFIG,
DEGRADE_TYPE,
@ -332,13 +328,6 @@ static const argument_t argument_mapping[] =
"FPS to be used for display \n" },
{"-i", "--trace", TRACE,
"Trace file\n"},
{ "--", "--max_wd", MAX_WD,
"Maximum width (Default: 2560) \n" },
{ "--", "--max_ht", MAX_HT,
"Maximum height (Default: 1600)\n" },
{ "--", "--max_level", MAX_LEVEL,
"Maximum Decoder Level (Default: 50)\n" },
{"--", "--degrade_type", DEGRADE_TYPE,
"Degrade type : 0: No degrade 0th bit set : Disable SAO 1st bit set : Disable deblocking 2nd bit set : Faster inter prediction filters 3rd bit set : Fastest inter prediction filters\n" },
@ -353,11 +342,6 @@ static const argument_t argument_mapping[] =
};
#define PEAK_WINDOW_SIZE 8
#define MAX_FRAME_WIDTH 2560
#define MAX_FRAME_HEIGHT 1600
#define MAX_LEVEL_SUPPORTED 50
#define MAX_REF_FRAMES 16
#define MAX_REORDER_FRAMES 16
#define DEFAULT_SHARE_DISPLAY_BUF 0
#define STRIDE 0
#define DEFAULT_NUM_CORES 1
@ -431,39 +415,45 @@ int raise(int a)
/* */
/*****************************************************************************/
void * ih264a_aligned_malloc(WORD32 alignment, WORD32 i4_size)
void * ih264a_aligned_malloc(void *pv_ctxt, WORD32 alignment, WORD32 i4_size)
{
(void)pv_ctxt;
return (void *)_aligned_malloc(i4_size, alignment);
}
void ih264a_aligned_free(void *pv_buf)
void ih264a_aligned_free(void *pv_ctxt, void *pv_buf)
{
(void)pv_ctxt;
_aligned_free(pv_buf);
return;
}
#endif
#if IOS
void * ih264a_aligned_malloc(WORD32 alignment, WORD32 i4_size)
void * ih264a_aligned_malloc(void *pv_ctxt, WORD32 alignment, WORD32 i4_size)
{
(void)pv_ctxt;
return malloc(i4_size);
}
void ih264a_aligned_free(void *pv_buf)
void ih264a_aligned_free(void *pv_ctxt, void *pv_buf)
{
(void)pv_ctxt;
free(pv_buf);
return;
}
#endif
#if (!defined(IOS)) && (!defined(_WIN32))
void * ih264a_aligned_malloc(WORD32 alignment, WORD32 i4_size)
void * ih264a_aligned_malloc(void *pv_ctxt, WORD32 alignment, WORD32 i4_size)
{
(void)pv_ctxt;
return memalign(alignment, i4_size);
}
void ih264a_aligned_free(void *pv_buf)
void ih264a_aligned_free(void *pv_ctxt, void *pv_buf)
{
(void)pv_ctxt;
free(pv_buf);
return;
}
@ -1252,15 +1242,6 @@ void parse_argument(vid_dec_ctx_t *ps_app_ctx, CHAR *argument, CHAR *value)
if(ps_app_ctx->fps <= 0)
ps_app_ctx->fps = DEFAULT_FPS;
break;
case MAX_WD:
sscanf(value, "%d", &ps_app_ctx->max_wd);
break;
case MAX_HT:
sscanf(value, "%d", &ps_app_ctx->max_ht);
break;
case MAX_LEVEL:
sscanf(value, "%d", &ps_app_ctx->max_level);
break;
case ARCH:
if((strcmp(value, "ARM_NONEON")) == 0)
ps_app_ctx->e_arch = ARCH_ARM_NONEON;
@ -1558,8 +1539,8 @@ WORD32 display_thread(void *pv_ctx)
ps_app_ctx->u4_pic_ht,
ps_app_ctx->i4_screen_wd,
ps_app_ctx->i4_screen_ht,
ps_app_ctx->max_wd,
ps_app_ctx->max_ht,
ps_app_ctx->u4_pic_wd,
ps_app_ctx->u4_pic_ht,
ps_app_ctx->full_screen,
&ps_app_ctx->quit,
&ps_app_ctx->paused);
@ -1813,12 +1794,10 @@ int main(WORD32 argc, CHAR *argv[])
ivd_out_bufdesc_t *ps_out_buf;
UWORD32 u4_num_bytes_dec = 0;
UWORD32 file_pos = 0;
IV_API_CALL_STATUS_T e_dec_status;
UWORD32 u4_ip_frm_ts = 0, u4_op_frm_ts = 0;
WORD32 u4_bytes_remaining = 0;
void *pv_mem_rec_location;
UWORD32 u4_num_mem_recs;
UWORD32 i;
UWORD32 u4_ip_buf_len;
UWORD32 frm_cnt = 0;
@ -1910,9 +1889,6 @@ int main(WORD32 argc, CHAR *argv[])
s_app_ctx.u4_num_cores = DEFAULT_NUM_CORES;
s_app_ctx.i4_degrade_type = 0;
s_app_ctx.i4_degrade_pics = 0;
s_app_ctx.max_wd = 0;
s_app_ctx.max_ht = 0;
s_app_ctx.max_level = 0;
s_app_ctx.e_arch = ARCH_ARM_A9Q;
s_app_ctx.e_soc = SOC_GENERIC;
@ -2134,144 +2110,37 @@ int main(WORD32 argc, CHAR *argv[])
ps_out_buf = (ivd_out_bufdesc_t *)malloc(sizeof(ivd_out_bufdesc_t));
{
iv_num_mem_rec_ip_t s_no_of_mem_rec_query_ip;
iv_num_mem_rec_op_t s_no_of_mem_rec_query_op;
s_no_of_mem_rec_query_ip.u4_size = sizeof(s_no_of_mem_rec_query_ip);
s_no_of_mem_rec_query_op.u4_size = sizeof(s_no_of_mem_rec_query_op);
s_no_of_mem_rec_query_ip.e_cmd = IV_CMD_GET_NUM_MEM_REC;
/*****************************************************************************/
/* API Call: Get Number of Mem Records */
/*****************************************************************************/
e_dec_status = ivd_api_function(
NULL, (void*)&s_no_of_mem_rec_query_ip,
(void*)&s_no_of_mem_rec_query_op);
if(IV_SUCCESS != e_dec_status)
{
sprintf(ac_error_str, "Error in get mem records");
codec_exit(ac_error_str);
}
u4_num_mem_recs = s_no_of_mem_rec_query_op.u4_num_mem_rec;
}
pv_mem_rec_location = malloc(u4_num_mem_recs * sizeof(iv_mem_rec_t));
if(pv_mem_rec_location == NULL)
{
sprintf(ac_error_str, "Allocation failure for mem_rec_location");
codec_exit(ac_error_str);
}
{
ih264d_fill_mem_rec_ip_t s_fill_mem_rec_ip;
ih264d_fill_mem_rec_op_t s_fill_mem_rec_op;
iv_mem_rec_t *ps_mem_rec;
UWORD32 total_size;
s_fill_mem_rec_ip.s_ivd_fill_mem_rec_ip_t.e_cmd =
IV_CMD_FILL_NUM_MEM_REC;
s_fill_mem_rec_ip.s_ivd_fill_mem_rec_ip_t.pv_mem_rec_location =
(iv_mem_rec_t *)pv_mem_rec_location;
s_fill_mem_rec_ip.s_ivd_fill_mem_rec_ip_t.u4_max_frm_wd =
(s_app_ctx.max_wd == 0) ? MAX_FRAME_WIDTH : s_app_ctx.max_wd;
s_fill_mem_rec_ip.s_ivd_fill_mem_rec_ip_t.u4_max_frm_ht =
(s_app_ctx.max_ht == 0) ? MAX_FRAME_HEIGHT : s_app_ctx.max_ht;
s_fill_mem_rec_ip.i4_level = (s_app_ctx.max_level == 0) ? MAX_LEVEL_SUPPORTED : s_app_ctx.max_level;
s_fill_mem_rec_ip.u4_num_ref_frames = MAX_REF_FRAMES;
s_fill_mem_rec_ip.u4_num_reorder_frames = MAX_REORDER_FRAMES;
s_fill_mem_rec_ip.u4_share_disp_buf = s_app_ctx.u4_share_disp_buf;
s_fill_mem_rec_ip.e_output_format =
(IV_COLOR_FORMAT_T)s_app_ctx.e_output_chroma_format;
s_fill_mem_rec_ip.u4_num_extra_disp_buf = EXTRA_DISP_BUFFERS;
s_fill_mem_rec_ip.s_ivd_fill_mem_rec_ip_t.u4_size =
sizeof(ih264d_fill_mem_rec_ip_t);
s_fill_mem_rec_op.s_ivd_fill_mem_rec_op_t.u4_size =
sizeof(ih264d_fill_mem_rec_op_t);
ps_mem_rec = (iv_mem_rec_t *)pv_mem_rec_location;
for(i = 0; i < u4_num_mem_recs; i++)
ps_mem_rec[i].u4_size = sizeof(iv_mem_rec_t);
/*****************************************************************************/
/* API Call: Fill Mem Records */
/*****************************************************************************/
e_dec_status = ivd_api_function(NULL,
(void *)&s_fill_mem_rec_ip,
(void *)&s_fill_mem_rec_op);
u4_num_mem_recs =
s_fill_mem_rec_op.s_ivd_fill_mem_rec_op_t.u4_num_mem_rec_filled;
if(IV_SUCCESS != e_dec_status)
{
sprintf(ac_error_str, "Error in fill mem records: %x",s_fill_mem_rec_op.s_ivd_fill_mem_rec_op_t.u4_error_code);
codec_exit(ac_error_str);
}
ps_mem_rec = (iv_mem_rec_t *)pv_mem_rec_location;
total_size = 0;
for(i = 0; i < u4_num_mem_recs; i++)
{
ps_mem_rec->pv_base = ih264a_aligned_malloc(ps_mem_rec->u4_mem_alignment,
ps_mem_rec->u4_mem_size);
if(ps_mem_rec->pv_base == NULL)
{
sprintf(ac_error_str,
"\nAllocation failure for mem record id %d i4_size %d\n",
i, ps_mem_rec->u4_mem_size);
codec_exit(ac_error_str);
}
total_size += ps_mem_rec->u4_mem_size;
ps_mem_rec++;
}
printf("\nTotal memory for codec %d\n", total_size);
}
/*****************************************************************************/
/* API Call: Initialize the Decoder */
/*****************************************************************************/
{
ih264d_init_ip_t s_init_ip;
ih264d_init_op_t s_init_op;
ih264d_create_ip_t s_create_ip;
ih264d_create_op_t s_create_op;
void *fxns = &ivd_api_function;
iv_mem_rec_t *mem_tab;
mem_tab = (iv_mem_rec_t*)pv_mem_rec_location;
s_init_ip.s_ivd_init_ip_t.e_cmd = (IVD_API_COMMAND_TYPE_T)IV_CMD_INIT;
s_init_ip.s_ivd_init_ip_t.pv_mem_rec_location = mem_tab;
s_init_ip.s_ivd_init_ip_t.u4_frm_max_wd = (s_app_ctx.max_wd == 0) ? MAX_FRAME_WIDTH : s_app_ctx.max_wd;
s_init_ip.s_ivd_init_ip_t.u4_frm_max_ht = (s_app_ctx.max_ht == 0) ? MAX_FRAME_HEIGHT : s_app_ctx.max_ht;
s_init_ip.i4_level = (s_app_ctx.max_level == 0) ? MAX_LEVEL_SUPPORTED : s_app_ctx.max_level;
s_init_ip.u4_num_ref_frames = MAX_REF_FRAMES;
s_init_ip.u4_num_reorder_frames = MAX_REORDER_FRAMES;
s_init_ip.u4_share_disp_buf = s_app_ctx.u4_share_disp_buf;
s_init_ip.u4_num_extra_disp_buf = EXTRA_DISP_BUFFERS;
s_init_ip.s_ivd_init_ip_t.u4_num_mem_rec = u4_num_mem_recs;
s_init_ip.s_ivd_init_ip_t.e_output_format =
(IV_COLOR_FORMAT_T)s_app_ctx.e_output_chroma_format;
s_init_ip.s_ivd_init_ip_t.u4_size = sizeof(ih264d_init_ip_t);
s_init_op.s_ivd_init_op_t.u4_size = sizeof(ih264d_init_op_t);
s_create_ip.s_ivd_create_ip_t.e_cmd = IVD_CMD_CREATE;
s_create_ip.s_ivd_create_ip_t.u4_share_disp_buf = s_app_ctx.u4_share_disp_buf;
s_create_ip.s_ivd_create_ip_t.e_output_format = (IV_COLOR_FORMAT_T)s_app_ctx.e_output_chroma_format;
s_create_ip.s_ivd_create_ip_t.pf_aligned_alloc = ih264a_aligned_malloc;
s_create_ip.s_ivd_create_ip_t.pf_aligned_free = ih264a_aligned_free;
s_create_ip.s_ivd_create_ip_t.pv_mem_ctxt = NULL;
s_create_ip.s_ivd_create_ip_t.u4_size = sizeof(ih264d_create_ip_t);
s_create_op.s_ivd_create_op_t.u4_size = sizeof(ih264d_create_op_t);
codec_obj = (iv_obj_t*)mem_tab[0].pv_base;
codec_obj->pv_fxns = fxns;
codec_obj->u4_size = sizeof(iv_obj_t);
s_app_ctx.cocodec_obj = codec_obj;
ret = ivd_api_function((iv_obj_t*)codec_obj, (void *)&s_init_ip,
(void *)&s_init_op);
ret = ivd_api_function(NULL, (void *)&s_create_ip,
(void *)&s_create_op);
if(ret != IV_SUCCESS)
{
sprintf(ac_error_str, "Error in Init %8x\n",
s_init_op.s_ivd_init_op_t.u4_error_code);
sprintf(ac_error_str, "Error in Create %8x\n",
s_create_op.s_ivd_create_op_t.u4_error_code);
codec_exit(ac_error_str);
}
codec_obj = (iv_obj_t*)s_create_op.s_ivd_create_op_t.pv_handle;
codec_obj->pv_fxns = fxns;
codec_obj->u4_size = sizeof(iv_obj_t);
s_app_ctx.cocodec_obj = codec_obj;
/*****************************************************************************/
/* set stride */
@ -2286,7 +2155,7 @@ int main(WORD32 argc, CHAR *argv[])
s_ctl_ip.u4_disp_wd = s_app_ctx.get_stride();
s_ctl_ip.e_frm_skip_mode = IVD_SKIP_NONE;
s_ctl_ip.e_frm_out_mode = IVD_DECODE_FRAME_OUT;
s_ctl_ip.e_frm_out_mode = IVD_DISPLAY_FRAME_OUT;
s_ctl_ip.e_vid_dec_mode = IVD_DECODE_HEADER;
s_ctl_ip.e_cmd = IVD_CMD_VIDEO_CTL;
s_ctl_ip.e_sub_cmd = IVD_CMD_CTL_SETPARAMS;
@ -2304,128 +2173,7 @@ int main(WORD32 argc, CHAR *argv[])
}
/*****************************************************************************/
/* Input and output buffer allocation */
/*****************************************************************************/
{
ivd_ctl_getbufinfo_ip_t s_ctl_ip;
ivd_ctl_getbufinfo_op_t s_ctl_op;
WORD32 outlen = 0;
s_ctl_ip.e_cmd = IVD_CMD_VIDEO_CTL;
s_ctl_ip.e_sub_cmd = IVD_CMD_CTL_GETBUFINFO;
s_ctl_ip.u4_size = sizeof(ivd_ctl_getbufinfo_ip_t);
s_ctl_op.u4_size = sizeof(ivd_ctl_getbufinfo_op_t);
ret = ivd_api_function((iv_obj_t*)codec_obj, (void *)&s_ctl_ip,
(void *)&s_ctl_op);
if(ret != IV_SUCCESS)
{
sprintf(ac_error_str, "Error in Get Buf Info %x", s_ctl_op.u4_error_code);
codec_exit(ac_error_str);
}
/* Allocate input buffer */
u4_ip_buf_len = s_ctl_op.u4_min_in_buf_size[0];
pu1_bs_buf = (UWORD8 *)malloc(u4_ip_buf_len);
if(pu1_bs_buf == NULL)
{
sprintf(ac_error_str,
"\nAllocation failure for input buffer of i4_size %d",
u4_ip_buf_len);
codec_exit(ac_error_str);
}
s_app_ctx.num_disp_buf = s_ctl_op.u4_num_disp_bufs;
/* Allocate output buffer only if display buffers are not shared */
/* Or if shared and output is 420P */
if((0 == s_app_ctx.u4_share_disp_buf) || (IV_YUV_420P == s_app_ctx.e_output_chroma_format))
{
ps_out_buf->u4_min_out_buf_size[0] =
s_ctl_op.u4_min_out_buf_size[0];
ps_out_buf->u4_min_out_buf_size[1] =
s_ctl_op.u4_min_out_buf_size[1];
ps_out_buf->u4_min_out_buf_size[2] =
s_ctl_op.u4_min_out_buf_size[2];
outlen = s_ctl_op.u4_min_out_buf_size[0];
if(s_ctl_op.u4_min_num_out_bufs > 1)
outlen += s_ctl_op.u4_min_out_buf_size[1];
if(s_ctl_op.u4_min_num_out_bufs > 2)
outlen += s_ctl_op.u4_min_out_buf_size[2];
ps_out_buf->pu1_bufs[0] = (UWORD8 *)malloc(outlen);
if(ps_out_buf->pu1_bufs[0] == NULL)
{
sprintf(ac_error_str,
"\nAllocation failure for output buffer of i4_size %d",
outlen);
codec_exit(ac_error_str);
}
if(s_ctl_op.u4_min_num_out_bufs > 1)
ps_out_buf->pu1_bufs[1] = ps_out_buf->pu1_bufs[0]
+ (s_ctl_op.u4_min_out_buf_size[0]);
if(s_ctl_op.u4_min_num_out_bufs > 2)
ps_out_buf->pu1_bufs[2] = ps_out_buf->pu1_bufs[1]
+ (s_ctl_op.u4_min_out_buf_size[1]);
ps_out_buf->u4_num_bufs = s_ctl_op.u4_min_num_out_bufs;
}
#ifdef APP_EXTRA_BUFS
s_app_ctx.disp_delay = EXTRA_DISP_BUFFERS;
s_ctl_op.u4_num_disp_bufs += EXTRA_DISP_BUFFERS;
#endif
/*****************************************************************************/
/* API Call: Allocate display buffers for display buffer shared case */
/*****************************************************************************/
for(i = 0; i < s_ctl_op.u4_num_disp_bufs; i++)
{
s_app_ctx.s_disp_buffers[i].u4_min_out_buf_size[0] =
s_ctl_op.u4_min_out_buf_size[0];
s_app_ctx.s_disp_buffers[i].u4_min_out_buf_size[1] =
s_ctl_op.u4_min_out_buf_size[1];
s_app_ctx.s_disp_buffers[i].u4_min_out_buf_size[2] =
s_ctl_op.u4_min_out_buf_size[2];
outlen = s_ctl_op.u4_min_out_buf_size[0];
if(s_ctl_op.u4_min_num_out_bufs > 1)
outlen += s_ctl_op.u4_min_out_buf_size[1];
if(s_ctl_op.u4_min_num_out_bufs > 2)
outlen += s_ctl_op.u4_min_out_buf_size[2];
s_app_ctx.s_disp_buffers[i].pu1_bufs[0] = (UWORD8 *)malloc(outlen);
if(s_app_ctx.s_disp_buffers[i].pu1_bufs[0] == NULL)
{
sprintf(ac_error_str,
"\nAllocation failure for output buffer of i4_size %d",
outlen);
codec_exit(ac_error_str);
}
if(s_ctl_op.u4_min_num_out_bufs > 1)
s_app_ctx.s_disp_buffers[i].pu1_bufs[1] =
s_app_ctx.s_disp_buffers[i].pu1_bufs[0]
+ (s_ctl_op.u4_min_out_buf_size[0]);
if(s_ctl_op.u4_min_num_out_bufs > 2)
s_app_ctx.s_disp_buffers[i].pu1_bufs[2] =
s_app_ctx.s_disp_buffers[i].pu1_bufs[1]
+ (s_ctl_op.u4_min_out_buf_size[1]);
s_app_ctx.s_disp_buffers[i].u4_num_bufs =
s_ctl_op.u4_min_num_out_bufs;
}
s_app_ctx.num_disp_buf = s_ctl_op.u4_num_disp_bufs;
}
}
}
@ -2485,37 +2233,54 @@ int main(WORD32 argc, CHAR *argv[])
/* Decode header to get width and height and buffer sizes */
/*****************************************************************************/
{
ivd_ctl_set_config_ip_t s_ctl_ip;
ivd_ctl_set_config_op_t s_ctl_op;
ivd_video_decode_ip_t s_video_decode_ip;
ivd_video_decode_op_t s_video_decode_op;
s_ctl_ip.u4_disp_wd = STRIDE;
if(1 == s_app_ctx.display)
s_ctl_ip.u4_disp_wd = s_app_ctx.get_stride();
s_ctl_ip.e_frm_skip_mode = IVD_SKIP_NONE;
s_ctl_ip.e_frm_out_mode = IVD_DISPLAY_FRAME_OUT;
s_ctl_ip.e_vid_dec_mode = IVD_DECODE_HEADER;
s_ctl_ip.e_cmd = IVD_CMD_VIDEO_CTL;
s_ctl_ip.e_sub_cmd = IVD_CMD_CTL_SETPARAMS;
s_ctl_ip.u4_size = sizeof(ivd_ctl_set_config_ip_t);
s_ctl_op.u4_size = sizeof(ivd_ctl_set_config_op_t);
ret = ivd_api_function((iv_obj_t*)codec_obj, (void *)&s_ctl_ip,
(void *)&s_ctl_op);
if(ret != IV_SUCCESS)
{
ivd_ctl_set_config_ip_t s_ctl_ip;
ivd_ctl_set_config_op_t s_ctl_op;
s_ctl_ip.u4_disp_wd = STRIDE;
if(1 == s_app_ctx.display)
s_ctl_ip.u4_disp_wd = s_app_ctx.get_stride();
s_ctl_ip.e_frm_skip_mode = IVD_SKIP_NONE;
s_ctl_ip.e_frm_out_mode = IVD_DISPLAY_FRAME_OUT;
s_ctl_ip.e_vid_dec_mode = IVD_DECODE_HEADER;
s_ctl_ip.e_cmd = IVD_CMD_VIDEO_CTL;
s_ctl_ip.e_sub_cmd = IVD_CMD_CTL_SETPARAMS;
s_ctl_ip.u4_size = sizeof(ivd_ctl_set_config_ip_t);
s_ctl_op.u4_size = sizeof(ivd_ctl_set_config_op_t);
ret = ivd_api_function((iv_obj_t*)codec_obj, (void *)&s_ctl_ip,
(void *)&s_ctl_op);
if(ret != IV_SUCCESS)
{
sprintf(ac_error_str,
"\nError in setting the codec in header decode mode");
codec_exit(ac_error_str);
}
}
/* Allocate input buffer for header */
u4_ip_buf_len = 256 * 1024;
pu1_bs_buf = (UWORD8 *)malloc(u4_ip_buf_len);
if(pu1_bs_buf == NULL)
{
sprintf(ac_error_str,
"\nError in setting the codec in header decode mode");
"\nAllocation failure for input buffer of i4_size %d",
u4_ip_buf_len);
codec_exit(ac_error_str);
}
do
{
WORD32 numbytes;
if(0 == s_app_ctx.u4_piclen_flag)
{
fseek(ps_ip_file, file_pos, SEEK_SET);
@ -2569,10 +2334,181 @@ int main(WORD32 argc, CHAR *argv[])
s_app_ctx.u4_pic_wd = s_video_decode_op.u4_pic_wd;
s_app_ctx.u4_pic_ht = s_video_decode_op.u4_pic_ht;
/* Allocate input buffer */
u4_ip_buf_len = 2048 * 2048;
free(pu1_bs_buf);
#if IOS_DISPLAY
s_app_ctx.i4_screen_wd = screen_wd;
s_app_ctx.i4_screen_ht = screen_ht;
#endif
{
ivd_ctl_getbufinfo_ip_t s_ctl_ip;
ivd_ctl_getbufinfo_op_t s_ctl_op;
WORD32 outlen = 0;
s_ctl_ip.e_cmd = IVD_CMD_VIDEO_CTL;
s_ctl_ip.e_sub_cmd = IVD_CMD_CTL_GETBUFINFO;
s_ctl_ip.u4_size = sizeof(ivd_ctl_getbufinfo_ip_t);
s_ctl_op.u4_size = sizeof(ivd_ctl_getbufinfo_op_t);
ret = ivd_api_function((iv_obj_t*)codec_obj, (void *)&s_ctl_ip,
(void *)&s_ctl_op);
if(ret != IV_SUCCESS)
{
sprintf(ac_error_str, "Error in Get Buf Info %x", s_ctl_op.u4_error_code);
codec_exit(ac_error_str);
}
/* Allocate bitstream buffer */
u4_ip_buf_len = s_ctl_op.u4_min_in_buf_size[0];
#ifdef ADAPTIVE_TEST
u4_ip_buf_len = ADAPTIVE_MAX_WD * ADAPTIVE_MAX_HT * 3 >> 1;
#endif
pu1_bs_buf = (UWORD8 *)malloc(u4_ip_buf_len);
if(pu1_bs_buf == NULL)
{
sprintf(ac_error_str,
"\nAllocation failure for input buffer of i4_size %d",
u4_ip_buf_len);
codec_exit(ac_error_str);
}
s_app_ctx.num_disp_buf = s_ctl_op.u4_num_disp_bufs;
/* Allocate output buffer only if display buffers are not shared */
/* Or if shared and output is 420P */
if((0 == s_app_ctx.u4_share_disp_buf) || (IV_YUV_420P == s_app_ctx.e_output_chroma_format))
{
#ifdef ADAPTIVE_TEST
switch(s_app_ctx.e_output_chroma_format)
{
case IV_YUV_420P:
{
s_ctl_op.u4_min_out_buf_size[0] = ADAPTIVE_MAX_WD * ADAPTIVE_MAX_HT;
s_ctl_op.u4_min_out_buf_size[1] = ADAPTIVE_MAX_WD * ADAPTIVE_MAX_HT >> 2;
s_ctl_op.u4_min_out_buf_size[2] = ADAPTIVE_MAX_WD * ADAPTIVE_MAX_HT >> 2;
break;
}
case IV_YUV_420SP_UV:
case IV_YUV_420SP_VU:
{
s_ctl_op.u4_min_out_buf_size[0] = ADAPTIVE_MAX_WD * ADAPTIVE_MAX_HT;
s_ctl_op.u4_min_out_buf_size[1] = ADAPTIVE_MAX_WD * ADAPTIVE_MAX_HT >> 1;
s_ctl_op.u4_min_out_buf_size[2] = 0;
break;
}
case IV_YUV_422ILE:
{
s_ctl_op.u4_min_out_buf_size[0] = ADAPTIVE_MAX_WD * ADAPTIVE_MAX_HT * 2;
s_ctl_op.u4_min_out_buf_size[1] = 0;
s_ctl_op.u4_min_out_buf_size[2] = 0;
break;
}
case IV_RGBA_8888:
{
s_ctl_op.u4_min_out_buf_size[0] = ADAPTIVE_MAX_WD * ADAPTIVE_MAX_HT * 4;
s_ctl_op.u4_min_out_buf_size[1] = 0;
s_ctl_op.u4_min_out_buf_size[2] = 0;
break;
}
case IV_RGB_565:
{
s_ctl_op.u4_min_out_buf_size[0] = ADAPTIVE_MAX_WD * ADAPTIVE_MAX_HT * 2;
s_ctl_op.u4_min_out_buf_size[1] = 0;
s_ctl_op.u4_min_out_buf_size[2] = 0;
break;
}
default:
break;
}
#endif
ps_out_buf->u4_min_out_buf_size[0] =
s_ctl_op.u4_min_out_buf_size[0];
ps_out_buf->u4_min_out_buf_size[1] =
s_ctl_op.u4_min_out_buf_size[1];
ps_out_buf->u4_min_out_buf_size[2] =
s_ctl_op.u4_min_out_buf_size[2];
outlen = s_ctl_op.u4_min_out_buf_size[0];
if(s_ctl_op.u4_min_num_out_bufs > 1)
outlen += s_ctl_op.u4_min_out_buf_size[1];
if(s_ctl_op.u4_min_num_out_bufs > 2)
outlen += s_ctl_op.u4_min_out_buf_size[2];
ps_out_buf->pu1_bufs[0] = (UWORD8 *)malloc(outlen);
if(ps_out_buf->pu1_bufs[0] == NULL)
{
sprintf(ac_error_str,
"\nAllocation failure for output buffer of i4_size %d",
outlen);
codec_exit(ac_error_str);
}
if(s_ctl_op.u4_min_num_out_bufs > 1)
ps_out_buf->pu1_bufs[1] = ps_out_buf->pu1_bufs[0]
+ (s_ctl_op.u4_min_out_buf_size[0]);
if(s_ctl_op.u4_min_num_out_bufs > 2)
ps_out_buf->pu1_bufs[2] = ps_out_buf->pu1_bufs[1]
+ (s_ctl_op.u4_min_out_buf_size[1]);
ps_out_buf->u4_num_bufs = s_ctl_op.u4_min_num_out_bufs;
}
#ifdef APP_EXTRA_BUFS
s_app_ctx.disp_delay = EXTRA_DISP_BUFFERS;
s_ctl_op.u4_num_disp_bufs += EXTRA_DISP_BUFFERS;
#endif
/*****************************************************************************/
/* API Call: Allocate display buffers for display buffer shared case */
/*****************************************************************************/
for(i = 0; i < s_ctl_op.u4_num_disp_bufs; i++)
{
s_app_ctx.s_disp_buffers[i].u4_min_out_buf_size[0] =
s_ctl_op.u4_min_out_buf_size[0];
s_app_ctx.s_disp_buffers[i].u4_min_out_buf_size[1] =
s_ctl_op.u4_min_out_buf_size[1];
s_app_ctx.s_disp_buffers[i].u4_min_out_buf_size[2] =
s_ctl_op.u4_min_out_buf_size[2];
outlen = s_ctl_op.u4_min_out_buf_size[0];
if(s_ctl_op.u4_min_num_out_bufs > 1)
outlen += s_ctl_op.u4_min_out_buf_size[1];
if(s_ctl_op.u4_min_num_out_bufs > 2)
outlen += s_ctl_op.u4_min_out_buf_size[2];
s_app_ctx.s_disp_buffers[i].pu1_bufs[0] = (UWORD8 *)malloc(outlen);
if(s_app_ctx.s_disp_buffers[i].pu1_bufs[0] == NULL)
{
sprintf(ac_error_str,
"\nAllocation failure for output buffer of i4_size %d",
outlen);
codec_exit(ac_error_str);
}
if(s_ctl_op.u4_min_num_out_bufs > 1)
s_app_ctx.s_disp_buffers[i].pu1_bufs[1] =
s_app_ctx.s_disp_buffers[i].pu1_bufs[0]
+ (s_ctl_op.u4_min_out_buf_size[0]);
if(s_ctl_op.u4_min_num_out_bufs > 2)
s_app_ctx.s_disp_buffers[i].pu1_bufs[2] =
s_app_ctx.s_disp_buffers[i].pu1_bufs[1]
+ (s_ctl_op.u4_min_out_buf_size[1]);
s_app_ctx.s_disp_buffers[i].u4_num_bufs =
s_ctl_op.u4_min_num_out_bufs;
}
s_app_ctx.num_disp_buf = s_ctl_op.u4_num_disp_bufs;
}
/* Create display thread and wait for the display buffers to be initialized */
if(1 == s_app_ctx.display)
@ -3034,7 +2970,6 @@ int main(WORD32 argc, CHAR *argv[])
}
}
}
@ -3158,39 +3093,21 @@ int main(WORD32 argc, CHAR *argv[])
}
{
iv_retrieve_mem_rec_ip_t s_retrieve_dec_ip;
iv_retrieve_mem_rec_op_t s_retrieve_dec_op;
s_retrieve_dec_ip.pv_mem_rec_location = (iv_mem_rec_t *)pv_mem_rec_location;
ivd_delete_ip_t s_delete_dec_ip;
ivd_delete_op_t s_delete_dec_op;
s_retrieve_dec_ip.e_cmd = IV_CMD_RETRIEVE_MEMREC;
s_retrieve_dec_ip.u4_size = sizeof(iv_retrieve_mem_rec_ip_t);
s_retrieve_dec_op.u4_size = sizeof(iv_retrieve_mem_rec_op_t);
s_delete_dec_ip.e_cmd = IVD_CMD_DELETE;
s_delete_dec_ip.u4_size = sizeof(ivd_delete_ip_t);
s_delete_dec_op.u4_size = sizeof(ivd_delete_op_t);
ret = ivd_api_function((iv_obj_t *)codec_obj, (void *)&s_retrieve_dec_ip,
(void *)&s_retrieve_dec_op);
ret = ivd_api_function((iv_obj_t *)codec_obj, (void *)&s_delete_dec_ip,
(void *)&s_delete_dec_op);
if(IV_SUCCESS != ret)
{
sprintf(ac_error_str, "Error in Retrieve Memrec");
sprintf(ac_error_str, "Error in Codec delete");
codec_exit(ac_error_str);
}
{
iv_mem_rec_t *ps_mem_rec;
UWORD16 u2_i;
u4_num_mem_recs = s_retrieve_dec_op.u4_num_mem_rec_filled;
ps_mem_rec = s_retrieve_dec_ip.pv_mem_rec_location;
for(u2_i = 0; u2_i < u4_num_mem_recs; u2_i++)
{
ih264a_aligned_free(ps_mem_rec->pv_base);
ps_mem_rec++;
}
free(s_retrieve_dec_ip.pv_mem_rec_location);
}
}
/***********************************************************************/
/* Close all the files and free all the memory */