Commit 0846a411 authored by Moto Hira's avatar Moto Hira Committed by Facebook GitHub Bot
Browse files

Set default value to optional arguments (#3208)

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

StreamReader/Writer is evolving and the number of arguments in
add_stream methods are growing.

This commit adds default values to these arguments.

Reviewed By: hwangjeff

Differential Revision: D44447263

fbshipit-source-id: e1c09956d78c2b4738bbeafb88195ec8e8ca5513
parent ac998eb1
...@@ -58,8 +58,8 @@ class StreamReader { ...@@ -58,8 +58,8 @@ class StreamReader {
/// (opening source). /// (opening source).
explicit StreamReader( explicit StreamReader(
const std::string& src, const std::string& src,
const c10::optional<std::string>& format = {}, const c10::optional<std::string>& format = c10::nullopt,
const c10::optional<OptionDict>& option = {}); const c10::optional<OptionDict>& option = c10::nullopt);
/// @cond /// @cond
...@@ -72,8 +72,8 @@ class StreamReader { ...@@ -72,8 +72,8 @@ class StreamReader {
// TODO: Move this to wrapper class // TODO: Move this to wrapper class
explicit StreamReader( explicit StreamReader(
AVIOContext* io_ctx, AVIOContext* io_ctx,
const c10::optional<std::string>& format = {}, const c10::optional<std::string>& format = c10::nullopt,
const c10::optional<OptionDict>& option = {}); const c10::optional<OptionDict>& option = c10::nullopt);
/// @endcond /// @endcond
...@@ -190,9 +190,9 @@ class StreamReader { ...@@ -190,9 +190,9 @@ class StreamReader {
int64_t i, int64_t i,
int64_t frames_per_chunk, int64_t frames_per_chunk,
int64_t num_chunks, int64_t num_chunks,
const c10::optional<std::string>& filter_desc, const c10::optional<std::string>& filter_desc = c10::nullopt,
const c10::optional<std::string>& decoder, const c10::optional<std::string>& decoder = c10::nullopt,
const c10::optional<OptionDict>& decoder_option); const c10::optional<OptionDict>& decoder_option = c10::nullopt);
/// Define an output video stream. /// Define an output video stream.
/// ///
/// @param i,frames_per_chunk,num_chunks,filter_desc,decoder,decoder_option /// @param i,frames_per_chunk,num_chunks,filter_desc,decoder,decoder_option
...@@ -211,10 +211,10 @@ class StreamReader { ...@@ -211,10 +211,10 @@ class StreamReader {
int64_t i, int64_t i,
int64_t frames_per_chunk, int64_t frames_per_chunk,
int64_t num_chunks, int64_t num_chunks,
const c10::optional<std::string>& filter_desc, const c10::optional<std::string>& filter_desc = c10::nullopt,
const c10::optional<std::string>& decoder, const c10::optional<std::string>& decoder = c10::nullopt,
const c10::optional<OptionDict>& decoder_option, const c10::optional<OptionDict>& decoder_option = c10::nullopt,
const c10::optional<std::string>& hw_accel); const c10::optional<std::string>& hw_accel = c10::nullopt);
/// Remove an output stream. /// Remove an output stream.
/// ///
/// @param i The index of the output stream to be removed. /// @param i The index of the output stream to be removed.
...@@ -288,7 +288,7 @@ class StreamReader { ...@@ -288,7 +288,7 @@ class StreamReader {
/// @param timeout See `process_packet_block()` /// @param timeout See `process_packet_block()`
/// @param backoff See `process_packet_block()` /// @param backoff See `process_packet_block()`
int fill_buffer( int fill_buffer(
const c10::optional<double>& timeout = {}, const c10::optional<double>& timeout = c10::nullopt,
const double backoff = 10.); const double backoff = 10.);
///@} ///@}
......
#pragma once #pragma once
#include <torch/torch.h> #include <torch/types.h>
#include <torchaudio/csrc/ffmpeg/ffmpeg.h> #include <torchaudio/csrc/ffmpeg/ffmpeg.h>
#include <torchaudio/csrc/ffmpeg/filter_graph.h> #include <torchaudio/csrc/ffmpeg/filter_graph.h>
#include <torchaudio/csrc/ffmpeg/stream_writer/encode_process.h> #include <torchaudio/csrc/ffmpeg/stream_writer/encode_process.h>
...@@ -34,7 +34,7 @@ class StreamWriter { ...@@ -34,7 +34,7 @@ class StreamWriter {
/// ``dst``. /// ``dst``.
explicit StreamWriter( explicit StreamWriter(
const std::string& dst, const std::string& dst,
const c10::optional<std::string>& format = {}); const c10::optional<std::string>& format = c10::nullopt);
/// @cond /// @cond
...@@ -45,7 +45,7 @@ class StreamWriter { ...@@ -45,7 +45,7 @@ class StreamWriter {
// TODO: Move this into wrapper class. // TODO: Move this into wrapper class.
explicit StreamWriter( explicit StreamWriter(
AVIOContext* io_ctx, AVIOContext* io_ctx,
const c10::optional<std::string>& format); const c10::optional<std::string>& format = c10::nullopt);
/// @endcond /// @endcond
...@@ -104,10 +104,10 @@ class StreamWriter { ...@@ -104,10 +104,10 @@ class StreamWriter {
int sample_rate, int sample_rate,
int num_channels, int num_channels,
const std::string& format, const std::string& format,
const c10::optional<std::string>& encoder, const c10::optional<std::string>& encoder = c10::nullopt,
const c10::optional<OptionDict>& encoder_option, const c10::optional<OptionDict>& encoder_option = c10::nullopt,
const c10::optional<std::string>& encoder_format, const c10::optional<std::string>& encoder_format = c10::nullopt,
const c10::optional<CodecConfig>& codec_config); const c10::optional<CodecConfig>& codec_config = c10::nullopt);
/// Add an output video stream. /// Add an output video stream.
/// ///
...@@ -144,11 +144,11 @@ class StreamWriter { ...@@ -144,11 +144,11 @@ class StreamWriter {
int width, int width,
int height, int height,
const std::string& format, const std::string& format,
const c10::optional<std::string>& encoder, const c10::optional<std::string>& encoder = c10::nullopt,
const c10::optional<OptionDict>& encoder_option, const c10::optional<OptionDict>& encoder_option = c10::nullopt,
const c10::optional<std::string>& encoder_format, const c10::optional<std::string>& encoder_format = c10::nullopt,
const c10::optional<std::string>& hw_accel, const c10::optional<std::string>& hw_accel = c10::nullopt,
const c10::optional<CodecConfig>& codec_config); const c10::optional<CodecConfig>& codec_config = c10::nullopt);
/// Set file-level metadata /// Set file-level metadata
/// @param metadata metadata. /// @param metadata metadata.
void set_metadata(const OptionDict& metadata); void set_metadata(const OptionDict& metadata);
...@@ -160,7 +160,7 @@ class StreamWriter { ...@@ -160,7 +160,7 @@ class StreamWriter {
/// Open the output file / device and write the header. /// Open the output file / device and write the header.
/// ///
/// @param opt Private options for protocol, device and muxer. /// @param opt Private options for protocol, device and muxer.
void open(const c10::optional<OptionDict>& opt); void open(const c10::optional<OptionDict>& opt = c10::nullopt);
/// Close the output file / device and finalize metadata. /// Close the output file / device and finalize metadata.
void close(); void close();
...@@ -182,7 +182,7 @@ class StreamWriter { ...@@ -182,7 +182,7 @@ class StreamWriter {
void write_audio_chunk( void write_audio_chunk(
int i, int i,
const torch::Tensor& frames, const torch::Tensor& frames,
const c10::optional<double>& pts = {}); const c10::optional<double>& pts = c10::nullopt);
/// Write video data /// Write video data
/// @param i Stream index. /// @param i Stream index.
/// @param frames Video/image tensor. Shape: ``(time, channel, height, /// @param frames Video/image tensor. Shape: ``(time, channel, height,
...@@ -203,7 +203,7 @@ class StreamWriter { ...@@ -203,7 +203,7 @@ class StreamWriter {
void write_video_chunk( void write_video_chunk(
int i, int i,
const torch::Tensor& frames, const torch::Tensor& frames,
const c10::optional<double>& pts = {}); const c10::optional<double>& pts = c10::nullopt);
/// Flush the frames from encoders and write the frames to the destination. /// Flush the frames from encoders and write the frames to the destination.
void flush(); void flush();
}; };
......
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