|
| 1 | +diff --git a/src/decoder.cpp b/src/decoder.cpp |
| 2 | +index 0a12d25..10834e3 100644 |
| 3 | +--- a/src/decoder.cpp |
| 4 | ++++ b/src/decoder.cpp |
| 5 | +@@ -38,7 +38,11 @@ Decoder::~Decoder() { reset(); } |
| 6 | + void Decoder::reset() |
| 7 | + { |
| 8 | + if (codecContext_) { |
| 9 | ++#if LIBAVFORMAT_VERSION_MAJOR < 59 |
| 10 | + avcodec_close(codecContext_); |
| 11 | ++#else |
| 12 | ++ avcodec_free_context(&codecContext_); |
| 13 | ++#endif |
| 14 | + av_free(codecContext_); |
| 15 | + codecContext_ = NULL; |
| 16 | + } |
| 17 | +diff --git a/src/encoder.cpp b/src/encoder.cpp |
| 18 | +index a4b6de6..2e1d4a2 100644 |
| 19 | +--- a/src/encoder.cpp |
| 20 | ++++ b/src/encoder.cpp |
| 21 | +@@ -54,7 +54,11 @@ static void free_frame(AVFrame ** frame) |
| 22 | + void Encoder::closeCodec() |
| 23 | + { |
| 24 | + if (codecContext_) { |
| 25 | ++#if LIBAVFORMAT_VERSION_MAJOR < 59 |
| 26 | + avcodec_close(codecContext_); |
| 27 | ++#else |
| 28 | ++ avcodec_free_context(&codecContext_); |
| 29 | ++#endif |
| 30 | + codecContext_ = nullptr; |
| 31 | + } |
| 32 | + free_frame(&frame_); |
| 33 | +diff --git a/src/utils.cpp b/src/utils.cpp |
| 34 | +index da089e4..01e8eea 100644 |
| 35 | +--- a/src/utils.cpp |
| 36 | ++++ b/src/utils.cpp |
| 37 | +@@ -104,8 +104,15 @@ enum AVPixelFormat get_preferred_pixel_format( |
| 38 | + std::vector<enum AVPixelFormat> get_encoder_formats(const AVCodec * c) |
| 39 | + { |
| 40 | + std::vector<enum AVPixelFormat> formats; |
| 41 | +- if (c && c->pix_fmts) { |
| 42 | +- for (const auto * p = c->pix_fmts; *p != AV_PIX_FMT_NONE; ++p) { |
| 43 | ++#if LIBAVUTIL_VERSION_MAJOR > 59 || (LIBAVUTIL_VERSION_MAJOR == 59 && LIBAVUTIL_VERSION_MINOR >= 39) |
| 44 | ++ const enum AVPixelFormat *pix_fmts = NULL; |
| 45 | ++ avcodec_get_supported_config(NULL, c, AV_CODEC_CONFIG_PIX_FORMAT, 0, (const void **) &pix_fmts, NULL); |
| 46 | ++ if (c && pix_fmts) { |
| 47 | ++#else |
| 48 | ++ const enum AVPixelFormat *pix_fmts = c->pix_fmts; |
| 49 | ++ if (c && pix_fmts) { |
| 50 | ++#endif |
| 51 | ++ for (const auto * p = pix_fmts; *p != AV_PIX_FMT_NONE; ++p) { |
| 52 | + formats.push_back(*p); |
| 53 | + } |
| 54 | + } |
0 commit comments