blob: 1f69e3ed4bca42e76bd8b5b7929d98f103b7553a [file] [log] [blame]
/******************************************************************************
*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*****************************************************************************
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
*/
/**
*******************************************************************************
* @file
* ih264e_api.c
*
* @brief
* Contains api function definitions for H264 encoder
*
* @author
* ittiam
*
* @par List of Functions:
* - api_check_struct_sanity()
* - ih264e_codec_update_config()
* - ih264e_set_default_params()
* - ih264e_init()
* - ih264e_get_num_rec()
* - ih264e_fill_num_mem_rec()
* - ih264e_init_mem_rec()
* - ih264e_retrieve_memrec()
* - ih264e_set_flush_mode()
* - ih264e_get_buf_info()
* - ih264e_set_dimensions()
* - ih264e_set_frame_rate()
* - ih264e_set_bit_rate()
* - ih264e_set_frame_type()
* - ih264e_set_qp()
* - ih264e_set_enc_mode()
* - ih264e_set_vbv_params()
* - ih264_set_air_params()
* - ih264_set_me_params()
* - ih264_set_ipe_params()
* - ih264_set_gop_params()
* - ih264_set_profile_params()
* - ih264_set_deblock_params()
* - ih264e_set_num_cores()
* - ih264e_reset()
* - ih264e_ctl()
* - ih264e_api_function()
*
* @remarks
* None
*
*******************************************************************************
*/
/*****************************************************************************/
/* File Includes */
/*****************************************************************************/
/* System Include Files */
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
/* User Include Files */
#include "ih264e_config.h"
#include "ih264_typedefs.h"
#include "ih264_size_defs.h"
#include "iv2.h"
#include "ive2.h"
#include "ih264e.h"
#include "ithread.h"
#include "ih264_debug.h"
#include "ih264_defs.h"
#include "ih264_error.h"
#include "ih264_structs.h"
#include "ih264_trans_quant_itrans_iquant.h"
#include "ih264_inter_pred_filters.h"
#include "ih264_mem_fns.h"
#include "ih264_padding.h"
#include "ih264_intra_pred_filters.h"
#include "ih264_deblk_edge_filters.h"
#include "ih264_cabac_tables.h"
#include "ih264_macros.h"
#include "ih264e_defs.h"
#include "ih264e_globals.h"
#include "ih264_buf_mgr.h"
#include "irc_mem_req_and_acq.h"
#include "irc_cntrl_param.h"
#include "irc_frame_info_collector.h"
#include "irc_rate_control_api.h"
#include "ih264e_time_stamp.h"
#include "ih264e_modify_frm_rate.h"
#include "ih264e_rate_control.h"
#include "ih264e_error.h"
#include "ih264e_bitstream.h"
#include "ime_defs.h"
#include "ime_distortion_metrics.h"
#include "ime_structs.h"
#include "ih264e_cabac_structs.h"
#include "ih264e_structs.h"
#include "ih264e_utils.h"
#include "ih264e_core_coding.h"
#include "ih264_platform_macros.h"
#include "ih264e_platform_macros.h"
#include "ih264_list.h"
#include "ih264_dpb_mgr.h"
#include "ih264_cavlc_tables.h"
#include "ih264e_cavlc.h"
#include "ih264_common_tables.h"
#include "ih264e_master.h"
#include "ih264e_fmt_conv.h"
#include "ih264e_version.h"
/*****************************************************************************/
/* Function Declarations */
/*****************************************************************************/
WORD32 ih264e_get_rate_control_mem_tab(void *pv_rate_control,
iv_mem_rec_t *ps_mem,
ITT_FUNC_TYPE_E e_func_type);
/*****************************************************************************/
/* Function Definitions */
/*****************************************************************************/
/**
*******************************************************************************
*
* @brief
* Used to test validity of input dimensions
*
* @par Description:
* Dimensions of the input buffer passed to encode call are validated
*
* @param[in] ps_codec
* Codec context
*
* @param[in] ps_ip
* Pointer to input structure
*
* @param[out] ps_op
* Pointer to output structure
*
* @returns error status
*
* @remarks none
*
*******************************************************************************
*/
static IV_STATUS_T api_check_input_dimensions(codec_t *ps_codec,
ih264e_video_encode_ip_t *ps_ip,
ih264e_video_encode_op_t *ps_op)
{
UWORD32 u4_wd, u4_ht;
cfg_params_t *ps_curr_cfg = &ps_codec->s_cfg;
iv_raw_buf_t *ps_inp_buf = &ps_ip->s_ive_ip.s_inp_buf;
u4_wd = ps_inp_buf->au4_wd[0];
u4_ht = ps_inp_buf->au4_ht[0];
switch (ps_inp_buf->e_color_fmt)
{
case IV_YUV_420P:
if (((ps_inp_buf->au4_wd[0] / 2) != ps_inp_buf->au4_wd[1]) ||
((ps_inp_buf->au4_wd[0] / 2) != ps_inp_buf->au4_wd[2]) ||
(ps_inp_buf->au4_wd[1] != ps_inp_buf->au4_wd[2]))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_WIDTH_NOT_SUPPORTED;
return (IV_FAIL);
}
if (((ps_inp_buf->au4_ht[0] / 2) != ps_inp_buf->au4_ht[1]) ||
((ps_inp_buf->au4_ht[0] / 2) != ps_inp_buf->au4_ht[2]) ||
(ps_inp_buf->au4_ht[1] != ps_inp_buf->au4_ht[2]))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_HEIGHT_NOT_SUPPORTED;
return (IV_FAIL);
}
break;
case IV_YUV_420SP_UV:
case IV_YUV_420SP_VU:
if ((ps_inp_buf->au4_wd[0] / 2) != ps_inp_buf->au4_wd[1])
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_WIDTH_NOT_SUPPORTED;
return (IV_FAIL);
}
if ((ps_inp_buf->au4_ht[0] / 2) != ps_inp_buf->au4_ht[1])
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_HEIGHT_NOT_SUPPORTED;
return (IV_FAIL);
}
break;
case IV_YUV_422ILE:
u4_wd = ps_inp_buf->au4_wd[0] / 2;
break;
default:
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_INPUT_CHROMA_FORMAT_NOT_SUPPORTED;
return (IV_FAIL);
}
if (u4_wd != ps_curr_cfg->u4_disp_wd)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_WIDTH_NOT_SUPPORTED;
return (IV_FAIL);
}
if (u4_ht != ps_curr_cfg->u4_disp_ht)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_HEIGHT_NOT_SUPPORTED;
return (IV_FAIL);
}
return IV_SUCCESS;
}
/**
*******************************************************************************
*
* @brief
* Used to test arguments for corresponding API call
*
* @par Description:
* For each command the arguments are validated
*
* @param[in] ps_handle
* Codec handle at API level
*
* @param[in] pv_api_ip
* Pointer to input structure
*
* @param[out] pv_api_op
* Pointer to output structure
*
* @returns error status
*
* @remarks none
*
*******************************************************************************
*/
static IV_STATUS_T api_check_struct_sanity(iv_obj_t *ps_handle,
void *pv_api_ip,
void *pv_api_op)
{
/* api call */
WORD32 command = IV_CMD_NA;
/* input structure expected by the api call */
UWORD32 *pu4_api_ip = pv_api_ip;
/* output structure expected by the api call */
UWORD32 *pu4_api_op = pv_api_op;
/* temp var */
WORD32 i, j;
if (NULL == pv_api_op || NULL == pv_api_ip)
{
return (IV_FAIL);
}
/* get command */
command = pu4_api_ip[1];
/* set error code */
pu4_api_op[1] = 0;
/* error checks on handle */
switch (command)
{
case IV_CMD_GET_NUM_MEM_REC:
case IV_CMD_FILL_NUM_MEM_REC:
break;
case IV_CMD_INIT:
if (ps_handle == NULL)
{
*(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM;
*(pu4_api_op + 1) |= IVE_ERR_HANDLE_NULL;
return IV_FAIL;
}
if (ps_handle->u4_size != sizeof(iv_obj_t))
{
*(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM;
*(pu4_api_op + 1) |= IVE_ERR_HANDLE_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
break;
case IVE_CMD_QUEUE_INPUT:
case IVE_CMD_QUEUE_OUTPUT:
case IVE_CMD_DEQUEUE_OUTPUT:
case IVE_CMD_GET_RECON:
case IV_CMD_RETRIEVE_MEMREC:
case IVE_CMD_VIDEO_CTL:
case IVE_CMD_VIDEO_ENCODE:
if (ps_handle == NULL)
{
*(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM;
*(pu4_api_op + 1) |= IVE_ERR_HANDLE_NULL;
return IV_FAIL;
}
if (ps_handle->u4_size != sizeof(iv_obj_t))
{
*(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM;
*(pu4_api_op + 1) |= IVE_ERR_HANDLE_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_handle->pv_fxns != ih264e_api_function)
{
*(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM;
*(pu4_api_op + 1) |= IVE_ERR_API_FUNCTION_PTR_NULL;
return IV_FAIL;
}
if (ps_handle->pv_codec_handle == NULL)
{
*(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM;
*(pu4_api_op + 1) |= IVE_ERR_INVALID_CODEC_HANDLE;
return IV_FAIL;
}
break;
default:
*(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM;
*(pu4_api_op + 1) |= IVE_ERR_INVALID_API_CMD;
return IV_FAIL;
}
/* error checks on input output structures */
switch (command)
{
case IV_CMD_GET_NUM_MEM_REC:
{
ih264e_num_mem_rec_ip_t *ps_ip = pv_api_ip;
ih264e_num_mem_rec_op_t *ps_op = pv_api_op;
ps_op->s_ive_op.u4_error_code = 0;
if (ps_ip->s_ive_ip.u4_size != sizeof(ih264e_num_mem_rec_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_GET_MEM_REC_API_STRUCT_SIZE_INCORRECT;
return (IV_FAIL);
}
if (ps_op->s_ive_op.u4_size != sizeof(ih264e_num_mem_rec_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_GET_MEM_REC_API_STRUCT_SIZE_INCORRECT;
return (IV_FAIL);
}
break;
}
case IV_CMD_FILL_NUM_MEM_REC:
{
ih264e_fill_mem_rec_ip_t *ps_ip = pv_api_ip;
ih264e_fill_mem_rec_op_t *ps_op = pv_api_op;
iv_mem_rec_t *ps_mem_rec = NULL;
WORD32 max_wd = ALIGN16(ps_ip->s_ive_ip.u4_max_wd);
WORD32 max_ht = ALIGN16(ps_ip->s_ive_ip.u4_max_ht);
ps_op->s_ive_op.u4_error_code = 0;
if (ps_ip->s_ive_ip.u4_size != sizeof(ih264e_fill_mem_rec_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_FILL_MEM_REC_API_STRUCT_SIZE_INCORRECT;
return (IV_FAIL);
}
if (ps_op->s_ive_op.u4_size != sizeof(ih264e_fill_mem_rec_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_FILL_MEM_REC_API_STRUCT_SIZE_INCORRECT;
return (IV_FAIL);
}
if (max_wd < MIN_WD || max_wd > MAX_WD)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_WIDTH_NOT_SUPPORTED;
return (IV_FAIL);
}
if (max_ht < MIN_HT || max_ht > MAX_HT)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_HEIGHT_NOT_SUPPORTED;
return (IV_FAIL);
}
/* verify number of mem rec ptr */
if (NULL == ps_ip->s_ive_ip.ps_mem_rec)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_FILL_NUM_MEM_RECS_POINTER_NULL;
return (IV_FAIL);
}
/* verify number of mem records */
if (ps_ip->s_ive_ip.u4_num_mem_rec != MEM_REC_CNT)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_NUM_MEM_REC_NOT_SUFFICIENT;
return IV_FAIL;
}
/* check mem records sizes are correct */
ps_mem_rec = ps_ip->s_ive_ip.ps_mem_rec;
for (i = 0; i < MEM_REC_CNT; i++)
{
if (ps_mem_rec[i].u4_size != sizeof(iv_mem_rec_t))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_MEM_REC_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
}
break;
}
case IV_CMD_INIT:
{
ih264e_init_ip_t *ps_ip = pv_api_ip;
ih264e_init_op_t *ps_op = pv_api_op;
iv_mem_rec_t *ps_mem_rec = NULL;
WORD32 max_wd = ALIGN16(ps_ip->s_ive_ip.u4_max_wd);
WORD32 max_ht = ALIGN16(ps_ip->s_ive_ip.u4_max_ht);
ps_op->s_ive_op.u4_error_code = 0;
if (ps_ip->s_ive_ip.u4_size != sizeof(ih264e_init_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_INIT_API_STRUCT_SIZE_INCORRECT;
return (IV_FAIL);
}
if (ps_op->s_ive_op.u4_size != sizeof(ih264e_init_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_INIT_API_STRUCT_SIZE_INCORRECT;
return (IV_FAIL);
}
if (max_wd < MIN_WD || max_wd > MAX_WD)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_WIDTH_NOT_SUPPORTED;
return (IV_FAIL);
}
if (max_ht < MIN_HT || max_ht > MAX_HT)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_HEIGHT_NOT_SUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.u4_max_ref_cnt > MAX_REF_PIC_CNT ||
ps_ip->s_ive_ip.u4_max_ref_cnt < MIN_REF_PIC_CNT)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_NUM_REF_UNSUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.u4_max_reorder_cnt != 0)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_NUM_REORDER_UNSUPPORTED;
return (IV_FAIL);
}
if ((ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_10)
&& (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_1B)
&& (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_11)
&& (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_12)
&& (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_13)
&& (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_20)
&& (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_21)
&& (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_22)
&& (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_30)
&& (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_31)
&& (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_32)
&& (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_40)
&& (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_41)
&& (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_42)
&& (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_50)
&& (ps_ip->s_ive_ip.u4_max_level != IH264_LEVEL_51))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_CODEC_LEVEL_NOT_SUPPORTED;
return (IV_FAIL);
}
if ((ps_ip->s_ive_ip.e_inp_color_fmt != IV_YUV_420P)
&& (ps_ip->s_ive_ip.e_inp_color_fmt != IV_YUV_422ILE)
&& (ps_ip->s_ive_ip.e_inp_color_fmt != IV_YUV_420SP_UV)
&& (ps_ip->s_ive_ip.e_inp_color_fmt != IV_YUV_420SP_VU))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INPUT_CHROMA_FORMAT_NOT_SUPPORTED;
return (IV_FAIL);
}
if ((ps_ip->s_ive_ip.e_recon_color_fmt != IV_YUV_420P)
&& (ps_ip->s_ive_ip.e_recon_color_fmt != IV_YUV_420SP_UV)
&& (ps_ip->s_ive_ip.e_recon_color_fmt != IV_YUV_420SP_VU))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_RECON_CHROMA_FORMAT_NOT_SUPPORTED;
return (IV_FAIL);
}
if ((ps_ip->s_ive_ip.e_rc_mode != IVE_RC_NONE)
&& (ps_ip->s_ive_ip.e_rc_mode != IVE_RC_STORAGE)
&& (ps_ip->s_ive_ip.e_rc_mode != IVE_RC_CBR_NON_LOW_DELAY))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_RATE_CONTROL_MODE_NOT_SUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.u4_max_framerate > DEFAULT_MAX_FRAMERATE)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_FRAME_RATE_NOT_SUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.u4_max_bitrate > DEFAULT_MAX_BITRATE)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_BITRATE_NOT_SUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.u4_num_bframes > MAX_NUM_BFRAMES)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_BFRAMES_NOT_SUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.u4_num_bframes
&& (ps_ip->s_ive_ip.u4_max_ref_cnt < 2))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_BFRAMES_NOT_SUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.e_content_type != IV_PROGRESSIVE)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_CONTENT_TYPE_NOT_SUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.u4_max_srch_rng_x > DEFAULT_MAX_SRCH_RANGE_X)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_HORIZONTAL_SEARCH_RANGE_NOT_SUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.u4_max_srch_rng_y > DEFAULT_MAX_SRCH_RANGE_Y)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_VERTICAL_SEARCH_RANGE_NOT_SUPPORTED;
return (IV_FAIL);
}
if ((ps_ip->s_ive_ip.e_slice_mode != IVE_SLICE_MODE_NONE)
&& (ps_ip->s_ive_ip.e_slice_mode != IVE_SLICE_MODE_BLOCKS))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_SLICE_TYPE_INPUT_INVALID;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.e_slice_mode == IVE_SLICE_MODE_BLOCKS)
{
if (ps_ip->s_ive_ip.u4_slice_param == 0
|| ps_ip->s_ive_ip.u4_slice_param > ((UWORD32)max_ht >> 4))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_SLICE_PARAM_INPUT_INVALID;
return (IV_FAIL);
}
}
if (NULL == ps_ip->s_ive_ip.ps_mem_rec)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_FILL_NUM_MEM_RECS_POINTER_NULL;
return (IV_FAIL);
}
/* verify number of mem records */
if (ps_ip->s_ive_ip.u4_num_mem_rec != MEM_REC_CNT)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_NUM_MEM_REC_NOT_SUFFICIENT;
return (IV_FAIL);
}
ps_mem_rec = ps_ip->s_ive_ip.ps_mem_rec;
/* check memrecords sizes are correct */
for (i = 0; i <((WORD32)ps_ip->s_ive_ip.u4_num_mem_rec); i++)
{
if (ps_mem_rec[i].u4_size != sizeof(iv_mem_rec_t))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_MEM_REC_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
/* check memrecords pointers are not NULL */
if (ps_mem_rec[i].pv_base == NULL)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_MEM_REC_BASE_POINTER_NULL;
return IV_FAIL;
}
}
/* verify memtabs for overlapping regions */
{
void *start[MEM_REC_CNT];
void *end[MEM_REC_CNT];
start[0] = (ps_mem_rec[0].pv_base);
end[0] = ((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 overlap */
start[i] = (ps_mem_rec[i].pv_base);
end[i] = ((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_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_MEM_REC_OVERLAP_ERR;
return IV_FAIL;
}
if ((end[i] >= start[j]) && (end[i] <= end[j]))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_MEM_REC_OVERLAP_ERR;
return IV_FAIL;
}
if ((start[i] < start[j]) && (end[i] > end[j]))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_MEM_REC_OVERLAP_ERR;
return IV_FAIL;
}
}
}
}
/* re-validate mem records with init config */
{
/* mem records */
iv_mem_rec_t s_mem_rec_ittiam_api[MEM_REC_CNT];
/* api interface structs */
ih264e_fill_mem_rec_ip_t s_ip;
ih264e_fill_mem_rec_op_t s_op;
/* error status */
IV_STATUS_T e_status;
/* temp var */
WORD32 i;
s_ip.s_ive_ip.u4_size = sizeof(ih264e_fill_mem_rec_ip_t);
s_op.s_ive_op.u4_size = sizeof(ih264e_fill_mem_rec_op_t);
s_ip.s_ive_ip.e_cmd = IV_CMD_FILL_NUM_MEM_REC;
s_ip.s_ive_ip.ps_mem_rec = s_mem_rec_ittiam_api;
s_ip.s_ive_ip.u4_max_wd = max_wd;
s_ip.s_ive_ip.u4_max_ht = max_ht;
s_ip.s_ive_ip.u4_num_mem_rec = ps_ip->s_ive_ip.u4_num_mem_rec;
s_ip.s_ive_ip.u4_max_level = ps_ip->s_ive_ip.u4_max_level;
s_ip.s_ive_ip.u4_max_ref_cnt = ps_ip->s_ive_ip.u4_max_ref_cnt;
s_ip.s_ive_ip.u4_max_reorder_cnt =
ps_ip->s_ive_ip.u4_max_reorder_cnt;
s_ip.s_ive_ip.e_color_format = ps_ip->s_ive_ip.e_inp_color_fmt;
s_ip.s_ive_ip.u4_max_srch_rng_x =
ps_ip->s_ive_ip.u4_max_srch_rng_x;
s_ip.s_ive_ip.u4_max_srch_rng_y =
ps_ip->s_ive_ip.u4_max_srch_rng_y;
for (i = 0; i < MEM_REC_CNT; i++)
{
s_mem_rec_ittiam_api[i].u4_size = sizeof(iv_mem_rec_t);
}
/* fill mem records */
e_status = ih264e_api_function(NULL, (void *) &s_ip,
(void *) &s_op);
if (IV_FAIL == e_status)
{
ps_op->s_ive_op.u4_error_code = s_op.s_ive_op.u4_error_code;
return (IV_FAIL);
}
/* verify mem records */
for (i = 0; i < MEM_REC_CNT; i++)
{
if (ps_mem_rec[i].u4_mem_size
< s_mem_rec_ittiam_api[i].u4_mem_size)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_MEM_REC_INSUFFICIENT_SIZE;
return IV_FAIL;
}
if (ps_mem_rec[i].u4_mem_alignment
!= s_mem_rec_ittiam_api[i].u4_mem_alignment)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_MEM_REC_ALIGNMENT_ERR;
return IV_FAIL;
}
if (ps_mem_rec[i].e_mem_type
!= s_mem_rec_ittiam_api[i].e_mem_type)
{
UWORD32 check = IV_SUCCESS;
UWORD32 diff = s_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)
&& (s_mem_rec_ittiam_api[i].e_mem_type
>= IV_INTERNAL_NONCACHEABLE_PERSISTENT_MEM))
{
check = IV_FAIL;
}
if (3 != (s_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_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_MEM_REC_INCORRECT_TYPE;
return IV_FAIL;
}
}
}
}
break;
}
case IVE_CMD_QUEUE_INPUT:
case IVE_CMD_QUEUE_OUTPUT:
case IVE_CMD_DEQUEUE_OUTPUT:
case IVE_CMD_GET_RECON:
break;
case IV_CMD_RETRIEVE_MEMREC:
{
ih264e_retrieve_mem_rec_ip_t *ps_ip = pv_api_ip;
ih264e_retrieve_mem_rec_op_t *ps_op = pv_api_op;
iv_mem_rec_t *ps_mem_rec = NULL;
ps_op->s_ive_op.u4_error_code = 0;
if (ps_ip->s_ive_ip.u4_size != sizeof(ih264e_retrieve_mem_rec_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_RETRIEVE_MEM_REC_API_STRUCT_SIZE_INCORRECT;
return (IV_FAIL);
}
if (ps_op->s_ive_op.u4_size != sizeof(ih264e_retrieve_mem_rec_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_RETRIEVE_MEM_REC_API_STRUCT_SIZE_INCORRECT;
return (IV_FAIL);
}
if (NULL == ps_ip->s_ive_ip.ps_mem_rec)
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_FILL_NUM_MEM_RECS_POINTER_NULL;
return (IV_FAIL);
}
ps_mem_rec = ps_ip->s_ive_ip.ps_mem_rec;
/* 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_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_MEM_REC_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
}
break;
}
case IVE_CMD_VIDEO_ENCODE:
{
codec_t *ps_codec = (codec_t *) (ps_handle->pv_codec_handle);
ih264e_video_encode_ip_t *ps_ip = pv_api_ip;
ih264e_video_encode_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size != sizeof(ih264e_video_encode_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_ENCODE_API_STRUCT_SIZE_INCORRECT;
return (IV_FAIL);
}
if (ps_op->s_ive_op.u4_size != sizeof(ih264e_video_encode_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_ENCODE_API_STRUCT_SIZE_INCORRECT;
return (IV_FAIL);
}
if (NULL != ps_ip->s_ive_ip.s_inp_buf.apv_bufs[0] &&
ps_codec->i4_header_mode != 1 &&
IV_SUCCESS != api_check_input_dimensions(ps_codec, ps_ip, ps_op))
{
ps_op->s_ive_op.u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IVE_ERR_OP_ENCODE_API_STRUCT_SIZE_INCORRECT;
return (IV_FAIL);
}
break;
}
case IVE_CMD_VIDEO_CTL:
{
/* ptr to input structure */
WORD32 *pu4_ptr_cmd = pv_api_ip;
/* sub command */
WORD32 sub_command = pu4_ptr_cmd[2];
switch (sub_command)
{
case IVE_CMD_CTL_SETDEFAULT:
{
ih264e_ctl_setdefault_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_setdefault_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_setdefault_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_SETDEF_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_setdefault_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_SETDEF_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
break;
}
case IVE_CMD_CTL_GETBUFINFO:
{
codec_t *ps_codec = (codec_t *) (ps_handle->pv_codec_handle);
ih264e_ctl_getbufinfo_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_getbufinfo_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_getbufinfo_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_GETBUFINFO_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_getbufinfo_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_GETBUFINFO_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_ip->s_ive_ip.u4_max_wd < MIN_WD)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_WIDTH_NOT_SUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.u4_max_wd > ps_codec->s_cfg.u4_max_wd)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_WIDTH_NOT_SUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.u4_max_ht < MIN_HT)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_HEIGHT_NOT_SUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.u4_max_ht > ps_codec->s_cfg.u4_max_ht)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_HEIGHT_NOT_SUPPORTED;
return (IV_FAIL);
}
if ((ps_ip->s_ive_ip.e_inp_color_fmt != IV_YUV_420P)
&& (ps_ip->s_ive_ip.e_inp_color_fmt != IV_YUV_422ILE)
&& (ps_ip->s_ive_ip.e_inp_color_fmt != IV_YUV_420SP_UV)
&& (ps_ip->s_ive_ip.e_inp_color_fmt != IV_YUV_420SP_VU))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INPUT_CHROMA_FORMAT_NOT_SUPPORTED;
return (IV_FAIL);
}
break;
}
case IVE_CMD_CTL_GETVERSION:
{
ih264e_ctl_getversioninfo_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_getversioninfo_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_getversioninfo_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_GETVERSION_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_getversioninfo_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_GETVERSION_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_ip->s_ive_ip.pu1_version == NULL)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_CTL_GET_VERSION_BUFFER_IS_NULL;
return IV_FAIL;
}
break;
}
case IVE_CMD_CTL_FLUSH:
{
ih264e_ctl_flush_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_flush_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_flush_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_FLUSH_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_flush_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_FLUSH_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
break;
}
case IVE_CMD_CTL_RESET:
{
ih264e_ctl_reset_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_reset_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_reset_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_RESET_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_reset_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_RESET_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
break;
}
case IVE_CMD_CTL_SET_NUM_CORES:
{
ih264e_ctl_set_num_cores_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_num_cores_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_set_num_cores_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_SETCORES_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_set_num_cores_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_SETCORES_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.u4_num_cores < 1)
|| (ps_ip->s_ive_ip.u4_num_cores > MAX_NUM_CORES))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_NUM_CORES;
return IV_FAIL;
}
break;
}
case IVE_CMD_CTL_SET_DIMENSIONS:
{
codec_t *ps_codec = (codec_t *) (ps_handle->pv_codec_handle);
ih264e_ctl_set_dimensions_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_dimensions_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_set_dimensions_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_SETDIM_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_set_dimensions_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_SETDIM_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_ip->s_ive_ip.u4_wd < MIN_WD)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_WIDTH_NOT_SUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.u4_wd > ps_codec->s_cfg.u4_max_wd)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_WIDTH_NOT_SUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.u4_ht < MIN_HT)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_HEIGHT_NOT_SUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.u4_ht > ps_codec->s_cfg.u4_max_ht)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_HEIGHT_NOT_SUPPORTED;
return (IV_FAIL);
}
if(ps_ip->s_ive_ip.u4_wd & 1)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_WIDTH_NOT_SUPPORTED;
return (IV_FAIL);
}
if(ps_ip->s_ive_ip.u4_ht & 1)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_HEIGHT_NOT_SUPPORTED;
return (IV_FAIL);
}
break;
}
case IVE_CMD_CTL_SET_FRAMERATE:
{
ih264e_ctl_set_frame_rate_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_frame_rate_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_set_frame_rate_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_SETFRAMERATE_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_set_frame_rate_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_SETFRAMERATE_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (((ps_ip->s_ive_ip.u4_src_frame_rate * 1000) > DEFAULT_MAX_FRAMERATE)
|| ((ps_ip->s_ive_ip.u4_tgt_frame_rate * 1000) > DEFAULT_MAX_FRAMERATE))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_FRAME_RATE_NOT_SUPPORTED;
return (IV_FAIL);
}
if ((ps_ip->s_ive_ip.u4_src_frame_rate == 0)
|| (ps_ip->s_ive_ip.u4_tgt_frame_rate == 0))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_FRAME_RATE_NOT_SUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.u4_tgt_frame_rate
> ps_ip->s_ive_ip.u4_src_frame_rate)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_TGT_FRAME_RATE_EXCEEDS_SRC_FRAME_RATE;
return (IV_FAIL);
}
break;
}
case IVE_CMD_CTL_SET_BITRATE:
{
ih264e_ctl_set_bitrate_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_bitrate_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_set_bitrate_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_SETBITRATE_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_set_bitrate_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_SETBITRATE_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.u4_target_bitrate > DEFAULT_MAX_BITRATE)
|| (ps_ip->s_ive_ip.u4_target_bitrate == 0))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_BITRATE_NOT_SUPPORTED;
return (IV_FAIL);
}
break;
}
case IVE_CMD_CTL_SET_FRAMETYPE:
{
ih264e_ctl_set_frame_type_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_frame_type_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_set_frame_type_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_SETFRAMETYPE_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_set_frame_type_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_SETFRAMETYPE_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.e_frame_type != IV_NA_FRAME)
&& (ps_ip->s_ive_ip.e_frame_type != IV_I_FRAME)
&& (ps_ip->s_ive_ip.e_frame_type != IV_P_FRAME)
&& (ps_ip->s_ive_ip.e_frame_type != IV_IDR_FRAME))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_FORCE_FRAME_INPUT;
return IV_FAIL;
}
break;
}
case IVE_CMD_CTL_SET_ME_PARAMS:
{
codec_t *ps_codec = (codec_t *) (ps_handle->pv_codec_handle);
ih264e_ctl_set_me_params_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_me_params_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_set_me_params_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_SETMEPARAMS_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_set_me_params_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_SETMEPARAMS_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.u4_me_speed_preset != FULL_SRCH)
&& (ps_ip->s_ive_ip.u4_me_speed_preset != DMND_SRCH)
&& (ps_ip->s_ive_ip.u4_me_speed_preset != HEX_SRCH))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_ME_SPEED_PRESET;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.u4_enable_hpel != 0)
&& (ps_ip->s_ive_ip.u4_enable_hpel != 1))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_HALFPEL_OPTION;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.u4_enable_qpel != 0)
&& (ps_ip->s_ive_ip.u4_enable_qpel != 1))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_QPEL_OPTION;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.u4_enable_fast_sad != 0)
&& (ps_ip->s_ive_ip.u4_enable_fast_sad != 1))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_FAST_SAD_OPTION;
return IV_FAIL;
}
if (ps_ip->s_ive_ip.u4_enable_alt_ref > 255)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_ALT_REF_OPTION;
return IV_FAIL;
}
if (ps_ip->s_ive_ip.u4_srch_rng_x
> ps_codec->s_cfg.u4_max_srch_rng_x)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_HORIZONTAL_SEARCH_RANGE_NOT_SUPPORTED;
return (IV_FAIL);
}
if (ps_ip->s_ive_ip.u4_srch_rng_y
> ps_codec->s_cfg.u4_max_srch_rng_y)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_VERTICAL_SEARCH_RANGE_NOT_SUPPORTED;
return (IV_FAIL);
}
break;
}
case IVE_CMD_CTL_SET_IPE_PARAMS:
{
ih264e_ctl_set_ipe_params_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_ipe_params_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_set_ipe_params_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_SETIPEPARAMS_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_set_ipe_params_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_SETIPEPARAMS_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.u4_enable_intra_4x4 != 0)
&& (ps_ip->s_ive_ip.u4_enable_intra_4x4 != 1))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_INTRA4x4_OPTION;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.u4_constrained_intra_pred != 0)
&& (ps_ip->s_ive_ip.u4_constrained_intra_pred != 1))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_CONSTRAINED_INTRA_PREDICTION_MODE;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.u4_enc_speed_preset != IVE_CONFIG)
&& (ps_ip->s_ive_ip.u4_enc_speed_preset != IVE_SLOWEST)
&& (ps_ip->s_ive_ip.u4_enc_speed_preset != IVE_NORMAL)
&& (ps_ip->s_ive_ip.u4_enc_speed_preset != IVE_FAST)
&& (ps_ip->s_ive_ip.u4_enc_speed_preset != IVE_HIGH_SPEED)
&& (ps_ip->s_ive_ip.u4_enc_speed_preset != IVE_FASTEST))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_ENC_SPEED_PRESET;
return IV_FAIL;
}
break;
}
case IVE_CMD_CTL_SET_GOP_PARAMS:
{
ih264e_ctl_set_gop_params_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_gop_params_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_set_gop_params_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_SETGOPPARAMS_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_set_gop_params_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_SETGOPPARAMS_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.u4_i_frm_interval < DEFAULT_MIN_INTRA_FRAME_RATE)
|| (ps_ip->s_ive_ip.u4_i_frm_interval > DEFAULT_MAX_INTRA_FRAME_RATE))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_INTRA_FRAME_INTERVAL;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.u4_idr_frm_interval < DEFAULT_MIN_INTRA_FRAME_RATE)
|| (ps_ip->s_ive_ip.u4_idr_frm_interval > DEFAULT_MAX_INTRA_FRAME_RATE))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_IDR_FRAME_INTERVAL;
return IV_FAIL;
}
break;
}
case IVE_CMD_CTL_SET_DEBLOCK_PARAMS:
{
ih264e_ctl_set_deblock_params_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_deblock_params_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_set_deblock_params_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_SETDEBLKPARAMS_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_set_deblock_params_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_SETDEBLKPARAMS_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.u4_disable_deblock_level != DISABLE_DEBLK_LEVEL_0)
&& (ps_ip->s_ive_ip.u4_disable_deblock_level != DISABLE_DEBLK_LEVEL_2)
&& (ps_ip->s_ive_ip.u4_disable_deblock_level != DISABLE_DEBLK_LEVEL_3)
&& (ps_ip->s_ive_ip.u4_disable_deblock_level != DISABLE_DEBLK_LEVEL_4))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_DEBLOCKING_TYPE_INPUT;
return IV_FAIL;
}
break;
}
case IVE_CMD_CTL_SET_QP:
{
ih264e_ctl_set_qp_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_qp_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_set_qp_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_SETQPPARAMS_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_set_qp_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_SETQPPARAMS_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.u4_i_qp_max > MAX_H264_QP)
|| (ps_ip->s_ive_ip.u4_p_qp_max > MAX_H264_QP)
|| (ps_ip->s_ive_ip.u4_b_qp_max > MAX_H264_QP))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_MAX_FRAME_QP;
return IV_FAIL;
}
/* We donot support QP < 4 */
if ((ps_ip->s_ive_ip.u4_i_qp_min < 4)
|| (ps_ip->s_ive_ip.u4_p_qp_min < 4)
|| (ps_ip->s_ive_ip.u4_b_qp_min < 4)
|| (ps_ip->s_ive_ip.u4_i_qp_min > ps_ip->s_ive_ip.u4_i_qp_max)
|| (ps_ip->s_ive_ip.u4_p_qp_min > ps_ip->s_ive_ip.u4_p_qp_max)
|| (ps_ip->s_ive_ip.u4_b_qp_min > ps_ip->s_ive_ip.u4_b_qp_max))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_MIN_FRAME_QP;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.u4_i_qp > ps_ip->s_ive_ip.u4_i_qp_max)
|| (ps_ip->s_ive_ip.u4_p_qp > ps_ip->s_ive_ip.u4_p_qp_max)
|| (ps_ip->s_ive_ip.u4_b_qp > ps_ip->s_ive_ip.u4_b_qp_max))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_INVALID_INIT_QP;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.u4_i_qp < ps_ip->s_ive_ip.u4_i_qp_min)
|| (ps_ip->s_ive_ip.u4_p_qp < ps_ip->s_ive_ip.u4_p_qp_min)
|| (ps_ip->s_ive_ip.u4_b_qp < ps_ip->s_ive_ip.u4_b_qp_min))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |= IH264E_INVALID_INIT_QP;
return IV_FAIL;
}
break;
}
case IVE_CMD_CTL_SET_VUI_PARAMS:
{
ih264e_vui_ip_t *ps_ip = pv_api_ip;
ih264e_vui_op_t *ps_op = pv_api_op;
if(ps_ip->u4_size != sizeof(ih264e_vui_ip_t))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IVE_ERR_IP_CTL_SET_VUI_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if(ps_op->u4_size != sizeof(ih264e_vui_op_t))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IVE_ERR_OP_CTL_SET_VUI_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
break;
}
case IVE_CMD_CTL_SET_SEI_MDCV_PARAMS:
{
ih264e_ctl_set_sei_mdcv_params_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_sei_mdcv_params_op_t *ps_op = pv_api_op;
if(ps_ip->u4_size != sizeof(ih264e_ctl_set_sei_mdcv_params_ip_t))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IVE_ERR_IP_CTL_SET_SEI_MDCV_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if(ps_op->u4_size != sizeof(ih264e_ctl_set_sei_mdcv_params_op_t))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IVE_ERR_OP_CTL_SET_SEI_MDCV_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if((ps_ip->u1_sei_mdcv_params_present_flag != 0)
&& (ps_ip->u1_sei_mdcv_params_present_flag) != 1)
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_MDCV_PARAMS;
return IV_FAIL;
}
if(1 == ps_ip->u1_sei_mdcv_params_present_flag)
{
/* Check values for u2_display_primaries_x and u2_display_primaries_y */
for(i = 0; i < 3; i++)
{
if((ps_ip->au2_display_primaries_x[i] >
DISPLAY_PRIMARIES_X_UPPER_LIMIT) ||
(ps_ip->au2_display_primaries_x[i] <
DISPLAY_PRIMARIES_X_LOWER_LIMIT) ||
((ps_ip->au2_display_primaries_x[i] %
DISPLAY_PRIMARIES_X_DIVISION_FACTOR) != 0))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_MDCV_PARAMS;
return IV_FAIL;
}
if((ps_ip->au2_display_primaries_y[i] >
DISPLAY_PRIMARIES_Y_UPPER_LIMIT) ||
(ps_ip->au2_display_primaries_y[i] <
DISPLAY_PRIMARIES_Y_LOWER_LIMIT) ||
((ps_ip->au2_display_primaries_y[i] %
DISPLAY_PRIMARIES_Y_DIVISION_FACTOR) != 0))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_MDCV_PARAMS;
return IV_FAIL;
}
}
if((ps_ip->u2_white_point_x > WHITE_POINT_X_UPPER_LIMIT) ||
(ps_ip->u2_white_point_x < WHITE_POINT_X_LOWER_LIMIT) ||
((ps_ip->u2_white_point_x % WHITE_POINT_X_DIVISION_FACTOR) != 0))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_MDCV_PARAMS;
return IV_FAIL;
}
if((ps_ip->u2_white_point_y > WHITE_POINT_Y_UPPER_LIMIT) ||
(ps_ip->u2_white_point_y < WHITE_POINT_Y_LOWER_LIMIT) ||
((ps_ip->u2_white_point_y % WHITE_POINT_Y_DIVISION_FACTOR) != 0))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_MDCV_PARAMS;
return IV_FAIL;
}
if((ps_ip->u4_max_display_mastering_luminance >
MAX_DISPLAY_MASTERING_LUMINANCE_UPPER_LIMIT) ||
(ps_ip->u4_max_display_mastering_luminance <
MAX_DISPLAY_MASTERING_LUMINANCE_LOWER_LIMIT) ||
((ps_ip->u4_max_display_mastering_luminance %
MAX_DISPLAY_MASTERING_LUMINANCE_DIVISION_FACTOR) != 0))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_MDCV_PARAMS;
return IV_FAIL;
}
if((ps_ip->u4_min_display_mastering_luminance >
MIN_DISPLAY_MASTERING_LUMINANCE_UPPER_LIMIT ) ||
(ps_ip->u4_min_display_mastering_luminance <
MIN_DISPLAY_MASTERING_LUMINANCE_LOWER_LIMIT))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_MDCV_PARAMS;
return IV_FAIL;
}
if(ps_ip->u4_max_display_mastering_luminance <=
ps_ip->u4_min_display_mastering_luminance)
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_MDCV_PARAMS;
return IV_FAIL;
}
}
break;
}
case IVE_CMD_CTL_SET_SEI_CLL_PARAMS:
{
ih264e_ctl_set_sei_cll_params_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_sei_cll_params_op_t *ps_op = pv_api_op;
if(ps_ip->u4_size != sizeof(ih264e_ctl_set_sei_cll_params_ip_t))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IVE_ERR_IP_CTL_SET_SEI_CLL_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if(ps_op->u4_size != sizeof(ih264e_ctl_set_sei_cll_params_op_t))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IVE_ERR_OP_CTL_SET_SEI_CLL_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if((ps_ip->u1_sei_cll_params_present_flag != 0)
&& (ps_ip->u1_sei_cll_params_present_flag != 1))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_CLL_PARAMS;
return IV_FAIL;
}
break;
}
case IVE_CMD_CTL_SET_SEI_AVE_PARAMS:
{
ih264e_ctl_set_sei_ave_params_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_sei_ave_params_op_t *ps_op = pv_api_op;
if(ps_ip->u4_size != sizeof(ih264e_ctl_set_sei_ave_params_ip_t))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IVE_ERR_IP_CTL_SET_SEI_AVE_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if(ps_op->u4_size != sizeof(ih264e_ctl_set_sei_ave_params_op_t))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IVE_ERR_OP_CTL_SET_SEI_AVE_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if((ps_ip->u1_sei_ave_params_present_flag != 0)
&& (ps_ip->u1_sei_ave_params_present_flag != 1))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_AVE_PARAMS;
return IV_FAIL;
}
if(1 == ps_ip->u1_sei_ave_params_present_flag)
{
if((0 == ps_ip->u4_ambient_illuminance))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_AVE_PARAMS;
return IV_FAIL;
}
if(ps_ip->u2_ambient_light_x > AMBIENT_LIGHT_X_UPPER_LIMIT)
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_AVE_PARAMS;
return IV_FAIL;
}
if(ps_ip->u2_ambient_light_y > AMBIENT_LIGHT_Y_UPPER_LIMIT)
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_AVE_PARAMS;
return IV_FAIL;
}
}
break;
}
case IVE_CMD_CTL_SET_SEI_CCV_PARAMS:
{
ih264e_ctl_set_sei_ccv_params_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_sei_ccv_params_op_t *ps_op = pv_api_op;
if(ps_ip->u4_size != sizeof(ih264e_ctl_set_sei_ccv_params_ip_t))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IVE_ERR_IP_CTL_SET_SEI_CCV_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if(ps_op->u4_size != sizeof(ih264e_ctl_set_sei_ccv_params_op_t))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IVE_ERR_OP_CTL_SET_SEI_CCV_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if((ps_ip->u1_sei_ccv_params_present_flag != 0)
&& (ps_ip->u1_sei_ccv_params_present_flag != 1))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_CCV_PARAMS;
return IV_FAIL;
}
if(1 == ps_ip->u1_sei_ccv_params_present_flag)
{
if((ps_ip->u1_ccv_cancel_flag != 0)
&& (ps_ip->u1_ccv_cancel_flag != 1))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_CCV_PARAMS;
return IV_FAIL;
}
if(0 == ps_ip->u1_ccv_cancel_flag)
{
if((ps_ip->u1_ccv_persistence_flag != 0)
&& (ps_ip->u1_ccv_persistence_flag != 1))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_CCV_PARAMS;
return IV_FAIL;
}
if((ps_ip->u1_ccv_primaries_present_flag != 0)
&& (ps_ip->u1_ccv_primaries_present_flag != 1))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_CCV_PARAMS;
return IV_FAIL;
}
if((ps_ip->u1_ccv_min_luminance_value_present_flag != 0)
&& (ps_ip->u1_ccv_min_luminance_value_present_flag != 1))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_CCV_PARAMS;
return IV_FAIL;
}
if((ps_ip->u1_ccv_max_luminance_value_present_flag != 0)
&& (ps_ip->u1_ccv_max_luminance_value_present_flag != 1))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_CCV_PARAMS;
return IV_FAIL;
}
if((ps_ip->u1_ccv_avg_luminance_value_present_flag != 0)
&& (ps_ip->u1_ccv_avg_luminance_value_present_flag != 1))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_CCV_PARAMS;
return IV_FAIL;
}
if((ps_ip->u1_ccv_primaries_present_flag == 0)
&& (ps_ip->u1_ccv_min_luminance_value_present_flag == 0)
&& (ps_ip->u1_ccv_max_luminance_value_present_flag == 0)
&& (ps_ip->u1_ccv_avg_luminance_value_present_flag == 0))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_CCV_PARAMS;
return IV_FAIL;
}
if((ps_ip->u1_ccv_reserved_zero_2bits != 0))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_CCV_PARAMS;
return IV_FAIL;
}
if(1 == ps_ip->u1_ccv_primaries_present_flag)
{
for(i = 0; i < 3; i++)
{
if((ps_ip->ai4_ccv_primaries_x[i] >
CCV_PRIMARIES_X_UPPER_LIMIT) ||
(ps_ip->ai4_ccv_primaries_x[i] <
CCV_PRIMARIES_X_LOWER_LIMIT))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_CCV_PARAMS;
return IV_FAIL;
}
if((ps_ip->ai4_ccv_primaries_y[i] >
CCV_PRIMARIES_Y_UPPER_LIMIT) ||
(ps_ip->ai4_ccv_primaries_y[i] <
CCV_PRIMARIES_Y_LOWER_LIMIT))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_CCV_PARAMS;
return IV_FAIL;
}
}
}
if((1 == ps_ip->u1_ccv_min_luminance_value_present_flag) &&
(1 == ps_ip->u1_ccv_avg_luminance_value_present_flag))
{
if((ps_ip->u4_ccv_avg_luminance_value <
ps_ip->u4_ccv_min_luminance_value))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_CCV_PARAMS;
return IV_FAIL;
}
}
if((1 == ps_ip->u1_ccv_min_luminance_value_present_flag) &&
(1 == ps_ip->u1_ccv_max_luminance_value_present_flag))
{
if((ps_ip->u4_ccv_max_luminance_value <
ps_ip->u4_ccv_min_luminance_value))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_CCV_PARAMS;
return IV_FAIL;
}
}
if((1 == ps_ip->u1_ccv_avg_luminance_value_present_flag) &&
(1 == ps_ip->u1_ccv_max_luminance_value_present_flag))
{
if((ps_ip->u4_ccv_max_luminance_value <
ps_ip->u4_ccv_avg_luminance_value))
{
ps_op->u4_error_code |= 1 << IVE_UNSUPPORTEDPARAM;
ps_op->u4_error_code |=
IH264E_INVALID_SEI_CCV_PARAMS;
return IV_FAIL;
}
}
}
}
break;
}
case IVE_CMD_CTL_SET_ENC_MODE:
{
ih264e_ctl_set_enc_mode_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_enc_mode_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_set_enc_mode_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_SETENCMODE_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_set_enc_mode_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_SETENCMODE_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.e_enc_mode != IVE_ENC_MODE_HEADER)
&& (ps_ip->s_ive_ip.e_enc_mode != IVE_ENC_MODE_PICTURE))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_ENC_OPERATION_MODE;
return IV_FAIL;
}
break;
}
case IVE_CMD_CTL_SET_VBV_PARAMS:
{
ih264e_ctl_set_vbv_params_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_vbv_params_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_set_vbv_params_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_SETVBVPARAMS_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_set_vbv_params_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_SETVBVPARAMS_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.u4_vbv_buffer_delay < DEFAULT_MIN_BUFFER_DELAY)
|| (ps_ip->s_ive_ip.u4_vbv_buffer_delay > DEFAULT_MAX_BUFFER_DELAY))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_BUFFER_DELAY;
return IV_FAIL;
}
break;
}
case IVE_CMD_CTL_SET_AIR_PARAMS:
{
ih264e_ctl_set_air_params_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_air_params_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_set_air_params_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_SETAIRPARAMS_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_set_air_params_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_SETAIRPARAMS_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if ((ps_ip->s_ive_ip.e_air_mode != IVE_AIR_MODE_NONE)
&& (ps_ip->s_ive_ip.e_air_mode != IVE_AIR_MODE_CYCLIC)
&& (ps_ip->s_ive_ip.e_air_mode != IVE_AIR_MODE_RANDOM))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_AIR_MODE;
return IV_FAIL;
}
if (ps_ip->s_ive_ip.u4_air_refresh_period == 0)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_AIR_REFRESH_PERIOD;
return IV_FAIL;
}
break;
}
case IVE_CMD_CTL_SET_PROFILE_PARAMS:
{
ih264e_ctl_set_profile_params_ip_t *ps_ip = pv_api_ip;
ih264e_ctl_set_profile_params_op_t *ps_op = pv_api_op;
if (ps_ip->s_ive_ip.u4_size
!= sizeof(ih264e_ctl_set_profile_params_ip_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_IP_CTL_SETPROFILE_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_op->s_ive_op.u4_size
!= sizeof(ih264e_ctl_set_profile_params_op_t))
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IVE_ERR_OP_CTL_SETPROFILE_API_STRUCT_SIZE_INCORRECT;
return IV_FAIL;
}
if (ps_ip->s_ive_ip.e_profile != IV_PROFILE_BASE &&
ps_ip->s_ive_ip.e_profile != IV_PROFILE_MAIN)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_PROFILE_NOT_SUPPORTED;
return IV_FAIL;
}
if (ps_ip->s_ive_ip.u4_entropy_coding_mode > 1)
{
ps_op->s_ive_op.u4_error_code |= 1
<< IVE_UNSUPPORTEDPARAM;
ps_op->s_ive_op.u4_error_code |=
IH264E_INVALID_ENTROPY_CODING_MODE;
return IV_FAIL;
}
break;
}
default:
*(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM;
*(pu4_api_op + 1) |= IVE_ERR_INVALID_API_SUB_CMD;
return IV_FAIL;
}
break;
}
default:
*(pu4_api_op + 1) |= 1 << IVE_UNSUPPORTEDPARAM;
*(pu4_api_op + 1) |= IVE_ERR_INVALID_API_CMD;
return IV_FAIL;
}
return IV_SUCCESS;
}
/**
*******************************************************************************
*
* @brief update encoder configuration parameters
*
* @par Description:
* updates encoder configuration parameters from the given config set.
* Initialize/reinitialize codec parameters according to new configurations.
*
* @param[in] ps_codec
* Pointer to codec context
*
* @param[in] ps_cfg
* Pointer to config param set
*
* @remarks none
*
*******************************************************************************
*/
IH264E_ERROR_T ih264e_codec_update_config(codec_t *ps_codec,
cfg_params_t *ps_cfg)
{
/* config params */
cfg_params_t *ps_curr_cfg = &ps_codec->s_cfg;
/* error status */
IH264E_ERROR_T err = IH264E_SUCCESS;
/* temp var */
UWORD32 u4_init_rc = 0;
/***********************/
/* UPDATE CODEC CONFIG */
/***********************/
if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_DIMENSIONS)
{
UWORD32 wd_aln = ALIGN16(ps_cfg->u4_wd);
UWORD32 ht_aln = ALIGN16(ps_cfg->u4_ht);
if (ps_curr_cfg->u4_wd != wd_aln || ps_curr_cfg->u4_ht != ht_aln
|| ps_curr_cfg->u4_disp_wd != ps_cfg->u4_disp_wd
|| ps_curr_cfg->u4_disp_ht != ps_cfg->u4_disp_ht)
{
ps_curr_cfg->u4_wd = wd_aln;
ps_curr_cfg->u4_ht = ht_aln;
ps_curr_cfg->u4_disp_wd = ps_cfg->u4_disp_wd;
ps_curr_cfg->u4_disp_ht = ps_cfg->u4_disp_ht;
ps_curr_cfg->i4_wd_mbs = ps_curr_cfg->u4_wd >> 4;
ps_curr_cfg->i4_ht_mbs = ps_curr_cfg->u4_ht >> 4;
ps_codec->i4_rec_strd = ALIGN16(ps_cfg->u4_wd) + PAD_WD;
/* If number of MBs in a frame changes the air map also changes.
* Hence recompute air map also reset air pic cnt */
if (ps_codec->s_cfg.e_air_mode != IVE_AIR_MODE_NONE)
{
/* re-init the air map */
ih264e_init_air_map(ps_codec);
/* reset air counter */
ps_codec->i4_air_pic_cnt = -1;
}
/* initialize mv bank buffer manager */
err = ih264e_mv_buf_mgr_add_bufs(ps_codec);
if (err != IH264E_SUCCESS)
return err;
/* initialize ref bank buffer manager */
err = ih264e_pic_buf_mgr_add_bufs(ps_codec);
if (err != IH264E_SUCCESS)
return err;
/* since dimension changed, start new sequence by forcing IDR */
ps_codec->force_curr_frame_type = IV_IDR_FRAME;
/* in case dimension changes, we need to reinitialize RC as the
* old model shall not fit further */
u4_init_rc = 1;
/* when the dimension changes, the header needs to be regenerated */
ps_codec->i4_gen_header = 1;
}
}
else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_FRAMERATE)
{
/* temp var */
UWORD32 u4_src_ticks, u4_tgt_ticks;
u4_src_ticks = ih264e_frame_time_get_src_ticks(
ps_codec->s_rate_control.pps_frame_time);
u4_tgt_ticks = ih264e_frame_time_get_tgt_ticks(
ps_codec->s_rate_control.pps_frame_time);
/* Change frame rate */
if (ps_codec->s_cfg.u4_src_frame_rate
!= ps_cfg->u4_src_frame_rate * 1000)
{
ps_codec->s_cfg.u4_src_frame_rate = ps_cfg->u4_src_frame_rate
* 1000;
ih264e_frame_time_update_src_frame_rate(
ps_codec->s_rate_control.pps_frame_time,
ps_codec->s_cfg.u4_src_frame_rate);
ih264_time_stamp_update_frame_rate(
ps_codec->s_rate_control.pps_time_stamp,
ps_codec->s_cfg.u4_src_frame_rate);
irc_change_frame_rate(ps_codec->s_rate_control.pps_rate_control_api,
ps_codec->s_cfg.u4_src_frame_rate,
u4_src_ticks, u4_tgt_ticks);
}
if (ps_codec->s_cfg.u4_tgt_frame_rate
!= ps_cfg->u4_tgt_frame_rate * 1000)
{
ps_codec->s_cfg.u4_tgt_frame_rate = ps_cfg->u4_tgt_frame_rate
* 1000;
ih264e_frame_time_update_tgt_frame_rate(
ps_codec->s_rate_control.pps_frame_time,
ps_codec->s_cfg.u4_tgt_frame_rate);
irc_change_frame_rate(ps_codec->s_rate_control.pps_rate_control_api,
ps_codec->s_cfg.u4_src_frame_rate,
u4_src_ticks, u4_tgt_ticks);
irc_change_frm_rate_for_bit_alloc(
ps_codec->s_rate_control.pps_rate_control_api,
ps_codec->s_cfg.u4_tgt_frame_rate);
}
}
else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_BITRATE)
{
if (ps_curr_cfg->u4_target_bitrate != ps_cfg->u4_target_bitrate)
{
if (IVE_RC_NONE != ps_curr_cfg->e_rc_mode)
irc_change_avg_bit_rate(
ps_codec->s_rate_control.pps_rate_control_api,
ps_cfg->u4_target_bitrate);
ps_curr_cfg->u4_target_bitrate = ps_cfg->u4_target_bitrate;
}
}
else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_FRAMETYPE)
{
switch (ps_cfg->e_frame_type)
{
case IV_I_FRAME:
ps_codec->force_curr_frame_type = IV_I_FRAME;
break;
case IV_IDR_FRAME:
ps_codec->force_curr_frame_type = IV_IDR_FRAME;
break;
case IV_P_FRAME:
default:
break;
}
}
else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_ME_PARAMS)
{
if (ps_curr_cfg->u4_enc_speed_preset == IVE_CONFIG)
{
ps_codec->s_cfg.u4_enable_hpel = ps_cfg->u4_enable_hpel;
ps_codec->s_cfg.u4_enable_fast_sad = ps_cfg->u4_enable_fast_sad;
ps_codec->s_cfg.u4_me_speed_preset = ps_cfg->u4_me_speed_preset;
ps_codec->s_cfg.u4_enable_qpel = ps_cfg->u4_enable_qpel;
}
else if (ps_curr_cfg->u4_enc_speed_preset == IVE_FASTEST)
{
ps_codec->s_cfg.u4_enable_fast_sad = ps_cfg->u4_enable_fast_sad;
}
ps_codec->s_cfg.u4_srch_rng_x = ps_cfg->u4_srch_rng_x;
ps_codec->s_cfg.u4_srch_rng_y = ps_cfg->u4_srch_rng_y;
if (ps_codec->s_cfg.u4_enable_alt_ref != ps_cfg->u4_enable_alt_ref)
{
ps_codec->s_cfg.u4_enable_alt_ref = ps_cfg->u4_enable_alt_ref;
ps_codec->u4_is_curr_frm_ref = 1;
}
}
else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_IPE_PARAMS)
{
ps_curr_cfg->u4_enc_speed_preset = ps_cfg->u4_enc_speed_preset;
ps_curr_cfg->u4_constrained_intra_pred = ps_cfg->u4_constrained_intra_pred;
if (ps_curr_cfg->u4_enc_speed_preset == IVE_SLOWEST)
{/* high quality */
/* enable diamond search */
ps_curr_cfg->u4_me_speed_preset = DMND_SRCH;
ps_curr_cfg->u4_enable_fast_sad = 0;
/* disable intra 4x4 */
ps_curr_cfg->u4_enable_intra_4x4 = 1;
ps_codec->luma_energy_compaction[1] =
ih264e_code_luma_intra_macroblock_4x4_rdopt_on;
/* sub pel off */
ps_curr_cfg->u4_enable_hpel = 1;
/* deblocking off */
ps_curr_cfg->u4_disable_deblock_level = DISABLE_DEBLK_LEVEL_0;
/* disabled intra inter gating in Inter slices */
ps_codec->u4_inter_gate = 0;
}
else if (ps_curr_cfg->u4_enc_speed_preset == IVE_NORMAL)
{/* normal */
/* enable diamond search */
ps_curr_cfg->u4_me_speed_preset = DMND_SRCH;
ps_curr_cfg->u4_enable_fast_sad = 0;
/* disable intra 4x4 */
ps_curr_cfg->u4_enable_intra_4x4 = 1;
/* sub pel off */
ps_curr_cfg->u4_enable_hpel = 1;
/* deblocking off */
ps_curr_cfg->u4_disable_deblock_level = DISABLE_DEBLK_LEVEL_0;
/* disabled intra inter gating in Inter slices */
ps_codec->u4_inter_gate = 0;
}
else if (ps_curr_cfg->u4_enc_speed_preset == IVE_FAST)
{/* normal */
/* enable diamond search */
ps_curr_cfg->u4_me_speed_preset = DMND_SRCH;
ps_curr_cfg->u4_enable_fast_sad = 0;
/* disable intra 4x4 */
ps_curr_cfg->u4_enable_intra_4x4 = 0;
/* sub pel off */
ps_curr_cfg->u4_enable_hpel = 1;
/* deblocking off */
ps_curr_cfg->u4_disable_deblock_level = DISABLE_DEBLK_LEVEL_0;
/* disabled intra inter gating in Inter slices */
ps_codec->u4_inter_gate = 1;
}
else if (ps_curr_cfg->u4_enc_speed_preset == IVE_HIGH_SPEED)
{/* fast */
/* enable diamond search */
ps_curr_cfg->u4_me_speed_preset = DMND_SRCH;
ps_curr_cfg->u4_enable_fast_sad = 0;
/* disable intra 4x4 */
ps_curr_cfg->u4_enable_intra_4x4 = 0;
/* sub pel off */
ps_curr_cfg->u4_enable_hpel = 0;
/* deblocking off */
ps_curr_cfg->u4_disable_deblock_level = DISABLE_DEBLK_LEVEL_4;
/* disabled intra inter gating in Inter slices */
ps_codec->u4_inter_gate = 0;
}
else if (ps_curr_cfg->u4_enc_speed_preset == IVE_FASTEST)
{/* fastest */
/* enable diamond search */
ps_curr_cfg->u4_me_speed_preset = DMND_SRCH;
//u4_num_layers = 4;
/* disable intra 4x4 */
ps_curr_cfg->u4_enable_intra_4x4 = 0;
/* sub pel off */
ps_curr_cfg->u4_enable_hpel = 0;
/* deblocking off */
ps_curr_cfg->u4_disable_deblock_level = DISABLE_DEBLK_LEVEL_4;
/* disabled intra inter gating in Inter slices */
ps_codec->u4_inter_gate = 1;
}
else if (ps_curr_cfg->u4_enc_speed_preset == IVE_CONFIG)
{
ps_curr_cfg->u4_enable_intra_4x4 = ps_cfg->u4_enable_intra_4x4;
}
}
else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_GOP_PARAMS)
{
if (ps_curr_cfg->u4_i_frm_interval != ps_cfg->u4_i_frm_interval)
{
ps_curr_cfg->u4_i_frm_interval = ps_cfg->u4_i_frm_interval;
/* reset air counter */
ps_codec->i4_air_pic_cnt = -1;
/* re-init air map */
ih264e_init_air_map(ps_codec);
/*Effect intra frame interval change*/
irc_change_intra_frm_int_call(
ps_codec->s_rate_control.pps_rate_control_api,
ps_curr_cfg->u4_i_frm_interval);
}
ps_curr_cfg->u4_idr_frm_interval = ps_cfg->u4_idr_frm_interval;
}
else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_DEBLOCK_PARAMS)
{
if (ps_curr_cfg->u4_enc_speed_preset == IVE_CONFIG)
{
ps_curr_cfg->u4_disable_deblock_level =
ps_cfg->u4_disable_deblock_level;
}
}
else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_QP)
{
UWORD8 au1_init_qp[MAX_PIC_TYPE];
UWORD8 au1_min_max_qp[2 * MAX_PIC_TYPE];
ps_codec->s_cfg.u4_i_qp_max = ps_cfg->u4_i_qp_max;
ps_codec->s_cfg.u4_i_qp_min = ps_cfg->u4_i_qp_min;
ps_codec->s_cfg.u4_i_qp = ps_cfg->u4_i_qp;
ps_codec->s_cfg.u4_p_qp_max = ps_cfg->u4_p_qp_max;
ps_codec->s_cfg.u4_p_qp_min = ps_cfg->u4_p_qp_min;
ps_codec->s_cfg.u4_p_qp = ps_cfg->u4_p_qp;
ps_codec->s_cfg.u4_b_qp_max = ps_cfg->u4_b_qp_max;
ps_codec->s_cfg.u4_b_qp_min = ps_cfg->u4_b_qp_min;
ps_codec->s_cfg.u4_b_qp = ps_cfg->u4_b_qp;
/* update rc lib with modified qp */
au1_init_qp[0] = gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_i_qp];
au1_init_qp[1] = gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_p_qp];
au1_init_qp[2] = gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_b_qp];
irc_change_init_qp(ps_codec->s_rate_control.pps_rate_control_api,
au1_init_qp);
au1_min_max_qp[2 * I_PIC] =
gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_i_qp_min];
au1_min_max_qp[2 * I_PIC + 1] =
gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_i_qp_max];
au1_min_max_qp[2 * P_PIC] =
gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_p_qp_min];
au1_min_max_qp[2 * P_PIC + 1] =
gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_p_qp_max];
au1_min_max_qp[2 * B_PIC] =
gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_b_qp_min];
au1_min_max_qp[2 * B_PIC + 1] =
gau1_h264_to_mpeg2_qmap[ps_codec->s_cfg.u4_b_qp_max];
irc_change_min_max_qp(ps_codec->s_rate_control.pps_rate_control_api,
au1_min_max_qp);
}
else if (ps_cfg->e_cmd == IVE_CMD_CTL_SET_ENC_MODE)
{