diff --git a/framework/codec/Android/mediaCodecDecoder.cpp b/framework/codec/Android/mediaCodecDecoder.cpp index f186d0ebc..04d579d96 100644 --- a/framework/codec/Android/mediaCodecDecoder.cpp +++ b/framework/codec/Android/mediaCodecDecoder.cpp @@ -193,7 +193,7 @@ namespace Cicada { if (pPacket != nullptr) { AF_LOGI("send Frame mFlushState = 2. pts %" - PRId64, pPacket->getInfo().pts); + PRId64, pPacket->getInfo().pts); } mFlushState = 2; @@ -224,9 +224,18 @@ namespace Cicada { mc_out out{}; mDecoder->get_out(index, &out, false); mVideoInfo.height = 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; + } + mVideoInfo.width = 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; + } + return -EAGAIN; - // TODO: crop info } else if (index >= 0) { mc_out out{}; ret = mDecoder->get_out(index, &out, false); @@ -239,9 +248,9 @@ namespace Cicada { } pFrame = unique_ptr(new AFMediaCodecFrame(IAFFrame::FrameTypeVideo, index, - [this](int index, bool render) { - mDecoder->release_out(index, render); - })); + [this](int index, bool render) { + mDecoder->release_out(index, render); + })); // AF_LOGD("mediacodec out pts %" PRId64, out.buf.pts); pFrame->getInfo().video = mVideoInfo; pFrame->getInfo().pts = out.buf.pts != -1 ? out.buf.pts : INT64_MIN; diff --git a/framework/codec/Android/mediacodec_jni.cpp b/framework/codec/Android/mediacodec_jni.cpp index 3ff3b7e63..022f4b1a7 100644 --- a/framework/codec/Android/mediacodec_jni.cpp +++ b/framework/codec/Android/mediacodec_jni.cpp @@ -127,12 +127,12 @@ namespace Cicada { /* getInteger can throw nullptrPointerException (when fetching the * "channel-mask" property for example) */ if (JniException::clearException(env)) { - return 0; + return MC_ERROR; } return i_ret; } else { - return 0; + return MC_ERROR; } } @@ -251,7 +251,7 @@ namespace Cicada { size_t h264_profile, bool *p_adaptive) { JniEnv jniEnv; - JNIEnv* handle = jniEnv.getEnv(); + JNIEnv *handle = jniEnv.getEnv(); if (!handle) { AF_LOGE("jni attach failed."); @@ -418,7 +418,7 @@ namespace Cicada { int MediaCodec_JNI::init(const char *mime, int category, jobject surface) { JniEnv jniEnv; - JNIEnv* handle = jniEnv.getEnv(); + JNIEnv *handle = jniEnv.getEnv(); if (!handle) { AF_LOGE("env is nullptr."); @@ -443,7 +443,7 @@ namespace Cicada { AndroidJniHandle joutput_buffers; jobject jbuffer_info; JniEnv jniEnv; - JNIEnv* handle = jniEnv.getEnv(); + JNIEnv *handle = jniEnv.getEnv(); if (!handle) { AF_LOGE("env is nullptr."); @@ -497,7 +497,7 @@ namespace Cicada { int MediaCodec_JNI::stop() { JniEnv jniEnv; - JNIEnv* handle = jniEnv.getEnv(); + JNIEnv *handle = jniEnv.getEnv(); if (!handle) { AF_LOGE("env is nullptr."); @@ -537,7 +537,7 @@ namespace Cicada { int MediaCodec_JNI::flush() { JniEnv jniEnv; - JNIEnv* handle = jniEnv.getEnv(); + JNIEnv *handle = jniEnv.getEnv(); if (!handle) { AF_LOGE("env is nullptr."); @@ -557,7 +557,7 @@ namespace Cicada { int MediaCodec_JNI::dequeue_in(int64_t timeout) { JniEnv jniEnv; - JNIEnv* handle = jniEnv.getEnv(); + JNIEnv *handle = jniEnv.getEnv(); if (!handle) { AF_LOGE("env is nullptr."); @@ -587,7 +587,7 @@ namespace Cicada { } JniEnv jniEnv; - JNIEnv* handle = jniEnv.getEnv(); + JNIEnv *handle = jniEnv.getEnv(); if (!handle) { AF_LOGE("env is nullptr."); @@ -648,7 +648,7 @@ namespace Cicada { int MediaCodec_JNI::dequeue_out(int64_t timeout) { JniEnv jniEnv; - JNIEnv* handle = jniEnv.getEnv(); + JNIEnv *handle = jniEnv.getEnv(); if (!handle) { AF_LOGE("env is nullptr."); @@ -678,7 +678,7 @@ namespace Cicada { int MediaCodec_JNI::get_out(int index, mc_out *out, bool readBuffer) { JniEnv jniEnv; - JNIEnv* handle = jniEnv.getEnv(); + JNIEnv *handle = jniEnv.getEnv(); if (!handle) { AF_LOGE("env is nullptr."); @@ -794,7 +794,7 @@ namespace Cicada { { bool b_adaptive; JniEnv jniEnv; - JNIEnv* handle = jniEnv.getEnv(); + JNIEnv *handle = jniEnv.getEnv(); std::string psz_name = mediaCodecGetName(psz_mime, args, i_h264_profile, &b_adaptive); AF_LOGI("android decode name %s, b_adaptive %d", psz_name.c_str(), b_adaptive); @@ -868,7 +868,7 @@ namespace Cicada { void MediaCodec_JNI::unInit() { JniEnv jniEnv; - JNIEnv* handle = jniEnv.getEnv(); + JNIEnv *handle = jniEnv.getEnv(); if (!handle) { AF_LOGE("env is nullptr."); @@ -890,7 +890,7 @@ namespace Cicada { int MediaCodec_JNI::setOutputSurface(jobject surface) { JniEnv jniEnv; - JNIEnv* handle = jniEnv.getEnv(); + JNIEnv *handle = jniEnv.getEnv(); if (!handle) { AF_LOGE("env is nullptr."); @@ -914,7 +914,7 @@ namespace Cicada { } JniEnv jniEnv; - JNIEnv* handle = jniEnv.getEnv(); + JNIEnv *handle = jniEnv.getEnv(); if (!handle) { AF_LOGE("env is nullptr.");