コード例 #1
0
JAIA_RETURN_STATUS_ENUM jaia_utility_output_from_buffer_to_file(JAIA_HANDLE jaia_workspace, kal_uint32 dst_offset, JAIA_BUFFER *target_buffer)
{
    JAIA_RETURN_STATUS_ENUM ret_status = JAIA_RETURN_OK;
    STFSAL *dst_fsal = jaia_workspace->dst_jpeg_fsal_handle;
    JAIA_BUFFER dst_buffer;

    if (JAIA_OUTPUT_TO_FILE == jaia_workspace->dst_output_mode)
    {
        FSAL_Seek(dst_fsal, dst_offset);

        if (FSAL_OK != FSAL_Write(dst_fsal, (kal_uint8 *)target_buffer->buff_addr, target_buffer->buff_size))
        {
            return JAIA_RETURN_FSAL_OUTPUT_ERROR;
        }

        jaia_workspace->jpeg_write_index += target_buffer->buff_size;
    }
    else if (JAIA_OUTPUT_TO_MEMORY == jaia_workspace->dst_output_mode)
    {
        dst_buffer.buff_addr = jaia_workspace->dst_jpeg_file_buffer->buff_addr;
        dst_buffer.buff_size = jaia_workspace->dst_jpeg_file_buffer->buff_size;
        dst_buffer.buff_addr = (void *)((kal_uint32)dst_buffer.buff_addr + dst_offset);

        memcpy(dst_buffer.buff_addr, target_buffer->buff_addr, target_buffer->buff_size);

        jaia_workspace->jpeg_write_index += target_buffer->buff_size;
    }

    return ret_status;
}
コード例 #2
0
ファイル: video_fileparse_adap.c プロジェクト: 12019/mtktest
//MEDIA_STATUS_CODE video_file_get_vos_data(MP4VIDEO_VOS_STRUCT **VOS)
MEDIA_STATUS_CODE video_file_get_vos_data(kal_uint8* p_vos, kal_uint32 *p_vos_size)
{
    kal_uint32 vos_pos;

    /* Get VOS information */
    vos_pos = MP4_Video_GetVOSOffset(g_video_dec_info_ptr->pMp4Parser);
    *p_vos_size = MP4_Video_GetVOSSize(g_video_dec_info_ptr->pMp4Parser);

    if ((*p_vos_size) > 100)
    {
        VIDEO_ASSERT(0);

        g_video_dec_status.VIDEO_STATUS = VIDEO_DEC_FATAL_ERROR;
        return VIDEO_ERROR;
    }

    /* Read VOS from file system*/
    g_video_dec_status.FSAL_STATUS = FSAL_Seek(g_video_dec_info_ptr->pstFSAL, vos_pos);
    if (g_video_dec_status.FSAL_STATUS != FSAL_OK)
    {
        VIDEO_ASSERT(0);

        g_video_dec_status.FSAL_ERROR_FILE = g_video_dec_info_ptr->pstFSAL;
        return FSAL_ERROR;
    }

    g_video_dec_status.FSAL_STATUS = FSAL_Read(g_video_dec_info_ptr->pstFSAL, p_vos, *p_vos_size);
    if (g_video_dec_status.FSAL_STATUS != FSAL_OK)
    {
        VIDEO_ASSERT(0);

        g_video_dec_status.FSAL_ERROR_FILE = g_video_dec_info_ptr->pstFSAL;
        return FSAL_ERROR;
    }

    return MEDIA_STATUS_OK;
}
コード例 #3
0
JAIA_RETURN_STATUS_ENUM jaia_utility_output_file_to_file(JAIA_HANDLE jaia_workspace, kal_uint32 src_offset, kal_uint32 dst_offset, kal_uint32 output_size)
{
    JAIA_RETURN_STATUS_ENUM ret_status = JAIA_RETURN_OK;
    JAIA_BUFFER wb = jaia_workspace->file_copy_buffer;
    STFSAL *src_fsal = jaia_workspace->src_jpeg_fsal_handle;
    STFSAL *dst_fsal = jaia_workspace->dst_jpeg_fsal_handle;
    JAIA_BUFFER dst_buffer;
    kal_uint32 src_left_size;
    kal_uint32 cnt;

    if ((0 == output_size) || (0 == wb.buff_size) || (NULL == wb.buff_addr))
    {
        return JAIA_RETURN_FSAL_OUTPUT_ERROR;
    }

    if (JAIA_OUTPUT_TO_FILE == jaia_workspace->dst_output_mode)
    {
        FSAL_Seek(src_fsal, src_offset);
        FSAL_Seek(dst_fsal, dst_offset);

        src_left_size = output_size % wb.buff_size;

        for (cnt = 0; cnt < output_size / wb.buff_size; cnt++)
        {
            if (FSAL_OK != FSAL_Read(src_fsal, (kal_uint8 *)wb.buff_addr, wb.buff_size))
            {
                return JAIA_RETURN_FSAL_OUTPUT_ERROR;
            }

            if (FSAL_OK != FSAL_Write(dst_fsal, (kal_uint8 *)wb.buff_addr, wb.buff_size))
            {
                return JAIA_RETURN_FSAL_OUTPUT_ERROR;
            }
        }

        if (FSAL_OK != FSAL_Read(src_fsal, (kal_uint8 *)wb.buff_addr, src_left_size))
        {
            return JAIA_RETURN_FSAL_OUTPUT_ERROR;
        }

        if (FSAL_OK != FSAL_Write(dst_fsal, (kal_uint8 *)wb.buff_addr, src_left_size))
        {
            return JAIA_RETURN_FSAL_OUTPUT_ERROR;
        }

        jaia_workspace->jpeg_write_index += output_size;
    }
    else if (JAIA_OUTPUT_TO_MEMORY == jaia_workspace->dst_output_mode)
    {
        FSAL_Seek(src_fsal, src_offset);

        dst_buffer.buff_addr = jaia_workspace->dst_jpeg_file_buffer->buff_addr;
        dst_buffer.buff_size = jaia_workspace->dst_jpeg_file_buffer->buff_size;
        dst_buffer.buff_addr = (void *)((kal_uint32)dst_buffer.buff_addr + dst_offset);

        {
           kal_uint32 write_left;

           // consider source/destination overlapping case
           write_left = output_size % wb.buff_size;
           for (cnt = 0; cnt < output_size / wb.buff_size; cnt++)
           {
               if (FSAL_OK != FSAL_Read(src_fsal, (kal_uint8 *)wb.buff_addr, wb.buff_size))
               {
                   return JAIA_RETURN_FSAL_OUTPUT_ERROR;
               }
               memcpy((kal_uint8*)dst_buffer.buff_addr, (kal_uint8 *)wb.buff_addr, wb.buff_size);
               dst_buffer.buff_addr = (void*)((kal_uint32)dst_buffer.buff_addr + wb.buff_size);
           }
   
           if (FSAL_OK != FSAL_Read(src_fsal, (kal_uint8 *)wb.buff_addr, write_left))
           {
               return JAIA_RETURN_FSAL_OUTPUT_ERROR;
           }
           memcpy((kal_uint8*)dst_buffer.buff_addr, (kal_uint8 *)wb.buff_addr, write_left);
           dst_buffer.buff_addr = (void*)((kal_uint32)dst_buffer.buff_addr + write_left);
        }

        jaia_workspace->jpeg_write_index += output_size;
    }


    return ret_status;
}
コード例 #4
0
ファイル: video_fileparse_adap.c プロジェクト: 12019/mtktest
/* Read bitstream from file system to buffer
 * @param  current_pos is start position in the file
 * @param  current_size is total bytes that should be read
  * @param  current_buffer_addr is the buffer start address
 * @return Media status, which is based MEDIA_STATUS_CODE structure.
 */
