]>
Commit | Line | Data |
---|---|---|
6d110796 JB |
1 | --- avifile-0.7-0.7.45/lib/aviread/FFReadHandler.cpp.orig 2013-07-16 16:48:12.312338353 +0200 |
2 | +++ avifile-0.7-0.7.45/lib/aviread/FFReadHandler.cpp 2013-07-19 17:06:37.738081034 +0200 | |
3 | @@ -46,14 +46,12 @@ | |
4 | ||
5 | int FFReadHandler::Init(const char* url) | |
6 | { | |
7 | - AVFormatParameters avfp; | |
8 | AVInputFormat* fmt = 0; | |
9 | // av_find_input_format(url); | |
10 | // printf("find input format %p %s\n", fmt, url); | |
11 | - memset(&avfp, 0, sizeof(avfp)); | |
12 | //if (!fmt) return -1; | |
13 | - int r = av_open_input_file(&m_pContext, url, | |
14 | - fmt, 64000, &avfp); | |
15 | + int r = avformat_open_input(&m_pContext, url, | |
16 | + fmt, NULL); | |
17 | if (r < 0) | |
18 | { | |
19 | AVM_WRITE("FF reader", "OPEN INPUT failed\n"); | |
20 | @@ -100,8 +98,8 @@ | |
21 | uint_t j = 0; | |
22 | switch (type) | |
23 | { | |
24 | - case IStream::Audio: t = CODEC_TYPE_AUDIO; break; | |
25 | - case IStream::Video: t = CODEC_TYPE_VIDEO; break; | |
26 | + case IStream::Audio: t = AVMEDIA_TYPE_AUDIO; break; | |
27 | + case IStream::Video: t = AVMEDIA_TYPE_VIDEO; break; | |
28 | default: return 0; | |
29 | } | |
30 | ||
31 | @@ -125,8 +123,8 @@ | |
32 | ||
33 | switch (type) | |
34 | { | |
35 | - case IStream::Audio: t = CODEC_TYPE_AUDIO; break; | |
36 | - case IStream::Video: t = CODEC_TYPE_VIDEO; break; | |
37 | + case IStream::Audio: t = AVMEDIA_TYPE_AUDIO; break; | |
38 | + case IStream::Video: t = AVMEDIA_TYPE_VIDEO; break; | |
39 | default: return 0; | |
40 | } | |
41 | ||
42 | @@ -152,7 +150,7 @@ | |
43 | int FFReadHandler::seek(framepos_t pos) | |
44 | { | |
45 | Locker locker(m_Mutex); | |
46 | - url_fseek(m_pContext->pb, 0, SEEK_SET); | |
47 | + avio_seek(m_pContext->pb, 0, SEEK_SET); | |
48 | flush(); | |
49 | //av_find_stream_info(m_pContext); | |
50 | return 0; | |
51 | @@ -177,8 +175,8 @@ | |
52 | AVFrame pic; | |
53 | int got_pic = 0; | |
54 | memset(&pic, 0, sizeof(pic)); | |
55 | - int r = avcodec_decode_video(s->m_pAvContext, | |
56 | - &pic, &got_pic, pkt.data, pkt.size); | |
57 | + int r = avcodec_decode_video2(s->m_pAvContext, | |
58 | + &pic, &got_pic, &pkt); | |
59 | AVM_WRITE("FF reader", "____ %d %d\n", r, got_pic); | |
60 | } | |
61 | //printf("FFMPEG pktsize: %u %llu %d\n", pkt.size, pkt.pts, pkt.stream_index);fflush(stdout); | |
62 | @@ -203,19 +201,19 @@ | |
63 | / st->codec.frame_rate; | |
64 | } | |
65 | #endif | |
66 | - //if (st->codec.codec_type == CODEC_TYPE_VIDEO) printf("FRATE %d pts:%lld %d %d t:%lld\n", p->position, pkt.pts,st->codec.frame_rate_base, st->codec.frame_rate, p->timestamp); | |
67 | + //if (st->codec.codec_type == AVMEDIA_TYPE_VIDEO) printf("FRATE %d pts:%lld %d %d t:%lld\n", p->position, pkt.pts,st->codec.frame_rate_base, st->codec.frame_rate, p->timestamp); | |
68 | //else printf("Bitrate %d\n", st->codec.bit_rate); | |
69 | //printf("TIMESTAMP %lld %d %d bitrate:%d\n", p->timestamp, s->m_pAvStream->r_frame_rate_base, s->m_pAvStream->r_frame_rate, st->codec.bit_rate); | |
70 | ||
71 | switch (st->codec->codec_type) | |
72 | { | |
73 | - case CODEC_TYPE_AUDIO: | |
74 | + case AVMEDIA_TYPE_AUDIO: | |
75 | if (!pkt.pts && st->codec->bit_rate) | |
76 | p->timestamp = (int64_t)p->position * 8 * 1000000 / | |
77 | st->codec->bit_rate; | |
78 | s->m_uiPosition += pkt.size; | |
79 | break; | |
80 | - case CODEC_TYPE_VIDEO: | |
81 | + case AVMEDIA_TYPE_VIDEO: | |
82 | default: | |
83 | s->m_uiPosition++; | |
84 | break; | |
85 | @@ -227,7 +225,7 @@ | |
86 | pkt.stream_index, m_Streams[pkt.stream_index]->m_Packets.size(), | |
87 | pkt.pts, pkt.size, p->timestamp, pkt.flags); | |
88 | #endif | |
89 | - if (pkt.flags & PKT_FLAG_KEY) | |
90 | + if (pkt.flags & AV_PKT_FLAG_KEY) | |
91 | p->flags |= KEYFRAME; | |
92 | av_free_packet(&pkt); | |
93 | ||
94 | --- avifile-0.7-0.7.45/lib/aviread/FFReadStream.cpp.orig 2013-07-19 17:08:37.194742686 +0200 | |
95 | +++ avifile-0.7-0.7.45/lib/aviread/FFReadStream.cpp 2013-07-19 17:45:26.764649961 +0200 | |
96 | @@ -18,7 +18,7 @@ | |
97 | AVM_BEGIN_NAMESPACE; | |
98 | ||
99 | static const struct id2fcc { | |
100 | - enum CodecID id; | |
101 | + enum AVCodecID id; | |
102 | uint32_t fcc; | |
103 | } id2fcct[] = { | |
104 | { CODEC_ID_MPEG1VIDEO, RIFFINFO_MPG1 }, | |
105 | @@ -32,7 +32,7 @@ | |
106 | { CODEC_ID_NONE } | |
107 | }; | |
108 | ||
109 | -static int get_fcc(enum CodecID id) | |
110 | +static int get_fcc(enum AVCodecID id) | |
111 | { | |
112 | for (const struct id2fcc* p = id2fcct; p->id; p++) | |
113 | if (p->id == id) | |
114 | @@ -53,15 +53,15 @@ | |
115 | //printf("CODECRA %d %d %d\n", avs->codec.frame_rate, avs->codec->frame_rate_base, m_pAvStream->r_frame_rate_base); | |
116 | if (0 && avs->codec->codec_id == CODEC_ID_MPEG1VIDEO) | |
117 | { | |
118 | - m_pAvContext = avcodec_alloc_context(); | |
119 | + m_pAvContext = avcodec_alloc_context3(NULL); | |
120 | //AVCodec* codec = avcodec_find_encoder(avs->codec->codec_id); | |
121 | if (m_pAvContext) | |
122 | { | |
123 | AVCodec* codec = avcodec_find_decoder(avs->codec->codec_id); | |
124 | - if (codec && avcodec_open(m_pAvContext, codec) == 0) | |
125 | + if (codec && avcodec_open2(m_pAvContext, codec, NULL) == 0) | |
126 | { | |
127 | m_pAvContext->flags |= CODEC_FLAG_TRUNCATED; | |
128 | - m_pAvContext->hurry_up = 5; | |
129 | + m_pAvContext->skip_idct = m_pAvContext->skip_frame = AVDISCARD_ALL; | |
130 | //printf("Opened hurryup decoder %p %p\n", codec, m_pAvContext->codec->decode); | |
131 | } | |
132 | else | |
133 | @@ -148,7 +148,7 @@ | |
134 | ||
135 | switch (avs->codec->codec_type) | |
136 | { | |
137 | - case CODEC_TYPE_AUDIO: | |
138 | + case AVMEDIA_TYPE_AUDIO: | |
139 | m_StreamInfo.m_p->setAudio(avs->codec->channels, | |
140 | avs->codec->sample_rate, | |
141 | avs->codec->frame_bits); | |
142 | @@ -157,7 +157,7 @@ | |
143 | AVM_WRITE("FF stream", "Audio Format: %.4s (0x%x)\n", | |
144 | (const char*)&avs->codec->codec_tag, avs->codec->codec_tag); | |
145 | break; | |
146 | - case CODEC_TYPE_VIDEO: | |
147 | + case AVMEDIA_TYPE_VIDEO: | |
148 | m_StreamInfo.m_p->setVideo(avs->codec->width, avs->codec->height, | |
149 | 0, avs->codec->sample_aspect_ratio.num / | |
150 | (float) avs->codec->sample_aspect_ratio.den); | |
151 | @@ -191,8 +191,8 @@ | |
152 | { | |
153 | switch (m_pHandler->m_pContext->streams[m_uiSId]->codec->codec_type) | |
154 | { | |
155 | - case CODEC_TYPE_AUDIO: return IStream::Audio; | |
156 | - case CODEC_TYPE_VIDEO: return IStream::Video; | |
157 | + case AVMEDIA_TYPE_AUDIO: return IStream::Audio; | |
158 | + case AVMEDIA_TYPE_VIDEO: return IStream::Video; | |
159 | default: return IStream::Other; | |
160 | } | |
161 | } | |
162 | @@ -202,7 +202,7 @@ | |
163 | AVStream* avs = m_pHandler->m_pContext->streams[m_uiSId]; | |
164 | switch (avs->codec->codec_type) | |
165 | { | |
166 | - case CODEC_TYPE_AUDIO: | |
167 | + case AVMEDIA_TYPE_AUDIO: | |
168 | if (pFormat && lSize >= sizeof(WAVEFORMATEX)) | |
169 | { | |
170 | WAVEFORMATEX* wf = (WAVEFORMATEX*) pFormat; | |
171 | @@ -228,7 +228,7 @@ | |
172 | //printf("EEEEEEEEEEE %d\n", avs->codec->extradata_size); | |
173 | return sizeof(WAVEFORMATEX) | |
174 | + ((avs->codec->extradata) ? avs->codec->extradata_size : 0); | |
175 | - case CODEC_TYPE_VIDEO: | |
176 | + case AVMEDIA_TYPE_VIDEO: | |
177 | if (pFormat && lSize >= sizeof(BITMAPINFOHEADER)) | |
178 | { | |
179 | BITMAPINFOHEADER* bh = (BITMAPINFOHEADER*) pFormat; | |
180 | @@ -312,7 +312,7 @@ | |
181 | { | |
182 | if (time < 1.) | |
183 | { | |
184 | - if (m_pAvStream->codec->codec_type == CODEC_TYPE_AUDIO) | |
185 | + if (m_pAvStream->codec->codec_type == AVMEDIA_TYPE_AUDIO) | |
186 | // check if more streams are available | |
187 | // and seek only with the video | |
188 | return 0; | |
189 | --- avifile-0.7-0.7.45/lib/codeckeeper.cpp.orig 2013-07-19 17:48:46.567974909 +0200 | |
190 | +++ avifile-0.7-0.7.45/lib/codeckeeper.cpp 2013-07-19 17:53:49.324628870 +0200 | |
191 | @@ -295,7 +295,6 @@ | |
192 | audio_codecs.clear(); | |
193 | ||
194 | // FFMPEG initialization | |
195 | - avcodec_init(); | |
196 | avcodec_register_all(); | |
197 | ||
198 | uncompressed_FillPlugins(video_codecs); | |
199 | --- avifile-0.7-0.7.45/plugins/libffmpeg/libffmpeg.cpp.orig 2006-03-05 21:44:59.000000000 +0100 | |
200 | +++ avifile-0.7-0.7.45/plugins/libffmpeg/libffmpeg.cpp 2013-07-19 18:00:25.221278922 +0200 | |
201 | @@ -137,7 +137,6 @@ | |
202 | static int is_init = 0; | |
203 | if (!is_init) | |
204 | { | |
205 | - avcodec_init(); | |
206 | avcodec_register_all(); | |
207 | is_init++; | |
208 | } | |
209 | --- avifile-0.7-0.7.45/plugins/libffmpeg/FFAudioDecoder.cpp.orig 2013-07-19 18:01:05.454610568 +0200 | |
210 | +++ avifile-0.7-0.7.45/plugins/libffmpeg/FFAudioDecoder.cpp 2013-07-19 18:15:09.351241818 +0200 | |
211 | @@ -25,7 +25,7 @@ | |
212 | { | |
213 | if (!m_pAvContext) | |
214 | { | |
215 | - m_pAvContext = avcodec_alloc_context(); | |
216 | + m_pAvContext = avcodec_alloc_context3(NULL); | |
217 | m_pAvContext->channels = m_pFormat->nChannels; | |
218 | if (m_pAvContext->channels > 2) | |
219 | m_pAvContext->channels = 2; | |
220 | @@ -33,7 +33,7 @@ | |
221 | m_pAvContext->sample_rate = m_pFormat->nSamplesPerSec; | |
222 | m_pAvContext->block_align = m_pFormat->nBlockAlign; | |
223 | m_pAvContext->codec_tag = m_Info.fourcc; | |
224 | - m_pAvContext->codec_id = (CodecID) m_pAvCodec->id; | |
225 | + m_pAvContext->codec_id = (AVCodecID) m_pAvCodec->id; | |
226 | ||
227 | if (m_pFormat->cbSize > 0) | |
228 | { | |
229 | @@ -41,7 +41,7 @@ | |
230 | m_pAvContext->extradata_size = m_pFormat->cbSize; | |
231 | } | |
232 | ||
233 | - if (avcodec_open(m_pAvContext, m_pAvCodec) < 0) | |
234 | + if (avcodec_open2(m_pAvContext, m_pAvCodec, NULL) < 0) | |
235 | { | |
236 | AVM_WRITE("FFAudioDecoder", "WARNING: can't open avcodec\n"); | |
237 | free(m_pAvContext); | |
238 | @@ -50,8 +50,12 @@ | |
239 | } | |
240 | } | |
241 | int framesz = 0; | |
242 | - int hr = avcodec_decode_audio2(m_pAvContext, (int16_t*)out_data, &framesz, | |
243 | - (uint8_t*)in_data, in_size); | |
244 | + AVPacket avpkt; | |
245 | + av_init_packet(&avpkt); | |
246 | + avpkt.data = (uint8_t*)in_data; | |
247 | + avpkt.size = in_size; | |
248 | + int hr = avcodec_decode_audio3(m_pAvContext, (int16_t*)out_data, &framesz, | |
249 | + &avpkt); | |
250 | //printf("CONVERT i:%d o:%d f:%d h:%d\n", in_size, out_size, framesz, hr); | |
251 | if (size_read) | |
252 | *size_read = (hr < 0) ? in_size : hr; | |
253 | --- avifile-0.7-0.7.45/plugins/libffmpeg/FFVideoDecoder.cpp.orig 2013-07-19 18:15:45.704573627 +0200 | |
254 | +++ avifile-0.7-0.7.45/plugins/libffmpeg/FFVideoDecoder.cpp 2013-07-19 20:13:57.874275997 +0200 | |
255 | @@ -101,36 +101,29 @@ | |
256 | pic->pts = pImage->m_lTimestamp; | |
257 | pic->type = FF_BUFFER_TYPE_USER; | |
258 | pImage->m_iType = pic->pict_type; | |
259 | - //pic->age = pic->coded_picture_number - pImage->m_iAge; | |
260 | - //pImage->m_iAge = (pic->pict_type == FF_B_TYPE) ? | |
261 | + //pImage->m_iAge = (pic->pict_type == AV_PICTURE_TYPE_B) ? | |
262 | //pImage->m_iAge = (pic->reference) ? | |
263 | // -256*256*256*64 : pic->coded_picture_number; | |
264 | ||
265 | d->m_iAgeIP[0]++; | |
266 | - pic->age = d->m_iAgeIP[0] - pImage->m_iAge; | |
267 | - pImage->m_iAge = (pic->pict_type == FF_B_TYPE) ? | |
268 | + pImage->m_iAge = (pic->pict_type == AV_PICTURE_TYPE_B) ? | |
269 | 256*256*256*64 : d->m_iAgeIP[0]; | |
270 | - if (pic->age < 1) | |
271 | - pic->age = 256*256*256*64; | |
272 | ||
273 | #if 0 | |
274 | // mplayer code | |
275 | if (pic->reference) | |
276 | { | |
277 | - pic->age = d->m_iAgeIP[0]; | |
278 | d->m_iAgeIP[0] = d->m_iAgeIP[1] + 1; | |
279 | d->m_iAgeIP[1] = 1; | |
280 | d->m_iAgeB++; | |
281 | } | |
282 | else | |
283 | { | |
284 | - pic->age = d->m_iAgeB; | |
285 | d->m_iAgeIP[0]++; | |
286 | d->m_iAgeIP[1]++; | |
287 | d->m_iAgeB = 1; | |
288 | } | |
289 | #endif | |
290 | - //printf("Age %d %d cp:%d %p\n", pic->age, pImage->m_iAge, pic->coded_picture_number, pImage); | |
291 | //printf("PictType %d %d\n", pic->pict_type, pic->reference); | |
292 | //printf("%p %p %p %d %d\n", avctx->dr_buffer[0], avctx->dr_buffer[1], avctx->dr_buffer[2], avctx->dr_stride, avctx->dr_uvstride); | |
293 | return 0; | |
294 | @@ -172,7 +165,7 @@ | |
295 | //printf("FFMPEG space \n"); m_Dest.Print(); pImage->GetFmt()->Print(); | |
296 | if (!m_pAvContext) | |
297 | { | |
298 | - m_pAvContext = avcodec_alloc_context(); | |
299 | + m_pAvContext = avcodec_alloc_context3(NULL); | |
300 | // for autodetection errors | |
301 | m_pAvContext->codec_tag = m_pFormat->biCompression; | |
302 | m_pAvContext->bits_per_coded_sample = m_pFormat->biBitCount; | |
303 | @@ -198,8 +191,6 @@ | |
304 | { | |
305 | m_pAvContext->extradata_size = m_pFormat->biSize - sizeof(BITMAPINFOHEADER); | |
306 | m_pAvContext->extradata = (uint8_t*) m_pFormat + sizeof(BITMAPINFOHEADER); | |
307 | - if (m_pAvContext->extradata_size > 40) | |
308 | - m_pAvContext->flags |= CODEC_FLAG_EXTERN_HUFF; // somewhat useless | |
309 | } | |
310 | ||
311 | m_uiBuffers = (pImage && pImage->GetAllocator()) ? pImage->GetAllocator()->GetImages() : 0; | |
312 | @@ -297,7 +288,7 @@ | |
313 | m_pAvContext->workaround_bugs |= p->flag; | |
314 | } | |
315 | */ | |
316 | - if (avcodec_open(m_pAvContext, m_pAvCodec) < 0) | |
317 | + if (avcodec_open2(m_pAvContext, m_pAvCodec, NULL) < 0) | |
318 | { | |
319 | AVM_WRITE(m_Info.GetPrivateName(), "WARNING: FFVideoDecoder::DecodeFrame() can't open avcodec\n"); | |
320 | Stop(); | |
321 | @@ -317,9 +308,13 @@ | |
322 | m_bUsed = false; | |
323 | m_pReleased = 0; | |
324 | AVFrame pic; | |
325 | + AVPacket avpkt; | |
326 | int got_picture = 0; | |
327 | - int hr = avcodec_decode_video(m_pAvContext, &pic, &got_picture, | |
328 | - (unsigned char*) src, size); | |
329 | + av_init_packet(&avpkt); | |
330 | + avpkt.data = (unsigned char*)src; | |
331 | + avpkt.size = size; | |
332 | + int hr = avcodec_decode_video2(m_pAvContext, &pic, &got_picture, | |
333 | + &avpkt); | |
334 | //printf("DECFF got_picture %d %p del:%d hr:%d size:%d\n", got_picture, src, m_pAvContext->delay, hr, size); | |
335 | //printf("PictType %d\n", m_pAvContext->pict_type); | |
336 | //static int ctr=0; printf("WIDTH %dx%d %d r:%d\n", m_pAvContext->width, m_pAvContext->height, ctr++, m_pAvContext->pict_type); | |
337 | @@ -365,7 +360,7 @@ | |
338 | } | |
339 | ||
340 | Debug printf("FF: r=0x%x sz=%d %d b:%d img:%p out:%p\n", hr, size, got_picture, m_bUsed, pImage, pOut); | |
341 | - Debug printf("FF: frame_size %d number %d picnum %d\n", m_pAvContext->frame_size, m_pAvContext->frame_number, m_pAvContext->real_pict_num); | |
342 | + Debug printf("FF: frame_size %d number %d\n", m_pAvContext->frame_size, m_pAvContext->frame_number); | |
343 | if (!got_picture) | |
344 | { | |
345 | Debug printf("FF: NO PICTURE released=%p\n", m_pReleased); | |
346 | @@ -388,8 +383,8 @@ | |
347 | switch (m_pAvContext->pix_fmt) | |
348 | { | |
349 | case PIX_FMT_BGR24: imfmt = IMG_FMT_BGR24; break; | |
350 | - case PIX_FMT_RGBA32: imfmt = IMG_FMT_BGR32; break; | |
351 | - case PIX_FMT_YUV422: imfmt = IMG_FMT_YUY2; break; | |
352 | + case PIX_FMT_RGB32: imfmt = IMG_FMT_BGR32; break; | |
353 | + case PIX_FMT_YUYV422: imfmt = IMG_FMT_YUY2; break; | |
354 | case PIX_FMT_YUV410P: imfmt = IMG_FMT_I410; break; | |
355 | case PIX_FMT_YUV411P: imfmt = IMG_FMT_I411; break; | |
356 | case PIX_FMT_YUV420P: imfmt = IMG_FMT_I420; break; | |
357 | --- avifile-0.7-0.7.45/plugins/libffmpeg/FFVideoEncoder.cpp.orig 2005-09-12 14:06:48.000000000 +0200 | |
358 | +++ avifile-0.7-0.7.45/plugins/libffmpeg/FFVideoEncoder.cpp 2013-07-19 20:15:08.434273035 +0200 | |
359 | @@ -122,7 +122,7 @@ | |
360 | ||
361 | if (!m_pAvContext) | |
362 | { | |
363 | - m_pAvContext = avcodec_alloc_context(); | |
364 | + m_pAvContext = avcodec_alloc_context3(NULL); | |
365 | m_pAvContext->width = m_bh.biWidth; | |
366 | m_pAvContext->height = m_obh.biHeight; | |
367 | //m_pAvContext->pix_fmt = PIX_FMT_YUV420P; | |
368 | @@ -138,7 +138,7 @@ | |
369 | ||
370 | printf("CODEC opening %dx%d\n", m_bh.biWidth, m_obh.biHeight); | |
371 | ||
372 | - if (avcodec_open(m_pAvContext, m_pAvCodec) < 0) | |
373 | + if (avcodec_open2(m_pAvContext, m_pAvCodec, NULL) < 0) | |
374 | { | |
375 | free(m_pAvContext); | |
376 | m_pAvContext = 0; | |
67ba34c6 JB |
377 | --- avifile-0.7-0.7.45/lib/aviread/FFReadHandler.cpp.orig 2020-08-29 20:43:18.688873368 +0200 |
378 | +++ avifile-0.7-0.7.45/lib/aviread/FFReadHandler.cpp 2020-08-29 20:43:43.955403155 +0200 | |
379 | @@ -40,7 +40,7 @@ | |
380 | delete m_Streams.back(); | |
381 | m_Streams.pop_back(); | |
382 | } | |
383 | - av_close_input_file(m_pContext); | |
384 | + avformat_close_input(&m_pContext); | |
385 | } | |
386 | } | |
387 | ||
388 | @@ -58,7 +58,7 @@ | |
389 | return -1; | |
390 | } | |
391 | ||
392 | - if (av_find_stream_info(m_pContext) < 0) | |
393 | + if (avformat_find_stream_info(m_pContext, NULL) < 0) | |
394 | return -1; | |
395 | ||
396 | AVM_WRITE("FF reader", "Format %s streams:%d\n", m_pContext->iformat->long_name, m_pContext->nb_streams); | |
397 | @@ -161,9 +161,9 @@ | |
398 | Locker locker(m_Mutex); | |
399 | AVPacket pkt; | |
400 | AVM_WRITE("FF reader", "readPacket()\n"); | |
401 | - if (av_read_packet(m_pContext, &pkt) < 0) | |
402 | + if (av_read_frame(m_pContext, &pkt) < 0) | |
403 | { | |
404 | - if (!url_feof(m_pContext->pb)) | |
405 | + if (!avio_feof(m_pContext->pb)) | |
406 | AVM_WRITE("FF reader", "ffmpeg packet error and not eof??\n"); | |
407 | return -1; | |
408 | } | |
409 | --- avifile-0.7-0.7.45/lib/aviread/FFReadStream.cpp.orig 2020-08-29 20:22:05.882435419 +0200 | |
410 | +++ avifile-0.7-0.7.45/lib/aviread/FFReadStream.cpp 2020-08-29 20:46:33.481151421 +0200 | |
411 | @@ -21,15 +21,15 @@ | |
412 | enum AVCodecID id; | |
413 | uint32_t fcc; | |
414 | } id2fcct[] = { | |
415 | - { CODEC_ID_MPEG1VIDEO, RIFFINFO_MPG1 }, | |
416 | - { CODEC_ID_H263, mmioFOURCC('H', '2', '6', '3') }, | |
417 | - { CODEC_ID_H263P, mmioFOURCC('H', '2', '6', '3') }, | |
418 | - { CODEC_ID_MP2, 0x50 }, | |
419 | - { CODEC_ID_MP3, 0x55 }, | |
420 | - { CODEC_ID_AC3, 0x2000 }, | |
421 | - { CODEC_ID_DVVIDEO, mmioFOURCC('D', 'V', 'S', 'D') }, | |
422 | - { CODEC_ID_DVAUDIO, ('D' << 8) | 'A' }, | |
423 | - { CODEC_ID_NONE } | |
424 | + { AV_CODEC_ID_MPEG1VIDEO, RIFFINFO_MPG1 }, | |
425 | + { AV_CODEC_ID_H263, mmioFOURCC('H', '2', '6', '3') }, | |
426 | + { AV_CODEC_ID_H263P, mmioFOURCC('H', '2', '6', '3') }, | |
427 | + { AV_CODEC_ID_MP2, 0x50 }, | |
428 | + { AV_CODEC_ID_MP3, 0x55 }, | |
429 | + { AV_CODEC_ID_AC3, 0x2000 }, | |
430 | + { AV_CODEC_ID_DVVIDEO, mmioFOURCC('D', 'V', 'S', 'D') }, | |
431 | + { AV_CODEC_ID_DVAUDIO, ('D' << 8) | 'A' }, | |
432 | + { AV_CODEC_ID_NONE } | |
433 | }; | |
434 | ||
435 | static int get_fcc(enum AVCodecID id) | |
436 | @@ -51,7 +51,7 @@ | |
437 | m_pHandler->m_pContext->start_time, m_pHandler->m_pContext->duration); | |
438 | m_dLength = m_pHandler->m_pContext->duration / (double) AV_TIME_BASE; | |
439 | //printf("CODECRA %d %d %d\n", avs->codec.frame_rate, avs->codec->frame_rate_base, m_pAvStream->r_frame_rate_base); | |
440 | - if (0 && avs->codec->codec_id == CODEC_ID_MPEG1VIDEO) | |
441 | + if (0 && avs->codec->codec_id == AV_CODEC_ID_MPEG1VIDEO) | |
442 | { | |
443 | m_pAvContext = avcodec_alloc_context3(NULL); | |
444 | //AVCodec* codec = avcodec_find_encoder(avs->codec->codec_id); | |
445 | @@ -60,7 +60,7 @@ | |
446 | AVCodec* codec = avcodec_find_decoder(avs->codec->codec_id); | |
447 | if (codec && avcodec_open2(m_pAvContext, codec, NULL) == 0) | |
448 | { | |
449 | - m_pAvContext->flags |= CODEC_FLAG_TRUNCATED; | |
450 | + m_pAvContext->flags |= AV_CODEC_FLAG_TRUNCATED; | |
451 | m_pAvContext->skip_idct = m_pAvContext->skip_frame = AVDISCARD_ALL; | |
452 | //printf("Opened hurryup decoder %p %p\n", codec, m_pAvContext->codec->decode); | |
453 | } | |
454 | --- avifile-0.7-0.7.45/plugins/libffmpeg/FFAudioDecoder.cpp.orig 2020-08-29 21:50:27.323715047 +0200 | |
455 | +++ avifile-0.7-0.7.45/plugins/libffmpeg/FFAudioDecoder.cpp 2020-08-29 21:50:31.260360387 +0200 | |
456 | @@ -49,18 +49,23 @@ | |
457 | return -1; | |
458 | } | |
459 | } | |
460 | - int framesz = 0; | |
461 | + int got_frame = 0; | |
462 | AVPacket avpkt; | |
463 | av_init_packet(&avpkt); | |
464 | avpkt.data = (uint8_t*)in_data; | |
465 | avpkt.size = in_size; | |
466 | - int hr = avcodec_decode_audio3(m_pAvContext, (int16_t*)out_data, &framesz, | |
467 | + AVFrame *decoded_frame = av_frame_alloc(); | |
468 | + int hr = avcodec_decode_audio4(m_pAvContext, decoded_frame, &got_frame, | |
469 | &avpkt); | |
470 | - //printf("CONVERT i:%d o:%d f:%d h:%d\n", in_size, out_size, framesz, hr); | |
471 | + int data_size = av_samples_get_buffer_size(NULL, m_pAvContext->channels, decoded_frame->nb_samples, m_pAvContext->sample_fmt, 1); | |
472 | if (size_read) | |
473 | *size_read = (hr < 0) ? in_size : hr; | |
474 | if (size_written) | |
475 | - *size_written = framesz; | |
476 | + *size_written = data_size; | |
477 | + | |
478 | + if (hr > 0) | |
479 | + memcpy(out_data, decoded_frame->data[0], data_size); | |
480 | + av_free(decoded_frame); | |
481 | ||
482 | if (hr < 0) | |
483 | { | |
484 | --- avifile-0.7-0.7.45/plugins/libffmpeg/FFVideoDecoder.cpp.orig 2020-08-29 20:47:30.190844199 +0200 | |
485 | +++ avifile-0.7-0.7.45/plugins/libffmpeg/FFVideoDecoder.cpp 2020-08-30 17:57:09.138147425 +0200 | |
486 | @@ -17,6 +17,12 @@ | |
487 | #endif | |
488 | ||
489 | #define Debug if (0) | |
490 | + | |
491 | +struct BufferData { | |
492 | + void *decoder; | |
493 | + AVFrame *pic; | |
494 | +}; | |
495 | + | |
496 | AVM_BEGIN_NAMESPACE; | |
497 | ||
498 | FFVideoDecoder::FFVideoDecoder(AVCodec* av, const CodecInfo& info, const BITMAPINFOHEADER& bh, int flip) | |
499 | @@ -31,7 +37,7 @@ | |
500 | if (1 && m_pFormat->biCompression == fccHFYU) | |
501 | { | |
502 | // for now disabled | |
503 | - m_pAvCodec->capabilities &= ~(CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1); | |
504 | + m_pAvCodec->capabilities &= ~(AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1); | |
505 | AVM_WRITE(m_Info.GetPrivateName(), "if you have troubles - use Win32 codec instead\n"); | |
506 | m_Caps = (CAPS) (m_Caps | CAP_YUY2); | |
507 | } | |
508 | @@ -75,31 +81,39 @@ | |
509 | d->m_pImg->Slice(&ci); | |
510 | } | |
511 | ||
512 | +static void free_buffer(void *opaque, uint8_t *data); | |
513 | + | |
514 | // callback to supply rendering buffer to ffmpeg | |
515 | -static int get_buffer(AVCodecContext* avctx, AVFrame* pic) | |
516 | +static int get_buffer2(AVCodecContext* avctx, AVFrame* pic, int flags) | |
517 | { | |
518 | + BufferData* buf_dat; | |
519 | FFVideoDecoder* d = (FFVideoDecoder*) avctx->opaque; | |
520 | CImage* pImage = d->m_pImg; | |
521 | d->m_bUsed = true; | |
522 | - if (avctx->pix_fmt != PIX_FMT_YUV420P || !pImage || !d->m_bDirect) | |
523 | + if (avctx->pix_fmt != AV_PIX_FMT_YUV420P || !pImage || !d->m_bDirect) | |
524 | { | |
525 | Debug printf("FF: Unsupported pixel format for Dr1 %d\n", avctx->pix_fmt); //abort(); | |
526 | - return avcodec_default_get_buffer(avctx, pic); | |
527 | + return avcodec_default_get_buffer2(avctx, pic, flags); | |
528 | } | |
529 | ||
530 | Debug printf("FF: GetBuffer %p %dx%d %d %p:%p:%p %f\n", pImage, avctx->width, avctx->height, pic->pict_type, | |
531 | pImage->Data(0), pImage->Data(2), pImage->Data(1), pImage->m_lTimestamp / 1000000.0); | |
532 | ||
533 | pic->opaque = pImage; | |
534 | - pic->data[0] = pImage->Data(0); | |
535 | - pic->data[1] = pImage->Data(2); | |
536 | - pic->data[2] = pImage->Data(1); | |
537 | + buf_dat = (BufferData*)av_malloc(sizeof(*buf_dat)); | |
538 | + buf_dat->decoder = d; | |
539 | + buf_dat->pic = pic; | |
540 | + pic->buf[0] = av_buffer_create (pImage->Data(0), 0, free_buffer, buf_dat, 0); | |
541 | + pic->buf[1] = av_buffer_create (pImage->Data(2), 0, free_buffer, NULL, 0); | |
542 | + pic->buf[2] = av_buffer_create (pImage->Data(1), 0, free_buffer, NULL, 0); | |
543 | + pic->data[0] = pic->buf[0]->data; | |
544 | + pic->data[1] = pic->buf[1]->data; | |
545 | + pic->data[2] = pic->buf[2]->data; | |
546 | pic->linesize[0] = pImage->Stride(0); | |
547 | // Note: most ffmpeg codecs linsize[1] == linesize[2] ! | |
548 | pic->linesize[1] = pImage->Stride(2); | |
549 | pic->linesize[2] = pImage->Stride(1); | |
550 | pic->pts = pImage->m_lTimestamp; | |
551 | - pic->type = FF_BUFFER_TYPE_USER; | |
552 | pImage->m_iType = pic->pict_type; | |
553 | //pImage->m_iAge = (pic->pict_type == AV_PICTURE_TYPE_B) ? | |
554 | //pImage->m_iAge = (pic->reference) ? | |
555 | @@ -129,21 +143,16 @@ | |
556 | return 0; | |
557 | } | |
558 | ||
559 | -static void release_buffer(struct AVCodecContext* avctx, AVFrame* pic) | |
560 | +static void free_buffer(void *opaque, uint8_t *data) | |
561 | { | |
562 | - if (pic->type == FF_BUFFER_TYPE_USER) | |
563 | - { | |
564 | - FFVideoDecoder* d = (FFVideoDecoder*) avctx->opaque; | |
565 | - d->m_pReleased = (CImage*) pic->opaque; | |
566 | - Debug printf("FF: Released buffer %p %p\n", pic->opaque, pic); | |
567 | - for (int i = 4; i >= 0; i--) | |
568 | - pic->data[i]= NULL; | |
569 | - pic->opaque = NULL; | |
570 | - } | |
571 | - else | |
572 | + if (opaque) | |
573 | { | |
574 | - Debug printf("******************************\n"); | |
575 | - avcodec_default_release_buffer(avctx, pic); | |
576 | + BufferData *buf_dat = (BufferData *) opaque; | |
577 | + FFVideoDecoder* d = (FFVideoDecoder*) buf_dat->decoder; | |
578 | + d->m_pReleased = (CImage*) buf_dat->pic->opaque; | |
579 | + Debug printf("FF: Released buffer %p %p\n", buf_dat->pic->opaque, buf_dat->pic); | |
580 | + buf_dat->pic->opaque = NULL; | |
581 | + av_free(buf_dat); | |
582 | } | |
583 | } | |
584 | ||
585 | @@ -171,8 +180,7 @@ | |
586 | m_pAvContext->bits_per_coded_sample = m_pFormat->biBitCount; | |
587 | m_pAvContext->width = m_Dest.biWidth; | |
588 | m_pAvContext->height = (m_Dest.biHeight < 0) ? -m_Dest.biHeight : m_Dest.biHeight; | |
589 | - m_pAvContext->get_buffer = avcodec_default_get_buffer; | |
590 | - m_pAvContext->release_buffer = avcodec_default_release_buffer; | |
591 | + m_pAvContext->get_buffer2 = avcodec_default_get_buffer2; | |
592 | ||
593 | if (m_pFormat->biSize > sizeof(BITMAPINFOHEADER) | |
594 | #if 0 | |
595 | @@ -200,7 +208,7 @@ | |
596 | const char* drtxt = "doesn't support DR1\n"; | |
597 | ||
598 | m_bDirect = false; | |
599 | - if (m_pAvCodec->capabilities & CODEC_CAP_DR1) | |
600 | + if (m_pAvCodec->capabilities & AV_CODEC_CAP_DR1) | |
601 | { | |
602 | drtxt = "not using DR1\n"; | |
603 | if (pImage) | |
604 | @@ -220,12 +228,10 @@ | |
605 | { | |
606 | // for DR we needs some special width aligment | |
607 | // also there are some more limitation | |
608 | - m_pAvContext->flags |= CODEC_FLAG_EMU_EDGE; | |
609 | drtxt = "using DR1\n"; | |
610 | m_bDirect = true; | |
611 | ||
612 | - m_pAvContext->get_buffer = get_buffer; | |
613 | - m_pAvContext->release_buffer = release_buffer; | |
614 | + m_pAvContext->get_buffer2 = get_buffer2; | |
615 | } | |
616 | } | |
617 | } | |
618 | @@ -234,8 +240,8 @@ | |
619 | m_bRestart = false; | |
620 | ||
621 | if (m_Info.fourcc == RIFFINFO_MPG1 | |
622 | - && m_pAvCodec->capabilities & CODEC_CAP_TRUNCATED) | |
623 | - m_pAvContext->flags |= CODEC_FLAG_TRUNCATED; | |
624 | + && m_pAvCodec->capabilities & AV_CODEC_CAP_TRUNCATED) | |
625 | + m_pAvContext->flags |= AV_CODEC_FLAG_TRUNCATED; | |
626 | ||
627 | //m_pAvContext->error_resilience = 2; | |
628 | //m_pAvContext->error_concealment = 3; | |
629 | @@ -299,7 +305,7 @@ | |
630 | // try using draw_horiz_band if DR1 is unsupported | |
631 | m_pAvContext->draw_horiz_band = | |
632 | (!m_bDirect && pImage && pImage->Format() == IMG_FMT_YV12 | |
633 | - && (m_pAvCodec->capabilities & CODEC_CAP_DRAW_HORIZ_BAND) | |
634 | + && (m_pAvCodec->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND) | |
635 | && !pImage->Direction() && render) ? draw_slice : 0; | |
636 | m_pAvContext->opaque = this; | |
637 | ||
638 | @@ -324,7 +330,7 @@ | |
639 | AVM_WRITE(m_Info.GetPrivateName(), "WARNING: FFVideoDecoder::DecodeFrame() hr=%d\n", hr); | |
640 | return hr; | |
641 | } | |
642 | - if (!(m_pAvContext->flags & CODEC_FLAG_TRUNCATED)) | |
643 | + if (!(m_pAvContext->flags & AV_CODEC_FLAG_TRUNCATED)) | |
644 | { | |
645 | hr = size; | |
646 | //m_bUsed = true; | |
647 | @@ -368,7 +374,6 @@ | |
648 | return hr | NO_PICTURE; | |
649 | // let's fake got_picture; | |
650 | if (!pic.opaque) { | |
651 | - pic.type = FF_BUFFER_TYPE_USER; | |
652 | pic.opaque = m_pReleased; | |
653 | } | |
654 | got_picture = true; | |
655 | @@ -382,14 +387,14 @@ | |
656 | int imfmt = 0; | |
657 | switch (m_pAvContext->pix_fmt) | |
658 | { | |
659 | - case PIX_FMT_BGR24: imfmt = IMG_FMT_BGR24; break; | |
660 | - case PIX_FMT_RGB32: imfmt = IMG_FMT_BGR32; break; | |
661 | - case PIX_FMT_YUYV422: imfmt = IMG_FMT_YUY2; break; | |
662 | - case PIX_FMT_YUV410P: imfmt = IMG_FMT_I410; break; | |
663 | - case PIX_FMT_YUV411P: imfmt = IMG_FMT_I411; break; | |
664 | - case PIX_FMT_YUV420P: imfmt = IMG_FMT_I420; break; | |
665 | - case PIX_FMT_YUV422P: imfmt = IMG_FMT_I422; break; | |
666 | - case PIX_FMT_YUV444P: imfmt = IMG_FMT_I444; break; | |
667 | + case AV_PIX_FMT_BGR24: imfmt = IMG_FMT_BGR24; break; | |
668 | + case AV_PIX_FMT_RGB32: imfmt = IMG_FMT_BGR32; break; | |
669 | + case AV_PIX_FMT_YUYV422: imfmt = IMG_FMT_YUY2; break; | |
670 | + case AV_PIX_FMT_YUV410P: imfmt = IMG_FMT_I410; break; | |
671 | + case AV_PIX_FMT_YUV411P: imfmt = IMG_FMT_I411; break; | |
672 | + case AV_PIX_FMT_YUV420P: imfmt = IMG_FMT_I420; break; | |
673 | + case AV_PIX_FMT_YUV422P: imfmt = IMG_FMT_I422; break; | |
674 | + case AV_PIX_FMT_YUV444P: imfmt = IMG_FMT_I444; break; | |
675 | default: break; | |
676 | } | |
677 | if (imfmt) { | |
678 | @@ -415,11 +420,8 @@ | |
679 | //printf("SWAP %d %d\n", m_Order.front().position, pImage->m_uiPosition); | |
680 | //printf("P %d %lld\n", p, m_Order[0].timestamp, m_Order.size()); | |
681 | ||
682 | - //printf("PICTYPE %d %p %p %d\n", pic.type, m_pReleased, pOut, FF_BUFFER_TYPE_USER); | |
683 | #if 1 | |
684 | - if (pOut && pic.opaque && | |
685 | - ((pic.type == FF_BUFFER_TYPE_USER) | |
686 | - || (pic.type == FF_BUFFER_TYPE_COPY))) | |
687 | + if (pOut && pic.opaque) | |
688 | { | |
689 | *pOut = (CImage*) pic.opaque; | |
690 | (*pOut)->m_lTimestamp = m_Order[0].timestamp; | |
691 | --- avifile-0.7-0.7.45/plugins/libffmpeg/FFVideoEncoder.cpp.orig 2020-08-29 20:47:30.190844199 +0200 | |
692 | +++ avifile-0.7-0.7.45/plugins/libffmpeg/FFVideoEncoder.cpp 2020-08-30 18:06:20.805158789 +0200 | |
693 | @@ -220,11 +220,15 @@ | |
694 | //printf("ECDING FF %p %p %p sz:%d\n", f.data[0], f.data[1], f.data[2], GetOutputSize()); | |
695 | //printf("ECDING FF %d %d %d\n", f.linesize[0], f.linesize[1], f.linesize[2]); | |
696 | ||
697 | - int rsize = avcodec_encode_video(m_pAvContext, (unsigned char*) dest, | |
698 | - GetOutputSize(), &f); | |
699 | + AVPacket pkt; | |
700 | + pkt.data = (uint8_t*)dest; | |
701 | + pkt.size = GetOutputSize(); | |
702 | + int got_output; | |
703 | + | |
704 | + int ret = avcodec_encode_video2(m_pAvContext, &pkt, &f, &got_output); | |
705 | //printf("ECDING FF size %d\n", rsize); | |
706 | if (size) | |
707 | - *size = rsize; | |
708 | + *size = pkt.size; | |
709 | if (is_keyframe) { | |
710 | *is_keyframe = m_pAvContext->coded_frame->key_frame ? 16 : 0; | |
711 | //printf("KEYFRAME %d\n", *is_keyframe); |