Skip to content

Commit

Permalink
add group video_params and audio_params to categorize parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
JackLau1222 committed Dec 25, 2024
1 parent 339312c commit bfe3409
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 20 deletions.
20 changes: 17 additions & 3 deletions bmf/c_modules/include/ffmpeg_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,27 @@ class CFFDecoder : public Module {
* The module can be used by BMF API such as bmf.decode() by providing json
style "option" to config such as the 3rd parameter below:
* @code
bmf.decode(
{'input_path': input_video_path}
)
bmf.decode(
{
"input_path": input_path,
"video_params": {
"hwaccel": "cuda",
},
"dec_params": {
"threads": 1,
},
}
)
* @endcode
* Details:\n
* @arg module name: c_ffmpeg_decoder\n
* @}
*/

/** @defgroup video_params Video Parameters
* @ingroup DecM
* Parameters related to video decoding.
* @{
* @} */

#endif // BMF_FF_DECODER_H
12 changes: 12 additions & 0 deletions bmf/c_modules/include/ffmpeg_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,16 @@ class CFFEncoder : public Module {
* @arg module name: c_ffmpeg_encoder\n
* @}
*/

/** @defgroup video_params Video Parameters
* @ingroup DecM
* Parameters related to video encoding.
* @{
* @} */

/** @defgroup audio_params Audio Parameters
* @ingroup DecM
* Parameters related to audio encoding.
* @{
* @} */
#endif
7 changes: 5 additions & 2 deletions bmf/c_modules/src/ffmpeg_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,15 @@ CFFDecoder::CFFDecoder(int node_id, JsonParam option) {
}
},
* @endcode
* @arg hwaccel: hardware accelete exp. cuda.
* @arg extract_frames: support extract frames with given fps and device.
* @} */
if (option.has_key("video_params")) {
JsonParam video_params;
option.get_object("video_params", video_params);
/** @addtogroup video_params
* @{
* @arg hwaccel: hardware accelete exp. cuda.
* @arg extract_frames: support extract frames with given fps and device.
* @} */
if (video_params.has_key("hwaccel")) {
video_params.get_string("hwaccel", hwaccel_str_);
}
Expand Down
30 changes: 15 additions & 15 deletions bmf/c_modules/src/ffmpeg_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ int CFFEncoder::init() {
if (input_option_.has_key("min_frames"))
input_option_.get_long("min_frames", ost_[0].min_frames);

/** @addtogroup EncM
/** @addtogroup video_params or audio_params
* @{
* @arg codec: param in video_params or audio_params to specify the name of
* the codec which libavcodec included. exp. "h264", "bytevc1", "jpg",
Expand All @@ -268,7 +268,7 @@ int CFFEncoder::init() {
codec_names_[0] = codec;
}
}
/** @addtogroup EncM
/** @addtogroup video_params
* @{
* @arg width: param in video_params to specify the video width
* @arg height: param in video_params to specify the video height
Expand Down Expand Up @@ -1128,7 +1128,7 @@ int CFFEncoder::init_codec(int idx, AVFrame *frame) {
has_complex_filtergraph_ = true;
}
}
/** @addtogroup EncM
/** @addtogroup video_params
* @{
* @arg threads: specify the number of threads for encoder, "auto" by
* default
Expand All @@ -1137,7 +1137,7 @@ int CFFEncoder::init_codec(int idx, AVFrame *frame) {
av_dict_set(&enc_opts, "threads", "auto", 0);
}

/** @addtogroup EncM
/** @addtogroup video_params
* @{
* @arg psnr: to set encoder provide psnr information
* @} */
Expand All @@ -1149,7 +1149,7 @@ int CFFEncoder::init_codec(int idx, AVFrame *frame) {
enc_ctxs_[0]->flags |= AV_CODEC_FLAG_PSNR;
}

/** @addtogroup EncM
/** @addtogroup video_params
* @{
* @arg in_time_base: to set time base manually
* @} */
Expand All @@ -1166,7 +1166,7 @@ int CFFEncoder::init_codec(int idx, AVFrame *frame) {
}
}

/** @addtogroup EncM
/** @addtogroup video_params
* @{
* @arg vsync: to set the video sync method on frame rate, "auto" by
* default.
Expand All @@ -1186,7 +1186,7 @@ int CFFEncoder::init_codec(int idx, AVFrame *frame) {
else if (!av_strcasecmp(s_vsync.c_str(), "drop"))
vsync_method_ = VSYNC_DROP;
}
/** @addtogroup EncM
/** @addtogroup video_params
* @{
* @arg max_fr: to set the frame rate
* @} */
Expand All @@ -1204,7 +1204,7 @@ int CFFEncoder::init_codec(int idx, AVFrame *frame) {
if (vsync_method_ == VSYNC_AUTO)
vsync_method_ = VSYNC_VFR;
}
/** @addtogroup EncM
/** @addtogroup video_params
* @{
* @arg max_fr: to set the frame rate, similar as ffmpeg
* @} */
Expand Down Expand Up @@ -1265,7 +1265,7 @@ int CFFEncoder::init_codec(int idx, AVFrame *frame) {
enc_ctxs_[idx]->sample_aspect_ratio;
}

/** @addtogroup EncM
/** @addtogroup video_params
* @{
* @arg qscal: to set the qscale for the encoder global_quality
* @} */
Expand All @@ -1279,7 +1279,7 @@ int CFFEncoder::init_codec(int idx, AVFrame *frame) {
enc_ctxs_[idx]->global_quality = FF_QP2LAMBDA * qscale;
}

/** @addtogroup EncM
/** @addtogroup video_params
* @{
* @arg vtag: to set the vtag for output stream
* @} */
Expand All @@ -1288,7 +1288,7 @@ int CFFEncoder::init_codec(int idx, AVFrame *frame) {
video_params_.erase("vtag");
}

/** @addtogroup EncM
/** @addtogroup video_params
* @{
* @arg bit_rate or b: to set the bitrate for video encode
* @} */
Expand All @@ -1315,7 +1315,7 @@ int CFFEncoder::init_codec(int idx, AVFrame *frame) {
enc_ctxs_[idx]->channel_layout =
av_get_default_channel_layout(enc_ctxs_[idx]->channels);

/** @addtogroup EncM
/** @addtogroup audio_params
* @{
* @arg channels: to set the channels for input audio
* @} */
Expand All @@ -1341,7 +1341,7 @@ int CFFEncoder::init_codec(int idx, AVFrame *frame) {
}
}

/** @addtogroup EncM
/** @addtogroup audio_params
* @{
* @arg bit_rate or b: to set the bit_rate for audio encode
* @} */
Expand All @@ -1350,7 +1350,7 @@ int CFFEncoder::init_codec(int idx, AVFrame *frame) {
audio_params_.erase("bit_rate");
}

/** @addtogroup EncM
/** @addtogroup audio_params
* @{
* @arg sample_rate: to set the sample_rate for audio encode
* @} */
Expand Down Expand Up @@ -1395,7 +1395,7 @@ int CFFEncoder::init_codec(int idx, AVFrame *frame) {
enc_ctxs_[idx]->global_quality = FF_QP2LAMBDA * qscale;
}

/** @addtogroup EncM
/** @addtogroup audio_params
* @{
* @arg atag: to set the atag for output stream
* @} */
Expand Down

0 comments on commit bfe3409

Please sign in to comment.