Skip to content

Commit

Permalink
StVideoQueue - try opening vp9/hevc MediaCodec hardware decoders
Browse files Browse the repository at this point in the history
  • Loading branch information
gkv311 committed Aug 2, 2020
1 parent 3b943e7 commit c49a72a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion StMoviePlayer/StMoviePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void StMoviePlayer::updateStrings() {
#if defined(_WIN32)
const StCString aGpuAcc = stCString(" (DXVA2)");
#elif defined(__APPLE__)
const StCString aGpuAcc = stCString(" (VDA)");
const StCString aGpuAcc = stCString(" (VideoToolbox)");
#elif defined(__ANDROID__)
const StCString aGpuAcc = stCString(""); //stCString(" (Android Media Codec)");
#else
Expand Down
12 changes: 10 additions & 2 deletions StMoviePlayer/StVideo/StVideoQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ StVideoQueue::StVideoQueue(const StHandle<StGLTextureQueue>& theTextureQueue,
myMaster(theMaster),
#if defined(__ANDROID__)
myCodecH264HW(avcodec_find_decoder_by_name("h264_mediacodec")),
myCodecHevcHW(avcodec_find_decoder_by_name("hevc_mediacodec")),
myCodecVp9HW (avcodec_find_decoder_by_name("vp9_mediacodec")),
#endif
myCodecOpenJpeg(avcodec_find_decoder_by_name("libopenjpeg")),
myUseGpu(false),
Expand Down Expand Up @@ -358,9 +360,15 @@ bool StVideoQueue::init(AVFormatContext* theFormatCtx,
#if defined(__ANDROID__)
AVCodec* aCodecGpu = NULL;
if(myUseGpu
&& StString(myCodecAuto->name).isEquals(stCString("h264"))
&& myCodecCtx->pix_fmt == stAV::PIX_FMT::YUV420P) {
aCodecGpu = myCodecH264HW;
const StString anAutoCodecName(myCodecAuto->name);
if(anAutoCodecName.isEquals(stCString("h264"))) {
aCodecGpu = myCodecH264HW;
} else if(anAutoCodecName.isEquals(stCString("hevc"))) {
aCodecGpu = myCodecHevcHW;
} else if(anAutoCodecName.isEquals(stCString("vp9"))) {
aCodecGpu = myCodecVp9HW;
}
}

if(aCodecGpu != NULL) {
Expand Down
4 changes: 3 additions & 1 deletion StMoviePlayer/StVideo/StVideoQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,9 @@ class StVideoQueue : public StAVPacketQueue {

StHandle<StHWAccelContext> myHWAccelCtx;
#if defined(__ANDROID__)
AVCodec* myCodecH264HW; //!< h264 decoder using dedicated hardware (VDA codec on OS X; Android Media Codec)
AVCodec* myCodecH264HW; //!< h264 decoder using dedicated hardware (Android Media Codec)
AVCodec* myCodecHevcHW; //!< hevc decoder using dedicated hardware
AVCodec* myCodecVp9HW; //!< vp9 decoder using dedicated hardware
#endif
AVCodec* myCodecOpenJpeg; //!< libopenjpeg decoder
bool myUseGpu; //!< activate decoding on GPU when possible
Expand Down

0 comments on commit c49a72a

Please sign in to comment.