Skip to content

Commit 31a0fe4

Browse files
NicolasHugdatumbox
authored andcommitted
[fbsync] Fixed some ffmpeg deprecation warnings in decoder (#4003)
Summary: * Fixed some ffmpeg deprecation warnings in decoder * Fixed clang error Reviewed By: fmassa Differential Revision: D29097712 fbshipit-source-id: 4810e7d0902c1edb22930575cae90f2826b6c566 Co-authored-by: Vasilis Vryniotis <[email protected]>
1 parent ea99221 commit 31a0fe4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

torchvision/csrc/io/decoder/decoder.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "decoder.h"
22
#include <c10/util/Logging.h>
3+
#include <libavutil/avutil.h>
34
#include <future>
45
#include <iostream>
56
#include <mutex>
@@ -196,8 +197,10 @@ int64_t Decoder::seekCallback(int64_t offset, int whence) {
196197
void Decoder::initOnce() {
197198
static std::once_flag flagInit;
198199
std::call_once(flagInit, []() {
200+
#if LIBAVUTIL_VERSION_MAJOR < 56 // Before FFMPEG 4.0
199201
av_register_all();
200202
avcodec_register_all();
203+
#endif
201204
avformat_network_init();
202205
// register ffmpeg lock manager
203206
av_lockmgr_register(&ffmpeg_lock);
@@ -397,10 +400,14 @@ bool Decoder::init(
397400
}
398401

399402
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++) {
401404
// - find the corespondent format at params_.formats set
402405
MediaFormat format;
406+
#if LIBAVUTIL_VERSION_MAJOR < 56 // Before FFMPEG 4.0
403407
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
404411
if (!mapFfmpegType(media, &format.type)) {
405412
VLOG(1) << "Stream media: " << media << " at index " << i
406413
<< " gets ignored, unknown type";

0 commit comments

Comments
 (0)