/* ------------------------------------------------------------------
* Copyright (C) 1998-2009 PacketVideo
*
* 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.
* -------------------------------------------------------------------
*/
#include "mp4dec_lib.h"
#include "vlc_decode.h"
#include "bitstream.h"
#define OSCL_DISABLE_WARNING_CONDITIONAL_IS_CONSTANT
#include "osclconfig_compiler_warnings.h"
#ifdef DEC_INTERNAL_MEMORY_OPT
#define QCIF_MBS 99
#define QCIF_BS (4*QCIF_MBS)
#define QCIF_MB_ROWS 11
extern uint8 IMEM_sliceNo[QCIF_MBS];
extern uint8 IMEM_acPredFlag[QCIF_MBS];
extern uint8 IMEM_headerInfo_Mode[QCIF_MBS];
extern uint8 IMEM_headerInfo_CBP[QCIF_MBS];
extern int IMEM_headerInfo_QPMB[QCIF_MBS];
extern MacroBlock IMEM_mblock;
extern MOT IMEM_motX[QCIF_BS];
extern MOT IMEM_motY[QCIF_BS];
extern BitstreamDecVideo IMEM_BitstreamDecVideo[4];
extern typeDCStore IMEM_predDC[QCIF_MBS];
extern typeDCACStore IMEM_predDCAC_col[QCIF_MB_ROWS+1];
extern VideoDecData IMEM_VideoDecData[1];
extern Vop IMEM_currVop[1];
extern Vop IMEM_prevVop[1];
extern PIXEL IMEM_currVop_yChan[QCIF_MBS*128*3];
extern PIXEL IMEM_prevVop_yChan[QCIF_MBS*128*3];
extern uint8 IMEM_pstprcTypCur[6*QCIF_MBS];
extern uint8 IMEM_pstprcTypPrv[6*QCIF_MBS];
extern Vop IMEM_vopHEADER[2];
extern Vol IMEM_VOL[2];
extern Vop IMEM_vopHeader[2][1];
extern Vol IMEM_vol[2][1];
#endif
/* ======================================================================== */
/* Function : PVInitVideoDecoder() */
/* Date : 04/11/2000, 08/29/2000 */
/* Purpose : Initialization of the MPEG-4 video decoder library. */
/* The return type is Bool instead of PV_STATUS because */
/* we don't want to expose PV_STATUS to (outside) programmers */
/* that use our decoder library SDK. */
/* In/out : */
/* Return : PV_TRUE if successed, PV_FALSE if failed. */
/* Modified : */
/* ======================================================================== */
OSCL_EXPORT_REF Bool PVInitVideoDecoder(VideoDecControls *decCtrl, uint8 *volbuf[],
int32 *volbuf_size, int nLayers, int width, int height, MP4DecodingMode mode)
{
VideoDecData *video = (VideoDecData *) decCtrl->videoDecoderData;
Bool status = PV_TRUE;
int idx;
BitstreamDecVideo *stream;
oscl_memset(decCtrl, 0, sizeof(VideoDecControls)); /* fix a size bug. 03/28/2001 */
decCtrl->nLayers = nLayers;
for (idx = 0; idx < nLayers; idx++)
{
decCtrl->volbuf[idx] = volbuf[idx];
decCtrl->volbuf_size[idx] = volbuf_size[idx];
}
/* memory allocation & initialization */
#ifdef DEC_INTERNAL_MEMORY_OPT
video = IMEM_VideoDecData;
#else
video = (VideoDecData *) oscl_malloc(sizeof(VideoDecData));
#endif
if (video != NULL)
{
oscl_memset(video, 0, sizeof(VideoDecData));
video->memoryUsage = sizeof(VideoDecData);
video->numberOfLayers = nLayers;
#ifdef DEC_INTERNAL_MEMORY_OPT
video->vol = (Vol **) IMEM_VOL;
#else
video->vol = (Vol **) oscl_malloc(nLayers * sizeof(Vol *));
#endif
if (video->vol == NULL) status = PV_FALSE;
video->memoryUsage += nLayers * sizeof(Vol *);
/* we need to setup this pointer for the application to */
/* pass it around. */
decCtrl->videoDecoderData = (void *) video;
video->videoDecControls = decCtrl; /* yes. we have a cyclic */
/* references here :) */
/* Allocating Vop space, this has to change when we add */
/* spatial scalability to the decoder */
#ifdef DEC_INTERNAL_MEMORY_OPT
video->currVop = IMEM_currVop;
if (video->currVop == NULL) status = PV_FALSE;
else oscl_memset(video->currVop, 0, sizeof(Vop));
video->prevVop = IMEM_prevVop;
if (video->prevVop == NULL) status = PV_FALSE;
else oscl_memset(video->prevVop, 0, sizeof(Vop));
video->memoryUsage += (sizeof(Vop) * 2);
video->vopHeader = (Vop **) IMEM_vopHEADER;
#else
video->currVop = (Vop *) oscl_malloc(sizeof(Vop));
if (video->currVop == NULL) status = PV_FALSE;
else oscl_memset(video->currVop, 0, sizeof(Vop));
video->prevVop = (Vop *) oscl_malloc(sizeof(Vop));
if (video->prevVop == NULL) status = PV_FALSE;
else oscl_memset(video->prevVop, 0, sizeof(Vop));
video->memoryUsage += (sizeof(Vop) * 2);
video->vopHeader = (Vop **) oscl_malloc(sizeof(Vop *) * nLayers);
#endif
if (video->vopHeader == NULL) status = PV_FALSE;
else oscl_memset(video->vopHeader, 0, sizeof(Vop *)*nLayers);
video->memoryUsage += (sizeof(Vop *) * nLayers);
video->initialized = PV_FALSE;
/* Decode the header to get all information to allocate data */
if (status == PV_TRUE)
{
/* initialize decoded frame counter. 04/24/2001 */
video->frame_idx = -1;
for (idx = 0; idx < nLayers; idx++)
{
#ifdef DEC_INTERNAL_MEMORY_OPT
video->vopHeader[idx] = IMEM_vopHeader[idx];
#else
video->vopHeader[idx] = (Vop *) oscl_malloc(sizeof(Vop));
#endif
if (video->vopHeader[idx] == NULL)
{
status = PV_FALSE;
break;
}
else
{
oscl_memset(video->vopHeader[idx], 0, sizeof(Vop));
video->vopHeader[idx]->timeStamp = 0;
video->memoryUsage += (sizeof(Vop));
}
#ifdef DEC_INTERNAL_MEMORY_OPT
video->vol[idx] = IMEM_vol[idx];
video->memoryUsage += sizeof(Vol);
oscl_memset(video->vol[idx], 0, sizeof(Vol));
if (video->vol[idx] == NULL) status = PV_FALSE;
stream = IMEM_BitstreamDecVideo;
#else
video->vol[idx] = (Vol *) oscl_malloc(sizeof(Vol));
if (video->vol[idx] == NULL)
{
status = PV_FALSE;
break;
}
else
{
video->memoryUsage += sizeof(Vol);
oscl_memset(video->vol[idx], 0, sizeof(Vol));
}
stream = (BitstreamDecVideo *) oscl_malloc(sizeof(BitstreamDecVideo));
#endif
video->memoryUsage += sizeof(BitstreamDecVideo);
if (stream == NULL)
{
status = PV_FALSE;
break;
}
else
{
int32 buffer_size;
if ((buffer_size = BitstreamOpen(stream, idx)) < 0)
{
mp4dec_log("InitVideoDecoder(): Can't allocate bitstream buffer.\n");
h263dec.rar_linux h263
版权申诉
165 浏览量
2022-09-24
19:03:04
上传
评论
收藏 162KB RAR 举报
周楷雯
- 粉丝: 80
- 资源: 1万+
最新资源
- 优先编码器除法电微分运算电路 全加器函数发生电路等电路经典Multisim仿真实验源文件合集(25个).zip
- 2331308JS课堂案例.zip
- STM32H750VBT6单片机最小系统开发板AD设计硬件(原理图+PCB+3D封装库)工程文件.zip
- 基于74LS161+ 74LS192芯片实现倒计时定时器Multisim仿真源文件,Multisim10以上版本可打开运行
- 科大讯飞语音引擎 jar包 demo,科大讯飞语音合成引擎3.0,支持4.0系统以上,文字转语音输出.zip
- Java架构面试笔试专题资料及经验(含答案)SpringBoot面试Linux面试专题及答案 合集.zip
- 头歌c语言实验答案tion-model-for-ne开发笔记
- docker配置使用-model-for-networK开发demo
- docker配置使用vaWeb-mas笔记
- c语言连接两个字符串-mas开发笔记
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