Skip to content

Commit 668109e

Browse files
author
Clement Champetier
committed
Move functions from common to util
1 parent b7899b1 commit 668109e

File tree

11 files changed

+46
-32
lines changed

11 files changed

+46
-32
lines changed

src/AvTranscoder/codec/ICodec.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#include <AvTranscoder/common.hpp>
55
#include <AvTranscoder/Option.hpp>
66

7+
extern "C" {
8+
#include <libavcodec/avcodec.h>
9+
}
10+
711
#include <string>
812

913
namespace avtranscoder

src/AvTranscoder/common.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#include "common.hpp"
22

33
extern "C" {
4-
#include <libavcodec/avcodec.h>
54
#include <libavformat/avformat.h>
6-
#include <libavutil/error.h>
75
}
86

97
namespace avtranscoder
@@ -19,25 +17,4 @@ void setLogLevel( const int level )
1917
av_log_set_level( level );
2018
}
2119

22-
std::string getFormat( const std::string& filename )
23-
{
24-
std::string format( "" );
25-
26-
AVOutputFormat* avOutputFormat = av_guess_format( NULL, filename.c_str(), NULL);
27-
if( avOutputFormat )
28-
{
29-
if( avOutputFormat->name )
30-
format = std::string( avOutputFormat->name );
31-
}
32-
33-
return format;
34-
}
35-
36-
bool matchFormat( const std::string& format, const std::string& filename )
37-
{
38-
AVOutputFormat* avOutputFormat = av_guess_format( format.c_str(), filename.c_str(), NULL);
39-
return avOutputFormat != NULL;
40-
}
41-
42-
4320
}

src/AvTranscoder/common.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ extern "C" {
99
#define INT64_C(c) (c ## LL)
1010
#define UINT64_C(c) (c ## ULL)
1111
#endif
12-
#include <libavformat/version.h>
1312
#include <libavcodec/version.h>
14-
#include <libavcodec/avcodec.h>
13+
#include <libavutil/error.h>
1514
#include <libavutil/rational.h>
1615
#include <libavutil/log.h>
1716
}
@@ -65,9 +64,6 @@ void AvExport preloadCodecsAndFormats();
6564
*/
6665
void AvExport setLogLevel( const int level );
6766

68-
std::string AvExport getFormat( const std::string& filename );
69-
bool AvExport matchFormat( const std::string& format, const std::string& filename );
70-
7167
}
7268

7369
#endif

src/AvTranscoder/file/OutputFile.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "OutputFile.hpp"
22

3+
#include <AvTranscoder/util.hpp>
4+
35
#include <iostream>
46
#include <stdexcept>
57

src/AvTranscoder/frame/VideoFrame.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <AvTranscoder/ProfileLoader.hpp>
66

77
extern "C" {
8+
#include <libavcodec/avcodec.h>
89
#include <libavutil/pixfmt.h>
910
#include <libavutil/pixdesc.h>
1011
}

src/AvTranscoder/mediaProperty/VideoProperties.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ extern "C" {
88

99
#include <stdexcept>
1010
#include <iomanip>
11+
#include <sstream>
1112

1213
#ifdef _MSC_VER
1314
#include <float.h>

src/AvTranscoder/mediaProperty/VideoProperties.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#ifndef _AV_TRANSCODER_MEDIA_PROPERTY_VIDEO_PROPERTIES_HPP
22
#define _AV_TRANSCODER_MEDIA_PROPERTY_VIDEO_PROPERTIES_HPP
33

4-
#include <AvTranscoder/common.hpp>
54
#include "PixelProperties.hpp"
5+
6+
#include <AvTranscoder/common.hpp>
67
#include <AvTranscoder/mediaProperty/util.hpp>
78
#include <AvTranscoder/file/util.hpp>
89
#include <AvTranscoder/file/FormatContext.hpp>

src/AvTranscoder/mediaProperty/util.cpp

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

3-
extern "C" {
4-
#include <libavutil/dict.h>
5-
}
3+
#include <sstream>
64

75
namespace avtranscoder
86
{

src/AvTranscoder/mediaProperty/util.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
#include <AvTranscoder/common.hpp>
55

6+
extern "C" {
7+
#include <libavutil/dict.h>
8+
}
9+
610
#include <vector>
711
#include <utility>
812
#include <string>

src/AvTranscoder/util.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,26 @@ extern "C" {
99
namespace avtranscoder
1010
{
1111

12+
std::string getFormat( const std::string& filename )
13+
{
14+
std::string format( "" );
15+
16+
AVOutputFormat* avOutputFormat = av_guess_format( NULL, filename.c_str(), NULL);
17+
if( avOutputFormat )
18+
{
19+
if( avOutputFormat->name )
20+
format = std::string( avOutputFormat->name );
21+
}
22+
23+
return format;
24+
}
25+
26+
bool matchFormat( const std::string& format, const std::string& filename )
27+
{
28+
AVOutputFormat* avOutputFormat = av_guess_format( format.c_str(), filename.c_str(), NULL);
29+
return avOutputFormat != NULL;
30+
}
31+
1232
std::vector<std::string> getPixelFormats( const std::string& videoCodecName )
1333
{
1434
std::vector<std::string> pixelFormats;

src/AvTranscoder/util.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ namespace avtranscoder
1818

1919
typedef std::map<std::string, OptionArray> OptionArrayMap;
2020

21+
/**
22+
* @brief Get format name from a given filename
23+
*/
24+
std::string AvExport getFormat( const std::string& filename );
25+
26+
/**
27+
* @brief Check if a format name corresponds to the format of a given filename
28+
*/
29+
bool AvExport matchFormat( const std::string& format, const std::string& filename );
30+
2131
/**
2232
* @brief Get pixel format supported by a video codec.
2333
* @param videoCodecName: the video codec name (empty if not indicated, and so get all pixel formats supported by all video codecs).

0 commit comments

Comments
 (0)