Index: dvbcut-svn/src/psfile.cpp =================================================================== --- dvbcut-svn.orig/src/psfile.cpp +++ dvbcut-svn/src/psfile.cpp @@ -90,7 +90,7 @@ psfile::psfile(const std::string &filena streamnumber[sid]=audiostream(audiostreams); stream *S=&s[audiostream(audiostreams++)]; S->id=sid; - S->dec=&mp2_decoder; + S->dec=avcodec_find_decoder(CODEC_ID_MP2); S->type=streamtype::mpegaudio; if (audiostreams>=MAXAUDIOSTREAMS) break; @@ -100,7 +100,7 @@ psfile::psfile(const std::string &filena streamnumber[sid]=audiostream(audiostreams); stream *S=&s[audiostream(audiostreams++)]; S->id=sid; - S->dec=&liba52_decoder; + S->dec=avcodec_find_decoder(CODEC_ID_AC3); S->type=streamtype::ac3audio; if (audiostreams>=MAXAUDIOSTREAMS) break; @@ -114,8 +114,8 @@ psfile::psfile(const std::string &filena S->allocavcc(); S->avcc->codec_type=CODEC_TYPE_VIDEO; S->avcc->codec_id=CODEC_ID_MPEG2VIDEO; - S->dec=&mpeg2video_decoder; - S->enc=&mpeg2video_encoder; + S->dec=avcodec_find_decoder(CODEC_ID_MPEG2VIDEO); + S->enc=avcodec_find_encoder(CODEC_ID_MPEG2VIDEO); S->type=streamtype::mpeg2video; } Index: dvbcut-svn/src/tsfile.cpp =================================================================== --- dvbcut-svn.orig/src/tsfile.cpp +++ dvbcut-svn/src/tsfile.cpp @@ -78,12 +78,12 @@ tsfile::tsfile(const std::string &filena stream *S=&s[audiostream(audiostreams++)]; S->id=it->second; if (it->first==0xbd) { - S->dec=&liba52_decoder; - S->enc=&ac3_encoder; + S->dec=avcodec_find_decoder(CODEC_ID_AC3); + S->enc=avcodec_find_encoder(CODEC_ID_AC3); S->type=streamtype::ac3audio; } else { - S->dec=&mp2_decoder; - S->enc=&mp2_encoder; + S->dec=avcodec_find_decoder(CODEC_ID_MP2); + S->enc=avcodec_find_decoder(CODEC_ID_MP2); S->type=streamtype::mpegaudio; } if (audiostreams>=MAXAUDIOSTREAMS) @@ -98,8 +98,8 @@ tsfile::tsfile(const std::string &filena S->allocavcc(); S->avcc->codec_type=CODEC_TYPE_VIDEO; S->avcc->codec_id=CODEC_ID_MPEG2VIDEO; - S->dec=&mpeg2video_decoder; - S->enc=&mpeg2video_encoder; + S->dec=avcodec_find_decoder(CODEC_ID_MPEG2VIDEO); + S->enc=avcodec_find_encoder(CODEC_ID_MPEG2VIDEO); S->type=streamtype::mpeg2video; } Index: dvbcut-svn/src/avframe.cpp =================================================================== --- dvbcut-svn.orig/src/avframe.cpp +++ dvbcut-svn/src/avframe.cpp @@ -23,7 +23,11 @@ #include #include "avframe.h" +#ifdef HAVE_LIB_SWSCALE +avframe::avframe() : tobefreed(0),w(0),h(0),dw(0),pix_fmt(),img_convert_ctx(0) +#else avframe::avframe() : tobefreed(0),w(0),h(0),dw(0),pix_fmt() +#endif { f=avcodec_alloc_frame(); } @@ -54,7 +58,11 @@ avframe::avframe(AVFrame *src, AVCodecCo h=ctx->height; pix_fmt=ctx->pix_fmt; dw=w*ctx->sample_aspect_ratio.num/ctx->sample_aspect_ratio.den; - +#ifdef HAVE_LIB_SWSCALE + img_convert_ctx=sws_getContext(w, h, pix_fmt, + w, h, PIX_FMT_BGR24, SWS_BICUBIC, + NULL, NULL, NULL); +#endif } avframe::~avframe() @@ -63,11 +71,19 @@ avframe::~avframe() free(tobefreed); if (f) av_free(f); +#ifdef HAVE_LIB_SWSCALE + if (img_convert_ctx) + sws_freeContext(img_convert_ctx); +#endif } QImage avframe::getqimage(bool scaled, int viewscalefactor) { +#ifdef HAVE_LIB_SWSCALE + if (w<=0 || h<=0 || img_convert_ctx==NULL) +#else if (w<=0 || h<=0) +#endif return QImage(); uint8_t *rgbbuffer=(uint8_t*)malloc(avpicture_get_size(PIX_FMT_RGB24, w, h)+64); @@ -79,11 +95,20 @@ QImage avframe::getqimage(bool scaled, i rgbbuffer+headerlen, PIX_FMT_RGB24,w,h); +#ifdef HAVE_LIB_SWSCALE + sws_scale(img_convert_ctx, f->data, f->linesize, 0, h, + avframergb->data, avframergb->linesize); +#else img_convert((AVPicture *)avframergb, PIX_FMT_RGB24, (AVPicture*)f, pix_fmt, w, h); +#endif QImage im; im.loadFromData(rgbbuffer, headerlen+w*h*3, "PPM"); +#ifdef HAVE_LIB_SWSCALE + im = im.swapRGB(); +#endif + if ((scaled && w!=dw)||(viewscalefactor!=1)) { #ifdef SMOOTHSCALE im = im.smoothScale((scaled?dw:w)/viewscalefactor, h/viewscalefactor); Index: dvbcut-svn/src/avframe.h =================================================================== --- dvbcut-svn.orig/src/avframe.h +++ dvbcut-svn/src/avframe.h @@ -23,6 +23,9 @@ extern "C" { #include +#ifdef HAVE_LIB_SWSCALE +#include +#endif } class QImage; @@ -37,6 +40,9 @@ protected: void *tobefreed; int w,h,dw; enum PixelFormat pix_fmt; +#ifdef HAVE_LIB_SWSCALE + struct SwsContext *img_convert_ctx; +#endif public: avframe(); Index: dvbcut-svn/SConstruct =================================================================== --- dvbcut-svn.orig/SConstruct +++ dvbcut-svn/SConstruct @@ -88,10 +88,6 @@ if (not env.GetOption('clean')): print "Checking for libao... found" else: print "Checking for libao... not found" - -### FINISH - -env=conf.Finish() ###### BUILD ENVIRONMENT (pt2) @@ -117,8 +113,23 @@ if (ffmpegpath!='/usr'): env.Append(CPPPATH=os.path.join(str(ffmpegpath),'include')) env.Append(LIBPATH=os.path.join(str(ffmpegpath),'lib')) env.Append(LIBS=['avformat','avcodec','avutil']) +if (localffmpeg==False): + env.Append(CPPDEFINES=["__STDC_CONSTANT_MACROS", "__STDC_LIMIT_MACROS"]) + + +### LIBSWSCALE +if (not env.GetOption('clean') and not localffmpeg): + if (conf.TryAction('pkg-config --exists libswscale')[0]): + conf.env.Append(CPPDEFINES="HAVE_LIB_SWSCALE") + conf.env.ParseConfig('pkg-config --cflags --libs libswscale') + print "Checking for C library swscale... yes" + elif (conf.CheckLibWithHeader('swscale', 'ffmpeg/swscale.h', 'C')): + conf.env.Append(CPPDEFINES="HAVE_LIB_SWSCALE") + +### FINISH + +env=conf.Finish() -env.Append(CPPDEFINES="__STDC_CONSTANT_MACROS") ###### WORK env.bin_targets=[]