diff --git a/source/app/InputStream.cpp b/source/app/InputStream.cpp index e9d0e80..6c7aab2 100755 --- a/source/app/InputStream.cpp +++ b/source/app/InputStream.cpp @@ -21,14 +21,19 @@ * \brief Input handling */ -#include +#include "config.h" +#include #include #include "InputStream.h" #include "LibMemAlloc.h" #include "LibMemory.h" +#ifdef USE_FFMPEG +#include "LibAvContextHandle.h" +#endif + namespace plaYUVer { @@ -142,13 +147,12 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for m_iFileFormat = YUVFormat; m_iPixelFormat = input_format; - m_cStreamInformationString = QString( "[" ); - #ifdef USE_FFMPEG if( QFileInfo( filename ).completeSuffix().compare( QString( "yuv" ) ) ) { avStatus = m_cLibAvContext.initAvFormat( m_cFilename.toLocal8Bit().data(), m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate ); - m_cStreamInformationString.append( QString::fromUtf8( m_cLibAvContext.getStreamInformation() ) ); + m_cFormatName = QString::fromUtf8( m_cLibAvContext.getCodecName() ); + m_uiTotalFrameNum = 100; } #endif @@ -181,15 +185,17 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for m_uiTotalFrameNum = ftell( m_pFile ) / ( frame_bytes_input ); fseek( m_pFile, 0, SEEK_SET ); - m_cStreamInformationString.append( QString::fromUtf8("rawvideo ") ); - } + m_cFormatName = QString::fromUtf8("rawvideo "); + } if( !getMem1D( &m_pInputBuffer, m_pcCurrFrame->getBytesPerFrame() ) ) { //Error return; } + m_cStreamInformationString = QString( "[" ); + m_cStreamInformationString.append( m_cFormatName ); m_cStreamInformationString.append( QString("/ ")); m_cStreamInformationString.append( PlaYUVerFrame::supportedPixelFormatList().at( m_iPixelFormat ) ); m_cStreamInformationString.append( "] " ); @@ -304,7 +310,7 @@ cv::Mat InputStream::getFrameCvMat() Void InputStream::seekInput( Int new_frame_num ) { - if( new_frame_num < 0 || new_frame_num >= m_uiTotalFrameNum ) + if( new_frame_num < 0 || new_frame_num >= (Int)m_uiTotalFrameNum ) return; #ifdef USE_FFMPEG if( m_cLibAvContext.getStatus() ) diff --git a/source/app/InputStream.h b/source/app/InputStream.h index 7e92558..6b16451 100755 --- a/source/app/InputStream.h +++ b/source/app/InputStream.h @@ -64,6 +64,7 @@ private: #endif QString m_cFilename; + QString m_cFormatName; QString m_cStreamInformationString; FILE* m_pFile; /**< The input file pointer >*/ @@ -127,8 +128,12 @@ public: return m_cFilename; } QString getStreamInformationString() + { + return m_cStreamInformationString; + } + QString getFormatName() { - return m_cStreamInformationString; + return m_cFormatName; } UInt getFrameNum() { diff --git a/source/app/TypeDef.h b/source/app/TypeDef.h index f440fbc..3b45beb 100644 --- a/source/app/TypeDef.h +++ b/source/app/TypeDef.h @@ -124,17 +124,6 @@ enum InputStreamFormats NUMBER_FORMATS }; -const std::string gInputStreamFormatsNames[] = -{ - "YUV420p", - "YUV444p", - "YUV422p", - "YUV411p", - "YUV410p", - "GRAY", - "RGB8", -}; - enum ColorSpace { COLOR_INVALID = -1, diff --git a/source/lib/PlaYUVerFrame.cpp b/source/lib/PlaYUVerFrame.cpp index 6bfd032..fa95f06 100755 --- a/source/lib/PlaYUVerFrame.cpp +++ b/source/lib/PlaYUVerFrame.cpp @@ -29,16 +29,6 @@ namespace plaYUVer { -QStringList PlaYUVerFrame::supportedPixelFormatList() -{ - QStringList formats; - for( Int i = 0; i < NUMBER_FORMATS; i++ ) - { - formats.append(gInputStreamFormatsNames[i].data()); - } - return formats; -} - PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pel_format ) { m_pppcInputPel[0] = NULL; diff --git a/source/lib/PlaYUVerFrame.h b/source/lib/PlaYUVerFrame.h index 3ea455c..1cd1567 100755 --- a/source/lib/PlaYUVerFrame.h +++ b/source/lib/PlaYUVerFrame.h @@ -38,13 +38,46 @@ class QImage; namespace plaYUVer { + +static const QString gInputStreamFormatsNames[] = +{ + "YUV420p", + "YUV444p", + "YUV422p", + "YUV411p", + "YUV410p", + "GRAY", + "RGB8", +}; + class PlaYUVerFrame { public: PlaYUVerFrame( UInt width, UInt height, Int pel_format ); ~PlaYUVerFrame(); - static QStringList supportedPixelFormatList(); + enum PixelFormats + { + NO_FMT = -1, + YUV420p = 0, + YUV444p, + YUV422p, + YUV411p, + YUV410p, + GRAY, + RGB8, + NUMBER_FORMATS + }; + + static QStringList supportedPixelFormatList() + { + QStringList formats; + for( Int i = 0; i < NUMBER_FORMATS; i++ ) + { + formats.append(gInputStreamFormatsNames[i]); + } + return formats; + } Void FrametoRGB8(); diff --git a/source/lib/ffmpeg/LibAvContextHandle.cpp b/source/lib/ffmpeg/LibAvContextHandle.cpp index ac5416e..7f83ef0 100755 --- a/source/lib/ffmpeg/LibAvContextHandle.cpp +++ b/source/lib/ffmpeg/LibAvContextHandle.cpp @@ -153,7 +153,7 @@ Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height const char *codec_name = avcodec_get_name(video_dec_ctx->codec_id); - sprintf(m_acStreamInformationString, "%s ", codec_name); + sprintf(m_acCodecName, "%s ", codec_name); Double fr = 30; if( video_stream->avg_frame_rate.den && video_stream->avg_frame_rate.num ) diff --git a/source/lib/ffmpeg/LibAvContextHandle.h b/source/lib/ffmpeg/LibAvContextHandle.h index 4a35751..6d6905e 100755 --- a/source/lib/ffmpeg/LibAvContextHandle.h +++ b/source/lib/ffmpeg/LibAvContextHandle.h @@ -65,9 +65,9 @@ public: { return m_bHasStream; } - Char* getStreamInformation() + Char* getCodecName() { - return m_acStreamInformationString; + return m_acCodecName; } uint8_t *video_dst_data[4]; @@ -84,7 +84,7 @@ private: Bool m_bHasStream; - Char m_acStreamInformationString[20]; + Char m_acCodecName[20]; }; } // NAMESPACE