⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 video_dec_buffer_manager.c

📁 最新MTK手机软件源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/

/*****************************************************************************
 *
 * Filename:
 * ---------
 *   video_dec_buffer_manager.c
 *
 * Project:
 * --------
 *		MT6218B and MT6219
 *
 * Description:
 * ------------
 *   This file defines buffer management APIs of mpeg4 decode.
 *
 * Author:
 * -------
 * -------
 *
 *============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/
#ifdef MP4_CODEC
#include "drv_comm.h"
#include "med_status.h"
#include "visual_comm.h"
#include "fsal.h"
#include "mp4_parser.h"
#include "l1audio.h"
#include "lcd_if.h"
#include "rtc_sw.h"
#include "video_file_creator.h"
#include "bmd.h"
#include "video_enc_glb.h"
#include "video_dec_glb.h"
#include "video_glb.h"
#include "stack_common.h"
#include "syscomp_config.h" /*MOD_BMT*/
#include "stack_msgs.h"
#include "app_ltlcom.h"      /* Task message communiction */
#include "stacklib.h"          /* Basic type for dll, evshed, stacktimer */
#include "event_shed.h"     /* Event scheduler */
#include "stack_timer.h"     /*Timer*/
#include "app_buff_alloc.h" /*buffer*/
#include "task_config.h"     /* Task creation */
#include "stack_ltlcom.h"   /*msg_send_ext_queue.....definitions*/
#include "intrCtrl.h"
#include "video_hw.h"

/* mutex can not be dynamic allocated */
static kal_mutexid  g_video_dec_buffer_mutex;
/* frame buffer manager uses array, so alloacte it only when used */
static VIDEO_DEC_BUFFER_MGR_STRUCT *g_video_dec_buffer_mgr_ptr;


/* Config and init buffer management.
*   It should be executed in task level. It may be configured according to differnet application
* @param cb_info buffer senario and callback function information
* @return None
*/
void video_dec_config_buffer(VIDEO_DEC_BUFFER_CB_STRUCT cb_info)
{
    kal_uint32 index;

    kal_uint8 *buffer_addr;
    kal_uint32 buffer_count = 0;
    kal_uint32 buffer_size = 0;
    kal_uint8 *current_buffer_addr;
    kal_uint32 buffer_addr_offset;

    if (kal_if_hisr() == KAL_TRUE)
        EXT_ASSERT(0, 0, 0, 0);

    /* Get control variable memory */
    g_video_dec_buffer_mgr_ptr = (VIDEO_DEC_BUFFER_MGR_STRUCT *)extmem_get_buffer(sizeof(VIDEO_DEC_BUFFER_MGR_STRUCT));

    /* Get real buffer memory */
    if(cb_info.scenario == VIDEO_DEC_BUFFER_SCENARIO_EDITOR)
    {
    #if defined(__VIDEO_EDITOR__)
        buffer_size = VIDEO_EDITOR_DEC_BUFFER_SIZE * VIDEO_EDITOR_DEC_BUFFER_COUNT;
        buffer_count = VIDEO_EDITOR_DEC_BUFFER_COUNT;
    #else
        ASSERT(0);
    #endif
    }
    else if( cb_info.scenario == VIDEO_DEC_BUFFER_SCENARIO_FILE)
    {
        buffer_size = VIDEO_DEC_BUFFER_SIZE * VIDEO_DEC_BUFFER_COUNT;
        buffer_count = VIDEO_DEC_BUFFER_COUNT;
    }    
    else
    {
        /* Not support */
        EXT_ASSERT(0, (kal_uint32)cb_info.scenario, 0, 0);
    }
    buffer_addr = (kal_uint8 *)extmem_get_buffer(buffer_size);
    if ((buffer_count > VIDEO_DEC_MAX_BUFFER_COUNT) || (buffer_addr == NULL))
            EXT_ASSERT(0, buffer_count, (kal_uint32)buffer_addr, (kal_uint32)cb_info.scenario);

    /* Init mutex */
    if (g_video_dec_buffer_mutex == 0)
        g_video_dec_buffer_mutex = kal_create_mutex("VIDEO_DEC_BUFFER_MUTEX");

    kal_take_mutex(g_video_dec_buffer_mutex);

    /* Init parameters */	
    g_video_dec_buffer_mgr_ptr->send_ilm = KAL_TRUE;
    g_video_dec_buffer_mgr_ptr->b_data_empty = KAL_FALSE;
    g_video_dec_buffer_mgr_ptr->cb_info.scenario = cb_info.scenario;
    g_video_dec_buffer_mgr_ptr->cb_info.callback = cb_info.callback;
    g_video_dec_buffer_mgr_ptr->cb_info.event_id = cb_info.event_id;
    g_video_dec_buffer_mgr_ptr->buffer_count = buffer_count;
    g_video_dec_buffer_mgr_ptr->buffer_start_addr = buffer_addr;
    current_buffer_addr = buffer_addr;
    buffer_addr_offset = buffer_size / buffer_count;

    for (index = 0; index < g_video_dec_buffer_mgr_ptr->buffer_count; index++)
    {
        g_video_dec_buffer_mgr_ptr->DEC_BUFFER[index].buffer = current_buffer_addr;
        g_video_dec_buffer_mgr_ptr->DEC_BUFFER[index].buffer_length = buffer_addr_offset;
        current_buffer_addr += buffer_addr_offset;
    }

    kal_give_mutex(g_video_dec_buffer_mutex);
}


/* Cancel the current put buffer action. If driver decides to stop, but task is still get data from file system to buffer.
*   It can stop put buffer as quickly as possible
* @param None
* @return None
*/
void video_dec_cancel_put_buffer(void)
{
    	g_video_dec_buffer_mgr_ptr->cancel_put_buffer = KAL_TRUE;
}


/* Clear all the buffers. Only clear the control parameter is enough.
*   It should be executed in task level.
* @param start_frame_no. the start frame that shuld be prepared
* @param end_frame_no. the end frame that shuld be prepared 
* @return None
*/
void video_dec_clr_buffer(kal_uint32 start_frame_no, kal_uint32 end_frame_no)
{
    kal_uint32 index;

    if (kal_if_hisr() == KAL_TRUE)
        EXT_ASSERT(0, 0, 0, 0);
    
    /* Only support these two scenario */
    if( (g_video_dec_buffer_mgr_ptr->cb_info.scenario != VIDEO_DEC_BUFFER_SCENARIO_FILE)
    	&& (g_video_dec_buffer_mgr_ptr->cb_info.scenario != VIDEO_DEC_BUFFER_SCENARIO_EDITOR))
    {
        EXT_ASSERT(0, (kal_uint32)g_video_dec_buffer_mgr_ptr->cb_info.scenario, 0, 0);
    }

    /* set cancel buffer as true first, so that if another task is putting frame to buffer at the same time and task the mutex, 
        it will stop put frame and give mutex */
    g_video_dec_buffer_mgr_ptr->cancel_put_buffer = KAL_TRUE;

    kal_take_mutex(g_video_dec_buffer_mutex);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -