View | Details | Raw Unified | Return to bug 214196
Collapse All | Expand All

(-)files/patch-image.c (+68 lines)
Line 0 Link Here
1
For ffmpeg 3.x compatibility
2
3
https://github.com/nordlicht/nordlicht/commit/5505a1898ab997a23b75553794eff6609447c43b.patch
4
https://github.com/nordlicht/nordlicht/commit/6e534a0c273756b88eecea7f510b6aa8a62dd789.patch
5
and https://github.com/nordlicht/nordlicht/pull/63/commits/b8f439c2796d6b1de73511c0610aecb31c942790
6
7
--- image.c.orig	2016-01-24 19:35:50 UTC
8
+++ image.c
9
@@ -5,11 +5,36 @@
10
 #include <string.h>
11
 #include <libswscale/swscale.h>
12
 
13
+// Changes for ffmpeg 3.0
14
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57,24,0)
15
+#  include <libavutil/imgutils.h>
16
+#  define av_free_packet av_packet_unref
17
+#  define avpicture_get_size(fmt,w,h) av_image_get_buffer_size(fmt,w,h,1)
18
+#endif
19
+
20
+// PIX_FMT was renamed to AV_PIX_FMT on this version
21
+#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(51,74,100)
22
+#  define AVPixelFormat PixelFormat
23
+#  define AV_PIX_FMT_RGB24 PIX_FMT_RGB24
24
+#  define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P
25
+#  define AV_PIX_FMT_YUVJ422P PIX_FMT_YUVJ422P
26
+#  define AV_PIX_FMT_YUVJ440P PIX_FMT_YUVJ440P
27
+#  define AV_PIX_FMT_YUVJ444P PIX_FMT_YUVJ444P
28
+#  define AV_PIX_FMT_YUV420P  PIX_FMT_YUV420P
29
+#  define AV_PIX_FMT_YUV422P  PIX_FMT_YUV422P
30
+#  define AV_PIX_FMT_YUV440P  PIX_FMT_YUV440P
31
+#  define AV_PIX_FMT_YUV444P  PIX_FMT_YUV444P
32
+#endif
33
+
34
 #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(52, 8, 0)
35
-#define av_frame_alloc  avcodec_alloc_frame
36
-#define av_frame_free av_freep
37
+#  define av_frame_alloc  avcodec_alloc_frame
38
+#  if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54,59,100)
39
+#    define av_frame_free   av_freep
40
+#  else
41
+#    define av_frame_free   avcodec_free_frame
42
+#  endif
43
 void av_frame_get_buffer(AVFrame *frame, int magic) { avpicture_alloc((AVPicture *)frame, frame->format, frame->width, frame->height); }
44
-void av_frame_copy(AVFrame *dst, AVFrame *src) { memcpy(dst->data[0], src->data[0], sizeof(uint8_t)*avpicture_get_size(PIX_FMT_RGB24, dst->width, dst->height)); }
45
+void av_frame_copy(AVFrame *dst, AVFrame *src) { memcpy(dst->data[0], src->data[0], sizeof(uint8_t)*avpicture_get_size(AV_PIX_FMT_RGB24, dst->width, dst->height)); }
46
 #endif
47
 
48
 #define MAX_FILTER_SIZE 256
49
@@ -25,7 +50,7 @@ image *image_init(const int width, const
50
     i->frame = (AVFrame *) av_frame_alloc();
51
     i->frame->width = width;
52
     i->frame->height = height;
53
-    i->frame->format = PIX_FMT_RGB24; // best choice?
54
+    i->frame->format = AV_PIX_FMT_RGB24; // best choice?
55
     av_frame_get_buffer(i->frame, 16); // magic number?
56
     return i;
57
 }
