Skip to content

Commit 445d13b

Browse files
committed
fix(libvideo2x): fix atomic int64_t frame_idx_ self add
Signed-off-by: k4yt3x <i@k4yt3x.com>
1 parent 8803cf1 commit 445d13b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/libvideo2x.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ int VideoProcessor::process_frames(
262262
return ret;
263263
}
264264
av_frame_unref(frame.get());
265-
frame_idx_++;
265+
frame_idx_.fetch_add(1);
266266
logger()->debug("Processed frame {}/{}", frame_idx_.load(), total_frames_.load());
267267
}
268268
} else if (enc_cfg_.copy_streams && stream_map[packet->stream_index] >= 0) {
@@ -274,12 +274,12 @@ int VideoProcessor::process_frames(
274274
av_packet_unref(packet.get());
275275
}
276276

277-
// Flush the filter
277+
// Flush the processor
278278
std::vector<AVFrame*> raw_flushed_frames;
279279
ret = processor->flush(raw_flushed_frames);
280280
if (ret < 0) {
281281
av_strerror(ret, errbuf, sizeof(errbuf));
282-
logger()->critical("Error flushing filter: {}", errbuf);
282+
logger()->critical("Error flushing processor: {}", errbuf);
283283
return ret;
284284
}
285285

@@ -295,7 +295,7 @@ int VideoProcessor::process_frames(
295295
if (ret < 0) {
296296
return ret;
297297
}
298-
frame_idx_++;
298+
frame_idx_.fetch_add(1);
299299
}
300300

301301
// Flush the encoder
@@ -314,7 +314,7 @@ int VideoProcessor::write_frame(AVFrame* frame, encoder::Encoder& encoder) {
314314
int ret = 0;
315315

316316
if (!benchmark_) {
317-
ret = encoder.write_frame(frame, frame_idx_);
317+
ret = encoder.write_frame(frame, frame_idx_.load());
318318
if (ret < 0) {
319319
av_strerror(ret, errbuf, sizeof(errbuf));
320320
logger()->critical("Error encoding/writing frame: {}", errbuf);
@@ -437,7 +437,7 @@ int VideoProcessor::process_interpolation(
437437
}
438438
}
439439

440-
frame_idx_++;
440+
frame_idx_.fetch_add(1);
441441
current_time_step += time_step;
442442
}
443443

0 commit comments

Comments
 (0)