From 400049c53ea2effa41a401a3ad3b58db59064d10 Mon Sep 17 00:00:00 2001 From: lifujun <814084764@qq.com> Date: Tue, 2 Jun 2020 11:37:09 +0800 Subject: [PATCH] fix(mediacodec): reset width and height to videoInfo --- framework/codec/Android/mediaCodecDecoder.cpp | 12 +++++++----- framework/codec/Android/mediaCodecDecoder.h | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/framework/codec/Android/mediaCodecDecoder.cpp b/framework/codec/Android/mediaCodecDecoder.cpp index 1e336cbce..a242ebe46 100644 --- a/framework/codec/Android/mediaCodecDecoder.cpp +++ b/framework/codec/Android/mediaCodecDecoder.cpp @@ -227,16 +227,16 @@ namespace Cicada { } else if (index == MC_INFO_OUTPUT_FORMAT_CHANGED) { mc_out out{}; mDecoder->get_out(index, &out, false); - mVideoInfo.height = out.conf.video.height; + mVideoHeight = out.conf.video.height; if (out.conf.video.crop_bottom != MC_ERROR && out.conf.video.crop_top != MC_ERROR) { - mVideoInfo.height = out.conf.video.crop_bottom + 1 - out.conf.video.crop_top; + mVideoHeight = out.conf.video.crop_bottom + 1 - out.conf.video.crop_top; } - mVideoInfo.width = out.conf.video.width; + mVideoWidth = out.conf.video.width; if (out.conf.video.crop_right != MC_ERROR && out.conf.video.crop_left != MC_ERROR) { - mVideoInfo.width = out.conf.video.crop_right + 1 - out.conf.video.crop_left; + mVideoWidth = out.conf.video.crop_right + 1 - out.conf.video.crop_left; } return -EAGAIN; @@ -256,7 +256,9 @@ namespace Cicada { mDecoder->release_out(index, render); })); // AF_LOGD("mediacodec out pts %" PRId64, out.buf.pts); - pFrame->getInfo().video = mVideoInfo; + pFrame->getInfo().video.width = mVideoWidth; + pFrame->getInfo().video.height = mVideoHeight; + pFrame->getInfo().pts = out.buf.pts != -1 ? out.buf.pts : INT64_MIN; if (out.b_eos) { diff --git a/framework/codec/Android/mediaCodecDecoder.h b/framework/codec/Android/mediaCodecDecoder.h index 59997ab07..6a6484c0e 100644 --- a/framework/codec/Android/mediaCodecDecoder.h +++ b/framework/codec/Android/mediaCodecDecoder.h @@ -65,7 +65,8 @@ namespace Cicada{ static mediaCodecDecoder se; private: - IAFFrame::videoInfo mVideoInfo{}; + int mVideoWidth{0}; + int mVideoHeight{0}; mediaCodec *mDecoder{nullptr}; std::recursive_mutex mFuncEntryMutex;