summary refs log tree commit diff
path: root/pkgs/development/libraries/opal/libav10.patch
blob: 3e02704f8998916c66276bc4cede4038c467208b (plain) (blame)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
Description: Fix compilation against libav10 
Author: Reinhard Tartler <siretart@tauware.de>
Bug-Debian: http://bugs.debian.org/739439

--- a/plugins/video/H.263-1998/h263-1998.cxx
+++ b/plugins/video/H.263-1998/h263-1998.cxx
@@ -94,7 +94,7 @@ static struct StdSizes {
   { CIF16_WIDTH, CIF16_HEIGHT, PLUGINCODEC_CIF16_MPI },
 };
 
-static FFMPEGLibrary FFMPEGLibraryInstance(CODEC_ID_H263P);
+static FFMPEGLibrary FFMPEGLibraryInstance(AV_CODEC_ID_H263P);
 
 
 /////////////////////////////////////////////////////////////////////////////
@@ -203,7 +203,7 @@ H263_Base_EncoderContext::~H263_Base_Enc
   PTRACE(4, m_prefix, "Encoder closed");
 }
 
-bool H263_Base_EncoderContext::Init(CodecID codecId)
+bool H263_Base_EncoderContext::Init(AVCodecID codecId)
 {
   PTRACE(5, m_prefix, "Opening encoder");
 
@@ -589,7 +589,7 @@ void H263_RFC2190_EncoderContext::RTPCal
 
 bool H263_RFC2190_EncoderContext::Init()
 {
-  if (!H263_Base_EncoderContext::Init(CODEC_ID_H263))
+  if (!H263_Base_EncoderContext::Init(AV_CODEC_ID_H263))
     return false;
 
 #if LIBAVCODEC_RTP_MODE
@@ -632,7 +632,7 @@ H263_RFC2429_EncoderContext::~H263_RFC24
 
 bool H263_RFC2429_EncoderContext::Init()
 {
-  return H263_Base_EncoderContext::Init(CODEC_ID_H263P);
+  return H263_Base_EncoderContext::Init(AV_CODEC_ID_H263P);
 }
 
 
@@ -656,7 +656,7 @@ H263_Base_DecoderContext::H263_Base_Deco
   if (!FFMPEGLibraryInstance.Load())
     return;
 
-  if ((m_codec = FFMPEGLibraryInstance.AvcodecFindDecoder(CODEC_ID_H263)) == NULL) {
+  if ((m_codec = FFMPEGLibraryInstance.AvcodecFindDecoder(AV_CODEC_ID_H263)) == NULL) {
     PTRACE(1, m_prefix, "Codec not found for decoder");
     return;
   }
--- a/plugins/video/H.264/h264-x264.cxx
+++ b/plugins/video/H.264/h264-x264.cxx
@@ -105,7 +105,7 @@ static struct PluginCodec_information Li
 
 ///////////////////////////////////////////////////////////////////////////////
 
-FFMPEGLibrary FFMPEGLibraryInstance(CODEC_ID_H264);
+FFMPEGLibrary FFMPEGLibraryInstance(AV_CODEC_ID_H264);
 
 PLUGINCODEC_CONTROL_LOG_FUNCTION_DEF
 
@@ -1065,17 +1065,17 @@ class MyDecoder : public PluginCodec<MY_
          allows you to fail the create operation (return false), which cannot
          be done in the normal C++ constructor. */
 
-      if ((m_codec = FFMPEGLibraryInstance.AvcodecFindDecoder(CODEC_ID_H264)) == NULL)
+      if ((m_codec = FFMPEGLibraryInstance.AvcodecFindDecoder(AV_CODEC_ID_H264)) == NULL)
         return false;
 
       if ((m_context = FFMPEGLibraryInstance.AvcodecAllocContext(m_codec)) == NULL)
         return false;
 
       m_context->workaround_bugs = FF_BUG_AUTODETECT;
-      m_context->idct_algo = FF_IDCT_H264;
+      m_context->idct_algo = FF_IDCT_AUTO;
       m_context->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK;
       m_context->flags = CODEC_FLAG_INPUT_PRESERVED | CODEC_FLAG_EMU_EDGE;
-      m_context->flags2 = CODEC_FLAG2_SKIP_RD |
+      m_context->flags2 = 
 #ifdef CODEC_FLAG2_DROP_FRAME_TIMECODE
                           CODEC_FLAG2_DROP_FRAME_TIMECODE |
 #endif
--- a/plugins/video/MPEG4-ffmpeg/mpeg4.cxx
+++ b/plugins/video/MPEG4-ffmpeg/mpeg4.cxx
@@ -205,7 +205,7 @@ const static struct mpeg4_resolution {
     { 0 }
 };
 
-FFMPEGLibrary FFMPEGLibraryInstance(CODEC_ID_MPEG4);
+FFMPEGLibrary FFMPEGLibraryInstance(AV_CODEC_ID_MPEG4);
 
 
 static bool mpeg4IsIframe (BYTE * frameBuffer, unsigned int frameLen )
@@ -688,7 +688,7 @@ void MPEG4EncoderContext::ResizeEncoding
 
 bool MPEG4EncoderContext::OpenCodec()
 {
-  if((m_avcodec = FFMPEGLibraryInstance.AvcodecFindEncoder(CODEC_ID_MPEG4)) == NULL){
+  if((m_avcodec = FFMPEGLibraryInstance.AvcodecFindEncoder(AV_CODEC_ID_MPEG4)) == NULL){
     PTRACE(1, "MPEG4", "Encoder not found");
     return false;
   }
@@ -1390,7 +1390,7 @@ void MPEG4DecoderContext::ResizeDecoding
 
 bool MPEG4DecoderContext::OpenCodec()
 {
-    if ((m_avcodec = FFMPEGLibraryInstance.AvcodecFindDecoder(CODEC_ID_MPEG4)) == NULL) {
+    if ((m_avcodec = FFMPEGLibraryInstance.AvcodecFindDecoder(AV_CODEC_ID_MPEG4)) == NULL) {
         PTRACE(1, "MPEG4", "Decoder not found for encoder");
         return false;
     }
--- a/plugins/video/H.263-1998/h263-1998.h
+++ b/plugins/video/H.263-1998/h263-1998.h
@@ -115,7 +115,7 @@ class H263_Base_EncoderContext
     virtual ~H263_Base_EncoderContext();
 
     virtual bool Init() = 0;
-    virtual bool Init(CodecID codecId);
+    virtual bool Init(AVCodecID codecId);
 
     virtual bool SetOptions(const char * const * options);
     virtual void SetOption(const char * option, const char * value);
--- a/plugins/video/common/dyna.cxx
+++ b/plugins/video/common/dyna.cxx
@@ -217,14 +217,14 @@ static void logCallbackFFMPEG(void * avc
 #endif
 
 
-FFMPEGLibrary::FFMPEGLibrary(CodecID codec)
+FFMPEGLibrary::FFMPEGLibrary(AVCodecID codec)
 {
   m_codec = codec;
-  if (m_codec==CODEC_ID_H264)
+  if (m_codec==AV_CODEC_ID_H264)
       snprintf( m_codecString, sizeof(m_codecString), "H264");
-  if (m_codec==CODEC_ID_H263P)
+  if (m_codec==AV_CODEC_ID_H263P)
       snprintf( m_codecString, sizeof(m_codecString), "H263+");
-  if (m_codec==CODEC_ID_MPEG4)
+  if (m_codec==AV_CODEC_ID_MPEG4)
       snprintf( m_codecString, sizeof(m_codecString), "MPEG4");
   m_isLoadedOK = false;
 }
@@ -268,12 +268,12 @@ bool FFMPEGLibrary::Load()
   return true;
 }
 
-AVCodec *FFMPEGLibrary::AvcodecFindEncoder(enum CodecID id)
+AVCodec *FFMPEGLibrary::AvcodecFindEncoder(enum AVCodecID id)
 {
   return avcodec_find_encoder(id);
 }
 
-AVCodec *FFMPEGLibrary::AvcodecFindDecoder(enum CodecID id)
+AVCodec *FFMPEGLibrary::AvcodecFindDecoder(enum AVCodecID id)
 {
   WaitAndSignal m(processLock);
 
@@ -308,13 +308,18 @@ int FFMPEGLibrary::AvcodecClose(AVCodecC
   return avcodec_close(ctx);
 }
 
+#undef  FFMAX
+#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) 
 int FFMPEGLibrary::AvcodecEncodeVideo(AVCodecContext *ctx, BYTE *buf, int buf_size, const AVFrame *pict)
 {
+  AVPacket pkt = { 0 };
+  int ret, got_output;
   int res;
 
-  res = avcodec_encode_video(ctx, buf, buf_size, pict);
+  ret = avcodec_encode_video2(ctx, &pkt, pict, &got_output);
 
-  PTRACE(6, m_codecString, "DYNA\tEncoded into " << res << " bytes, max " << buf_size);
+  PTRACE(6, m_codecString, "DYNA\tEncoded into " << ret << " bytes, max " << buf_size);
+  memcpy(buf, pkt.data, FFMAX(pkt.size, buf_size));
   return res;
 }
 
--- a/plugins/video/common/dyna.h
+++ b/plugins/video/common/dyna.h
@@ -88,13 +88,13 @@ class DynaLink
 class FFMPEGLibrary 
 {
   public:
-    FFMPEGLibrary(CodecID codec);
+    FFMPEGLibrary(AVCodecID codec);
     ~FFMPEGLibrary();
 
     bool Load();
 
-    AVCodec *AvcodecFindEncoder(enum CodecID id);
-    AVCodec *AvcodecFindDecoder(enum CodecID id);
+    AVCodec *AvcodecFindEncoder(enum AVCodecID id);
+    AVCodec *AvcodecFindDecoder(enum AVCodecID id);
     AVCodecContext *AvcodecAllocContext(AVCodec*);
     AVFrame *AvcodecAllocFrame(void);
     int AvcodecOpen(AVCodecContext *ctx, AVCodec *codec);
@@ -117,7 +117,7 @@ class FFMPEGLibrary
     DynaLink m_libAvcodec;
     DynaLink m_libAvutil;
 
-    CodecID m_codec;
+    AVCodecID m_codec;
     char m_codecString[32];
 
     bool m_isLoadedOK;