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
5 int FFReadHandler::Init(const char* url)
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,
15 + int r = avformat_open_input(&m_pContext, url,
19 AVM_WRITE("FF reader", "OPEN INPUT failed\n");
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;
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;
43 int FFReadHandler::seek(framepos_t pos)
45 Locker locker(m_Mutex);
46 - url_fseek(m_pContext->pb, 0, SEEK_SET);
47 + avio_seek(m_pContext->pb, 0, SEEK_SET);
49 //av_find_stream_info(m_pContext);
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);
61 //printf("FFMPEG pktsize: %u %llu %d\n", pkt.size, pkt.pts, pkt.stream_index);fflush(stdout);
63 / st->codec.frame_rate;
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);
71 switch (st->codec->codec_type)
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 /
78 s->m_uiPosition += pkt.size;
80 - case CODEC_TYPE_VIDEO:
81 + case AVMEDIA_TYPE_VIDEO:
86 pkt.stream_index, m_Streams[pkt.stream_index]->m_Packets.size(),
87 pkt.pts, pkt.size, p->timestamp, pkt.flags);
89 - if (pkt.flags & PKT_FLAG_KEY)
90 + if (pkt.flags & AV_PKT_FLAG_KEY)
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
99 static const struct id2fcc {
104 { CODEC_ID_MPEG1VIDEO, RIFFINFO_MPG1 },
109 -static int get_fcc(enum CodecID id)
110 +static int get_fcc(enum AVCodecID id)
112 for (const struct id2fcc* p = id2fcct; p->id; p++)
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)
118 - m_pAvContext = avcodec_alloc_context();
119 + m_pAvContext = avcodec_alloc_context3(NULL);
120 //AVCodec* codec = avcodec_find_encoder(avs->codec->codec_id);
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)
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);
135 switch (avs->codec->codec_type)
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);
143 AVM_WRITE("FF stream", "Audio Format: %.4s (0x%x)\n",
144 (const char*)&avs->codec->codec_tag, avs->codec->codec_tag);
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);
153 switch (m_pHandler->m_pContext->streams[m_uiSId]->codec->codec_type)
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;
163 AVStream* avs = m_pHandler->m_pContext->streams[m_uiSId];
164 switch (avs->codec->codec_type)
166 - case CODEC_TYPE_AUDIO:
167 + case AVMEDIA_TYPE_AUDIO:
168 if (pFormat && lSize >= sizeof(WAVEFORMATEX))
170 WAVEFORMATEX* wf = (WAVEFORMATEX*) pFormat;
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))
179 BITMAPINFOHEADER* bh = (BITMAPINFOHEADER*) pFormat;
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
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
192 audio_codecs.clear();
194 // FFMPEG initialization
196 avcodec_register_all();
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
202 static int is_init = 0;
206 avcodec_register_all();
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
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;
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;
227 if (m_pFormat->cbSize > 0)
230 m_pAvContext->extradata_size = m_pFormat->cbSize;
233 - if (avcodec_open(m_pAvContext, m_pAvCodec) < 0)
234 + if (avcodec_open2(m_pAvContext, m_pAvCodec, NULL) < 0)
236 AVM_WRITE("FFAudioDecoder", "WARNING: can't open avcodec\n");
242 - int hr = avcodec_decode_audio2(m_pAvContext, (int16_t*)out_data, &framesz,
243 - (uint8_t*)in_data, in_size);
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,
250 //printf("CONVERT i:%d o:%d f:%d h:%d\n", in_size, out_size, framesz, hr);
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;
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];
271 - pic->age = 256*256*256*64;
277 - pic->age = d->m_iAgeIP[0];
278 d->m_iAgeIP[0] = d->m_iAgeIP[1] + 1;
284 - pic->age = d->m_iAgeB;
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);
295 //printf("FFMPEG space \n"); m_Dest.Print(); pImage->GetFmt()->Print();
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;
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
311 m_uiBuffers = (pImage && pImage->GetAllocator()) ? pImage->GetAllocator()->GetImages() : 0;
313 m_pAvContext->workaround_bugs |= p->flag;
316 - if (avcodec_open(m_pAvContext, m_pAvCodec) < 0)
317 + if (avcodec_open2(m_pAvContext, m_pAvCodec, NULL) < 0)
319 AVM_WRITE(m_Info.GetPrivateName(), "WARNING: FFVideoDecoder::DecodeFrame() can't open avcodec\n");
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;
332 + int hr = avcodec_decode_video2(m_pAvContext, &pic, &got_picture,
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);
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);
345 Debug printf("FF: NO PICTURE released=%p\n", m_pReleased);
347 switch (m_pAvContext->pix_fmt)
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
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;
370 printf("CODEC opening %dx%d\n", m_bh.biWidth, m_obh.biHeight);
372 - if (avcodec_open(m_pAvContext, m_pAvCodec) < 0)
373 + if (avcodec_open2(m_pAvContext, m_pAvCodec, NULL) < 0)
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
380 delete m_Streams.back();
381 m_Streams.pop_back();
383 - av_close_input_file(m_pContext);
384 + avformat_close_input(&m_pContext);
392 - if (av_find_stream_info(m_pContext) < 0)
393 + if (avformat_find_stream_info(m_pContext, NULL) < 0)
396 AVM_WRITE("FF reader", "Format %s streams:%d\n", m_pContext->iformat->long_name, m_pContext->nb_streams);
398 Locker locker(m_Mutex);
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)
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");
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
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' },
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 }
435 static int get_fcc(enum AVCodecID id)
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)
443 m_pAvContext = avcodec_alloc_context3(NULL);
444 //AVCodec* codec = avcodec_find_encoder(avs->codec->codec_id);
446 AVCodec* codec = avcodec_find_decoder(avs->codec->codec_id);
447 if (codec && avcodec_open2(m_pAvContext, codec, NULL) == 0)
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);
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
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,
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);
473 *size_read = (hr < 0) ? in_size : hr;
475 - *size_written = framesz;
476 + *size_written = data_size;
479 + memcpy(out_data, decoded_frame->data[0], data_size);
480 + av_free(decoded_frame);
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
498 FFVideoDecoder::FFVideoDecoder(AVCodec* av, const CodecInfo& info, const BITMAPINFOHEADER& bh, int flip)
500 if (1 && m_pFormat->biCompression == fccHFYU)
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);
509 d->m_pImg->Slice(&ci);
512 +static void free_buffer(void *opaque, uint8_t *data);
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)
518 + BufferData* buf_dat;
519 FFVideoDecoder* d = (FFVideoDecoder*) avctx->opaque;
520 CImage* pImage = d->m_pImg;
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)
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);
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);
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 @@
559 -static void release_buffer(struct AVCodecContext* avctx, AVFrame* pic)
560 +static void free_buffer(void *opaque, uint8_t *data)
562 - if (pic->type == FF_BUFFER_TYPE_USER)
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;
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;
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;
593 if (m_pFormat->biSize > sizeof(BITMAPINFOHEADER)
596 const char* drtxt = "doesn't support DR1\n";
599 - if (m_pAvCodec->capabilities & CODEC_CAP_DR1)
600 + if (m_pAvCodec->capabilities & AV_CODEC_CAP_DR1)
602 drtxt = "not using DR1\n";
604 @@ -220,12 +228,10 @@
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";
612 - m_pAvContext->get_buffer = get_buffer;
613 - m_pAvContext->release_buffer = release_buffer;
614 + m_pAvContext->get_buffer2 = get_buffer2;
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;
627 //m_pAvContext->error_resilience = 2;
628 //m_pAvContext->error_concealment = 3;
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;
639 AVM_WRITE(m_Info.GetPrivateName(), "WARNING: FFVideoDecoder::DecodeFrame() hr=%d\n", hr);
642 - if (!(m_pAvContext->flags & CODEC_FLAG_TRUNCATED))
643 + if (!(m_pAvContext->flags & AV_CODEC_FLAG_TRUNCATED))
648 return hr | NO_PICTURE;
649 // let's fake got_picture;
651 - pic.type = FF_BUFFER_TYPE_USER;
652 pic.opaque = m_pReleased;
655 @@ -382,14 +387,14 @@
657 switch (m_pAvContext->pix_fmt)
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;
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());
682 - //printf("PICTYPE %d %p %p %d\n", pic.type, m_pReleased, pOut, FF_BUFFER_TYPE_USER);
684 - if (pOut && pic.opaque &&
685 - ((pic.type == FF_BUFFER_TYPE_USER)
686 - || (pic.type == FF_BUFFER_TYPE_COPY)))
687 + if (pOut && pic.opaque)
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]);
697 - int rsize = avcodec_encode_video(m_pAvContext, (unsigned char*) dest,
698 - GetOutputSize(), &f);
700 + pkt.data = (uint8_t*)dest;
701 + pkt.size = GetOutputSize();
704 + int ret = avcodec_encode_video2(m_pAvContext, &pkt, &f, &got_output);
705 //printf("ECDING FF size %d\n", rsize);
710 *is_keyframe = m_pAvContext->coded_frame->key_frame ? 16 : 0;
711 //printf("KEYFRAME %d\n", *is_keyframe);