Skip to content

Commit 13313d2

Browse files
authored
Merge pull request #163 from h4tr3d/fetch_content_test
Fetch content, Frame SideData and others - All includes with avcpp/ prefixed now - FetchContent well work for me now - Added Frame SideData support (basic) - Added iterators over streams for the FormatContext - Methods that return data pointer via std::span() now has name ::span() - Added AVBufferRef wrapper - Move a lot of code from the template Frame to the non-template basic class FrameCommon - SideData (both packets and frames) access via index now has name sideDataIndex(idx) - Static library builds with -fPIC by default, can be control via -DAV_ENABLE_STATIC_PIC=On/Off - Added more tests
2 parents 819f3e8 + 25b917e commit 13313d2

91 files changed

Lines changed: 2575 additions & 1118 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
1414
set(FFMPEG_PKG_CONFIG_SUFFIX "" CACHE STRING "This suffix uses for FFmpeg component names searches by pkg-config")
1515
set(AV_ENABLE_STATIC On CACHE BOOL "Enable static library build (On)")
1616
set(AV_ENABLE_SHARED On CACHE BOOL "Enable shared library build (On)")
17+
set(AV_ENABLE_STATIC_PIC On CACHE BOOL "Enable Position Independent Code build for the statis library")
1718
set(AV_BUILD_EXAMPLES On CACHE BOOL "Build example applications (On)")
1819
set(AV_BUILD_TESTS On CACHE BOOL "Build tests (On)")
1920
option(AV_DISABLE_AVFORMAT "Disable libavformat usage. Also turns off: AVFILTER, AVDEVICE" Off)

example/api2-samples/api2-decode-audio.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
#include <memory>
55
#include <functional>
66

7-
#include "av.h"
8-
#include "ffmpeg.h"
9-
#include "codec.h"
10-
#include "packet.h"
11-
#include "videorescaler.h"
12-
#include "audioresampler.h"
13-
#include "avutils.h"
7+
#include "avcpp/av.h"
8+
#include "avcpp/ffmpeg.h"
9+
#include "avcpp/codec.h"
10+
#include "avcpp/packet.h"
11+
#include "avcpp/videorescaler.h"
12+
#include "avcpp/audioresampler.h"
13+
#include "avcpp/avutils.h"
1414

1515
// API2
16-
#include "format.h"
17-
#include "formatcontext.h"
18-
#include "codec.h"
19-
#include "codeccontext.h"
16+
#include "avcpp/format.h"
17+
#include "avcpp/formatcontext.h"
18+
#include "avcpp/codec.h"
19+
#include "avcpp/codeccontext.h"
2020

2121
using namespace std;
2222
using namespace av;

example/api2-samples/api2-decode-encode-audio.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
#include <memory>
55
#include <functional>
66

7-
#include "av.h"
8-
#include "ffmpeg.h"
9-
#include "codec.h"
10-
#include "packet.h"
11-
#include "videorescaler.h"
12-
#include "audioresampler.h"
13-
#include "avutils.h"
7+
#include "avcpp/av.h"
8+
#include "avcpp/ffmpeg.h"
9+
#include "avcpp/codec.h"
10+
#include "avcpp/packet.h"
11+
#include "avcpp/videorescaler.h"
12+
#include "avcpp/audioresampler.h"
13+
#include "avcpp/avutils.h"
1414

1515
// API2
16-
#include "format.h"
17-
#include "formatcontext.h"
18-
#include "codec.h"
19-
#include "codeccontext.h"
16+
#include "avcpp/format.h"
17+
#include "avcpp/formatcontext.h"
18+
#include "avcpp/codec.h"
19+
#include "avcpp/codeccontext.h"
2020

2121
using namespace std;
2222
using namespace av;

example/api2-samples/api2-decode-encode-video.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
#include <memory>
55
#include <functional>
66

7-
#include "av.h"
8-
#include "ffmpeg.h"
9-
#include "codec.h"
10-
#include "packet.h"
11-
#include "videorescaler.h"
12-
#include "audioresampler.h"
13-
#include "avutils.h"
7+
#include "avcpp/av.h"
8+
#include "avcpp/ffmpeg.h"
9+
#include "avcpp/codec.h"
10+
#include "avcpp/packet.h"
11+
#include "avcpp/videorescaler.h"
12+
#include "avcpp/audioresampler.h"
13+
#include "avcpp/avutils.h"
1414

