Skip to content

Clean #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/AvTranscoder/EssenceStream/DummyVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace avtranscoder
DummyVideo::DummyVideo( )
: InputEssence( )
, _inputFrame( NULL )
, _videoDesc()
, _videoFrameDesc()
, _numberOfView( 1 )
{
}
Expand All @@ -32,12 +34,13 @@ void DummyVideo::setFrame( Frame& inputFrame )

bool DummyVideo::readNextFrame( Frame& frameBuffer )
{
frameBuffer.getBuffer().resize( _videoFrameDesc.getDataSize() );

if( ! _inputFrame )
{
int fillChar = 0; // fill images with black
memset( frameBuffer.getPtr(), fillChar, frameBuffer.getSize() );

if( frameBuffer.getSize() != _videoFrameDesc.getDataSize() )
frameBuffer.getBuffer().resize( _videoFrameDesc.getDataSize() );
memset( frameBuffer.getPtr(), fillChar, _videoFrameDesc.getDataSize() );
return true;
}

Expand Down
9 changes: 1 addition & 8 deletions src/AvTranscoder/EssenceStream/OutputVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ bool OutputVideo::encodeFrame( const Frame& sourceFrame, DataStream& codedFrame
frame->width = codecContext->width;
frame->height = codecContext->height;
frame->format = codecContext->pix_fmt;
avpicture_fill( (AVPicture*)frame, const_cast< unsigned char * >( sourceImageFrame.getPtr() ), codecContext->pix_fmt, codecContext->width, codecContext->height );
avpicture_fill( (AVPicture*)frame, sourceImageFrame.getPtr(), codecContext->pix_fmt, codecContext->width, codecContext->height );

AVPacket packet;
av_init_packet( &packet );
Expand All @@ -80,12 +80,7 @@ bool OutputVideo::encodeFrame( const Frame& sourceFrame, DataStream& codedFrame
if( ( codecContext->coded_frame ) &&
( codecContext->coded_frame->pts != (int)AV_NOPTS_VALUE ) )
{
// why need to do that ?
//packet.pts = av_rescale_q( codecContext->coded_frame->pts, codecContext->time_base, codecContext->time_base );

//std::cout << "pts with rescale " << (int)packet.pts << std::endl;
packet.pts = codecContext->coded_frame->pts;
//std::cout << "pts without rescale " << (int)packet.pts << std::endl;
}

if( codecContext->coded_frame &&
Expand All @@ -94,7 +89,6 @@ bool OutputVideo::encodeFrame( const Frame& sourceFrame, DataStream& codedFrame
packet.flags |= AV_PKT_FLAG_KEY;
}


#if LIBAVCODEC_VERSION_MAJOR > 53
int gotPacket = 0;
int ret = avcodec_encode_video2( codecContext, &packet, frame, &gotPacket );
Expand Down Expand Up @@ -145,7 +139,6 @@ bool OutputVideo::encodeFrame( const Frame& sourceFrame, DataStream& codedFrame
return ret == 0;
}


bool OutputVideo::encodeFrame( DataStream& codedFrame )
{
AVCodecContext* codecContext = _videoDesc.getCodecContext();
Expand Down
3 changes: 0 additions & 3 deletions src/AvTranscoder/EssenceStructures/VideoFrame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ class AvExport VideoFrame : public Frame
m_dataBuffer = DataBuffer( ref.getDataSize(), 0 );
}

virtual ~VideoFrame()
{};

const VideoFrameDesc& desc() const { return m_videoFrameDesc; }

private:
Expand Down
6 changes: 3 additions & 3 deletions src/AvTranscoder/EssenceTransform/VideoEssenceTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ void VideoEssenceTransform::convert( const Frame& srcFrame, Frame& dstFrame )

for( size_t plane = 0; plane < MAX_SWS_PLANE; ++plane )
{
_srcData.at( plane ) = (uint8_t*) const_cast< unsigned char* >( src.getPtr() + _srcOffsets.at( plane ) );
_srcData.at( plane ) = (uint8_t*) src.getPtr() + _srcOffsets.at( plane );
_dstData.at( plane ) = (uint8_t*) dst.getPtr() + _dstOffsets.at( plane );
}

if( !_imageConvertContext )
if( ! _imageConvertContext )
{
throw std::runtime_error( "unknown color convert context" );
}
Expand All @@ -112,7 +112,7 @@ void VideoEssenceTransform::convert( const Frame& srcFrame, Frame& dstFrame )
&_srcData[0], &_srcLineSize[0], 0, src.desc().getHeight(),
&_dstData[0], &_dstLineSize[0] );

if( ret != (int) src.desc().getHeight() )
if( ret != (int) dst.desc().getHeight() )
throw std::runtime_error( "error in color converter" );
}

Expand Down