58
@@ -240,7 +265,9 @@ int image_write_png(const image *i, cons
59
     encoder_context = avcodec_alloc_context3(encoder);
60
     encoder_context->width = i->frame->width;
61
     encoder_context->height = i->frame->height;
62
-    encoder_context->pix_fmt = PIX_FMT_RGB24;
63
+    encoder_context->pix_fmt = AV_PIX_FMT_RGB24;
64
+    encoder_context->time_base.num = 1;
65
+    encoder_context->time_base.den = 1;
66
     if (avcodec_open2(encoder_context, encoder, NULL) < 0) {
67
         error("Could not open output codec.");
68
         return -1;
(-)files/patch-source.c (+66 lines)
Line 0 Link Here
1
For ffmpeg 3.x compatibility
2
3
https://github.com/nordlicht/nordlicht/commit/5505a1898ab997a23b75553794eff6609447c43b.patch
4
https://github.com/nordlicht/nordlicht/commit/6e534a0c273756b88eecea7f510b6aa8a62dd789.patch
5
6
--- source.c.orig	2016-01-24 19:35:50 UTC
7
+++ source.c
8
@@ -6,9 +6,34 @@
9
 #include <libavutil/avutil.h>
10
 #include <libswscale/swscale.h>
11
 
12
+// Changes for ffmpeg 3.0
13
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57,24,0)
14
+#  include <libavutil/imgutils.h>
15
+#  define av_free_packet av_packet_unref
16
+#  define avpicture_get_size(fmt,w,h) av_image_get_buffer_size(fmt,w,h,1)
17
+#endif
18
+
19
+// PIX_FMT was renamed to AV_PIX_FMT on this version
20
+#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(51,74,100)
21
+#  define AVPixelFormat PixelFormat
22
+#  define AV_PIX_FMT_RGB24 PIX_FMT_RGB24
23
+#  define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P
24
+#  define AV_PIX_FMT_YUVJ422P PIX_FMT_YUVJ422P
25
+#  define AV_PIX_FMT_YUVJ440P PIX_FMT_YUVJ440P
26
+#  define AV_PIX_FMT_YUVJ444P PIX_FMT_YUVJ444P
27
+#  define AV_PIX_FMT_YUV420P  PIX_FMT_YUV420P
28
+#  define AV_PIX_FMT_YUV422P  PIX_FMT_YUV422P
29
+#  define AV_PIX_FMT_YUV440P  PIX_FMT_YUV440P
30
+#  define AV_PIX_FMT_YUV444P  PIX_FMT_YUV444P
31
+#endif
32
+
33
 #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(52, 8, 0)
34
-#define av_frame_alloc  avcodec_alloc_frame
35
-#define av_frame_free av_freep
36
+#  define av_frame_alloc  avcodec_alloc_frame
37
+#  if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54,59,100)
38
+#    define av_frame_free   av_freep
39
+#  else
40
+#    define av_frame_free   avcodec_free_frame
41
+#  endif
42
 #endif
43
 
44
 #define HEURISTIC_NUMBER_OF_FRAMES 1800 // how many frames will the heuristic look at?
45
@@ -244,13 +269,17 @@ source* source_init(const char *filename
46
         s->scaleframe = av_frame_alloc();
47
         s->scaleframe->width = s->video->frame->width;
48
         s->scaleframe->height = s->video->frame->height;
49
-        s->scaleframe->format = PIX_FMT_RGB24;
50
+        s->scaleframe->format = AV_PIX_FMT_RGB24;
51
 
52
-        s->buffer = (uint8_t *)av_malloc(sizeof(uint8_t)*avpicture_get_size(PIX_FMT_RGB24, s->scaleframe->width, s->scaleframe->height));
53
-        avpicture_fill((AVPicture *)s->scaleframe, s->buffer, PIX_FMT_RGB24, s->video->frame->width, s->video->frame->height);
54
+        s->buffer = (uint8_t *)av_malloc(sizeof(uint8_t)*avpicture_get_size(s->scaleframe->format, s->scaleframe->width, s->scaleframe->height));
55
+        #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57,24,0)
56
+            av_image_fill_arrays(s->scaleframe->data, s->scaleframe->linesize, s->buffer, s->scaleframe->format, s->video->frame->width, s->video->frame->height, 1);
57
+        #else
58
+            avpicture_fill((AVPicture *)s->scaleframe, s->buffer, s->scaleframe->format, s->video->frame->width, s->video->frame->height);
59
+        #endif
60
 
61
         s->sws_context = sws_getCachedContext(NULL, s->video->frame->width, s->video->frame->height, s->video->frame->format,
62
-                s->scaleframe->width, s->scaleframe->height, PIX_FMT_RGB24, SWS_AREA, NULL, NULL, NULL);
63
+                s->scaleframe->width, s->scaleframe->height, s->scaleframe->format, SWS_AREA, NULL, NULL, NULL);
64
     }
65
 
66
     s->keyframes = NULL;

Return to bug 214196