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
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <vector> #include <vector>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// AVDictionary // AVDictionary
...@@ -158,5 +158,5 @@ AVFilterGraphPtr::AVFilterGraphPtr() ...@@ -158,5 +158,5 @@ AVFilterGraphPtr::AVFilterGraphPtr()
void AVFilterGraphPtr::reset() { void AVFilterGraphPtr::reset() {
ptr.reset(get_filter_graph()); ptr.reset(get_filter_graph());
} }
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -23,7 +23,7 @@ extern "C" { ...@@ -23,7 +23,7 @@ extern "C" {
} }
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
using OptionDict = c10::Dict<std::string, std::string>; using OptionDict = c10::Dict<std::string, std::string>;
...@@ -187,5 +187,5 @@ struct AVFilterGraphPtr : public Wrapper<AVFilterGraph, AVFilterGraphDeleter> { ...@@ -187,5 +187,5 @@ struct AVFilterGraphPtr : public Wrapper<AVFilterGraph, AVFilterGraphDeleter> {
AVFilterGraphPtr(); AVFilterGraphPtr();
void reset(); void reset();
}; };
} // 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 {
FilterGraph::FilterGraph(AVMediaType media_type) : media_type(media_type) { FilterGraph::FilterGraph(AVMediaType media_type) : media_type(media_type) {
switch (media_type) { switch (media_type) {
...@@ -200,5 +200,5 @@ int FilterGraph::get_frame(AVFrame* pOutputFrame) { ...@@ -200,5 +200,5 @@ int FilterGraph::get_frame(AVFrame* pOutputFrame) {
return av_buffersink_get_frame(buffersink_ctx, pOutputFrame); return av_buffersink_get_frame(buffersink_ctx, pOutputFrame);
} }
} // 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 {
class FilterGraph { class FilterGraph {
AVMediaType media_type; AVMediaType media_type;
...@@ -64,5 +64,5 @@ class FilterGraph { ...@@ -64,5 +64,5 @@ class FilterGraph {
int get_frame(AVFrame* pOutputFrame); int get_frame(AVFrame* pOutputFrame);
}; };
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <torchaudio/csrc/ffmpeg/pybind/stream_writer.h> #include <torchaudio/csrc/ffmpeg/pybind/stream_writer.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
namespace { namespace {
PYBIND11_MODULE(_torchaudio_ffmpeg, m) { PYBIND11_MODULE(_torchaudio_ffmpeg, m) {
...@@ -49,5 +49,5 @@ PYBIND11_MODULE(_torchaudio_ffmpeg, m) { ...@@ -49,5 +49,5 @@ PYBIND11_MODULE(_torchaudio_ffmpeg, m) {
} }
} // namespace } // namespace
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <torchaudio/csrc/ffmpeg/pybind/typedefs.h> #include <torchaudio/csrc/ffmpeg/pybind/typedefs.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
namespace { namespace {
SrcInfoPyBind convert_pybind(SrcStreamInfo ssi) { SrcInfoPyBind convert_pybind(SrcStreamInfo ssi) {
return SrcInfoPyBind(std::forward_as_tuple( return SrcInfoPyBind(std::forward_as_tuple(
...@@ -72,5 +72,5 @@ void StreamReaderFileObj::add_video_stream( ...@@ -72,5 +72,5 @@ void StreamReaderFileObj::add_video_stream(
hw_accel); hw_accel);
} }
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#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 {
// The reason we inherit FileObj instead of making it an attribute // The reason we inherit FileObj instead of making it an attribute
// is so that FileObj is instantiated first. // is so that FileObj is instantiated first.
...@@ -37,5 +37,5 @@ class StreamReaderFileObj : protected FileObj, public StreamReaderBinding { ...@@ -37,5 +37,5 @@ class StreamReaderFileObj : protected FileObj, public StreamReaderBinding {
const c10::optional<std::string>& hw_accel); const c10::optional<std::string>& hw_accel);
}; };
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
#include <torchaudio/csrc/ffmpeg/pybind/stream_writer.h> #include <torchaudio/csrc/ffmpeg/pybind/stream_writer.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
StreamWriterFileObj::StreamWriterFileObj( StreamWriterFileObj::StreamWriterFileObj(
py::object fileobj_, py::object fileobj_,
...@@ -51,5 +51,5 @@ void StreamWriterFileObj::add_video_stream( ...@@ -51,5 +51,5 @@ void StreamWriterFileObj::add_video_stream(
hw_accel); hw_accel);
} }
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,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 {
class StreamWriterFileObj : private FileObj, public StreamWriter { class StreamWriterFileObj : private FileObj, public StreamWriter {
public: public:
...@@ -31,5 +31,5 @@ class StreamWriterFileObj : private FileObj, public StreamWriter { ...@@ -31,5 +31,5 @@ class StreamWriterFileObj : private FileObj, public StreamWriter {
const c10::optional<std::string>& hw_accel); const c10::optional<std::string>& hw_accel);
}; };
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
#include <torchaudio/csrc/ffmpeg/pybind/typedefs.h> #include <torchaudio/csrc/ffmpeg/pybind/typedefs.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
namespace { namespace {
static int read_function(void* opaque, uint8_t* buf, int buf_size) { static int read_function(void* opaque, uint8_t* buf, int buf_size) {
...@@ -112,5 +112,5 @@ OptionMap dict2map(const OptionDict& src) { ...@@ -112,5 +112,5 @@ OptionMap dict2map(const OptionDict& src) {
return ret; return ret;
} }
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <torchaudio/csrc/ffmpeg/ffmpeg.h> #include <torchaudio/csrc/ffmpeg/ffmpeg.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
struct FileObj { struct FileObj {
py::object fileobj; py::object fileobj;
...@@ -20,5 +20,5 @@ c10::optional<OptionDict> map2dict(const c10::optional<OptionMap>& src); ...@@ -20,5 +20,5 @@ c10::optional<OptionDict> map2dict(const c10::optional<OptionMap>& src);
OptionMap dict2map(const OptionDict& src); OptionMap dict2map(const OptionDict& src);
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <torchaudio/csrc/ffmpeg/stream_reader/typedefs.h> #include <torchaudio/csrc/ffmpeg/stream_reader/typedefs.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Buffer Interface // Buffer Interface
...@@ -29,5 +29,5 @@ class Buffer { ...@@ -29,5 +29,5 @@ class Buffer {
virtual void flush() = 0; virtual void flush() = 0;
}; };
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <torchaudio/csrc/ffmpeg/stream_reader/buffer/common.h> #include <torchaudio/csrc/ffmpeg/stream_reader/buffer/common.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
namespace detail { namespace detail {
ChunkedBuffer::ChunkedBuffer( ChunkedBuffer::ChunkedBuffer(
...@@ -152,5 +152,5 @@ void ChunkedBuffer::flush() { ...@@ -152,5 +152,5 @@ void ChunkedBuffer::flush() {
} }
} // namespace detail } // namespace detail
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,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 {
namespace detail { namespace detail {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
...@@ -63,5 +63,5 @@ class ChunkedVideoBuffer : public ChunkedBuffer { ...@@ -63,5 +63,5 @@ class ChunkedVideoBuffer : public ChunkedBuffer {
}; };
} // namespace detail } // namespace detail
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#endif #endif
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
namespace detail { namespace detail {
torch::Tensor convert_audio(AVFrame* pFrame) { torch::Tensor convert_audio(AVFrame* pFrame) {
...@@ -380,5 +380,5 @@ torch::Tensor convert_image(AVFrame* frame, const torch::Device& device) { ...@@ -380,5 +380,5 @@ torch::Tensor convert_image(AVFrame* frame, const torch::Device& device) {
} }
} // namespace detail } // namespace detail
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <torchaudio/csrc/ffmpeg/ffmpeg.h> #include <torchaudio/csrc/ffmpeg/ffmpeg.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
namespace detail { namespace detail {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
...@@ -14,5 +14,5 @@ torch::Tensor convert_audio(AVFrame* frame); ...@@ -14,5 +14,5 @@ torch::Tensor convert_audio(AVFrame* frame);
torch::Tensor convert_image(AVFrame* frame, const torch::Device& device); torch::Tensor convert_image(AVFrame* frame, const torch::Device& device);
} // namespace detail } // namespace detail
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <torchaudio/csrc/ffmpeg/stream_reader/buffer/unchunked_buffer.h> #include <torchaudio/csrc/ffmpeg/stream_reader/buffer/unchunked_buffer.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
namespace detail { namespace detail {
UnchunkedVideoBuffer::UnchunkedVideoBuffer(const torch::Device& device) UnchunkedVideoBuffer::UnchunkedVideoBuffer(const torch::Device& device)
...@@ -43,5 +43,5 @@ void UnchunkedBuffer::flush() { ...@@ -43,5 +43,5 @@ void UnchunkedBuffer::flush() {
} }
} // namespace detail } // namespace detail
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <deque> #include <deque>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
namespace detail { namespace detail {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
...@@ -42,5 +42,5 @@ class UnchunkedVideoBuffer : public UnchunkedBuffer { ...@@ -42,5 +42,5 @@ class UnchunkedVideoBuffer : public UnchunkedBuffer {
}; };
} // namespace detail } // namespace detail
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
#include <torchaudio/csrc/ffmpeg/stream_reader/decoder.h> #include <torchaudio/csrc/ffmpeg/stream_reader/decoder.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Decoder // Decoder
...@@ -131,5 +131,5 @@ void Decoder::flush_buffer() { ...@@ -131,5 +131,5 @@ void Decoder::flush_buffer() {
avcodec_flush_buffers(pCodecContext); avcodec_flush_buffers(pCodecContext);
} }
} // namespace ffmpeg } // namespace io
} // namespace torchaudio } // namespace torchaudio
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <torchaudio/csrc/ffmpeg/ffmpeg.h> #include <torchaudio/csrc/ffmpeg/ffmpeg.h>
namespace torchaudio { namespace torchaudio {
namespace ffmpeg { namespace io {
class Decoder { class Decoder {
AVCodecContextPtr pCodecContext; AVCodecContextPtr pCodecContext;
...@@ -34,5 +34,5 @@ class Decoder { ...@@ -34,5 +34,5 @@ class Decoder {
void flush_buffer(); void flush_buffer();
}; };
} // 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