]>
Commit | Line | Data |
---|---|---|
109bca2e | 1 | --- ffmpeg-php-0.6.0/ffmpeg_movie.c.bak 2011-07-11 14:35:26.781123285 +0200 |
2 | +++ ffmpeg-php-0.6.0/ffmpeg_movie.c 2011-07-11 14:36:58.333123285 +0200 | |
3 | @@ -46,6 +46,10 @@ | |
4 | #include "ffmpeg_frame.h" | |
5 | #include "ffmpeg_movie.h" | |
6 | #include "ffmpeg_tools.h" | |
7 | + | |
8 | +#if LIBAVFORMAT_VERSION_MAJOR >= 53 | |
9 | +#define MAX_STREAMS 1024 /* arbitrary sanity check value */ | |
10 | +#endif | |
11 | ||
12 | #define GET_MOVIE_RESOURCE(ff_movie_ctx) {\ | |
13 | zval **_tmp_zval;\ | |
14 | @@ -152,7 +156,7 @@ | |
15 | */ | |
16 | static AVStream *_php_get_video_stream(AVFormatContext *fmt_ctx) | |
17 | { | |
18 | - int i = _php_get_stream_index(fmt_ctx, CODEC_TYPE_VIDEO); | |
19 | + int i = _php_get_stream_index(fmt_ctx, AVMEDIA_TYPE_VIDEO); | |
20 | ||
21 | return i < 0 ? NULL : fmt_ctx->streams[i]; | |
22 | } | |
23 | @@ -165,7 +169,7 @@ | |
24 | */ | |
25 | static AVStream *_php_get_audio_stream(AVFormatContext *fmt_ctx) | |
26 | { | |
27 | - int i = _php_get_stream_index(fmt_ctx, CODEC_TYPE_AUDIO); | |
28 | + int i = _php_get_stream_index(fmt_ctx, AVMEDIA_TYPE_AUDIO); | |
29 | ||
30 | return i < 0 ? NULL : fmt_ctx->streams[i]; | |
31 | } | |
32 | @@ -508,7 +512,7 @@ | |
33 | stream_index = _php_get_stream_index(ffmovie_ctx->fmt_ctx, stream_type); | |
34 | if (stream_index < 0) { | |
35 | // FIXME: factor out the conditional. | |
36 | - if (stream_type == CODEC_TYPE_VIDEO) { | |
37 | + if (stream_type == AVMEDIA_TYPE_VIDEO) { | |
38 | zend_error(E_WARNING, "Can't find video stream in %s", | |
39 | _php_get_filename(ffmovie_ctx)); | |
40 | return NULL; | |
41 | @@ -760,7 +764,7 @@ | |
42 | } | |
43 | ||
44 | #if LIBAVCODEC_BUILD > 4753 | |
45 | - if (GET_CODEC_FIELD(st->codec, codec_type) == CODEC_TYPE_VIDEO){ | |
46 | + if (GET_CODEC_FIELD(st->codec, codec_type) == AVMEDIA_TYPE_VIDEO){ | |
47 | if (st->r_frame_rate.den && st->r_frame_rate.num) { | |
48 | rate = av_q2d(st->r_frame_rate); | |
49 | } else { | |
50 | @@ -892,7 +896,7 @@ | |
51 | { | |
52 | AVCodecContext *decoder_ctx = NULL; | |
53 | ||
54 | - decoder_ctx = _php_get_decoder_context(ffmovie_ctx, CODEC_TYPE_VIDEO); | |
55 | + decoder_ctx = _php_get_decoder_context(ffmovie_ctx, AVMEDIA_TYPE_VIDEO); | |
56 | if (!decoder_ctx) { | |
57 | return 0; | |
58 | } | |
59 | @@ -932,7 +936,7 @@ | |
60 | { | |
61 | AVCodecContext *decoder_ctx; | |
62 | ||
63 | - decoder_ctx = _php_get_decoder_context(ffmovie_ctx, CODEC_TYPE_VIDEO); | |
64 | + decoder_ctx = _php_get_decoder_context(ffmovie_ctx, AVMEDIA_TYPE_VIDEO); | |
65 | ||
66 | return decoder_ctx ? decoder_ctx->pix_fmt : 0; | |
67 | } | |
68 | @@ -1045,7 +1049,7 @@ | |
69 | codec_name = decoder_ctx->codec_name; | |
70 | } else { | |
71 | /* output avi tags */ | |
72 | - if (decoder_ctx->codec_type == CODEC_TYPE_VIDEO) { | |
73 | + if (decoder_ctx->codec_type == AVMEDIA_TYPE_VIDEO) { | |
74 | snprintf(buf1, sizeof(buf1), "%c%c%c%c", | |
75 | decoder_ctx->codec_tag & 0xff, | |
76 | (decoder_ctx->codec_tag >> 8) & 0xff, | |
77 | @@ -1071,7 +1075,7 @@ | |
78 | ||
79 | GET_MOVIE_RESOURCE(ffmovie_ctx); | |
80 | ||
81 | - codec_name = (char*)_php_get_codec_name(ffmovie_ctx, CODEC_TYPE_VIDEO); | |
82 | + codec_name = (char*)_php_get_codec_name(ffmovie_ctx, AVMEDIA_TYPE_VIDEO); | |
83 | ||
84 | if (codec_name) { | |
85 | RETURN_STRINGL(codec_name, strlen(codec_name), 1); | |
86 | @@ -1091,7 +1095,7 @@ | |
87 | ||
88 | GET_MOVIE_RESOURCE(ffmovie_ctx); | |
89 | ||
90 | - codec_name = (char*)_php_get_codec_name(ffmovie_ctx, CODEC_TYPE_AUDIO); | |
91 | + codec_name = (char*)_php_get_codec_name(ffmovie_ctx, AVMEDIA_TYPE_AUDIO); | |
92 | ||
93 | if (codec_name) { | |
94 | RETURN_STRINGL(codec_name, strlen(codec_name), 1); | |
95 | @@ -1111,7 +1115,7 @@ | |
96 | ||
97 | GET_MOVIE_RESOURCE(ffmovie_ctx); | |
98 | ||
99 | - stream_id= _php_get_stream_index(ffmovie_ctx->fmt_ctx, CODEC_TYPE_VIDEO); | |
100 | + stream_id= _php_get_stream_index(ffmovie_ctx->fmt_ctx, AVMEDIA_TYPE_VIDEO); | |
101 | ||
102 | if( stream_id == -1 ) | |
103 | { | |
104 | @@ -1133,7 +1137,7 @@ | |
105 | ||
106 | GET_MOVIE_RESOURCE(ffmovie_ctx); | |
107 | ||
108 | - stream_id= _php_get_stream_index(ffmovie_ctx->fmt_ctx, CODEC_TYPE_AUDIO); | |
109 | + stream_id= _php_get_stream_index(ffmovie_ctx->fmt_ctx, AVMEDIA_TYPE_AUDIO); | |
110 | ||
111 | if( stream_id == -1 ) | |
112 | { | |
113 | @@ -1171,7 +1175,7 @@ | |
114 | ||
115 | GET_MOVIE_RESOURCE(ffmovie_ctx); | |
116 | ||
117 | - channels = _php_get_codec_channels(ffmovie_ctx, CODEC_TYPE_AUDIO); | |
118 | + channels = _php_get_codec_channels(ffmovie_ctx, AVMEDIA_TYPE_AUDIO); | |
119 | ||
120 | if (channels) { | |
121 | RETURN_LONG(channels); | |
122 | @@ -1207,7 +1211,7 @@ | |
123 | ||
124 | GET_MOVIE_RESOURCE(ffmovie_ctx); | |
125 | ||
126 | - sample_rate = _php_get_codec_sample_rate(ffmovie_ctx, CODEC_TYPE_AUDIO); | |
127 | + sample_rate = _php_get_codec_sample_rate(ffmovie_ctx, AVMEDIA_TYPE_AUDIO); | |
128 | ||
129 | if (sample_rate) { | |
130 | RETURN_LONG(sample_rate); | |
131 | @@ -1243,7 +1247,7 @@ | |
132 | ||
133 | GET_MOVIE_RESOURCE(ffmovie_ctx); | |
134 | ||
135 | - bit_rate = _php_get_codec_bit_rate(ffmovie_ctx, CODEC_TYPE_AUDIO); | |
136 | + bit_rate = _php_get_codec_bit_rate(ffmovie_ctx, AVMEDIA_TYPE_AUDIO); | |
137 | ||
138 | if (bit_rate) { | |
139 | RETURN_LONG(bit_rate); | |
140 | @@ -1263,7 +1267,7 @@ | |
141 | ||
142 | GET_MOVIE_RESOURCE(ffmovie_ctx); | |
143 | ||
144 | - bit_rate = _php_get_codec_bit_rate(ffmovie_ctx, CODEC_TYPE_VIDEO); | |
145 | + bit_rate = _php_get_codec_bit_rate(ffmovie_ctx, AVMEDIA_TYPE_VIDEO); | |
146 | ||
147 | if (bit_rate) { | |
148 | RETURN_LONG(bit_rate); | |
149 | @@ -1286,7 +1290,7 @@ | |
150 | int got_frame; | |
151 | ||
152 | video_stream = _php_get_stream_index(ffmovie_ctx->fmt_ctx, | |
153 | - CODEC_TYPE_VIDEO); | |
154 | + AVMEDIA_TYPE_VIDEO); | |
155 | if (video_stream < 0) { | |
156 | return NULL; | |
157 | } | |
158 | @@ -1300,7 +1304,7 @@ | |
159 | avcodec_decode_video2(decoder_ctx, frame, &got_frame, &packet); | |
160 | ||
161 | if (got_frame) { | |
162 | - *is_keyframe = (packet.flags & PKT_FLAG_KEY); | |
163 | + *is_keyframe = (packet.flags & AV_PKT_FLAG_KEY); | |
164 | *pts = packet.pts; | |
165 | av_free_packet(&packet); | |
166 | return frame; | |
167 | @@ -1327,7 +1331,7 @@ | |
168 | AVCodecContext *decoder_ctx = NULL; | |
169 | AVFrame *frame = NULL; | |
170 | ||
171 | - decoder_ctx = _php_get_decoder_context(ffmovie_ctx, CODEC_TYPE_VIDEO); | |
172 | + decoder_ctx = _php_get_decoder_context(ffmovie_ctx, AVMEDIA_TYPE_VIDEO); | |
173 | if (decoder_ctx == NULL) { | |
174 | return NULL; | |
175 | } | |
176 | @@ -1363,9 +1367,9 @@ | |
177 | wanted_frame != GETFRAME_NEXTFRAME && | |
178 | wanted_frame - ffmovie_ctx->frame_number > | |
179 | decoder_ctx->gop_size + 1) { | |
180 | - decoder_ctx->hurry_up = 1; | |
181 | + decoder_ctx->skip_frame = AVDISCARD_NONREF; | |
182 | } else { | |
183 | - decoder_ctx->hurry_up = 0; | |
184 | + decoder_ctx->skip_frame = AVDISCARD_DEFAULT; | |
185 | } | |
186 | ffmovie_ctx->frame_number++; | |
187 | ||
188 | @@ -1524,7 +1528,7 @@ | |
189 | AVCodecContext *decoder_ctx; | |
190 | ||
191 | ||
192 | - decoder_ctx = _php_get_decoder_context(ffmovie_ctx, CODEC_TYPE_VIDEO); | |
193 | + decoder_ctx = _php_get_decoder_context(ffmovie_ctx, AVMEDIA_TYPE_VIDEO); | |
194 | if (!decoder_ctx) { | |
195 | return -1; | |
196 | } |