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)