loggerd: always run encoders (#22649)

* loggerd: always run encoders

* fix raw logger

* bump loggerd cpu usage
pull/22688/head
Adeeb Shihadeh 4 years ago committed by GitHub
parent 897492d27c
commit 76bd932cf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      selfdrive/camerad/cameras/camera_common.h
  2. 8
      selfdrive/loggerd/loggerd.cc
  3. 21
      selfdrive/loggerd/omx_encoder.cc
  4. 5
      selfdrive/loggerd/omx_encoder.h
  5. 7
      selfdrive/loggerd/raw_logger.cc
  6. 3
      selfdrive/loggerd/raw_logger.h
  7. 2
      selfdrive/test/test_onroad.py

@ -62,6 +62,7 @@ typedef struct LogCameraInfo {
bool has_qcamera; bool has_qcamera;
bool trigger_rotate; bool trigger_rotate;
bool enable; bool enable;
bool record;
} LogCameraInfo; } LogCameraInfo;
typedef struct FrameMetadata { typedef struct FrameMetadata {

@ -64,6 +64,7 @@ const LogCameraInfo cameras_logged[] = {
.has_qcamera = true, .has_qcamera = true,
.trigger_rotate = true, .trigger_rotate = true,
.enable = true, .enable = true,
.record = true,
}, },
{ {
.type = DriverCam, .type = DriverCam,
@ -76,7 +77,8 @@ const LogCameraInfo cameras_logged[] = {
.downscale = false, .downscale = false,
.has_qcamera = false, .has_qcamera = false,
.trigger_rotate = Hardware::TICI(), .trigger_rotate = Hardware::TICI(),
.enable = !Hardware::PC() && Params().getBool("RecordFront"), .enable = !Hardware::PC(),
.record = Params().getBool("RecordFront"),
}, },
{ {
.type = WideRoadCam, .type = WideRoadCam,
@ -90,6 +92,7 @@ const LogCameraInfo cameras_logged[] = {
.has_qcamera = false, .has_qcamera = false,
.trigger_rotate = true, .trigger_rotate = true,
.enable = Hardware::TICI(), .enable = Hardware::TICI(),
.record = Hardware::TICI(),
}, },
}; };
const LogCameraInfo qcam_info = { const LogCameraInfo qcam_info = {
@ -146,7 +149,8 @@ void encoder_thread(const LogCameraInfo &cam_info) {
// main encoder // main encoder
encoders.push_back(new Encoder(cam_info.filename, buf_info.width, buf_info.height, 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 // qcamera encoder
if (cam_info.has_qcamera) { if (cam_info.has_qcamera) {
encoders.push_back(new Encoder(qcam_info.filename, qcam_info.frame_width, qcam_info.frame_height, 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 ***** // ***** 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->filename = filename;
this->write = write;
this->width = width; this->width = width;
this->height = height; this->height = height;
this->fps = fps; this->fps = fps;
@ -503,13 +504,15 @@ void OmxEncoder::encoder_open(const char* path) {
this->wrote_codec_config = false; this->wrote_codec_config = false;
} else { } else {
this->of = fopen(this->vid_path, "wb"); if (this->write) {
assert(this->of); this->of = fopen(this->vid_path, "wb");
assert(this->of);
#ifndef QCOM2 #ifndef QCOM2
if (this->codec_config_len > 0) { if (this->codec_config_len > 0) {
fwrite(this->codec_config, this->codec_config_len, 1, this->of); fwrite(this->codec_config, this->codec_config_len, 1, this->of);
} }
#endif #endif
}
} }
// create camera lock file // create camera lock file
@ -553,8 +556,10 @@ void OmxEncoder::encoder_close() {
avio_closep(&this->ofmt_ctx->pb); avio_closep(&this->ofmt_ctx->pb);
avformat_free_context(this->ofmt_ctx); avformat_free_context(this->ofmt_ctx);
} else { } else {
fclose(this->of); if (this->of) {
this->of = nullptr; fclose(this->of);
this->of = nullptr;
}
} }
unlink(this->lock_path); unlink(this->lock_path);
} }

@ -15,7 +15,7 @@ extern "C" {
// OmxEncoder, lossey codec using hardware hevc // OmxEncoder, lossey codec using hardware hevc
class OmxEncoder : public VideoEncoder { class OmxEncoder : public VideoEncoder {
public: 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(); ~OmxEncoder();
int encode_frame(const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr, 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); int in_width, int in_height, uint64_t ts);
@ -39,10 +39,11 @@ private:
char lock_path[1024]; char lock_path[1024];
bool is_open = false; bool is_open = false;
bool dirty = false; bool dirty = false;
bool write = false;
int counter = 0; int counter = 0;
const char* filename; const char* filename;
FILE *of; FILE *of = nullptr;
size_t codec_config_len; size_t codec_config_len;
uint8_t *codec_config = NULL; uint8_t *codec_config = NULL;

@ -21,9 +21,10 @@ extern "C" {
#include "selfdrive/common/util.h" #include "selfdrive/common/util.h"
RawLogger::RawLogger(const char* filename, int width, int height, int fps, RawLogger::RawLogger(const char* filename, int width, int height, int fps,
int bitrate, bool h265, bool downscale) int bitrate, bool h265, bool downscale, bool write)
: filename(filename), : filename(filename), fps(fps) {
fps(fps) {
// TODO: respect write arg
av_register_all(); av_register_all();
codec = avcodec_find_encoder(AV_CODEC_ID_FFVHUFF); codec = avcodec_find_encoder(AV_CODEC_ID_FFVHUFF);

@ -16,7 +16,7 @@ extern "C" {
class RawLogger : public VideoEncoder { class RawLogger : public VideoEncoder {
public: public:
RawLogger(const char* filename, int width, int height, int fps, 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(); ~RawLogger();
int encode_frame(const uint8_t *y_ptr, const uint8_t *u_ptr, const uint8_t *v_ptr, 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); int in_width, int in_height, uint64_t ts);
@ -25,6 +25,7 @@ class RawLogger : public VideoEncoder {
private: private:
const char* filename; const char* filename;
//bool write;
int fps; int fps;
int counter = 0; int counter = 0;
bool is_open = false; bool is_open = false;

@ -51,7 +51,7 @@ if EON:
if TICI: if TICI:
PROCS.update({ PROCS.update({
"./loggerd": 60.0, "./loggerd": 70.0,
"selfdrive.controls.controlsd": 28.0, "selfdrive.controls.controlsd": 28.0,
"./camerad": 31.0, "./camerad": 31.0,
"./_ui": 21.0, "./_ui": 21.0,

Loading…
Cancel
Save