Package: libavg / 1.8.2-3

ffmpeg_2.9.patch Patch series | download
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
Description: Replace deprecated FFmpeg API
Author: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Last-Update: <2015-11-02>

--- a/src/player/VideoWriterThread.cpp
+++ b/src/player/VideoWriterThread.cpp
@@ -35,7 +35,7 @@ using namespace std;
 namespace avg {
 
 const unsigned int VIDEO_BUFFER_SIZE = 400000;
-const AVPixelFormat STREAM_PIXEL_FORMAT = ::PIX_FMT_YUVJ420P;
+const AVPixelFormat STREAM_PIXEL_FORMAT = ::AV_PIX_FMT_YUVJ420P;
 
 VideoWriterThread::VideoWriterThread(CQueue& cmdQueue, const string& sFilename,
         IntPoint size, int frameRate, int qMin, int qMax)
@@ -95,7 +95,7 @@ void VideoWriterThread::close()
 
         av_free(m_pOutputFormatContext);
         av_free(m_pVideoBuffer);
-        av_free(m_pConvertedFrame);
+        av_frame_free(&m_pConvertedFrame);
         av_free(m_pPictureBuffer);
         sws_freeContext(m_pFrameConversionContext);
         m_pOutputFormatContext = 0;
@@ -174,7 +174,7 @@ void VideoWriterThread::open()
     }
 
     m_pFrameConversionContext = sws_getContext(m_Size.x, m_Size.y, 
-            ::PIX_FMT_RGB32, m_Size.x, m_Size.y, STREAM_PIXEL_FORMAT, 
+            ::AV_PIX_FMT_RGB32, m_Size.x, m_Size.y, STREAM_PIXEL_FORMAT,
             SWS_BILINEAR, NULL, NULL, NULL);
 
     m_pConvertedFrame = createFrame(STREAM_PIXEL_FORMAT, m_Size);
