mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-07-16 18:32:06 +08:00
loggerd: always run encoders (#22649)
* loggerd: always run encoders * fix raw logger * bump loggerd cpu usage
This commit is contained in:
@@ -62,6 +62,7 @@ typedef struct LogCameraInfo {
|
||||
bool has_qcamera;
|
||||
bool trigger_rotate;
|
||||
bool enable;
|
||||
bool record;
|
||||
} LogCameraInfo;
|
||||
|
||||
typedef struct FrameMetadata {
|
||||
|
||||
@@ -64,6 +64,7 @@ const LogCameraInfo cameras_logged[] = {
|
||||
.has_qcamera = true,
|
||||
.trigger_rotate = true,
|
||||
.enable = true,
|
||||
.record = true,
|
||||
},
|
||||
{
|
||||
.type = DriverCam,
|
||||
@@ -76,7 +77,8 @@ const LogCameraInfo cameras_logged[] = {
|
||||
.downscale = false,
|
||||
.has_qcamera = false,
|
||||
.trigger_rotate = Hardware::TICI(),
|
||||
.enable = !Hardware::PC() && Params().getBool("RecordFront"),
|
||||
.enable = !Hardware::PC(),
|
||||
.record = Params().getBool("RecordFront"),
|
||||
},
|
||||
{
|
||||
.type = WideRoadCam,
|
||||
@@ -90,6 +92,7 @@ const LogCameraInfo cameras_logged[] = {
|
||||
.has_qcamera = false,
|
||||
.trigger_rotate = true,
|
||||
.enable = Hardware::TICI(),
|
||||
.record = Hardware::TICI(),
|
||||
},
|
||||
};
|
||||
const LogCameraInfo qcam_info = {
|
||||
@@ -146,7 +149,8 @@ void encoder_thread(const LogCameraInfo &cam_info) {
|
||||
|
||||
// main encoder
|
||||
encoders.push_back(new Encoder(cam_info.filename, buf_info.width, buf_info.height,
|
||||
cam_info.fps, cam_info.bitrate, cam_info.is_h265, cam_info.downscale));
|
||||
cam_info.fps, cam_info.bitrate, cam_info.is_h265,
|
||||
cam_info.downscale, cam_info.record));
|
||||
// qcamera encoder
|
||||
if (cam_info.has_qcamera) {
|
||||
encoders.push_back(new Encoder(qcam_info.filename, qcam_info.frame_width, qcam_info.frame_height,
|
||||
|
||||
@@ -156,8 +156,9 @@ static const char* omx_color_fomat_name(uint32_t format) {
|
||||
|
||||
// ***** encoder functions *****
|
||||
|
||||
OmxEncoder::OmxEncoder(const char* filename, int width, int height, int fps, int bitrate, bool h265, bool downscale) {
|
||||
OmxEncoder::OmxEncoder(const char* filename, int width, int height, int fps, int bitrate, bool h265, bool downscale, bool write) {
|
||||
this->filename = filename;
|
||||
this->write = write;
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
this->fps = fps;
|
||||
@@ -503,13 +504,15 @@ void OmxEncoder::encoder_open(const char* path) {
|
||||
|
||||
this->wrote_codec_config = false;
|
||||
} else {
|
||||
this->of = fopen(this->vid_path, "wb");
|
||||
assert(this->of);
|
||||
if (this->write) {
|
||||
this->of = fopen(this->vid_path, "wb");
|
||||
assert(this->of);
|
||||
#ifndef QCOM2
|
||||
if (this->codec_config_len > 0) {
|
||||
fwrite(this->codec_config, this->codec_config_len, 1, this->of);
|
||||
}
|
||||
if (this->codec_config_len > 0) {
|
||||
fwrite(this->codec_config, this->codec_config_len, 1, this->of);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// create camera lock file
|
||||
@@ -553,8 +556,10 @@ void OmxEncoder::encoder_close() {
|
||||
avio_closep(&this->ofmt_ctx->pb);
|
||||
avformat_free_context(this->ofmt_ctx);
|
||||
} else {
|
||||
fclose(this->of);
|
||||
this->of = nullptr;
|
||||
if (this->of) {
|
||||
fclose(this->of);
|
||||
this->of = nullptr;
|
||||
}
|
||||
}
|
||||
unlink(this->lock_path);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ extern "C" {
|
||||
// OmxEncoder, lossey codec using hardware hevc
|
||||
class OmxEncoder : public VideoEncoder {
|
||||
public:
|
||||
OmxEncoder(const char* filename, int width, int height, int fps, int bitrate, bool h265, bool downscale);
|
||||
OmxEncoder(const char* filename, int width, int height, int fps, int bitrate, bool h265, bool downscale, bool write = true);
|
||||
~OmxEncoder();
|
||||
int encode_frame(const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr,
|
||||
int in_width, int in_height, uint64_t ts);
|
||||
@@ -39,10 +39,11 @@ private:
|
||||
char lock_path[1024];
|
||||
bool is_open = false;
|
||||
bool dirty = false;
|
||||
bool write = false;
|
||||
int counter = 0;
|
||||
|
||||
const char* filename;
|
||||
FILE *of;
|
||||
FILE *of = nullptr;
|
||||
|
||||
size_t codec_config_len;
|
||||
uint8_t *codec_config = NULL;
|
||||
|
||||
@@ -21,9 +21,10 @@ extern "C" {
|
||||
#include "selfdrive/common/util.h"
|
||||
|
||||
RawLogger::RawLogger(const char* filename, int width, int height, int fps,
|
||||
int bitrate, bool h265, bool downscale)
|
||||
: filename(filename),
|
||||
fps(fps) {
|
||||
int bitrate, bool h265, bool downscale, bool write)
|
||||
: filename(filename), fps(fps) {
|
||||
|
||||
// TODO: respect write arg
|
||||
|
||||
av_register_all();
|
||||
codec = avcodec_find_encoder(AV_CODEC_ID_FFVHUFF);
|
||||
|
||||
@@ -16,7 +16,7 @@ extern "C" {
|
||||
class RawLogger : public VideoEncoder {
|
||||
public:
|
||||
RawLogger(const char* filename, int width, int height, int fps,
|
||||
int bitrate, bool h265, bool downscale);
|
||||
int bitrate, bool h265, bool downscale, bool write = true);
|
||||
~RawLogger();
|
||||
int encode_frame(const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr,
|
||||
int in_width, int in_height, uint64_t ts);
|
||||
@@ -25,6 +25,7 @@ class RawLogger : public VideoEncoder {
|
||||
|
||||
private:
|
||||
const char* filename;
|
||||
//bool write;
|
||||
int fps;
|
||||
int counter = 0;
|
||||
bool is_open = false;
|
||||
|
||||
@@ -51,7 +51,7 @@ if EON:
|
||||
|
||||
if TICI:
|
||||
PROCS.update({
|
||||
"./loggerd": 60.0,
|
||||
"./loggerd": 70.0,
|
||||
"selfdrive.controls.controlsd": 28.0,
|
||||
"./camerad": 31.0,
|
||||
"./_ui": 21.0,
|
||||
|
||||
Reference in New Issue
Block a user