Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion torchvision/csrc/io/decoder/decoder.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "decoder.h"
#include <c10/util/Logging.h>
#include <libavutil/avutil.h>
#include <future>
#include <iostream>
#include <mutex>
Expand Down Expand Up @@ -196,8 +197,10 @@ int64_t Decoder::seekCallback(int64_t offset, int whence) {
void Decoder::initOnce() {
static std::once_flag flagInit;
std::call_once(flagInit, []() {
#if LIBAVUTIL_VERSION_MAJOR < 56 // Before FFMPEG 4.0
av_register_all();
avcodec_register_all();
#endif
avformat_network_init();
// register ffmpeg lock manager
av_lockmgr_register(&ffmpeg_lock);
Expand Down Expand Up @@ -397,10 +400,14 @@ bool Decoder::init(
}

bool Decoder::openStreams(std::vector<DecoderMetadata>* metadata) {
for (int i = 0; i < inputCtx_->nb_streams; i++) {
for (unsigned int i = 0; i < inputCtx_->nb_streams; i++) {
// - find the corespondent format at params_.formats set
MediaFormat format;
#if LIBAVUTIL_VERSION_MAJOR < 56 // Before FFMPEG 4.0
const auto media = inputCtx_->streams[i]->codec->codec_type;
#else // FFMPEG 4.0+
const auto media = inputCtx_->streams[i]->codecpar->codec_type;
#endif
if (!mapFfmpegType(media, &format.type)) {
VLOG(1) << "Stream media: " << media << " at index " << i
<< " gets ignored, unknown type";
Expand Down