summaryrefslogtreecommitdiff
blob: 4eb8c97042354182337254e07b98628cdd67d745 (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
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
--- src/ffDiaporama/engine/cBaseMediaFile.cpp	2014-02-09 10:48:04.000000000 +0100
+++ src/ffDiaporama/engine/cBaseMediaFile.cpp	2016-02-21 19:00:43.129114600 +0100
@@ -113,10 +113,23 @@
 #define VC_USERDATA     0x00000008
 #define VC_FLUSHED      0x00000010
 
-#define PIXFMT          PIX_FMT_RGB24
+#if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=300))
+  #define PIXELFORMAT AVPixelFormat
+  #define PIXFMT AV_PIX_FMT_RGB24
+#else
+  #define PIXELFORMAT PixelFormat
+  #define PIXFMT PIX_FMT_RGB24
+#endif
 #define QTPIXFMT        QImage::Format_RGB888
 
-AVFrame *ALLOCFRAME()           { return avcodec_alloc_frame(); }
+AVFrame *ALLOCFRAME()           { return 
+  #if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=300))
+    av_frame_alloc();
+  #else
+    avcodec_alloc_frame();
+  #endif
+}
+
 void    FREEFRAME(AVFrame **Buf){ avcodec_free_frame(Buf); *Buf=NULL; }
 
 //****************************************************************************************************************************************************************
@@ -2402,7 +2415,7 @@
                             AVFrame *FrameRGB=ALLOCFRAME();
                             if ((FrameRGB)&&(!Thumbnail.isNull())) {
                                 avpicture_fill((AVPicture *)FrameRGB,Thumbnail.bits(),PIXFMT,RealW,RealH);
-                                struct SwsContext *img_convert_ctx=sws_getContext(FrameYUV->width,FrameYUV->height,(PixelFormat)FrameYUV->format,RealW,RealH,PIXFMT,SWS_FAST_BILINEAR,NULL,NULL,NULL);
+                                struct SwsContext *img_convert_ctx=sws_getContext(FrameYUV->width,FrameYUV->height,(PIXELFORMAT)FrameYUV->format,RealW,RealH,PIXFMT,SWS_FAST_BILINEAR,NULL,NULL,NULL);
                                 if (img_convert_ctx!=NULL) {
                                     int ret = sws_scale(img_convert_ctx,FrameYUV->data,FrameYUV->linesize,0,FrameYUV->height,FrameRGB->data,FrameRGB->linesize);
                                     if (ret>0) {
@@ -3482,7 +3495,7 @@
         struct SwsContext *img_convert_ctx=sws_getContext(
             Frame->width,                                                     // Src width
             Frame->height,                                                    // Src height
-            (PixelFormat)Frame->format,                                       // Src Format
+            (PIXELFORMAT)Frame->format,                                       // Src Format
             W,                                                                // Destination width
             H,                                                                // Destination height
             PIXFMT,                                                           // Destination Format
--- src/ffDiaporama/engine/cDeviceModelDef.h	2016-02-21 19:53:00.487286000 +0100
+++ src/ffDiaporama/engine/cDeviceModelDef.h	2016-02-21 19:52:47.623287800 +0100
@@ -53,7 +53,9 @@
 
 #include <libavutil/mathematics.h>
 #include <libavutil/pixdesc.h>
-#include <libavutil/audioconvert.h>
+#if (LIBAVUTIL_VERSION_INT<AV_VERSION_INT(54,31,100))
+    #include <libavutil/audioconvert.h>
+#endif
 
 #include <libavcodec/avcodec.h>
 
@@ -90,10 +92,10 @@
       #define RESAMPLE_MAX_CHANNELS 32
     #endif
     
-    #include "libavfilter/avcodec.h"
-    #include "libavfilter/buffersink.h"
-    #include "libavfilter/buffersrc.h"
-    #if     ((LIBAVUTIL_VERSION_INT>=AV_VERSION_INT(52,48,100))&&(LIBAVCODEC_VERSION_INT>=AV_VERSION_INT(55,39,100))&&(LIBAVFORMAT_VERSION_INT>=AV_VERSION_INT(55,19,104))&&(LIBAVDEVICE_VERSION_INT>=AV_VERSION_INT(55,5,100))&&(LIBAVFILTER_VERSION_INT>=AV_VERSION_INT(3,90,100))&&(LIBSWSCALE_VERSION_INT>=AV_VERSION_INT(2,5,101))&&(LIBSWRESAMPLE_VERSION_INT>=AV_VERSION_INT(0,17,104)))
+    #if     ((LIBAVUTIL_VERSION_INT>=AV_VERSION_INT(55,17,103))&&(LIBAVCODEC_VERSION_INT>=AV_VERSION_INT(57,24,102))&&(LIBAVFORMAT_VERSION_INT>=AV_VERSION_INT(57,25,100))&&(LIBAVDEVICE_VERSION_INT>=AV_VERSION_INT(57,0,101))&&(LIBAVFILTER_VERSION_INT>=AV_VERSION_INT(6,31,100))&&(LIBSWSCALE_VERSION_INT>=AV_VERSION_INT(4,0,100))&&(LIBSWRESAMPLE_VERSION_INT>=AV_VERSION_INT(2,0,101)))
+        #define FFMPEGVERSIONINT    300
+        #define FFMPEGVERSION       "FFmpeg 3.0 or higher"
+    #elif     ((LIBAVUTIL_VERSION_INT>=AV_VERSION_INT(52,48,100))&&(LIBAVCODEC_VERSION_INT>=AV_VERSION_INT(55,39,100))&&(LIBAVFORMAT_VERSION_INT>=AV_VERSION_INT(55,19,104))&&(LIBAVDEVICE_VERSION_INT>=AV_VERSION_INT(55,5,100))&&(LIBAVFILTER_VERSION_INT>=AV_VERSION_INT(3,90,100))&&(LIBSWSCALE_VERSION_INT>=AV_VERSION_INT(2,5,101))&&(LIBSWRESAMPLE_VERSION_INT>=AV_VERSION_INT(0,17,104)))
         #define FFMPEGVERSIONINT    210
         #define FFMPEGVERSION       "FFmpeg 2.1 or higher"
     #elif   ((LIBAVUTIL_VERSION_INT>=AV_VERSION_INT(52,38,100))&&(LIBAVCODEC_VERSION_INT>=AV_VERSION_INT(55,18,102))&&(LIBAVFORMAT_VERSION_INT>=AV_VERSION_INT(55,12,100))&&(LIBAVDEVICE_VERSION_INT>=AV_VERSION_INT(55,3,100))&&(LIBAVFILTER_VERSION_INT>=AV_VERSION_INT(3,79,101))&&(LIBSWSCALE_VERSION_INT>=AV_VERSION_INT(2,3,100))&&(LIBSWRESAMPLE_VERSION_INT>=AV_VERSION_INT(0,17,102)))
@@ -108,6 +110,13 @@
     #else
         // unsupported version
     #endif
+    #if (FFMPEGVERSIONINT<300)
+      #include "libavfilter/avcodec.h"
+    #else
+      #include "libavcodec/avcodec.h"
+    #endif
+    #include "libavfilter/buffersink.h"
+    #include "libavfilter/buffersrc.h"
 #endif
 }
 
--- src/ffDiaporama/engine/_EncodeVideo.cpp	2016-02-22 08:19:13.935794200 +0100
+++ src/ffDiaporama/engine/_EncodeVideo.cpp	2016-02-22 08:33:52.928215900 +0100
@@ -20,7 +20,11 @@
 
 #include "_EncodeVideo.h"
 
-#define PIXFMT      PIX_FMT_RGB24
+#if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=300))
+  #define PIXFMT AV_PIX_FMT_RGB24
+#else
+  #define PIXFMT PIX_FMT_RGB24
+#endif
 #define QTPIXFMT    QImage::Format_RGB888
 
 //*************************************************************************************************************************************************
@@ -410,8 +414,13 @@
     // Setup codec parameters
     VideoStream->codec->width               =ImageWidth;
     VideoStream->codec->height              =ImageHeight;
+    #if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=300))
+    VideoStream->codec->pix_fmt             =AV_PIX_FMT_YUV420P;
+    #else
     VideoStream->codec->pix_fmt             =PIX_FMT_YUV420P;
+    #endif
     VideoStream->codec->time_base           =VideoFrameRate;
+    VideoStream->time_base                  =VideoFrameRate;
     VideoStream->codec->sample_aspect_ratio =PixelAspectRatio;
     VideoStream->sample_aspect_ratio        =PixelAspectRatio;
     if ((codec->id!=AV_CODEC_ID_H264)||(!VBR)) {
@@ -434,7 +443,11 @@
 
     } else if (codec->id==AV_CODEC_ID_MJPEG) {
         //-qscale 2 -qmin 2 -qmax 2
+        #if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=300))
+        VideoStream->codec->pix_fmt             =AV_PIX_FMT_YUVJ420P;
+        #else
         VideoStream->codec->pix_fmt             =PIX_FMT_YUVJ420P;
+        #endif
         VideoStream->codec->qmin                =2;
         VideoStream->codec->qmax                =2;
         VideoStream->codec->bit_rate_tolerance  =(ImageWidth*ImageHeight*2*VideoFrameRate.den/VideoFrameRate.num)*2;
@@ -564,7 +577,11 @@
     #endif
 
     // Create and prepare VideoFrame and VideoFrameBuf
-    VideoFrame=avcodec_alloc_frame();  // Allocate structure for RGB image
+    #if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=300))
+    VideoFrame=av_frame_alloc();
+    #else
+    VideoFrame=avcodec_alloc_frame();
+    #endif
     if (!VideoFrame) {
         ToLog(LOGMSG_CRITICAL,"EncodeVideo-OpenVideoStream: avcodec_alloc_frame() failed");
         return false;
@@ -654,7 +671,11 @@
         return false;
     }
 
+    #if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=300))
+    AudioFrame=av_frame_alloc();
+    #else
     AudioFrame=avcodec_alloc_frame();
+    #endif
     if (AudioFrame==NULL) {
         ToLog(LOGMSG_CRITICAL,QString("EncodeVideo-OpenAudioStream:: avcodec_alloc_frame failed"));
         return false;
@@ -1095,7 +1116,11 @@
             if (Continue) {
                 // Init AudioFrame
                 AVRational AVR;
+                #if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=300))
+                av_frame_unref(AudioFrame);
+                #else
                 avcodec_get_frame_defaults(AudioFrame);
+                #endif
                 AVR.num                     =1;
                 AVR.den                     =AudioStream->codec->sample_rate;
                 AudioFrame->nb_samples      =DestPacketSize/DestSampleSize;
@@ -1180,7 +1205,11 @@
     int     errcode;
 
     if (Image) {
-        avcodec_get_frame_defaults(VideoFrame);
+        #if (defined(FFMPEG)&&(FFMPEGVERSIONINT>=300))
+        av_frame_unref(AudioFrame);
+        #else
+        avcodec_get_frame_defaults(AudioFrame);
+        #endif
         if (avpicture_fill(
             (AVPicture *)VideoFrame,            // Frame to prepare
             VideoFrameBuf,                      // Buffer which will contain the image data
@@ -1225,9 +1254,14 @@
         }
     }
 
-    if ((VideoFrameNbr%VideoStream->codec->gop_size)==0) VideoFrame->pict_type=AV_PICTURE_TYPE_I;
-        else VideoFrame->pict_type=(AVPictureType)0;
+    if ((VideoFrameNbr%VideoStream->codec->gop_size)==0)
+        VideoFrame->pict_type=AV_PICTURE_TYPE_I;
+    else
+        VideoFrame->pict_type=(AVPictureType)0;
     VideoFrame->pts=VideoFrameNbr;
+    VideoFrame->format=VideoStream->codec->pix_fmt;
+    VideoFrame->width=VideoStream->codec->width;
+    VideoFrame->height=VideoStream->codec->height;
 
     if ((Continue)&&(!StopProcessWanted)) {