Skip to content

Commit 62151aa

Browse files
committed
Modify the maximum number of software decoding sending frames to maxReorderSize + 1 for HarmonyOS. (#2751)
(cherry picked from commit 9696b0c)
1 parent ece7b58 commit 62151aa

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/platform/ohos/OHOSVideoDecoder.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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();

src/platform/ohos/OHOSVideoDecoder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class OHOSVideoDecoder : public VideoDecoder {
9797
int64_t yBufferSize = 0;
9898
int64_t uvBufferSize = 0;
9999
std::weak_ptr<OHOSVideoDecoder> weakThis;
100+
size_t maxPendingFramesCount = 0;
100101

101102
explicit OHOSVideoDecoder(const VideoFormat& format, bool hardware);
102103
bool initDecoder(const OH_AVCodecCategory avCodecCategory);

0 commit comments

Comments
 (0)