summaryrefslogtreecommitdiff
path: root/testing/mediastreamer/mediastreamer-ffmpeg.patch
blob: 944d4b833eacedf2df5e858acc66046fce011a2f (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
197
198
199
200
201
202
203
204
205
diff --git a/include/mediastreamer2/msvideo.h b/include/mediastreamer2/msvideo.h
index 5ae8a63..86edf86 100644
--- mediastreamer2/include/mediastreamer2/msvideo.h
+++ mediastreamer2/include/mediastreamer2/msvideo.h
@@ -21,6 +21,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #define msvideo_h
 
 #include <mediastreamer2/msfilter.h>
+#ifndef INT64_C
+#define INT64_C(c) (c ## LL)
+#define UINT64_C(c) (c ## ULL)
+#endif
+#include <libavutil/avutil.h>
+#include <libavcodec/version.h>
 
 /* some global constants for video MSFilter(s) */
 #define MS_VIDEO_SIZE_SQCIF_W 128
@@ -206,7 +212,9 @@ extern "C"{
 MS2_PUBLIC int ms_pix_fmt_to_ffmpeg(MSPixFmt fmt);
 MS2_PUBLIC MSPixFmt ffmpeg_pix_fmt_to_ms(int fmt);
 MS2_PUBLIC MSPixFmt ms_fourcc_to_pix_fmt(uint32_t fourcc);
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 0, 100)
 MS2_PUBLIC void ms_ffmpeg_check_init(void);
+#endif
 MS2_PUBLIC int ms_yuv_buf_init_from_mblk(MSPicture *buf, mblk_t *m);
 MS2_PUBLIC int ms_yuv_buf_init_from_mblk_with_size(MSPicture *buf, mblk_t *m, int w, int h);
 MS2_PUBLIC int ms_picture_init_from_mblk_with_size(MSPicture *buf, mblk_t *m, MSPixFmt fmt, int w, int h);
diff --git a/src/h264dec.c b/src/h264dec.c
index 223de3d..8c40a7c 100644
--- mediastreamer2/src/h264dec.c
+++ mediastreamer2/src/h264dec.c
@@ -44,7 +44,9 @@ typedef struct _DecData{
 static void ffmpeg_init(){
 	static bool_t done=FALSE;
 	if (!done){
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 0, 100)
 		avcodec_init();
+#endif
 		avcodec_register_all();
 		done=TRUE;
 	}
diff --git a/src/mscommon.c b/src/mscommon.c
index 2cab005..bebb946 100644
--- mediastreamer2/src/mscommon.c
+++ mediastreamer2/src/mscommon.c
@@ -33,9 +33,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "mediastreamer2/mscodecutils.h"
 #include "mediastreamer2/msfilter.h"
 #include <ortp/ortp_srtp.h>
+#ifndef INT64_C
+#define INT64_C(c) (c ## LL)
+#define UINT64_C(c) (c ## ULL)
+#endif
+#include <libavutil/avutil.h>
+#include <libavcodec/version.h>
 
 extern void __register_ffmpeg_encoders_if_possible(void);
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 0, 100)
 extern void ms_ffmpeg_check_init();
+#endif
 extern bool_t libmsandroiddisplay_init(void);
 extern void libmsandroiddisplaybad_init(void);
 extern void libmsandroidopengldisplay_init(void);
@@ -645,7 +653,9 @@ void ms_init(){
 		}
 	}
 #if !defined(NO_FFMPEG)
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 0, 100)
 	ms_ffmpeg_check_init();
+#endif
 	__register_ffmpeg_encoders_if_possible();
 #endif
 #endif
diff --git a/src/videodec.c b/src/videodec.c
index c04e1e9..a455075 100644
--- mediastreamer2/src/videodec.c
+++ mediastreamer2/src/videodec.c
@@ -27,9 +27,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "mediastreamer2/msvideo.h"
 #include "mediastreamer2/msticker.h"
 #include "rfc2429.h"
+#ifndef INT64_C
+#define INT64_C(c) (c ## LL)
+#define UINT64_C(c) (c ## ULL)
+#endif
+#include <libavutil/avutil.h>
+#include <libavcodec/version.h>
 
-
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 0, 100)
 extern void ms_ffmpeg_check_init();
