Projects
Games
avifile
avifile-ffmpeg-1.0.patch
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File avifile-ffmpeg-1.0.patch of Package avifile
diff -urN avifile-0.7-0.7.45.orig/lib/aviread/FFReadHandler.cpp avifile-0.7-0.7.45/lib/aviread/FFReadHandler.cpp --- avifile-0.7-0.7.45.orig/lib/aviread/FFReadHandler.cpp 2013-05-18 21:06:57.115712974 +0800 +++ avifile-0.7-0.7.45/lib/aviread/FFReadHandler.cpp 2013-05-18 23:50:13.538240839 +0800 @@ -38,27 +38,24 @@ delete m_Streams.back(); m_Streams.pop_back(); } - av_close_input_file(m_pContext); + avformat_close_input(&m_pContext); } } int FFReadHandler::Init(const char* url) { - AVFormatParameters avfp; AVInputFormat* fmt = 0; // av_find_input_format(url); // printf("find input format %p %s\n", fmt, url); - memset(&avfp, 0, sizeof(avfp)); - //if (!fmt) return -1; - int r = av_open_input_file(&m_pContext, url, - fmt, 64000, &avfp); + int r = avformat_open_input(&m_pContext, url, + fmt, NULL); if (r < 0) { AVM_WRITE("FF reader", "OPEN INPUT failed\n"); return -1; } - if (av_find_stream_info(m_pContext) < 0) + if (avformat_find_stream_info(m_pContext, NULL) < 0) return -1; AVM_WRITE("FF reader", "Format %s streams:%d\n", m_pContext->iformat->long_name, m_pContext->nb_streams); @@ -98,8 +95,8 @@ uint_t j = 0; switch (type) { - case IStream::Audio: t = CODEC_TYPE_AUDIO; break; - case IStream::Video: t = CODEC_TYPE_VIDEO; break; + case IStream::Audio: t = AVMEDIA_TYPE_AUDIO; break; + case IStream::Video: t = AVMEDIA_TYPE_VIDEO; break; default: return 0; } @@ -123,8 +120,8 @@ switch (type) { - case IStream::Audio: t = CODEC_TYPE_AUDIO; break; - case IStream::Video: t = CODEC_TYPE_VIDEO; break; + case IStream::Audio: t = AVMEDIA_TYPE_AUDIO; break; + case IStream::Video: t = AVMEDIA_TYPE_VIDEO; break; default: return 0; } @@ -150,7 +147,7 @@ int FFReadHandler::seek(framepos_t pos) { Locker locker(m_Mutex); - url_fseek(&m_pContext->pb, 0, SEEK_SET); + avio_seek((AVIOContext*) &m_pContext->pb, 0, SEEK_SET); flush(); //av_find_stream_info(m_pContext); return 0; @@ -163,7 +160,7 @@ AVM_WRITE("FF reader", "readPacket()\n"); if (av_read_packet(m_pContext, &pkt) < 0) { - if (!url_feof(&m_pContext->pb)) + if (!url_feof((AVIOContext*) &m_pContext->pb)) AVM_WRITE("FF reader", "ffmpeg packet error and not eof??\n"); return -1; } @@ -175,8 +172,8 @@ AVFrame pic; int got_pic = 0; memset(&pic, 0, sizeof(pic)); - int r = avcodec_decode_video(s->m_pAvContext, - &pic, &got_pic, pkt.data, pkt.size); + + int r = avcodec_decode_video2(s->m_pAvContext, &pic, &got_pic, &pkt); AVM_WRITE("FF reader", "____ %d %d\n", r, got_pic); } //printf("FFMPEG pktsize: %u %llu %d\n", pkt.size, pkt.pts, pkt.stream_index);fflush(stdout); @@ -201,19 +198,19 @@ / st->codec.frame_rate; } #endif - //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); + //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); //else printf("Bitrate %d\n", st->codec.bit_rate); //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); switch (st->codec->codec_type) { - case CODEC_TYPE_AUDIO: + case AVMEDIA_TYPE_AUDIO: if (!pkt.pts && st->codec->bit_rate) p->timestamp = (int64_t)p->position * 8 * 1000000 / st->codec->bit_rate; s->m_uiPosition += pkt.size; break; - case CODEC_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: default: s->m_uiPosition++; break; @@ -225,7 +222,7 @@ pkt.stream_index, m_Streams[pkt.stream_index]->m_Packets.size(), pkt.pts, pkt.size, p->timestamp, pkt.flags); #endif - if (pkt.flags & PKT_FLAG_KEY) + if (pkt.flags & AV_PKT_FLAG_KEY) p->flags |= KEYFRAME; av_free_packet(&pkt); diff -urN avifile-0.7-0.7.45.orig/lib/aviread/FFReadStream.cpp avifile-0.7-0.7.45/lib/aviread/FFReadStream.cpp --- avifile-0.7-0.7.45.orig/lib/aviread/FFReadStream.cpp 2013-05-18 21:06:57.114712987 +0800 +++ avifile-0.7-0.7.45/lib/aviread/FFReadStream.cpp 2013-05-18 23:56:00.126907884 +0800 @@ -51,15 +51,15 @@ //printf("CODECRA %d %d %d\n", avs->codec.frame_rate, avs->codec->frame_rate_base, m_pAvStream->r_frame_rate_base); if (0 && avs->codec->codec_id == CODEC_ID_MPEG1VIDEO) { - m_pAvContext = avcodec_alloc_context(); + m_pAvContext = avcodec_alloc_context3(NULL); //AVCodec* codec = avcodec_find_encoder(avs->codec->codec_id); if (m_pAvContext) { AVCodec* codec = avcodec_find_decoder(avs->codec->codec_id); - if (codec && avcodec_open(m_pAvContext, codec) == 0) + if (codec && avcodec_open2(m_pAvContext, codec, NULL) == 0) { m_pAvContext->flags |= CODEC_FLAG_TRUNCATED; - m_pAvContext->hurry_up = 5; + m_pAvContext->skip_frame = AVDISCARD_NONKEY; //printf("Opened hurryup decoder %p %p\n", codec, m_pAvContext->codec->decode); } else @@ -146,7 +146,7 @@ switch (avs->codec->codec_type) { - case CODEC_TYPE_AUDIO: + case AVMEDIA_TYPE_AUDIO: m_StreamInfo.m_p->setAudio(avs->codec->channels, avs->codec->sample_rate, avs->codec->frame_bits); @@ -155,7 +155,7 @@ AVM_WRITE("FF stream", "Audio Format: %.4s (0x%x)\n", (const char*)&avs->codec->codec_tag, avs->codec->codec_tag); break; - case CODEC_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: m_StreamInfo.m_p->setVideo(avs->codec->width, avs->codec->height, 0, avs->codec->sample_aspect_ratio.num / (float) avs->codec->sample_aspect_ratio.den); @@ -189,8 +189,8 @@ { switch (m_pHandler->m_pContext->streams[m_uiSId]->codec->codec_type) { - case CODEC_TYPE_AUDIO: return IStream::Audio; - case CODEC_TYPE_VIDEO: return IStream::Video; + case AVMEDIA_TYPE_AUDIO: return IStream::Audio; + case AVMEDIA_TYPE_VIDEO: return IStream::Video; default: return IStream::Other; } } @@ -200,7 +200,7 @@ AVStream* avs = m_pHandler->m_pContext->streams[m_uiSId]; switch (avs->codec->codec_type) { - case CODEC_TYPE_AUDIO: + case AVMEDIA_TYPE_AUDIO: if (pFormat && lSize >= sizeof(WAVEFORMATEX)) { WAVEFORMATEX* wf = (WAVEFORMATEX*) pFormat; @@ -213,7 +213,7 @@ wf->nSamplesPerSec = avs->codec->sample_rate; wf->nAvgBytesPerSec = avs->codec->bit_rate / 8; wf->nBlockAlign = avs->codec->block_align; - wf->wBitsPerSample = avs->codec->bits_per_sample; + wf->wBitsPerSample = avs->codec->bits_per_coded_sample; if (lSize >= (sizeof(WAVEFORMATEX) + avs->codec->extradata_size) && avs->codec->extradata) { @@ -226,7 +226,7 @@ //printf("EEEEEEEEEEE %d\n", avs->codec->extradata_size); return sizeof(WAVEFORMATEX) + ((avs->codec->extradata) ? avs->codec->extradata_size : 0); - case CODEC_TYPE_VIDEO: + case AVMEDIA_TYPE_VIDEO: if (pFormat && lSize >= sizeof(BITMAPINFOHEADER)) { BITMAPINFOHEADER* bh = (BITMAPINFOHEADER*) pFormat; @@ -237,7 +237,7 @@ bh->biHeight = avs->codec->height; bh->biPlanes = 1; bh->biCompression = avs->codec->codec_tag; - bh->biBitCount = avs->codec->bits_per_sample; + bh->biBitCount = avs->codec->bits_per_coded_sample; // hack which might be eventually usefull memcpy(&bh->biXPelsPerMeter, &m_pHandler->m_pContext, sizeof(void*)); if (bh->biCompression == 0) @@ -310,7 +310,7 @@ { if (time < 1.) { - if (m_pAvStream->codec->codec_type == CODEC_TYPE_AUDIO) + if (m_pAvStream->codec->codec_type == AVMEDIA_TYPE_AUDIO) // check if more streams are available // and seek only with the video return 0; diff -urN avifile-0.7-0.7.45.orig/lib/codeckeeper.cpp avifile-0.7-0.7.45/lib/codeckeeper.cpp --- avifile-0.7-0.7.45.orig/lib/codeckeeper.cpp 2013-05-18 21:06:57.113712999 +0800 +++ avifile-0.7-0.7.45/lib/codeckeeper.cpp 2013-05-18 23:58:53.802736638 +0800 @@ -1,3 +1,4 @@ +#define __STDC_CONSTANT_MACROS #include "avm_cpuinfo.h" #include "avm_except.h" // catch only #include "avm_creators.h" @@ -295,7 +296,6 @@ audio_codecs.clear(); // FFMPEG initialization - avcodec_init(); avcodec_register_all(); uncompressed_FillPlugins(video_codecs); diff -urN avifile-0.7-0.7.45.orig/lib/Makefile.am avifile-0.7-0.7.45/lib/Makefile.am --- avifile-0.7-0.7.45.orig/lib/Makefile.am 2013-05-18 21:06:57.117712949 +0800 +++ avifile-0.7-0.7.45/lib/Makefile.am 2013-05-19 01:44:27.568553669 +0800 @@ -28,7 +28,7 @@ lib_LTLIBRARIES = libaviplay.la libaviplay_la_SOURCES = $(AVISOURCES) -libaviplay_la_LIBADD = $(ADD_LIBS) $(PTHREAD_LIBS) +libaviplay_la_LIBADD = $(ADD_LIBS) $(PTHREAD_LIBS) -lavcodec -lavformat libaviplay_la_LDFLAGS = -release $(AVIFILE_MAJOR_VERSION).$(AVIFILE_MINOR_VERSION) -version-info 0:$(AVIFILE_MICRO_VERSION):0 # speedup compilation of codekeeper.cpp - it's not necessary to have # this code fast anyway - runs only few times diff -urN avifile-0.7-0.7.45.orig/plugins/libffmpeg/FFAudioDecoder.cpp avifile-0.7-0.7.45/plugins/libffmpeg/FFAudioDecoder.cpp --- avifile-0.7-0.7.45.orig/plugins/libffmpeg/FFAudioDecoder.cpp 2013-05-18 21:06:57.063713624 +0800 +++ avifile-0.7-0.7.45/plugins/libffmpeg/FFAudioDecoder.cpp 2013-05-19 00:07:21.140394044 +0800 @@ -25,7 +25,7 @@ { if (!m_pAvContext) { - m_pAvContext = avcodec_alloc_context(); + m_pAvContext = avcodec_alloc_context3(NULL); m_pAvContext->channels = m_pFormat->nChannels; if (m_pAvContext->channels > 2) m_pAvContext->channels = 2; @@ -37,11 +37,11 @@ if (m_pFormat->cbSize > 0) { - m_pAvContext->extradata = (char*)(m_pFormat + 1); + m_pAvContext->extradata = (uint8_t*)(m_pFormat + 1); m_pAvContext->extradata_size = m_pFormat->cbSize; } - if (avcodec_open(m_pAvContext, m_pAvCodec) < 0) + if (avcodec_open2(m_pAvContext, m_pAvCodec, NULL) < 0) { AVM_WRITE("FFAudioDecoder", "WARNING: can't open avcodec\n"); free(m_pAvContext); @@ -49,9 +49,14 @@ return -1; } } - int framesz = 0; - int hr = avcodec_decode_audio(m_pAvContext, (int16_t*)out_data, &framesz, - (uint8_t*)in_data, in_size); + + AVPacket avpkt; + av_init_packet(&avpkt); + avpkt.data = (uint8_t*)in_data; + avpkt.size = (int)in_size; + int framesz = AVCODEC_MAX_AUDIO_FRAME_SIZE; + int hr = avcodec_decode_audio3(m_pAvContext, (int16_t*)out_data, &framesz, &avpkt); + //printf("CONVERT i:%d o:%d f:%d h:%d\n", in_size, out_size, framesz, hr); if (size_read) *size_read = (hr < 0) ? in_size : hr; diff -urN avifile-0.7-0.7.45.orig/plugins/libffmpeg/FFVideoDecoder.cpp avifile-0.7-0.7.45/plugins/libffmpeg/FFVideoDecoder.cpp --- avifile-0.7-0.7.45.orig/plugins/libffmpeg/FFVideoDecoder.cpp 2013-05-18 21:06:57.062713637 +0800 +++ avifile-0.7-0.7.45/plugins/libffmpeg/FFVideoDecoder.cpp 2013-05-19 00:50:32.188001492 +0800 @@ -101,36 +101,30 @@ pic->pts = pImage->m_lTimestamp; pic->type = FF_BUFFER_TYPE_USER; pImage->m_iType = pic->pict_type; - //pic->age = pic->coded_picture_number - pImage->m_iAge; - //pImage->m_iAge = (pic->pict_type == FF_B_TYPE) ? + //pImage->m_iAge = (pic->pict_type == AV_PICTURE_TYPE_B) ? //pImage->m_iAge = (pic->reference) ? // -256*256*256*64 : pic->coded_picture_number; d->m_iAgeIP[0]++; - pic->age = d->m_iAgeIP[0] - pImage->m_iAge; - pImage->m_iAge = (pic->pict_type == FF_B_TYPE) ? + pImage->m_iAge = (pic->pict_type == AV_PICTURE_TYPE_B) ? 256*256*256*64 : d->m_iAgeIP[0]; - if (pic->age < 1) - pic->age = 256*256*256*64; #if 0 // mplayer code if (pic->reference) { - pic->age = d->m_iAgeIP[0]; d->m_iAgeIP[0] = d->m_iAgeIP[1] + 1; d->m_iAgeIP[1] = 1; d->m_iAgeB++; } else { - pic->age = d->m_iAgeB; d->m_iAgeIP[0]++; d->m_iAgeIP[1]++; d->m_iAgeB = 1; } #endif - //printf("Age %d %d cp:%d %p\n", pic->age, pImage->m_iAge, pic->coded_picture_number, pImage); + //printf("Age %d %d cp:%d %p\n", pImage->m_iAge, pic->coded_picture_number, pImage); //printf("PictType %d %d\n", pic->pict_type, pic->reference); //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); return 0; @@ -172,10 +166,11 @@ //printf("FFMPEG space \n"); m_Dest.Print(); pImage->GetFmt()->Print(); if (!m_pAvContext) { - m_pAvContext = avcodec_alloc_context(); + AVDictionary *dict = NULL; + m_pAvContext = avcodec_alloc_context3(NULL); // for autodetection errors m_pAvContext->codec_tag = m_pFormat->biCompression; - m_pAvContext->bits_per_sample = m_pFormat->biBitCount; + m_pAvContext->bits_per_coded_sample = m_pFormat->biBitCount; m_pAvContext->width = m_Dest.biWidth; m_pAvContext->height = (m_Dest.biHeight < 0) ? -m_Dest.biHeight : m_Dest.biHeight; m_pAvContext->get_buffer = avcodec_default_get_buffer; @@ -197,9 +192,9 @@ ) { m_pAvContext->extradata_size = m_pFormat->biSize - sizeof(BITMAPINFOHEADER); - m_pAvContext->extradata = (char*) m_pFormat + sizeof(BITMAPINFOHEADER); + m_pAvContext->extradata = (uint8_t*) m_pFormat + sizeof(BITMAPINFOHEADER); if (m_pAvContext->extradata_size > 40) - m_pAvContext->flags |= CODEC_FLAG_EXTERN_HUFF; // somewhat useless + av_dict_set(&dict, "extern_huff", "1", 0); } m_uiBuffers = (pImage && pImage->GetAllocator()) ? pImage->GetAllocator()->GetImages() : 0; @@ -297,12 +292,13 @@ m_pAvContext->workaround_bugs |= p->flag; } */ - if (avcodec_open(m_pAvContext, m_pAvCodec) < 0) + if (avcodec_open2(m_pAvContext, m_pAvCodec, &dict) < 0) { AVM_WRITE(m_Info.GetPrivateName(), "WARNING: FFVideoDecoder::DecodeFrame() can't open avcodec\n"); Stop(); return -1; } + av_dict_free(&dict); } // try using draw_horiz_band if DR1 is unsupported @@ -318,8 +314,13 @@ m_pReleased = 0; AVFrame pic; int got_picture = 0; - int hr = avcodec_decode_video(m_pAvContext, &pic, &got_picture, - (unsigned char*) src, size); + + AVPacket avpkt; + av_init_packet(&avpkt); + avpkt.data = (uint8_t*)src; + avpkt.size = (int)size; + + int hr = avcodec_decode_video2(m_pAvContext, &pic, &got_picture, &avpkt); //printf("DECFF got_picture %d %p del:%d hr:%d size:%d\n", got_picture, src, m_pAvContext->delay, hr, size); //printf("PictType %d\n", m_pAvContext->pict_type); //static int ctr=0; printf("WIDTH %dx%d %d r:%d\n", m_pAvContext->width, m_pAvContext->height, ctr++, m_pAvContext->pict_type); @@ -365,7 +366,7 @@ } Debug printf("FF: r=0x%x sz=%d %d b:%d img:%p out:%p\n", hr, size, got_picture, m_bUsed, pImage, pOut); - Debug printf("FF: frame_size %d number %d picnum %d\n", m_pAvContext->frame_size, m_pAvContext->frame_number, m_pAvContext->real_pict_num); + Debug printf("FF: frame_size %d number %d\n", m_pAvContext->frame_size, m_pAvContext->frame_number); if (!got_picture) { Debug printf("FF: NO PICTURE released=%p\n", m_pReleased); @@ -388,8 +389,8 @@ switch (m_pAvContext->pix_fmt) { case PIX_FMT_BGR24: imfmt = IMG_FMT_BGR24; break; - case PIX_FMT_RGBA32: imfmt = IMG_FMT_BGR32; break; - case PIX_FMT_YUV422: imfmt = IMG_FMT_YUY2; break; + case PIX_FMT_RGB32: imfmt = IMG_FMT_BGR32; break; + case PIX_FMT_YUYV422: imfmt = IMG_FMT_YUY2; break; case PIX_FMT_YUV410P: imfmt = IMG_FMT_I410; break; case PIX_FMT_YUV411P: imfmt = IMG_FMT_I411; break; case PIX_FMT_YUV420P: imfmt = IMG_FMT_I420; break; diff -urN avifile-0.7-0.7.45.orig/plugins/libffmpeg/FFVideoEncoder.cpp avifile-0.7-0.7.45/plugins/libffmpeg/FFVideoEncoder.cpp --- avifile-0.7-0.7.45.orig/plugins/libffmpeg/FFVideoEncoder.cpp 2013-05-18 21:06:57.062713637 +0800 +++ avifile-0.7-0.7.45/plugins/libffmpeg/FFVideoEncoder.cpp 2013-05-18 22:50:47.031828305 +0800 @@ -122,7 +122,7 @@ if (!m_pAvContext) { - m_pAvContext = avcodec_alloc_context(); + m_pAvContext = avcodec_alloc_context3(NULL); m_pAvContext->width = m_bh.biWidth; m_pAvContext->height = m_obh.biHeight; //m_pAvContext->pix_fmt = PIX_FMT_YUV420P; @@ -138,7 +138,7 @@ printf("CODEC opening %dx%d\n", m_bh.biWidth, m_obh.biHeight); - if (avcodec_open(m_pAvContext, m_pAvCodec) < 0) + if (avcodec_open2(m_pAvContext, m_pAvCodec, NULL) < 0) { free(m_pAvContext); m_pAvContext = 0; diff -urN avifile-0.7-0.7.45.orig/plugins/libffmpeg/libffmpeg.cpp avifile-0.7-0.7.45/plugins/libffmpeg/libffmpeg.cpp --- avifile-0.7-0.7.45.orig/plugins/libffmpeg/libffmpeg.cpp 2013-05-18 21:06:57.063713624 +0800 +++ avifile-0.7-0.7.45/plugins/libffmpeg/libffmpeg.cpp 2013-05-19 00:00:26.562576980 +0800 @@ -137,7 +137,6 @@ static int is_init = 0; if (!is_init) { - avcodec_init(); avcodec_register_all(); is_init++; } diff -urN avifile-0.7-0.7.45.orig/plugins/libffmpeg/Makefile.am avifile-0.7-0.7.45/plugins/libffmpeg/Makefile.am --- avifile-0.7-0.7.45.orig/plugins/libffmpeg/Makefile.am 2013-05-18 21:06:57.063713624 +0800 +++ avifile-0.7-0.7.45/plugins/libffmpeg/Makefile.am 2013-05-19 01:44:45.370331116 +0800 @@ -11,7 +11,7 @@ FFVideoDecoder.cpp \ FFVideoEncoder.cpp -ffmpeg_la_LIBADD = $(LINK_AVIPLAY) +ffmpeg_la_LIBADD = $(LINK_AVIPLAY) -lavcodec -lavformat #ffmpeg_la_LIBADD = ../../ffmpeg/libavcodec/libavcodec.a ffmpeg_la_LDFLAGS = -module -avoid-version
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.