From 5724fb0b1cdbb8971ec31123b11a306da8938b6f Mon Sep 17 00:00:00 2001 From: Lakshmi Kumar Date: Wed, 19 Feb 2025 14:19:49 -0800 Subject: [PATCH] Bug fix - videoToSequence sample (#514) * rocm version check for targets * fix sample * cmake merge with develop * address reciew comments * comment update [ROCm/rocdecode commit: e9f9aa9f5824ae8648feaf5fba8021ae1ec1e5ac] --- projects/rocdecode/samples/common.h | 2 +- .../rocdecode/samples/videoToSequence/videotosequence.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/projects/rocdecode/samples/common.h b/projects/rocdecode/samples/common.h index eebfe39339..13dffea2a5 100644 --- a/projects/rocdecode/samples/common.h +++ b/projects/rocdecode/samples/common.h @@ -67,7 +67,7 @@ int ReconfigureFlushCallback(void *p_viddec_obj, uint32_t flush_mode, void *p_us } // release and flush frame viddec->ReleaseFrame(pts, true); - n_frames_flushed ++; + n_frames_flushed++; } return n_frames_flushed; diff --git a/projects/rocdecode/samples/videoToSequence/videotosequence.cpp b/projects/rocdecode/samples/videoToSequence/videotosequence.cpp index 40e10ffff1..3842570fd4 100644 --- a/projects/rocdecode/samples/videoToSequence/videotosequence.cpp +++ b/projects/rocdecode/samples/videoToSequence/videotosequence.cpp @@ -165,7 +165,6 @@ void DecProc(RocVideoDecoder *p_dec, VideoDemuxer *demuxer, int *pn_frame, doubl n_frame = static_cast (pts * demuxer->GetFrameRate()); // start frame number seq_start = false; p_dec->FlushAndReconfigure(); - } else { demuxer->Demux(&p_video, &n_video_bytes, &pts); } @@ -175,8 +174,8 @@ void DecProc(RocVideoDecoder *p_dec, VideoDemuxer *demuxer, int *pn_frame, doubl std::cerr << "Error: Failed to get Output Surface Info!" << std::endl; break; } - for (int i = 0; i < n_frame_returned; i++) { - if ((n_frame + i) == next_frame_num) { + for (int i = 0; i < n_frame_returned; i++) { + if ((n_frame + i) == next_frame_num) { p_frame = p_dec->GetFrame(&pts); if (n_frame_seq < seq_info.seq_length) { p_dec->SaveFrameToFile(seq_output_file_name, p_frame, surf_info); @@ -201,6 +200,8 @@ void DecProc(RocVideoDecoder *p_dec, VideoDemuxer *demuxer, int *pn_frame, doubl seq_output_file_name = p_output_file_name[num_seq]; } p_dec->ResetSaveFrameToFile(); + // needed to flush last sequence frames before decoding the next sequence by passing EOS to parser + n_frame_returned = p_dec->DecodeFrame(nullptr, 0, ROCDEC_PKT_ENDOFSTREAM, -1); } } while (n_video_bytes && num_seq < seq_info.batch_size);