static MEDIA_STATUS_CODE video_file_read_bitstream_data(kal_uint32 current_pos, kal_uint32 current_size,
                                                        kal_uint32 current_buffer_addr)
{
    if (current_size > 512)
    {
        g_video_dec_status.FSAL_STATUS = FSAL_Direct_Seek(g_video_dec_info_ptr->pstFSAL, current_pos);

        if (g_video_dec_status.FSAL_STATUS != FSAL_OK)
        {
            VIDEO_ASSERT(0);
#ifdef PGDL_SUPPORT
            if (g_video_dec_status.scenario == VIDEO_SCENARIO_PGDL) {
                kal_prompt_trace(MOD_MED, "FSAL_Direct_Seek Error: %d, %d, %d\n", g_video_dec_status.FSAL_STATUS, current_pos, current_size, current_buffer_addr);
            }
#endif
            g_video_dec_status.FSAL_ERROR_FILE = g_video_dec_info_ptr->pstFSAL;
            return FSAL_ERROR;
        }

        g_video_dec_status.FSAL_STATUS = FSAL_Direct_Read(g_video_dec_info_ptr->pstFSAL,
                                                          (kal_uint8 *)current_buffer_addr,
                                                          current_size);
        if (g_video_dec_status.FSAL_STATUS != FSAL_OK)
        {
            VIDEO_ASSERT(0);
#ifdef PGDL_SUPPORT
            if (g_video_dec_status.scenario == VIDEO_SCENARIO_PGDL) {
                kal_prompt_trace(MOD_MED, "FSAL_Direct_Read Error: %d, %d, %d\n", g_video_dec_status.FSAL_STATUS, current_pos, current_size, current_buffer_addr);
            }
#endif

            g_video_dec_status.FSAL_ERROR_FILE = g_video_dec_info_ptr->pstFSAL;
            return FSAL_ERROR;
        }
    }
    else
    {
        g_video_dec_status.FSAL_STATUS = FSAL_Seek(g_video_dec_info_ptr->pstFSAL, current_pos);

        if (g_video_dec_status.FSAL_STATUS != FSAL_OK)
        {
            VIDEO_ASSERT(0);
#ifdef PGDL_SUPPORT
            if (g_video_dec_status.scenario == VIDEO_SCENARIO_PGDL) {
                kal_prompt_trace(MOD_MED, "FSAL_Seek Error: %d, %d, %d\n", g_video_dec_status.FSAL_STATUS, current_pos, current_size, current_buffer_addr);
            }
#endif

            g_video_dec_status.FSAL_ERROR_FILE = g_video_dec_info_ptr->pstFSAL;
            return FSAL_ERROR;
        }

        g_video_dec_status.FSAL_STATUS = FSAL_Read(g_video_dec_info_ptr->pstFSAL, (kal_uint8 *)current_buffer_addr,
                                                   current_size);
        if (g_video_dec_status.FSAL_STATUS != FSAL_OK)
        {
            VIDEO_ASSERT(0);
#ifdef PGDL_SUPPORT
            if (g_video_dec_status.scenario == VIDEO_SCENARIO_PGDL) {
                kal_prompt_trace(MOD_MED, "FSAL_Read Error: %d, %d, %d\n", g_video_dec_status.FSAL_STATUS, current_pos, current_size, current_buffer_addr);
            }
#endif

            g_video_dec_status.FSAL_ERROR_FILE = g_video_dec_info_ptr->pstFSAL;
            return FSAL_ERROR;
        }
    }

    return MEDIA_STATUS_OK;
}