Skip to content

Commit a2e1bf1

Browse files
* Decode output dumping improvement: Better condition check for new dump file creation. (#606)
- Coded video size change was used as one of conditions to create a new file when dumping decode output. When a stream has coded video size change but the display size does not change, there is no need to dump the decoded frames into a new file. - Now we replace the coded size check with display size check to avoid unnecessary new dump file creation. Co-authored-by: Aryan Salmanpour <[email protected]>
1 parent 9283abc commit a2e1bf1

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

utils/ffmpegvideodecode/ffmpeg_video_dec.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ int FFMpegVideoDecoder::ReconfigureDecoder(RocdecVideoFormat *p_video_format) {
394394
target_width_ = (crop_rect_.right - crop_rect_.left + 1) & ~1;
395395
target_height_ = (crop_rect_.bottom - crop_rect_.top + 1) & ~1;
396396
}
397+
is_output_surface_changed_ = true;
397398
}
398399

399400
surface_stride_ = target_width_ * byte_per_pixel_;
@@ -432,7 +433,6 @@ int FFMpegVideoDecoder::ReconfigureDecoder(RocdecVideoFormat *p_video_format) {
432433
<< "\tDisplay area : [" << p_video_format->display_area.left << ", " << p_video_format->display_area.top << ", "
433434
<< p_video_format->display_area.right << ", " << p_video_format->display_area.bottom << "]" << std::endl;
434435
input_video_info_str_ << std::endl;
435-
is_decoder_reconfigured_ = true;
436436
return 1;
437437
}
438438

@@ -838,7 +838,7 @@ void FFMpegVideoDecoder::SaveFrameToFile(std::string output_file_name, void *sur
838838
}
839839

840840
// don't overwrite to the same file if reconfigure is detected for a resolution changes.
841-
if (is_decoder_reconfigured_) {
841+
if (is_output_surface_changed_) {
842842
if (fp_out_) {
843843
fclose(fp_out_);
844844
fp_out_ = nullptr;
@@ -856,7 +856,7 @@ void FFMpegVideoDecoder::SaveFrameToFile(std::string output_file_name, void *sur
856856
output_file_name += to_append;
857857
}
858858
}
859-
is_decoder_reconfigured_ = false;
859+
is_output_surface_changed_ = false;
860860
}
861861

862862
if (fp_out_ == nullptr) {

utils/rocvideodecode/roc_video_dec.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ int RocVideoDecoder::ReconfigureDecoder(RocdecVideoFormat *p_video_format) {
587587
// If the coded_width or coded_height hasn't changed but display resolution has changed, then need to update width and height for
588588
// correct output with cropping. There is no need to reconfigure the decoder.
589589
if (!is_decode_res_changed && is_display_rect_changed && !is_bit_depth_changed && !is_dec_surface_num_changed) {
590+
is_output_surface_changed_ = true;
590591
return 1;
591592
}
592593

@@ -642,8 +643,8 @@ int RocVideoDecoder::ReconfigureDecoder(RocdecVideoFormat *p_video_format) {
642643
input_video_info_str_ << std::endl;
643644
std::cout << input_video_info_str_.str();
644645

645-
if (is_decode_res_changed || is_bit_depth_changed) {
646-
is_decoder_reconfigured_ = true;
646+
if (is_display_rect_changed || is_bit_depth_changed) {
647+
is_output_surface_changed_ = true;
647648
}
648649
return 1;
649650
}
@@ -957,15 +958,15 @@ void RocVideoDecoder::SaveFrameToFile(std::string output_file_name, void *surf_m
957958
current_output_filename = output_file_name;
958959
}
959960

960-
// don't overwrite to the same file if reconfigure is detected for a resolution changes.
961-
if (is_decoder_reconfigured_) {
961+
// don't overwrite to the same file if reconfigure is detected for a resolution/bit depth changes.
962+
if (is_output_surface_changed_) {
962963
if (fp_out_) {
963964
fclose(fp_out_);
964965
fp_out_ = nullptr;
965966
}
966-
// Append the width and height of the new stream to the old file name to create a file name to save the new frames
967-
// do this only if resolution changes within a stream (e.g., decoding a multi-resolution stream using the videoDecode app)
968-
// don't append to the output_file_name if multiple output file name is provided (e.g., decoding multi-files using the videDecodeMultiFiles)
967+
// Append the width and height of the new sequence to the old file name to create a file name to save the new frames
968+
// Do this only if resolution/bit depth changes within a stream (e.g., decoding a multi-resolution stream using the videoDecode app)
969+
// Don't append to the output_file_name if multiple output file name is provided (e.g., decoding multi-files using the videDecodeMultiFiles)
969970
if (!current_output_filename.compare(output_file_name)) {
970971
std::string::size_type const pos(output_file_name.find_last_of('.'));
971972
extra_output_file_count_++;
@@ -976,7 +977,7 @@ void RocVideoDecoder::SaveFrameToFile(std::string output_file_name, void *surf_m
976977
output_file_name += to_append;
977978
}
978979
}
979-
is_decoder_reconfigured_ = false;
980+
is_output_surface_changed_ = false;
980981
}
981982

982983
if (fp_out_ == nullptr) {

utils/rocvideodecode/roc_video_dec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ class RocVideoDecoder {
522522
Rect crop_rect_ = {}; // user specified region of interest within diplayable area disp_rect_
523523
FILE *fp_sei_ = NULL;
524524
FILE *fp_out_ = NULL;
525-
bool is_decoder_reconfigured_ = false;
525+
bool is_output_surface_changed_ = false;
526526
std::string current_output_filename = "";
527527
uint32_t extra_output_file_count_ = 0;
528528
std::thread::id decoder_session_id_; // Decoder session identifier. Used to gather session level stats.

0 commit comments

Comments
 (0)