Skip to content

Commit f9e428d

Browse files
committed
Context: split Context / FormatContext / CodecContext into separate files
* New files: FormatContext and CodecContext. * Rename context file to Context.
1 parent 881de92 commit f9e428d

File tree

13 files changed

+109
-67
lines changed

13 files changed

+109
-67
lines changed

app/optionChecker/optionChecker.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <AvTranscoder/util.hpp>
2-
#include <AvTranscoder/option/context.hpp>
2+
#include <AvTranscoder/option/Context.hpp>
3+
#include <AvTranscoder/option/CodecContext.hpp>
34
#include <AvTranscoder/option/Option.hpp>
45
#include <AvTranscoder/file/InputFile.hpp>
56

src/AvTranscoder/essenceStream/AvInputVideo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "AvInputVideo.hpp"
22

3-
#include <AvTranscoder/option/context.hpp>
3+
#include <AvTranscoder/option/Context.hpp>
44
#include <AvTranscoder/codedStream/AvInputStream.hpp>
55
#include <AvTranscoder/frame/VideoFrame.hpp>
66

src/AvTranscoder/essenceStream/AvOutputAudio.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "AvOutputAudio.hpp"
22

3-
#include <AvTranscoder/option/context.hpp>
3+
#include <AvTranscoder/option/Context.hpp>
44

55
extern "C" {
66
#include <libavcodec/avcodec.h>

src/AvTranscoder/essenceStream/AvOutputVideo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "AvOutputVideo.hpp"
22

3-
#include <AvTranscoder/option/context.hpp>
3+
#include <AvTranscoder/option/Context.hpp>
44

55
extern "C" {
66
#include <libavcodec/avcodec.h>

src/AvTranscoder/file/InputFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "InputFile.hpp"
22

3-
#include <AvTranscoder/option/context.hpp>
3+
#include <AvTranscoder/option/Context.hpp>
44
#include <AvTranscoder/mediaProperty/VideoStreamProperty.hpp>
55
#include <AvTranscoder/mediaProperty/AudioStreamProperty.hpp>
66
#include <AvTranscoder/mediaProperty/DataStreamProperty.hpp>

src/AvTranscoder/file/OutputFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "OutputFile.hpp"
22

3-
#include <AvTranscoder/option/context.hpp>
3+
#include <AvTranscoder/option/Context.hpp>
44

55
extern "C" {
66
#include <libavcodec/avcodec.h>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "CodecContext.hpp"
2+
3+
extern "C" {
4+
#include <libavcodec/avcodec.h>
5+
}
6+
7+
namespace avtranscoder
8+
{
9+
10+
CodecContext::CodecContext( int req_flags )
11+
: _avCodecContext( NULL )
12+
{
13+
_avCodecContext = avcodec_alloc_context3( NULL );
14+
loadOptions( _avCodecContext, req_flags );
15+
}
16+
17+
CodecContext::~CodecContext()
18+
{
19+
avcodec_close( _avCodecContext );
20+
av_free( _avCodecContext );
21+
}
22+
23+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef _AV_TRANSCODER_CODEC_CONTEXT_HPP_
2+
#define _AV_TRANSCODER_CODEC_CONTEXT_HPP_
3+
4+
#include "Context.hpp"
5+
6+
struct AVCodecContext;
7+
8+
namespace avtranscoder
9+
{
10+
11+
/**
12+
* @brief Wrapper of an AVCodecContext.
13+
* @note The AVCodecContext is allocated and free by the class. It is not the case of the base class.
14+
*/
15+
class CodecContext : public Context
16+
{
17+
public:
18+
CodecContext( int req_flags = 0 );
19+
~CodecContext();
20+
21+
private:
22+
AVCodecContext* _avCodecContext;
23+
};
24+
25+
}
26+
27+
#endif

src/AvTranscoder/option/context.cpp renamed to src/AvTranscoder/option/Context.cpp

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
#include "context.hpp"
1+
#include "Context.hpp"
22

33
extern "C" {
4-
#include <libavformat/avformat.h>
5-
#include <libavcodec/avcodec.h>
64
#include <libavutil/mem.h>
75
#include <libavutil/opt.h>
86
}
@@ -83,7 +81,7 @@ void Context::loadOptions( void* av_class, int req_flags )
8381
parentFound = true;
8482
break;
8583
}
86-
}
84+
}
8785

8886
if( ! parentFound )
8987
{
@@ -92,29 +90,4 @@ void Context::loadOptions( void* av_class, int req_flags )
9290
}
9391
}
9492

