2021-01-23 18:11:36 -07:00
|
|
|
#pragma once
|
2020-01-17 12:20:17 -07:00
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
#include <libavformat/avformat.h>
|
2021-05-08 23:15:17 -06:00
|
|
|
#include <libavutil/imgutils.h>
|
2020-01-17 12:20:17 -07:00
|
|
|
}
|
|
|
|
|
2021-05-08 23:15:17 -06:00
|
|
|
#include "selfdrive/loggerd/encoder.h"
|
2020-01-17 12:20:17 -07:00
|
|
|
|
2021-01-12 17:28:22 -07:00
|
|
|
class RawLogger : public VideoEncoder {
|
2021-05-08 23:15:17 -06:00
|
|
|
public:
|
2021-01-12 17:28:22 -07:00
|
|
|
RawLogger(const char* filename, int width, int height, int fps,
|
|
|
|
int bitrate, bool h265, bool downscale);
|
2020-01-17 12:20:17 -07:00
|
|
|
~RawLogger();
|
2021-01-12 17:28:22 -07:00
|
|
|
int encode_frame(const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr,
|
2021-02-07 18:48:46 -07:00
|
|
|
int in_width, int in_height, uint64_t ts);
|
|
|
|
void encoder_open(const char* path);
|
2021-01-12 17:28:22 -07:00
|
|
|
void encoder_close();
|
2020-01-17 12:20:17 -07:00
|
|
|
|
|
|
|
private:
|
2021-01-12 17:28:22 -07:00
|
|
|
const char* filename;
|
|
|
|
int fps;
|
2020-01-17 12:20:17 -07:00
|
|
|
int counter = 0;
|
2021-01-12 17:28:22 -07:00
|
|
|
bool is_open = false;
|
|
|
|
|
|
|
|
std::string vid_path, lock_path;
|
|
|
|
|
2020-01-17 12:20:17 -07:00
|
|
|
AVCodec *codec = NULL;
|
|
|
|
AVCodecContext *codec_ctx = NULL;
|
|
|
|
|
|
|
|
AVStream *stream = NULL;
|
|
|
|
AVFormatContext *format_ctx = NULL;
|
|
|
|
|
|
|
|
AVFrame *frame = NULL;
|
|
|
|
};
|