summaryrefslogtreecommitdiff
path: root/ffmpeg5-compat.patch
diff options
context:
space:
mode:
Diffstat (limited to 'ffmpeg5-compat.patch')
-rw-r--r--ffmpeg5-compat.patch101
1 files changed, 101 insertions, 0 deletions
diff --git a/ffmpeg5-compat.patch b/ffmpeg5-compat.patch
new file mode 100644
index 0000000..b8c57ca
--- /dev/null
+++ b/ffmpeg5-compat.patch
@@ -0,0 +1,101 @@
+--- a/osdk-core/advanced-sensing/camera_stream/src/dji_camera_stream_decoder.hpp
++++ b/osdk-core/advanced-sensing/camera_stream/src/dji_camera_stream_decoder.hpp
+@@ -13,6 +13,7 @@
+ extern "C"{
+ #include <libavcodec/avcodec.h>
+ #include <libavformat/avformat.h>
++#include <libavutil/imgutils.h>
+ #include <libswscale/swscale.h>
+ }
+
+@@ -52,7 +53,7 @@
+
+ pthread_mutex_t decodemutex;
+ AVCodecContext* pCodecCtx;
+- AVCodec* pCodec;
++ const AVCodec* pCodec;
+ AVCodecParserContext* pCodecParserCtx;
+ SwsContext* pSwsCtx;
+
+--- a/osdk-core/advanced-sensing/camera_stream/src/dji_camera_stream_decoder.cpp
++++ b/osdk-core/advanced-sensing/camera_stream/src/dji_camera_stream_decoder.cpp
+@@ -67,7 +67,6 @@
+ return true;
+ }
+
+- avcodec_register_all();
+ pCodecCtx = avcodec_alloc_context3(NULL);
+ if (!pCodecCtx)
+ {
+@@ -130,7 +129,7 @@
+
+ if (NULL != pFrameYUV)
+ {
+- av_free(pFrameYUV);
++ av_frame_free(&pFrameYUV);
+ pFrameYUV = NULL;
+ }
+
+@@ -140,16 +139,10 @@
+ pCodecParserCtx = NULL;
+ }
+
+- if (NULL != pCodec)
+- {
+- avcodec_close(pCodecCtx);
+- pCodec = NULL;
+- }
+-
+ if (NULL != pCodecCtx)
+ {
+- av_free(pCodecCtx);
+- pCodecCtx = NULL;
++ avcodec_free_context(&pCodecCtx);
++ pCodec = NULL;
+ }
+
+ if (NULL != rgbBuf )
+@@ -160,7 +153,7 @@
+
+ if (NULL != pFrameRGB)
+ {
+- av_free(pFrameRGB);
++ av_frame_free(&pFrameRGB);
+ pFrameRGB = NULL;
+ }
+
+@@ -219,7 +212,12 @@
+ if (pkt.size > 0)
+ {
+ int gotPicture = 0;
+- avcodec_decode_video2(pCodecCtx, pFrameYUV, &gotPicture, &pkt);
++ int ret = avcodec_send_packet(pCodecCtx, &pkt);
++ if (ret >= 0)
++ {
++ ret = avcodec_receive_frame(pCodecCtx, pFrameYUV);
++ gotPicture = (ret == 0) ? 1 : 0;
++ }
+
+ if (!gotPicture)
+ {
+@@ -241,9 +239,9 @@
+
+ if(NULL == rgbBuf)
+ {
+- bufSize = avpicture_get_size(AV_PIX_FMT_RGB24, w, h);
++ bufSize = av_image_get_buffer_size(AV_PIX_FMT_RGB24, w, h, 1);
+ rgbBuf = (uint8_t*) av_malloc(bufSize);
+- avpicture_fill((AVPicture*)pFrameRGB, rgbBuf, AV_PIX_FMT_RGB24, w, h);
++ av_image_fill_arrays(pFrameRGB->data, pFrameRGB->linesize, rgbBuf, AV_PIX_FMT_RGB24, w, h, 1);
+ }
+
+ if(NULL != pSwsCtx && NULL != rgbBuf)
+@@ -261,7 +259,7 @@
+ }
+ }
+ pthread_mutex_unlock(&decodemutex);
+- av_free_packet(&pkt);
++ av_packet_unref(&pkt);
+ }
+
+ bool DJICameraStreamDecoder::registerCallback(CameraImageCallback f, void *param)