Skip to content

Commit 11c5053

Browse files
authored
Revert "addressing #3805: remove deprecated function call 3 (#3861)"
This reverts commit f6b6b51.
1 parent 4c95bb6 commit 11c5053

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

torchvision/csrc/io/decoder/audio_stream.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ namespace ffmpeg {
77

88
namespace {
99
bool operator==(const AudioFormat& x, const AVFrame& y) {
10-
return static_cast<int>(x.samples) == y.sample_rate &&
11-
static_cast<int>(x.channels) == y.channels && x.format == y.format;
10+
return x.samples == y.sample_rate && x.channels == y.channels &&
11+
x.format == y.format;
1212
}
1313

1414
bool operator==(const AudioFormat& x, const AVCodecContext& y) {
15-
return static_cast<int>(x.samples) == y.sample_rate &&
16-
static_cast<int>(x.channels) == y.channels && x.format == y.sample_fmt;
15+
return x.samples == y.sample_rate && x.channels == y.channels &&
16+
x.format == y.sample_fmt;
1717
}
1818

1919
AudioFormat& toAudioFormat(AudioFormat& x, const AVFrame& y) {

torchvision/csrc/io/decoder/decoder.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ int64_t Decoder::seekCallback(int64_t offset, int whence) {
196196
void Decoder::initOnce() {
197197
static std::once_flag flagInit;
198198
std::call_once(flagInit, []() {
199+
av_register_all();
200+
avcodec_register_all();
199201
avformat_network_init();
200202
// register ffmpeg lock manager
201203
av_lockmgr_register(&ffmpeg_lock);
@@ -395,10 +397,10 @@ bool Decoder::init(
395397
}
396398

397399
bool Decoder::openStreams(std::vector<DecoderMetadata>* metadata) {
398-
for (int i = 0; i < static_cast<int>(inputCtx_->nb_streams); i++) {
400+
for (int i = 0; i < inputCtx_->nb_streams; i++) {
399401
// - find the corespondent format at params_.formats set
400402
MediaFormat format;
401-
const auto media = inputCtx_->streams[i]->codecpar->codec_type;
403+
const auto media = inputCtx_->streams[i]->codec->codec_type;
402404
if (!mapFfmpegType(media, &format.type)) {
403405
VLOG(1) << "Stream media: " << media << " at index " << i
404406
<< " gets ignored, unknown type";

0 commit comments

Comments
 (0)