mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-06 00:36:32 +08:00
misc encoder cleanups
This commit is contained in:
@@ -11,7 +11,6 @@ VideoEncoder::VideoEncoder(const EncoderInfo &encoder_info, int in_width, int in
|
||||
|
||||
void VideoEncoder::publisher_publish(int segment_num, uint32_t idx, VisionIpcBufExtra &extra,
|
||||
unsigned int flags, kj::ArrayPtr<capnp::byte> header, kj::ArrayPtr<capnp::byte> dat) {
|
||||
// broadcast packet
|
||||
MessageBuilder msg;
|
||||
auto event = msg.initEvent(true);
|
||||
auto edat = (event.*(encoder_info.init_encode_data_func))();
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
VideoEncoder(const EncoderInfo &encoder_info, int in_width, int in_height);
|
||||
virtual ~VideoEncoder() {}
|
||||
virtual int encode_frame(VisionBuf* buf, VisionIpcBufExtra *extra) = 0;
|
||||
virtual void encoder_open(const char* path) = 0;
|
||||
virtual void encoder_open() = 0;
|
||||
virtual void encoder_close() = 0;
|
||||
|
||||
void publisher_publish(int segment_num, uint32_t idx, VisionIpcBufExtra &extra, unsigned int flags, kj::ArrayPtr<capnp::byte> header, kj::ArrayPtr<capnp::byte> dat);
|
||||
|
||||
@@ -47,7 +47,7 @@ FfmpegEncoder::~FfmpegEncoder() {
|
||||
av_frame_free(&frame);
|
||||
}
|
||||
|
||||
void FfmpegEncoder::encoder_open(const char* path) {
|
||||
void FfmpegEncoder::encoder_open() {
|
||||
auto codec_id = encoder_info.encode_type == cereal::EncodeIndex::Type::QCAMERA_H264
|
||||
? AV_CODEC_ID_H264
|
||||
: AV_CODEC_ID_FFVHUFF;
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
FfmpegEncoder(const EncoderInfo &encoder_info, int in_width, int in_height);
|
||||
~FfmpegEncoder();
|
||||
int encode_frame(VisionBuf* buf, VisionIpcBufExtra *extra);
|
||||
void encoder_open(const char* path);
|
||||
void encoder_open();
|
||||
void encoder_close();
|
||||
|
||||
private:
|
||||
|
||||
@@ -275,7 +275,7 @@ V4LEncoder::V4LEncoder(const EncoderInfo &encoder_info, int in_width, int in_hei
|
||||
}
|
||||
}
|
||||
|
||||
void V4LEncoder::encoder_open(const char* path) {
|
||||
void V4LEncoder::encoder_open() {
|
||||
dequeue_handler_thread = std::thread(V4LEncoder::dequeue_handler, this);
|
||||
this->is_open = true;
|
||||
this->counter = 0;
|
||||
|
||||
@@ -11,8 +11,9 @@ public:
|
||||
V4LEncoder(const EncoderInfo &encoder_info, int in_width, int in_height);
|
||||
~V4LEncoder();
|
||||
int encode_frame(VisionBuf* buf, VisionIpcBufExtra *extra);
|
||||
void encoder_open(const char* path);
|
||||
void encoder_open();
|
||||
void encoder_close();
|
||||
|
||||
private:
|
||||
int fd;
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ void encoder_thread(EncoderdState *s, const LogCameraInfo &cam_info) {
|
||||
|
||||
for (const auto &encoder_info : cam_info.encoder_infos) {
|
||||
auto &e = encoders.emplace_back(new Encoder(encoder_info, buf_info.width, buf_info.height));
|
||||
e->encoder_open(nullptr);
|
||||
e->encoder_open();
|
||||
}
|
||||
|
||||
// Only one thumbnail can be generated per camera stream
|
||||
@@ -103,7 +103,7 @@ void encoder_thread(EncoderdState *s, const LogCameraInfo &cam_info) {
|
||||
if (cur_seg >= 0 && extra.frame_id >= ((cur_seg + 1) * frames_per_seg) + s->start_frame_id) {
|
||||
for (auto &e : encoders) {
|
||||
e->encoder_close();
|
||||
e->encoder_open(NULL);
|
||||
e->encoder_open();
|
||||
}
|
||||
++cur_seg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user