Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/android vapx loop #119

Merged
merged 2 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class HardDecoder(player: AnimPlayer) : Decoder(player), SurfaceTexture.OnFrameA
var outputDone = false
var inputDone = false
var frameIndex = 0
var isLoop = false

val decoderInputBuffers = decoder.inputBuffers

Expand Down Expand Up @@ -256,7 +257,7 @@ class HardDecoder(player: AnimPlayer) : Decoder(player), SurfaceTexture.OnFrameA
// release & render
decoder.releaseOutputBuffer(decoderStatus, doRender && !needYUV)

if (frameIndex == 0) {
if (frameIndex == 0 && !isLoop) {
onVideoStart()
}
player.pluginManager.onDecoding(frameIndex)
Expand All @@ -266,11 +267,13 @@ class HardDecoder(player: AnimPlayer) : Decoder(player), SurfaceTexture.OnFrameA
ALog.d(TAG, "decode frameIndex=$frameIndex")
if (loop > 0) {
ALog.d(TAG, "Reached EOD, looping")
player.pluginManager.onLoopStart()
extractor.seekTo(0, MediaExtractor.SEEK_TO_CLOSEST_SYNC)
inputDone = false
decoder.flush()
speedControlUtil.reset()
frameIndex = 1
frameIndex = 0
isLoop = true
}
if (outputDone) {
release(decoder, extractor)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Tencent is pleased to support the open source community by making vap available.
*
* Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tencent.qgame.animplayer.file

import android.annotation.TargetApi
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Tencent is pleased to support the open source community by making vap available.
*
* Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tencent.qgame.animplayer.file

import android.annotation.TargetApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AnimPluginManager(val player: AnimPlayer) {
// 当前渲染的帧
private var frameIndex = 0
// 当前解码的帧
private var decodeIndex = 1
private var decodeIndex = 0
// 帧不相同的次数, 连续多次不同则直接使用decodeIndex
private var frameDiffTimes = 0

Expand All @@ -66,6 +66,7 @@ class AnimPluginManager(val player: AnimPlayer) {
fun onRenderCreate() {
ALog.i(TAG, "onRenderCreate")
frameIndex = 0
decodeIndex = 0
plugins.forEach {
it.onRenderCreate()
}
Expand All @@ -79,6 +80,13 @@ class AnimPluginManager(val player: AnimPlayer) {
}
}

// 开始循环调用
fun onLoopStart() {
ALog.i(TAG, "onLoopStart")
frameIndex = 0
decodeIndex = 0
}

fun onRendering() {
if (decodeIndex > frameIndex + 1 || frameDiffTimes >= DIFF_TIMES) {
ALog.i(TAG, "jump frameIndex= $frameIndex,decodeIndex=$decodeIndex,frameDiffTimes=$frameDiffTimes")
Expand Down