@@ -146,6 +146,15 @@ bool OHOSVideoDecoder::initDecoder(const OH_AVCodecCategory avCodecCategory) {
146146 LOGE (" video decoder prepare failed!, ret:%d" , ret);
147147 return false ;
148148 }
149+ /* *
150+ * According to HarmonyOS recommendations, temporarily modify the maximum number of hardware
151+ * decoding frames to 16 and the maximum number of software decoding frames to maxReorderSize + 1
152+ * to avoid stuttering on some HarmonyOS devices due to insufficient decoding data. However, this
153+ * modification will increase memory usage. Subsequent adjustments will be made once the
154+ * HarmonyOS system is improved.
155+ */
156+ maxPendingFramesCount =
157+ (codecCategory == HARDWARE) ? 16 : static_cast <size_t >(videoFormat.maxReorderSize ) + 1 ;
149158 if (!start ()) {
150159 LOGE (" video decoder start failed!, ret:%d" , ret);
151160 return false ;
@@ -197,12 +206,8 @@ DecodingResult OHOSVideoDecoder::onDecodeFrame() {
197206 releaseOutputBuffer ();
198207 std::unique_lock<std::mutex> lock (codecUserData->outputMutex );
199208 codecUserData->outputCondition .wait (lock, [this ]() {
200- /* *
201- * According to HarmonyOS recommendations, temporarily modify the maximum frame delivery count to 16 to avoid
202- * freezing issues caused by the lack of decoded data on certain HarmonyOS devices. However, this change will
203- * result in increased memory usage. Once HarmonyOS are improved, appropriate adjustments will be made here.
204- */
205- return codecUserData->outputBufferInfoQueue .size () > 0 || pendingFrames.size () <= 16 ;
209+ return codecUserData->outputBufferInfoQueue .size () > 0 ||
210+ pendingFrames.size () <= maxPendingFramesCount;
206211 });
207212 if (codecUserData->outputBufferInfoQueue .size () > 0 ) {
208213 codecBufferInfo = codecUserData->outputBufferInfoQueue .front ();
0 commit comments