Commit 08597236 authored by moto's avatar moto Committed by Facebook GitHub Bot
Browse files

Rename AVContextPtr with AVContextInputPtr (#2530)

Summary:
Preparation to add save features with ffmpeg.

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

Reviewed By: carolineechen

Differential Revision: D37698147

Pulled By: mthrok

fbshipit-source-id: feb5cbb6349a2b6b7faf44b629c574fdae47ecab
parent 8b70c93e
...@@ -11,7 +11,6 @@ namespace ffmpeg { ...@@ -11,7 +11,6 @@ namespace ffmpeg {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// AVDictionary // AVDictionary
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
AVDictionary* get_option_dict(const OptionDict& option) { AVDictionary* get_option_dict(const OptionDict& option) {
AVDictionary* opt = nullptr; AVDictionary* opt = nullptr;
for (const auto& it : option) { for (const auto& it : option) {
...@@ -38,12 +37,12 @@ void clean_up_dict(AVDictionary* p) { ...@@ -38,12 +37,12 @@ void clean_up_dict(AVDictionary* p) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// AVFormatContext // AVFormatContext
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void AVFormatContextDeleter::operator()(AVFormatContext* p) { void AVFormatInputContextDeleter::operator()(AVFormatContext* p) {
avformat_close_input(&p); avformat_close_input(&p);
}; };
AVFormatContextPtr::AVFormatContextPtr(AVFormatContext* p) AVFormatInputContextPtr::AVFormatInputContextPtr(AVFormatContext* p)
: Wrapper<AVFormatContext, AVFormatContextDeleter>(p) {} : Wrapper<AVFormatContext, AVFormatInputContextDeleter>(p) {}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// AVIO // AVIO
......
...@@ -84,13 +84,13 @@ void clean_up_dict(AVDictionary* p); ...@@ -84,13 +84,13 @@ void clean_up_dict(AVDictionary* p);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// AVFormatContext // AVFormatContext
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
struct AVFormatContextDeleter { struct AVFormatInputContextDeleter {
void operator()(AVFormatContext* p); void operator()(AVFormatContext* p);
}; };
struct AVFormatContextPtr struct AVFormatInputContextPtr
: public Wrapper<AVFormatContext, AVFormatContextDeleter> { : public Wrapper<AVFormatContext, AVFormatInputContextDeleter> {
explicit AVFormatContextPtr(AVFormatContext* p); explicit AVFormatInputContextPtr(AVFormatContext* p);
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
......
...@@ -45,7 +45,7 @@ void StreamReader::validate_src_stream_type(int i, AVMediaType type) { ...@@ -45,7 +45,7 @@ void StreamReader::validate_src_stream_type(int i, AVMediaType type) {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Initialization / resource allocations // Initialization / resource allocations
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
StreamReader::StreamReader(AVFormatContextPtr&& p) StreamReader::StreamReader(AVFormatInputContextPtr&& p)
: pFormatContext(std::move(p)) { : pFormatContext(std::move(p)) {
if (avformat_find_stream_info(pFormatContext, nullptr) < 0) { if (avformat_find_stream_info(pFormatContext, nullptr) < 0) {
throw std::runtime_error("Failed to find stream information."); throw std::runtime_error("Failed to find stream information.");
......
...@@ -8,7 +8,7 @@ namespace torchaudio { ...@@ -8,7 +8,7 @@ namespace torchaudio {
namespace ffmpeg { namespace ffmpeg {
class StreamReader { class StreamReader {
AVFormatContextPtr pFormatContext; AVFormatInputContextPtr pFormatContext;
AVPacketPtr pPacket; AVPacketPtr pPacket;
std::vector<std::unique_ptr<StreamProcessor>> processors; std::vector<std::unique_ptr<StreamProcessor>> processors;
...@@ -18,7 +18,7 @@ class StreamReader { ...@@ -18,7 +18,7 @@ class StreamReader {
std::vector<std::pair<int, int>> stream_indices; std::vector<std::pair<int, int>> stream_indices;
public: public:
explicit StreamReader(AVFormatContextPtr&& p); explicit StreamReader(AVFormatInputContextPtr&& p);
~StreamReader() = default; ~StreamReader() = default;
// Non-copyable // Non-copyable
StreamReader(const StreamReader&) = delete; StreamReader(const StreamReader&) = delete;
......
...@@ -55,7 +55,7 @@ OutInfo convert(OutputStreamInfo osi) { ...@@ -55,7 +55,7 @@ OutInfo convert(OutputStreamInfo osi) {
} }
} // namespace } // namespace
AVFormatContextPtr get_input_format_context( AVFormatInputContextPtr get_input_format_context(
const std::string& src, const std::string& src,
const c10::optional<std::string>& device, const c10::optional<std::string>& device,
const OptionDict& option, const OptionDict& option,
...@@ -91,10 +91,10 @@ AVFormatContextPtr get_input_format_context( ...@@ -91,10 +91,10 @@ AVFormatContextPtr get_input_format_context(
throw std::runtime_error( throw std::runtime_error(
"Failed to open the input \"" + src + "\" (" + av_err2string(ret) + "Failed to open the input \"" + src + "\" (" + av_err2string(ret) +
")."); ").");
return AVFormatContextPtr(pFormat); return AVFormatInputContextPtr(pFormat);
} }
StreamReaderBinding::StreamReaderBinding(AVFormatContextPtr&& p) StreamReaderBinding::StreamReaderBinding(AVFormatInputContextPtr&& p)
: StreamReader(std::move(p)) {} : StreamReader(std::move(p)) {}
SrcInfo StreamReaderBinding::get_src_stream_info(int64_t i) { SrcInfo StreamReaderBinding::get_src_stream_info(int64_t i) {
......
...@@ -6,7 +6,7 @@ namespace torchaudio { ...@@ -6,7 +6,7 @@ namespace torchaudio {
namespace ffmpeg { namespace ffmpeg {
// create format context for reading media // create format context for reading media
AVFormatContextPtr get_input_format_context( AVFormatInputContextPtr get_input_format_context(
const std::string& src, const std::string& src,
const c10::optional<std::string>& device, const c10::optional<std::string>& device,
const OptionDict& option, const OptionDict& option,
...@@ -65,7 +65,7 @@ using OutInfo = std::tuple< ...@@ -65,7 +65,7 @@ using OutInfo = std::tuple<
// suitable for Binding the code (i.e. it receives/returns pritimitves) // suitable for Binding the code (i.e. it receives/returns pritimitves)
struct StreamReaderBinding : public StreamReader, struct StreamReaderBinding : public StreamReader,
public torch::CustomClassHolder { public torch::CustomClassHolder {
explicit StreamReaderBinding(AVFormatContextPtr&& p); explicit StreamReaderBinding(AVFormatInputContextPtr&& p);
SrcInfo get_src_stream_info(int64_t i); SrcInfo get_src_stream_info(int64_t i);
SrcInfoPyBind get_src_stream_info_pybind(int64_t i); SrcInfoPyBind get_src_stream_info_pybind(int64_t i);
OutInfo get_out_stream_info(int64_t i); OutInfo get_out_stream_info(int64_t i);
......
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