From 445d13b73b28538c8a101b8d9bd519da550e190f Mon Sep 17 00:00:00 2001 From: k4yt3x Date: Sat, 8 Feb 2025 00:00:00 +0000 Subject: [PATCH] fix(libvideo2x): fix atomic int64_t frame_idx_ self add Signed-off-by: k4yt3x --- src/libvideo2x.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libvideo2x.cpp b/src/libvideo2x.cpp index ee66983..626e59f 100644 --- a/src/libvideo2x.cpp +++ b/src/libvideo2x.cpp @@ -262,7 +262,7 @@ int VideoProcessor::process_frames( return ret; } av_frame_unref(frame.get()); - frame_idx_++; + frame_idx_.fetch_add(1); logger()->debug("Processed frame {}/{}", frame_idx_.load(), total_frames_.load()); } } else if (enc_cfg_.copy_streams && stream_map[packet->stream_index] >= 0) { @@ -274,12 +274,12 @@ int VideoProcessor::process_frames( av_packet_unref(packet.get()); } - // Flush the filter + // Flush the processor std::vector raw_flushed_frames; ret = processor->flush(raw_flushed_frames); if (ret < 0) { av_strerror(ret, errbuf, sizeof(errbuf)); - logger()->critical("Error flushing filter: {}", errbuf); + logger()->critical("Error flushing processor: {}", errbuf); return ret; } @@ -295,7 +295,7 @@ int VideoProcessor::process_frames( if (ret < 0) { return ret; } - frame_idx_++; + frame_idx_.fetch_add(1); } // Flush the encoder @@ -314,7 +314,7 @@ int VideoProcessor::write_frame(AVFrame* frame, encoder::Encoder& encoder) { int ret = 0; if (!benchmark_) { - ret = encoder.write_frame(frame, frame_idx_); + ret = encoder.write_frame(frame, frame_idx_.load()); if (ret < 0) { av_strerror(ret, errbuf, sizeof(errbuf)); logger()->critical("Error encoding/writing frame: {}", errbuf); @@ -437,7 +437,7 @@ int VideoProcessor::process_interpolation( } } - frame_idx_++; + frame_idx_.fetch_add(1); current_time_step += time_step; }