@@ -16,9 +16,7 @@ namespace {
1616
1717bool g_cpu = registerDeviceInterface(
1818 torch::kCPU ,
19- [](const torch::Device& device, const AVRational& timeBase) {
20- return new CpuDeviceInterface (device, timeBase);
21- });
19+ [](const torch::Device& device) { return new CpuDeviceInterface (device); });
2220
2321} // namespace
2422
@@ -36,10 +34,8 @@ bool CpuDeviceInterface::DecodedFrameContext::operator!=(
3634 return !(*this == other);
3735}
3836
39- CpuDeviceInterface::CpuDeviceInterface (
40- const torch::Device& device,
41- const AVRational& timeBase)
42- : DeviceInterface(device, timeBase) {
37+ CpuDeviceInterface::CpuDeviceInterface (const torch::Device& device)
38+ : DeviceInterface(device) {
4339 if (device_.type () != torch::kCPU ) {
4440 throw std::runtime_error (" Unsupported device: " + device_.str ());
4541 }
@@ -56,6 +52,7 @@ CpuDeviceInterface::CpuDeviceInterface(
5652// `dimension_order` parameter. It's up to callers to re-shape it if needed.
5753void CpuDeviceInterface::convertAVFrameToFrameOutput (
5854 const VideoStreamOptions& videoStreamOptions,
55+ const AVRational& timeBase,
5956 UniqueAVFrame& avFrame,
6057 FrameOutput& frameOutput,
6158 std::optional<torch::Tensor> preAllocatedOutputTensor) {
@@ -136,7 +133,7 @@ void CpuDeviceInterface::convertAVFrameToFrameOutput(
136133 frameOutput.data = outputTensor;
137134 } else if (colorConversionLibrary == ColorConversionLibrary::FILTERGRAPH) {
138135 if (!filterGraphContext_.filterGraph || prevFrameContext_ != frameContext) {
139- createFilterGraph (frameContext, videoStreamOptions);
136+ createFilterGraph (frameContext, videoStreamOptions, timeBase );
140137 prevFrameContext_ = frameContext;
141138 }
142139 outputTensor = convertAVFrameToTensorUsingFilterGraph (avFrame);
@@ -215,7 +212,8 @@ torch::Tensor CpuDeviceInterface::convertAVFrameToTensorUsingFilterGraph(
215212
216213void CpuDeviceInterface::createFilterGraph (
217214 const DecodedFrameContext& frameContext,
218- const VideoStreamOptions& videoStreamOptions) {
215+ const VideoStreamOptions& videoStreamOptions,
216+ const AVRational& timeBase) {
219217 filterGraphContext_.filterGraph .reset (avfilter_graph_alloc ());
220218 TORCH_CHECK (filterGraphContext_.filterGraph .get () != nullptr );
221219
@@ -231,7 +229,7 @@ void CpuDeviceInterface::createFilterGraph(
231229 filterArgs << " video_size=" << frameContext.decodedWidth << " x"
232230 << frameContext.decodedHeight ;
233231 filterArgs << " :pix_fmt=" << frameContext.decodedFormat ;
234- filterArgs << " :time_base=" << timeBase_ .num << " /" << timeBase_ .den ;
232+ filterArgs << " :time_base=" << timeBase .num << " /" << timeBase .den ;
235233 filterArgs << " :pixel_aspect=" << frameContext.decodedAspectRatio .num << " /"
236234 << frameContext.decodedAspectRatio .den ;
237235
0 commit comments