SPRDMP3Decoder::SPRDMP3Decoder( const char *name, const OMX_CALLBACKTYPE *callbacks, OMX_PTR appData, OMX_COMPONENTTYPE **component) : SprdSimpleOMXComponent(name, callbacks, appData, component), mNumChannels(2), mSamplingRate(44100), mBitRate(0), mNextMdBegin(0), mPreFilledLen(0), mMaxFrameBuf(NULL), mLastInTimeUs(0), mAnchorTimeUs(0), mNumFramesOutput(0), mEOSFlag(false), mSignalledError(false), mLibHandle(NULL), mOutputPortSettingsChange(NONE), mMP3_ARM_DEC_Construct(NULL), mMP3_ARM_DEC_Deconstruct(NULL), mMP3_ARM_DEC_InitDecoder(NULL), mMP3_ARM_DEC_DecodeFrame(NULL) { bool ret = false; ret = openDecoder("libomx_mp3dec_sprd.so"); CHECK_EQ(ret, true); initPorts(); initDecoder(); }
bool OMXAudioPlayer::open(StreamInfo& hints, OMXClock *av_clock, OMXReader *omx_reader, std::string device) { if(ThreadHandle()) { close(); } if (!av_clock) { return false; } omxStreamInfo = hints; omxClock = av_clock; omxReader = omx_reader; deviceName = device; currentPTS = DVD_NOPTS_VALUE; doAbort = false; doFlush = false; cachedSize = 0; audioCodecOMX = NULL; channelMap = NULL; speed = DVD_PLAYSPEED_NORMAL; // omxClock->SetMasterClock(false); bool success = openCodec(); if(!success) { ofLogError(__func__) << "openCodec: " << success; close(); return success; } success = openDecoder(); if(!success) { ofLogError(__func__) << "openDecoder: " << success; close(); return success; } Create(); isOpen = true; return true; }
bool SoundSourceM4A::reopenDecoder() { closeDecoder(); return openDecoder(); }
int getFrameAt(int64_t timeUs, int width, int height) { int ret = -1; AVFrame* pFrame = NULL; ret = avformat_seek_file(m_pFormatContext, -1, INT16_MIN, timeUs, INT16_MAX, 0); pFrame = av_frame_alloc(); m_pThumbFrame = av_frame_alloc(); ret = openDecoder(); if (ret != 0) { av_frame_free(&pFrame); av_frame_free(&m_pThumbFrame); return ret; } #ifdef DEBUG_SPEND_TIME #ifdef _WIN32 DWORD start_time = timeGetTime(); #else struct timeval start, end; gettimeofday(&start, NULL); #endif #endif ret = decodeOneFrame(pFrame); if (ret < 0) { av_frame_free(&pFrame); av_frame_free(&m_pThumbFrame); return ret; } #ifdef DEBUG_SPEND_TIME #ifdef _WIN32 DWORD end_time = timeGetTime(); printf("decodeOneFrame spend time = %d ms\n", end_time - start_time); #else gettimeofday(&end, NULL); int spend_time = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_usec - start.tv_usec) / 1000; printf("spend_time = %d ms\n", spend_time); #endif #endif ret = getThumbnail(pFrame, m_pThumbFrame, width, height); if (ret < 0) { av_frame_free(&pFrame); av_frame_free(&m_pThumbFrame); return ret; } // save the rgb565 FILE *pFile = fopen(strThumbFileName, "ab"); if (pFile) { fwrite(m_pThumbFrame->data[0], 1, m_pThumbFrame->width * m_pThumbFrame->height * 2, pFile); fclose(pFile); } av_frame_free(&pFrame); av_frame_free(&m_pThumbFrame); closeDecoder(); return ret; }