Fix some problems
Fix problems in the histogram calculation Change handle of frame count in the stream handlers
This commit is contained in:
20 files changed
+92
-149
No files matched your search
+1
-1
@@ -130,7 +130,7 @@ ENDIF()
|
||||
|
||||
|
||||
ADD_EXECUTABLE( ${PROJECT_NAME} ${plaYUVer_App_SRCS} ${HEADERS_MOC_FILES} ${PlaYUVer_App_UI_Wrap} ${PlaYUVer_App_RCC} ${WINDOWS_RES_FILE} )
|
||||
TARGET_LINK_LIBRARIES( ${PROJECT_NAME} PlaYUVerLib PlaYUVerModules QCustomPlotLib ${APP_LINKER_LIBS} ${QT_LINKER_LIBS} )
|
||||
TARGET_LINK_LIBRARIES( ${PROJECT_NAME} PlaYUVerLib PlaYUVerModules ${APP_LINKER_LIBS} ${QT_LINKER_LIBS} QCustomPlotLib )
|
||||
|
||||
# QT5_USE_MODULES( ${PROJECT_NAME} ${QT_MODULES} )
|
||||
|
||||
|
||||
+10
-3
@@ -25,10 +25,16 @@
|
||||
|
||||
// TODO:
|
||||
// - Optimizar paintEvent. Parece haver codigo redundante !!
|
||||
#include "HistogramWidget.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "HistogramWidget.h"
|
||||
#include <QtDebug>
|
||||
#include <QtGui>
|
||||
#include <QThread>
|
||||
#include <QEvent>
|
||||
#include <QCoreApplication>
|
||||
#include <QTimer>
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
#include <cmath>
|
||||
|
||||
class HistogramWorker : public QThread
|
||||
@@ -47,7 +53,8 @@ public:
|
||||
Void setup( PlaYUVerFrame* frame )
|
||||
{
|
||||
m_pcFrame = frame;
|
||||
run();
|
||||
// run();
|
||||
start();
|
||||
}
|
||||
Void run()
|
||||
{
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
#ifndef __HISTOGRAMWIDGET_H__
|
||||
#define __HISTOGRAMWIDGET_H__
|
||||
|
||||
#include "PlaYUVerAppDefs.h"
|
||||
#include "config.h"
|
||||
#include "PlaYUVerAppDefs.h"
|
||||
#include "lib/PlaYUVerFrame.h"
|
||||
#include <QColor>
|
||||
#include <QWidget>
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <QString>
|
||||
#include <QGridLayout>
|
||||
|
||||
|
||||
ModuleHandleDock::ModuleHandleDock( QWidget* parent, PlaYUVerAppModuleIf* moduleIf ) : QWidget( parent ), m_pcCurrModuleIf( moduleIf )
|
||||
{
|
||||
// ----------------- Dock definition -----------------
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
*/
|
||||
|
||||
#include "PlotSubWindow.h"
|
||||
#include "external/qcustomplot/qcustomplot.h"
|
||||
#include "qcustomplot.h"
|
||||
//#include "external/qcustomplot/qcustomplot.h"
|
||||
|
||||
Void PlotSubWindow::definePlotColors()
|
||||
{
|
||||
|
||||
@@ -133,6 +133,7 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget*
|
||||
, m_pcCurrentDisplayModule( NULL )
|
||||
, m_pcReferenceSubWindow( NULL )
|
||||
, m_bIsPlaying( false )
|
||||
, m_pcUpdateTimer( NULL )
|
||||
{
|
||||
// Create a new scroll area inside the sub-window
|
||||
m_pcScrollArea = new QScrollArea;
|
||||
@@ -150,8 +151,8 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget*
|
||||
connect( m_cViewArea, SIGNAL( selectionChanged( QRect ) ), this, SLOT( updateSelectedArea( QRect ) ) );
|
||||
connect( m_cViewArea, SIGNAL( positionChanged( const QPoint& ) ), this, SLOT( updatePixelValueStatusBar( const QPoint& ) ) );
|
||||
|
||||
m_pcScrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
m_pcScrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
// m_pcScrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
// m_pcScrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
|
||||
// Define the cViewArea as the widget inside the scroll area
|
||||
m_pcScrollArea->setWidget( m_cViewArea );
|
||||
@@ -176,6 +177,7 @@ VideoSubWindow::~VideoSubWindow()
|
||||
m_pcCurrFrame = NULL;
|
||||
disableModule();
|
||||
delete m_cViewArea;
|
||||
delete m_pcUpdateTimer;
|
||||
if( m_pCurrStream )
|
||||
delete m_pCurrStream;
|
||||
}
|
||||
@@ -304,7 +306,7 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
|
||||
Bool bConfig = guessFormat( cFilename, Width, Height, InputFormat, BitsPel, Endianness ) || bForceDialog;
|
||||
Bool bRet = false;
|
||||
for( Int iPass = 0; iPass < 2 && !bRet; iPass++ ) {
|
||||
if( iPass && bConfig )
|
||||
if( iPass || bConfig )
|
||||
{
|
||||
if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate ) ==
|
||||
QDialog::Rejected )
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ set(qcustomplot_SRCS
|
||||
qcustomplot.h
|
||||
)
|
||||
|
||||
ADD_LIBRARY( QCustomPlotLib SHARED ${qcustomplot_SRCS} )
|
||||
ADD_LIBRARY( QCustomPlotLib STATIC ${qcustomplot_SRCS} )
|
||||
TARGET_LINK_LIBRARIES( QCustomPlotLib
|
||||
Qt5::Core
|
||||
Qt5::Gui
|
||||
|
||||
+7
-62
@@ -116,48 +116,19 @@ Int getMem3D( T**** array3D, Int dim0, Int dim1, Int dim2 )
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Int getMem4D( T***** array4D, Int dim0, Int dim1, Int dim2, Int dim3 )
|
||||
{
|
||||
int i, mem_size = dim0 * sizeof( int*** );
|
||||
|
||||
if( ( ( *array4D ) = (T****)xMallocMem( dim0 * sizeof( T*** ) ) ) == NULL )
|
||||
printf( "get_mem4Dint: array4D" );
|
||||
|
||||
mem_size += getMem3D( *array4D, dim0 * dim1, dim2, dim3 );
|
||||
|
||||
for( i = 1; i < dim0; i++ ) ( *array4D )[i] = ( *array4D )[i - 1] + dim1;
|
||||
|
||||
return mem_size;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Int getMem5D( T****** array5D, Int dim0, Int dim1, Int dim2, Int dim3, Int dim4 )
|
||||
{
|
||||
int i, mem_size = dim0 * sizeof( T**** );
|
||||
|
||||
if( ( ( *array5D ) = (T*****)xMallocMem( dim0 * sizeof( T**** ) ) ) == NULL )
|
||||
printf( "get_mem5Dint: array5D" );
|
||||
|
||||
mem_size += getMem4D( *array5D, dim0 * dim1, dim2, dim3, dim4 );
|
||||
|
||||
for( i = 1; i < dim0; i++ ) ( *array5D )[i] = ( *array5D )[i - 1] + dim1;
|
||||
|
||||
return mem_size;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Void freeMem1D( T* array1D )
|
||||
Void freeMem1D( T*& array1D )
|
||||
{
|
||||
if( array1D )
|
||||
{
|
||||
xFreeMem( array1D );
|
||||
array1D = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Void freeMem2D( T** array2D )
|
||||
Void freeMem2D( T**& array2D )
|
||||
{
|
||||
if( array2D )
|
||||
if( *array2D )
|
||||
{
|
||||
if( *array2D )
|
||||
xFreeMem( *array2D );
|
||||
@@ -165,6 +136,7 @@ Void freeMem2D( T** array2D )
|
||||
printf( "free_mem2Dint: trying to free unused memory" );
|
||||
|
||||
xFreeMem( array2D );
|
||||
array2D = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -173,12 +145,13 @@ Void freeMem2D( T** array2D )
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Void freeMem3D( T*** array3D )
|
||||
Void freeMem3D( T***& array3D )
|
||||
{
|
||||
if( array3D )
|
||||
{
|
||||
freeMem2D( *array3D );
|
||||
xFreeMem( array3D );
|
||||
array3D = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -186,32 +159,4 @@ Void freeMem3D( T*** array3D )
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Void freeMem4D( T**** array4D )
|
||||
{
|
||||
if( array4D )
|
||||
{
|
||||
freeMem3D( *array4D );
|
||||
xFreeMem( array4D );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "free_mem4Dint: trying to free unused memory" );
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Void freeMem5D( T***** array5D )
|
||||
{
|
||||
if( array5D )
|
||||
{
|
||||
freeMem4D( *array5D );
|
||||
xFreeMem( array5D );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "free_mem5Dint: trying to free unused memory" );
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __LIBMEMORY_H__
|
||||
+11
-18
@@ -138,17 +138,16 @@ struct PlaYUVerFramePrivate
|
||||
Bool m_bHasRGBPel; //!< Flag indicating that the ARGB buffer was computed
|
||||
UChar* m_pcARGB32; //!< Buffer with the ARGB pixels used in Qt libs
|
||||
|
||||
/** Histogram control variables **/
|
||||
Bool m_bHasHistogram;
|
||||
Bool m_bHistogramRunning;
|
||||
/** The histogram data.*/
|
||||
UInt* m_puiHistogram;
|
||||
|
||||
/** If the image is RGB and calcLuma is true, we have 1 more channel */
|
||||
UInt m_uiHistoChannels;
|
||||
|
||||
/** Numbers of histogram segments depending of image bytes depth*/
|
||||
UInt m_uiHistoSegments;
|
||||
|
||||
Bool m_bHasHistogram;
|
||||
|
||||
/**
|
||||
* Common constructor function of a frame
|
||||
*
|
||||
@@ -189,6 +188,7 @@ struct PlaYUVerFramePrivate
|
||||
|
||||
m_puiHistogram = NULL;
|
||||
m_bHasHistogram = false;
|
||||
m_bHistogramRunning = false;
|
||||
|
||||
m_uiHistoSegments = 1 << m_uiBitsPel;
|
||||
|
||||
@@ -197,6 +197,8 @@ struct PlaYUVerFramePrivate
|
||||
else
|
||||
m_uiHistoChannels = m_pcPelFormat->numberChannels;
|
||||
|
||||
getMem1D<UInt>( &( m_puiHistogram ), m_uiHistoSegments * m_uiHistoChannels );
|
||||
|
||||
m_cPelFmtName = PlaYUVerFrame::supportedPixelFormatListNames()[m_iPixelFormat].c_str();
|
||||
|
||||
m_bInit = true;
|
||||
@@ -204,20 +206,17 @@ struct PlaYUVerFramePrivate
|
||||
|
||||
~PlaYUVerFramePrivate()
|
||||
{
|
||||
while( m_bHistogramRunning )
|
||||
;
|
||||
if( m_puiHistogram )
|
||||
{
|
||||
freeMem1D( m_puiHistogram );
|
||||
}
|
||||
m_puiHistogram = NULL;
|
||||
m_bHasHistogram = false;
|
||||
|
||||
if( m_pppcInputPel )
|
||||
freeImgMemory( m_pppcInputPel );
|
||||
m_pppcInputPel = NULL;
|
||||
|
||||
if( m_pcARGB32 )
|
||||
freeMem1D( m_pcARGB32 );
|
||||
m_pcARGB32 = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -728,17 +727,10 @@ Void PlaYUVerFrame::fillRGBBuffer()
|
||||
|
||||
Void PlaYUVerFrame::calcHistogram()
|
||||
{
|
||||
if( d->m_bHasHistogram )
|
||||
if( d->m_bHasHistogram || !d->m_puiHistogram )
|
||||
return;
|
||||
|
||||
if( !d->m_puiHistogram )
|
||||
{
|
||||
getMem1D<UInt>( &( d->m_puiHistogram ), d->m_uiHistoSegments * d->m_uiHistoChannels );
|
||||
if( !d->m_puiHistogram )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
d->m_bHistogramRunning = true;
|
||||
|
||||
xMemSet( UInt, d->m_uiHistoSegments * d->m_uiHistoChannels, d->m_puiHistogram );
|
||||
|
||||
@@ -784,6 +776,7 @@ Void PlaYUVerFrame::calcHistogram()
|
||||
}
|
||||
}
|
||||
d->m_bHasHistogram = true;
|
||||
d->m_bHistogramRunning = false;
|
||||
}
|
||||
|
||||
Int PlaYUVerFrame::getHistogramSegment()
|
||||
|
||||
+15
-17
@@ -188,7 +188,6 @@ PlaYUVerStream::PlaYUVerStream()
|
||||
m_pcHandler = NULL;
|
||||
m_bIsInput = true;
|
||||
m_bLoadAll = false;
|
||||
m_uiTotalFrameNum = 0;
|
||||
m_iCurrFrameNum = -1;
|
||||
m_cFilename = "";
|
||||
}
|
||||
@@ -289,14 +288,12 @@ Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_f
|
||||
return m_bInit;
|
||||
}
|
||||
|
||||
m_pcHandler->setBytesPerFrame( m_frameBuffer->current()->getBytesPerFrame() );
|
||||
m_pcHandler->m_uiNBytesPerFrame = m_frameBuffer->current()->getBytesPerFrame();
|
||||
|
||||
if( m_bIsInput )
|
||||
{
|
||||
m_uiTotalFrameNum = m_pcHandler->calculateFrameNumber();
|
||||
}
|
||||
// Some handlers need to know how long is a frame to get frame number
|
||||
m_pcHandler->calculateFrameNumber();
|
||||
|
||||
if( m_bIsInput && m_uiTotalFrameNum <= 0 )
|
||||
if( m_bIsInput && m_pcHandler->m_uiTotalNumberFrames == 0 )
|
||||
{
|
||||
close();
|
||||
throw PlaYUVerFailure( "PlaYUVerStream", "Incorrect configuration: less than one frame" );
|
||||
@@ -327,15 +324,16 @@ Bool PlaYUVerStream::reload()
|
||||
throw PlaYUVerFailure( "PlaYUVerStream",
|
||||
"Cannot open stream " + m_cFilename + " with the " + String( m_pcHandler->m_pchHandlerName ) + " handler" );
|
||||
}
|
||||
m_pcHandler->setBytesPerFrame( m_frameBuffer->current()->getBytesPerFrame() );
|
||||
m_uiTotalFrameNum = m_pcHandler->calculateFrameNumber();
|
||||
m_pcHandler->m_uiNBytesPerFrame = m_frameBuffer->current()->getBytesPerFrame();
|
||||
m_pcHandler->calculateFrameNumber();
|
||||
m_pcHandler->configureBuffer( m_frameBuffer->current() );
|
||||
|
||||
if( m_pcHandler->m_uiWidth <= 0 || m_pcHandler->m_uiHeight <= 0 || m_pcHandler->m_iPixelFormat < 0 || m_pcHandler->m_uiBitsPerPixel == 0 ||
|
||||
m_uiTotalFrameNum < 1 )
|
||||
m_pcHandler->m_uiTotalNumberFrames == 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( UInt( m_iCurrFrameNum ) >= m_uiTotalFrameNum )
|
||||
if( UInt( m_iCurrFrameNum ) >= m_pcHandler->m_uiTotalNumberFrames )
|
||||
{
|
||||
m_iCurrFrameNum = 0;
|
||||
}
|
||||
@@ -366,7 +364,7 @@ String PlaYUVerStream::getFileName()
|
||||
|
||||
UInt PlaYUVerStream::getFrameNum()
|
||||
{
|
||||
return m_uiTotalFrameNum;
|
||||
return m_pcHandler->m_uiTotalNumberFrames;
|
||||
}
|
||||
UInt PlaYUVerStream::getWidth() const
|
||||
{
|
||||
@@ -419,7 +417,7 @@ Void PlaYUVerStream::loadAll()
|
||||
|
||||
try
|
||||
{
|
||||
m_frameBuffer->increase( m_uiTotalFrameNum );
|
||||
m_frameBuffer->increase( m_pcHandler->m_uiTotalNumberFrames );
|
||||
}
|
||||
catch( PlaYUVerFailure& e )
|
||||
{
|
||||
@@ -460,7 +458,7 @@ Void PlaYUVerStream::getDuration( Int* duration_array )
|
||||
|
||||
Bool PlaYUVerStream::readFrame( PlaYUVerFrame* frame )
|
||||
{
|
||||
if( !m_bInit || !m_bIsInput || m_pcHandler->m_uiCurrFrameFileIdx >= m_uiTotalFrameNum )
|
||||
if( !m_bInit || !m_bIsInput || m_pcHandler->m_uiCurrFrameFileIdx >= m_pcHandler->m_uiTotalNumberFrames )
|
||||
return false;
|
||||
|
||||
if( m_bLoadAll )
|
||||
@@ -510,7 +508,7 @@ Bool PlaYUVerStream::setNextFrame()
|
||||
{
|
||||
Bool bEndOfSeq = false;
|
||||
|
||||
if( m_iCurrFrameNum + 1 < Int( m_uiTotalFrameNum ) )
|
||||
if( m_iCurrFrameNum + 1 < Int64( m_pcHandler->m_uiTotalNumberFrames ) )
|
||||
{
|
||||
m_frameBuffer->setNextFrame();
|
||||
m_iCurrFrameNum++;
|
||||
@@ -569,7 +567,7 @@ Bool PlaYUVerStream::seekInputRelative( Bool bIsFoward )
|
||||
|
||||
Bool PlaYUVerStream::seekInput( UInt64 new_frame_num )
|
||||
{
|
||||
if( !m_bInit || new_frame_num >= m_uiTotalFrameNum || (Int64)new_frame_num == m_iCurrFrameNum )
|
||||
if( !m_bInit || new_frame_num >= m_pcHandler->m_uiTotalNumberFrames || Int64( new_frame_num ) == m_iCurrFrameNum )
|
||||
return false;
|
||||
|
||||
m_iCurrFrameNum = new_frame_num;
|
||||
@@ -587,7 +585,7 @@ Bool PlaYUVerStream::seekInput( UInt64 new_frame_num )
|
||||
|
||||
m_frameBuffer->setIndex( 0 );
|
||||
readFrame( m_frameBuffer->current() );
|
||||
if( m_uiTotalFrameNum > 1 )
|
||||
if( m_pcHandler->m_uiTotalNumberFrames > 1 )
|
||||
readFrame( m_frameBuffer->next() );
|
||||
|
||||
return true;
|
||||
|
||||
@@ -126,7 +126,6 @@ private:
|
||||
|
||||
Bool m_bIsInput;
|
||||
String m_cFilename;
|
||||
UInt64 m_uiTotalFrameNum;
|
||||
Int64 m_iCurrFrameNum;
|
||||
|
||||
Bool m_bLoadAll;
|
||||
|
||||
@@ -79,7 +79,9 @@ public:
|
||||
, m_uiBitsPerPixel( 8 )
|
||||
, m_iEndianness( -1 )
|
||||
, m_dFrameRate( 30 )
|
||||
, m_uiTotalNumberFrames( 0 )
|
||||
, m_pStreamBuffer( NULL )
|
||||
, m_uiNBytesPerFrame( 0 )
|
||||
{
|
||||
}
|
||||
virtual ~PlaYUVerStreamHandlerIf() {}
|
||||
@@ -88,17 +90,20 @@ public:
|
||||
virtual Bool openHandler( String strFilename, Bool bInput ) = 0;
|
||||
virtual Void closeHandler() = 0;
|
||||
virtual Bool configureBuffer( PlaYUVerFrame* pcFrame ) = 0;
|
||||
virtual UInt64 calculateFrameNumber() = 0;
|
||||
virtual Bool seek( UInt64 iFrameNum ) = 0;
|
||||
virtual Bool read( PlaYUVerFrame* pcFrame ) = 0;
|
||||
virtual Bool write( PlaYUVerFrame* pcFrame ) = 0;
|
||||
|
||||
Void setBytesPerFrame( UInt64 uiNBytes ) { m_uiNBytesPerFrame = uiNBytes; }
|
||||
virtual Void calculateFrameNumber(){};
|
||||
|
||||
String getFormatName() { return m_strFormatName; }
|
||||
String getCodecName() { return m_strCodecName; }
|
||||
|
||||
protected:
|
||||
const Char* m_pchHandlerName;
|
||||
|
||||
String m_strFormatName;
|
||||
String m_strCodecName;
|
||||
Bool m_bIsInput;
|
||||
UInt64 m_uiCurrFrameFileIdx;
|
||||
String m_cFilename;
|
||||
@@ -108,11 +113,9 @@ protected:
|
||||
UInt m_uiBitsPerPixel;
|
||||
Int m_iEndianness;
|
||||
Double m_dFrameRate;
|
||||
|
||||
UInt64 m_uiTotalNumberFrames;
|
||||
Byte* m_pStreamBuffer;
|
||||
UInt64 m_uiNBytesPerFrame;
|
||||
String m_strFormatName;
|
||||
String m_strCodecName;
|
||||
};
|
||||
|
||||
#endif // __PLAYUVERSTREAMHANDLERIF_H__
|
||||
+11
-10
@@ -167,6 +167,9 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput )
|
||||
const char* name = avcodec_get_name( m_cCodedCtx->codec_id );
|
||||
m_strCodecName = name;
|
||||
|
||||
// Set bits per pixel to default (8 bits)
|
||||
m_uiBitsPerPixel = 8;
|
||||
|
||||
/**
|
||||
* Auxiliar conversation to re-use similar pixfmt
|
||||
*/
|
||||
@@ -223,8 +226,7 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput )
|
||||
|
||||
m_dFrameRate = fr;
|
||||
|
||||
// Set bits per pixel to default (8 bits)
|
||||
m_uiBitsPerPixel = 8;
|
||||
calculateFrameNumber();
|
||||
|
||||
/* dump input information to stderr */
|
||||
av_dump_format( m_cFmtCtx, 0, filename, 0 );
|
||||
@@ -275,15 +277,14 @@ Bool StreamHandlerLibav::configureBuffer( PlaYUVerFrame* pcFrame )
|
||||
return getMem1D<Byte>( &m_pStreamBuffer, pcFrame->getBytesPerFrame() );
|
||||
}
|
||||
|
||||
UInt64 StreamHandlerLibav::calculateFrameNumber()
|
||||
Void StreamHandlerLibav::calculateFrameNumber()
|
||||
{
|
||||
UInt64 num_frames;
|
||||
// if( m_cStream->nb_frames )
|
||||
// { *
|
||||
// num_frames = m_cStream->nb_frames;
|
||||
// }
|
||||
// else
|
||||
if( m_cFmtCtx->duration != AV_NOPTS_VALUE )
|
||||
if( m_cStream->nb_frames )
|
||||
{
|
||||
num_frames = m_cStream->nb_frames;
|
||||
}
|
||||
else if( m_cFmtCtx->duration != AV_NOPTS_VALUE )
|
||||
{
|
||||
Int64 duration = m_cFmtCtx->duration + 5000;
|
||||
m_uiSecs = duration / AV_TIME_BASE;
|
||||
@@ -295,7 +296,7 @@ UInt64 StreamHandlerLibav::calculateFrameNumber()
|
||||
num_frames = 0;
|
||||
}
|
||||
num_frames = num_frames == 0 ? 1 : num_frames;
|
||||
return num_frames;
|
||||
m_uiTotalNumberFrames = num_frames;
|
||||
}
|
||||
|
||||
Bool StreamHandlerLibav::read( PlaYUVerFrame* pcFrame )
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
Bool openHandler( String strFilename, Bool bInput );
|
||||
Void closeHandler();
|
||||
Bool configureBuffer( PlaYUVerFrame* pcFrame );
|
||||
UInt64 calculateFrameNumber();
|
||||
Void calculateFrameNumber();
|
||||
Bool seek( UInt64 iFrameNum );
|
||||
Bool read( PlaYUVerFrame* pcFrame );
|
||||
Bool write( PlaYUVerFrame* pcFrame );
|
||||
|
||||
@@ -97,6 +97,12 @@ Bool StreamHandlerOpenCV::openHandler( String strFilename, Bool bInput )
|
||||
}
|
||||
m_uiBitsPerPixel = 8;
|
||||
m_iPixelFormat = PlaYUVerFrame::findPixelFormat( "BGR" );
|
||||
|
||||
m_uiTotalNumberFrames = 1;
|
||||
if( pcVideoCapture )
|
||||
{
|
||||
m_uiTotalNumberFrames = 2;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -117,15 +123,6 @@ Bool StreamHandlerOpenCV::configureBuffer( PlaYUVerFrame* pcFrame )
|
||||
return true;
|
||||
}
|
||||
|
||||
UInt64 StreamHandlerOpenCV::calculateFrameNumber()
|
||||
{
|
||||
if( pcVideoCapture )
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
Bool StreamHandlerOpenCV::seek( UInt64 iFrameNum )
|
||||
{
|
||||
// m_uiCurrFrameFileIdx =
|
||||
|
||||
@@ -45,7 +45,6 @@ public:
|
||||
Bool openHandler( String strFilename, Bool bInput );
|
||||
Void closeHandler();
|
||||
Bool configureBuffer( PlaYUVerFrame* pcFrame );
|
||||
UInt64 calculateFrameNumber();
|
||||
Bool seek( UInt64 iFrameNum );
|
||||
Bool read( PlaYUVerFrame* pcFrame );
|
||||
Bool write( PlaYUVerFrame* pcFrame );
|
||||
|
||||
@@ -105,6 +105,7 @@ Bool StreamHandlerPortableMap::openHandler( String strFilename, Bool bInput )
|
||||
}
|
||||
m_iEndianness = 0;
|
||||
m_dFrameRate = 1;
|
||||
m_uiTotalNumberFrames = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -122,11 +123,6 @@ Bool StreamHandlerPortableMap::configureBuffer( PlaYUVerFrame* pcFrame )
|
||||
return getMem1D<Byte>( &m_pStreamBuffer, pcFrame->getBytesPerFrame() );
|
||||
}
|
||||
|
||||
UInt64 StreamHandlerPortableMap::calculateFrameNumber()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Bool StreamHandlerPortableMap::seek( UInt64 iFrameNum )
|
||||
{
|
||||
// m_uiCurrFrameFileIdx =
|
||||
|
||||
@@ -40,7 +40,6 @@ public:
|
||||
Bool openHandler( String strFilename, Bool bInput );
|
||||
Void closeHandler();
|
||||
Bool configureBuffer( PlaYUVerFrame* pcFrame );
|
||||
UInt64 calculateFrameNumber();
|
||||
Bool seek( UInt64 iFrameNum );
|
||||
Bool read( PlaYUVerFrame* pcFrame );
|
||||
Bool write( PlaYUVerFrame* pcFrame );
|
||||
|
||||
@@ -55,6 +55,7 @@ Bool StreamHandlerRaw::openHandler( String strFilename, Bool bInput )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
calculateFrameNumber();
|
||||
m_strFormatName = "YUV";
|
||||
m_strCodecName = "Raw Video";
|
||||
return true;
|
||||
@@ -73,14 +74,15 @@ Bool StreamHandlerRaw::configureBuffer( PlaYUVerFrame* pcFrame )
|
||||
return getMem1D<Byte>( &m_pStreamBuffer, pcFrame->getBytesPerFrame() );
|
||||
}
|
||||
|
||||
UInt64 StreamHandlerRaw::calculateFrameNumber()
|
||||
Void StreamHandlerRaw::calculateFrameNumber()
|
||||
{
|
||||
if( !m_pFile || m_uiNBytesPerFrame == 0 )
|
||||
return 0;
|
||||
fseek( m_pFile, 0, SEEK_END );
|
||||
UInt64 fileSize = ftell( m_pFile );
|
||||
fseek( m_pFile, 0, SEEK_SET );
|
||||
return ( fileSize / m_uiNBytesPerFrame );
|
||||
if( m_pFile && m_uiNBytesPerFrame > 0 )
|
||||
{
|
||||
fseek( m_pFile, 0, SEEK_END );
|
||||
UInt64 fileSize = ftell( m_pFile );
|
||||
fseek( m_pFile, 0, SEEK_SET );
|
||||
m_uiTotalNumberFrames = fileSize / m_uiNBytesPerFrame;
|
||||
}
|
||||
}
|
||||
|
||||
Bool StreamHandlerRaw::seek( UInt64 iFrameNum )
|
||||
@@ -96,6 +98,8 @@ Bool StreamHandlerRaw::seek( UInt64 iFrameNum )
|
||||
|
||||
Bool StreamHandlerRaw::read( PlaYUVerFrame* pcFrame )
|
||||
{
|
||||
if( !m_pFile || !m_pStreamBuffer || m_uiNBytesPerFrame == 0 )
|
||||
return false;
|
||||
UInt64 processed_bytes = fread( m_pStreamBuffer, sizeof( Byte ), m_uiNBytesPerFrame, m_pFile );
|
||||
if( processed_bytes != m_uiNBytesPerFrame )
|
||||
return false;
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
Bool openHandler( String strFilename, Bool bInput );
|
||||
Void closeHandler();
|
||||
Bool configureBuffer( PlaYUVerFrame* pcFrame );
|
||||
UInt64 calculateFrameNumber();
|
||||
Void calculateFrameNumber();
|
||||
Bool seek( UInt64 iFrameNum );
|
||||
Bool read( PlaYUVerFrame* pcFrame );
|
||||
Bool write( PlaYUVerFrame* pcFrame );
|
||||
|
||||
Reference in new issue
Block a user