summaryrefslogtreecommitdiff
path: root/sci-libs/ignition-common/files/ffmpeg5.patch
blob: 668b2befeb740c2ed8dcb357af519d15d732d80d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Index: ign-common-ignition-common3_3.14.0/av/src/AudioDecoder.cc
===================================================================
--- ign-common-ignition-common3_3.14.0.orig/av/src/AudioDecoder.cc
+++ ign-common-ignition-common3_3.14.0/av/src/AudioDecoder.cc
@@ -35,7 +35,7 @@ class ignition::common::AudioDecoderPriv
   public: AVCodecContext *codecCtx;
 
   /// \brief libavcodec audio codec.
-  public: AVCodec *codec;
+  public: const AVCodec *codec;
 
   /// \brief Index of the audio stream.
   public: int audioStream;
@@ -132,8 +132,12 @@ bool AudioDecoder::Decode(uint8_t **_out
 # pragma GCC diagnostic push
 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 #endif
-        bytesDecoded = avcodec_decode_audio4(this->data->codecCtx, decodedFrame,
-            &gotFrame, &packet1);
+	bytesDecoded = avcodec_send_packet(this->data->codecCtx, &packet1);                                                        
+	if (bytesDecoded >= 0 || bytesDecoded == AVERROR_EOF) {                                                              
+		bytesDecoded = avcodec_receive_frame(this->data->codecCtx, decodedFrame);
+		gotFrame = bytesDecoded >= 0;
+		if (bytesDecoded == AVERROR(EAGAIN) || bytesDecoded == AVERROR_EOF) bytesDecoded = 0;
+	}                                                                                   
 #ifndef _WIN32
 # pragma GCC diagnostic pop
 #endif
@@ -224,7 +228,7 @@ bool AudioDecoder::SetFile(const std::st
 # pragma GCC diagnostic push
 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 #endif
-    if (this->data->formatCtx->streams[i]->codec->codec_type == // NOLINT(*)
+    if (this->data->formatCtx->streams[i]->codecpar->codec_type == // NOLINT(*)
         AVMEDIA_TYPE_AUDIO)
 #ifndef _WIN32
 # pragma GCC diagnostic pop
@@ -249,8 +253,9 @@ bool AudioDecoder::SetFile(const std::st
 # pragma GCC diagnostic push
 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 #endif
-  this->data->codecCtx = this->data->formatCtx->streams[
-    this->data->audioStream]->codec;
+  this->data->codecCtx = avcodec_alloc_context3(nullptr);
+  avcodec_parameters_to_context(this->data->codecCtx, this->data->formatCtx->streams[
+    this->data->audioStream]->codecpar);
 #ifndef _WIN32
 # pragma GCC diagnostic pop
 #endif
Index: ign-common-ignition-common3_3.14.0/av/src/Video.cc
===================================================================
--- ign-common-ignition-common3_3.14.0.orig/av/src/Video.cc
+++ ign-common-ignition-common3_3.14.0/av/src/Video.cc
@@ -91,7 +91,7 @@ void Video::Cleanup()
 /////////////////////////////////////////////////
 bool Video::Load(const std::string &_filename)
 {
-  AVCodec *codec = nullptr;
+  const AVCodec *codec = nullptr;
   this->dataPtr->videoStream = -1;
 
   if (this->dataPtr->formatCtx || this->dataPtr->avFrame ||
Index: ign-common-ignition-common3_3.14.0/av/src/VideoEncoder.cc
===================================================================
--- ign-common-ignition-common3_3.14.0.orig/av/src/VideoEncoder.cc
+++ ign-common-ignition-common3_3.14.0/av/src/VideoEncoder.cc
@@ -106,7 +106,7 @@ class IGNITION_COMMON_AV_HIDDEN ignition
   /// Find a suitable encoder for the given codec ID.
   /// \param[in] _codecId ID of the codec we seek the encoder for.
   /// \return The matched encoder (or nullptr on failure).
-  public: AVCodec* FindEncoder(AVCodecID _codecId);
+  public: const AVCodec* FindEncoder(AVCodecID _codecId);
 
   /// \brief Get a pointer to the frame that contains the encoder input. This
   /// mainly serves for uploading the frame to GPU buffer if HW acceleration is
@@ -123,7 +123,7 @@ class IGNITION_COMMON_AV_HIDDEN ignition
 };
 
 /////////////////////////////////////////////////
-AVCodec* VideoEncoderPrivate::FindEncoder(AVCodecID _codecId)
+const AVCodec* VideoEncoderPrivate::FindEncoder(AVCodecID _codecId)
 {
 #ifdef IGN_COMMON_BUILD_HW_VIDEO
   if (this->hwEncoder)
@@ -367,7 +367,7 @@ bool VideoEncoder::Start(
   }
   else
   {
-    AVOutputFormat *outputFormat = av_guess_format(nullptr,
+    const AVOutputFormat *outputFormat = av_guess_format(nullptr,
                                    this->dataPtr->filename.c_str(), nullptr);
 
     if (!outputFormat)