Skip to content

Commit 91851c2

Browse files
adding missing Datas Structures
1 parent d40702c commit 91851c2

File tree

3 files changed

+118
-0
lines changed

3 files changed

+118
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include "Pixel.hpp"
2+
3+
extern "C" {
4+
#ifndef __STDC_CONSTANT_MACROS
5+
#define __STDC_CONSTANT_MACROS
6+
#endif
7+
#include <libavutil/pixfmt.h>
8+
#include <libswscale/swscale.h>
9+
#include <libavutil/imgutils.h>
10+
#include <libavutil/pixdesc.h>
11+
}
12+
13+
namespace avtranscoder
14+
{
15+
16+
bool Pixel::asCorrectColorComponents( const AVPixFmtDescriptor* pix_desc, const EComponentType componentType )
17+
{
18+
if( componentType == eComponentRgb && pix_desc->flags & PIX_FMT_RGB )
19+
return true;
20+
if( ( componentType != eComponentRgb ) && ! ( pix_desc->flags & PIX_FMT_RGB ) )
21+
return true;
22+
return false;
23+
}
24+
25+
bool Pixel::asCorrectSubsampling( const AVPixFmtDescriptor* pix_desc, const ESubsamplingType subsamplingType )
26+
{
27+
switch( subsamplingType )
28+
{
29+
case eSubsamplingNone :
30+
return ( pix_desc->log2_chroma_w == false ) &&
31+
( pix_desc->log2_chroma_h == false );
32+
case eSubsampling422 :
33+
return ( pix_desc->log2_chroma_w == true ) &&
34+
( pix_desc->log2_chroma_h == false );
35+
case eSubsampling420 :
36+
return ( pix_desc->log2_chroma_w == true ) &&
37+
( pix_desc->log2_chroma_h == true );
38+
}
39+
return false;
40+
}
41+
42+
void Pixel::findMatchingPixel()
43+
{
44+
const AVPixFmtDescriptor *pix_desc = NULL;
45+
while( ( pix_desc = av_pix_fmt_desc_next( pix_desc ) ) )
46+
{
47+
//std::cout << pix_desc->name << std::endl;
48+
// enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id( pix_desc );
49+
if( m_components == (int) pix_desc->nb_components &&
50+
m_bitDepth == (size_t) av_get_bits_per_pixel( pix_desc ) &&
51+
m_endianess == ( pix_desc->flags & PIX_FMT_BE ) &&
52+
m_outWithAlpha == ( pix_desc->flags & PIX_FMT_ALPHA ) &&
53+
asCorrectColorComponents( pix_desc, m_componentType ) &&
54+
asCorrectSubsampling( pix_desc, m_subsamplingType ) )
55+
{
56+
//std::cout << "select : " << pix_desc->name << std::endl;
57+
m_pixel = av_pix_fmt_desc_get_id( pix_desc );
58+
return;
59+
}
60+
}
61+
}
62+
63+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include "VideoStream.hpp"
2+
3+
namespace avtranscoder
4+
{
5+
6+
void VideoStream::setCodecFromName( const std::string& codecName )
7+
{
8+
AVCodec* codec = avcodec_find_encoder_by_name( codecName.c_str() );
9+
m_codecId = codec->id;
10+
}
11+
12+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifndef _AV_TRANSCODER_DATA_VIDEO_STREAM_HPP_
2+
#define _AV_TRANSCODER_DATA_VIDEO_STREAM_HPP_
3+
4+
#include "Image.hpp"
5+
#include <string>
6+
7+
extern "C" {
8+
#ifndef __STDC_CONSTANT_MACROS
9+
#define __STDC_CONSTANT_MACROS
10+
#endif
11+
#ifndef INT64_C
12+
#define INT64_C(c) (c ## LL)
13+
#define UINT64_C(c) (c ## ULL)
14+
#endif
15+
#include <libavcodec/avcodec.h>
16+
}
17+
18+
namespace avtranscoder
19+
{
20+
21+
class VideoStream
22+
{
23+
public:
24+
VideoStream(){};
25+
26+
void setCodecFromName( const std::string& codecName );
27+
28+
void setCodecFromID( const AVCodecID codecId ) { m_codecId = codecId; }
29+
30+
void setParametersFromImage( const Image& image );
31+
32+
void setBitrate( const size_t bitRate ) { m_bitRate = bitRate; }
33+
34+
AVCodecID getCodecId() const { return m_codecId; }
35+
36+
private:
37+
AVCodecID m_codecId;
38+
size_t m_bitRate;
39+
};
40+
41+
}
42+
43+
#endif

0 commit comments

Comments
 (0)