Hi,
building dvbcut with "make FFMPEG=/usr" does not compile
and link any more with the latest snapshot of ffmpeg,
because they have change the API:
- C++ support has been removed -> ffmpeg headers have to be included
within a extern "C" directive
- new software scaler library libswscale introduced -> img_convert has
been
removed from libavcodec -> replace with swscale stuff
The attached patch fix this for SVN revision 59 of dvbcut.
Michael
--- ./SConstruct 2007-07-27 23:11:54.000000000 +0200
+++ ./SConstruct 2007-07-27 23:58:55.000000000 +0200
@@ -112,11 +112,12 @@
else:
localffmpeg=False
ffmpegpath=env["FFMPEG"].rstrip("/")
+ env.Append(CPPDEFINES="__STDC_CONSTANT_MACROS")
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'])
+env.Append(LIBS=['avformat','avcodec','avutil','swscale'])
###### WORK
--- ./src/avframe.cpp 2007-07-27 23:11:54.000000000 +0200
+++ ./src/avframe.cpp 2007-07-27 01:52:52.000000000 +0200
@@ -23,7 +23,7 @@
#include <stdio.h>
#include "avframe.h"
-avframe::avframe() : tobefreed(0),w(0),h(0),dw(0),pix_fmt()
+avframe::avframe() : tobefreed(0),w(0),h(0),dw(0),pix_fmt(),img_convert_ctx(0)
{
f=avcodec_alloc_frame();
}
@@ -54,6 +54,9 @@
h=ctx->height;
pix_fmt=ctx->pix_fmt;
dw=w*ctx->sample_aspect_ratio.num/ctx->sample_aspect_ratio.den;
+ img_convert_ctx=sws_getContext(w, h, pix_fmt,
+ w, h, PIX_FMT_BGR24, SWS_BICUBIC,
+ NULL, NULL, NULL);
}
@@ -63,26 +66,29 @@
free(tobefreed);
if (f)
av_free(f);
+ if (img_convert_ctx)
+ sws_freeContext(img_convert_ctx);
}
QImage avframe::getqimage(bool scaled, int viewscalefactor)
{
- if (w<=0 || h<=0)
+ if (w<=0 || h<=0 || img_convert_ctx==NULL)
return QImage();
- uint8_t *rgbbuffer=(uint8_t*)malloc(avpicture_get_size(PIX_FMT_RGB24, w, h)+64);
+ uint8_t *rgbbuffer=(uint8_t*)malloc(avpicture_get_size(PIX_FMT_BGR24, w, h)+64);
int headerlen=sprintf((char *) rgbbuffer, "P6\n%d %d\n255\n", w, h);
AVFrame *avframergb=avcodec_alloc_frame();
avpicture_fill((AVPicture*)avframergb,
rgbbuffer+headerlen,
- PIX_FMT_RGB24,w,h);
-
- img_convert((AVPicture *)avframergb, PIX_FMT_RGB24, (AVPicture*)f, pix_fmt, w, h);
+ PIX_FMT_BGR24,w,h);
+ sws_scale(img_convert_ctx, f->data, f->linesize, 0, h,
+ avframergb->data, avframergb->linesize);
QImage im;
im.loadFromData(rgbbuffer, headerlen+w*h*3, "PPM");
+ im = im.swapRGB();
if ((scaled && w!=dw)||(viewscalefactor!=1)) {
#ifdef SMOOTHSCALE
--- ./src/avframe.h 2007-07-27 23:11:54.000000000 +0200
+++ ./src/avframe.h 2007-07-26 01:37:56.000000000 +0200
@@ -21,7 +21,10 @@
#ifndef _DVBCUT_AVFRAME_H
#define _DVBCUT_AVFRAME_H
+extern "C" {
#include <ffmpeg/avcodec.h>
+#include <ffmpeg/swscale.h>
+}
class QImage;
@@ -35,6 +38,7 @@
void *tobefreed;
int w,h,dw;
enum PixelFormat pix_fmt;
+ struct SwsContext *img_convert_ctx;
public:
avframe();
--- ./src/lavfmuxer.cpp 2007-07-27 23:11:54.000000000 +0200
+++ ./src/lavfmuxer.cpp 2007-07-26 00:49:21.000000000 +0200
@@ -18,8 +18,10 @@
/* $Id: lavfmuxer.cpp 58 2007-07-23 07:03:07Z too-tired $ */
+extern "C" {
#include <ffmpeg/avformat.h>
#include <ffmpeg/avcodec.h>
+}
#include <string.h>
#include <utility>
#include <list>
@@ -88,7 +90,7 @@
if (sd->getitemlistsize() > 1) {
if (!avcodec_open(s->codec,
(mpg.getstreamtype(astr)==streamtype::ac3audio) ?
- &liba52_decoder : &mp2_decoder)) {
+ avcodec_find_decoder(CODEC_ID_AC3) : avcodec_find_decoder(CODEC_ID_MP2))) {
int16_t samples[6*1536]; // must be enough for 6 AC-3 channels --mr
int frame_size=sizeof(samples);
//fprintf(stderr, "** decode audio size=%d\n", sd->inbytes());
--- ./src/lavfmuxer.h 2007-07-27 23:11:54.000000000 +0200
+++ ./src/lavfmuxer.h 2007-07-26 00:50:28.000000000 +0200
@@ -21,7 +21,10 @@
#ifndef _DVBCUT_LAVFMUXER_H
#define _DVBCUT_LAVFMUXER_H
+extern "C" {
#include <ffmpeg/avformat.h>
+}
+
#include "mpgfile.h"
#include "muxer.h"
--- ./src/main.cpp 2007-07-27 23:11:54.000000000 +0200
+++ ./src/main.cpp 2007-07-26 00:51:05.000000000 +0200
@@ -30,7 +30,9 @@
#endif // HAVE_LIB_AO
#include <qapplication.h>
+extern "C" {
#include <ffmpeg/avformat.h>
+}
#include <qimage.h>
#include <qsettings.h>
#include "dvbcut.h"
--- ./src/mpgfile.h 2007-07-27 23:11:54.000000000 +0200
+++ ./src/mpgfile.h 2007-07-26 00:51:37.000000000 +0200
@@ -21,7 +21,10 @@
#ifndef _DVBCUT_MPGFILE_H
#define _DVBCUT_MPGFILE_H
+extern "C" {
#include <ffmpeg/avcodec.h>
+}
+
#include <string>
#include <vector>
#include <list>
--- ./src/psfile.cpp 2007-07-27 23:11:54.000000000 +0200
+++ ./src/psfile.cpp 2007-07-27 23:25:49.000000000 +0200
@@ -21,7 +21,10 @@
#include "psfile.h"
#include "streamhandle.h"
#include "stream.h"
+
+extern "C" {
#include <ffmpeg/avcodec.h>
+}
psfile::psfile(inbuffer &b, int initial_offset)
: mpgfile(b, initial_offset)
@@ -92,7 +95,7 @@
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;
@@ -102,7 +105,7 @@
streamnumber[sid]=audiostream(audiostreams);
stream *S=&s[audiostream(audiostreams++)];
S->id=sid;
-// S->dec=&ac3_decoder;
+// S->dec=avcodec_find_decoder(CODEC_ID_AC3);
S->type=streamtype::ac3audio;
if (audiostreams>=MAXAUDIOSTREAMS)
break;
@@ -116,8 +119,8 @@
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;
}
--- ./src/tsfile.cpp 2007-07-27 23:11:54.000000000 +0200
+++ ./src/tsfile.cpp 2007-07-27 23:24:16.000000000 +0200
@@ -24,7 +24,9 @@
#include <list>
#include <utility>
+extern "C" {
#include <ffmpeg/avcodec.h>
+}
tsfile::tsfile(inbuffer &b, int initial_offset)
: mpgfile(b, initial_offset)
@@ -80,12 +82,12 @@
stream *S=&s[audiostream(audiostreams++)];
S->id=it->second;
if (it->first==0xbd) {
-// S->dec=&ac3_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_encoder(CODEC_ID_MP2);
S->type=streamtype::mpegaudio;
}
if (audiostreams>=MAXAUDIOSTREAMS)
@@ -100,8 +102,8 @@
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;
}
-------------------------------------------------------------------------
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