95-
FormatContext::FormatContext( int req_flags )
96-
: _avFormatContext( NULL )
97-
{
98-
_avFormatContext = avformat_alloc_context();
99-
loadOptions( _avFormatContext, req_flags );
100-
}
101-
102-
FormatContext::~FormatContext()
103-
{
104-
avformat_free_context( _avFormatContext );
105-
}
106-
107-
CodecContext::CodecContext( int req_flags )
108-
: _avCodecContext( NULL )
109-
{
110-
_avCodecContext = avcodec_alloc_context3( NULL );
111-
loadOptions( _avCodecContext, req_flags );
112-
}
113-
114-
CodecContext::~CodecContext()
115-
{
116-
avcodec_close( _avCodecContext );
117-
av_free( _avCodecContext );
118-
}
119-
12093
}

src/AvTranscoder/option/context.hpp renamed to src/AvTranscoder/option/Context.hpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
#include <string>
99
#include <map>
1010

11-
struct AVFormatContext;
12-
struct AVCodecContext;
13-
1411
namespace avtranscoder
1512
{
1613

@@ -53,34 +50,6 @@ class Context
5350
void* _avContext; ///< Has link (no ownership)
5451
};
5552

56-
/**
57-
* @brief Wrapper of an AVFormatContext.
58-
* @note The AVFormatContext is allocated and free by the class. It is not the case of the base class.
59-
*/
60-
class FormatContext : public Context
61-
{
62-
public:
63-
FormatContext( int req_flags = 0 );
64-
~FormatContext();
65-
66-
private:
67-
AVFormatContext* _avFormatContext;
68-
};
69-
70-
/**
71-
* @brief Wrapper of an AVCodecContext.
72-
* @note The AVCodecContext is allocated and free by the class. It is not the case of the base class.
73-
*/
74-
class CodecContext : public Context
75-
{
76-
public:
77-
CodecContext( int req_flags = 0 );
78-
~CodecContext();
79-
80-
private:
81-
AVCodecContext* _avCodecContext;
82-
};
83-
8453
}
8554

8655
#endif
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "FormatContext.hpp"
2+
3+
extern "C" {
4+
#include <libavformat/avformat.h>
5+
}
6+
7+
namespace avtranscoder
8+
{
9+
10+
FormatContext::FormatContext( int req_flags )
11+
: _avFormatContext( NULL )
12+
{
13+
_avFormatContext = avformat_alloc_context();
14+
loadOptions( _avFormatContext, req_flags );
15+
}
16+
17+
FormatContext::~FormatContext()
18+
{
19+
avformat_free_context( _avFormatContext );
20+
}
21+
22+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef _AV_TRANSCODER_FORMAT_CONTEXT_HPP_
2+
#define _AV_TRANSCODER_FORMAT_CONTEXT_HPP_
3+
4+
#include "Context.hpp"
5+
6+
struct AVFormatContext;
7+
8+
namespace avtranscoder
9+
{
10+
11+
/**
12+
* @brief Wrapper of an AVFormatContext.
13+
* @note The AVFormatContext is allocated and free by the class. It is not the case of the base class.
14+
*/
15+
class FormatContext : public Context
16+
{
17+
public:
18+
FormatContext( int req_flags = 0 );
19+
~FormatContext();
20+
21+
private:
22+
AVFormatContext* _avFormatContext;
23+
};
24+
25+
}
26+
27+
#endif

src/AvTranscoder/util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "util.hpp"
22

3-
#include <AvTranscoder/option/context.hpp>
3+
#include <AvTranscoder/option/Context.hpp>
44
#include <AvTranscoder/option/Option.hpp>
55

66
extern "C" {

0 commit comments

Comments
 (0)