1515
// API2
16-
#include "format.h"
17-
#include "formatcontext.h"
18-
#include "codec.h"
19-
#include "codeccontext.h"
16+
#include "avcpp/format.h"
17+
#include "avcpp/formatcontext.h"
18+
#include "avcpp/codec.h"
19+
#include "avcpp/codeccontext.h"
2020

2121
using namespace std;
2222
using namespace av;

example/api2-samples/api2-decode-filter-encode.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@
44
#include <memory>
55
#include <set>
66

7-
#include "audioresampler.h"
8-
#include "av.h"
9-
#include "avutils.h"
10-
#include "codec.h"
11-
#include "ffmpeg.h"
12-
#include "packet.h"
13-
#include "videorescaler.h"
7+
#include "avcpp/audioresampler.h"
8+
#include "avcpp/av.h"
9+
#include "avcpp/avutils.h"
10+
#include "avcpp/codec.h"
11+
#include "avcpp/ffmpeg.h"
12+
#include "avcpp/packet.h"
13+
#include "avcpp/videorescaler.h"
1414

1515
// API2
16-
#include "codec.h"
17-
#include "codeccontext.h"
18-
#include "filters/buffersink.h"
19-
#include "filters/buffersrc.h"
20-
#include "filters/filtergraph.h"
21-
#include "format.h"
22-
#include "formatcontext.h"
16+
#include "avcpp/codec.h"
17+
#include "avcpp/codeccontext.h"
18+
#include "avcpp/format.h"
19+
#include "avcpp/formatcontext.h"
20+
#include "avcpp/filters/buffersink.h"
21+
#include "avcpp/filters/buffersrc.h"
22+
#include "avcpp/filters/filtergraph.h"
23+
2324

2425
using namespace std;
2526
using namespace av;

example/api2-samples/api2-decode-rasample-audio.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
#include <memory>
55
#include <functional>
66

7-
#include "av.h"
8-
#include "ffmpeg.h"
9-
#include "codec.h"
10-
#include "packet.h"
11-
#include "videorescaler.h"
12-
#include "audioresampler.h"
13-
#include "avutils.h"
7+
#include "avcpp/av.h"
8+
#include "avcpp/ffmpeg.h"
9+
#include "avcpp/codec.h"
10+
#include "avcpp/packet.h"
11+
#include "avcpp/videorescaler.h"
12+
#include "avcpp/audioresampler.h"
13+
#include "avcpp/avutils.h"
1414

1515
// API2
16-
#include "format.h"
17-
#include "formatcontext.h"
18-
#include "codec.h"
19-
#include "codeccontext.h"
16+
#include "avcpp/format.h"
17+
#include "avcpp/formatcontext.h"
18+
#include "avcpp/codec.h"
19+
#include "avcpp/codeccontext.h"
2020

2121
using namespace std;
2222
using namespace av;

example/api2-samples/api2-decode-raw-h264.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
#include <iostream>
33
#include <filesystem>
44

5-
#include "av.h"
6-
#include "ffmpeg.h"
7-
#include "codec.h"
8-
#include "packet.h"
9-
#include "videorescaler.h"
10-
#include "audioresampler.h"
11-
#include "avutils.h"
5+
#include "avcpp/av.h"
6+
#include "avcpp/ffmpeg.h"
7+
#include "avcpp/codec.h"
8+
#include "avcpp/packet.h"
9+
#include "avcpp/videorescaler.h"
10+
#include "avcpp/audioresampler.h"
11+
#include "avcpp/avutils.h"
1212

1313
// API2
14-
#include "codec.h"
15-
#include "codeccontext.h"
14+
#include "avcpp/codec.h"
15+
#include "avcpp/codeccontext.h"
1616

1717
using namespace std;
1818
using namespace av;

example/api2-samples/api2-decode.cpp

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
#include <memory>
55
#include <functional>
66

7-
#include "avconfig.h"
7+
#include "avcpp/avconfig.h"
88