@@ -234,7 +234,7 @@ AVFrame* VideoWriterThread::createFrame(
 {
     AVFrame* pPicture;
 
-    pPicture = avcodec_alloc_frame();
+    pPicture = av_frame_alloc();
 
     int memNeeded = avpicture_get_size(pixelFormat, size.x, size.y);
     m_pPictureBuffer = static_cast<unsigned char*>(av_malloc(memNeeded));
--- a/src/video/AudioDecoderThread.cpp
+++ b/src/video/AudioDecoderThread.cpp
@@ -132,7 +132,7 @@ void AudioDecoderThread::decodePacket(AV
     pTempPacket->size = pPacket->size;
 #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53, 25, 0)
     AVFrame* pDecodedFrame;
-    pDecodedFrame = avcodec_alloc_frame();
+    pDecodedFrame = av_frame_alloc();
 #else
     pDecodedData = (char*)av_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE +
             FF_INPUT_BUFFER_PADDING_SIZE);
@@ -197,7 +197,7 @@ void AudioDecoderThread::decodePacket(AV
         }
     }
 #if LIBAVCODEC_VERSION_MAJOR > 53
-    avcodec_free_frame(&pDecodedFrame);
+    av_frame_free(&pDecodedFrame);
 #elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53, 25, 0)
     delete pDecodedFrame;
 #else
--- a/src/video/FFMpegFrameDecoder.cpp
+++ b/src/video/FFMpegFrameDecoder.cpp
@@ -119,29 +119,29 @@ void FFMpegFrameDecoder::convertFrameToB
     switch (pBmp->getPixelFormat()) {
         case R8G8B8X8:
         case R8G8B8A8:
-            destFmt = PIX_FMT_RGBA;
+            destFmt = AV_PIX_FMT_RGBA;
             break;
         case B8G8R8X8:
         case B8G8R8A8:
-            destFmt = PIX_FMT_BGRA;
+            destFmt = AV_PIX_FMT_BGRA;
             break;
         case R8G8B8:
-            destFmt = PIX_FMT_RGB24;
+            destFmt = AV_PIX_FMT_RGB24;
             break;
         case B8G8R8:
-            destFmt = PIX_FMT_BGR24;
+            destFmt = AV_PIX_FMT_BGR24;
             break;
         case YCbCr422:
-            destFmt = PIX_FMT_YUYV422;
+            destFmt = AV_PIX_FMT_YUYV422;
             break;
         default:
             AVG_ASSERT_MSG(false, (string("FFMpegFrameDecoder: Dest format ") +
                     toString(pBmp->getPixelFormat()) + " not supported.").c_str());
-            destFmt = PIX_FMT_BGRA;
+            destFmt = AV_PIX_FMT_BGRA;
     }
     AVCodecContext const* pContext = m_pStream->codec;
-    if (destFmt == PIX_FMT_BGRA && (pContext->pix_fmt == PIX_FMT_YUV420P || 
-                pContext->pix_fmt == PIX_FMT_YUVJ420P))
+    if (destFmt == AV_PIX_FMT_BGRA && (pContext->pix_fmt == AV_PIX_FMT_YUV420P ||
+                pContext->pix_fmt == AV_PIX_FMT_YUVJ420P))
     {
         ScopeTimer timer(ConvertImageLibavgProfilingZone);
         BitmapPtr pBmpY(new Bitmap(pBmp->getSize(), I8, pFrame->data[0],
@@ -151,7 +151,7 @@ void FFMpegFrameDecoder::convertFrameToB
         BitmapPtr pBmpV(new Bitmap(pBmp->getSize(), I8, pFrame->data[2],
                 pFrame->linesize[2], false));
         pBmp->copyYUVPixels(*pBmpY, *pBmpU, *pBmpV, 
-                pContext->pix_fmt == PIX_FMT_YUVJ420P);
+                pContext->pix_fmt == AV_PIX_FMT_YUVJ420P);
     } else {
         if (!m_pSwsContext) {
             m_pSwsContext = sws_getContext(pContext->width, pContext->height, 
--- a/src/video/SyncVideoDecoder.cpp
+++ b/src/video/SyncVideoDecoder.cpp
@@ -82,7 +82,7 @@ void SyncVideoDecoder::startDecoding(boo
     m_pFrameDecoder = FFMpegFrameDecoderPtr(new FFMpegFrameDecoder(getVideoStream()));
     m_pFrameDecoder->setFPS(m_FPS);
 #if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(54, 28, 0) 
-    m_pFrame = avcodec_alloc_frame();
+    m_pFrame = av_frame_alloc();
 #else
     m_pFrame = new AVFrame;
 #endif
@@ -96,7 +96,7 @@ void SyncVideoDecoder::close()
     m_pFrameDecoder = FFMpegFrameDecoderPtr();
     VideoDecoder::close();
 #if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(54, 28, 0) 
-    avcodec_free_frame(&m_pFrame);
+    av_frame_free(&m_pFrame);
 #else
     delete m_pFrame;
 #endif
--- a/src/video/VDPAUDecoder.cpp
+++ b/src/video/VDPAUDecoder.cpp
@@ -43,7 +43,7 @@ namespace avg {
 VDPAUDecoder::VDPAUDecoder()
     : m_VDPDecoder(VDP_INVALID_HANDLE),
       m_VDPMixer(VDP_INVALID_HANDLE),
-      m_PixFmt(PIX_FMT_NONE),
+      m_PixFmt(AV_PIX_FMT_NONE),
       m_Size(-1,-1)
 {
 }
@@ -92,8 +92,7 @@ AVCodec* VDPAUDecoder::openCodec(AVCodec
             pCodec = 0;
     }
     if (pCodec) {
-        pContext->get_buffer = VDPAUDecoder::getBuffer;
-        pContext->release_buffer = VDPAUDecoder::releaseBuffer;
+        pContext->get_buffer2 = VDPAUDecoder::getBuffer2;
         pContext->draw_horiz_band = VDPAUDecoder::drawHorizBand;
         pContext->get_format = VDPAUDecoder::getFormat;
         pContext->slice_flags = SLICE_FLAG_CODED_ORDER | SLICE_FLAG_ALLOW_FIELD;
@@ -111,19 +110,19 @@ bool VDPAUDecoder::isAvailable()
 #endif
 }
 
-int VDPAUDecoder::getBuffer(AVCodecContext* pContext, AVFrame* pFrame)
+int VDPAUDecoder::getBuffer2(AVCodecContext* pContext, AVFrame* pFrame, int flags)
 {
     VDPAUDecoder* pVDPAUDecoder = (VDPAUDecoder*)pContext->opaque;
     return pVDPAUDecoder->getBufferInternal(pContext, pFrame);
 }
 
 // does not release the render structure, that will be unlocked after getting data
-void VDPAUDecoder::releaseBuffer(struct AVCodecContext* pContext, AVFrame* pFrame)
+void VDPAUDecoder::dummy_free_buffer(void *opaque, uint8_t *data)
 {
+    AVFrame* pFrame = (AVFrame*)opaque;
     pFrame->data[0] = 0;
 }
 
-
 // main rendering routine
 void VDPAUDecoder::drawHorizBand(struct AVCodecContext* pContext, const AVFrame* src,
         int offset[4], int y, int type, int height)
@@ -136,15 +135,15 @@ AVPixelFormat VDPAUDecoder::getFormat(AV
 {
     switch (pContext->codec_id) {
         case AV_CODEC_ID_H264:
-            return PIX_FMT_VDPAU_H264;
+            return AV_PIX_FMT_VDPAU_H264;
         case AV_CODEC_ID_MPEG1VIDEO:
-            return PIX_FMT_VDPAU_MPEG1;
+            return AV_PIX_FMT_VDPAU_MPEG1;
         case AV_CODEC_ID_MPEG2VIDEO:
-            return PIX_FMT_VDPAU_MPEG2;
+            return AV_PIX_FMT_VDPAU_MPEG2;
         case AV_CODEC_ID_WMV3:
-            return PIX_FMT_VDPAU_WMV3;
+            return AV_PIX_FMT_VDPAU_WMV3;
         case AV_CODEC_ID_VC1:
-            return PIX_FMT_VDPAU_VC1;
+            return AV_PIX_FMT_VDPAU_VC1;
         default:
             return pFmt[0];
     }
@@ -174,8 +173,8 @@ vdpau_render_state* VDPAUDecoder::getFre
 int VDPAUDecoder::getBufferInternal(AVCodecContext* pContext, AVFrame* pFrame)
 {
     vdpau_render_state* pRenderState = getFreeRenderState();
-    pFrame->data[0] = (uint8_t*)pRenderState;
-    pFrame->type = FF_BUFFER_TYPE_USER;
+    pFrame->buf[0] = av_buffer_create((uint8_t*)pRenderState, 0, VDPAUDecoder::dummy_free_buffer, pFrame, 0);
+    pFrame->data[0] = pFrame->buf[0]->data;
 
     pRenderState->state |= FF_VDPAU_STATE_USED_FOR_REFERENCE;
     return 0;
@@ -202,19 +201,19 @@ void VDPAUDecoder::setupDecoder(AVCodecC
     // Create new decoder and mixer.
     VdpDecoderProfile profile = 0;
     switch (pContext->pix_fmt) {
-        case PIX_FMT_VDPAU_MPEG1:
+        case AV_PIX_FMT_VDPAU_MPEG1:
             profile = VDP_DECODER_PROFILE_MPEG1;
             break;
-        case PIX_FMT_VDPAU_MPEG2:
+        case AV_PIX_FMT_VDPAU_MPEG2:
             profile = VDP_DECODER_PROFILE_MPEG2_MAIN;
             break;
-        case PIX_FMT_VDPAU_H264:
+        case AV_PIX_FMT_VDPAU_H264:
             profile = VDP_DECODER_PROFILE_H264_HIGH;
             break;
-        case PIX_FMT_VDPAU_WMV3:
+        case AV_PIX_FMT_VDPAU_WMV3:
             profile = VDP_DECODER_PROFILE_VC1_SIMPLE;
             break;
-        case PIX_FMT_VDPAU_VC1:
+        case AV_PIX_FMT_VDPAU_VC1:
             profile = VDP_DECODER_PROFILE_VC1_SIMPLE;
             break;
         default:
--- a/src/video/VDPAUDecoder.h
+++ b/src/video/VDPAUDecoder.h
@@ -43,8 +43,8 @@ public:
 
 private:
     // Callbacks
-    static int getBuffer(AVCodecContext* pContext, AVFrame* pFrame);
-    static void releaseBuffer(struct AVCodecContext* pContext, AVFrame* pFrame);
+    static int getBuffer2(AVCodecContext* pContext, AVFrame* pFrame, int flags);
+    static void dummy_free_buffer(void *opaque, uint8_t *data);
     static void drawHorizBand(AVCodecContext* pContext, const AVFrame* pFrame, 
             int offset[4], int y, int type, int height);
     static AVPixelFormat getFormat(AVCodecContext* pContext, const AVPixelFormat* pFmt);
--- a/src/video/VideoDecoder.cpp
+++ b/src/video/VideoDecoder.cpp
@@ -439,25 +439,25 @@ PixelFormat VideoDecoder::calcPixelForma
     AVCodecContext const* pContext = getCodecContext();
     if (bUseYCbCr) {
         switch(pContext->pix_fmt) {
-            case PIX_FMT_YUV420P:
+            case AV_PIX_FMT_YUV420P:
 #ifdef AVG_ENABLE_VDPAU
-            case PIX_FMT_VDPAU_H264:
-            case PIX_FMT_VDPAU_MPEG1:
-            case PIX_FMT_VDPAU_MPEG2:
-            case PIX_FMT_VDPAU_WMV3:
-            case PIX_FMT_VDPAU_VC1:
+            case AV_PIX_FMT_VDPAU_H264:
+            case AV_PIX_FMT_VDPAU_MPEG1:
+            case AV_PIX_FMT_VDPAU_MPEG2:
+            case AV_PIX_FMT_VDPAU_WMV3:
+            case AV_PIX_FMT_VDPAU_VC1:
 #endif
                 return YCbCr420p;
-            case PIX_FMT_YUVJ420P:
+            case AV_PIX_FMT_YUVJ420P:
                 return YCbCrJ420p;
-            case PIX_FMT_YUVA420P:
+            case AV_PIX_FMT_YUVA420P:
                 return YCbCrA420p;
             default:
                 break;
         }
     }
-    bool bAlpha = (pContext->pix_fmt == PIX_FMT_BGRA ||
-            pContext->pix_fmt == PIX_FMT_YUVA420P);
+    bool bAlpha = (pContext->pix_fmt == AV_PIX_FMT_BGRA ||
+            pContext->pix_fmt == AV_PIX_FMT_YUVA420P);
     return BitmapLoader::get()->getDefaultPixelFormat(bAlpha);
 }
 
--- a/src/video/VideoDecoderThread.cpp
+++ b/src/video/VideoDecoderThread.cpp
@@ -59,7 +59,7 @@ VideoDecoderThread::~VideoDecoderThread(
 bool VideoDecoderThread::init()
 {
 #if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(54, 28, 0) 
-    m_pFrame = avcodec_alloc_frame();
+    m_pFrame = av_frame_alloc();
 #else
     m_pFrame = new AVFrame;
 #endif
@@ -69,7 +69,7 @@ bool VideoDecoderThread::init()
 void VideoDecoderThread::deinit()
 {
 #if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(54, 28, 0) 
-    avcodec_free_frame(&m_pFrame);
+    av_frame_free(&m_pFrame);
 #else
     delete m_pFrame;
 #endif
--- a/src/video/WrapFFMpeg.h
+++ b/src/video/WrapFFMpeg.h
@@ -86,8 +86,6 @@ extern "C" {
 
 #ifdef PixelFormat
 #undef PixelFormat
-#else
-#define AVPixelFormat ::PixelFormat
 #endif
 
 #endif