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