refactor: VideoReader and videoin post-audio review cleanup

VideoReader:
- Remove unused #include <iostream>
- Remove dead AudioInfo::samples and ::channel_stride fields
- Rename have_video → has_video (consistent with has_audio)
- Rename get_next_frame → read_next (returns audio too, not just frames)
- Fix outdated comment on read_next
- Remove trailing blank line in allocate_audio_conversion_buffers

videoin:
- Remove redundant FFmpeg includes (VideoReader.hpp provides them)
- Fix bug: mxlFlowWriterGetMaxWriteLengthSamples called with invalid
  audio_writer when mxlCreateFlowWriter fails — moved inside else branch
- Rename call site: get_next_frame → read_next
- Rename have_video → has_video at call sites
- Use = nullptr for audio_writer (consistent with video_writer)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
JohannesItten
2026-07-05 12:44:35 +03:00
parent 166efc3c59
commit 0298cf9b48
2 changed files with 18 additions and 33 deletions
+7 -16
View File
@@ -1,11 +1,3 @@
extern "C" {
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
#include <libswscale/swscale.h>
#include <libavutil/imgutils.h>
}
#include <string>
#include <mxl/flow.h>
#include <mxl/time.h>
@@ -21,11 +13,11 @@ class VideoInNode : public dmf::NodeBase {
log("file: %s", filename.c_str());
dmf::VideoReader video_reader(filename);
if (!video_reader.have_video && !video_reader.has_audio) {
if (!video_reader.has_video && !video_reader.has_audio) {
log("no video or audio stream found"); return;
}
const bool has_video = config().contains("video_flow_id") && video_reader.have_video;
const bool has_video = config().contains("video_flow_id") && video_reader.has_video;
mxlFlowWriter video_writer = nullptr;
mxlFlowConfigInfo video_cfg{};
uint32_t video_stride = 0;
@@ -56,7 +48,7 @@ class VideoInNode : public dmf::NodeBase {
video_stride, video_stride * static_cast<uint32_t>(height), video_cfg.discrete.grainCount);
}
mxlFlowWriter audio_writer{};
mxlFlowWriter audio_writer = nullptr;
mxlFlowConfigInfo audio_cfg{};
int sample_rate = video_reader.audio_info.sample_rate;
int channels = video_reader.audio_info.channels;
@@ -82,11 +74,10 @@ class VideoInNode : public dmf::NodeBase {
} else {
log("audio channels=%u buffer=%u samples",
audio_cfg.continuous.channelCount, audio_cfg.continuous.bufferLength);
size_t max_write = 0;
mxlFlowWriterGetMaxWriteLengthSamples(audio_writer, &max_write);
max_audio_samples = static_cast<int>(max_write);
}
size_t max_write = 0;
mxlFlowWriterGetMaxWriteLengthSamples(audio_writer, &max_write);
max_audio_samples = static_cast<int>(max_write);
}
std::vector<uint8_t> audio_temp(max_audio_samples * channels * sizeof(float));
@@ -107,7 +98,7 @@ class VideoInNode : public dmf::NodeBase {
}
int out_samples_written = 0;
dmf::VideoReader::FrameKind frame_kind = video_reader.get_next_frame(
dmf::VideoReader::FrameKind frame_kind = video_reader.read_next(
has_video ? video_buf : nullptr,
video_stride,
has_audio ? audio_temp.data() : nullptr,