Hi,
> > [...]
> > Really? My libavcodec.a (SVN 9816) compiled today still contains
> > img_convert. It is marked deprecated, but still exists. Maybe you
> > have configured your ffmpeg in some non-standard way?
>
> I have not build ffmpeg by my own, i used the ffmpeg RPM package from
> packman (ffmpeg-0.4.9-8.pm.svn20070724). I will check the sources of this
> package to see if this is wrongly configured/build or the img_convert is
> really removed. nm /usr/lib/libavcodec.a shows that the img_convert is
> missing, but other functions marked as deprecated (img_copy,img_crop,...)
> are available.
Result of investigation on the latest ffmpeg sources:
If ffmpeg is be build with "--enable-swscaler", then a new
library "libswscale" is build and the function "img_convert" is removed
from "libavcodec".
If not, "img_convert" is still available.
I have attached a patch for dvbcut r63 that use the software scaler, if the
library "libswscale" is available. If the library is not available or the
internal ffmpeg is used, "img_convert" is kept.
Regards,
Michael
--- dvbcut/SConstruct 2007-07-29 00:03:50.000000000 +0200
+++ dvbcut/SConstruct 2007-08-01 23:09:40.000000000 +0200
@@ -88,10 +88,6 @@
print "Checking for C library a52... yes"
elif (conf.CheckLibWithHeader('a52', ['stdint.h','a52dec/a52.h'], 'C')):
conf.env.Append(CPPDEFINES="HAVE_LIB_A52")
-
-### FINISH
-
-env=conf.Finish()
###### BUILD ENVIRONMENT (pt2)
@@ -120,6 +116,19 @@
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()
###### WORK
--- dvbcut/src/avframe.h 2007-07-29 00:03:50.000000000 +0200
+++ dvbcut/src/avframe.h 2007-08-01 23:09:29.000000000 +0200
@@ -23,6 +23,9 @@
extern "C" {
#include <ffmpeg/avcodec.h>
+#ifdef HAVE_LIB_SWSCALE
+#include <ffmpeg/swscale.h>
+#endif
}
class QImage;
@@ -37,6 +40,9 @@
void *tobefreed;
int w,h,dw;
enum PixelFormat pix_fmt;
+#ifdef HAVE_LIB_SWSCALE
+ struct SwsContext *img_convert_ctx;
+#endif
public:
avframe();
--- dvbcut/src/avframe.cpp 2007-07-23 23:37:46.000000000 +0200
+++ dvbcut/src/avframe.cpp 2007-07-31 00:38:29.000000000 +0200
@@ -23,7 +23,11 @@
#include <stdio.h>
#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 @@
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 @@
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 @@
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);
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
DVBCUT-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dvbcut-user