feat:调整缓冲区大小

This commit is contained in:
liyi 2025-05-14 09:09:27 +08:00
parent 38df1883f5
commit 8cdcab24b2
2 changed files with 4 additions and 4 deletions

View File

@ -48,7 +48,7 @@ class VideoDecoder(
companion object { companion object {
private const val TAG = "VideoDecoder" private const val TAG = "VideoDecoder"
private const val TIMEOUT_US = 10000L private const val TIMEOUT_US = 10000L
private const val INPUT_BUFFER_QUEUE_CAPACITY = 7 // 输入缓冲区容量 private const val INPUT_BUFFER_QUEUE_CAPACITY = 15 // 输入缓冲区容量
} }
// region 成员变量定义 // region 成员变量定义
@ -64,7 +64,7 @@ class VideoDecoder(
private val frameSeqSet = Collections.newSetFromMap(ConcurrentHashMap<Int, Boolean>()) // 防止重复帧入队 private val frameSeqSet = Collections.newSetFromMap(ConcurrentHashMap<Int, Boolean>()) // 防止重复帧入队
// 解码输出缓冲区容量为100帧 // 解码输出缓冲区容量为100帧
private val outputFrameQueue = LinkedBlockingQueue<DecodedFrame>(7) private val outputFrameQueue = LinkedBlockingQueue<DecodedFrame>(15)
// 渲染线程控制 // 渲染线程控制
@Volatile private var renderThreadRunning = true @Volatile private var renderThreadRunning = true

View File

@ -46,12 +46,12 @@ class VideoDecoder {
private let inputQueue = DispatchQueue(label: "video_decode_plugin.input.queue", attributes: .concurrent) private let inputQueue = DispatchQueue(label: "video_decode_plugin.input.queue", attributes: .concurrent)
private var inputBuffer: [(frameData: Data, frameType: Int, timestamp: Int64, frameSeq: Int, refIFrameSeq: Int?, sps: Data?, pps: Data?)] = [] private var inputBuffer: [(frameData: Data, frameType: Int, timestamp: Int64, frameSeq: Int, refIFrameSeq: Int?, sps: Data?, pps: Data?)] = []
private let inputBufferSemaphore = DispatchSemaphore(value: 1) private let inputBufferSemaphore = DispatchSemaphore(value: 1)
private let inputBufferMaxCount = 7 private let inputBufferMaxCount = 15
/// 线 /// 线
private let outputQueue = DispatchQueue(label: "video_decode_plugin.output.queue", attributes: .concurrent) private let outputQueue = DispatchQueue(label: "video_decode_plugin.output.queue", attributes: .concurrent)
private var outputBuffer: [(pixelBuffer: CVPixelBuffer, timestamp: Int64)] = [] private var outputBuffer: [(pixelBuffer: CVPixelBuffer, timestamp: Int64)] = []
private let outputBufferSemaphore = DispatchSemaphore(value: 1) private let outputBufferSemaphore = DispatchSemaphore(value: 1)
private let outputBufferMaxCount = 7 private let outputBufferMaxCount = 15
/// 线 /// 线
private var renderThread: Thread? private var renderThread: Thread?
/// 线 /// 线