美羊羊的配音演员视频:stagefright简单流程

来源:百度文库 编辑:中财网 时间:2024/05/05 01:25:24
以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, ×tamp, &bufferSize,
                &useExtTimestamp,
                (uint8_t *)mFrames[mNumSamplesOutput & 0x01]->data())
            != PV_TRUE) {
        LOGE("failed to decode video frame.");

        inputBuffer->release();
        inputBuffer = NULL;

        return UNKNOWN_ERROR;
    }
    ...
}