You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					37 lines
				
				1.1 KiB
			
		
		
			
		
	
	
					37 lines
				
				1.1 KiB
			| 
								 
											4 years ago
										 
									 | 
							
								#pragma once
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "selfdrive/common/queue.h"
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								#include "selfdrive/loggerd/encoder/encoder.h"
							 | 
						||
| 
								 | 
							
								#include "selfdrive/loggerd/encoder/video_writer.h"
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								#define BUF_IN_COUNT 7
							 | 
						||
| 
								 | 
							
								#define BUF_OUT_COUNT 6
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class V4LEncoder : public VideoEncoder {
							 | 
						||
| 
								 | 
							
								public:
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								  V4LEncoder(const char* filename, CameraType type, int in_width, int in_height, int fps,
							 | 
						||
| 
								 | 
							
								             int bitrate, cereal::EncodeIndex::Type codec, int out_width, int out_height, bool write) :
							 | 
						||
| 
								 | 
							
								             VideoEncoder(filename, type, in_width, in_height, fps, bitrate, codec, out_width, out_height, write) { encoder_init(); }
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								  ~V4LEncoder();
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								  void encoder_init();
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								  int encode_frame(const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr,
							 | 
						||
| 
								 | 
							
								                   int in_width, int in_height, VisionIpcBufExtra *extra);
							 | 
						||
| 
								 | 
							
								  void encoder_open(const char* path);
							 | 
						||
| 
								 | 
							
								  void encoder_close();
							 | 
						||
| 
								 | 
							
								private:
							 | 
						||
| 
								 | 
							
								  int fd;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  bool is_open = false;
							 | 
						||
| 
								 | 
							
								  int segment_num = -1;
							 | 
						||
| 
								 | 
							
								  int counter = 0;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								  SafeQueue<VisionIpcBufExtra> extras;
							 | 
						||
| 
								 
											4 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								  static void dequeue_handler(V4LEncoder *e);
							 | 
						||
| 
								 | 
							
								  std::thread dequeue_handler_thread;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  VisionBuf buf_in[BUF_IN_COUNT];
							 | 
						||
| 
								 | 
							
								  VisionBuf buf_out[BUF_OUT_COUNT];
							 | 
						||
| 
								 | 
							
								  SafeQueue<unsigned int> free_buf_in;
							 | 
						||
| 
								 | 
							
								};
							 |