Blame view

src/decoder/dvpp/FFRecoder.h 1.19 KB
09c2d08c   Hu Chunming   arm交付版
1
2
3
  #pragma once
  #include <memory>
  
746db74c   Hu Chunming   实现recode
4
5
6
7
8
9
10
11
  extern "C" {
  	#include <libavcodec/avcodec.h>
  	#include <libavformat/avformat.h>
  	#include <libavutil/opt.h>
  	#include <libavutil/timestamp.h>
  	#include <libavutil/imgutils.h>
  	#include <libswscale/swscale.h>
  }
09c2d08c   Hu Chunming   arm交付版
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  
  class FFRecoder
  {
  public:
  	FFRecoder();
  	virtual ~FFRecoder();
  
  	bool init(int w, int h, AVRational time_base, AVCodecContext* avctx, const char* outfile_name);
  	void uninit();
  	bool write_image(const uint8_t* bgr);
  	bool write_yuv(const uint8_t* yuv_data);
  	bool write_frame(AVFrame* frame);
  	bool flush();
  
  	// AVPacket 方式
bf661eb0   Hu Chunming   录像文件保存优化
27
  	bool init(AVStream* stream, AVCodecContext* avctx, const char* outfile_name);
09c2d08c   Hu Chunming   arm交付版
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  	bool write_pkt(AVPacket *pkt);
  
  private:
  	bool bgr_to_yuv420p(const uint8_t* const buf_bgr, uint8_t* const buf_420p);
  	void update_pts(AVPacket* pkt);
  
  private:
  	int width_;
  	int height_;
  	int y_size_;
  	int uv_size_;
  	int pts_;
  	AVCodecContext* codec_ctx_;
  	AVFormatContext* fmt_ctx_;
  	AVStream* out_stream_;
  	AVFrame* yuv_frame_;
  
  	SwsContext * img_convert_ctx;
  	//AVFrame* pFrameOut;
  	uint8_t * out_buffer;
  
  	bool bFirstFrame;
  	int64_t last_src_pts;
  	int64_t last_pts;
d9fc3e82   Hu Chunming   recode添加colse功能和mq功能
52
  
bf661eb0   Hu Chunming   录像文件保存优化
53
54
55
56
57
  	int64_t first_pts;
  	int64_t first_dts;
  
  	int64_t frame_index{0};
  	AVStream* m_inStream;
09c2d08c   Hu Chunming   arm交付版
58
  };