-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: wep21 <[email protected]>
- Loading branch information
Showing
5 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
diff --git a/src/decoder.cpp b/src/decoder.cpp | ||
index 0a12d25..10834e3 100644 | ||
--- a/src/decoder.cpp | ||
+++ b/src/decoder.cpp | ||
@@ -38,7 +38,11 @@ Decoder::~Decoder() { reset(); } | ||
void Decoder::reset() | ||
{ | ||
if (codecContext_) { | ||
+#if LIBAVFORMAT_VERSION_MAJOR < 59 | ||
avcodec_close(codecContext_); | ||
+#else | ||
+ avcodec_free_context(&codecContext_); | ||
+#endif | ||
av_free(codecContext_); | ||
codecContext_ = NULL; | ||
} | ||
diff --git a/src/encoder.cpp b/src/encoder.cpp | ||
index a4b6de6..2e1d4a2 100644 | ||
--- a/src/encoder.cpp | ||
+++ b/src/encoder.cpp | ||
@@ -54,7 +54,11 @@ static void free_frame(AVFrame ** frame) | ||
void Encoder::closeCodec() | ||
{ | ||
if (codecContext_) { | ||
+#if LIBAVFORMAT_VERSION_MAJOR < 59 | ||
avcodec_close(codecContext_); | ||
+#else | ||
+ avcodec_free_context(&codecContext_); | ||
+#endif | ||
codecContext_ = nullptr; | ||
} | ||
free_frame(&frame_); | ||
diff --git a/src/utils.cpp b/src/utils.cpp | ||
index da089e4..01e8eea 100644 | ||
--- a/src/utils.cpp | ||
+++ b/src/utils.cpp | ||
@@ -104,8 +104,15 @@ enum AVPixelFormat get_preferred_pixel_format( | ||
std::vector<enum AVPixelFormat> get_encoder_formats(const AVCodec * c) | ||
{ | ||
std::vector<enum AVPixelFormat> formats; | ||
- if (c && c->pix_fmts) { | ||
- for (const auto * p = c->pix_fmts; *p != AV_PIX_FMT_NONE; ++p) { | ||
+#if LIBAVUTIL_VERSION_MAJOR > 59 || (LIBAVUTIL_VERSION_MAJOR == 59 && LIBAVUTIL_VERSION_MINOR >= 39) | ||
+ const enum AVPixelFormat *pix_fmts = NULL; | ||
+ avcodec_get_supported_config(NULL, c, AV_CODEC_CONFIG_PIX_FORMAT, 0, (const void **) &pix_fmts, NULL); | ||
+ if (c && pix_fmts) { | ||
+#else | ||
+ const enum AVPixelFormat *pix_fmts = c->pix_fmts; | ||
+ if (c && pix_fmts) { | ||
+#endif | ||
+ for (const auto * p = pix_fmts; *p != AV_PIX_FMT_NONE; ++p) { | ||
formats.push_back(*p); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters