am 63ac8091: (-s ours) am 8ce82804: Fixed issue in cost computation for BIPRED ME
* commit '63ac8091838cefbe837baa4b536e32c732979070':
diff --git a/decoder/ih264d.h b/decoder/ih264d.h
index 6dd9893..63a5ce1 100644
--- a/decoder/ih264d.h
+++ b/decoder/ih264d.h
@@ -78,7 +78,6 @@
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_ERROR_CODES_T;
@@ -86,60 +85,20 @@
/* 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;
/*****************************************************************************/
@@ -148,20 +107,13 @@
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;
/*****************************************************************************/
diff --git a/decoder/ih264d_api.c b/decoder/ih264d_api.c
index 6fbd834..6ef5185 100644
--- a/decoder/ih264d_api.c
+++ b/decoder/ih264d_api.c
@@ -27,11 +27,8 @@
/* */
/* List of Functions : api_check_struct_sanity */
/* ih264d_set_processor */
-/* ih264d_get_num_rec */
-/* ih264d_init_decoder */
-/* ih264d_init_video_decoder */
-/* ih264d_fill_num_mem_rec */
-/* ih264d_clr */
+/* ih264d_create */
+/* ih264d_delete */
/* ih264d_init */
/* ih264d_map_error */
/* ih264d_video_decode */
@@ -103,7 +100,7 @@
//Move this to where it is used
#define CODEC_NAME "H264VDEC"
#define CODEC_RELEASE_TYPE "production"
-#define CODEC_RELEASE_VER "04.00"
+#define CODEC_RELEASE_VER "05.00"
#define CODEC_VENDOR "ITTIAM"
#define MAXVERSION_STRLEN 511
#define VERSION(version_string, codec_name, codec_release_type, codec_release_ver, codec_vendor) \
@@ -111,16 +108,12 @@
"@(#)Id:%s_%s Ver:%s Released by %s Build: %s @ %s", \
codec_name, codec_release_type, codec_release_ver, codec_vendor, __DATE__, __TIME__)
-#define MAX_NAL_UNIT_SIZE MAX((H264_MAX_FRAME_HEIGHT * H264_MAX_FRAME_HEIGHT),MIN_NALUNIT_SIZE)
-#define MIN_NALUNIT_SIZE 200000
-
#define MIN_IN_BUFS 1
#define MIN_OUT_BUFS_420 3
#define MIN_OUT_BUFS_422ILE 1
#define MIN_OUT_BUFS_RGB565 1
#define MIN_OUT_BUFS_420SP 2
-#define MIN_IN_BUF_SIZE (2*1024*1024) // Currently, i4_size set to 500kb, CHECK LATER
#define NUM_FRAMES_LIMIT_ENABLED 0
@@ -173,32 +166,14 @@
/* error checks on handle */
switch((WORD32)e_cmd)
{
- case IV_CMD_GET_NUM_MEM_REC:
- case IV_CMD_FILL_NUM_MEM_REC:
+ case IVD_CMD_CREATE:
break;
- case IV_CMD_INIT:
- if(ps_handle == NULL)
- {
- *(pu4_api_op + 1) |= 1 << IVD_UNSUPPORTEDPARAM;
- *(pu4_api_op + 1) |= IVD_HANDLE_NULL;
- return IV_FAIL;
- }
- if(ps_handle->u4_size != sizeof(iv_obj_t))
- {
- *(pu4_api_op + 1) |= 1 << IVD_UNSUPPORTEDPARAM;
- *(pu4_api_op + 1) |= IVD_HANDLE_STRUCT_SIZE_INCORRECT;
- H264_DEC_DEBUG_PRINT(
- "Sizes do not match. Expected: %d, Got: %d",
- sizeof(iv_obj_t), ps_handle->u4_size);
- return IV_FAIL;
- }
- break;
case IVD_CMD_REL_DISPLAY_FRAME:
case IVD_CMD_SET_DISPLAY_FRAME:
case IVD_CMD_GET_DISPLAY_FRAME:
case IVD_CMD_VIDEO_DECODE:
- case IV_CMD_RETRIEVE_MEMREC:
+ case IVD_CMD_DELETE:
case IVD_CMD_VIDEO_CTL:
if(ps_handle == NULL)
{
@@ -236,530 +211,57 @@
switch((WORD32)e_cmd)
{
- case IV_CMD_GET_NUM_MEM_REC:
+ case IVD_CMD_CREATE:
{
- ih264d_num_mem_rec_ip_t *ps_ip =
- (ih264d_num_mem_rec_ip_t *)pv_api_ip;
- ih264d_num_mem_rec_op_t *ps_op =
- (ih264d_num_mem_rec_op_t *)pv_api_op;
- ps_op->s_ivd_num_mem_rec_op_t.u4_error_code = 0;
+ ih264d_create_ip_t *ps_ip = (ih264d_create_ip_t *)pv_api_ip;
+ ih264d_create_op_t *ps_op = (ih264d_create_op_t *)pv_api_op;
- if(ps_ip->s_ivd_num_mem_rec_ip_t.u4_size
- != sizeof(ih264d_num_mem_rec_ip_t))
+
+ ps_op->s_ivd_create_op_t.u4_error_code = 0;
+
+ if((ps_ip->s_ivd_create_ip_t.u4_size > sizeof(ih264d_create_ip_t))
+ || (ps_ip->s_ivd_create_ip_t.u4_size
+ < sizeof(ivd_create_ip_t)))
{
- ps_op->s_ivd_num_mem_rec_op_t.u4_error_code |= 1
+ ps_op->s_ivd_create_op_t.u4_error_code |= 1
<< IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_num_mem_rec_op_t.u4_error_code |=
- IVD_IP_API_STRUCT_SIZE_INCORRECT;
- return (IV_FAIL);
- }
-
- if(ps_op->s_ivd_num_mem_rec_op_t.u4_size
- != sizeof(ih264d_num_mem_rec_op_t))
- {
- ps_op->s_ivd_num_mem_rec_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_num_mem_rec_op_t.u4_error_code |=
- IVD_OP_API_STRUCT_SIZE_INCORRECT;
- return (IV_FAIL);
- }
- }
- break;
- case IV_CMD_FILL_NUM_MEM_REC:
- {
- ih264d_fill_mem_rec_ip_t *ps_ip =
- (ih264d_fill_mem_rec_ip_t *)pv_api_ip;
- ih264d_fill_mem_rec_op_t *ps_op =
- (ih264d_fill_mem_rec_op_t *)pv_api_op;
- iv_mem_rec_t *ps_mem_rec;
- WORD32 max_wd = ps_ip->s_ivd_fill_mem_rec_ip_t.u4_max_frm_wd;
- WORD32 max_ht = ps_ip->s_ivd_fill_mem_rec_ip_t.u4_max_frm_ht;
-
- max_wd = ALIGN16(max_wd);
- max_ht = ALIGN32(max_ht);
-
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code = 0;
-
- if((ps_ip->s_ivd_fill_mem_rec_ip_t.u4_size
- > sizeof(ih264d_fill_mem_rec_ip_t))
- || (ps_ip->s_ivd_fill_mem_rec_ip_t.u4_size
- < sizeof(iv_fill_mem_rec_ip_t)))
- {
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code |=
- IVD_IP_API_STRUCT_SIZE_INCORRECT;
- return (IV_FAIL);
- }
-
- if((ps_op->s_ivd_fill_mem_rec_op_t.u4_size
- != sizeof(ih264d_fill_mem_rec_op_t))
- && (ps_op->s_ivd_fill_mem_rec_op_t.u4_size
- != sizeof(iv_fill_mem_rec_op_t)))
- {
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code |=
- IVD_OP_API_STRUCT_SIZE_INCORRECT;
- return (IV_FAIL);
- }
-
- if(max_wd < H264_MIN_FRAME_WIDTH)
- {
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code |=
- IVD_REQUESTED_WIDTH_NOT_SUPPPORTED;
- return (IV_FAIL);
- }
-
- if(max_wd > H264_MAX_FRAME_WIDTH)
- {
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code |=
- IVD_REQUESTED_WIDTH_NOT_SUPPPORTED;
- return (IV_FAIL);
- }
-
- if(max_ht < H264_MIN_FRAME_HEIGHT)
- {
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code |=
- IVD_REQUESTED_HEIGHT_NOT_SUPPPORTED;
- return (IV_FAIL);
- }
-
- if((max_ht * max_wd)
- > (H264_MAX_FRAME_HEIGHT * H264_MAX_FRAME_WIDTH))
-
- {
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code |=
- IVD_REQUESTED_HEIGHT_NOT_SUPPPORTED;
- return (IV_FAIL);
- }
-
- if(NULL == ps_ip->s_ivd_fill_mem_rec_ip_t.pv_mem_rec_location)
- {
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code |=
- IVD_NUM_REC_NOT_SUFFICIENT;
- return (IV_FAIL);
- }
-
- /* check memrecords sizes are correct */
- ps_mem_rec = ps_ip->s_ivd_fill_mem_rec_ip_t.pv_mem_rec_location;
- for(i = 0; i < MEM_REC_CNT; i++)
- {
- if(ps_mem_rec[i].u4_size != sizeof(iv_mem_rec_t))
- {
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_fill_mem_rec_op_t.u4_error_code |=
- IVD_MEM_REC_STRUCT_SIZE_INCORRECT;
- return IV_FAIL;
- }
- }
- }
- break;
-
- case IV_CMD_INIT:
- {
- ih264d_init_ip_t *ps_ip = (ih264d_init_ip_t *)pv_api_ip;
- ih264d_init_op_t *ps_op = (ih264d_init_op_t *)pv_api_op;
- iv_mem_rec_t *ps_mem_rec;
- WORD32 max_wd = ps_ip->s_ivd_init_ip_t.u4_frm_max_wd;
- WORD32 max_ht = ps_ip->s_ivd_init_ip_t.u4_frm_max_ht;
-
- max_wd = ALIGN16(max_wd);
- max_ht = ALIGN32(max_ht);
-
- ps_op->s_ivd_init_op_t.u4_error_code = 0;
-
- if((ps_ip->s_ivd_init_ip_t.u4_size > sizeof(ih264d_init_ip_t))
- || (ps_ip->s_ivd_init_ip_t.u4_size
- < sizeof(ivd_init_ip_t)))
- {
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
+ ps_op->s_ivd_create_op_t.u4_error_code |=
IVD_IP_API_STRUCT_SIZE_INCORRECT;
H264_DEC_DEBUG_PRINT("\n");
return (IV_FAIL);
}
- if((ps_op->s_ivd_init_op_t.u4_size != sizeof(ih264d_init_op_t))
- && (ps_op->s_ivd_init_op_t.u4_size
- != sizeof(ivd_init_op_t)))
+ if((ps_op->s_ivd_create_op_t.u4_size != sizeof(ih264d_create_op_t))
+ && (ps_op->s_ivd_create_op_t.u4_size
+ != sizeof(ivd_create_op_t)))
{
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
+ ps_op->s_ivd_create_op_t.u4_error_code |= 1
<< IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
+ ps_op->s_ivd_create_op_t.u4_error_code |=
IVD_OP_API_STRUCT_SIZE_INCORRECT;
H264_DEC_DEBUG_PRINT("\n");
return (IV_FAIL);
}
- if(ps_ip->s_ivd_init_ip_t.u4_num_mem_rec != MEM_REC_CNT)
- {
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
- IVD_INIT_DEC_NOT_SUFFICIENT;
- H264_DEC_DEBUG_PRINT("\n");
- return (IV_FAIL);
- }
- if(max_wd < H264_MIN_FRAME_WIDTH)
- {
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
- IVD_INIT_DEC_WIDTH_NOT_SUPPPORTED;
- H264_DEC_DEBUG_PRINT("\n");
- return (IV_FAIL);
- }
-
- if(max_wd > H264_MAX_FRAME_WIDTH)
- {
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
- IVD_INIT_DEC_WIDTH_NOT_SUPPPORTED;
- H264_DEC_DEBUG_PRINT("\n");
- return (IV_FAIL);
- }
-
- if(max_ht < H264_MIN_FRAME_HEIGHT)
- {
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
- IVD_INIT_DEC_HEIGHT_NOT_SUPPPORTED;
- H264_DEC_DEBUG_PRINT("\n");
- return (IV_FAIL);
- }
-
- if((max_ht * max_wd)
- > (H264_MAX_FRAME_HEIGHT * H264_MAX_FRAME_WIDTH))
-
- {
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
- IVD_INIT_DEC_HEIGHT_NOT_SUPPPORTED;
- H264_DEC_DEBUG_PRINT("\n");
- return (IV_FAIL);
- }
-
- if(NULL == ps_ip->s_ivd_init_ip_t.pv_mem_rec_location)
- {
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
- IVD_NUM_REC_NOT_SUFFICIENT;
- H264_DEC_DEBUG_PRINT("\n");
- return (IV_FAIL);
- }
-
- if((ps_ip->s_ivd_init_ip_t.e_output_format != IV_YUV_420P)
- && (ps_ip->s_ivd_init_ip_t.e_output_format
+ if((ps_ip->s_ivd_create_ip_t.e_output_format != IV_YUV_420P)
+ && (ps_ip->s_ivd_create_ip_t.e_output_format
!= IV_YUV_422ILE)
- && (ps_ip->s_ivd_init_ip_t.e_output_format
+ && (ps_ip->s_ivd_create_ip_t.e_output_format
!= IV_RGB_565)
- && (ps_ip->s_ivd_init_ip_t.e_output_format
+ && (ps_ip->s_ivd_create_ip_t.e_output_format
!= IV_YUV_420SP_UV)
- && (ps_ip->s_ivd_init_ip_t.e_output_format
+ && (ps_ip->s_ivd_create_ip_t.e_output_format
!= IV_YUV_420SP_VU))
{
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
+ ps_op->s_ivd_create_op_t.u4_error_code |= 1
<< IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
+ ps_op->s_ivd_create_op_t.u4_error_code |=
IVD_INIT_DEC_COL_FMT_NOT_SUPPORTED;
H264_DEC_DEBUG_PRINT("\n");
return (IV_FAIL);
}
- /* verify number of mem records */
- if(ps_ip->s_ivd_init_ip_t.u4_num_mem_rec < MEM_REC_CNT)
- {
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
- IVD_INIT_DEC_MEM_REC_NOT_SUFFICIENT;
- H264_DEC_DEBUG_PRINT("\n");
- return IV_FAIL;
- }
-
- ps_mem_rec = ps_ip->s_ivd_init_ip_t.pv_mem_rec_location;
- /* check memrecords sizes are correct */
- for(i = 0; i < ps_ip->s_ivd_init_ip_t.u4_num_mem_rec; i++)
- {
- if(ps_mem_rec[i].u4_size != sizeof(iv_mem_rec_t))
- {
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
- IVD_MEM_REC_STRUCT_SIZE_INCORRECT;
- H264_DEC_DEBUG_PRINT("i: %d\n", i);
- return IV_FAIL;
- }
- /* check memrecords pointers are not NULL */
-
- if(ps_mem_rec[i].pv_base == NULL)
- {
-
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
- IVD_INIT_DEC_MEM_REC_BASE_NULL;
- H264_DEC_DEBUG_PRINT("i: %d\n", i);
- return IV_FAIL;
-
- }
-
- }
-
- /* verify memtabs for overlapping regions */
- {
- void *start[MEM_REC_CNT];
- void *end[MEM_REC_CNT];
-
- start[0] = (void *)(ps_mem_rec[0].pv_base);
- end[0] = (void *)((UWORD8 *)ps_mem_rec[0].pv_base
- + ps_mem_rec[0].u4_mem_size - 1);
- for(i = 1; i < MEM_REC_CNT; i++)
- {
- /* This array is populated to check memtab overlapp */
- start[i] = (void *)(ps_mem_rec[i].pv_base);
- end[i] = (void *)((UWORD8 *)ps_mem_rec[i].pv_base
- + ps_mem_rec[i].u4_mem_size - 1);
-
- for(j = 0; j < i; j++)
- {
- if((start[i] >= start[j]) && (start[i] <= end[j]))
- {
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
- IVD_INIT_DEC_MEM_REC_OVERLAP_ERR;
- H264_DEC_DEBUG_PRINT("i: %d, j: %d\n", i, j);
- return IV_FAIL;
- }
-
- if((end[i] >= start[j]) && (end[i] <= end[j]))
- {
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
- IVD_INIT_DEC_MEM_REC_OVERLAP_ERR;
- H264_DEC_DEBUG_PRINT("i: %d, j: %d\n", i, j);
- return IV_FAIL;
- }
-
- if((start[i] < start[j]) && (end[i] > end[j]))
- {
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
- IVD_INIT_DEC_MEM_REC_OVERLAP_ERR;
- H264_DEC_DEBUG_PRINT("i: %d, j: %d\n", i, j);
- return IV_FAIL;
- }
- }
-
- }
- }
-
- {
- iv_mem_rec_t mem_rec_ittiam_api[MEM_REC_CNT];
- ih264d_fill_mem_rec_ip_t s_fill_mem_rec_ip;
- ih264d_fill_mem_rec_op_t s_fill_mem_rec_op;
- IV_API_CALL_STATUS_T e_status;
-
- UWORD32 i;
- 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 =
- mem_rec_ittiam_api;
- s_fill_mem_rec_ip.s_ivd_fill_mem_rec_ip_t.u4_max_frm_wd =
- max_wd;
- s_fill_mem_rec_ip.s_ivd_fill_mem_rec_ip_t.u4_max_frm_ht =
- max_ht;
-
- if(ps_ip->s_ivd_init_ip_t.u4_size
- > offsetof(ih264d_init_ip_t, i4_level))
- {
- s_fill_mem_rec_ip.i4_level = ps_ip->i4_level;
- }
- else
- {
- s_fill_mem_rec_ip.i4_level = H264_LEVEL_3_1;
- }
-
- if(ps_ip->s_ivd_init_ip_t.u4_size
- > offsetof(ih264d_init_ip_t, u4_num_ref_frames))
- {
- s_fill_mem_rec_ip.u4_num_ref_frames =
- ps_ip->u4_num_ref_frames;
- }
- else
- {
- s_fill_mem_rec_ip.u4_num_ref_frames =
- (H264_MAX_REF_PICS + 1);
- }
-
- if(ps_ip->s_ivd_init_ip_t.u4_size
- > offsetof(ih264d_init_ip_t,
- u4_num_reorder_frames))
- {
- s_fill_mem_rec_ip.u4_num_reorder_frames =
- ps_ip->u4_num_reorder_frames;
- }
- else
- {
- s_fill_mem_rec_ip.u4_num_reorder_frames = (H264_MAX_REF_PICS
- + 1);
- }
-
- if(ps_ip->s_ivd_init_ip_t.u4_size
- > offsetof(ih264d_init_ip_t,
- u4_num_extra_disp_buf))
- {
- s_fill_mem_rec_ip.u4_num_extra_disp_buf =
- ps_ip->u4_num_extra_disp_buf;
- }
- else
- {
- s_fill_mem_rec_ip.u4_num_extra_disp_buf = 0;
- }
-
- if(ps_ip->s_ivd_init_ip_t.u4_size
- > offsetof(ih264d_init_ip_t, u4_share_disp_buf))
- {
-#ifndef LOGO_EN
- s_fill_mem_rec_ip.u4_share_disp_buf =
- ps_ip->u4_share_disp_buf;
-#else
- s_fill_mem_rec_ip.u4_share_disp_buf = 0;
-#endif
- }
- else
- {
- s_fill_mem_rec_ip.u4_share_disp_buf = 0;
- }
-
- s_fill_mem_rec_ip.e_output_format =
- ps_ip->s_ivd_init_ip_t.e_output_format;
-
- if((s_fill_mem_rec_ip.e_output_format != IV_YUV_420P)
- && (s_fill_mem_rec_ip.e_output_format
- != IV_YUV_420SP_UV)
- && (s_fill_mem_rec_ip.e_output_format
- != IV_YUV_420SP_VU))
- {
- s_fill_mem_rec_ip.u4_share_disp_buf = 0;
- }
-
- 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);
-
- for(i = 0; i < MEM_REC_CNT; i++)
- mem_rec_ittiam_api[i].u4_size = sizeof(iv_mem_rec_t);
-
- e_status = ih264d_api_function(NULL,
- (void *)&s_fill_mem_rec_ip,
- (void *)&s_fill_mem_rec_op);
- if(IV_FAIL == e_status)
- {
- ps_op->s_ivd_init_op_t.u4_error_code =
- s_fill_mem_rec_op.s_ivd_fill_mem_rec_op_t.u4_error_code;
- H264_DEC_DEBUG_PRINT("Fail\n");
- return (IV_FAIL);
- }
-
- for(i = 0; i < MEM_REC_CNT; i++)
- {
- if(ps_mem_rec[i].u4_mem_size
- < mem_rec_ittiam_api[i].u4_mem_size)
- {
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
- IVD_INIT_DEC_MEM_REC_INSUFFICIENT_SIZE;
- H264_DEC_DEBUG_PRINT("i: %d \n", i);
- return IV_FAIL;
- }
- if(ps_mem_rec[i].u4_mem_alignment
- != mem_rec_ittiam_api[i].u4_mem_alignment)
- {
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
- IVD_INIT_DEC_MEM_REC_ALIGNMENT_ERR;
- H264_DEC_DEBUG_PRINT("i: %d \n", i);
- return IV_FAIL;
- }
- if(ps_mem_rec[i].e_mem_type
- != mem_rec_ittiam_api[i].e_mem_type)
- {
- UWORD32 check = IV_SUCCESS;
- UWORD32 diff = mem_rec_ittiam_api[i].e_mem_type
- - ps_mem_rec[i].e_mem_type;
-
- if((ps_mem_rec[i].e_mem_type
- <= IV_EXTERNAL_CACHEABLE_SCRATCH_MEM)
- && (mem_rec_ittiam_api[i].e_mem_type
- >= IV_INTERNAL_NONCACHEABLE_PERSISTENT_MEM))
- {
- check = IV_FAIL;
- }
- if(3 != MOD(mem_rec_ittiam_api[i].e_mem_type, 4))
- {
- /*
- * It is not IV_EXTERNAL_NONCACHEABLE_PERSISTENT_MEM or IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM
- */
- if((diff < 1) || (diff > 3))
- {
- // Difference between 1 and 3 is okay for all cases other than the two filtered
- // with the MOD condition above
- check = IV_FAIL;
- }
- }
- else
- {
- if(diff == 1)
- {
- /*
- * This particular case is when codec asked for External Persistent, but got
- * Internal Scratch.
- */
- check = IV_FAIL;
- }
- if((diff != 2) && (diff != 3))
- {
- check = IV_FAIL;
- }
- }
- if(check == IV_FAIL)
- {
- ps_op->s_ivd_init_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_init_op_t.u4_error_code |=
- IVD_INIT_DEC_MEM_REC_INCORRECT_TYPE;
- H264_DEC_DEBUG_PRINT("i: %d \n", i);
- return IV_FAIL;
- }
- }
- }
- }
-
}
break;
@@ -955,49 +457,35 @@
}
break;
- case IV_CMD_RETRIEVE_MEMREC:
+ case IVD_CMD_DELETE:
{
- ih264d_retrieve_mem_rec_ip_t *ps_ip =
- (ih264d_retrieve_mem_rec_ip_t *)pv_api_ip;
- ih264d_retrieve_mem_rec_op_t *ps_op =
- (ih264d_retrieve_mem_rec_op_t *)pv_api_op;
- iv_mem_rec_t *ps_mem_rec;
+ ih264d_delete_ip_t *ps_ip =
+ (ih264d_delete_ip_t *)pv_api_ip;
+ ih264d_delete_op_t *ps_op =
+ (ih264d_delete_op_t *)pv_api_op;
- ps_op->s_ivd_retrieve_mem_rec_op_t.u4_error_code = 0;
+ ps_op->s_ivd_delete_op_t.u4_error_code = 0;
- if(ps_ip->s_ivd_retrieve_mem_rec_ip_t.u4_size
- != sizeof(ih264d_retrieve_mem_rec_ip_t))
+ if(ps_ip->s_ivd_delete_ip_t.u4_size
+ != sizeof(ih264d_delete_ip_t))
{
- ps_op->s_ivd_retrieve_mem_rec_op_t.u4_error_code |= 1
+ ps_op->s_ivd_delete_op_t.u4_error_code |= 1
<< IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_retrieve_mem_rec_op_t.u4_error_code |=
+ ps_op->s_ivd_delete_op_t.u4_error_code |=
IVD_IP_API_STRUCT_SIZE_INCORRECT;
return (IV_FAIL);
}
- if(ps_op->s_ivd_retrieve_mem_rec_op_t.u4_size
- != sizeof(ih264d_retrieve_mem_rec_op_t))
+ if(ps_op->s_ivd_delete_op_t.u4_size
+ != sizeof(ih264d_delete_op_t))
{
- ps_op->s_ivd_retrieve_mem_rec_op_t.u4_error_code |= 1
+ ps_op->s_ivd_delete_op_t.u4_error_code |= 1
<< IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_retrieve_mem_rec_op_t.u4_error_code |=
+ ps_op->s_ivd_delete_op_t.u4_error_code |=
IVD_OP_API_STRUCT_SIZE_INCORRECT;
return (IV_FAIL);
}
- ps_mem_rec = ps_ip->s_ivd_retrieve_mem_rec_ip_t.pv_mem_rec_location;
- /* check memrecords sizes are correct */
- for(i = 0; i < MEM_REC_CNT; i++)
- {
- if(ps_mem_rec[i].u4_size != sizeof(iv_mem_rec_t))
- {
- ps_op->s_ivd_retrieve_mem_rec_op_t.u4_error_code |= 1
- << IVD_UNSUPPORTEDPARAM;
- ps_op->s_ivd_retrieve_mem_rec_op_t.u4_error_code |=
- IVD_MEM_REC_STRUCT_SIZE_INCORRECT;
- return IV_FAIL;
- }
- }
}
break;
@@ -1365,38 +853,6 @@
ps_op->u4_error_code = 0;
return IV_SUCCESS;
}
-/*****************************************************************************/
-/* */
-/* Function Name : ih264d_get_num_rec */
-/* */
-/* Description : returns number of mem records required */
-/* */
-/* Inputs : pv_api_ip input api structure */
-/* : pv_api_op output api structure */
-/* Outputs : */
-/* Outputs : */
-/* Returns : void */
-/* */
-/* Issues : none */
-/* */
-/* Revision History: */
-/* */
-/* DD MM YYYY Author(s) Changes (Describe the changes made) */
-/* 22 10 2008 100356 Draft */
-/* */
-/*****************************************************************************/
-WORD32 ih264d_get_num_rec(void *pv_api_ip, void *pv_api_op)
-{
- iv_num_mem_rec_ip_t *ps_mem_q_ip;
- iv_num_mem_rec_op_t *ps_mem_q_op;
- ps_mem_q_ip = (iv_num_mem_rec_ip_t *)pv_api_ip;
- ps_mem_q_op = (iv_num_mem_rec_op_t *)pv_api_op;
- UNUSED(ps_mem_q_ip);
- ps_mem_q_op->u4_num_mem_rec = MEM_REC_CNT;
-
- return IV_SUCCESS;
-
-}
/**************************************************************************
@@ -1427,11 +883,8 @@
dec_slice_params_t *ps_cur_slice;
pocstruct_t *ps_prev_poc, *ps_cur_poc;
-
-
- /* Set pic_parameter_set_id to -1 */
-
-
+ /* Free any dynamic buffers that are allocated */
+ ih264d_free_dynamic_bufs(ps_dec);
ps_cur_slice = ps_dec->ps_cur_slice;
ps_dec->init_done = 0;
@@ -1579,12 +1032,6 @@
/* Initialize Reference Pic Buffers */
ih264d_init_ref_bufs(ps_dec->ps_dpb_mgr);
-#if VERT_SCALE_UP_AND_422
- ps_dec->u1_vert_up_scale_flag = 1;
-#else
- ps_dec->u1_vert_up_scale_flag = 0;
-#endif
-
ps_dec->u2_prv_frame_num = 0;
ps_dec->u1_top_bottom_decoded = 0;
ps_dec->u1_dangling_field = 0;
@@ -1615,750 +1062,341 @@
ih264d_init_arch(ps_dec);
ih264d_init_function_ptr(ps_dec);
-
+ ps_dec->e_frm_out_mode = IVD_DISPLAY_FRAME_OUT;
ps_dec->init_done = 1;
- ps_dec->process_called = 1;
- ps_dec->pv_pic_buf_mgr = NULL;
- ps_dec->pv_mv_buf_mgr = NULL;
}
-
-/**************************************************************************
- * \if Function name : ih264d_init_video_decoder \endif
- *
- * \brief
- * Wrapper for the decoder init
- *
- * \param p_NALBufAPI: Pointer to NAL Buffer API.
- * \param ih264d_dec_mem_manager :Pointer to the function that will be called by decoder
- * for memory allocation and freeing.
- *
- * \return
- * pointer to the decparams
- *
- **************************************************************************
- */
-
-WORD32 ih264d_init_video_decoder(iv_obj_t *dec_hdl,
- ih264d_init_ip_t *ps_init_ip,
- ih264d_init_op_t *ps_init_op)
+WORD32 ih264d_free_static_bufs(iv_obj_t *dec_hdl)
{
- dec_struct_t * ps_dec;
- iv_mem_rec_t *memtab;
- UWORD8 *pu1_extra_mem_base,*pu1_mem_base;
+ dec_struct_t *ps_dec;
- memtab = ps_init_ip->s_ivd_init_ip_t.pv_mem_rec_location;
+ void (*pf_aligned_free)(void *pv_mem_ctxt, void *pv_buf);
+ void *pv_mem_ctxt;
- dec_hdl->pv_codec_handle = memtab[MEM_REC_CODEC].pv_base;
- ps_dec = dec_hdl->pv_codec_handle;
+ ps_dec = (dec_struct_t *)dec_hdl->pv_codec_handle;
+ pf_aligned_free = ps_dec->pf_aligned_free;
+ pv_mem_ctxt = ps_dec->pv_mem_ctxt;
+
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_sps);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_pps);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pv_dec_thread_handle);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pv_bs_deblk_thread_handle);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_dpb_mgr);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_pred);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pv_disp_buf_mgr);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pv_pic_buf_mgr);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_pic_buf_base);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_dec_err_status);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_sei);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_dpb_cmds);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_bitstrm);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_cur_slice);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pv_scratch_sps_pps);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_bits_buf_static);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ppv_map_ref_idx_to_poc_base);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->p_cabac_ctxt_table_t);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_left_mb_ctxt_info);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_ref_buff_base);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pi2_pred1);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_temp_mc_buffer);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_init_dpb_base);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu4_mbaff_wt_mat);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu4_wts_ofsts_mat);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_left_mvpred_addr);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pv_mv_buf_mgr);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_col_mv_base);
+ PS_DEC_ALIGNED_FREE(ps_dec, dec_hdl->pv_codec_handle);
+
+ if(dec_hdl)
+ {
+ pf_aligned_free(pv_mem_ctxt, dec_hdl);
+ }
+ return IV_SUCCESS;
+}
+/*****************************************************************************/
+/* */
+/* Function Name : ih264d_create */
+/* */
+/* Description : creates decoder */
+/* */
+/* Inputs :iv_obj_t decoder handle */
+/* :pv_api_ip pointer to input structure */
+/* :pv_api_op pointer to output structure */
+/* Outputs : */
+/* Returns : void */
+/* */
+/* Issues : none */
+/* */
+/* Revision History: */
+/* */
+/* DD MM YYYY Author(s) Changes (Describe the changes made) */
+/* 22 10 2008 100356 Draft */
+/* */
+/*****************************************************************************/
+WORD32 ih264d_allocate_static_bufs(iv_obj_t **dec_hdl, void *pv_api_ip, void *pv_api_op)
+{
+ ih264d_create_ip_t *ps_create_ip;
+ ih264d_create_op_t *ps_create_op;
+ void *pv_buf;
+ UWORD8 *pu1_buf;
+ dec_struct_t *ps_dec;
+ 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;
+ WORD32 size;
+
+ ps_create_ip = (ih264d_create_ip_t *)pv_api_ip;
+ ps_create_op = (ih264d_create_op_t *)pv_api_op;
+
+ ps_create_op->s_ivd_create_op_t.u4_error_code = 0;
+
+ pf_aligned_alloc = ps_create_ip->s_ivd_create_ip_t.pf_aligned_alloc;
+ pf_aligned_free = ps_create_ip->s_ivd_create_ip_t.pf_aligned_free;
+ pv_mem_ctxt = ps_create_ip->s_ivd_create_ip_t.pv_mem_ctxt;
+
+ /* Initialize return handle to NULL */
+ ps_create_op->s_ivd_create_op_t.pv_handle = NULL;
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, sizeof(iv_obj_t));
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ *dec_hdl = (iv_obj_t *)pv_buf;
+ ps_create_op->s_ivd_create_op_t.pv_handle = *dec_hdl;
+
+ (*dec_hdl)->pv_codec_handle = NULL;
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, sizeof(dec_struct_t));
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ (*dec_hdl)->pv_codec_handle = (dec_struct_t *)pv_buf;
+ ps_dec = (dec_struct_t *)pv_buf;
memset(ps_dec, 0, sizeof(dec_struct_t));
- if(ps_init_ip->s_ivd_init_ip_t.u4_size
- > offsetof(ih264d_init_ip_t, i4_level))
- {
- ps_dec->u4_level_at_init = ps_init_ip->i4_level;
- }
- else
- {
- ps_dec->u4_level_at_init = H264_LEVEL_3_1;
- }
-
- if(ps_init_ip->s_ivd_init_ip_t.u4_size
- > offsetof(ih264d_init_ip_t, u4_num_ref_frames))
- {
- ps_dec->u4_num_ref_frames_at_init = ps_init_ip->u4_num_ref_frames;
- }
- else
- {
- ps_dec->u4_num_ref_frames_at_init = H264_MAX_REF_PICS;
- }
-
- if(ps_init_ip->s_ivd_init_ip_t.u4_size
- > offsetof(ih264d_init_ip_t, u4_num_reorder_frames))
- {
- ps_dec->u4_num_reorder_frames_at_init =
- ps_init_ip->u4_num_reorder_frames;
- }
- else
- {
- ps_dec->u4_num_reorder_frames_at_init = H264_MAX_REF_PICS;
- }
-
- if(ps_init_ip->s_ivd_init_ip_t.u4_size
- > offsetof(ih264d_init_ip_t, u4_num_extra_disp_buf))
- {
- ps_dec->u4_num_extra_disp_bufs_at_init =
- ps_init_ip->u4_num_extra_disp_buf;
- }
- else
- {
- ps_dec->u4_num_extra_disp_bufs_at_init = 0;
- }
-
- if(ps_init_ip->s_ivd_init_ip_t.u4_size
- > offsetof(ih264d_init_ip_t, u4_share_disp_buf))
- {
#ifndef LOGO_EN
- ps_dec->u4_share_disp_buf = ps_init_ip->u4_share_disp_buf;
+ ps_dec->u4_share_disp_buf = ps_create_ip->s_ivd_create_ip_t.u4_share_disp_buf;
#else
- ps_dec->u4_share_disp_buf = 0;
+ ps_dec->u4_share_disp_buf = 0;
#endif
- }
- else
- {
- ps_dec->u4_share_disp_buf = 0;
- }
- if((ps_init_ip->s_ivd_init_ip_t.e_output_format != IV_YUV_420P)
- && (ps_init_ip->s_ivd_init_ip_t.e_output_format
+ ps_dec->u1_chroma_format =
+ (UWORD8)(ps_create_ip->s_ivd_create_ip_t.e_output_format);
+
+ if((ps_dec->u1_chroma_format != IV_YUV_420P)
+ && (ps_dec->u1_chroma_format
!= IV_YUV_420SP_UV)
- && (ps_init_ip->s_ivd_init_ip_t.e_output_format
+ && (ps_dec->u1_chroma_format
!= IV_YUV_420SP_VU))
{
ps_dec->u4_share_disp_buf = 0;
}
- if((ps_dec->u4_level_at_init < MIN_LEVEL_SUPPORTED)
- || (ps_dec->u4_level_at_init > MAX_LEVEL_SUPPORTED))
- {
- ps_init_op->s_ivd_init_op_t.u4_error_code |= ERROR_LEVEL_UNSUPPORTED;
- return (IV_FAIL);
- }
+ ps_dec->pf_aligned_alloc = pf_aligned_alloc;
+ ps_dec->pf_aligned_free = pf_aligned_free;
+ ps_dec->pv_mem_ctxt = pv_mem_ctxt;
- if(ps_dec->u4_num_ref_frames_at_init > H264_MAX_REF_PICS)
- {
- ps_init_op->s_ivd_init_op_t.u4_error_code |= ERROR_NUM_REF;
- ps_dec->u4_num_ref_frames_at_init = H264_MAX_REF_PICS;
- }
- if(ps_dec->u4_num_reorder_frames_at_init > H264_MAX_REF_PICS)
- {
- ps_init_op->s_ivd_init_op_t.u4_error_code |= ERROR_NUM_REF;
- ps_dec->u4_num_reorder_frames_at_init = H264_MAX_REF_PICS;
- }
+ size = ((sizeof(dec_seq_params_t)) * MAX_NUM_SEQ_PARAMS);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_sps = pv_buf;
- if(ps_dec->u4_num_extra_disp_bufs_at_init > H264_MAX_REF_PICS)
- {
- ps_init_op->s_ivd_init_op_t.u4_error_code |= ERROR_NUM_REF;
- ps_dec->u4_num_extra_disp_bufs_at_init = 0;
- }
+ size = (sizeof(dec_pic_params_t)) * MAX_NUM_PIC_PARAMS;
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_pps = pv_buf;
- if(0 == ps_dec->u4_share_disp_buf)
- ps_dec->u4_num_extra_disp_bufs_at_init = 0;
+ size = ithread_get_handle_size();
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pv_dec_thread_handle = pv_buf;
- ps_dec->u4_num_disp_bufs_requested = 1;
+ size = ithread_get_handle_size();
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pv_bs_deblk_thread_handle = pv_buf;
- ps_dec->u4_width_at_init = ps_init_ip->s_ivd_init_ip_t.u4_frm_max_wd;
- ps_dec->u4_height_at_init = ps_init_ip->s_ivd_init_ip_t.u4_frm_max_ht;
+ size = sizeof(dpb_manager_t);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_dpb_mgr = pv_buf;
- ps_dec->u4_width_at_init = ALIGN16(ps_dec->u4_width_at_init);
- ps_dec->u4_height_at_init = ALIGN32(ps_dec->u4_height_at_init);
+ size = sizeof(pred_info_t) * 2 * 32;
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_pred = pv_buf;
- ps_dec->pv_dec_thread_handle = memtab[MEM_REC_THREAD_HANDLE].pv_base;
+ size = sizeof(disp_mgr_t);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pv_disp_buf_mgr = pv_buf;
- pu1_mem_base = memtab[MEM_REC_THREAD_HANDLE].pv_base;
- ps_dec->pv_bs_deblk_thread_handle = pu1_mem_base
- + ithread_get_handle_size();
+ size = sizeof(buf_mgr_t) + ithread_get_mutex_lock_size();
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pv_pic_buf_mgr = pv_buf;
- ps_dec->u4_extra_mem_used = 0;
+ size = sizeof(struct pic_buffer_t) * (H264_MAX_REF_PICS * 2);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_pic_buf_base = pv_buf;
- pu1_extra_mem_base = memtab[MEM_REC_EXTRA_MEM].pv_base;
+ size = sizeof(dec_err_status_t);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_dec_err_status = (dec_err_status_t *)pv_buf;
- ps_dec->ps_dec_err_status = (dec_err_status_t *)(pu1_extra_mem_base + ps_dec->u4_extra_mem_used);
- ps_dec->u4_extra_mem_used += (((sizeof(dec_err_status_t) + 127) >> 7) << 7);
+ size = sizeof(sei);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_sei = (sei *)pv_buf;
- ps_dec->ps_mem_tab = memtab[MEM_REC_BACKUP].pv_base;
+ size = sizeof(dpb_commands_t);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_dpb_cmds = (dpb_commands_t *)pv_buf;
- memcpy(ps_dec->ps_mem_tab, memtab, sizeof(iv_mem_rec_t) * MEM_REC_CNT);
+ size = sizeof(dec_bit_stream_t);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_bitstrm = (dec_bit_stream_t *)pv_buf;
- ps_dec->ps_pps = memtab[MEM_REC_PPS].pv_base;
+ size = sizeof(dec_slice_params_t);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_cur_slice = (dec_slice_params_t *)pv_buf;
- ps_dec->ps_sps = memtab[MEM_REC_SPS].pv_base;
+ size = MAX(sizeof(dec_seq_params_t), sizeof(dec_pic_params_t));
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pv_scratch_sps_pps = pv_buf;
- ps_dec->ps_sei = (sei *)(pu1_extra_mem_base + ps_dec->u4_extra_mem_used);
- ps_dec->u4_extra_mem_used += sizeof(sei);
- ps_dec->ps_dpb_mgr = memtab[MEM_REC_DPB_MGR].pv_base;
+ ps_dec->u4_static_bits_buf_size = 256000;
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, ps_dec->u4_static_bits_buf_size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pu1_bits_buf_static = pv_buf;
- ps_dec->ps_dpb_cmds = (dpb_commands_t *)(pu1_extra_mem_base + ps_dec->u4_extra_mem_used);
- ps_dec->u4_extra_mem_used += sizeof(dpb_commands_t);
- ps_dec->ps_bitstrm = (dec_bit_stream_t *)(pu1_extra_mem_base + ps_dec->u4_extra_mem_used);
- ps_dec->u4_extra_mem_used += sizeof(dec_bit_stream_t);
+ size = ((TOTAL_LIST_ENTRIES + PAD_MAP_IDX_POC)
+ * sizeof(void *));
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ppv_map_ref_idx_to_poc_base = pv_buf;
+ memset(ps_dec->ppv_map_ref_idx_to_poc_base, 0, size);
- ps_dec->ps_cur_slice =(dec_slice_params_t *) (pu1_extra_mem_base + ps_dec->u4_extra_mem_used);
- ps_dec->u4_extra_mem_used += sizeof(dec_slice_params_t);
+ ps_dec->ppv_map_ref_idx_to_poc = ps_dec->ppv_map_ref_idx_to_poc_base + OFFSET_MAP_IDX_POC;
- ps_dec->pv_scratch_sps_pps = (void *)(pu1_extra_mem_base + ps_dec->u4_extra_mem_used);
+ size = (sizeof(bin_ctxt_model_t) * NUM_CABAC_CTXTS);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->p_cabac_ctxt_table_t = pv_buf;
- ps_dec->u4_extra_mem_used += MAX(sizeof(dec_seq_params_t),
- sizeof(dec_pic_params_t));
- ps_dec->ps_pred_pkd = memtab[MEM_REC_PRED_INFO_PKD].pv_base;
- ps_dec->ps_dpb_mgr->pv_codec_handle = ps_dec;
+ size = sizeof(ctxt_inc_mb_info_t);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_left_mb_ctxt_info = pv_buf;
- ps_dec->pv_dec_out = (void *)ps_init_op;
- ps_dec->pv_dec_in = (void *)ps_init_ip;
- ps_dec->u1_chroma_format =
- (UWORD8)(ps_init_ip->s_ivd_init_ip_t.e_output_format);
+ size = MAX_REF_BUF_SIZE * 2;
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pu1_ref_buff_base = pv_buf;
+ ps_dec->pu1_ref_buff = ps_dec->pu1_ref_buff_base + MAX_REF_BUF_SIZE;
- ih264d_init_decoder(ps_dec);
-
- return (IV_SUCCESS);
-
-}
-
-
-/*****************************************************************************/
-/* */
-/* Function Name : ih264d_fill_num_mem_rec */
-/* */
-/* Description : fills memory records */
-/* */
-/* Inputs : pv_api_ip input api structure */
-/* : pv_api_op output api structure */
-/* Outputs : */
-/* Returns : void */
-/* */
-/* Issues : none */
-/* */
-/* Revision History: */
-/* */
-/* DD MM YYYY Author(s) Changes (Describe the changes made) */
-/* 22 10 2008 100356 Draft */
-/* */
-/*****************************************************************************/
-WORD32 ih264d_fill_num_mem_rec(void *pv_api_ip, void *pv_api_op)
-{
-
- ih264d_fill_mem_rec_ip_t *ps_mem_q_ip;
- ih264d_fill_mem_rec_op_t *ps_mem_q_op;
- WORD32 level;
- UWORD32 num_reorder_frames;
- UWORD32 num_ref_frames;
- UWORD32 num_extra_disp_bufs;
- UWORD32 u4_dpb_size_num_frames;
- iv_mem_rec_t *memTab;
-
- UWORD32 chroma_format, u4_share_disp_buf;
- UWORD32 u4_total_num_mbs;
- UWORD32 luma_width, luma_width_in_mbs;
- UWORD32 luma_height, luma_height_in_mbs;
- UWORD32 max_dpb_size;
-
- ps_mem_q_ip = (ih264d_fill_mem_rec_ip_t *)pv_api_ip;
- ps_mem_q_op = (ih264d_fill_mem_rec_op_t *)pv_api_op;
-
- if(ps_mem_q_ip->s_ivd_fill_mem_rec_ip_t.u4_size
- > offsetof(ih264d_fill_mem_rec_ip_t, i4_level))
- {
- level = ps_mem_q_ip->i4_level;
- }
- else
- {
- level = H264_LEVEL_3_1;
- }
-
- if(ps_mem_q_ip->s_ivd_fill_mem_rec_ip_t.u4_size
- > offsetof(ih264d_fill_mem_rec_ip_t, u4_num_reorder_frames))
- {
- num_reorder_frames = ps_mem_q_ip->u4_num_reorder_frames;
- }
- else
- {
- num_reorder_frames = H264_MAX_REF_PICS;
- }
-
- if(ps_mem_q_ip->s_ivd_fill_mem_rec_ip_t.u4_size
- > offsetof(ih264d_fill_mem_rec_ip_t, u4_num_ref_frames))
- {
- num_ref_frames = ps_mem_q_ip->u4_num_ref_frames;
- }
- else
- {
- num_ref_frames = H264_MAX_REF_PICS;
- }
-
- if(ps_mem_q_ip->s_ivd_fill_mem_rec_ip_t.u4_size
- > offsetof(ih264d_fill_mem_rec_ip_t, u4_num_extra_disp_buf))
- {
- num_extra_disp_bufs = ps_mem_q_ip->u4_num_extra_disp_buf;
- }
- else
- {
- num_extra_disp_bufs = 0;
- }
-
- if(ps_mem_q_ip->s_ivd_fill_mem_rec_ip_t.u4_size
- > offsetof(ih264d_fill_mem_rec_ip_t, u4_share_disp_buf))
- {
-#ifndef LOGO_EN
- u4_share_disp_buf = ps_mem_q_ip->u4_share_disp_buf;
-#else
- u4_share_disp_buf = 0;
-#endif
- }
- else
- {
- u4_share_disp_buf = 0;
- }
-
- if(ps_mem_q_ip->s_ivd_fill_mem_rec_ip_t.u4_size
- > offsetof(ih264d_fill_mem_rec_ip_t, e_output_format))
- {
- chroma_format = ps_mem_q_ip->e_output_format;
- }
- else
- {
- chroma_format = -1;
- }
-
- if((chroma_format != IV_YUV_420P) && (chroma_format != IV_YUV_420SP_UV)
- && (chroma_format != IV_YUV_420SP_VU))
- {
- u4_share_disp_buf = 0;
- }
- if(0 == u4_share_disp_buf)
- num_extra_disp_bufs = 0;
-
- {
-
- luma_height = ps_mem_q_ip->s_ivd_fill_mem_rec_ip_t.u4_max_frm_ht;
- luma_width = ps_mem_q_ip->s_ivd_fill_mem_rec_ip_t.u4_max_frm_wd;
-
- luma_height = ALIGN32(luma_height);
- luma_width = ALIGN16(luma_width);
- luma_width_in_mbs = luma_width >> 4;
- luma_height_in_mbs = luma_height >> 4;
- u4_total_num_mbs = (luma_height * luma_width) >> 8;
- }
- /*
- * If level is lesser than 31 and the resolution required is higher,
- * then make the level at least 31.
- */
- if(u4_total_num_mbs > MAX_MBS_LEVEL_30 && level < H264_LEVEL_3_1)
- {
- level = H264_LEVEL_3_1;
- }
-
- if((level < MIN_LEVEL_SUPPORTED) || (level > MAX_LEVEL_SUPPORTED))
- {
- ps_mem_q_op->s_ivd_fill_mem_rec_op_t.u4_error_code |=
- ERROR_LEVEL_UNSUPPORTED;
- return (IV_FAIL);
- }
-
- if(num_ref_frames > H264_MAX_REF_PICS)
- {
- ps_mem_q_op->s_ivd_fill_mem_rec_op_t.u4_error_code |= ERROR_NUM_REF;
- num_ref_frames = H264_MAX_REF_PICS;
- }
-
- if(num_reorder_frames > H264_MAX_REF_PICS)
- {
- ps_mem_q_op->s_ivd_fill_mem_rec_op_t.u4_error_code |= ERROR_NUM_REF;
- num_reorder_frames = H264_MAX_REF_PICS;
- }
- memTab = ps_mem_q_ip->s_ivd_fill_mem_rec_ip_t.pv_mem_rec_location;
-
- memTab[MEM_REC_IV_OBJ].u4_mem_size = sizeof(iv_obj_t);
- memTab[MEM_REC_IV_OBJ].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_IV_OBJ].e_mem_type = IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- H264_DEC_DEBUG_PRINT("MEM_REC_IV_OBJ MEM Size = %d\n",
- memTab[MEM_REC_IV_OBJ].u4_mem_size);
-
- memTab[MEM_REC_CODEC].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_CODEC].e_mem_type = IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_CODEC].u4_mem_size = sizeof(dec_struct_t);
-
- {
- UWORD32 mvinfo_size, mv_info_size_pad;
- UWORD32 MVbank, MVbank_pad;
- UWORD32 Ysize;
- UWORD32 UVsize;
- UWORD32 one_frm_size;
-
- UWORD32 extra_mem = 0;
-
- UWORD32 pad_len_h, pad_len_v;
-
- /*
- * For low_delay, use num_buf as 2 -
- * num_buf = (num_buf_ref) + 1;
- * where num_buf_ref is 1.
- */
- UWORD32 num_buf;
-
- {
- UWORD32 num_bufs_app, num_bufs_level;
-
- num_bufs_app = num_ref_frames + num_reorder_frames + 1;
-
- if(num_bufs_app <= 1)
- num_bufs_app = 2;
-
- num_bufs_level = ih264d_get_dpb_size_new(level, (luma_width >> 4),
- (luma_height >> 4));
-
- max_dpb_size = num_bufs_level;
-
- num_bufs_level = num_bufs_level * 2 + 1;
-
- num_buf = MIN(num_bufs_level, num_bufs_app);
-
- num_buf += num_extra_disp_bufs;
-
- }
-
- mvinfo_size = ((luma_width * (luma_height)) >> 4);
-
- mv_info_size_pad = ((luma_width * (PAD_MV_BANK_ROW)) >> 4);
-
- Ysize = ALIGN32((luma_width + (PAD_LEN_Y_H << 1)))
- * (luma_height + (PAD_LEN_Y_V << 2));
-
-
- UVsize = Ysize >> 2;
- if(u4_share_disp_buf == 1)
- {
- /* In case of buffers getting shared between application and library
- there is no need of reference memtabs. Instead of setting the i4_size
- to zero, it is reduced to a small i4_size to ensure that changes
- in the code are minimal */
-
- if((chroma_format == IV_YUV_420P)
- || (chroma_format == IV_YUV_420SP_UV)
- || (chroma_format == IV_YUV_420SP_VU))
- {
- Ysize = 64;
- }
- if(chroma_format == IV_YUV_420SP_UV)
- {
- UVsize = 64;
- }
- }
-
- one_frm_size = (((Ysize + 127) >> 7) << 7)
- + ((((UVsize << 1) + 127) >> 7) << 7);
-
- //Note that for ARM RVDS WS the sizeof(mv_pred_t) is 16
-
- /*Add memory for colocated MB*/
- MVbank = sizeof(mv_pred_t) * mvinfo_size;
- MVbank_pad = sizeof(mv_pred_t) * mv_info_size_pad;
-
- MVbank = (((MVbank + 127) >> 7) << 7);
-
- MVbank_pad = (((MVbank_pad + 127) >> 7) << 7);
-
- memTab[MEM_REC_MVBANK].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_MVBANK].e_mem_type =
- IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_MVBANK].u4_mem_size = (MVbank + MVbank_pad)
- * (MIN(max_dpb_size, num_ref_frames) + 1);
-
-
- memTab[MEM_REC_REF_PIC].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_REF_PIC].e_mem_type =
- IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_REF_PIC].u4_mem_size = one_frm_size * num_buf;
-
- }
-
- memTab[MEM_REC_DEBLK_MB_INFO].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_DEBLK_MB_INFO].e_mem_type =
- IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_DEBLK_MB_INFO].u4_mem_size = (((((u4_total_num_mbs
- + (luma_width >> 4)) * sizeof(deblk_mb_t)) + 127) >> 7) << 7);
-
- memTab[MEM_REC_NEIGHBOR_INFO].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_NEIGHBOR_INFO].e_mem_type =
- IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_NEIGHBOR_INFO].u4_mem_size = sizeof(mb_neigbour_params_t)
- * ((luma_width + 16) >> 4) * 2 * 2;
- {
- WORD32 size;
- WORD32 num_entries;
-
- num_entries = MIN(MAX_FRAMES, num_ref_frames);
- num_entries = 2 * ((2 * num_entries) + 1);
-
- size = num_entries * sizeof(void *);
- size += PAD_MAP_IDX_POC * sizeof(void *);
- size *= u4_total_num_mbs;
- size += sizeof(dec_slice_struct_t) * u4_total_num_mbs;
- memTab[MEM_REC_SLICE_HDR].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_SLICE_HDR].e_mem_type = IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_SLICE_HDR].u4_mem_size = size;
- }
- {
-
- UWORD32 u4_num_entries;
-
- u4_num_entries = u4_total_num_mbs;
-
- memTab[MEM_REC_MB_INFO].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_MB_INFO].e_mem_type =
- IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_MB_INFO].u4_mem_size = sizeof(dec_mb_info_t)
- * u4_num_entries;
-
- memTab[MEM_REC_PRED_INFO].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_PRED_INFO].e_mem_type =
- IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
-
- memTab[MEM_REC_PRED_INFO].u4_mem_size = sizeof(pred_info_t) * 2*32;
-
- memTab[MEM_REC_COEFF_DATA].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_COEFF_DATA].e_mem_type =
- IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_COEFF_DATA].u4_mem_size = MB_LUM_SIZE * sizeof(WORD16);
- /*For I16x16 MBs, 16 4x4 AC coeffs and 1 4x4 DC coeff TU blocks will be sent
- For all MBs along with 8 4x4 AC coeffs 2 2x2 DC coeff TU blocks will be sent
- So use 17 4x4 TU blocks for luma and 9 4x4 TU blocks for chroma */
- memTab[MEM_REC_COEFF_DATA].u4_mem_size += u4_num_entries
- * (MAX(17 * sizeof(tu_sblk4x4_coeff_data_t),4 * sizeof(tu_blk8x8_coeff_data_t))
- + 9 * sizeof(tu_sblk4x4_coeff_data_t));
- //32 bytes for each mb to store u1_prev_intra4x4_pred_mode and u1_rem_intra4x4_pred_mode data
- memTab[MEM_REC_COEFF_DATA].u4_mem_size += u4_num_entries * 32;
-
- }
-
- memTab[MEM_REC_SPS].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_SPS].e_mem_type = IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_SPS].u4_mem_size = ((sizeof(dec_seq_params_t))
- * MAX_NUM_SEQ_PARAMS);
-
- memTab[MEM_REC_PPS].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_PPS].e_mem_type = IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_PPS].u4_mem_size = (sizeof(dec_pic_params_t))
- * MAX_NUM_PIC_PARAMS;
-
- {
- UWORD32 u4_mem_size;
-
- u4_mem_size = 0;
- u4_mem_size += (((sizeof(dec_err_status_t) + 127) >> 7) << 7);
- u4_mem_size += sizeof(sei);
- u4_mem_size += sizeof(dpb_commands_t);
- u4_mem_size += sizeof(dec_bit_stream_t);
- u4_mem_size += sizeof(dec_slice_params_t);
- u4_mem_size += MAX(sizeof(dec_seq_params_t), sizeof(dec_pic_params_t));
-
- memTab[MEM_REC_EXTRA_MEM].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_EXTRA_MEM].e_mem_type =
- IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_EXTRA_MEM].u4_mem_size = u4_mem_size;
- }
-
- {
-
- UWORD32 u4_mem_size;
-
- u4_mem_size = 0;
- u4_mem_size += ((TOTAL_LIST_ENTRIES + PAD_MAP_IDX_POC) * sizeof(void *));
- u4_mem_size = ALIGN64(u4_mem_size);
- u4_mem_size += (sizeof(bin_ctxt_model_t) * NUM_CABAC_CTXTS);
- u4_mem_size = ALIGN64(u4_mem_size);
- u4_mem_size += sizeof(ctxt_inc_mb_info_t);
- u4_mem_size = ALIGN64(u4_mem_size);
- u4_mem_size += sizeof(UWORD32) * (MAX_REF_BUFS * MAX_REF_BUFS);
- u4_mem_size = ALIGN64(u4_mem_size);
-
- u4_mem_size += MAX_REF_BUF_SIZE * 2;
- u4_mem_size = ALIGN64(u4_mem_size);
- u4_mem_size += ((sizeof(WORD16)) * PRED_BUFFER_WIDTH
+ size = ((sizeof(WORD16)) * PRED_BUFFER_WIDTH
* PRED_BUFFER_HEIGHT * 2);
- u4_mem_size = ALIGN64(u4_mem_size);
- u4_mem_size += sizeof(UWORD8) * (MB_LUM_SIZE);
- u4_mem_size = ALIGN64(u4_mem_size);
- u4_mem_size += sizeof(parse_pmbarams_t) * luma_width_in_mbs; //Max recon mb group*/
- u4_mem_size = ALIGN64(u4_mem_size);
- u4_mem_size += (sizeof(parse_part_params_t) * luma_width_in_mbs) << 4; //Max recon mb group*/
- u4_mem_size = ALIGN64(u4_mem_size);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pi2_pred1 = pv_buf;
- u4_mem_size += 2 * MAX_REF_BUFS * sizeof(struct pic_buffer_t);
- u4_mem_size = ALIGN64(u4_mem_size);
- u4_mem_size += 2 * MAX_REF_BUFS * sizeof(struct pic_buffer_t);
- u4_mem_size = ALIGN64(u4_mem_size);
- u4_mem_size += (sizeof(UWORD32) * 3 * (MAX_REF_BUFS * MAX_REF_BUFS)) << 3;
- u4_mem_size = ALIGN64(u4_mem_size);
- u4_mem_size += sizeof(UWORD32) * 2 * 3 * (MAX_REF_BUFS * MAX_REF_BUFS);
- u4_mem_size = ALIGN64(u4_mem_size);
+ size = sizeof(UWORD8) * (MB_LUM_SIZE);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pu1_temp_mc_buffer = pv_buf;
- memTab[MEM_REC_INTERNAL_SCRATCH].u4_mem_alignment =
- (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_INTERNAL_SCRATCH].e_mem_type =
- IV_EXTERNAL_CACHEABLE_SCRATCH_MEM;
- memTab[MEM_REC_INTERNAL_SCRATCH].u4_mem_size = u4_mem_size;
- }
+
+
+
+ size = 8 * MAX_REF_BUFS * sizeof(struct pic_buffer_t);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+
+ ps_dec->pu1_init_dpb_base = pv_buf;
+ pu1_buf = pv_buf;
+ ps_dec->ps_dpb_mgr->ps_init_dpb[0][0] = (struct pic_buffer_t *)pu1_buf;
+
+ pu1_buf += size / 2;
+ ps_dec->ps_dpb_mgr->ps_init_dpb[1][0] = (struct pic_buffer_t *)pu1_buf;
+
+ size = (sizeof(UWORD32) * 3
+ * (MAX_FRAMES * MAX_FRAMES))
+ << 3;
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pu4_mbaff_wt_mat = pv_buf;
+
+ size = sizeof(UWORD32) * 2 * 3
+ * (MAX_FRAMES * MAX_FRAMES);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pu4_wts_ofsts_mat = pv_buf;
+
+
+ size = (sizeof(neighbouradd_t) << 2);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_left_mvpred_addr = pv_buf;
+
+
+ size = sizeof(buf_mgr_t) + ithread_get_mutex_lock_size();
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pv_mv_buf_mgr = pv_buf;
+
+
+ size = sizeof(col_mv_buf_t) * (H264_MAX_REF_PICS * 2);
+ pv_buf = pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_col_mv_base = pv_buf;
+ memset(ps_dec->ps_col_mv_base, 0, size);
{
+ UWORD8 i;
+ struct pic_buffer_t *ps_init_dpb;
+ ps_init_dpb = ps_dec->ps_dpb_mgr->ps_init_dpb[0][0];
+ for(i = 0; i < 2 * MAX_REF_BUFS; i++)
+ {
+ ps_init_dpb->pu1_buf1 = NULL;
+ ps_init_dpb->u1_long_term_frm_idx = MAX_REF_BUFS + 1;
+ ps_dec->ps_dpb_mgr->ps_init_dpb[0][i] = ps_init_dpb;
+ ps_dec->ps_dpb_mgr->ps_mod_dpb[0][i] = ps_init_dpb;
+ ps_init_dpb++;
+ }
- UWORD32 u4_mem_used;
- UWORD32 u4_numRows = MB_SIZE << 1;
- UWORD32 u4_blk_wd = ((luma_width_in_mbs << 4) >> 1) + 8;
-
- u4_mem_used = 0;
- u4_mem_used += ((luma_width_in_mbs * sizeof(deblkmb_neighbour_t)) << 1);
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += (sizeof(neighbouradd_t) << 2);
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += ((sizeof(ctxt_inc_mb_info_t))
- * (((luma_width_in_mbs + 1) << 1) + 1));
- u4_mem_used = ALIGN64(u4_mem_used);
-
- u4_mem_used += (sizeof(mv_pred_t) * luma_width_in_mbs * 16);
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += (sizeof(mv_pred_t) * luma_width_in_mbs * 16);
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += (sizeof(mv_pred_t) * luma_width_in_mbs * 4
- * MV_SCRATCH_BUFS);
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += sizeof(UWORD8) * u4_numRows * u4_blk_wd;
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += sizeof(UWORD8) * u4_numRows * u4_blk_wd;
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_numRows = BLK8x8SIZE << 1;
-
- u4_blk_wd = ((luma_width_in_mbs << 3) >> 1) + 8;
-
- u4_mem_used += sizeof(UWORD8) * u4_numRows * u4_blk_wd;
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += sizeof(UWORD8) * u4_numRows * u4_blk_wd;
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += sizeof(UWORD8) * u4_numRows * u4_blk_wd;
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += sizeof(UWORD8) * u4_numRows * u4_blk_wd;
- u4_mem_used += 32;
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += sizeof(UWORD8) * (luma_width + 16) * 2;
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += sizeof(UWORD8) * (luma_width + 16) * 2;
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += sizeof(UWORD8) * (luma_width + 16) * 2;
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += sizeof(mb_neigbour_params_t) * (luma_width_in_mbs + 1)
- * luma_height_in_mbs;
- u4_mem_used += luma_width;
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += luma_width;
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += luma_width;
- u4_mem_used = ALIGN64(u4_mem_used);
-
- u4_mem_used += ((MB_SIZE + 4) << 1) * PAD_LEN_Y_H;
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += ((BLK8x8SIZE + 2) << 1) * PAD_LEN_UV_H;
- u4_mem_used = ALIGN64(u4_mem_used);
- u4_mem_used += ((BLK8x8SIZE + 2) << 1) * PAD_LEN_UV_H;
- u4_mem_used = ALIGN64(u4_mem_used);
- memTab[MEM_REC_INTERNAL_PERSIST].u4_mem_alignment =
- (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_INTERNAL_PERSIST].e_mem_type =
- IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_INTERNAL_PERSIST].u4_mem_size = u4_mem_used;
+ ps_init_dpb = ps_dec->ps_dpb_mgr->ps_init_dpb[1][0];
+ for(i = 0; i < 2 * MAX_REF_BUFS; i++)
+ {
+ ps_init_dpb->pu1_buf1 = NULL;
+ ps_init_dpb->u1_long_term_frm_idx = MAX_REF_BUFS + 1;
+ ps_dec->ps_dpb_mgr->ps_init_dpb[1][i] = ps_init_dpb;
+ ps_dec->ps_dpb_mgr->ps_mod_dpb[1][i] = ps_init_dpb;
+ ps_init_dpb++;
+ }
}
-
- memTab[MEM_REC_BITSBUF].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_BITSBUF].e_mem_type = IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_BITSBUF].u4_mem_size = MAX(256000, (luma_width * luma_height * 3 / 2));
-
- {
-
- UWORD32 u4_thread_struct_size = ithread_get_handle_size();
-
- memTab[MEM_REC_THREAD_HANDLE].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_THREAD_HANDLE].e_mem_type =
- IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_THREAD_HANDLE].u4_mem_size = u4_thread_struct_size * 2;
-
- }
-
- memTab[MEM_REC_PARSE_MAP].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_PARSE_MAP].e_mem_type = IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_PARSE_MAP].u4_mem_size = u4_total_num_mbs;
-
- memTab[MEM_REC_PROC_MAP].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_PROC_MAP].e_mem_type = IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_PROC_MAP].u4_mem_size = u4_total_num_mbs;
-
- memTab[MEM_REC_SLICE_NUM_MAP].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_SLICE_NUM_MAP].e_mem_type =
- IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_SLICE_NUM_MAP].u4_mem_size = u4_total_num_mbs
- * sizeof(UWORD16);
-
- memTab[MEM_REC_DPB_MGR].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_DPB_MGR].e_mem_type = IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_DPB_MGR].u4_mem_size = sizeof(dpb_manager_t);
-
- memTab[MEM_REC_BACKUP].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_BACKUP].e_mem_type = IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_BACKUP].u4_mem_size = sizeof(iv_mem_rec_t) * MEM_REC_CNT;
-
- {
-
- UWORD32 u4_mem_size;
-
- u4_mem_size = sizeof(disp_mgr_t);
- u4_mem_size += sizeof(buf_mgr_t) + ithread_get_mutex_lock_size();
- u4_mem_size += sizeof(struct pic_buffer_t) * (H264_MAX_REF_PICS * 2);
-
- memTab[MEM_REC_PIC_BUF_MGR].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_PIC_BUF_MGR].e_mem_type =
- IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_PIC_BUF_MGR].u4_mem_size = u4_mem_size;
- }
-
- {
- UWORD32 u4_mem_size;
-
- u4_mem_size = sizeof(buf_mgr_t) + ithread_get_mutex_lock_size();
- u4_mem_size += sizeof(col_mv_buf_t) * (H264_MAX_REF_PICS * 2);
- u4_mem_size = ALIGN128(u4_mem_size);
- u4_mem_size += ((luma_width * luma_height) >> 4)
- * (MIN(max_dpb_size, num_ref_frames) + 1);
- memTab[MEM_REC_MV_BUF_MGR].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_MV_BUF_MGR].e_mem_type =
- IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
- memTab[MEM_REC_MV_BUF_MGR].u4_mem_size = u4_mem_size;
- }
-
- memTab[MEM_REC_PRED_INFO_PKD].u4_mem_alignment = (128 * 8) / CHAR_BIT;
- memTab[MEM_REC_PRED_INFO_PKD].e_mem_type =
- IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM;
-
- {
- UWORD32 u4_num_entries;
- u4_num_entries = u4_total_num_mbs;
-
- if(1 == num_ref_frames)
- u4_num_entries *= 16;
- else
- u4_num_entries *= 16 * 2;
-
- memTab[MEM_REC_PRED_INFO_PKD].u4_mem_size = sizeof(pred_info_pkd_t)
- * u4_num_entries;
- }
-
- ps_mem_q_op->s_ivd_fill_mem_rec_op_t.u4_num_mem_rec_filled = MEM_REC_CNT;
-
+ ih264d_init_decoder(ps_dec);
return IV_SUCCESS;
}
+
+
/*****************************************************************************/
/* */
-/* Function Name : ih264d_clr */
+/* Function Name : ih264d_create */
/* */
-/* Description : returns memory records to app */
+/* Description : creates decoder */
/* */
/* Inputs :iv_obj_t decoder handle */
/* :pv_api_ip pointer to input structure */
@@ -2374,78 +1412,33 @@
/* 22 10 2008 100356 Draft */
/* */
/*****************************************************************************/
-WORD32 ih264d_clr(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op)
+WORD32 ih264d_create(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op)
{
+ ih264d_create_op_t *ps_create_op;
- dec_struct_t * ps_dec;
- iv_retrieve_mem_rec_ip_t *dec_clr_ip;
- iv_retrieve_mem_rec_op_t *dec_clr_op;
+ WORD32 ret;
- dec_clr_ip = (iv_retrieve_mem_rec_ip_t *)pv_api_ip;
- dec_clr_op = (iv_retrieve_mem_rec_op_t *)pv_api_op;
- ps_dec = (dec_struct_t *)(dec_hdl->pv_codec_handle);
+ ps_create_op = (ih264d_create_op_t *)pv_api_op;
- if(ps_dec->init_done != 1)
+ ps_create_op->s_ivd_create_op_t.u4_error_code = 0;
+
+ ret = ih264d_allocate_static_bufs(&dec_hdl, pv_api_ip, pv_api_op);
+
+ /* If allocation of some buffer fails, then free buffers allocated till then */
+ if((IV_FAIL == ret) && (NULL != dec_hdl))
{
- //return a proper Error Code
+ ih264d_free_static_bufs(dec_hdl);
+ ps_create_op->s_ivd_create_op_t.u4_error_code = IVD_MEM_ALLOC_FAILED;
+ ps_create_op->s_ivd_create_op_t.u4_error_code = 1 << IVD_FATALERROR;
+
return IV_FAIL;
}
- if(ps_dec->pv_pic_buf_mgr)
- ih264_buf_mgr_free((buf_mgr_t *)ps_dec->pv_pic_buf_mgr);
- if(ps_dec->pv_mv_buf_mgr)
- ih264_buf_mgr_free((buf_mgr_t *)ps_dec->pv_mv_buf_mgr);
-
- memcpy(dec_clr_ip->pv_mem_rec_location, ps_dec->ps_mem_tab,
- MEM_REC_CNT * (sizeof(iv_mem_rec_t)));
- dec_clr_op->u4_num_mem_rec_filled = MEM_REC_CNT;
-
- H264_DEC_DEBUG_PRINT("The clear non-conceal num mem recs: %d\n",
- dec_clr_op->u4_num_mem_rec_filled);
-
return IV_SUCCESS;
-
}
/*****************************************************************************/
/* */
-/* Function Name : ih264d_init */
-/* */
-/* Description : initializes decoder */
-/* */
-/* Inputs :iv_obj_t decoder handle */
-/* :pv_api_ip pointer to input structure */
-/* :pv_api_op pointer to output structure */
-/* Outputs : */
-/* Returns : void */
-/* */
-/* Issues : none */
-/* */
-/* Revision History: */
-/* */
-/* DD MM YYYY Author(s) Changes (Describe the changes made) */
-/* 22 10 2008 100356 Draft */
-/* */
-/*****************************************************************************/
-WORD32 ih264d_init(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op)
-{
- ih264d_init_ip_t *ps_init_ip;
- ih264d_init_op_t *ps_init_op;
- WORD32 init_status = IV_SUCCESS;
- ps_init_ip = (ih264d_init_ip_t *)pv_api_ip;
- ps_init_op = (ih264d_init_op_t *)pv_api_op;
-
- init_status = ih264d_init_video_decoder(dec_hdl, ps_init_ip, ps_init_op);
-
- if(IV_SUCCESS != init_status)
- {
- return init_status;
- }
-
- return init_status;
-}
-/*****************************************************************************/
-/* */
/* Function Name : ih264d_map_error */
/* */
/* Description : Maps error codes to IVD error groups */
@@ -2477,6 +1470,7 @@
case ERROR_ACTUAL_RESOLUTION_GREATER_THAN_INIT:
case ERROR_PROFILE_NOT_SUPPORTED:
case ERROR_INIT_NOT_DONE:
+ case IVD_MEM_ALLOC_FAILED:
temp = 1 << IVD_FATALERROR;
H264_DEC_DEBUG_PRINT("\nFatal Error\n");
break;
@@ -2600,7 +1594,6 @@
ps_dec_ip = (ivd_video_decode_ip_t *)pv_api_ip;
ps_dec_op = (ivd_video_decode_op_t *)pv_api_op;
ps_dec->pv_dec_out = ps_dec_op;
- ps_dec->process_called = 1;
if(ps_dec->init_done != 1)
{
return IV_FAIL;
@@ -2640,7 +1633,6 @@
ps_dec->u4_output_present = 0;
ps_dec->s_disp_op.u4_error_code = 1;
ps_dec->u4_fmt_conv_num_rows = FMT_CONV_NUM_ROWS;
- ps_dec->u4_stop_threads = 0;
if(0 == ps_dec->u4_share_disp_buf
&& ps_dec->i4_decode_header == 0)
{
@@ -2859,17 +1851,46 @@
DEBUG_THREADS_PRINTF(" Starting process call\n");
+
ps_dec->u4_pic_buf_got = 0;
do
{
+ WORD32 buf_size;
pu1_buf = (UWORD8*)ps_dec_ip->pv_stream_buffer
+ ps_dec_op->u4_num_bytes_consumed;
u4_max_ofst = ps_dec_ip->u4_num_Bytes
- ps_dec_op->u4_num_bytes_consumed;
- pu1_bitstrm_buf = ps_dec->ps_mem_tab[MEM_REC_BITSBUF].pv_base;
+
+ /* If dynamic bitstream buffer is not allocated and
+ * header decode is done, then allocate dynamic bitstream buffer
+ */
+ if((NULL == ps_dec->pu1_bits_buf_dynamic) &&
+ (ps_dec->i4_header_decoded & 1))
+ {
+ WORD32 size;
+
+ void *pv_buf;
+ void *pv_mem_ctxt = ps_dec->pv_mem_ctxt;
+ size = MAX(256000, ps_dec->u2_pic_wd * ps_dec->u2_pic_ht * 3 / 2);
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pu1_bits_buf_dynamic = pv_buf;
+ ps_dec->u4_dynamic_bits_buf_size = size;
+ }
+
+ if(ps_dec->pu1_bits_buf_dynamic)
+ {
+ pu1_bitstrm_buf = ps_dec->pu1_bits_buf_dynamic;
+ buf_size = ps_dec->u4_dynamic_bits_buf_size;
+ }
+ else
+ {
+ pu1_bitstrm_buf = ps_dec->pu1_bits_buf_static;
+ buf_size = ps_dec->u4_static_bits_buf_size;
+ }
u4_next_is_aud = 0;
@@ -2880,47 +1901,11 @@
if(buflen == -1)
buflen = 0;
/* Ignore bytes beyond the allocated size of intermediate buffer */
- buflen = MIN(buflen, (WORD32)ps_dec->ps_mem_tab[MEM_REC_BITSBUF].u4_mem_size);
+ buflen = MIN(buflen, buf_size);
bytes_consumed = buflen + u4_length_of_start_code;
ps_dec_op->u4_num_bytes_consumed += bytes_consumed;
- if(buflen >= MAX_NAL_UNIT_SIZE)
- {
-
- ih264d_fill_output_struct_from_context(ps_dec, ps_dec_op);
- H264_DEC_DEBUG_PRINT(
- "\nNal Size exceeded %d, Processing Stopped..\n",
- MAX_NAL_UNIT_SIZE);
- ps_dec->i4_error_code = 1 << IVD_CORRUPTEDDATA;
-
- ps_dec_op->e_pic_type = -1;
- /*signal the decode thread*/
- ih264d_signal_decode_thread(ps_dec);
- /*signal end of frame decode for curren frame*/
-
- if(ps_dec->u4_pic_buf_got == 0)
- {
- if(ps_dec->i4_header_decoded == 3)
- {
- ps_dec->u2_total_mbs_coded =
- ps_dec->ps_cur_sps->u2_max_mb_addr + 1;
- }
-
- /* close deblock thread if it is not closed yet*/
- if(ps_dec->u4_num_cores == 3)
- {
- ih264d_signal_bs_deblk_thread(ps_dec);
- }
- return IV_FAIL;
- }
- else
- {
- ps_dec->u1_pic_decode_done = 1;
- continue;
- }
- }
-
{
UWORD8 u1_firstbyte, u1_nal_ref_idc;
@@ -3020,7 +2005,6 @@
api_ret_value = IV_FAIL;
if((ret == IVD_RES_CHANGED)
- || (ret == IVD_STREAM_WIDTH_HEIGHT_NOT_SUPPORTED)
|| (ret == ERROR_UNAVAIL_PICBUF_T)
|| (ret == ERROR_UNAVAIL_MVBUF_T))
{
@@ -3102,7 +2086,6 @@
}
if((ret == IVD_RES_CHANGED)
- || (ret == IVD_STREAM_WIDTH_HEIGHT_NOT_SUPPORTED)
|| (ret == ERROR_UNAVAIL_PICBUF_T)
|| (ret == ERROR_UNAVAIL_MVBUF_T))
{
@@ -3290,7 +2273,7 @@
* Note in this mode, format conversion does not run paralelly in a thread and adds to the codec cycles
*/
- if((0 == ps_dec->u4_num_reorder_frames_at_init)
+ if((IVD_DECODE_FRAME_OUT == ps_dec->e_frm_out_mode)
&& ps_dec->u1_init_dec_flag)
{
@@ -3363,7 +2346,7 @@
return (IV_FAIL);
}
- version_string_len = strlen(version_string) + 1;
+ version_string_len = strnlen(version_string, MAXVERSION_STRLEN) + 1;
if(ps_ip->u4_version_buffer_size >= version_string_len) //(WORD32)sizeof(sizeof(version_string)))
{
@@ -3437,72 +2420,20 @@
ivd_set_display_frame_ip_t *dec_disp_ip;
ivd_set_display_frame_op_t *dec_disp_op;
- UWORD32 i, num_mvbank_req;
+ UWORD32 i;
dec_struct_t * ps_dec = (dec_struct_t *)(dec_hdl->pv_codec_handle);
dec_disp_ip = (ivd_set_display_frame_ip_t *)pv_api_ip;
dec_disp_op = (ivd_set_display_frame_op_t *)pv_api_op;
dec_disp_op->u4_error_code = 0;
- if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid)))
- {
- UWORD32 level, width_mbs, height_mbs;
- level = ps_dec->u4_level_at_init;
- width_mbs = ps_dec->u2_frm_wd_in_mbs;
- height_mbs = ps_dec->u2_frm_ht_in_mbs;
-
- if((ps_dec->ps_cur_sps->u1_vui_parameters_present_flag == 1)
- && (ps_dec->ps_cur_sps->s_vui.u4_num_reorder_frames != 64))
- {
- num_mvbank_req = ps_dec->ps_cur_sps->s_vui.u4_num_reorder_frames + 2;
- }
- else
- {
- /*if VUI is not present assume maximum possible refrence frames for the level,
- * as max reorder frames*/
- num_mvbank_req = ih264d_get_dpb_size_new(level, width_mbs,
- height_mbs);
- }
-
- num_mvbank_req += ps_dec->ps_cur_sps->u1_num_ref_frames + 1;
- }
- else
- {
- UWORD32 num_bufs_app, num_bufs_level;
- UWORD32 num_ref_frames, num_reorder_frames, luma_width;
- UWORD32 luma_height, level;
-
- num_ref_frames = ps_dec->u4_num_ref_frames_at_init;
- num_reorder_frames = ps_dec->u4_num_reorder_frames_at_init;
- level = ps_dec->u4_level_at_init;
- luma_width = ps_dec->u4_width_at_init;
- luma_height = ps_dec->u4_height_at_init;
-
- num_bufs_app = num_ref_frames + num_reorder_frames + 1;
-
- if(num_bufs_app <= 1)
- num_bufs_app = 2;
-
- num_bufs_level = ih264d_get_dpb_size_new(level, (luma_width >> 4),
- (luma_height >> 4));
-
- num_bufs_level = num_bufs_level * 2 + 1;
-
- num_mvbank_req = MIN(num_bufs_level, num_bufs_app);
-
- num_mvbank_req += ps_dec->u4_num_extra_disp_bufs_at_init;
-
- }
ps_dec->u4_num_disp_bufs = 0;
if(ps_dec->u4_share_disp_buf)
{
UWORD32 u4_num_bufs = dec_disp_ip->num_disp_bufs;
- if(u4_num_bufs > MAX_DISP_BUFS_NEW)
- u4_num_bufs = MAX_DISP_BUFS_NEW;
u4_num_bufs = MIN(u4_num_bufs, MAX_DISP_BUFS_NEW);
- u4_num_bufs = MIN(u4_num_bufs, num_mvbank_req);
ps_dec->u4_num_disp_bufs = u4_num_bufs;
for(i = 0; i < u4_num_bufs; i++)
@@ -3613,8 +2544,6 @@
ps_dec = (dec_struct_t *)(dec_hdl->pv_codec_handle);
- pic_wd = ps_dec->u4_width_at_init;
- pic_ht = ps_dec->u4_height_at_init;
if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid)))
{
@@ -3635,6 +2564,9 @@
}
else
{
+ pic_wd = 0;
+ pic_ht = 0;
+
ps_ctl_op->u4_pic_ht = pic_wd;
ps_ctl_op->u4_pic_wd = pic_ht;
@@ -3655,25 +2587,17 @@
{
if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid)))
{
- UWORD32 level, width_mbs, height_mbs;
-
- level = ps_dec->u4_level_at_init;
- width_mbs = ps_dec->u2_frm_wd_in_mbs;
- height_mbs = ps_dec->u2_frm_ht_in_mbs;
-
- if((ps_dec->ps_cur_sps->u1_vui_parameters_present_flag == 1)
- && (ps_dec->ps_cur_sps->s_vui.u4_num_reorder_frames
- != 64))
+ if((ps_dec->ps_cur_sps->u1_vui_parameters_present_flag == 1) &&
+ (1 == ps_dec->ps_cur_sps->s_vui.u1_bitstream_restriction_flag))
{
ps_ctl_op->u4_num_disp_bufs =
- ps_dec->ps_cur_sps->s_vui.u4_num_reorder_frames + 2;
+ ps_dec->ps_cur_sps->s_vui.u4_num_reorder_frames + 1;
}
else
{
/*if VUI is not present assume maximum possible refrence frames for the level,
* as max reorder frames*/
- ps_ctl_op->u4_num_disp_bufs = ih264d_get_dpb_size_new(
- level, width_mbs, height_mbs);
+ ps_ctl_op->u4_num_disp_bufs = ih264d_get_dpb_size(ps_dec->ps_cur_sps);
}
ps_ctl_op->u4_num_disp_bufs +=
@@ -3681,21 +2605,8 @@
}
else
{
- ps_ctl_op->u4_num_disp_bufs = ih264d_get_dpb_size_new(
- ps_dec->u4_level_at_init,
- (ps_dec->u4_width_at_init >> 4),
- (ps_dec->u4_height_at_init >> 4));
-
- ps_ctl_op->u4_num_disp_bufs +=
- ps_ctl_op->u4_num_disp_bufs;
-
- ps_ctl_op->u4_num_disp_bufs =
- MIN(ps_ctl_op->u4_num_disp_bufs,
- (ps_dec->u4_num_ref_frames_at_init
- + ps_dec->u4_num_reorder_frames_at_init));
-
+ ps_ctl_op->u4_num_disp_bufs = 32;
}
-
ps_ctl_op->u4_num_disp_bufs = MAX(
ps_ctl_op->u4_num_disp_bufs, 6);
ps_ctl_op->u4_num_disp_bufs = MIN(
@@ -3737,7 +2648,7 @@
for(i = 0; i < ps_ctl_op->u4_min_num_in_bufs; i++)
{
- ps_ctl_op->u4_min_in_buf_size[i] = MIN_IN_BUF_SIZE;
+ ps_ctl_op->u4_min_in_buf_size[i] = MAX(256000, pic_wd * pic_ht * 3 / 2);
}
/*!*/
@@ -3829,15 +2740,11 @@
ps_ctl_op->u4_num_disp_bufs = 1;
- for(i = 0; i < ps_ctl_op->u4_min_num_in_bufs; i++)
- {
- ps_ctl_op->u4_min_in_buf_size[i] = MIN_IN_BUF_SIZE;
- }
- pic_wd = ps_dec->u4_width_at_init;
- pic_ht = ps_dec->u4_height_at_init;
+ pic_wd = 0;
+ pic_ht = 0;
- if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid)))
+ if(ps_dec->i4_header_decoded == 3)
{
if(0 == ps_dec->u4_share_disp_buf)
@@ -3853,16 +2760,11 @@
}
}
- else
+
+ for(i = 0; i < ps_ctl_op->u4_min_num_in_bufs; i++)
{
- if(1 == ps_dec->u4_share_disp_buf)
- {
- pic_wd += (PAD_LEN_Y_H << 1);
- pic_ht += (PAD_LEN_Y_V << 2);
-
- }
+ ps_ctl_op->u4_min_in_buf_size[i] = MAX(256000, pic_wd * pic_ht * 3 / 2);
}
-
if((WORD32)ps_dec->u4_app_disp_width > pic_wd)
pic_wd = ps_dec->u4_app_disp_width;
@@ -3872,25 +2774,17 @@
{
if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid)))
{
- UWORD32 level, width_mbs, height_mbs;
-
- level = ps_dec->u4_level_at_init;
- width_mbs = ps_dec->u2_frm_wd_in_mbs;
- height_mbs = ps_dec->u2_frm_ht_in_mbs;
-
- if((ps_dec->ps_cur_sps->u1_vui_parameters_present_flag == 1)
- && (ps_dec->ps_cur_sps->s_vui.u4_num_reorder_frames
- != 64))
+ if((ps_dec->ps_cur_sps->u1_vui_parameters_present_flag == 1) &&
+ (1 == ps_dec->ps_cur_sps->s_vui.u1_bitstream_restriction_flag))
{
ps_ctl_op->u4_num_disp_bufs =
- ps_dec->ps_cur_sps->s_vui.u4_num_reorder_frames + 2;
+ ps_dec->ps_cur_sps->s_vui.u4_num_reorder_frames + 1;
}
else
{
/*if VUI is not present assume maximum possible refrence frames for the level,
* as max reorder frames*/
- ps_ctl_op->u4_num_disp_bufs = ih264d_get_dpb_size_new(
- level, width_mbs, height_mbs);
+ ps_ctl_op->u4_num_disp_bufs = ih264d_get_dpb_size(ps_dec->ps_cur_sps);
}
ps_ctl_op->u4_num_disp_bufs +=
@@ -3899,18 +2793,7 @@
}
else
{
- ps_ctl_op->u4_num_disp_bufs = ih264d_get_dpb_size_new(
- ps_dec->u4_level_at_init,
- (ps_dec->u4_width_at_init >> 4),
- (ps_dec->u4_height_at_init >> 4));
-
- ps_ctl_op->u4_num_disp_bufs +=
- ps_ctl_op->u4_num_disp_bufs;
-
- ps_ctl_op->u4_num_disp_bufs =
- MIN(ps_ctl_op->u4_num_disp_bufs,
- (ps_dec->u4_num_ref_frames_at_init
- + ps_dec->u4_num_reorder_frames_at_init));
+ ps_ctl_op->u4_num_disp_bufs = 32;
}
@@ -4031,11 +2914,11 @@
}
else
{
- if((ps_ctl_ip->u4_disp_wd >= ps_dec->u2_pic_wd)/* && (ps_ctl_ip->u4_disp_wd <= ps_dec->u4_width_at_init) */)
+ if(ps_ctl_ip->u4_disp_wd >= ps_dec->u2_pic_wd)
{
ps_dec->u4_app_disp_width = ps_ctl_ip->u4_disp_wd;
}
- else if((0 == ps_dec->i4_header_decoded) /*&& (ps_ctl_ip->u4_disp_wd <= ps_dec->u4_width_at_init)*/)
+ else if(0 == ps_dec->i4_header_decoded)
{
ps_dec->u4_app_disp_width = ps_ctl_ip->u4_disp_wd;
}
@@ -4065,7 +2948,15 @@
ps_dec->i4_decode_header = 1;
ret = IV_FAIL;
}
+ ps_dec->e_frm_out_mode = IVD_DISPLAY_FRAME_OUT;
+ if((ps_ctl_ip->e_frm_out_mode != IVD_DECODE_FRAME_OUT) &&
+ (ps_ctl_ip->e_frm_out_mode != IVD_DISPLAY_FRAME_OUT))
+ {
+ ps_ctl_op->u4_error_code = (1 << IVD_UNSUPPORTEDPARAM);
+ ret = IV_FAIL;
+ }
+ ps_dec->e_frm_out_mode = ps_ctl_ip->e_frm_out_mode;
return ret;
}
@@ -4115,7 +3006,40 @@
return ret;
}
+/*****************************************************************************/
+/* */
+/* Function Name : ih264d_reset */
+/* */
+/* Description : */
+/* */
+/* Inputs :iv_obj_t decoder handle */
+/* :pv_api_ip pointer to input structure */
+/* :pv_api_op pointer to output structure */
+/* Globals : <Does it use any global variables?> */
+/* Outputs : */
+/* Returns : void */
+/* */
+/* Issues : none */
+/* */
+/* Revision History: */
+/* */
+/* DD MM YYYY Author(s) Changes (Describe the changes made) */
+/* 22 10 2008 100356 Draft */
+/* */
+/*****************************************************************************/
+WORD32 ih264d_delete(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op)
+{
+ dec_struct_t *ps_dec;
+ ih264d_delete_ip_t *ps_ip = (ih264d_delete_ip_t *)pv_api_ip;
+ ih264d_delete_op_t *ps_op = (ih264d_delete_op_t *)pv_api_op;
+ ps_dec = (dec_struct_t *)(dec_hdl->pv_codec_handle);
+ UNUSED(ps_ip);
+ ps_op->s_ivd_delete_op_t.u4_error_code = 0;
+ ih264d_free_dynamic_bufs(ps_dec);
+ ih264d_free_static_bufs(dec_hdl);
+ return IV_SUCCESS;
+}
/*****************************************************************************/
/* */
/* Function Name : ih264d_reset */
@@ -4145,17 +3069,10 @@
ps_ctl_op->u4_error_code = 0;
ps_dec = (dec_struct_t *)(dec_hdl->pv_codec_handle);
-//CHECK
+
if(ps_dec != NULL)
{
-
ih264d_init_decoder(ps_dec);
-
- /*
- memset(ps_dec->disp_bufs, 0, (MAX_DISP_BUFS_NEW) * sizeof(disp_buf_t));
- memset(ps_dec->u4_disp_buf_mapping, 0, (MAX_DISP_BUFS_NEW) * sizeof(UWORD32));
- memset(ps_dec->u4_disp_buf_to_be_freed, 0, (MAX_DISP_BUFS_NEW) * sizeof(UWORD32));
- */
}
else
{
@@ -4400,8 +3317,8 @@
}
else
{
- disp_wd = ps_dec->u4_width_at_init;
- disp_ht = ps_dec->u4_height_at_init;
+ disp_wd = 0;
+ disp_ht = 0;
if(0 == ps_dec->u4_share_disp_buf)
{
@@ -4487,7 +3404,6 @@
if(ps_dec->u4_num_cores == 1)
{
ps_dec->u1_separate_parse = 0;
- ps_dec->pi4_ctxt_save_register_dec = ps_dec->pi4_ctxt_save_register;
}
else
{
@@ -4579,18 +3495,12 @@
switch(command)
{
- case IV_CMD_GET_NUM_MEM_REC:
- u4_api_ret = ih264d_get_num_rec((void *)pv_api_ip,
- (void *)pv_api_op);
-
+ case IVD_CMD_CREATE:
+ u4_api_ret = ih264d_create(dec_hdl, (void *)pv_api_ip,
+ (void *)pv_api_op);
break;
- case IV_CMD_FILL_NUM_MEM_REC:
-
- u4_api_ret = ih264d_fill_num_mem_rec((void *)pv_api_ip,
- (void *)pv_api_op);
- break;
- case IV_CMD_INIT:
- u4_api_ret = ih264d_init(dec_hdl, (void *)pv_api_ip,
+ case IVD_CMD_DELETE:
+ u4_api_ret = ih264d_delete(dec_hdl, (void *)pv_api_ip,
(void *)pv_api_op);
break;
@@ -4616,11 +3526,6 @@
(void *)pv_api_op);
break;
- case IV_CMD_RETRIEVE_MEMREC:
- u4_api_ret = ih264d_clr(dec_hdl, (void *)pv_api_ip,
- (void *)pv_api_op);
- break;
-
case IVD_CMD_VIDEO_CTL:
u4_api_ret = ih264d_ctl(dec_hdl, (void *)pv_api_ip,
(void *)pv_api_op);
diff --git a/decoder/ih264d_defs.h b/decoder/ih264d_defs.h
index fbdbd45..e266206 100644
--- a/decoder/ih264d_defs.h
+++ b/decoder/ih264d_defs.h
@@ -302,42 +302,6 @@
#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
diff --git a/decoder/ih264d_inter_pred.c b/decoder/ih264d_inter_pred.c
index d3e6a4d..01f2e01 100644
--- a/decoder/ih264d_inter_pred.c
+++ b/decoder/ih264d_inter_pred.c
@@ -869,7 +869,7 @@
/* 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;
diff --git a/decoder/ih264d_mb_utils.c b/decoder/ih264d_mb_utils.c
index c38b266..ded2756 100644
--- a/decoder/ih264d_mb_utils.c
+++ b/decoder/ih264d_mb_utils.c
@@ -1461,11 +1461,7 @@
/* 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;
}
diff --git a/decoder/ih264d_mem_request.h b/decoder/ih264d_mem_request.h
index 3c60c72..88e334d 100644
--- a/decoder/ih264d_mem_request.h
+++ b/decoder/ih264d_mem_request.h
@@ -76,7 +76,7 @@
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_ */
diff --git a/decoder/ih264d_parse_bslice.c b/decoder/ih264d_parse_bslice.c
index 6707039..0758b77 100644
--- a/decoder/ih264d_parse_bslice.c
+++ b/decoder/ih264d_parse_bslice.c
@@ -907,7 +907,7 @@
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 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 *);
diff --git a/decoder/ih264d_parse_headers.c b/decoder/ih264d_parse_headers.c
index 743b573..71db2e7 100644
--- a/decoder/ih264d_parse_headers.c
+++ b/decoder/ih264d_parse_headers.c
@@ -561,6 +561,10 @@
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;
@@ -777,49 +781,6 @@
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",
@@ -930,10 +891,6 @@
ps_dec->u2_disp_width = i4_cropped_wd;
}
- if(ps_dec->u4_level_at_init < u1_level_idc)
- {
- return IH264D_UNSUPPORTED_LEVEL;
- }
ps_seq->u1_is_valid = TRUE;
diff --git a/decoder/ih264d_parse_pslice.c b/decoder/ih264d_parse_pslice.c
index d56f44e..f300e2b 100644
--- a/decoder/ih264d_parse_pslice.c
+++ b/decoder/ih264d_parse_pslice.c
@@ -1655,9 +1655,17 @@
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 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 *);
diff --git a/decoder/ih264d_parse_slice.c b/decoder/ih264d_parse_slice.c
index eef9db5..fa85aa1 100644
--- a/decoder/ih264d_parse_slice.c
+++ b/decoder/ih264d_parse_slice.c
@@ -344,15 +344,12 @@
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 @@
<< 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 @@
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 @@
+ 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 @@
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 @@
|| ((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 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 *);
diff --git a/decoder/ih264d_process_pslice.c b/decoder/ih264d_process_pslice.c
index 2c7446e..95ac557 100644
--- a/decoder/ih264d_process_pslice.c
+++ b/decoder/ih264d_process_pslice.c
@@ -97,7 +97,6 @@
*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;
diff --git a/decoder/ih264d_structs.h b/decoder/ih264d_structs.h
index 062747b..4260393 100644
--- a/decoder/ih264d_structs.h
+++ b/decoder/ih264d_structs.h
@@ -581,12 +581,6 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
/* 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 @@
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 @@
/* 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 @@
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 @@
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 @@
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 @@
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;
diff --git a/decoder/ih264d_thread_parse_decode.c b/decoder/ih264d_thread_parse_decode.c
index f3da270..131c808 100644
--- a/decoder/ih264d_thread_parse_decode.c
+++ b/decoder/ih264d_thread_parse_decode.c
@@ -534,13 +534,7 @@
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;
diff --git a/decoder/ih264d_utils.c b/decoder/ih264d_utils.c
index 84909ea..d388421 100644
--- a/decoder/ih264d_utils.c
+++ b/decoder/ih264d_utils.c
@@ -550,16 +550,6 @@
u1_pic_type = TOP_REF | BOT_REF;
ps_dec->ps_cur_pic->u1_pic_type |= u1_pic_type;
-#if ROW_ACCESSES_STAT
- {
- H264_DEC_DEBUG_PRINT("Row_Accesses_BeforeBB = %6d, Row_Accesses_AfterBB = %6d \n\n",
- gui_Row_Accesses_BeforeBB, gui_Row_Accesses_AfterBB);
- gui_Row_Accesses_BeforeBBTotal += gui_Row_Accesses_BeforeBB;
- gui_Row_Accesses_AfterBBTotal += gui_Row_Accesses_AfterBB;
- gui_Row_Accesses_AfterBB = 0;
- gui_Row_Accesses_BeforeBB = 0;
- }
-#endif
if(ps_cur_slice->u1_field_pic_flag)
{
@@ -591,13 +581,12 @@
/* 28 04 2005 NS Draft */
/* */
/*****************************************************************************/
-WORD32 ih264d_get_dpb_size(dec_seq_params_t *ps_seq, dec_struct_t *ps_dec)
+WORD32 ih264d_get_dpb_size(dec_seq_params_t *ps_seq)
{
WORD32 i4_size;
UWORD8 u1_level_idc;
- u1_level_idc = ps_seq->u1_level_idc; //harcode for the time being
- u1_level_idc = MIN(u1_level_idc, ps_dec->u4_level_at_init);
+ u1_level_idc = ps_seq->u1_level_idc;
switch(u1_level_idc)
{
@@ -661,121 +650,6 @@
return (i4_size);
}
-WORD32 ih264d_get_dpb_size_new(UWORD32 u4_level_idc,
- UWORD32 u2_frm_wd_in_mbs,
- UWORD32 u2_frm_ht_in_mbs)
-{
-
- UWORD32 i4_size = 0;
-
- switch(u4_level_idc)
- {
- case 10:
- i4_size = 152064;
- break;
- case 11:
- i4_size = 345600;
- break;
- case 12:
- i4_size = 912384;
- break;
- case 13:
- i4_size = 912384;
- break;
- case 20:
- i4_size = 912384;
- break;
- case 21:
- i4_size = 1824768;
- break;
- case 22:
- i4_size = 3110400;
- break;
- case 30:
- i4_size = 3110400;
- break;
- case 31:
- i4_size = 6912000;
- break;
- case 32:
- i4_size = 7864320;
- break;
- case 40:
- i4_size = 12582912;
- break;
- case 41:
- i4_size = 12582912;
- break;
- case 42:
- i4_size = 12582912;
- break;
- case 50:
- i4_size = 42393600;
- break;
- case 51:
- i4_size = 70778880;
- break;
- case 52:
- i4_size = 70778880;
- break;
- default:
- {
- i4_size = 70778880;
- }
- break;
- }
-
- i4_size = i4_size / (u2_frm_wd_in_mbs * (u2_frm_ht_in_mbs));
- i4_size = (i4_size + 383) / 384;
- i4_size = MIN(i4_size, 16);
- i4_size = MAX(i4_size, 1);
- return (i4_size);
-}
-
-/*****************************************************************************/
-/* */
-/* Function Name : ih264d_max_possible_ref_pics */
-/* */
-/* Description : This function returns the maximum number of */
-/* reference buffers corresponding to the current Level */
-/* in accordance to "Table A-1 Level limits" in standard. */
-/* Please refer to Annex A - Profiles and Levels */
-/* Maximum Number of reference buffers are derived from */
-/* the dbpsize and max_mbs_in frame given in the table */
-/* Inputs : level number */
-/* */
-/* Revision History: */
-/* */
-/* DD MM YYYY Author(s) Changes (Describe the changes made) */
-/* 19 05 2005 SWRN Draft */
-/* */
-/*****************************************************************************/
-
-UWORD8 ih264d_max_possible_ref_pics(UWORD8 u1_level)
-{
- switch(u1_level)
- {
- case H264_LEVEL_1_0:
- return (MAX_REF_LEVEL_1_0);
- case H264_LEVEL_1_1:
- return (MAX_REF_LEVEL_1_1);
- case H264_LEVEL_1_2:
- return (MAX_REF_LEVEL_1_2);
- case H264_LEVEL_1_3:
- return (MAX_REF_LEVEL_1_3);
- case H264_LEVEL_2_0:
- return (MAX_REF_LEVEL_2_0);
- case H264_LEVEL_2_1:
- return (MAX_REF_LEVEL_2_1);
- case H264_LEVEL_2_2:
- return (MAX_REF_LEVEL_2_2);
- case H264_LEVEL_3_0:
- return (MAX_REF_LEVEL_3_0);
- }
-
- return (H264_MAX_REF_PICS);
-}
-
/***************************************************************************/
/* If change in Level or the required PicBuffers i4_size is more than the */
/* current one FREE the current PicBuffers and allocate affresh */
@@ -829,66 +703,7 @@
return OK;
}
-/*!
- **************************************************************************
- * \if Function name : get_numbuf_dpb_bank \endif
- *
- * \brief
- * Initializes the picture.
- *
- * \return
- * 0 on Success and Error code otherwise
- *
- * \note
- * This function is called when first slice of the
- * NON -IDR picture is encountered.
- **************************************************************************
- */
-static WORD32 get_numbuf_dpb_bank(dec_struct_t *ps_dec)
-{
- WORD32 i4_DPB_size;
- WORD32 i4_pic_size;
- WORD32 i4_num_buf_alloc;
- UWORD32 Ysize;
- UWORD32 UVsize;
- UWORD32 one_frm_size;
- UWORD32 luma_height;
- luma_height = ps_dec->u2_pic_ht;
-
- i4_DPB_size = ps_dec->ps_mem_tab[MEM_REC_REF_PIC].u4_mem_size;
-
- Ysize = (ps_dec->u2_frm_wd_y) * (luma_height + (PAD_LEN_Y_V << 2));
-
- UVsize = Ysize >> 2;
-
- {
- if(ps_dec->u4_share_disp_buf == 1)
- {
- /* In case of buffers getting shared between application and library
- there is no need of reference memtabs. Instead of setting the i4_size
- to zero, it is reduced to a small i4_size to ensure that changes
- in the code are minimal */
- if((ps_dec->u1_chroma_format == IV_YUV_420SP_UV)
- || (ps_dec->u1_chroma_format == IV_YUV_420SP_VU)
- || (ps_dec->u1_chroma_format == IV_YUV_420P))
- {
- Ysize = 64;
- }
- if(ps_dec->u1_chroma_format == IV_YUV_420SP_UV)
- {
- UVsize = 64;
- }
-
- }
- }
-
- one_frm_size = (((Ysize + 127) >> 7) << 7)
- + ((((UVsize << 1) + 127) >> 7) << 7);
- i4_num_buf_alloc = i4_DPB_size / (one_frm_size);
-
- return i4_num_buf_alloc;
-}
/*!
**************************************************************************
* \if Function name : ih264d_init_pic \endif
@@ -948,58 +763,44 @@
if(!ps_dec->u1_init_dec_flag
|| ih264d_is_sps_changed(ps_prev_seq_params, ps_seq))
{
+ ps_dec->u1_max_dec_frame_buffering = ih264d_get_dpb_size(ps_seq);
+ ps_dec->i4_display_delay = ps_dec->u1_max_dec_frame_buffering;
+ if((1 == ps_seq->u1_vui_parameters_present_flag) &&
+ (1 == ps_seq->s_vui.u1_bitstream_restriction_flag))
+ {
+ if(ps_seq->u1_frame_mbs_only_flag == 1)
+ ps_dec->i4_display_delay = ps_seq->s_vui.u4_num_reorder_frames + 1;
+ else
+ ps_dec->i4_display_delay = ps_seq->s_vui.u4_num_reorder_frames * 2 + 2;
+ }
- ivd_video_decode_ip_t *ps_dec_in = ps_dec->pv_dec_in;
- ivd_video_decode_op_t *ps_dec_out = ps_dec->pv_dec_out;
+ if(IVD_DECODE_FRAME_OUT == ps_dec->e_frm_out_mode)
+ ps_dec->i4_display_delay = 0;
if(ps_dec->u4_share_disp_buf == 0)
{
- i4_pic_bufs = get_numbuf_dpb_bank(ps_dec);
+ if(ps_seq->u1_frame_mbs_only_flag == 1)
+ ps_dec->u1_pic_bufs = ps_dec->i4_display_delay + ps_seq->u1_num_ref_frames + 1;
+ else
+ ps_dec->u1_pic_bufs = ps_dec->i4_display_delay + ps_seq->u1_num_ref_frames * 2 + 2;
}
else
{
- i4_pic_bufs = (WORD32)ps_dec->u4_num_disp_bufs;
+ ps_dec->u1_pic_bufs = (WORD32)ps_dec->u4_num_disp_bufs;
}
- ps_dec->u1_pic_bufs = CLIP_U8(i4_pic_bufs);
+ /* Ensure at least two buffers are allocated */
+ ps_dec->u1_pic_bufs = MAX(ps_dec->u1_pic_bufs, 2);
if(ps_dec->u4_share_disp_buf == 0)
ps_dec->u1_pic_bufs = MIN(ps_dec->u1_pic_bufs,
(H264_MAX_REF_PICS * 2));
- ps_dec->u1_max_dec_frame_buffering = ih264d_get_dpb_size(ps_seq,
- ps_dec);
-
- ps_dec->u1_max_dec_frame_buffering = MIN(
- ps_dec->u1_max_dec_frame_buffering,
- ps_dec->u4_num_ref_frames_at_init);
ps_dec->u1_max_dec_frame_buffering = MIN(
ps_dec->u1_max_dec_frame_buffering,
ps_dec->u1_pic_bufs);
-// ps_dec->u1_pic_bufs = ps_dec->i1_max_dec_frame_buffering;
-
- /* Fix is for handling one pic in and one pic out incase of */
- /* MMCO 5 or IDR */
-
- ps_dec->i4_display_delay = MIN(ps_dec->u4_num_reorder_frames_at_init,
- ps_dec->u1_max_dec_frame_buffering);
-
- if(1 == ps_seq->u1_vui_parameters_present_flag)
- {
- if(ps_seq->u1_frame_mbs_only_flag == 1)
- ps_dec->i4_display_delay = MIN(
- (UWORD32 )ps_dec->i4_display_delay,
- ((UWORD32 )ps_seq->s_vui.u4_num_reorder_frames
- + 1));
- else
- ps_dec->i4_display_delay = MIN(
- (UWORD32 )ps_dec->i4_display_delay,
- ((UWORD32 )ps_seq->s_vui.u4_num_reorder_frames
- + 1) * 2);
- }
-
/* Temporary hack to run Tractor Cav/Cab/MbAff Profiler streams also for CAFI1_SVA_C.264 in conformance*/
if(ps_dec->u1_init_dec_flag)
{
@@ -1021,12 +822,21 @@
return ret;
}
+ ret = ih264d_allocate_dynamic_bufs(ps_dec);
+ if(ret != OK)
+ {
+ /* Free any dynamic buffers that are allocated */
+ ih264d_free_dynamic_bufs(ps_dec);
+ ps_dec->i4_error_code = IVD_MEM_ALLOC_FAILED;
+ return IVD_MEM_ALLOC_FAILED;
+ }
+
ret = ih264d_create_pic_buffers(ps_dec->u1_pic_bufs,
ps_dec);
if(ret != OK)
return ret;
- ih264d_get_memory_dec_params(ps_dec);
+
ret = ih264d_create_mv_bank(ps_dec, ps_dec->u2_pic_wd,
ps_dec->u2_pic_ht);
@@ -1872,26 +1682,11 @@
UWORD32 u4_luma_size, u4_chroma_size;
UWORD8 u1_frm = ps_dec->ps_cur_sps->u1_frame_mbs_only_flag;
WORD32 j;
- UWORD32 u4_pic_buf_mem_used, u4_ref_buf_mem_used;
- UWORD8 *pu1_pic_buf_mem_base, *pu1_ref_buf_mem_base;
+ UWORD8 *pu1_buf;
- u4_pic_buf_mem_used = 0;
- pu1_pic_buf_mem_base = ps_dec->ps_mem_tab[MEM_REC_PIC_BUF_MGR].pv_base;
-
- ps_dec->pv_disp_buf_mgr = (void *)(pu1_pic_buf_mem_base
- + u4_pic_buf_mem_used);
- u4_pic_buf_mem_used += sizeof(disp_mgr_t);
+ ps_pic_buf = ps_dec->ps_pic_buf_base;
ih264_disp_mgr_init((disp_mgr_t *)ps_dec->pv_disp_buf_mgr);
-
- ps_dec->pv_pic_buf_mgr =
- (void *)(pu1_pic_buf_mem_base + u4_pic_buf_mem_used);
- u4_pic_buf_mem_used += sizeof(buf_mgr_t) + ithread_get_mutex_lock_size();
ih264_buf_mgr_init((buf_mgr_t *)ps_dec->pv_pic_buf_mgr);
-
- ps_pic_buf = (pic_buffer_t *)(pu1_pic_buf_mem_base + u4_pic_buf_mem_used);
- u4_pic_buf_mem_used += sizeof(struct pic_buffer_t)
- * (H264_MAX_REF_PICS * 2);
-
u4_luma_size = ps_dec->u2_frm_wd_y * ps_dec->u2_frm_ht_y;
u4_chroma_size = ps_dec->u2_frm_wd_uv * ps_dec->u2_frm_ht_uv;
@@ -1910,7 +1705,6 @@
}
if(ps_dec->u1_chroma_format == IV_YUV_420SP_UV)
-
{
u4_chroma_size = 64;
}
@@ -1918,8 +1712,7 @@
}
}
- pu1_ref_buf_mem_base = ps_dec->ps_mem_tab[MEM_REC_REF_PIC].pv_base;
- u4_ref_buf_mem_used = 0;
+ pu1_buf = ps_dec->pu1_pic_buf_base;
/* Allocate memory for refernce buffers */
for(i = 0; i < u1_num_of_buf; i++)
@@ -1927,11 +1720,12 @@
UWORD32 u4_offset;
WORD32 buf_ret;
UWORD8 *pu1_luma, *pu1_chroma;
+ void *pv_mem_ctxt = ps_dec->pv_mem_ctxt;
- pu1_luma = pu1_ref_buf_mem_base + u4_ref_buf_mem_used;
- u4_ref_buf_mem_used += u4_luma_size;
- pu1_chroma = pu1_ref_buf_mem_base + u4_ref_buf_mem_used;
- u4_ref_buf_mem_used += u4_chroma_size;
+ pu1_luma = pu1_buf;
+ pu1_buf += ALIGN64(u4_luma_size);
+ pu1_chroma = pu1_buf;
+ pu1_buf += ALIGN64(u4_chroma_size);
/* Offset to the start of the pic from the top left corner of the frame
buffer */
@@ -1990,9 +1784,7 @@
ps_dec->disp_bufs[i].u4_ofst[1] = u4_offset;
ps_dec->disp_bufs[i].u4_ofst[2] = u4_offset;
-
}
-
}
ps_pic_buf->u2_frm_ht_y = ps_dec->u2_frm_ht_y;
@@ -2014,13 +1806,6 @@
ps_pic_buf++;
}
- if((u4_ref_buf_mem_used > ps_dec->ps_mem_tab[MEM_REC_REF_PIC].u4_mem_size) ||
- (u4_pic_buf_mem_used > ps_dec->ps_mem_tab[MEM_REC_PIC_BUF_MGR].u4_mem_size))
- {
- ps_dec->i4_error_code = ERROR_BUF_MGR;
- return ERROR_BUF_MGR;
- }
-
if(1 == ps_dec->u4_share_disp_buf)
{
for(i = 0; i < u1_num_of_buf; i++)
@@ -2031,7 +1816,7 @@
/*!
**************************************************************************
- * \if Function name : ih264d_get_memory_dec_params \endif
+ * \if Function name : ih264d_allocate_dynamic_bufs \endif
*
* \brief
* This function allocates memory required by Decoder.
@@ -2043,7 +1828,7 @@
*
**************************************************************************
*/
-WORD16 ih264d_get_memory_dec_params(dec_struct_t * ps_dec)
+WORD16 ih264d_allocate_dynamic_bufs(dec_struct_t * ps_dec)
{
struct MemReq s_MemReq;
struct MemBlock *p_MemBlock;
@@ -2068,330 +1853,237 @@
UWORD32 ui_size = 0;
UWORD32 u4_int_scratch_size = 0, u4_ref_pred_size = 0;
UWORD8 *pu1_buf;
+ WORD32 num_entries;
+ WORD32 size;
+ void *pv_buf;
+ UWORD32 u4_num_bufs;
+ UWORD32 u4_luma_size, u4_chroma_size;
+ void *pv_mem_ctxt = ps_dec->pv_mem_ctxt;
- ps_dec->ps_deblk_pic = ps_dec->ps_mem_tab[MEM_REC_DEBLK_MB_INFO].pv_base;
- memset(ps_dec->ps_deblk_pic, 0, ps_dec->ps_mem_tab[MEM_REC_DEBLK_MB_INFO].u4_mem_size);
+ size = u4_total_mbs;
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pu1_dec_mb_map = pv_buf;
- ps_dec->pu1_dec_mb_map = ps_dec->ps_mem_tab[MEM_REC_PARSE_MAP].pv_base;
+ size = u4_total_mbs;
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pu1_recon_mb_map = pv_buf;
- ps_dec->pu1_recon_mb_map = ps_dec->ps_mem_tab[MEM_REC_PROC_MAP].pv_base;
+ size = u4_total_mbs * sizeof(UWORD16);
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pu2_slice_num_map = pv_buf;
- ps_dec->pu2_slice_num_map =
- ps_dec->ps_mem_tab[MEM_REC_SLICE_NUM_MAP].pv_base;
+ /************************************************************/
+ /* Post allocation Initialisations */
+ /************************************************************/
+ ps_dec->ps_parse_cur_slice = &(ps_dec->ps_dec_slice_buf[0]);
+ ps_dec->ps_decode_cur_slice = &(ps_dec->ps_dec_slice_buf[0]);
+ ps_dec->ps_computebs_cur_slice = &(ps_dec->ps_dec_slice_buf[0]);
- ps_dec->ps_dec_slice_buf = ps_dec->ps_mem_tab[MEM_REC_SLICE_HDR].pv_base;
- memset(ps_dec->ps_mem_tab[MEM_REC_SLICE_HDR].pv_base, 0,
- ps_dec->ps_mem_tab[MEM_REC_SLICE_HDR].u4_mem_size);
+ ps_dec->ps_pred_start = ps_dec->ps_pred;
+
+ size = sizeof(parse_pmbarams_t) * (ps_dec->u1_recon_mb_grp);
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_parse_mb_data = pv_buf;
+
+ size = sizeof(parse_part_params_t)
+ * ((ps_dec->u1_recon_mb_grp) << 4);
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_parse_part_params = pv_buf;
+
+ size = ((u4_wd_mbs * sizeof(deblkmb_neighbour_t)) << uc_frmOrFld);
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_deblk_top_mb = pv_buf;
+
+ size = ((sizeof(ctxt_inc_mb_info_t))
+ * (((u4_wd_mbs + 1) << uc_frmOrFld) + 1));
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->p_ctxt_inc_mb_map = pv_buf;
+
+ size = (sizeof(mv_pred_t) * ps_dec->u1_recon_mb_grp
+ * 16);
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_mv_p[0] = pv_buf;
+
+ size = (sizeof(mv_pred_t) * ps_dec->u1_recon_mb_grp
+ * 16);
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_mv_p[1] = pv_buf;
+
+ {
+ UWORD8 i;
+ for(i = 0; i < MV_SCRATCH_BUFS; i++)
+ {
+ size = (sizeof(mv_pred_t)
+ * ps_dec->u1_recon_mb_grp * 4);
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_mv_top_p[i] = pv_buf;
+ }
+ }
+
+ size = sizeof(UWORD8) * ((u4_wd_mbs + 1) * MB_SIZE) * 2;
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pu1_y_intra_pred_line = pv_buf;
+ memset(ps_dec->pu1_y_intra_pred_line, 0, size);
+
+ size = sizeof(UWORD8) * ((u4_wd_mbs + 1) * MB_SIZE) * 2;
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pu1_u_intra_pred_line = pv_buf;
+ memset(ps_dec->pu1_u_intra_pred_line, 0, size);
+
+ size = sizeof(UWORD8) * ((u4_wd_mbs + 1) * MB_SIZE) * 2;
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pu1_v_intra_pred_line = pv_buf;
+ memset(ps_dec->pu1_v_intra_pred_line, 0, size);
+
+ if(ps_dec->u1_separate_parse)
+ {
+ size = sizeof(mb_neigbour_params_t)
+ * 2 * ((u4_wd_mbs + 2) * u4_ht_mbs);
+ }
+ else
+ {
+ size = sizeof(mb_neigbour_params_t)
+ * 2 * ((u4_wd_mbs + 2) << uc_frmOrFld);
+ }
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+
+ ps_dec->ps_nbr_mb_row = pv_buf;
+ memset(ps_dec->ps_nbr_mb_row, 0, size);
+
+ /* Allocate deblock MB info */
+ size = (u4_total_mbs + u4_wd_mbs) * sizeof(deblk_mb_t);
+
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_deblk_pic = pv_buf;
+
+ memset(ps_dec->ps_deblk_pic, 0, size);
+
+ /* Allocate frame level mb info */
+ size = sizeof(dec_mb_info_t) * u4_total_mbs;
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_frm_mb_info = pv_buf;
+ memset(ps_dec->ps_frm_mb_info, 0, size);
+
+ /* Allocate memory for slice headers dec_slice_struct_t */
+ 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 *);
+ size *= u4_total_mbs;
+ size += sizeof(dec_slice_struct_t) * u4_total_mbs;
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+
+ ps_dec->ps_dec_slice_buf = pv_buf;
+ memset(ps_dec->ps_dec_slice_buf, 0, size);
pu1_buf = (UWORD8 *)ps_dec->ps_dec_slice_buf;
pu1_buf += sizeof(dec_slice_struct_t) * u4_total_mbs;
ps_dec->pv_map_ref_idx_to_poc_buf = (void *)pu1_buf;
- ps_dec->ps_frm_mb_info = ps_dec->ps_mem_tab[MEM_REC_MB_INFO].pv_base;
- memset(ps_dec->ps_frm_mb_info, 0, ps_dec->ps_mem_tab[MEM_REC_MB_INFO].u4_mem_size);
+ /* Allocate memory for packed pred info */
+ num_entries = u4_total_mbs;
+ if(1 == ps_dec->ps_cur_sps->u1_num_ref_frames)
+ num_entries *= 16;
+ else
+ num_entries *= 16 * 2;
- ps_dec->ps_pred = ps_dec->ps_mem_tab[MEM_REC_PRED_INFO].pv_base;
+ size = sizeof(pred_info_pkd_t) * num_entries;
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->ps_pred_pkd = pv_buf;
- ps_dec->pi2_coeff_data = ps_dec->ps_mem_tab[MEM_REC_COEFF_DATA].pv_base;
+ /* Allocate memory for coeff data */
+ size = MB_LUM_SIZE * sizeof(WORD16);
+ /*For I16x16 MBs, 16 4x4 AC coeffs and 1 4x4 DC coeff TU blocks will be sent
+ For all MBs along with 8 4x4 AC coeffs 2 2x2 DC coeff TU blocks will be sent
+ So use 17 4x4 TU blocks for luma and 9 4x4 TU blocks for chroma */
+ size += u4_total_mbs * (MAX(17 * sizeof(tu_sblk4x4_coeff_data_t),4 * sizeof(tu_blk8x8_coeff_data_t))
+ + 9 * sizeof(tu_sblk4x4_coeff_data_t));
+ //32 bytes for each mb to store u1_prev_intra4x4_pred_mode and u1_rem_intra4x4_pred_mode data
+ size += u4_total_mbs * 32;
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+
+ ps_dec->pi2_coeff_data = pv_buf;
ps_dec->pv_pic_tu_coeff_data = (void *)(ps_dec->pi2_coeff_data + MB_LUM_SIZE);
- /*scratch memory allocations*/
+ /* Allocate MV bank buffer */
{
- UWORD8 *pu1_scratch_mem_base;
- UWORD32 u4_scratch_mem_used;
+ UWORD32 col_flag_buffer_size, mvpred_buffer_size;
- pu1_scratch_mem_base =
- ps_dec->ps_mem_tab[MEM_REC_INTERNAL_SCRATCH].pv_base;
- u4_scratch_mem_used = 0;
+ col_flag_buffer_size = ((ps_dec->u2_pic_wd * ps_dec->u2_pic_ht) >> 4);
+ mvpred_buffer_size = sizeof(mv_pred_t)
+ * ((ps_dec->u2_pic_wd * (ps_dec->u2_pic_ht + PAD_MV_BANK_ROW)) >> 4);
- ps_dec->ppv_map_ref_idx_to_poc = (void *)(pu1_scratch_mem_base
- + u4_scratch_mem_used);
- u4_scratch_mem_used = ALIGN64(u4_scratch_mem_used);
- u4_scratch_mem_used += ((TOTAL_LIST_ENTRIES + PAD_MAP_IDX_POC)
- * sizeof(void *));
- u4_scratch_mem_used = ALIGN64(u4_scratch_mem_used);
- memset(ps_dec->ppv_map_ref_idx_to_poc, 0, (TOTAL_LIST_ENTRIES + PAD_MAP_IDX_POC)
- * sizeof(void *));
+ u4_num_bufs = ps_dec->ps_cur_sps->u1_num_ref_frames + 1;
- ps_dec->p_cabac_ctxt_table_t = (void *)(pu1_scratch_mem_base
- + u4_scratch_mem_used);
- u4_scratch_mem_used += (sizeof(bin_ctxt_model_t) * NUM_CABAC_CTXTS);
- u4_scratch_mem_used = ALIGN64(u4_scratch_mem_used);
-
- ps_dec->ps_left_mb_ctxt_info = (void *)(pu1_scratch_mem_base
- + u4_scratch_mem_used);
- u4_scratch_mem_used += sizeof(ctxt_inc_mb_info_t);
- u4_scratch_mem_used = ALIGN64(u4_scratch_mem_used);
-
- ps_dec->pu4_defI_wts_ofsts = (void *)(pu1_scratch_mem_base
- + u4_scratch_mem_used);
- u4_scratch_mem_used +=
- sizeof(UWORD32)
- * (ps_sps->u1_num_ref_frames
- * ps_sps->u1_num_ref_frames);
- u4_scratch_mem_used = ALIGN64(u4_scratch_mem_used);
-
- ps_dec->pu1_ref_buff = pu1_scratch_mem_base + u4_scratch_mem_used + MAX_REF_BUF_SIZE;
- u4_scratch_mem_used += MAX_REF_BUF_SIZE * 2;
- u4_scratch_mem_used = ALIGN64(u4_scratch_mem_used);
- ps_dec->pi2_pred1 =
- (void *)(pu1_scratch_mem_base + u4_scratch_mem_used);
- u4_scratch_mem_used += ((sizeof(WORD16)) * PRED_BUFFER_WIDTH
- * PRED_BUFFER_HEIGHT * 2);
- u4_scratch_mem_used = ALIGN64(u4_scratch_mem_used);
-
- ps_dec->pu1_temp_mc_buffer = (void *)(pu1_scratch_mem_base
- + u4_scratch_mem_used);
- u4_scratch_mem_used += sizeof(UWORD8) * (MB_LUM_SIZE);
-
- ps_dec->ps_parse_mb_data = (void *)(pu1_scratch_mem_base
- + u4_scratch_mem_used);
- u4_scratch_mem_used += sizeof(parse_pmbarams_t)
- * (ps_dec->u1_recon_mb_grp);
- u4_scratch_mem_used = ALIGN64(u4_scratch_mem_used);
-
- ps_dec->ps_parse_part_params = (void *)(pu1_scratch_mem_base
- + u4_scratch_mem_used);
- u4_scratch_mem_used += sizeof(parse_part_params_t)
- * ((ps_dec->u1_recon_mb_grp) << 4);
- u4_scratch_mem_used = ALIGN64(u4_scratch_mem_used);
-
- ps_dec->ps_dpb_mgr->ps_init_dpb[0][0] =
- (struct pic_buffer_t*)(pu1_scratch_mem_base
- + u4_scratch_mem_used);
- u4_scratch_mem_used += 2 * MAX_REF_BUFS * sizeof(struct pic_buffer_t);
-
- u4_scratch_mem_used = ALIGN64(u4_scratch_mem_used);
- ps_dec->ps_dpb_mgr->ps_init_dpb[1][0] =
- (struct pic_buffer_t*)(pu1_scratch_mem_base + u4_scratch_mem_used);
- u4_scratch_mem_used += 2 * MAX_REF_BUFS * sizeof(struct pic_buffer_t);
- u4_scratch_mem_used = ALIGN64(u4_scratch_mem_used);
- ps_dec->pu4_mbaff_wt_mat = (UWORD32 *)(pu1_scratch_mem_base + u4_scratch_mem_used);
-
- u4_scratch_mem_used += (sizeof(UWORD32) * 3
- * (MAX_FRAMES * MAX_FRAMES))
- << 3;
- u4_scratch_mem_used = ALIGN64(u4_scratch_mem_used);
-
- ps_dec->pu4_wts_ofsts_mat = (UWORD32 *)(pu1_scratch_mem_base + u4_scratch_mem_used);
- u4_scratch_mem_used += sizeof(UWORD32) * 2 * 3
- * (MAX_FRAMES * MAX_FRAMES);
- u4_scratch_mem_used = ALIGN64(u4_scratch_mem_used);
+ u4_num_bufs = MIN(u4_num_bufs, ps_dec->u1_pic_bufs);
+ u4_num_bufs = MAX(u4_num_bufs, 2);
+ size = ALIGN64(mvpred_buffer_size) + ALIGN64(col_flag_buffer_size);
+ size *= u4_num_bufs;
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pu1_mv_bank_buf_base = pv_buf;
}
- /********************************************************************/
- /* check whether deblk memory used is less than the scratch buffer */
- /* and assign deblocking pointers in the the reference buffers */
- /********************************************************************/
+
+ /* Allocate Pic buffer */
+ u4_luma_size = ps_dec->u2_frm_wd_y * ps_dec->u2_frm_ht_y;
+ u4_chroma_size = ps_dec->u2_frm_wd_uv * ps_dec->u2_frm_ht_uv;
+
{
- /************************************************************/
- /* Post allocation Initialisations */
- /************************************************************/
- memset(ps_dec->ppv_map_ref_idx_to_poc, 0,
- (TOTAL_LIST_ENTRIES + PAD_MAP_IDX_POC) * sizeof(void *));
- ps_dec->ppv_map_ref_idx_to_poc += OFFSET_MAP_IDX_POC;
-
+ if(ps_dec->u4_share_disp_buf == 1)
{
- ps_dec->ps_parse_cur_slice = &(ps_dec->ps_dec_slice_buf[0]);
- ps_dec->ps_decode_cur_slice = &(ps_dec->ps_dec_slice_buf[0]);
- ps_dec->ps_computebs_cur_slice = &(ps_dec->ps_dec_slice_buf[0]);
-
- ps_dec->ps_pred_start = ps_dec->ps_pred;
- ps_dec->u4_ref_buf_size = MAX_REF_BUF_SIZE;
- }
-
- {
- UWORD8 i;
- struct pic_buffer_t *ps_init_dpb;
- ps_init_dpb = ps_dec->ps_dpb_mgr->ps_init_dpb[0][0];
- for(i = 0; i < 2 * MAX_REF_BUFS; i++)
+ /* In case of buffers getting shared between application and library
+ there is no need of reference memtabs. Instead of setting the i4_size
+ to zero, it is reduced to a small i4_size to ensure that changes
+ in the code are minimal */
+ if((ps_dec->u1_chroma_format == IV_YUV_420SP_UV)
+ || (ps_dec->u1_chroma_format == IV_YUV_420SP_VU)
+ || (ps_dec->u1_chroma_format == IV_YUV_420P))
{
- ps_init_dpb->pu1_buf1 = NULL;
- ps_init_dpb->u1_long_term_frm_idx = MAX_REF_BUFS + 1;
- ps_dec->ps_dpb_mgr->ps_init_dpb[0][i] = ps_init_dpb;
- ps_dec->ps_dpb_mgr->ps_mod_dpb[0][i] = ps_init_dpb;
- ps_init_dpb++;
+ u4_luma_size = 64;
}
- ps_init_dpb = ps_dec->ps_dpb_mgr->ps_init_dpb[1][0];
- for(i = 0; i < 2 * MAX_REF_BUFS; i++)
+ if(ps_dec->u1_chroma_format == IV_YUV_420SP_UV)
{
- ps_init_dpb->pu1_buf1 = NULL;
- ps_init_dpb->u1_long_term_frm_idx = MAX_REF_BUFS + 1;
- ps_dec->ps_dpb_mgr->ps_init_dpb[1][i] = ps_init_dpb;
- ps_dec->ps_dpb_mgr->ps_mod_dpb[1][i] = ps_init_dpb;
- ps_init_dpb++;
+ u4_chroma_size = 64;
}
+
}
}
- /*persistent memory allocations*/
-
- {
- UWORD8 *pu1_persitent_mem_base;
- UWORD32 u4_persistent_mem_used;
-
- pu1_persitent_mem_base =
- ps_dec->ps_mem_tab[MEM_REC_INTERNAL_PERSIST].pv_base;
- u4_persistent_mem_used = 0;
-
- ps_dec->ps_deblk_top_mb = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += ((u4_wd_mbs
- * sizeof(deblkmb_neighbour_t)) << uc_frmOrFld);
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- ps_dec->ps_left_mvpred_addr = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += (sizeof(neighbouradd_t) << 2);
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- ps_dec->p_ctxt_inc_mb_map = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += ((sizeof(ctxt_inc_mb_info_t))
- * (((u4_wd_mbs + 1) << uc_frmOrFld) + 1));
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- ps_dec->ps_mv_p[0] = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += (sizeof(mv_pred_t) * ps_dec->u1_recon_mb_grp
- * 16);
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- ps_dec->ps_mv_p[1] = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += (sizeof(mv_pred_t) * ps_dec->u1_recon_mb_grp
- * 16);
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- {
- UWORD8 i;
- for(i = 0; i < MV_SCRATCH_BUFS; i++)
- {
-
- ps_dec->ps_mv_top_p[i] = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += (sizeof(mv_pred_t)
- * ps_dec->u1_recon_mb_grp * 4);
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- }
- }
-
- {
- UWORD32 u4_numRows = MB_SIZE << 1;
-
- /* Allocate memory for ping, pong and left reconstruction buffers */
- u4_blk_wd = ((ps_dec->u1_recon_mb_grp << 4) >> 1) + 8;
-
- ps_dec->pu1_y_scratch[0] = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += sizeof(UWORD8) * u4_numRows * u4_blk_wd;
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- ps_dec->pu1_y_scratch[1] = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += sizeof(UWORD8) * u4_numRows * u4_blk_wd;
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- u4_numRows = BLK8x8SIZE << 1;
- u4_blk_wd = ((ps_dec->u1_recon_mb_grp << 3) >> 1) + 8;
-
- ps_dec->pu1_u_scratch[0] = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += sizeof(UWORD8) * u4_numRows * u4_blk_wd;
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- ps_dec->pu1_v_scratch[0] = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += sizeof(UWORD8) * u4_numRows * u4_blk_wd;
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- ps_dec->pu1_u_scratch[1] = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += sizeof(UWORD8) * u4_numRows * u4_blk_wd;
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- ps_dec->pu1_v_scratch[1] = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += sizeof(UWORD8) * u4_numRows * u4_blk_wd;
- u4_persistent_mem_used += 32;
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- }
-
- ps_dec->pu1_y_intra_pred_line = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += sizeof(UWORD8) * ((u4_wd_mbs + 1) * MB_SIZE) * 2;
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- ps_dec->pu1_u_intra_pred_line = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += sizeof(UWORD8) * ((u4_wd_mbs + 1) * MB_SIZE) * 2;
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- ps_dec->pu1_v_intra_pred_line = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += sizeof(UWORD8) * ((u4_wd_mbs + 1) * MB_SIZE) * 2;
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- ps_dec->ps_nbr_mb_row = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- if(ps_dec->u1_separate_parse)
- {
- u4_persistent_mem_used += sizeof(mb_neigbour_params_t)
- * ((u4_wd_mbs + 1) * u4_ht_mbs);
- memset(ps_dec->ps_nbr_mb_row, 0, sizeof(mb_neigbour_params_t)
- * ((u4_wd_mbs + 1) * u4_ht_mbs));
- }
- else
- {
- u4_persistent_mem_used += sizeof(mb_neigbour_params_t)
- * ((u4_wd_mbs + 1) << uc_frmOrFld);
- memset(ps_dec->ps_nbr_mb_row, 0, sizeof(mb_neigbour_params_t)
- * ((u4_wd_mbs + 1) << uc_frmOrFld));
-
- }
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
- ps_dec->s_pad_mgr.pu1_row_y = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += ps_dec->u2_frm_wd_y;
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- ps_dec->s_pad_mgr.pu1_row_u = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += ps_dec->u2_frm_wd_uv;
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- ps_dec->s_pad_mgr.pu1_row_v = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += ps_dec->u2_frm_wd_uv;
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- ps_dec->s_pad_mgr.pu1_mb_y = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += ((MB_SIZE + 4) << uc_frmOrFld) * PAD_LEN_Y_H;
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- ps_dec->s_pad_mgr.pu1_mb_u = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += ((BLK8x8SIZE + 2) << uc_frmOrFld)
- * PAD_LEN_UV_H;
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
-
- ps_dec->s_pad_mgr.pu1_mb_v = (void *)(pu1_persitent_mem_base
- + u4_persistent_mem_used);
- u4_persistent_mem_used += ((BLK8x8SIZE + 2) << uc_frmOrFld)
- * PAD_LEN_UV_H;
- u4_persistent_mem_used = ALIGN64(u4_persistent_mem_used);
- }
-
- /*Post allocation initializations*/
- memset(ps_dec->pu1_y_intra_pred_line, 0,
- sizeof(UWORD8) * u4_luma_wd + PAD_LEN_Y_H);
- memset(ps_dec->pu1_u_intra_pred_line, 0,
- sizeof(UWORD8) * u4_chroma_wd + PAD_LEN_UV_H);
- memset(ps_dec->pu1_v_intra_pred_line, 0,
- sizeof(UWORD8) * u4_chroma_wd + PAD_LEN_UV_H);
+ size = ALIGN64(u4_luma_size) + ALIGN64(u4_chroma_size);
+ size *= ps_dec->u1_pic_bufs;
+ pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size);
+ RETURN_IF((NULL == pv_buf), IV_FAIL);
+ ps_dec->pu1_pic_buf_base = pv_buf;
/* 0th entry of CtxtIncMbMap will be always be containing default values
for CABAC context representing MB not available */
@@ -2472,15 +2164,68 @@
ps_dec->s_high_profile.ps_last_sigcoeff_8x8_field =
p_cabac_ctxt_table_t
+ LAST_SIGNIFICANT_COEFF_FLAG_8X8_FIELD;
-
}
-
}
return (i16_status);
}
/*!
**************************************************************************
+ * \if Function name : ih264d_free_dynamic_bufs \endif
+ *
+ * \brief
+ * This function frees dynamic memory allocated by Decoder.
+ *
+ * \param ps_dec: Pointer to dec_struct_t.
+ *
+ * \return
+ * Returns i4_status as returned by MemManager.
+ *
+ **************************************************************************
+ */
+WORD16 ih264d_free_dynamic_bufs(dec_struct_t * ps_dec)
+{
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_bits_buf_dynamic);
+
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_deblk_pic);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_dec_mb_map);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_recon_mb_map);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu2_slice_num_map);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_dec_slice_buf);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_frm_mb_info);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pi2_coeff_data);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_parse_mb_data);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_parse_part_params);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_deblk_top_mb);
+
+ if(ps_dec->p_ctxt_inc_mb_map)
+ {
+ ps_dec->p_ctxt_inc_mb_map -= 1;
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->p_ctxt_inc_mb_map);
+ }
+
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_mv_p[0]);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_mv_p[1]);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_pred_pkd);
+ {
+ UWORD8 i;
+ for(i = 0; i < MV_SCRATCH_BUFS; i++)
+ {
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_mv_top_p[i]);
+ }
+ }
+
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_y_intra_pred_line);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_u_intra_pred_line);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_v_intra_pred_line);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_nbr_mb_row);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_mv_bank_buf_base);
+ PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_pic_buf_base);
+ return 0;
+}
+
+/*!
+ **************************************************************************
* \if Function name : ih264d_create_mv_bank \endif
*
* \brief
@@ -2508,39 +2253,38 @@
UWORD8 i;
UWORD32 col_flag_buffer_size, mvpred_buffer_size;
UWORD8 *pu1_mv_buf_mgr_base, *pu1_mv_bank_base;
- UWORD32 u4_mv_buf_mgr_mem_used, u4_mv_bank_mem_used;
col_mv_buf_t *ps_col_mv;
mv_pred_t *ps_mv;
UWORD8 *pu1_col_zero_flag_buf;
dec_struct_t *ps_dec = (dec_struct_t *)pv_dec;
WORD32 buf_ret;
+ UWORD32 u4_num_bufs;
+ UWORD8 *pu1_buf;
+ WORD32 size;
+ void *pv_mem_ctxt = ps_dec->pv_mem_ctxt;
- pu1_mv_buf_mgr_base = ps_dec->ps_mem_tab[MEM_REC_MV_BUF_MGR].pv_base;
- u4_mv_buf_mgr_mem_used = 0;
col_flag_buffer_size = ((ui_width * ui_height) >> 4);
-
- pu1_mv_bank_base = ps_dec->ps_mem_tab[MEM_REC_MVBANK].pv_base;
- u4_mv_bank_mem_used = 0;
mvpred_buffer_size = sizeof(mv_pred_t)
* ((ui_width * (ui_height + PAD_MV_BANK_ROW)) >> 4);
- ps_dec->pv_mv_buf_mgr = (void *)(pu1_mv_buf_mgr_base + u4_mv_buf_mgr_mem_used);
- u4_mv_buf_mgr_mem_used += sizeof(buf_mgr_t) + ithread_get_mutex_lock_size();
ih264_buf_mgr_init((buf_mgr_t *)ps_dec->pv_mv_buf_mgr);
- ps_col_mv = (col_mv_buf_t *)(pu1_mv_buf_mgr_base + u4_mv_buf_mgr_mem_used);
- u4_mv_buf_mgr_mem_used += sizeof(col_mv_buf_t) * (H264_MAX_REF_PICS * 2);
- u4_mv_buf_mgr_mem_used = ALIGN128(u4_mv_buf_mgr_mem_used);
+ ps_col_mv = ps_dec->ps_col_mv_base;
- for(i = 0 ; i < ps_dec->u1_max_dec_frame_buffering + 1; i++)
+ u4_num_bufs = ps_dec->ps_cur_sps->u1_num_ref_frames + 1;
+
+ u4_num_bufs = MIN(u4_num_bufs, ps_dec->u1_pic_bufs);
+ u4_num_bufs = MAX(u4_num_bufs, 2);
+ pu1_buf = ps_dec->pu1_mv_bank_buf_base;
+ for(i = 0 ; i < u4_num_bufs ; i++)
{
- pu1_col_zero_flag_buf = pu1_mv_buf_mgr_base + u4_mv_buf_mgr_mem_used;
- u4_mv_buf_mgr_mem_used += col_flag_buffer_size;
+ pu1_col_zero_flag_buf = pu1_buf;
+ pu1_buf += ALIGN64(col_flag_buffer_size);
- ps_mv = (mv_pred_t *)(pu1_mv_bank_base + u4_mv_bank_mem_used);
- u4_mv_bank_mem_used += mvpred_buffer_size;
+ ps_mv = (mv_pred_t *)pu1_buf;
+ pu1_buf += ALIGN64(mvpred_buffer_size);
- memset(ps_mv, 0, ((ui_width*OFFSET_MV_BANK_ROW) >> 4) * sizeof(mv_pred_t));
+ memset(ps_mv, 0, ((ui_width * OFFSET_MV_BANK_ROW) >> 4) * sizeof(mv_pred_t));
ps_mv += (ui_width*OFFSET_MV_BANK_ROW) >> 4;
ps_col_mv->pv_col_zero_flag = (void *)pu1_col_zero_flag_buf;
@@ -2553,19 +2297,9 @@
}
ps_col_mv++;
}
-
- if((u4_mv_buf_mgr_mem_used > ps_dec->ps_mem_tab[MEM_REC_MV_BUF_MGR].u4_mem_size) ||
- (u4_mv_bank_mem_used > ps_dec->ps_mem_tab[MEM_REC_MVBANK].u4_mem_size))
- {
- ps_dec->i4_error_code = ERROR_BUF_MGR;
- return ERROR_BUF_MGR;
- }
-
return OK;
-
}
-
void ih264d_unpack_coeff4x4_dc_4x4blk(tu_sblk4x4_coeff_data_t *ps_tu_4x4,
WORD16 *pi2_out_coeff_data,
UWORD8 *pu1_inv_scan)
diff --git a/decoder/ih264d_utils.h b/decoder/ih264d_utils.h
index a1a64d5..ddef744 100644
--- a/decoder/ih264d_utils.h
+++ b/decoder/ih264d_utils.h
@@ -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,12 +92,11 @@
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);
+WORD16 ih264d_free_dynamic_bufs(dec_struct_t * ps_dec);
#endif /* _IH264D_UTILS_H_ */
diff --git a/decoder/ih264d_vui.c b/decoder/ih264d_vui.c
index 87276bd..97b40c2 100644
--- a/decoder/ih264d_vui.c
+++ b/decoder/ih264d_vui.c
@@ -205,8 +205,9 @@
}
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 @@
{
/* 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;
diff --git a/decoder/ih264d_vui.h b/decoder/ih264d_vui.h
index e380a5b..b882f72 100644
--- a/decoder/ih264d_vui.h
+++ b/decoder/ih264d_vui.h
@@ -81,6 +81,7 @@
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;
diff --git a/decoder/iv.h b/decoder/iv.h
index 3a2ebf5..dbccae5 100644
--- a/decoder/iv.h
+++ b/decoder/iv.h
@@ -65,20 +65,6 @@
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 @@
/* 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 @@
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 @@
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 */
diff --git a/decoder/ivd.h b/decoder/ivd.h
index b30b0b1..8d304bc 100644
--- a/decoder/ivd.h
+++ b/decoder/ivd.h
@@ -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 @@
/* 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 @@
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 @@
/* 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 {
- /* 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
{
- /* 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
{
- /* 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
{
- /* 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
{
- /* 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
{
- /* 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{
- /* 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{
- /* 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 {
- /* 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{
- /* 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{
- /* 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{
- /* 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;
diff --git a/encoder/ih264e_api.c b/encoder/ih264e_api.c
index c46134d..69085ab 100644
--- a/encoder/ih264e_api.c
+++ b/encoder/ih264e_api.c
@@ -3473,7 +3473,7 @@
ps_mem_rec = &ps_mem_rec_base[MEM_REC_MB_INFO_NMB];
{
ps_mem_rec->u4_mem_size = MAX_PROCESS_CTXT * max_mb_cols *
- (sizeof(mb_info_nmb_t) + MB_SIZE * MB_SIZE
+ (sizeof(mb_info_nmb_t) + MB_SIZE * MB_SIZE
* sizeof(UWORD8));
}
DEBUG("\nMemory record Id %d = %d \n", MEM_REC_MB_INFO_NMB, ps_mem_rec->u4_mem_size);
diff --git a/encoder/ih264e_encode_header.c b/encoder/ih264e_encode_header.c
index cc81e1b..ac025d6 100644
--- a/encoder/ih264e_encode_header.c
+++ b/encoder/ih264e_encode_header.c
@@ -136,6 +136,82 @@
return(return_status);
}
+/**
+******************************************************************************
+*
+* @brief Generates VUI (Video usability information)
+*
+* @par Description
+* This function generates VUI header as per the spec
+*
+* @param[in] ps_bitstrm
+* pointer to bitstream context (handle)
+*
+* @param[in] ps_vui
+* pointer to structure containing VUI data
+
+*
+* @return success or failure error code
+*
+******************************************************************************
+*/
+WORD32 ih264e_generate_vui(bitstrm_t *ps_bitstrm, vui_t *ps_vui)
+{
+ WORD32 return_status = IH264E_SUCCESS;
+
+ /* aspect_ratio_info_present_flag */
+ PUT_BITS(ps_bitstrm, ps_vui->u1_aspect_ratio_info_present_flag, 1, return_status, "aspect_ratio_info_present_flag");
+
+ /* overscan_info_present_flag */
+ PUT_BITS(ps_bitstrm, ps_vui->u1_overscan_info_present_flag, 1, return_status, "overscan_info_present_flag");
+
+ /* video_signal_type_present_flag */
+ PUT_BITS(ps_bitstrm, ps_vui->u1_video_signal_type_present_flag, 1, return_status, "video_signal_type_present_flag");
+
+ /* chroma_loc_info_present_flag */
+ PUT_BITS(ps_bitstrm, ps_vui->u1_chroma_loc_info_present_flag, 1, return_status, "chroma_loc_info_present_flag");
+
+ /* timing_info_present_flag */
+ PUT_BITS(ps_bitstrm, ps_vui->u1_vui_timing_info_present_flag, 1, return_status, "timing_info_present_flag");
+
+ /* nal_hrd_parameters_present_flag */
+ PUT_BITS(ps_bitstrm, ps_vui->u1_nal_hrd_parameters_present_flag, 1, return_status, "nal_hrd_parameters_present_flag");
+
+ /* vcl_hrd_parameters_present_flag */
+ PUT_BITS(ps_bitstrm, ps_vui->u1_vcl_hrd_parameters_present_flag, 1, return_status, "vcl_hrd_parameters_present_flag");
+
+ /* pic_struct_present_flag */
+ PUT_BITS(ps_bitstrm, ps_vui->u1_pic_struct_present_flag, 1, return_status, "pic_struct_present_flag");
+
+ /* bitstream_restriction_flag */
+ PUT_BITS(ps_bitstrm, ps_vui->u1_bitstream_restriction_flag, 1, return_status, "bitstream_restriction_flag");
+
+ if(ps_vui->u1_bitstream_restriction_flag == 1)
+ {
+ /* motion_vectors_over_pic_boundaries_flag */
+ PUT_BITS(ps_bitstrm, ps_vui->u1_motion_vectors_over_pic_boundaries_flag, 1, return_status, "motion_vectors_over_pic_boundaries_flag");
+
+ /* max_bytes_per_pic_denom */
+ PUT_BITS_UEV(ps_bitstrm,ps_vui->u1_max_bytes_per_pic_denom,return_status,"max_bytes_per_pic_denom");
+
+ /* max_bits_per_mb_denom */
+ PUT_BITS_UEV(ps_bitstrm,ps_vui->u1_max_bits_per_mb_denom,return_status,"max_bits_per_mb_denom");
+
+ /* log2_max_mv_length_horizontal */
+ PUT_BITS_UEV(ps_bitstrm,ps_vui->u1_log2_max_mv_length_horizontal,return_status,"log2_max_mv_length_horizontal");
+
+ /* log2_max_mv_length_vertical */
+ PUT_BITS_UEV(ps_bitstrm,ps_vui->u1_log2_max_mv_length_vertical,return_status,"log2_max_mv_length_vertical");
+
+ /* max_num_reorder_frames */
+ PUT_BITS_UEV(ps_bitstrm,ps_vui->u1_num_reorder_frames,return_status,"max_num_reorder_frames");
+
+ /* max_dec_frame_buffering */
+ PUT_BITS_UEV(ps_bitstrm,ps_vui->u1_max_dec_frame_buffering,return_status,"max_dec_frame_buffering");
+ }
+
+ return return_status;
+}
/**
******************************************************************************
@@ -151,11 +227,14 @@
* @param[in] ps_sps
* pointer to structure containing SPS data
*
+* @param[in] ps_vui
+* pointer to structure containing VUI data
+*
* @return success or failure error code
*
******************************************************************************
*/
-WORD32 ih264e_generate_sps(bitstrm_t *ps_bitstrm, sps_t *ps_sps)
+WORD32 ih264e_generate_sps(bitstrm_t *ps_bitstrm, sps_t *ps_sps, vui_t *ps_vui)
{
WORD32 return_status = IH264E_SUCCESS;
WORD32 i;
@@ -297,6 +376,7 @@
if (ps_sps->i1_vui_parameters_present_flag)
{
/* Add vui parameters to the bitstream */;
+ return_status |= ih264e_generate_vui(ps_bitstrm, ps_vui);
}
/* rbsp trailing bits */
@@ -637,6 +717,58 @@
return return_status;
}
+/**
+******************************************************************************
+*
+* @brief Populates VUI structure
+*
+* @par Description
+* Populates VUI structure for its use in header generation
+*
+* @param[in] ps_codec
+* pointer to encoder context
+*
+* @param[out] ps_vui
+* pointer to vui params that needs to be populated
+*
+* @return success or failure error code
+*
+******************************************************************************
+*/
+IH264E_ERROR_T ih264e_populate_vui(codec_t *ps_codec, vui_t *ps_vui)
+{
+ sps_t *ps_sps;
+
+ ps_sps = ps_codec->ps_sps_base + ps_codec->i4_sps_id;
+ ps_vui->u1_aspect_ratio_info_present_flag = 0;
+ ps_vui->u1_overscan_info_present_flag = 0;
+ ps_vui->u1_video_signal_type_present_flag = 0;
+ ps_vui->u1_chroma_loc_info_present_flag = 0;
+ ps_vui->u1_vui_timing_info_present_flag = 0;
+ ps_vui->u1_nal_hrd_parameters_present_flag = 0;
+ ps_vui->u1_vcl_hrd_parameters_present_flag = 0;
+ ps_vui->u1_pic_struct_present_flag = 0;
+ ps_vui->u1_bitstream_restriction_flag = 1;
+ ps_vui->u1_motion_vectors_over_pic_boundaries_flag = 1;
+ ps_vui->u1_max_bytes_per_pic_denom = 0;
+ ps_vui->u1_max_bits_per_mb_denom = 0;
+ ps_vui->u1_log2_max_mv_length_horizontal = 16;
+ ps_vui->u1_log2_max_mv_length_vertical = 16;
+
+ if(ps_codec->s_cfg.u4_num_bframes == 0)
+ {
+ ps_vui->u1_num_reorder_frames = 0;
+ }
+ else
+ {
+ ps_vui->u1_num_reorder_frames = 1;
+ }
+
+ ps_vui->u1_max_dec_frame_buffering = ps_sps->u1_max_num_ref_frames;
+
+ return 0;
+}
+
/**
@@ -824,11 +956,12 @@
}
/* vui params */
- ps_sps->i1_vui_parameters_present_flag = 0;
+ ps_sps->i1_vui_parameters_present_flag = 1;
if (ps_sps->i1_vui_parameters_present_flag)
{
/* populate vui params */
+ ih264e_populate_vui(ps_codec,&(ps_codec->s_vui));
}
return i4_err_code;
diff --git a/encoder/ih264e_encode_header.h b/encoder/ih264e_encode_header.h
index acae5b6..c379d5e 100644
--- a/encoder/ih264e_encode_header.h
+++ b/encoder/ih264e_encode_header.h
@@ -101,7 +101,8 @@
WORD32 ih264e_generate_sps
(
bitstrm_t *ps_bitstrm,
- sps_t *ps_sps
+ sps_t *ps_sps,
+ vui_t *ps_vui
);
/**
diff --git a/encoder/ih264e_process.c b/encoder/ih264e_process.c
index 850cefc..c21931d 100644
--- a/encoder/ih264e_process.c
+++ b/encoder/ih264e_process.c
@@ -181,7 +181,7 @@
ps_entropy->i4_error_code = IH264E_SUCCESS;
/* generate sps */
- ps_entropy->i4_error_code |= ih264e_generate_sps(ps_bitstrm, ps_sps);
+ ps_entropy->i4_error_code |= ih264e_generate_sps(ps_bitstrm, ps_sps, &ps_codec->s_vui);
/* generate pps */
ps_entropy->i4_error_code |= ih264e_generate_pps(ps_bitstrm, ps_pps, ps_sps);
@@ -371,7 +371,7 @@
if (1 == ps_entropy->i4_gen_header)
{
/* generate sps */
- ps_entropy->i4_error_code |= ih264e_generate_sps(ps_bitstrm, ps_sps);
+ ps_entropy->i4_error_code |= ih264e_generate_sps(ps_bitstrm, ps_sps, &ps_codec->s_vui);
/* generate pps */
ps_entropy->i4_error_code |= ih264e_generate_pps(ps_bitstrm, ps_pps, ps_sps);
diff --git a/encoder/ih264e_structs.h b/encoder/ih264e_structs.h
index fdf0e0a..074731e 100644
--- a/encoder/ih264e_structs.h
+++ b/encoder/ih264e_structs.h
@@ -2618,6 +2618,11 @@
rate_control_ctxt_t s_rate_control;
/**
+ * VUI structure
+ */
+ vui_t s_vui;
+
+ /**
* input buffer queue
*/
inp_buf_t as_inp_list[MAX_NUM_BFRAMES];
diff --git a/encoder/ih264e_time_stamp.c b/encoder/ih264e_time_stamp.c
index cd829b5..85b75a3 100644
--- a/encoder/ih264e_time_stamp.c
+++ b/encoder/ih264e_time_stamp.c
@@ -84,6 +84,7 @@
#include "ih264e_structs.h"
#include "ih264e_rc_mem_interface.h"
#include "ih264e_time_stamp.h"
+#include "irc_common.h"
#include "irc_rate_control_api.h"
@@ -278,8 +279,15 @@
* frame times increase */
WORD32 i4_gcd = gcd(u4_src_frm_rate, u4_tgt_frm_rate);
- ps_frame_time->common_time_base = (u4_src_frm_rate * u4_tgt_frm_rate)
- / i4_gcd;
+ /* Avoiding overflow by doing calculations in float */
+ number_t s_src_frm_rate, s_tgt_frm_rate, s_gcd, s_common_time_base, s_numerator;
+
+ SET_VAR_Q(s_src_frm_rate, u4_src_frm_rate, 0);
+ SET_VAR_Q(s_tgt_frm_rate, u4_tgt_frm_rate, 0);
+ SET_VAR_Q(s_gcd, i4_gcd, 0);
+ mult32_var_q(s_src_frm_rate, s_tgt_frm_rate, &s_numerator);
+ div32_var_q(s_numerator, s_gcd, &s_common_time_base);
+ number_t_to_word32(s_common_time_base, &(ps_frame_time->common_time_base));
/* The source and target increment per vop is initialized */
ps_frame_time->u4_src_frm_time_incr = ps_frame_time->common_time_base
diff --git a/test/decoder/main.c b/test/decoder/main.c
index 35454a4..89a54c5 100644
--- a/test/decoder/main.c
+++ b/test/decoder/main.c
@@ -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 @@
UWORD32 display;
UWORD32 full_screen;
UWORD32 fps;
- UWORD32 max_wd;
- UWORD32 max_ht;
- UWORD32 max_level;
UWORD32 u4_strd;
@@ -268,9 +267,6 @@
FULLSCREEN,
FPS,
TRACE,
- MAX_WD,
- MAX_HT,
- MAX_LEVEL,
CONFIG,
DEGRADE_TYPE,
@@ -332,13 +328,6 @@
"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 @@
};
#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 @@
/* */
/*****************************************************************************/
-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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
- /*****************************************************************************/
- /* 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 @@
/* 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 @@
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 @@
}
}
-
}
@@ -3158,39 +3093,21 @@
}
{
- 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 */