Format code
This commit is contained in:
1 parent
3064095c95
commit
7c9363ee9d
11 files changed
+286
-277
No files matched your search
@@ -60,7 +60,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
|
||||
|
||||
headerSpacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
|
||||
|
||||
dialogIconLabel = new QLabel( );
|
||||
dialogIconLabel = new QLabel();
|
||||
dialogIconLabel->setObjectName( QStringLiteral( "dialogIconLabel" ) );
|
||||
dialogIconLabel->setPixmap( QPixmap( ":/images/dialogheader-grid.png" ) );
|
||||
|
||||
@@ -77,13 +77,13 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
|
||||
|
||||
standardResolutionLayout = new QHBoxLayout( this );
|
||||
standardResolutionLayout->setObjectName( QStringLiteral( "standardResolutionLayout" ) );
|
||||
standardResolutionLabel = new QLabel( );
|
||||
standardResolutionLabel = new QLabel();
|
||||
standardResolutionLabel->setObjectName( QStringLiteral( "standardResolutionLabel" ) );
|
||||
standardResolutionLabel->setText( QApplication::translate( "ConfigureFormat", "Standard Resolution", 0 ) );
|
||||
|
||||
horizontalSpacer = new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
|
||||
|
||||
standardResolutionBox = new QComboBox( );
|
||||
standardResolutionBox = new QComboBox();
|
||||
standardResolutionBox->setObjectName( QStringLiteral( "standardResolutionBox" ) );
|
||||
QSizePolicy sizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
|
||||
sizePolicy.setHorizontalStretch( 0 );
|
||||
@@ -110,7 +110,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
|
||||
resolutionGrid = new QGridLayout( this );
|
||||
resolutionGrid->setObjectName( QStringLiteral( "resolutionGrid" ) );
|
||||
|
||||
resolutionLabel = new QLabel( );
|
||||
resolutionLabel = new QLabel();
|
||||
resolutionLabel->setObjectName( QStringLiteral( "resolutionLabel" ) );
|
||||
QFont font1;
|
||||
font1.setBold( true );
|
||||
@@ -118,23 +118,23 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
|
||||
resolutionLabel->setFont( font1 );
|
||||
resolutionLabel->setText( QApplication::translate( "ConfigureFormat", "Resolution chosen", 0 ) );
|
||||
|
||||
widthLabel = new QLabel( );
|
||||
widthLabel = new QLabel();
|
||||
widthLabel->setObjectName( QStringLiteral( "widthLabel" ) );
|
||||
widthLabel->setText( QApplication::translate( "ConfigureFormat", "Width", 0 ) );
|
||||
widthSpinBox = new QSpinBox( );
|
||||
widthSpinBox = new QSpinBox();
|
||||
widthSpinBox->setObjectName( QStringLiteral( "widthSpinBox" ) );
|
||||
widthSpinBox->setRange( 0, 5000 );
|
||||
widthSpinBox->setValue( 0 );
|
||||
|
||||
heightLabel = new QLabel( );
|
||||
heightLabel = new QLabel();
|
||||
heightLabel->setObjectName( QStringLiteral( "heightLabel" ) );
|
||||
heightLabel->setText( QApplication::translate( "ConfigureFormat", "Height", 0 ) );
|
||||
heightSpinBox = new QSpinBox( );
|
||||
heightSpinBox = new QSpinBox();
|
||||
heightSpinBox->setObjectName( QStringLiteral( "heightSpinBox" ) );
|
||||
heightSpinBox->setRange( 0, 5000 );
|
||||
heightSpinBox->setValue( 0 );
|
||||
|
||||
pixelsLabel = new QLabel( );
|
||||
pixelsLabel = new QLabel();
|
||||
pixelsLabel->setObjectName( QStringLiteral( "pixelsLabel" ) );
|
||||
pixelsLabel->setText( QApplication::translate( "ConfigureFormat", "Pixels", 0 ) );
|
||||
|
||||
@@ -147,21 +147,19 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
|
||||
|
||||
MainLayout->addLayout( resolutionGrid );
|
||||
|
||||
|
||||
|
||||
pixelFormatVerticalSpacer = new QSpacerItem( 10, 20, QSizePolicy::Minimum );
|
||||
MainLayout->addItem( pixelFormatVerticalSpacer );
|
||||
|
||||
pixelFormatLayout = new QHBoxLayout( this );
|
||||
pixelFormatLayout->setObjectName( QStringLiteral( "pixelFormatLayout" ) );
|
||||
|
||||
pixelFormatLabel = new QLabel( );
|
||||
pixelFormatLabel = new QLabel();
|
||||
pixelFormatLabel->setObjectName( QStringLiteral( "pixelFormatLabel" ) );
|
||||
pixelFormatLabel->setText( QApplication::translate( "pixelFormat", "Pixel FormatBox", 0 ) );
|
||||
|
||||
pixelFormatHorizontalSpacer = new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
|
||||
|
||||
pixelFormatBox = new QComboBox( );
|
||||
pixelFormatBox = new QComboBox();
|
||||
pixelFormatBox->setObjectName( QStringLiteral( "pixelFormatBox" ) );
|
||||
QSizePolicy sizePolicyPixelFormat( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
|
||||
sizePolicyPixelFormat.setHorizontalStretch( 0 );
|
||||
@@ -193,7 +191,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
|
||||
|
||||
framerateFormatHorizontalSpacer = new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
|
||||
|
||||
framerateSpinBox = new QSpinBox( );
|
||||
framerateSpinBox = new QSpinBox();
|
||||
framerateSpinBox->setObjectName( QStringLiteral( "framerateSpinBox" ) );
|
||||
framerateSpinBox->setRange( 0, 200 );
|
||||
framerateSpinBox->setValue( 30 );
|
||||
@@ -220,7 +218,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
|
||||
connect( dialogButtonOkCancel, SIGNAL( accepted() ), this, SLOT( accept() ) );
|
||||
connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) );
|
||||
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
QMetaObject::connectSlotsByName( this );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -277,12 +277,12 @@ Bool InputStream::checkErrors( Int error_type )
|
||||
{
|
||||
if( m_iErrorStatus == error_type )
|
||||
{
|
||||
m_iErrorStatus = NO_ERROR;
|
||||
m_iErrorStatus = NO_STREAM_ERROR;
|
||||
return true;
|
||||
}
|
||||
if( m_iErrorStatus == error_type )
|
||||
{
|
||||
m_iErrorStatus = NO_ERROR;
|
||||
m_iErrorStatus = NO_STREAM_ERROR;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace plaYUVer
|
||||
|
||||
enum InputStream_Errors
|
||||
{
|
||||
NO_ERROR = 0, READING = 1, END_OF_SEQ = 2,
|
||||
NO_STREAM_ERROR = 0, READING = 1, END_OF_SEQ = 2,
|
||||
};
|
||||
|
||||
class InputStream
|
||||
|
||||
+203
-203
@@ -35,215 +35,215 @@
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
static int open_codec_context( int *stream_idx, AVFormatContext *fmt_ctx, enum AVMediaType type )
|
||||
{
|
||||
int ret;
|
||||
AVStream *st;
|
||||
AVCodecContext *dec_ctx = NULL;
|
||||
AVCodec *dec = NULL;
|
||||
|
||||
ret = av_find_best_stream( fmt_ctx, type, -1, -1, NULL, 0 );
|
||||
if( ret < 0 )
|
||||
static int open_codec_context( int *stream_idx, AVFormatContext *fmt_ctx, enum AVMediaType type )
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
*stream_idx = ret;
|
||||
st = fmt_ctx->streams[*stream_idx];
|
||||
int ret;
|
||||
AVStream *st;
|
||||
AVCodecContext *dec_ctx = NULL;
|
||||
AVCodec *dec = NULL;
|
||||
|
||||
/* find decoder for the stream */
|
||||
dec_ctx = st->codec;
|
||||
dec = avcodec_find_decoder( dec_ctx->codec_id );
|
||||
if( !dec )
|
||||
{
|
||||
printf( "Failed to find %s codec\n", av_get_media_type_string( type ) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
if( ( ret = avcodec_open2( dec_ctx, dec, NULL ) ) < 0 )
|
||||
{
|
||||
printf( "Failed to open %s codec\n", av_get_media_type_string( type ) );
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Void LibAvContextHandle::closeAvFormat()
|
||||
{
|
||||
if( m_bHasStream )
|
||||
{
|
||||
if( video_dec_ctx )
|
||||
avcodec_close( video_dec_ctx );
|
||||
|
||||
if( fmt_ctx )
|
||||
avformat_close_input( &fmt_ctx );
|
||||
|
||||
av_free( frame );
|
||||
av_free( video_dst_data[0] );
|
||||
}
|
||||
m_bHasStream = false;
|
||||
}
|
||||
|
||||
Bool LibAvContextHandle::initAvFormat( QString filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate )
|
||||
{
|
||||
Bool bRet = true;
|
||||
int ret = 0;
|
||||
|
||||
fmt_ctx = NULL;
|
||||
video_dec_ctx = NULL;
|
||||
video_stream = NULL;
|
||||
video_dst_data[0] = NULL;
|
||||
video_dst_data[1] = NULL;
|
||||
video_dst_data[2] = NULL;
|
||||
video_dst_data[3] = NULL;
|
||||
video_stream_idx = -1;
|
||||
frame = NULL;
|
||||
m_bHasStream = false;
|
||||
|
||||
char *src_filename = filename.toLocal8Bit().data();
|
||||
AVDictionary *format_opts = NULL;
|
||||
|
||||
/* register all formats and codecs */
|
||||
av_register_all();
|
||||
|
||||
if( width >= 0 && height >= 0 )
|
||||
{
|
||||
Char aux_string[10];
|
||||
sprintf( aux_string, "%dx%d", width, height );
|
||||
av_dict_set( &format_opts, "video_size", aux_string, 0 );
|
||||
}
|
||||
switch( pixel_format )
|
||||
{
|
||||
case PlaYUVerFrame::NO_FMT:
|
||||
break;
|
||||
case PlaYUVerFrame::YUV420:
|
||||
av_dict_set( &format_opts, "pixel_format", av_get_pix_fmt_name( AV_PIX_FMT_YUV420P ), 0 );
|
||||
break;
|
||||
case PlaYUVerFrame::YUV400:
|
||||
av_dict_set( &format_opts, "pixel_format", av_get_pix_fmt_name( AV_PIX_FMT_GRAY8 ), 0 );
|
||||
break;
|
||||
}
|
||||
|
||||
/* open input file, and allocate format context */
|
||||
if( avformat_open_input( &fmt_ctx, src_filename, NULL, &format_opts ) < 0 )
|
||||
{
|
||||
qDebug( ) << " Could not open source file %s !!!" << filename << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* retrieve stream information */
|
||||
if( avformat_find_stream_info( fmt_ctx, NULL ) < 0 )
|
||||
{
|
||||
qDebug( ) << " Could not find stream information !!!" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( open_codec_context( &video_stream_idx, fmt_ctx, AVMEDIA_TYPE_VIDEO ) >= 0 )
|
||||
{
|
||||
video_stream = fmt_ctx->streams[video_stream_idx];
|
||||
video_dec_ctx = video_stream->codec;
|
||||
|
||||
/* allocate image where the decoded image will be put */
|
||||
ret = av_image_alloc( video_dst_data, video_dst_linesize, video_dec_ctx->width, video_dec_ctx->height, video_dec_ctx->pix_fmt, 1 );
|
||||
ret = av_find_best_stream( fmt_ctx, type, -1, -1, NULL, 0 );
|
||||
if( ret < 0 )
|
||||
{
|
||||
qDebug( ) << " Could not allocate raw video buffer !!!" << endl;
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
*stream_idx = ret;
|
||||
st = fmt_ctx->streams[*stream_idx];
|
||||
|
||||
/* find decoder for the stream */
|
||||
dec_ctx = st->codec;
|
||||
dec = avcodec_find_decoder( dec_ctx->codec_id );
|
||||
if( !dec )
|
||||
{
|
||||
printf( "Failed to find %s codec\n", av_get_media_type_string( type ) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
if( ( ret = avcodec_open2( dec_ctx, dec, NULL ) ) < 0 )
|
||||
{
|
||||
printf( "Failed to open %s codec\n", av_get_media_type_string( type ) );
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Void LibAvContextHandle::closeAvFormat()
|
||||
{
|
||||
if( m_bHasStream )
|
||||
{
|
||||
if( video_dec_ctx )
|
||||
avcodec_close( video_dec_ctx );
|
||||
|
||||
if( fmt_ctx )
|
||||
avformat_close_input( &fmt_ctx );
|
||||
|
||||
av_free( frame );
|
||||
av_free( video_dst_data[0] );
|
||||
}
|
||||
m_bHasStream = false;
|
||||
}
|
||||
|
||||
Bool LibAvContextHandle::initAvFormat( QString filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate )
|
||||
{
|
||||
Bool bRet = true;
|
||||
int ret = 0;
|
||||
|
||||
fmt_ctx = NULL;
|
||||
video_dec_ctx = NULL;
|
||||
video_stream = NULL;
|
||||
video_dst_data[0] = NULL;
|
||||
video_dst_data[1] = NULL;
|
||||
video_dst_data[2] = NULL;
|
||||
video_dst_data[3] = NULL;
|
||||
video_stream_idx = -1;
|
||||
frame = NULL;
|
||||
m_bHasStream = false;
|
||||
|
||||
char *src_filename = filename.toLocal8Bit().data();
|
||||
AVDictionary *format_opts = NULL;
|
||||
|
||||
/* register all formats and codecs */
|
||||
av_register_all();
|
||||
|
||||
if( width >= 0 && height >= 0 )
|
||||
{
|
||||
Char aux_string[10];
|
||||
sprintf( aux_string, "%dx%d", width, height );
|
||||
av_dict_set( &format_opts, "video_size", aux_string, 0 );
|
||||
}
|
||||
switch( pixel_format )
|
||||
{
|
||||
case PlaYUVerFrame::NO_FMT:
|
||||
break;
|
||||
case PlaYUVerFrame::YUV420:
|
||||
av_dict_set( &format_opts, "pixel_format", av_get_pix_fmt_name( AV_PIX_FMT_YUV420P ), 0 );
|
||||
break;
|
||||
case PlaYUVerFrame::YUV400:
|
||||
av_dict_set( &format_opts, "pixel_format", av_get_pix_fmt_name( AV_PIX_FMT_GRAY8 ), 0 );
|
||||
break;
|
||||
}
|
||||
|
||||
/* open input file, and allocate format context */
|
||||
if( avformat_open_input( &fmt_ctx, src_filename, NULL, &format_opts ) < 0 )
|
||||
{
|
||||
qDebug( ) << " Could not open source file %s !!!" << filename << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* retrieve stream information */
|
||||
if( avformat_find_stream_info( fmt_ctx, NULL ) < 0 )
|
||||
{
|
||||
qDebug( ) << " Could not find stream information !!!" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( open_codec_context( &video_stream_idx, fmt_ctx, AVMEDIA_TYPE_VIDEO ) >= 0 )
|
||||
{
|
||||
video_stream = fmt_ctx->streams[video_stream_idx];
|
||||
video_dec_ctx = video_stream->codec;
|
||||
|
||||
/* allocate image where the decoded image will be put */
|
||||
ret = av_image_alloc( video_dst_data, video_dst_linesize, video_dec_ctx->width, video_dec_ctx->height, video_dec_ctx->pix_fmt, 1 );
|
||||
if( ret < 0 )
|
||||
{
|
||||
qDebug( ) << " Could not allocate raw video buffer !!!" << endl;
|
||||
closeAvFormat();
|
||||
return false;
|
||||
}
|
||||
video_dst_bufsize = ret;
|
||||
}
|
||||
|
||||
Double fr = 30;
|
||||
if( video_stream->avg_frame_rate.den && video_stream->avg_frame_rate.num )
|
||||
fr = av_q2d( video_stream->avg_frame_rate );
|
||||
#if FF_API_R_FRAME_RATE
|
||||
else if( video_stream->r_frame_rate.den && video_stream->r_frame_rate.num )
|
||||
fr = av_q2d( video_stream->r_frame_rate );
|
||||
#endif
|
||||
else if( video_stream->time_base.den && video_stream->time_base.num )
|
||||
fr = 1 / av_q2d( video_stream->time_base );
|
||||
else if( video_stream->codec->time_base.den && video_stream->codec->time_base.num )
|
||||
fr = 1 / av_q2d( video_stream->codec->time_base );
|
||||
|
||||
frame_rate = ( UInt )fr;
|
||||
|
||||
width = video_dec_ctx->width;
|
||||
height = video_dec_ctx->height;
|
||||
switch( video_dec_ctx->pix_fmt )
|
||||
{
|
||||
case AV_PIX_FMT_YUV420P:
|
||||
pixel_format = PlaYUVerFrame::YUV420;
|
||||
break;
|
||||
case AV_PIX_FMT_GRAY8:
|
||||
pixel_format = PlaYUVerFrame::YUV400;
|
||||
break;
|
||||
}
|
||||
|
||||
/* dump input information to stderr */
|
||||
av_dump_format( fmt_ctx, 0, src_filename, 0 );
|
||||
if( !video_stream )
|
||||
{
|
||||
qDebug( ) << " Could not find audio or video stream in the input, aborting !!!" << endl;
|
||||
bRet = false;
|
||||
closeAvFormat();
|
||||
return false;
|
||||
}
|
||||
video_dst_bufsize = ret;
|
||||
}
|
||||
|
||||
Double fr = 30;
|
||||
if( video_stream->avg_frame_rate.den && video_stream->avg_frame_rate.num )
|
||||
fr = av_q2d( video_stream->avg_frame_rate );
|
||||
#if FF_API_R_FRAME_RATE
|
||||
else if( video_stream->r_frame_rate.den && video_stream->r_frame_rate.num )
|
||||
fr = av_q2d( video_stream->r_frame_rate );
|
||||
#endif
|
||||
else if( video_stream->time_base.den && video_stream->time_base.num )
|
||||
fr = 1 / av_q2d( video_stream->time_base );
|
||||
else if( video_stream->codec->time_base.den && video_stream->codec->time_base.num )
|
||||
fr = 1 / av_q2d( video_stream->codec->time_base );
|
||||
|
||||
frame_rate = ( UInt )fr;
|
||||
|
||||
width = video_dec_ctx->width;
|
||||
height = video_dec_ctx->height;
|
||||
switch( video_dec_ctx->pix_fmt )
|
||||
{
|
||||
case AV_PIX_FMT_YUV420P:
|
||||
pixel_format = PlaYUVerFrame::YUV420;
|
||||
break;
|
||||
case AV_PIX_FMT_GRAY8:
|
||||
pixel_format = PlaYUVerFrame::YUV400;
|
||||
break;
|
||||
}
|
||||
|
||||
/* dump input information to stderr */
|
||||
av_dump_format( fmt_ctx, 0, src_filename, 0 );
|
||||
if( !video_stream )
|
||||
{
|
||||
qDebug( ) << " Could not find audio or video stream in the input, aborting !!!" << endl;
|
||||
bRet = false;
|
||||
closeAvFormat();
|
||||
return false;
|
||||
}
|
||||
|
||||
frame = avcodec_alloc_frame();
|
||||
if( !frame )
|
||||
{
|
||||
qDebug( ) << " Could not allocate frame !!!" << endl;
|
||||
ret = AVERROR( ENOMEM );
|
||||
closeAvFormat();
|
||||
return false;
|
||||
}
|
||||
|
||||
/* initialize packet, set data to NULL, let the demuxer fill it */
|
||||
av_init_packet( &pkt );
|
||||
pkt.data = NULL;
|
||||
pkt.size = 0;
|
||||
|
||||
m_bHasStream = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Bool LibAvContextHandle::decodeAvFormat()
|
||||
{
|
||||
Int got_frame;
|
||||
int ret;
|
||||
/* read frames from the file */
|
||||
|
||||
if( av_read_frame( fmt_ctx, &pkt ) >= 0 )
|
||||
{
|
||||
if( pkt.stream_index == video_stream_idx )
|
||||
frame = avcodec_alloc_frame();
|
||||
if( !frame )
|
||||
{
|
||||
/* decode video frame */
|
||||
ret = avcodec_decode_video2( video_dec_ctx, frame, &got_frame, &pkt );
|
||||
if( ret < 0 )
|
||||
{
|
||||
fprintf( stderr, "Error decoding video frame\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( got_frame )
|
||||
{
|
||||
/* copy decoded frame to destination buffer:
|
||||
* this is required since rawvideo expects non aligned data */
|
||||
av_image_copy( video_dst_data, video_dst_linesize, ( const uint8_t ** )( frame->data ), frame->linesize, video_dec_ctx->pix_fmt, video_dec_ctx->width,
|
||||
video_dec_ctx->height );
|
||||
|
||||
/* write to rawvideo file */
|
||||
//fwrite( video_dst_data[0], 1, video_dst_bufsize, video_dst_file );
|
||||
}
|
||||
qDebug( ) << " Could not allocate frame !!!" << endl;
|
||||
ret = AVERROR( ENOMEM );
|
||||
closeAvFormat();
|
||||
return false;
|
||||
}
|
||||
av_free_packet( &pkt );
|
||||
|
||||
/* initialize packet, set data to NULL, let the demuxer fill it */
|
||||
av_init_packet( &pkt );
|
||||
pkt.data = NULL;
|
||||
pkt.size = 0;
|
||||
|
||||
m_bHasStream = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Bool LibAvContextHandle::decodeAvFormat()
|
||||
{
|
||||
Int got_frame;
|
||||
int ret;
|
||||
/* read frames from the file */
|
||||
|
||||
if( av_read_frame( fmt_ctx, &pkt ) >= 0 )
|
||||
{
|
||||
if( pkt.stream_index == video_stream_idx )
|
||||
{
|
||||
/* decode video frame */
|
||||
ret = avcodec_decode_video2( video_dec_ctx, frame, &got_frame, &pkt );
|
||||
if( ret < 0 )
|
||||
{
|
||||
fprintf( stderr, "Error decoding video frame\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( got_frame )
|
||||
{
|
||||
/* copy decoded frame to destination buffer:
|
||||
* this is required since rawvideo expects non aligned data */
|
||||
av_image_copy( video_dst_data, video_dst_linesize, ( const uint8_t ** )( frame->data ), frame->linesize, video_dec_ctx->pix_fmt, video_dec_ctx->width,
|
||||
video_dec_ctx->height );
|
||||
|
||||
/* write to rawvideo file */
|
||||
//fwrite( video_dst_data[0], 1, video_dst_bufsize, video_dst_file );
|
||||
}
|
||||
}
|
||||
av_free_packet( &pkt );
|
||||
}
|
||||
|
||||
// /* flush cached frames */
|
||||
// pkt.data = NULL;
|
||||
// pkt.size = 0;
|
||||
@@ -253,13 +253,13 @@ Bool LibAvContextHandle::decodeAvFormat()
|
||||
// }
|
||||
// while( got_frame );
|
||||
|
||||
true;
|
||||
}
|
||||
true;
|
||||
}
|
||||
|
||||
Void LibAvContextHandle::seekAvFormat( UInt frame_num )
|
||||
{
|
||||
av_seek_frame( fmt_ctx, video_stream_idx, frame_num, AVSEEK_FLAG_ANY );
|
||||
}
|
||||
Void LibAvContextHandle::seekAvFormat( UInt frame_num )
|
||||
{
|
||||
av_seek_frame( fmt_ctx, video_stream_idx, frame_num, AVSEEK_FLAG_ANY );
|
||||
}
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
|
||||
+24
-24
@@ -43,34 +43,34 @@ extern "C"
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
class LibAvContextHandle
|
||||
{
|
||||
public:
|
||||
Bool initAvFormat( QString filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate );
|
||||
Void closeAvFormat();
|
||||
Bool decodeAvFormat();
|
||||
|
||||
Void seekAvFormat( UInt frame_num );
|
||||
|
||||
Bool getStatus()
|
||||
class LibAvContextHandle
|
||||
{
|
||||
return m_bHasStream;
|
||||
}
|
||||
public:
|
||||
Bool initAvFormat( QString filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate );
|
||||
Void closeAvFormat();
|
||||
Bool decodeAvFormat();
|
||||
|
||||
uint8_t *video_dst_data[4];
|
||||
int video_dst_linesize[4];
|
||||
int video_dst_bufsize;
|
||||
Void seekAvFormat( UInt frame_num );
|
||||
|
||||
private:
|
||||
AVFormatContext *fmt_ctx;
|
||||
AVCodecContext *video_dec_ctx;
|
||||
AVStream *video_stream;
|
||||
Int video_stream_idx;
|
||||
AVFrame *frame;
|
||||
AVPacket pkt;
|
||||
Bool getStatus()
|
||||
{
|
||||
return m_bHasStream;
|
||||
}
|
||||
|
||||
Bool m_bHasStream;
|
||||
};
|
||||
uint8_t *video_dst_data[4];
|
||||
int video_dst_linesize[4];
|
||||
int video_dst_bufsize;
|
||||
|
||||
private:
|
||||
AVFormatContext *fmt_ctx;
|
||||
AVCodecContext *video_dec_ctx;
|
||||
AVStream *video_stream;
|
||||
Int video_stream_idx;
|
||||
AVFrame *frame;
|
||||
AVPacket pkt;
|
||||
|
||||
Bool m_bHasStream;
|
||||
};
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
|
||||
#include "LibMemAlloc.h"
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
/*!
|
||||
************************************************************************
|
||||
* \brief
|
||||
@@ -136,3 +139,5 @@ void free_mem3Dpel( Pel ***array3D )
|
||||
mem_free( array3D );
|
||||
}
|
||||
}
|
||||
|
||||
} // NAMESPACE
|
||||
@@ -30,6 +30,9 @@
|
||||
#include <cstring>
|
||||
#include "TypeDef.h"
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
extern int get_mem1Dpel( Pel **array2D, int dim0 );
|
||||
extern int get_mem2Dpel( Pel ***array2D, int dim0, int dim1 );
|
||||
extern int get_mem3Dpel( Pel ****array3D, int dim0, int dim1, int dim2 );
|
||||
@@ -70,4 +73,6 @@ static inline void mem_free( void *ptr )
|
||||
}
|
||||
}
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
#endif // __LIBMEMALLOC_H__
|
||||
@@ -67,7 +67,8 @@ bool SubWindowHandle::loadFile( const QString &fileName )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_currStream.init( fileName, formatDialog.getResolution().width(), formatDialog.getResolution().height(), formatDialog.getPixelFormat(), formatDialog.getFrameRate() );
|
||||
m_currStream.init( fileName, formatDialog.getResolution().width(), formatDialog.getResolution().height(), formatDialog.getPixelFormat(),
|
||||
formatDialog.getFrameRate() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+4
-1
@@ -26,6 +26,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
// ====================================================================================================================
|
||||
// Basic type redefinition
|
||||
// ====================================================================================================================
|
||||
@@ -93,7 +96,6 @@ typedef UChar Pel; ///< 8-bit pixel type
|
||||
#define xFree( ptr ) free ( ptr )
|
||||
#endif
|
||||
|
||||
|
||||
// ====================================================================================================================
|
||||
// Qt functions
|
||||
// ====================================================================================================================
|
||||
@@ -102,5 +104,6 @@ typedef UChar Pel; ///< 8-bit pixel type
|
||||
#define QStringLiteral QString::fromUtf8
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif // __TYPEDEF_H__
|
||||
+26
-29
@@ -36,7 +36,6 @@
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
|
||||
plaYUVerApp::plaYUVerApp()
|
||||
{
|
||||
|
||||
@@ -137,7 +136,7 @@ void plaYUVerApp::play()
|
||||
UInt timeInterval;
|
||||
|
||||
frameRate = activeImageInterface()->getInputStream()->getFrameRate();
|
||||
timeInterval = (UInt)( 1000.0/frameRate + 0.5 );
|
||||
timeInterval = ( UInt )( 1000.0 / frameRate + 0.5 );
|
||||
|
||||
playingTimer->start( timeInterval );
|
||||
|
||||
@@ -345,32 +344,31 @@ Void plaYUVerApp::createActions()
|
||||
|
||||
// ------------ Playing ------------
|
||||
|
||||
actionVideoPlay = new QAction( "VideoPlay" , this );
|
||||
actionVideoPause = new QAction( "VideoPause", this );
|
||||
actionVideoStop = new QAction( "VideoStop" , this );
|
||||
actionVideoBackward = new QAction( "VideoBackward" , this );
|
||||
actionVideoForward = new QAction( "VideoForward" , this );
|
||||
actionVideoLoop = new QAction( "VideoLoop" , this );
|
||||
actionVideoLock = new QAction( "VideoLock" , this );
|
||||
actionVideoInterlace = new QAction( "VideoInterlace" , this );
|
||||
actionVideoCenter = new QAction( "VideoCenter" , this );
|
||||
actionVideoPlay = new QAction( "VideoPlay", this );
|
||||
actionVideoPause = new QAction( "VideoPause", this );
|
||||
actionVideoStop = new QAction( "VideoStop", this );
|
||||
actionVideoBackward = new QAction( "VideoBackward", this );
|
||||
actionVideoForward = new QAction( "VideoForward", this );
|
||||
actionVideoLoop = new QAction( "VideoLoop", this );
|
||||
actionVideoLock = new QAction( "VideoLock", this );
|
||||
actionVideoInterlace = new QAction( "VideoInterlace", this );
|
||||
actionVideoCenter = new QAction( "VideoCenter", this );
|
||||
|
||||
actionVideoPlay ->setIcon( QIcon( style()->standardIcon(QStyle::SP_MediaPlay ) ) );
|
||||
actionVideoPause ->setIcon( QIcon( style()->standardIcon(QStyle::SP_MediaPause ) ) );
|
||||
actionVideoStop ->setIcon( QIcon( style()->standardIcon(QStyle::SP_MediaStop ) ) );
|
||||
actionVideoBackward ->setIcon( QIcon( style()->standardIcon(QStyle::SP_MediaSeekBackward ) ) );
|
||||
actionVideoForward ->setIcon( QIcon( style()->standardIcon(QStyle::SP_MediaSeekForward ) ) );
|
||||
/*
|
||||
actionVideoLoop ->setIcon( QIcon( ":/images/videoloop.png" ) );
|
||||
actionVideoLock ->setIcon( QIcon( ":/images/lock.png" ) );
|
||||
actionVideoInterlace->setIcon( QIcon( ":/images/interlace.png" ) );
|
||||
actionVideoCenter ->setIcon( QIcon( ":/images/center.png" ) );
|
||||
*/
|
||||
|
||||
connect( actionVideoPlay , SIGNAL( triggered() ), this , SLOT ( play() ) );
|
||||
connect( actionVideoPause , SIGNAL( triggered() ), this , SLOT ( pause() ) );
|
||||
connect( actionVideoStop , SIGNAL( triggered() ), this , SLOT ( stop() ) );
|
||||
actionVideoPlay->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ) );
|
||||
actionVideoPause->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPause ) ) );
|
||||
actionVideoStop->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaStop ) ) );
|
||||
actionVideoBackward->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekBackward ) ) );
|
||||
actionVideoForward->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekForward ) ) );
|
||||
/*
|
||||
actionVideoLoop ->setIcon( QIcon( ":/images/videoloop.png" ) );
|
||||
actionVideoLock ->setIcon( QIcon( ":/images/lock.png" ) );
|
||||
actionVideoInterlace->setIcon( QIcon( ":/images/interlace.png" ) );
|
||||
actionVideoCenter ->setIcon( QIcon( ":/images/center.png" ) );
|
||||
*/
|
||||
|
||||
connect( actionVideoPlay, SIGNAL( triggered() ), this, SLOT( play() ) );
|
||||
connect( actionVideoPause, SIGNAL( triggered() ), this, SLOT( pause() ) );
|
||||
connect( actionVideoStop, SIGNAL( triggered() ), this, SLOT( stop() ) );
|
||||
|
||||
// ------------ Window ------------
|
||||
|
||||
@@ -395,7 +393,6 @@ Void plaYUVerApp::createActions()
|
||||
separatorAct = new QAction( this );
|
||||
separatorAct->setSeparator( true );
|
||||
|
||||
|
||||
// ------------ About ------------
|
||||
|
||||
aboutAct = new QAction( tr( "&About" ), this );
|
||||
@@ -495,8 +492,8 @@ QMdiSubWindow *plaYUVerApp::findImageInterface( const QString &fileName )
|
||||
foreach( QMdiSubWindow * window, mdiArea->subWindowList() ){
|
||||
SubWindowHandle *mdiChild = qobject_cast<SubWindowHandle *>( window);
|
||||
if( mdiChild->currentFile() == canonicalFilePath )
|
||||
return window;
|
||||
}
|
||||
return window;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class SubWindowHandle;
|
||||
|
||||
class plaYUVerApp: public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
plaYUVerApp();
|
||||
|
||||
Reference in new issue
Block a user