9-
#include "av.h"
10-
#include "ffmpeg.h"
11-
#include "codec.h"
12-
#include "packet.h"
13-
#include "videorescaler.h"
14-
#include "audioresampler.h"
15-
#include "avutils.h"
9+
#include "avcpp/av.h"
10+
#include "avcpp/ffmpeg.h"
11+
#include "avcpp/codec.h"
12+
#include "avcpp/packet.h"
13+
#include "avcpp/videorescaler.h"
14+
#include "avcpp/audioresampler.h"
15+
#include "avcpp/avutils.h"
1616

1717
// API2
18-
#include "format.h"
19-
#include "formatcontext.h"
20-
#include "codec.h"
21-
#include "codeccontext.h"
18+
#include "avcpp/format.h"
19+
#include "avcpp/formatcontext.h"
20+
#include "avcpp/codec.h"
21+
#include "avcpp/codeccontext.h"
2222

2323
using namespace std;
2424
using namespace av;
@@ -58,11 +58,10 @@ int main(int argc, char **argv)
5858
return 1;
5959
}
6060

61-
for (size_t i = 0; i < ictx.streamsCount(); ++i) {
62-
auto st = ictx.stream(i);
61+
for (auto&& st : ictx.streams()) {
6362
if (st.mediaType() == AVMEDIA_TYPE_VIDEO) {
64-
videoStream = i;
6563
vst = st;
64+
videoStream = st.index();
6665
break;
6766
}
6867
}
@@ -77,11 +76,9 @@ int main(int argc, char **argv)
7776
if (vst.isValid()) {
7877
vdec = VideoDecoderContext(vst);
7978

80-
81-
Codec codec = findDecodingCodec(vdec.raw()->codec_id);
82-
83-
vdec.setCodec(codec);
84-
vdec.setRefCountedFrames(true);
79+
//Codec codec = findDecodingCodec(vdec.raw()->codec_id);
80+
//vdec.setCodec(codec);
81+
//vdec.setRefCountedFrames(true);
8582

8683
vdec.open({{"threads", "1"}}, Codec(), ec);
8784
//vdec.open(ec);
@@ -109,15 +106,15 @@ int main(int argc, char **argv)
109106
for (auto side : pkt.sideData()) {
110107
clog << " found packet side data: " << side.name() << endl;
111108
if (side.type() == AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL) {
112-
assert(side.data().size() >= sizeof(uint64_t));
109+
assert(side.span().size() >= sizeof(uint64_t));
113110

114111
// BE
115112
uint64_t idType{};
116-
memcpy(&idType, side.data().data(), sizeof(idType));
113+
memcpy(&idType, side.span().data(), sizeof(idType));
117114
//idType = std::endian::native == std::endian::little ? std::byteswap(idType) : idType;
118115
idType = av_be2ne64(idType);
119116

120-
auto payload = side.data().subspan(sizeof(uint64_t));
117+
auto payload = side.span().subspan(sizeof(uint64_t));
121118
clog << " matroska block additions id type = " << idType << endl;
122119
if (!payload.empty() && idType == 100 /* vendor specific */) {
123120
clog << " block additions data: " << std::string_view{(const char*)payload.data(), payload.size()} << endl;

example/api2-samples/api2-demux-seek.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
#include <memory>
55
#include <functional>
66

7-
#include "av.h"
8-
#include "ffmpeg.h"
9-
#include "codec.h"
10-
#include "packet.h"
11-
#include "videorescaler.h"
12-
#include "audioresampler.h"
13-
#include "avutils.h"
7+
#include "avcpp/av.h"
8+
#include "avcpp/ffmpeg.h"
9+
#include "avcpp/codec.h"
10+
#include "avcpp/packet.h"
11+
#include "avcpp/videorescaler.h"
12+
#include "avcpp/audioresampler.h"
13+
#include "avcpp/avutils.h"
1414

1515
// API2
16-
#include "format.h"
17-
#include "formatcontext.h"
18-
#include "codec.h"
19-
#include "codeccontext.h"
16+
#include "avcpp/format.h"
17+
#include "avcpp/formatcontext.h"
18+
#include "avcpp/codec.h"
19+
#include "avcpp/codeccontext.h"
2020

2121
using namespace std;
2222
using namespace av;

example/api2-samples/api2-dict-basic.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <iostream>
22

3-
#include "av.h"
4-
#include "dictionary.h"
3+
#include "avcpp/av.h"
4+
#include "avcpp/dictionary.h"
55

66
using namespace std;
77
using namespace av;

0 commit comments

Comments
 (0)