Commit 51aae466 authored by Moto Hira's avatar Moto Hira Committed by Facebook GitHub Bot
Browse files

Replace torchaudio::ffmpeg with torchaudio::io (#3013)

Summary:
Pull Request resolved: https://github.com/pytorch/audio/pull/3013

Namespace clean up before publishing the torchaudio C++ API as prototype.

Reviewed By: hwangjeff

Differential Revision: D42699903

fbshipit-source-id: 8a9eed0390dfa4a152124b42f2b927dbdd3e23d2
parent 12f960b2
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <stdexcept> #include <stdexcept>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
namespace { namespace {
std::unique_ptr<Buffer> get_buffer( std::unique_ptr<Buffer> get_buffer(
...@@ -130,5 +130,5 @@ void Sink::flush() { ...@@ -130,5 +130,5 @@ void Sink::flush() {
buffer->flush(); buffer->flush();
} }
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <torchaudio/csrc/ffmpeg/stream_reader/buffer.h> #include <torchaudio/csrc/ffmpeg/stream_reader/buffer.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
class Sink { class Sink {
AVFramePtr frame; AVFramePtr frame;
...@@ -35,5 +35,5 @@ class Sink { ...@@ -35,5 +35,5 @@ class Sink {
void flush(); void flush();
}; };
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <stdexcept> #include <stdexcept>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
using KeyType = StreamProcessor::KeyType; using KeyType = StreamProcessor::KeyType;
...@@ -155,5 +155,5 @@ c10::optional<Chunk> StreamProcessor::pop_chunk(KeyType key) { ...@@ -155,5 +155,5 @@ c10::optional<Chunk> StreamProcessor::pop_chunk(KeyType key) {
return sinks.at(key).buffer->pop_chunk(); return sinks.at(key).buffer->pop_chunk();
} }
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <map> #include <map>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
class StreamProcessor { class StreamProcessor {
public: public:
...@@ -99,5 +99,5 @@ class StreamProcessor { ...@@ -99,5 +99,5 @@ class StreamProcessor {
c10::optional<Chunk> pop_chunk(KeyType key); c10::optional<Chunk> pop_chunk(KeyType key);
}; };
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <thread> #include <thread>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
using KeyType = StreamProcessor::KeyType; using KeyType = StreamProcessor::KeyType;
...@@ -445,5 +445,5 @@ std::vector<c10::optional<Chunk>> StreamReader::pop_chunks() { ...@@ -445,5 +445,5 @@ std::vector<c10::optional<Chunk>> StreamReader::pop_chunks() {
return ret; return ret;
} }
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <vector> #include <vector>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
/// ///
/// Fetch and decode audio/video streams chunk by chunk. /// Fetch and decode audio/video streams chunk by chunk.
...@@ -293,5 +293,5 @@ class StreamReader { ...@@ -293,5 +293,5 @@ class StreamReader {
///@} ///@}
}; };
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <stdexcept> #include <stdexcept>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
namespace { namespace {
...@@ -92,5 +92,5 @@ TORCH_LIBRARY_FRAGMENT(torchaudio, m) { ...@@ -92,5 +92,5 @@ TORCH_LIBRARY_FRAGMENT(torchaudio, m) {
} }
} // namespace } // namespace
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
#include <torchaudio/csrc/ffmpeg/stream_reader/stream_reader_wrapper.h> #include <torchaudio/csrc/ffmpeg/stream_reader/stream_reader_wrapper.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
namespace { namespace {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
...@@ -190,5 +190,5 @@ TORCH_LIBRARY_FRAGMENT(torchaudio, m) { ...@@ -190,5 +190,5 @@ TORCH_LIBRARY_FRAGMENT(torchaudio, m) {
.def("pop_chunks", [](S s) { return s->pop_chunks(); }); .def("pop_chunks", [](S s) { return s->pop_chunks(); });
} }
} // namespace } // namespace
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
#include <torchaudio/csrc/ffmpeg/stream_reader/stream_reader_wrapper.h> #include <torchaudio/csrc/ffmpeg/stream_reader/stream_reader_wrapper.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
namespace { namespace {
SrcInfo convert(SrcStreamInfo ssi) { SrcInfo convert(SrcStreamInfo ssi) {
...@@ -93,5 +93,5 @@ std::vector<c10::optional<ChunkData>> StreamReaderBinding::pop_chunks() { ...@@ -93,5 +93,5 @@ std::vector<c10::optional<ChunkData>> StreamReaderBinding::pop_chunks() {
return ret; return ret;
} }
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <torchaudio/csrc/ffmpeg/stream_reader/stream_reader.h> #include <torchaudio/csrc/ffmpeg/stream_reader/stream_reader.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
// Because TorchScript requires c10::Dict type to pass dict, // Because TorchScript requires c10::Dict type to pass dict,
// while PyBind11 requires std::map type to pass dict, // while PyBind11 requires std::map type to pass dict,
...@@ -86,5 +86,5 @@ struct StreamReaderBinding : public StreamReader, ...@@ -86,5 +86,5 @@ struct StreamReaderBinding : public StreamReader,
std::vector<c10::optional<ChunkData>> pop_chunks(); std::vector<c10::optional<ChunkData>> pop_chunks();
}; };
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <iostream> #include <iostream>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
struct SrcStreamInfo { struct SrcStreamInfo {
/// @name COMMON MEMBERS /// @name COMMON MEMBERS
...@@ -119,5 +119,5 @@ struct Chunk { ...@@ -119,5 +119,5 @@ struct Chunk {
double pts; double pts;
}; };
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#endif #endif
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
namespace { namespace {
AVFormatContext* get_output_format_context( AVFormatContext* get_output_format_context(
...@@ -1107,5 +1107,5 @@ void StreamWriter::flush_stream(OutputStream& os) { ...@@ -1107,5 +1107,5 @@ void StreamWriter::flush_stream(OutputStream& os) {
encode_frame(nullptr, os.codec_ctx, os.stream); encode_frame(nullptr, os.codec_ctx, os.stream);
} }
} }
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <torchaudio/csrc/ffmpeg/filter_graph.h> #include <torchaudio/csrc/ffmpeg/filter_graph.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
struct OutputStream { struct OutputStream {
AVStream* stream; AVStream* stream;
...@@ -208,5 +208,5 @@ class StreamWriter { ...@@ -208,5 +208,5 @@ class StreamWriter {
void flush_stream(OutputStream& os); void flush_stream(OutputStream& os);
}; };
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <torchaudio/csrc/ffmpeg/stream_writer/stream_writer.h> #include <torchaudio/csrc/ffmpeg/stream_writer/stream_writer.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
namespace { namespace {
class StreamWriterBinding : public StreamWriter, class StreamWriterBinding : public StreamWriter,
...@@ -82,5 +82,5 @@ TORCH_LIBRARY_FRAGMENT(torchaudio, m) { ...@@ -82,5 +82,5 @@ TORCH_LIBRARY_FRAGMENT(torchaudio, m) {
} }
} // namespace } // namespace
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <torchaudio/csrc/ffmpeg/ffmpeg.h> #include <torchaudio/csrc/ffmpeg/ffmpeg.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
namespace { namespace {
c10::Dict<std::string, std::tuple<int64_t, int64_t, int64_t>> get_versions() { c10::Dict<std::string, std::tuple<int64_t, int64_t, int64_t>> get_versions() {
...@@ -124,5 +124,5 @@ TORCH_LIBRARY_FRAGMENT(torchaudio, m) { ...@@ -124,5 +124,5 @@ TORCH_LIBRARY_FRAGMENT(torchaudio, m) {
} }
} // namespace } // namespace
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment