opencore android,stagefright与opencore对比 - Android - 韵寒书香

以mp4decoder为例,大概流程如下:

1 AwesomePlayer::initVideoDecoder()

mVideoSource = OMXCodec::Create(...)

2 OMXCodec::Create()

实际会执行下面代码

#if BUILD_WITH_FULL_STAGEFRIGHT

sp softwareCodec =

InstantiateSoftwareCodec(componentName, source);

#endif

FACTORY_CREATE(MP3Decoder)

FACTORY_CREATE(AMRNBDecoder)

FACTORY_CREATE(AMRWBDecoder)

FACTORY_CREATE(AACDecoder)

FACTORY_CREATE(AVCDecoder)

FACTORY_CREATE(M4vH263Decoder)

FACTORY_CREATE(VorbisDecoder)

FACTORY_CREATE(AMRNBEncoder)

上述decoder里找不到时,会执行如下部分,下面代码才是调到opencore的omx部分

status_t err = omx->allocateNode(componentName, observer, &node);

if (err == OK) {

LOGV("Successfully allocated OMX node '%s'", componentName);

sp codec = new OMXCodec(

omx, node, getComponentQuirks(componentName),

createEncoder, mime, componentName,

source);

observer->setCodec(codec);

err = codec->configureCodec(meta);

if (err == OK) {

return codec;

}

LOGV("Failed to configure codec '%s'", componentName);

}

3 关于read函数

实际read时,先读取数据再调用解码,这一点是与opencore处理机制不同的,如果系统采用软解码,要考虑read加decode作为一个原子执行是否会影响效率,如果decode部分有硬解码则到无妨。

status_t M4vH263Decoder::read(MediaBuffer **out, const ReadOptions *options) {

...

status_t err = mSource->read(&inputBuffer, options);

...

if (PVDecodeVideoFrame(

mHandle, &bitstream, &timestamp, &bufferSize,

&useExtTimestamp,

(uint8_t *)mFrames[mNumSamplesOutput & 0x01]->data())

!= PV_TRUE) {

LOGE("failed to decode video frame.");

inputBuffer->release();

inputBuffer = NULL;

return UNKNOWN_ERROR;

}

...

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值