+#endif
 
 
 typedef struct DecState{
@@ -50,7 +57,9 @@ typedef struct DecState{
 
 static void dec_init(MSFilter *f, enum CodecID cid){
 	DecState *s=(DecState *)ms_new0(DecState,1);
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 0, 100)
 	ms_ffmpeg_check_init();
+#endif
 	
 	avcodec_get_context_defaults(&s->av_context);
 	s->av_codec=NULL;
diff --git a/src/videoenc.c b/src/videoenc.c
index 21d016f..520f06a 100644
--- mediastreamer2/src/videoenc.c
+++ mediastreamer2/src/videoenc.c
@@ -37,7 +37,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #define RATE_CONTROL_MARGIN 15000 /*bits/second*/
 
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 0, 100)
 static bool_t avcodec_initialized=FALSE;
+#endif
 
 #ifdef ENABLE_LOG_FFMPEG
 
@@ -51,6 +53,7 @@ void ms_ffmpeg_log_callback(void* ptr, int level, const char* fmt, va_list vl)
 
 #endif
 
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 0, 100)
 void ms_ffmpeg_check_init(){
 	if(!avcodec_initialized){
 		avcodec_init();
@@ -62,6 +65,7 @@ void ms_ffmpeg_check_init(){
 #endif
 	}
 }
+#endif
 
 /* the goal of this small object is to tell when to send I frames at startup:
 at 2 and 4 seconds*/
@@ -201,7 +205,9 @@ static void enc_init(MSFilter *f, enum CodecID codec)
 {
 	EncState *s=(EncState *)ms_new(EncState,1);
 	f->data=s;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 0, 100)
 	ms_ffmpeg_check_init();
+#endif
 	s->profile=0;/*always default to profile 0*/
 	s->comp_buf=NULL;
 	s->fps=15;
@@ -300,9 +306,13 @@ static void prepare_h263(EncState *s){
 	if (s->profile==0){
 		s->codec=CODEC_ID_H263;
 	}else{
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 0, 100)
 		c->flags|=CODEC_FLAG_H263P_UMV;
+#endif
 		c->flags|=CODEC_FLAG_AC_PRED;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 0, 100)
 		c->flags|=CODEC_FLAG_H263P_SLICE_STRUCT;
+#endif
 		/*
 		c->flags|=CODEC_FLAG_OBMC;
 		c->flags|=CODEC_FLAG_AC_PRED;
@@ -372,7 +382,11 @@ static void add_rfc2190_header(mblk_t **packet, AVCodecContext *context){
 	// assume video size is CIF or QCIF
 	if (context->width == 352 && context->height == 288) header->b_wptr[1] = 0x60;
 	else header->b_wptr[1] = 0x40;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 0, 100)
 	if (context->coded_frame->pict_type != FF_I_TYPE) header->b_wptr[1] |= 0x10;
+#else
+	if (context->coded_frame->pict_type != AV_PICTURE_TYPE_I) header->b_wptr[1] |= 0x10;
+#endif
 	header->b_wptr += 4;
 	header->b_cont = *packet;
 	*packet = header;
@@ -779,7 +793,11 @@ static void process_frame(MSFilter *f, mblk_t *inm){
 		s->req_vfu=TRUE;
 	}
 	if (s->req_vfu){
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 0, 100)
 		pict.pict_type=FF_I_TYPE;
+#else
+		pict.pict_type=AV_PICTURE_TYPE_I;
+#endif
 		s->req_vfu=FALSE;
 	}
 	comp_buf->b_rptr=comp_buf->b_wptr=comp_buf->b_datap->db_base;
@@ -799,7 +817,11 @@ static void process_frame(MSFilter *f, mblk_t *inm){
 		if (s->framenum==1){
 			video_starter_first_frame (&s->starter,f->ticker->time);
 		}
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 0, 100)
 		if (c->coded_frame->pict_type==FF_I_TYPE){
+#else
+		if (c->coded_frame->pict_type==AV_PICTURE_TYPE_I){
+#endif
 			ms_message("Emitting I-frame");
 		}
 		comp_buf->b_wptr+=error;
@@ -1067,7 +1089,9 @@ MSFilterDesc ms_mjpeg_enc_desc={
 #endif
 
 void __register_ffmpeg_encoders_if_possible(void){
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 0, 100)
 	ms_ffmpeg_check_init();
+#endif
 	if (avcodec_find_encoder(CODEC_ID_MPEG4))
 		ms_filter_register(&ms_mpeg4_enc_desc);
 	if (avcodec_find_encoder(CODEC_ID_H263)){