diff --git a/src/torchcodec/decoders/_core/VideoDecoderOps.cpp b/src/torchcodec/decoders/_core/VideoDecoderOps.cpp index ad8c6f258..bb13e113d 100644 --- a/src/torchcodec/decoders/_core/VideoDecoderOps.cpp +++ b/src/torchcodec/decoders/_core/VideoDecoderOps.cpp @@ -142,20 +142,6 @@ at::Tensor create_from_tensor( return wrapDecoderPointerToTensor(std::move(uniqueDecoder)); } -at::Tensor create_from_buffer( - const void* buffer, - size_t length, - std::optional seek_mode) { - VideoDecoder::SeekMode realSeek = VideoDecoder::SeekMode::exact; - if (seek_mode.has_value()) { - realSeek = seekModeFromString(seek_mode.value()); - } - - std::unique_ptr uniqueDecoder = - std::make_unique(buffer, length, realSeek); - return wrapDecoderPointerToTensor(std::move(uniqueDecoder)); -} - void add_video_stream( at::Tensor& decoder, std::optional width, diff --git a/src/torchcodec/decoders/_core/VideoDecoderOps.h b/src/torchcodec/decoders/_core/VideoDecoderOps.h index a3cc821ad..034a8842a 100644 --- a/src/torchcodec/decoders/_core/VideoDecoderOps.h +++ b/src/torchcodec/decoders/_core/VideoDecoderOps.h @@ -28,13 +28,6 @@ at::Tensor create_from_tensor( at::Tensor video_tensor, std::optional seek_mode = std::nullopt); -// This API is C++ only and will not be exposed via custom ops, use -// videodecoder_create_from_bytes in Python -at::Tensor create_from_buffer( - const void* buffer, - size_t length, - std::optional seek_mode = std::nullopt); - // Add a new video stream at `stream_index` using the provided options. void add_video_stream( at::Tensor& decoder, diff --git a/test/decoders/CMakeLists.txt b/test/decoders/CMakeLists.txt index 21791dde3..3350c92c5 100644 --- a/test/decoders/CMakeLists.txt +++ b/test/decoders/CMakeLists.txt @@ -21,15 +21,8 @@ add_executable( VideoDecoderTest.cpp ) -add_executable( - VideoDecoderOpsTest - VideoDecoderOpsTest.cpp -) - target_include_directories(VideoDecoderTest SYSTEM PRIVATE ${TORCH_INCLUDE_DIRS}) target_include_directories(VideoDecoderTest PRIVATE ../../) -target_include_directories(VideoDecoderOpsTest SYSTEM PRIVATE ${TORCH_INCLUDE_DIRS}) -target_include_directories(VideoDecoderOpsTest PRIVATE ../../) target_link_libraries( VideoDecoderTest @@ -37,12 +30,5 @@ target_link_libraries( GTest::gtest_main ) -target_link_libraries( - VideoDecoderOpsTest - ${libtorchcodec_target_name} - GTest::gtest_main -) - include(GoogleTest) gtest_discover_tests(VideoDecoderTest) -gtest_discover_tests(VideoDecoderOpsTest) diff --git a/test/decoders/VideoDecoderOpsTest.cpp b/test/decoders/VideoDecoderOpsTest.cpp deleted file mode 100644 index f2414797d..000000000 --- a/test/decoders/VideoDecoderOpsTest.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Meta Platforms, Inc. and affiliates. -// All rights reserved. -// -// This source code is licensed under the BSD-style license found in the -// LICENSE file in the root directory of this source tree. - -#include "src/torchcodec/decoders/_core/VideoDecoderOps.h" - -#include -#include -#include -#include - -#ifdef FBCODE_BUILD -#include "tools/cxx/Resources.h" -#endif - -using namespace ::testing; - -namespace facebook::torchcodec { - -std::string getResourcePath(const std::string& filename) { -#ifdef FBCODE_BUILD - std::string filepath = "pytorch/torchcodec/test/resources/" + filename; - filepath = build::getResourcePath(filepath).string(); -#else - std::filesystem::path dirPath = std::filesystem::path(__FILE__); - std::string filepath = - dirPath.parent_path().string() + "/../resources/" + filename; -#endif - return filepath; -} - -TEST(VideoDecoderOpsTest, TestCreateDecoderFromBuffer) { - std::string filepath = getResourcePath("nasa_13013.mp4"); - std::ostringstream outputStringStream; - std::ifstream input(filepath, std::ios::binary); - outputStringStream << input.rdbuf(); - std::string content = outputStringStream.str(); - void* buffer = content.data(); - size_t length = outputStringStream.str().length(); - at::Tensor decoder = create_from_buffer(buffer, length); - add_video_stream(decoder); - auto result = get_next_frame(decoder); - at::Tensor tensor1 = std::get<0>(result); - EXPECT_EQ(tensor1.sizes(), std::vector({3, 270, 480})); - EXPECT_EQ(std::get<1>(result).item(), 0); - EXPECT_NEAR(std::get<2>(result).item(), 0.033367, 1e-6); -} - -} // namespace facebook::torchcodec