1010
1111#define FFMPG3_4
1212#define FFMPG4_0
13+ #define FFMPG4_4
1314
14- extern " C"
15- {
16- #include " libavcodec/avcodec.h"
17- #include " libavformat/avformat.h"
18- #include " libswscale/swscale.h"
19- #include " libavutil/imgutils.h"
20- #include " libavutil/samplefmt.h"
21- #include " libavutil/timestamp.h"
22- #include " libavutil/opt.h"
23- #include " libavutil/avassert.h"
24- #include " libavutil/channel_layout.h"
25- #include " libavutil/opt.h"
26- #include " libavutil/mathematics.h"
27- #include " libswresample/swresample.h"
15+ namespace cmpc {
16+ extern " C"
17+ {
18+ #include " libavcodec/avcodec.h"
19+ #include " libavformat/avformat.h"
20+ #include " libswscale/swscale.h"
21+ #include " libavutil/imgutils.h"
22+ #include " libavutil/samplefmt.h"
23+ #include " libavutil/timestamp.h"
24+ #include " libavutil/opt.h"
25+ #include " libavutil/avassert.h"
26+ #include " libavutil/channel_layout.h"
27+ #include " libavutil/mathematics.h"
28+ #include " libavutil/time.h"
29+ #include " libswresample/swresample.h"
30+ }
2831}
2932
30- #define MPEGCODER_CURRENT_VERSION " 2.05 "
33+ #define MPEGCODER_CURRENT_VERSION " 3.0.0 "
3134
32- #define STREAM_PIX_FMT AV_PIX_FMT_YUV420P /* default pix_fmt */
35+ #define STREAM_PIX_FMT AVPixelFormat:: AV_PIX_FMT_YUV420P /* default pix_fmt */
3336
3437#define SCALE_FLAGS SWS_BICUBIC
3538// SWS_BILINEAR
3639
3740#include < iostream>
3841// #include <memory>
3942#include < string>
43+ #include < functional>
4044#include < iomanip>
45+ #include < sstream>
4146#include < fstream>
4247#include < thread>
4348#include < mutex>
4449#include < Python.h>
45- #include < numpy/arrayobject.h>
4650using std::string;
4751using std::cerr;
4852using std::cout;
4953using std::endl;
5054using std::ostream;
5155
5256#ifdef __cplusplus
57+ namespace cmpc {
5358 static const string av_make_error_string2 (int errnum) {
5459 char errbuf[AV_ERROR_MAX_STRING_SIZE];
5560 av_strerror (errnum, errbuf, AV_ERROR_MAX_STRING_SIZE);
@@ -66,20 +71,37 @@ using std::ostream;
6671 }
6772 #undef av_ts2str
6873 #define av_ts2str (ts ) av_ts_make_string_cpp(ts).c_str()
69- static const string av_ts_make_time_string_cpp (int64_t ts, AVRational * tb) {
74+ static const string av_ts_make_time_string_cpp (int64_t ts, AVRational* tb) {
7075 char tsstrbuf[AV_TS_MAX_STRING_SIZE];
7176 av_ts_make_time_string (tsstrbuf, ts, tb);
7277 string strtsstrbuf = tsstrbuf;
7378 return strtsstrbuf;
7479 }
7580 #undef av_ts2timestr
7681 #define av_ts2timestr (ts, tb ) av_ts_make_time_string_cpp(ts, tb).c_str()
82+ }
7783#endif // __cplusplus
7884
85+ namespace cmpc {
86+ // a wrapper around a single output AVStream
87+ typedef struct _OutputStream {
88+ AVStream* st;
89+ AVCodecContext* enc;
90+
91+ /* pts of the next frame that will be generated */
92+ int64_t next_frame;
93+
94+ AVFrame* frame;
95+ AVFrame* tmp_frame;
96+
97+ struct SwsContext * sws_ctx;
98+ } OutputStream;
99+ }
100+
79101// compatibility with newer API
80102#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,28,1)
81103 #define av_frame_alloc avcodec_alloc_frame
82104 #define av_frame_free avcodec_free_frame
83105#endif
84106
85- #endif
107+ #endif
0 commit comments