From 1cd8886cb30b0b6f020ffcac418a6950dbe5f3b7 Mon Sep 17 00:00:00 2001 From: LucasWang Date: Fri, 18 Jan 2013 19:12:55 +0800 Subject: [PATCH] ipp --- src/ImageConverterIPP.cpp | 60 +++++++++++ src/QtAV/ImageConverter.h | 4 +- src/QtAV/ImageConverterFF.h | 2 +- src/QtAV/ImageConverterIPP.h | 37 +++++++ src/VideoDecoder.cpp | 3 +- src/libQtAV.pri | 5 +- src/libQtAV.pro | 189 +++++++++++++++++------------------ 7 files changed, 198 insertions(+), 102 deletions(-) create mode 100644 src/ImageConverterIPP.cpp create mode 100644 src/QtAV/ImageConverterIPP.h diff --git a/src/ImageConverterIPP.cpp b/src/ImageConverterIPP.cpp new file mode 100644 index 00000000..b697884e --- /dev/null +++ b/src/ImageConverterIPP.cpp @@ -0,0 +1,60 @@ +/****************************************************************************** + ImageConverterIPP: Image resizing & color model convertion using Intel IPP + Copyright (C) 2012-2013 Wang Bin + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +******************************************************************************/ + +#include +#include +#include + +#define LINK_IPP 1 +#if LINK_IPP +#include +#else + +#endif + +namespace QtAV { + +class ImageConverterIPPPrivate : public ImageConverterPrivate +{ +public: + +}; + +ImageConverterIPP::ImageConverterIPP() + :ImageConverter(*new ImageConverterIPPPrivate()) +{ +} + +bool ImageConverterIPP::convert(const quint8 *const srcSlice[], const int srcStride[]) +{ + DPTR_D(ImageConverterIPP); + ippiYUV420ToRGB_8u_P3C3(const_cast(srcSlice), (Ipp8u*)(d.data_out.data()), (IppiSize){d.w_in, d.h_in}); + return true; +} + +bool ImageConverterIPP::prepareData() +{ + DPTR_D(ImageConverterIPP); + int bytes = avpicture_get_size((PixelFormat)d.fmt_out, d.w_out, d.h_out); + if(d.data_out.size() < bytes) { + d.data_out.resize(bytes); + } + return true; +} + +} //namespace QtAV diff --git a/src/QtAV/ImageConverter.h b/src/QtAV/ImageConverter.h index 7ec2a62c..3ca56ccf 100644 --- a/src/QtAV/ImageConverter.h +++ b/src/QtAV/ImageConverter.h @@ -25,7 +25,7 @@ namespace QtAV { class ImageConverterPrivate; -class ImageConverter +class Q_EXPORT ImageConverter { DPTR_DECLARE_PRIVATE(ImageConverter) public: @@ -40,6 +40,8 @@ public: void setInterlaced(bool interlaced); bool isInterlaced() const; virtual bool convert(const quint8 *const srcSlice[], const int srcStride[]) = 0; + //virtual bool convertColor(const quint8 *const srcSlice[], const int srcStride[]) = 0; + //virtual bool resize(const quint8 *const srcSlice[], const int srcStride[]) = 0; protected: ImageConverter(ImageConverterPrivate& d); //Allocate memory for out data. Called in setOutFormat() diff --git a/src/QtAV/ImageConverterFF.h b/src/QtAV/ImageConverterFF.h index edfd81d0..6391a6ae 100644 --- a/src/QtAV/ImageConverterFF.h +++ b/src/QtAV/ImageConverterFF.h @@ -24,7 +24,7 @@ namespace QtAV { class ImageConverterFFPrivate; -class ImageConverterFF : public ImageConverter +class Q_EXPORT ImageConverterFF : public ImageConverter { DPTR_DECLARE_PRIVATE(ImageConverterFF) public: diff --git a/src/QtAV/ImageConverterIPP.h b/src/QtAV/ImageConverterIPP.h new file mode 100644 index 00000000..063a050d --- /dev/null +++ b/src/QtAV/ImageConverterIPP.h @@ -0,0 +1,37 @@ +/****************************************************************************** + ImageConverterIPP: Image resizing & color model convertion using Intel IPP + Copyright (C) 2012-2013 Wang Bin + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +******************************************************************************/ + +#ifndef QTAV_IMAGECONVERTERIPP_H +#define QTAV_IMAGECONVERTERIPP_H + +#include + +namespace QtAV { + +class ImageConverterIPPPrivate; +class Q_EXPORT ImageConverterIPP : public ImageConverter +{ + DPTR_DECLARE_PRIVATE(ImageConverterIPP) +public: + ImageConverterIPP(); + virtual bool convert(const quint8 *const srcSlice[], const int srcStride[]); +protected: + virtual bool prepareData(); //Allocate memory for out data +}; +} //namespace QtAV +#endif // QTAV_IMAGECONVERTERIPP_H diff --git a/src/VideoDecoder.cpp b/src/VideoDecoder.cpp index 2b509bbb..199270dd 100644 --- a/src/VideoDecoder.cpp +++ b/src/VideoDecoder.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -36,7 +37,7 @@ class VideoDecoderPrivate : public AVDecoderPrivate public: VideoDecoderPrivate():width(0),height(0) { - conv = new ImageConverterFF(); //TODO: set in AVPlayer + conv = new ImageConverterIPP(); //TODO: set in AVPlayer conv->setOutFormat(PIX_FMT_RGB32); } ~VideoDecoderPrivate() { diff --git a/src/libQtAV.pri b/src/libQtAV.pri index a17a3fb1..53159b8d 100644 --- a/src/libQtAV.pri +++ b/src/libQtAV.pri @@ -160,7 +160,10 @@ openal { win32:LIBS *= -lOpenAL32 else: LIBS *= -lopenal } - +ipp-link { + INCLUDEPATH += $$(IPPROOT)/include + LIBS *= -L$$(IPPROOT)/lib/intel64 -lippcc_t -lippcore_t -liomp5#omp for static link. _t is multi-thread static link +} unset(LIB_VERSION) unset(PROJECT_SRCPATH) unset(PROJECT_LIBDIR) diff --git a/src/libQtAV.pro b/src/libQtAV.pro index a6933cff..3d741e1b 100644 --- a/src/libQtAV.pro +++ b/src/libQtAV.pro @@ -1,98 +1,91 @@ -TEMPLATE = lib - -QT += core gui opengl -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG *= qtav-buildlib -#var with '_' can not pass to pri? -STATICLINK = 0 -PROJECTROOT = $$PWD/.. -!include(libQtAV.pri): error("could not find libQtAV.pri") -preparePaths($$OUT_PWD/../out) - -win32:RC_FILE = $${PROJECTROOT}/res/QtAV.rc -OTHER_FILES += $$RC_FILE -#src -unix: SOURCES += -else:win32: SOURCES += - -portaudio { -SOURCES += AOPortAudio.cpp -HEADERS += QtAV/AOPortAudio.h \ - QtAV/private/AOPortAudio_p.h -} -openal { -SOURCES += AOOpenAL.cpp -HEADERS += QtAV/AOOpenAL.h \ - QtAV/private/AOOpenAL_p.h -} - -SOURCES += \ - QtAV_Compat.cpp \ - AudioThread.cpp \ - AVThread.cpp \ - AudioDecoder.cpp \ - AudioOutput.cpp \ - AVDecoder.cpp \ - AVDemuxer.cpp \ - AVDemuxThread.cpp \ - EventFilter.cpp \ - GraphicsItemRenderer.cpp \ - ImageConverter.cpp \ - ImageConverterFF.cpp \ - ImageRenderer.cpp \ - Packet.cpp \ - AVPlayer.cpp \ - VideoCapture.cpp \ - VideoRenderer.cpp \ - WidgetRenderer.cpp \ - AVOutput.cpp \ - AVClock.cpp \ - VideoDecoder.cpp \ - VideoThread.cpp - -HEADERS += \ - QtAV/prepost.h \ - QtAV/dptr.h \ - QtAV/QtAV_Global.h \ - QtAV/QtAV_Compat.h \ - QtAV/AVThread.h \ - QtAV/AudioThread.h \ - QtAV/EventFilter.h \ - QtAV/private/AudioOutput_p.h \ - QtAV/private/AVThread_p.h \ - QtAV/private/AVDecoder_p.h \ - QtAV/private/AVOutput_p.h \ - QtAV/private/GraphicsItemRenderer_p.h \ - QtAV/private/ImageConverter_p.h \ - QtAV/private/ImageRenderer_p.h \ - QtAV/private/VideoRenderer_p.h \ - QtAV/private/WidgetRenderer_p.h \ - QtAV/AudioDecoder.h \ - QtAV/AudioOutput.h \ - QtAV/AVDecoder.h \ - QtAV/AVDemuxer.h \ - QtAV/AVDemuxThread.h \ - QtAV/BlockingQueue.h \ - QtAV/GraphicsItemRenderer.h \ - QtAV/ImageConverter.h \ - QtAV/ImageConverterFF.h \ - QtAV/ImageRenderer.h \ - QtAV/Packet.h \ - QtAV/AVPlayer.h \ - QtAV/VideoCapture.h \ - QtAV/VideoRenderer.h \ - QtAV/WidgetRenderer.h \ - QtAV/AVOutput.h \ - QtAV/AVClock.h \ - QtAV/VideoDecoder.h \ - QtAV/VideoThread.h - -HEADERS += \ - - -HEADERS += \ - - -SOURCES += \ - +TEMPLATE = lib + +QT += core gui opengl +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG *= qtav-buildlib +#var with '_' can not pass to pri? +STATICLINK = 0 +PROJECTROOT = $$PWD/.. +!include(libQtAV.pri): error("could not find libQtAV.pri") +preparePaths($$OUT_PWD/../out) + +win32:RC_FILE = $${PROJECTROOT}/res/QtAV.rc +OTHER_FILES += $$RC_FILE +#src +unix: SOURCES += +else:win32: SOURCES += + +portaudio { +SOURCES += AOPortAudio.cpp +HEADERS += QtAV/AOPortAudio.h \ + QtAV/private/AOPortAudio_p.h +} +openal { +SOURCES += AOOpenAL.cpp +HEADERS += QtAV/AOOpenAL.h \ + QtAV/private/AOOpenAL_p.h +} + +SOURCES += \ + QtAV_Compat.cpp \ + AudioThread.cpp \ + AVThread.cpp \ + AudioDecoder.cpp \ + AudioOutput.cpp \ + AVDecoder.cpp \ + AVDemuxer.cpp \ + AVDemuxThread.cpp \ + EventFilter.cpp \ + GraphicsItemRenderer.cpp \ + ImageConverter.cpp \ + ImageConverterFF.cpp \ + ImageConverterIPP.cpp \ + ImageRenderer.cpp \ + Packet.cpp \ + AVPlayer.cpp \ + VideoCapture.cpp \ + VideoRenderer.cpp \ + WidgetRenderer.cpp \ + AVOutput.cpp \ + AVClock.cpp \ + VideoDecoder.cpp \ + VideoThread.cpp + +HEADERS += \ + QtAV/prepost.h \ + QtAV/dptr.h \ + QtAV/QtAV_Global.h \ + QtAV/QtAV_Compat.h \ + QtAV/AVThread.h \ + QtAV/AudioThread.h \ + QtAV/EventFilter.h \ + QtAV/private/AudioOutput_p.h \ + QtAV/private/AVThread_p.h \ + QtAV/private/AVDecoder_p.h \ + QtAV/private/AVOutput_p.h \ + QtAV/private/GraphicsItemRenderer_p.h \ + QtAV/private/ImageConverter_p.h \ + QtAV/private/ImageRenderer_p.h \ + QtAV/private/VideoRenderer_p.h \ + QtAV/private/WidgetRenderer_p.h \ + QtAV/AudioDecoder.h \ + QtAV/AudioOutput.h \ + QtAV/AVDecoder.h \ + QtAV/AVDemuxer.h \ + QtAV/AVDemuxThread.h \ + QtAV/BlockingQueue.h \ + QtAV/GraphicsItemRenderer.h \ + QtAV/ImageConverter.h \ + QtAV/ImageConverterFF.h \ + QtAV/ImageConverterIPP.h \ + QtAV/ImageRenderer.h \ + QtAV/Packet.h \ + QtAV/AVPlayer.h \ + QtAV/VideoCapture.h \ + QtAV/VideoRenderer.h \ + QtAV/WidgetRenderer.h \ + QtAV/AVOutput.h \ + QtAV/AVClock.h \ + QtAV/VideoDecoder.h \ + QtAV/VideoThread.h