Gentoo Archives: gentoo-commits

From: "Alexis Ballier (aballier)" <aballier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-php/ffmpeg-php/files: ffmpeg-php-0.6.0-ffmpeg.patch
Date: Mon, 09 Jan 2012 14:53:16
Message-Id: 20120109145306.9E9522004C@flycatcher.gentoo.org
1 aballier 12/01/09 14:53:06
2
3 Added: ffmpeg-php-0.6.0-ffmpeg.patch
4 Log:
5 attempt to fix build and compatibility with latest ffmpeg releases, bug #395563
6
7 (Portage version: 2.2.0_alpha84/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.1 dev-php/ffmpeg-php/files/ffmpeg-php-0.6.0-ffmpeg.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-php/ffmpeg-php/files/ffmpeg-php-0.6.0-ffmpeg.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-php/ffmpeg-php/files/ffmpeg-php-0.6.0-ffmpeg.patch?rev=1.1&content-type=text/plain
14
15 Index: ffmpeg-php-0.6.0-ffmpeg.patch
16 ===================================================================
17 Index: work/php5.3/ffmpeg_movie.c
18 ===================================================================
19 --- work.orig/php5.3/ffmpeg_movie.c
20 +++ work/php5.3/ffmpeg_movie.c
21 @@ -36,6 +36,7 @@
22
23 #include <avcodec.h>
24 #include <avformat.h>
25 +#include <pixdesc.h>
26
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 @@ -67,6 +68,9 @@
30 #define GET_CODEC_FIELD(codec, field) codec.field
31 #define GET_CODEC_PTR(codec) &codec
32 #endif
33 +#ifndef MAX_STREAMS
34 +#define MAX_STREAMS 20
35 +#endif
36
37 typedef struct {
38 AVFormatContext *fmt_ctx;
39 @@ -149,7 +153,7 @@ static int _php_get_stream_index(AVForma
40 */
41 static AVStream *_php_get_video_stream(AVFormatContext *fmt_ctx)
42 {
43 - int i = _php_get_stream_index(fmt_ctx, CODEC_TYPE_VIDEO);
44 + int i = _php_get_stream_index(fmt_ctx, AVMEDIA_TYPE_VIDEO);
45
46 return i < 0 ? NULL : fmt_ctx->streams[i];
47 }
48 @@ -162,7 +166,7 @@ static AVStream *_php_get_video_stream(A
49 */
50 static AVStream *_php_get_audio_stream(AVFormatContext *fmt_ctx)
51 {
52 - int i = _php_get_stream_index(fmt_ctx, CODEC_TYPE_AUDIO);
53 + int i = _php_get_stream_index(fmt_ctx, AVMEDIA_TYPE_AUDIO);
54
55 return i < 0 ? NULL : fmt_ctx->streams[i];
56 }
57 @@ -481,7 +485,7 @@ static AVCodecContext* _php_get_decoder_
58 stream_index = _php_get_stream_index(ffmovie_ctx->fmt_ctx, stream_type);
59 if (stream_index < 0) {
60 // FIXME: factor out the conditional.
61 - if (stream_type == CODEC_TYPE_VIDEO) {
62 + if (stream_type == AVMEDIA_TYPE_VIDEO) {
63 zend_error(E_WARNING, "Can't find video stream in %s",
64 _php_get_filename(ffmovie_ctx));
65 return NULL;
66 @@ -519,17 +523,26 @@ static AVCodecContext* _php_get_decoder_
67 }
68 /* }}} */
69
70 +static const char* get_metadata(AVDictionary *metadata, const char* val){
71 + AVDictionaryEntry *ade;
72 + ade = av_dict_get(metadata, val, NULL, 0 );
73 + if(ade == NULL) return "";
74 + return ade->value;
75 +}
76 +
77
78 /* {{{ proto string getComment()
79 */
80 FFMPEG_PHP_METHOD(ffmpeg_movie, getComment)
81 {
82 ff_movie_context *ffmovie_ctx;
83 + const char* val;
84
85 GET_MOVIE_RESOURCE(ffmovie_ctx);
86 +
87 + val = get_metadata(ffmovie_ctx->fmt_ctx->metadata, "COMMENT");
88
89 - RETURN_STRINGL(ffmovie_ctx->fmt_ctx->comment,
90 - strlen(ffmovie_ctx->fmt_ctx->comment), 1);
91 + RETURN_STRINGL(val, strlen(val), 1);
92 }
93 /* }}} */
94
95 @@ -540,11 +553,12 @@ FFMPEG_PHP_METHOD(ffmpeg_movie, getComme
96 FFMPEG_PHP_METHOD(ffmpeg_movie, getTitle)
97 {
98 ff_movie_context *ffmovie_ctx;
99 + const char* val;
100
101 GET_MOVIE_RESOURCE(ffmovie_ctx);
102
103 - RETURN_STRINGL(ffmovie_ctx->fmt_ctx->title,
104 - strlen(ffmovie_ctx->fmt_ctx->title), 1);
105 + val = get_metadata(ffmovie_ctx->fmt_ctx->metadata, "TITLE");
106 + RETURN_STRINGL(val, strlen(val), 1);
107 }
108 /* }}} */
109
110 @@ -555,11 +569,12 @@ FFMPEG_PHP_METHOD(ffmpeg_movie, getTitle
111 FFMPEG_PHP_METHOD(ffmpeg_movie, getAuthor)
112 {
113 ff_movie_context *ffmovie_ctx;
114 + const char* val;
115
116 GET_MOVIE_RESOURCE(ffmovie_ctx);
117
118 - RETURN_STRINGL(ffmovie_ctx->fmt_ctx->author,
119 - strlen(ffmovie_ctx->fmt_ctx->author), 1);
120 + val = get_metadata(ffmovie_ctx->fmt_ctx->metadata, "ARTIST");
121 + RETURN_STRINGL(val, strlen(val), 1);
122 }
123 /* }}} */
124
125 @@ -569,11 +584,12 @@ FFMPEG_PHP_METHOD(ffmpeg_movie, getAutho
126 FFMPEG_PHP_METHOD(ffmpeg_movie, getCopyright)
127 {
128 ff_movie_context *ffmovie_ctx;
129 + const char* val;
130
131 GET_MOVIE_RESOURCE(ffmovie_ctx);
132
133 - RETURN_STRINGL(ffmovie_ctx->fmt_ctx->copyright,
134 - strlen(ffmovie_ctx->fmt_ctx->copyright), 1);
135 + val = get_metadata(ffmovie_ctx->fmt_ctx->metadata, "COPYRIGHT");
136 + RETURN_STRINGL(val, strlen(val), 1);
137 }
138 /* }}} */
139
140 @@ -584,11 +600,12 @@ FFMPEG_PHP_METHOD(ffmpeg_movie, getCopyr
141 FFMPEG_PHP_METHOD(ffmpeg_movie, getAlbum)
142 {
143 ff_movie_context *ffmovie_ctx;
144 + const char* val;
145
146 GET_MOVIE_RESOURCE(ffmovie_ctx);
147
148 - RETURN_STRINGL(ffmovie_ctx->fmt_ctx->album,
149 - strlen(ffmovie_ctx->fmt_ctx->album), 1);
150 + val = get_metadata(ffmovie_ctx->fmt_ctx->metadata, "ALBUMTITLE");
151 + RETURN_STRINGL(val, strlen(val), 1);
152 }
153 /* }}} */
154
155 @@ -598,11 +615,12 @@ FFMPEG_PHP_METHOD(ffmpeg_movie, getAlbum
156 FFMPEG_PHP_METHOD(ffmpeg_movie, getGenre)
157 {
158 ff_movie_context *ffmovie_ctx;
159 + const char* val;
160
161 GET_MOVIE_RESOURCE(ffmovie_ctx);
162
163 - RETURN_STRINGL(ffmovie_ctx->fmt_ctx->genre,
164 - strlen(ffmovie_ctx->fmt_ctx->genre), 1);
165 + val = get_metadata(ffmovie_ctx->fmt_ctx->metadata, "GENRE");
166 + RETURN_STRINGL(val, strlen(val), 1);
167 }
168 /* }}} */
169
170 @@ -613,10 +631,12 @@ FFMPEG_PHP_METHOD(ffmpeg_movie, getGenre
171 FFMPEG_PHP_METHOD(ffmpeg_movie, getTrackNumber)
172 {
173 ff_movie_context *ffmovie_ctx;
174 + const char* val;
175
176 GET_MOVIE_RESOURCE(ffmovie_ctx);
177
178 - RETURN_LONG(ffmovie_ctx->fmt_ctx->track);
179 + val = get_metadata(ffmovie_ctx->fmt_ctx->metadata, "TRACK");
180 + RETURN_STRINGL(val, strlen(val), 1);
181 }
182 /* }}} */
183
184 @@ -626,10 +646,12 @@ FFMPEG_PHP_METHOD(ffmpeg_movie, getTrack
185 FFMPEG_PHP_METHOD(ffmpeg_movie, getYear)
186 {
187 ff_movie_context *ffmovie_ctx;
188 + const char* val;
189
190 GET_MOVIE_RESOURCE(ffmovie_ctx);
191
192 - RETURN_LONG(ffmovie_ctx->fmt_ctx->year);
193 + val = get_metadata(ffmovie_ctx->fmt_ctx->metadata, "YEAR");
194 + RETURN_STRINGL(val, strlen(val), 1);
195 }
196 /* }}} */
197
198 @@ -675,7 +697,7 @@ static float _php_get_framerate(ff_movie
199 }
200
201 #if LIBAVCODEC_BUILD > 4753
202 - if (GET_CODEC_FIELD(st->codec, codec_type) == CODEC_TYPE_VIDEO){
203 + if (GET_CODEC_FIELD(st->codec, codec_type) == AVMEDIA_TYPE_VIDEO){
204 if (st->r_frame_rate.den && st->r_frame_rate.num) {
205 rate = av_q2d(st->r_frame_rate);
206 } else {
207 @@ -807,7 +829,7 @@ static long _php_get_framenumber(ff_movi
208 {
209 AVCodecContext *decoder_ctx = NULL;
210
211 - decoder_ctx = _php_get_decoder_context(ffmovie_ctx, CODEC_TYPE_VIDEO);
212 + decoder_ctx = _php_get_decoder_context(ffmovie_ctx, AVMEDIA_TYPE_VIDEO);
213 if (!decoder_ctx) {
214 return 0;
215 }
216 @@ -847,7 +869,7 @@ static int _php_get_pixelformat(ff_movie
217 {
218 AVCodecContext *decoder_ctx;
219
220 - decoder_ctx = _php_get_decoder_context(ffmovie_ctx, CODEC_TYPE_VIDEO);
221 + decoder_ctx = _php_get_decoder_context(ffmovie_ctx, AVMEDIA_TYPE_VIDEO);
222
223 return decoder_ctx ? decoder_ctx->pix_fmt : 0;
224 }
225 @@ -865,7 +887,7 @@ FFMPEG_PHP_METHOD(ffmpeg_movie, getPixel
226 GET_MOVIE_RESOURCE(ffmovie_ctx);
227
228 pix_fmt = _php_get_pixelformat(ffmovie_ctx);
229 - fmt = avcodec_get_pix_fmt_name(pix_fmt);
230 + fmt = av_get_pix_fmt_name(pix_fmt);
231
232 if (fmt) {
233 /* cast const to non-const to keep compiler from complaining,
234 @@ -960,7 +982,7 @@ static const char* _php_get_codec_name(f
235 codec_name = decoder_ctx->codec_name;
236 } else {
237 /* output avi tags */
238 - if (decoder_ctx->codec_type == CODEC_TYPE_VIDEO) {
239 + if (decoder_ctx->codec_type == AVMEDIA_TYPE_VIDEO) {
240 snprintf(buf1, sizeof(buf1), "%c%c%c%c",
241 decoder_ctx->codec_tag & 0xff,
242 (decoder_ctx->codec_tag >> 8) & 0xff,
243 @@ -986,7 +1008,7 @@ FFMPEG_PHP_METHOD(ffmpeg_movie, getVideo
244
245 GET_MOVIE_RESOURCE(ffmovie_ctx);
246
247 - codec_name = (char*)_php_get_codec_name(ffmovie_ctx, CODEC_TYPE_VIDEO);
248 + codec_name = (char*)_php_get_codec_name(ffmovie_ctx, AVMEDIA_TYPE_VIDEO);
249
250 if (codec_name) {
251 RETURN_STRINGL(codec_name, strlen(codec_name), 1);
252 @@ -1006,7 +1028,7 @@ FFMPEG_PHP_METHOD(ffmpeg_movie, getAudio
253
254 GET_MOVIE_RESOURCE(ffmovie_ctx);
255
256 - codec_name = (char*)_php_get_codec_name(ffmovie_ctx, CODEC_TYPE_AUDIO);
257 + codec_name = (char*)_php_get_codec_name(ffmovie_ctx, AVMEDIA_TYPE_AUDIO);
258
259 if (codec_name) {
260 RETURN_STRINGL(codec_name, strlen(codec_name), 1);
261 @@ -1026,7 +1048,7 @@ FFMPEG_PHP_METHOD(ffmpeg_movie, getVideo
262
263 GET_MOVIE_RESOURCE(ffmovie_ctx);
264
265 - stream_id= _php_get_stream_index(ffmovie_ctx->fmt_ctx, CODEC_TYPE_VIDEO);
266 + stream_id= _php_get_stream_index(ffmovie_ctx->fmt_ctx, AVMEDIA_TYPE_VIDEO);
267
268 if( stream_id == -1 )
269 {
270 @@ -1048,7 +1070,7 @@ FFMPEG_PHP_METHOD(ffmpeg_movie, getAudio
271
272 GET_MOVIE_RESOURCE(ffmovie_ctx);
273
274 - stream_id= _php_get_stream_index(ffmovie_ctx->fmt_ctx, CODEC_TYPE_AUDIO);
275 + stream_id= _php_get_stream_index(ffmovie_ctx->fmt_ctx, AVMEDIA_TYPE_AUDIO);
276
277 if( stream_id == -1 )
278 {
279 @@ -1086,7 +1108,7 @@ FFMPEG_PHP_METHOD(ffmpeg_movie, getAudio
280
281 GET_MOVIE_RESOURCE(ffmovie_ctx);
282
283 - channels = _php_get_codec_channels(ffmovie_ctx, CODEC_TYPE_AUDIO);
284 + channels = _php_get_codec_channels(ffmovie_ctx, AVMEDIA_TYPE_AUDIO);
285
286 if (channels) {
287 RETURN_LONG(channels);
288 @@ -1122,7 +1144,7 @@ FFMPEG_PHP_METHOD(ffmpeg_movie, getAudio
289
290 GET_MOVIE_RESOURCE(ffmovie_ctx);
291
292 - sample_rate = _php_get_codec_sample_rate(ffmovie_ctx, CODEC_TYPE_AUDIO);
293 + sample_rate = _php_get_codec_sample_rate(ffmovie_ctx, AVMEDIA_TYPE_AUDIO);
294
295 if (sample_rate) {
296 RETURN_LONG(sample_rate);
297 @@ -1158,7 +1180,7 @@ FFMPEG_PHP_METHOD(ffmpeg_movie, getAudio
298
299 GET_MOVIE_RESOURCE(ffmovie_ctx);
300
301 - bit_rate = _php_get_codec_bit_rate(ffmovie_ctx, CODEC_TYPE_AUDIO);
302 + bit_rate = _php_get_codec_bit_rate(ffmovie_ctx, AVMEDIA_TYPE_AUDIO);
303
304 if (bit_rate) {
305 RETURN_LONG(bit_rate);
306 @@ -1178,7 +1200,7 @@ FFMPEG_PHP_METHOD(ffmpeg_movie, getVideo
307
308 GET_MOVIE_RESOURCE(ffmovie_ctx);
309
310 - bit_rate = _php_get_codec_bit_rate(ffmovie_ctx, CODEC_TYPE_VIDEO);
311 + bit_rate = _php_get_codec_bit_rate(ffmovie_ctx, AVMEDIA_TYPE_VIDEO);
312
313 if (bit_rate) {
314 RETURN_LONG(bit_rate);
315 @@ -1201,7 +1223,7 @@ static AVFrame* _php_read_av_frame(ff_mo
316 int got_frame;
317
318 video_stream = _php_get_stream_index(ffmovie_ctx->fmt_ctx,
319 - CODEC_TYPE_VIDEO);
320 + AVMEDIA_TYPE_VIDEO);
321 if (video_stream < 0) {
322 return NULL;
323 }
324 @@ -1212,11 +1234,10 @@ static AVFrame* _php_read_av_frame(ff_mo
325 while (av_read_frame(ffmovie_ctx->fmt_ctx, &packet) >= 0) {
326 if (packet.stream_index == video_stream) {
327
328 - avcodec_decode_video(decoder_ctx, frame, &got_frame,
329 - packet.data, packet.size);
330 + avcodec_decode_video2(decoder_ctx, frame, &got_frame, &packet);
331
332 if (got_frame) {
333 - *is_keyframe = (packet.flags & PKT_FLAG_KEY);
334 + *is_keyframe = (packet.flags & AV_PKT_FLAG_KEY);
335 *pts = packet.pts;
336 av_free_packet(&packet);
337 return frame;
338 @@ -1243,7 +1264,7 @@ static AVFrame* _php_get_av_frame(ff_mov
339 AVCodecContext *decoder_ctx = NULL;
340 AVFrame *frame = NULL;
341
342 - decoder_ctx = _php_get_decoder_context(ffmovie_ctx, CODEC_TYPE_VIDEO);
343 + decoder_ctx = _php_get_decoder_context(ffmovie_ctx, AVMEDIA_TYPE_VIDEO);
344 if (decoder_ctx == NULL) {
345 return NULL;
346 }
347 @@ -1279,9 +1300,7 @@ static AVFrame* _php_get_av_frame(ff_mov
348 wanted_frame != GETFRAME_NEXTFRAME &&
349 wanted_frame - ffmovie_ctx->frame_number >
350 decoder_ctx->gop_size + 1) {
351 - decoder_ctx->hurry_up = 1;
352 - } else {
353 - decoder_ctx->hurry_up = 0;
354 + decoder_ctx->skip_frame = AVDISCARD_BIDIR;
355 }
356 ffmovie_ctx->frame_number++;
357
358 @@ -1440,7 +1459,7 @@ static double _php_get_sample_aspect_rat
359 AVCodecContext *decoder_ctx;
360
361
362 - decoder_ctx = _php_get_decoder_context(ffmovie_ctx, CODEC_TYPE_VIDEO);
363 + decoder_ctx = _php_get_decoder_context(ffmovie_ctx, AVMEDIA_TYPE_VIDEO);
364 if (!decoder_ctx) {
365 return -1;
366 }