File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
torchvision/csrc/io/decoder Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1
1
#include " decoder.h"
2
2
#include < c10/util/Logging.h>
3
+ #include < libavutil/avutil.h>
3
4
#include < future>
4
5
#include < iostream>
5
6
#include < mutex>
@@ -196,8 +197,10 @@ int64_t Decoder::seekCallback(int64_t offset, int whence) {
196
197
void Decoder::initOnce () {
197
198
static std::once_flag flagInit;
198
199
std::call_once (flagInit, []() {
200
+ #if LIBAVUTIL_VERSION_MAJOR < 56 // Before FFMPEG 4.0
199
201
av_register_all ();
200
202
avcodec_register_all ();
203
+ #endif
201
204
avformat_network_init ();
202
205
// register ffmpeg lock manager
203
206
av_lockmgr_register (&ffmpeg_lock);
@@ -397,10 +400,14 @@ bool Decoder::init(
397
400
}
398
401
399
402
bool Decoder::openStreams (std::vector<DecoderMetadata>* metadata) {
400
- for (int i = 0 ; i < inputCtx_->nb_streams ; i++) {
403
+ for (unsigned int i = 0 ; i < inputCtx_->nb_streams ; i++) {
401
404
// - find the corespondent format at params_.formats set
402
405
MediaFormat format;
406
+ #if LIBAVUTIL_VERSION_MAJOR < 56 // Before FFMPEG 4.0
403
407
const auto media = inputCtx_->streams [i]->codec ->codec_type ;
408
+ #else // FFMPEG 4.0+
409
+ const auto media = inputCtx_->streams [i]->codecpar ->codec_type ;
410
+ #endif
404
411
if (!mapFfmpegType (media, &format.type )) {
405
412
VLOG (1 ) << " Stream media: " << media << " at index " << i
406
413
<< " gets ignored, unknown type" ;
You can’t perform that action at this time.
0 commit comments