From e4316f009c3c403b7b913802ed7a4a77c5fa283c Mon Sep 17 00:00:00 2001 From: Lakshmi Kumar Date: Wed, 20 Mar 2024 05:25:00 -0700 Subject: [PATCH] Sample Bug Fix - Batch sync issue (#289) * bug fix for new dec creation * move bit depth change after creating new dec * codec update for every new dec * bug fix for new dec creation * move bit depth change after creating new dec * codec update for every new dec * fixes sync issue on MI250X for batch sample * remove unused variable --- samples/videoDecodeBatch/videodecodebatch.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/samples/videoDecodeBatch/videodecodebatch.cpp b/samples/videoDecodeBatch/videodecodebatch.cpp index 9857f5c370..0e46340ef0 100644 --- a/samples/videoDecodeBatch/videodecodebatch.cpp +++ b/samples/videoDecodeBatch/videodecodebatch.cpp @@ -119,7 +119,6 @@ void DecProc(RocVideoDecoder *p_dec, VideoDemuxer *demuxer, int *pn_frame, doubl int64_t pts = 0; double total_dec_time = 0.0; OutputSurfaceInfo *surf_info; - decoding_complete = false; auto start_time = std::chrono::high_resolution_clock::now(); do { demuxer->Demux(&p_video, &n_video_bytes, &pts); @@ -345,10 +344,16 @@ int main(int argc, char **argv) { std::right << std::hex << pci_domain_id << "." << pci_device_id << std::dec << std::endl; } + std::mutex mutex; + for (int j = 0; j < num_files; j++) { int thread_idx = j % n_thread; if (j >= n_thread) { - while (!v_dec_info[thread_idx]->decoding_complete); + { + std::unique_lock lock(mutex); + while (!v_dec_info[thread_idx]->decoding_complete); + v_dec_info[thread_idx]->decoding_complete = false; + } uint32_t bit_depth = v_demuxer[j]->GetBitDepth(); rocDecVideoCodec codec_id = AVCodec2RocDecVideoCodec(v_demuxer[j]->GetCodecID()); if (v_dec_info[thread_idx]->bit_depth != bit_depth || v_dec_info[thread_idx]->rocdec_codec_id != codec_id) {