Skip to content

Commit 6b15e7b

Browse files
Conflicts: src/AvTranscoder/Transcoder/StreamTranscoder.cpp src/AvTranscoder/Transcoder/StreamTranscoder.hpp
2 parents e211239 + 38b7c87 commit 6b15e7b

File tree

19 files changed

+647
-254
lines changed

19 files changed

+647
-254
lines changed

SConstruct

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ envPy.Append(
162162
if mymode == "release":
163163
env.Append(CCFLAGS = ['-O3'])
164164
if mymode == "debug":
165-
env.Append(CCFLAGS = ['-pg'])
165+
env.Append(CCFLAGS = ['-pg', '-g'])
166166

167167
Export( "env" )
168168
Export( "envJava" )

app/avMeta/avMeta.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ int main( int argc, char** argv )
1717
input.analyse( p, avtranscoder::InputFile::eAnalyseLevelFull );
1818

1919
// a simply metadata display
20-
displayMetadatas( input );
20+
std::cout << input << std::endl;
2121
}

app/avplay/AvReader.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class AvReader : public Reader
9898

9999
void printMetadatas()
100100
{
101-
displayMetadatas( m_inputFile );
101+
std::cout << m_inputFile << std::endl;
102102
}
103103

104104
private:

app/genericProcessor/genericProcessor.cpp

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
#include <sstream>
99
#include <cstdlib>
1010

11+
static const size_t dummyWidth = 1920;
12+
static const size_t dummyHeight = 1080;
13+
static const std::string dummyPixelFormat = "yuv420p";
14+
static const std::string dummyVideoCodec = "mpeg2video";
15+
static const std::string dummyAudioCodec = "pcm_s16le";
16+
1117
// bool verbose = false;
1218
bool verbose = true;
1319

@@ -47,9 +53,27 @@ void parseConfigFile( const std::string& configFilename, avtranscoder::Transcode
4753
std::cout << ( transcodeProfile.length() ? transcodeProfile : "rewrap" );
4854
std::cout << std::endl;
4955
}
50-
51-
transcoder.add( filename, streamIndex, subStreamIndex, transcodeProfile );
52-
56+
57+
// dummy stream, need a CodedDesc (audio or video)
58+
if( ! filename.length() )
59+
{
60+
// video
61+
avtranscoder::VideoFrameDesc imageDesc;
62+
imageDesc.setWidth( dummyWidth );
63+
imageDesc.setHeight( dummyHeight );
64+
imageDesc.setDar( dummyWidth, dummyHeight );
65+
avtranscoder::Pixel inputPixel( dummyPixelFormat );
66+
imageDesc.setPixel( inputPixel );
67+
68+
avtranscoder::VideoDesc inputVideoDesc( dummyVideoCodec );
69+
inputVideoDesc.setImageParameters( imageDesc );
70+
71+
transcoder.add( filename, streamIndex, subStreamIndex, transcodeProfile, inputVideoDesc );
72+
}
73+
else
74+
{
75+
transcoder.add( filename, streamIndex, subStreamIndex, transcodeProfile );
76+
}
5377
}
5478
}
5579
}
@@ -84,12 +108,16 @@ int main( int argc, char** argv )
84108
avtranscoder::OutputFile outputFile( argv[2] );
85109

86110
avtranscoder::Transcoder transcoder( outputFile );
87-
transcoder.setVerbose( verbose );
88111

89112
if( verbose )
90113
std::cout << "parse config file" << std::endl;
91114
parseConfigFile( inputConfigFile, transcoder, profiles );
92115

116+
// set verbose of all stream
117+
transcoder.setVerbose( verbose );
118+
transcoder.setProcessMethod( avtranscoder::eProcessMethodInfinity );
119+
//transcoder.setOutputFps( 12 );
120+
93121
if( verbose )
94122
std::cout << "start Transcode" << std::endl;
95123

src/AvTranscoder/CodedStructures/CodedDesc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,18 @@ void CodedDesc::initCodecContext( )
5757
{
5858
if( m_codec == NULL )
5959
{
60-
throw std::runtime_error( "unknown audio codec" );
60+
throw std::runtime_error( "unknown codec" );
6161
}
6262

6363
if( ( m_codecContext = avcodec_alloc_context3( m_codec ) ) == NULL )
6464
{
65-
throw std::runtime_error( "unable to create context for audio context" );
65+
throw std::runtime_error( "unable to create context for context" );
6666
}
6767

6868
// Set default codec parameters
6969
if( avcodec_get_context_defaults3( m_codecContext, m_codec ) != 0 )
7070
{
71-
throw std::runtime_error( "unable to find audio codec default values" );
71+
throw std::runtime_error( "unable to find codec default values" );
7272
}
7373
}
7474

src/AvTranscoder/EssenceStream/DummyVideo.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
#include "DummyVideo.hpp"
22

