diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-05-28 10:34:18 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-05-28 10:34:18 +0100 |
| commit | f648d137d381d778f1ae25a25a2cc7257128123b (patch) | |
| tree | 79896759a249a3a012aed7c150d171dfa082bca1 /rotord/libavwrapper.h | |
| parent | 14f3d350aa7c9abfd8bc394e87177d3f9e6b8d87 (diff) | |
further work on wrapper
Diffstat (limited to 'rotord/libavwrapper.h')
| -rwxr-xr-x | rotord/libavwrapper.h | 73 |
1 files changed, 68 insertions, 5 deletions
diff --git a/rotord/libavwrapper.h b/rotord/libavwrapper.h index c06a94d..a03cbbe 100755 --- a/rotord/libavwrapper.h +++ b/rotord/libavwrapper.h @@ -47,6 +47,13 @@ extern "C" { namespace libav { + static bool b_is_one_time_inited=false; + // Some libavcodec calls are not reentrant + //static QMutex mutex; + void maybeInitFFMpegLib(); + + static int sws_flags = SWS_BICUBIC; + // Translated to C++ by Christopher Bruns May 2012 // from ffmeg_adapt.c in whisk package by Nathan Clack, Mark Bolstadt, Michael Meeuwisse class decoder @@ -59,10 +66,7 @@ namespace libav { BLUE = 2, ALPHA = 3 }; - - // Some libavcodec calls are not reentrant - //static QMutex mutex; - static void maybeInitFFMpegLib(); + decoder(PixelFormat pixelFormat=PIX_FMT_RGB24); //decoder(QUrl url, PixelFormat pixelFormat=PIX_FMT_RGB24); @@ -92,7 +96,7 @@ namespace libav { bool open(char* fileName, enum PixelFormat formatParam = PIX_FMT_RGB24); protected: - static bool b_is_one_time_inited; + void initialize(); @@ -152,6 +156,65 @@ namespace libav { float audiostep; }; + + class exporter { + public: + virtual ~exporter(); + bool setup(int w,int h, int bitRate, int frameRate, std::string container); + bool record(std::string filename); + bool encodeFrame(unsigned char *pixels, uint16_t *samples); + bool encodeFrame(unsigned char *pixels,AVPacket *audiopkt); //is possible to just copy the packets? + bool encodeFrame(unsigned char *pixels); + bool encodeFrame(uint16_t *samples); + void finishRecord(); + int get_audio_framesize(){return audioframesize;}; + float get_audio_step(){return audiostep;}; + + AVStream *add_stream(AVFormatContext *oc, AVCodec **codec,enum AVCodecID codec_id); + void open_video(AVFormatContext *oc, AVCodec *codec, AVStream *st); + int open_audio(AVFormatContext *oc, AVCodec *codec, AVStream *st); + + void write_audio_frame(AVFormatContext *oc, AVStream *st,uint16_t *samples); + void write_audio_frame(AVFormatContext *oc, AVStream *st,AVPacket *pkt); + void close_audio(AVFormatContext *oc, AVStream *st); + + void write_video_frame(AVFormatContext *oc, AVStream *st, uint8_t *pixels); + void close_video(AVFormatContext *oc, AVStream *st); + + private: + AVOutputFormat *fmt; + AVFormatContext *oc; + AVStream *audio_st, *video_st; + AVCodec *audio_codec, *video_codec; + double audio_pts, video_pts; + + int audioframesize; + float audiostep; + int w; + int h; + int bitRate; + int frameRate; + std::string container; + + int outputframe; + + // video output // + + AVFrame *frame; + AVPicture src_picture, dst_picture; + int frame_count; + uint8_t *outPixels; + + + //************************************************************// + // audio output // + + float t, tincr, tincr2; + int audio_input_frame_size; + + + }; + } |
