Mercurial > hg > easaier-soundaccess
changeset 150:c946c19e6329
(none)
author | ivand_qmul |
---|---|
date | Wed, 14 Nov 2007 15:11:46 +0000 |
parents | 735e67e91508 |
children | f2d2c1084e7c |
files | data/fileio/VideoFileReader.cpp data/model/SDLWidget.cpp sv/videoio/SDL_ffmpeg.cpp sv/videoio/SDL_ffmpeg.h |
diffstat | 4 files changed, 68 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/data/fileio/VideoFileReader.cpp Wed Nov 14 10:41:46 2007 +0000 +++ b/data/fileio/VideoFileReader.cpp Wed Nov 14 15:11:46 2007 +0000 @@ -32,6 +32,7 @@ #ifdef WIN32 #include <Windows.h> #endif +extern float zoomFivan; long long countFreq; int Videow=320; int Videoh=240; @@ -198,10 +199,10 @@ SDL_Init(SDL_INIT_VIDEO); - Videow=w; - Videoh=h; + Videow=w=320*zoomFivan; + Videoh=h=240*zoomFivan; // Open the Video device - screen = SDL_SetVideoMode(w, h, 0, SDL_DOUBLEBUF|SDL_HWSURFACE); + screen = SDL_SetVideoMode(w, h, 0, SDL_DOUBLEBUF|SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL); //SDL_WM_SetCaption("EASAIER Video Player", "EASAIER Video Player"); if(!screen) { printf("Couldn't open video: %s\n", SDL_GetError()); @@ -242,7 +243,12 @@ film->vs[film->videoStream]->lastTimeStamp=0; while( film->videoThreadActive ) { - + if (!(w==(int)(320*zoomFivan))){ + w=320*zoomFivan; + h=240*zoomFivan; + // Open the Video device + screen = SDL_SetVideoMode(w, h, 0, SDL_DOUBLEBUF|SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL); + } if (MWins->isAudioPlaying()) { if ((SDL_ffmpegGetState(film))||((long)(abs((long)(film->audioTime - (int64_t)(MWins->Get_CurAudioTime()))))>=1000))
--- a/data/model/SDLWidget.cpp Wed Nov 14 10:41:46 2007 +0000 +++ b/data/model/SDLWidget.cpp Wed Nov 14 15:11:46 2007 +0000 @@ -2,13 +2,14 @@ #include <cstdlib> #include <ctime> #include "SDLWidget.h" -extern int Videow; -extern int Videoh; +float zoomFivan=1; + + SDLWidget::SDLWidget() :windowInitialized(false), screen(0),m_width(0), m_height(0) - { - setAttribute(Qt::WA_PaintOnScreen); + { + setAttribute(Qt::WA_PaintOnScreen); setAttribute(Qt::WA_NoSystemBackground); zoomFactor = 1; connect(this,SIGNAL(initSizeChanged()),this,SLOT(updateMinSize())); @@ -20,38 +21,38 @@ SDL_Quit(); } -void SDLWidget::setZoomFactor( float f ) -{ - int w, h; - - if( f == zoomFactor ) - return; - - zoomFactor = f; - emit(zoomfactorChanged(f)); - - w = m_width*zoomFactor; - h = m_height*zoomFactor; - setMinimumSize( w, h ); - emit(sizeChanged(w,h)); - emit(zoomfactorChanged(f)); - - /*QWidget *p = dynamic_cast<QWidget*>( parent() ); - if( p ){ - resize( p->width(), p->height() ); - }*/ +void SDLWidget::setZoomFactor( float f ) +{ + int w, h; + + if( f == zoomFactor ) + return; + + zoomFactor = f; + emit(zoomfactorChanged(f)); + + w = m_width*zoomFactor; + h = m_height*zoomFactor; + setMinimumSize( w, h ); + emit(sizeChanged(w,h)); + emit(zoomfactorChanged(f)); + + /*QWidget *p = dynamic_cast<QWidget*>( parent() ); + if( p ){ + resize( p->width(), p->height() ); + }*/ } -void SDLWidget::wheelEvent( QWheelEvent *event ) -{ - float f; - - f = zoomFactor + 0.001*event->delta(); - if( f < 32.0/m_width ){ - f = 32.0/m_height; - } - - setZoomFactor( f ); +void SDLWidget::wheelEvent( QWheelEvent *event ) +{ + float f; + + f = zoomFactor + 0.001*event->delta(); + if( f < 32.0/m_width ){ + f = 32.0/m_height; + } +zoomFivan=f; + setZoomFactor( f ); } void SDLWidget::setInitSize(int w, int h){ @@ -70,19 +71,19 @@ void SDLWidget::showEvent(QShowEvent *e) - { + { (void)e; if(!windowInitialized) { // it's here the link between SDL and QT - char windowid[64]; + char windowid[64]; #ifdef Q_WS_WIN - sprintf(windowid, "SDL_WINDOWID=0x%lx", reinterpret_cast<qlonglong>(winId())); -#elif defined Q_WS_X11 - sprintf(windowid, "SDL_WINDOWID=0x%lx", winId()); -#else - qFatal("uncorrect window ID"); + sprintf(windowid, "SDL_WINDOWID=0x%lx", reinterpret_cast<qlonglong>(winId())); +#elif defined Q_WS_X11 + sprintf(windowid, "SDL_WINDOWID=0x%lx", winId()); +#else + qFatal("uncorrect window ID"); #endif SDL_putenv(windowid);
--- a/sv/videoio/SDL_ffmpeg.cpp Wed Nov 14 10:41:46 2007 +0000 +++ b/sv/videoio/SDL_ffmpeg.cpp Wed Nov 14 15:11:46 2007 +0000 @@ -46,7 +46,7 @@ //const int SDL_FFMPEG_MAX_BUFFERED_FRAMES = 25; //const int SDL_FFMPEG_MAX_BUFFERED_SAMPLES = 512 * 512; - +extern float zoomFivan; int FFMPEG_init_was_called = 0; FILE *pFile, *tFile; int64_t Time,Time1; @@ -609,10 +609,16 @@ // if new timestamp is from future, we proceed // if(buf->timestamp >= SDL_ffmpegGetPosition(file)) // { - if (img_convert_ctx == NULL) { + int w=320*zoomFivan; + int h=240*zoomFivan; + if ((w>file->vs[file->videoStream]->width)||(h>file->vs[file->videoStream]->height)){ + w=file->vs[file->videoStream]->width; + h=file->vs[file->videoStream]->height; + } + if (img_convert_ctx == NULL) { img_convert_ctx = sws_getContext(file->vs[file->videoStream]->width, file->vs[file->videoStream]->height, ((AVCodecContext*)file->vs[file->videoStream]->_ffmpeg)->pix_fmt, - file->vs[file->videoStream]->width, file->vs[file->videoStream]->height, + w,h, file->vs[file->videoStream]->pixFmt, sws_flags, NULL, NULL, NULL); if (img_convert_ctx == NULL) { @@ -621,9 +627,11 @@ } } + ((AVPicture*)inFrameRGB)->linesize[0]=(int)w*3; sws_scale(img_convert_ctx, ((AVPicture*)inFrame)->data, ((AVPicture*)inFrame)->linesize, 0, file->vs[file->videoStream]->height, ((AVPicture*)inFrameRGB)->data, ((AVPicture*)inFrameRGB)->linesize); - + sws_freeContext(img_convert_ctx); + img_convert_ctx=NULL; // we convert whatever type of data we got to RGB24 /* img_convert((AVPicture*)inFrameRGB, file->vs[file->videoStream]->pixFmt, @@ -634,13 +642,13 @@ */ // allocate image room buf->img = SDL_CreateRGBSurface(SDL_SWSURFACE, - file->vs[file->videoStream]->width, - file->vs[file->videoStream]->height, + w, + h, 24, 0x0000FF, 0x00FF00, 0xFF0000, 0); // copy image data to image room memcpy(buf->img->pixels, inFrameRGB->data[0], - file->vs[file->videoStream]->width * file->vs[file->videoStream]->height * 3); + w*h* 3); file->timebase=buf->timestamp-file->vs[file->videoStream]->lastTimeStamp; // we write the lastTimestamp we got file->vs[file->videoStream]->lastTimeStamp = buf->timestamp;
--- a/sv/videoio/SDL_ffmpeg.h Wed Nov 14 10:41:46 2007 +0000 +++ b/sv/videoio/SDL_ffmpeg.h Wed Nov 14 15:11:46 2007 +0000 @@ -49,7 +49,7 @@ } #endif #define SWS_BICUBIC 4 -const int SDL_FFMPEG_MAX_BUFFERED_FRAMES = 60; +const int SDL_FFMPEG_MAX_BUFFERED_FRAMES = 25; const int SDL_FFMPEG_MAX_BUFFERED_SAMPLES = 512*512; static int sws_flags = SWS_BICUBIC; // we pack our decoded images into bufferImage structs