3+
#include <AvTranscoder/EssenceTransform/VideoEssenceTransform.hpp>
4+
35
namespace avtranscoder
46
{
57

68
DummyVideo::DummyVideo( )
79
: InputEssence( )
810
, _inputFrame( NULL )
11+
, _videoDesc()
12+
, _videoFrameDesc()
913
, _numberOfView( 1 )
1014
{
1115
}
@@ -32,12 +36,27 @@ void DummyVideo::setFrame( Frame& inputFrame )
3236

3337
bool DummyVideo::readNextFrame( Frame& frameBuffer )
3438
{
35-
frameBuffer.getBuffer().resize( _videoFrameDesc.getDataSize() );
36-
3739
if( ! _inputFrame )
3840
{
39-
int fillChar = 0; // fill images with black
40-
memset( frameBuffer.getPtr(), fillChar, frameBuffer.getSize() );
41+
// @todo support PAL (0 to 255) and NTFC (16 to 235)
42+
int fillChar = 0;
43+
44+
if( frameBuffer.getSize() != _videoFrameDesc.getDataSize() )
45+
frameBuffer.getBuffer().resize( _videoFrameDesc.getDataSize() );
46+
47+
VideoFrameDesc desc( _videoDesc.getVideoFrameDesc() );
48+
Pixel rgbPixel;
49+
rgbPixel.setColorComponents( eComponentRgb );
50+
rgbPixel.setPlanar( false );
51+
desc.setPixel( rgbPixel );
52+
53+
VideoFrame intermediateBuffer( desc );
54+
intermediateBuffer.getBuffer().resize( _videoFrameDesc.getDataSize() );
55+
memset( intermediateBuffer.getPtr(), fillChar, _videoFrameDesc.getDataSize() );
56+
57+
VideoEssenceTransform videoEssenceTransform;
58+
videoEssenceTransform.convert( intermediateBuffer, frameBuffer );
59+
4160
return true;
4261
}
4362

src/AvTranscoder/EssenceStream/OutputVideo.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,7 @@ bool OutputVideo::encodeFrame( const Frame& sourceFrame, DataStream& codedFrame
8080
if( ( codecContext->coded_frame ) &&
8181
( codecContext->coded_frame->pts != (int)AV_NOPTS_VALUE ) )
8282
{
83-
// why need to do that ?
84-
//packet.pts = av_rescale_q( codecContext->coded_frame->pts, codecContext->time_base, codecContext->time_base );
85-
86-
//std::cout << "pts with rescale " << (int)packet.pts << std::endl;
8783
packet.pts = codecContext->coded_frame->pts;
88-
//std::cout << "pts without rescale " << (int)packet.pts << std::endl;
8984
}
9085

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

97-
9892
#if LIBAVCODEC_VERSION_MAJOR > 53
9993
int gotPacket = 0;
10094
int ret = avcodec_encode_video2( codecContext, &packet, frame, &gotPacket );
@@ -145,7 +139,6 @@ bool OutputVideo::encodeFrame( const Frame& sourceFrame, DataStream& codedFrame
145139
return ret == 0;
146140
}
147141

148-
149142
bool OutputVideo::encodeFrame( DataStream& codedFrame )
150143
{
151144
AVCodecContext* codecContext = _videoDesc.getCodecContext();

src/AvTranscoder/EssenceStructures/Pixel.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ extern "C" {
1010
#include <libavutil/pixdesc.h>
1111
}
1212

13+
#include <stdexcept>
14+
1315
namespace avtranscoder
1416
{
1517

@@ -65,7 +67,13 @@ AVPixelFormat Pixel::findPixel() const
6567

6668
void Pixel::init( const AVPixelFormat avPixelFormat )
6769
{
68-
const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get( avPixelFormat );
70+
const AVPixFmtDescriptor* pix_desc = av_pix_fmt_desc_get( avPixelFormat );
71+
72+
if( ! pix_desc )
73+
{
74+
throw std::runtime_error( "unable to find pixel format." );
75+
}
76+
6977
setBitsPerPixel ( av_get_bits_per_pixel( pix_desc ) );
7078
setBigEndian ( pix_desc->flags & PIX_FMT_BE );
7179
setComponents ( pix_desc->nb_components );

src/AvTranscoder/EssenceStructures/VideoFrame.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ class AvExport VideoFrame : public Frame
9797
m_dataBuffer = DataBuffer( ref.getDataSize(), 0 );
9898
}
9999

100-
virtual ~VideoFrame()
101-
{};
102-
103100
const VideoFrameDesc& desc() const { return m_videoFrameDesc; }
104101

105102
private:

src/AvTranscoder/EssenceTransform/VideoEssenceTransform.cpp

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ VideoEssenceTransform::VideoEssenceTransform()
3434
, _srcOffsets ( MAX_SWS_PLANE, 0 )
3535
, _dstOffsets ( MAX_SWS_PLANE, 0 )
3636
, _isInit ( false )
37+
, _verbose( false )
3738
{
3839
}
3940

@@ -60,6 +61,34 @@ bool VideoEssenceTransform::init( const Frame& srcFrame, const Frame& dstFrame )
6061
av_image_fill_linesizes( &_srcLineSize[0], src.desc().getPixelDesc().findPixel(), src.desc().getWidth() );
6162
av_image_fill_linesizes( &_dstLineSize[0], dst.desc().getPixelDesc().findPixel(), dst.desc().getWidth() );
6263

64+
if( _verbose )
65+
{
66+
std::clog << "video conversion from ";
67+
const char* pixFmt;
68+
pixFmt = av_get_pix_fmt_name( src.desc().getPixelDesc().findPixel() );
69+
std::clog << ( pixFmt != NULL ? pixFmt : "None" ) << " to ";
70+
pixFmt = av_get_pix_fmt_name( dst.desc().getPixelDesc().findPixel() );
71+
std::clog << ( pixFmt != NULL ? pixFmt : "None" ) << std::endl;
72+
73+
std::clog << "source, width = " << src.desc().getWidth() << std::endl;
74+
std::clog << "source, height = " << src.desc().getHeight() << std::endl;
75+
76+
std::clog << "source, lineSize:" << std::endl;
77+
std::clog << "[0] = " << _srcLineSize[0] << std::endl;
78+
std::clog << "[1] = " << _srcLineSize[1] << std::endl;
79+
std::clog << "[2] = " << _srcLineSize[2] << std::endl;
80+
std::clog << "[3] = " << _srcLineSize[3] << std::endl;
81+
82+
std::clog << "destination, width = " << dst.desc().getWidth() << std::endl;
83+
std::clog << "destination, height = " << dst.desc().getHeight() << std::endl;
84+
85+
std::clog << "destination, lineSize:" << std::endl;
86+
std::clog << "[0] = " << _dstLineSize[0] << std::endl;
87+
std::clog << "[1] = " << _dstLineSize[1] << std::endl;
88+
std::clog << "[2] = " << _dstLineSize[2] << std::endl;
89+
std::clog << "[3] = " << _dstLineSize[3] << std::endl;
90+
}
91+
6392
size_t cumulSrcOffset = 0;
6493
size_t cumulDstOffset = 0;
6594

@@ -99,20 +128,47 @@ void VideoEssenceTransform::convert( const Frame& srcFrame, Frame& dstFrame )
99128

100129
for( size_t plane = 0; plane < MAX_SWS_PLANE; ++plane )
101130
{
102-
_srcData.at( plane ) = (uint8_t*) const_cast< unsigned char* >( src.getPtr() + _srcOffsets.at( plane ) );
131+
_srcData.at( plane ) = (uint8_t*) src.getPtr() + _srcOffsets.at( plane );
103132
_dstData.at( plane ) = (uint8_t*) dst.getPtr() + _dstOffsets.at( plane );
104133
}
105134

106-
if( !_imageConvertContext )
135+
if( ! _imageConvertContext )
107136
{
108137
throw std::runtime_error( "unknown color convert context" );
109138
}
110139

140+
if( _verbose )
141+
{
142+
std::clog << "source, offset:" << std::endl;
143+
std::clog << "[0] = " << &_srcOffsets[0] << std::endl;
144+
std::clog << "[1] = " << &_srcOffsets[1] << std::endl;
145+
std::clog << "[2] = " << &_srcOffsets[2] << std::endl;
146+
std::clog << "[3] = " << &_srcOffsets[3] << std::endl;
147+
148+
std::clog << "source, slice:" << std::endl;
149+
std::clog << "[0] = " << &_srcData[0] << std::endl;
150+
std::clog << "[1] = " << &_srcData[1] << std::endl;
151+
std::clog << "[2] = " << &_srcData[2] << std::endl;
152+
std::clog << "[3] = " << &_srcData[3] << std::endl;
153+
154+
std::clog << "destination, offset:" << std::endl;
155+
std::clog << "[0] = " << &_dstOffsets[0] << std::endl;
156+
std::clog << "[1] = " << &_dstOffsets[1] << std::endl;
157+
std::clog << "[2] = " << &_dstOffsets[2] << std::endl;
158+
std::clog << "[3] = " << &_dstOffsets[3] << std::endl;
159+
160+
std::clog << "destination, slice:" << std::endl;
161+
std::clog << "[0] = " << &_dstData[0] << std::endl;
162+
std::clog << "[1] = " << &_dstData[1] << std::endl;
163+
std::clog << "[2] = " << &_dstData[2] << std::endl;
164+
std::clog << "[3] = " << &_dstData[3] << std::endl;
165+
}
166+
111167
int ret = sws_scale( _imageConvertContext,
112168
&_srcData[0], &_srcLineSize[0], 0, src.desc().getHeight(),
113169
&_dstData[0], &_dstLineSize[0] );
114170

115-
if( ret != (int) src.desc().getHeight() )
171+
if( ret != (int) dst.desc().getHeight() )
116172
throw std::runtime_error( "error in color converter" );
117173
}
118174

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy