tici: fix loggerd (#1302)

* loggerd builds

* codec

* add frame_id cams

* working

* no qcam on tici

* pthread always

Co-authored-by: Tici <robbe@comma.ai>
albatross
George Hotz 2020-03-31 18:25:05 -07:00 committed by GitHub
parent 8db0993663
commit cfcf3f9368
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 68 additions and 18 deletions

View File

@ -49,13 +49,14 @@ if arch == "aarch64" or arch == "larch64":
libpath += ["#external/capnparm/lib", "/usr/lib/aarch64-linux-gnu"]
cflags = ["-DQCOM2", "-mcpu=cortex-a57"]
cxxflags = ["-DQCOM2", "-mcpu=cortex-a57"]
rpath = ["/usr/local/lib"]
else:
libpath += ["#phonelibs/snpe/aarch64"]
libpath += ["#phonelibs/libyuv/lib"]
cflags = ["-DQCOM", "-mcpu=cortex-a57"]
cxxflags = ["-DQCOM", "-mcpu=cortex-a57"]
rpath = ["/system/vendor/lib64"]
rpath = ["/system/vendor/lib64"]
else:
lenv = {
"PATH": "#external/bin:" + os.environ['PATH'],

View File

@ -0,0 +1 @@
ffmpeg-4.2.2*

View File

@ -0,0 +1,31 @@
#!/bin/bash -e
sudo apt-get remove ffmpeg libavcodec-dev
sudo apt-get update -qq && sudo apt-get -y install \
autoconf \
automake \
build-essential \
cmake \
git-core \
libass-dev \
libfreetype6-dev \
libsdl2-dev \
libtool \
libva-dev \
libvdpau-dev \
libvorbis-dev \
libxcb1-dev \
libxcb-shm0-dev \
libxcb-xfixes0-dev \
pkg-config \
texinfo \
wget \
zlib1g-dev
wget https://ffmpeg.org/releases/ffmpeg-4.2.2.tar.bz2
tar xvf ffmpeg-4.2.2.tar.bz2
cd ffmpeg-4.2.2
./configure --enable-shared
make -j8
make install

View File

@ -895,6 +895,7 @@ struct video_event_data {
void cameras_run(DualCameraState *s) {
LOG("-- Dequeueing Video events");
int frame_id = 1;
while (!do_exit) {
struct pollfd fds[2] = {{0}};
@ -927,6 +928,7 @@ void cameras_run(DualCameraState *s) {
if (s->rear.request_ids[j] == event_data->frame_id) {
// TODO: support more than rear camera
tbuffer_dispatch(&s->rear.camera_tb, j);
s->rear.camera_bufs_metadata[j].frame_id = frame_id++;
break;
}
}

View File

@ -459,8 +459,8 @@ void* processing_thread(void *arg) {
#endif
// TODO: add this back
//#if !defined(QCOM) && !defined(QCOM2)
#ifndef QCOM
#if !defined(QCOM) && !defined(QCOM2)
//#ifndef QCOM
framed.setImage(kj::arrayPtr((const uint8_t*)s->yuv_ion[yuv_idx].addr, s->yuv_buf_size));
#endif

View File

@ -8,5 +8,10 @@ libs = ['zmq', 'czmq', 'capnp', 'kj', 'z',
if arch == "aarch64":
src += ['encoder.c', 'raw_logger.cc']
libs += ['OmxVenc', 'OmxCore', 'cutils']
elif arch == "larch64":
src += ['encoder.c', 'raw_logger.cc']
libs += ['OmxVenc', 'OmxCore', 'pthread']
else:
libs += ['pthread']
env.Program(src, LIBS=libs)

View File

@ -15,7 +15,7 @@
#include <libyuv.h>
#include <android/log.h>
//#include <android/log.h>
#include <msm_media_info.h>
@ -24,7 +24,7 @@
#include "encoder.h"
#define ALOG(...) __android_log_print(ANDROID_LOG_VERBOSE, "omxapp", ##__VA_ARGS__)
//#define ALOG(...) __android_log_print(ANDROID_LOG_VERBOSE, "omxapp", ##__VA_ARGS__)
// encoder: lossey codec using hardware hevc
static void wait_for_state(EncoderState *s, OMX_STATETYPE state) {
@ -204,6 +204,9 @@ void encoder_init(EncoderState *s, const char* filename, int width, int height,
err = OMX_GetHandle(&s->handle, (OMX_STRING)"OMX.qcom.video.encoder.avc",
s, &omx_callbacks);
}
if (err != OMX_ErrorNone) {
LOGE("error getting codec: %x", err);
}
assert(err == OMX_ErrorNone);
// printf("handle: %p\n", s->handle);
@ -283,20 +286,22 @@ void encoder_init(EncoderState *s, const char* filename, int width, int height,
assert(err == OMX_ErrorNone);
if (h265) {
// setup HEVC
OMX_VIDEO_PARAM_HEVCTYPE hecv_type = {0};
hecv_type.nSize = sizeof(hecv_type);
hecv_type.nPortIndex = (OMX_U32) PORT_INDEX_OUT;
err = OMX_GetParameter(s->handle, (OMX_INDEXTYPE)OMX_IndexParamVideoHevc,
(OMX_PTR) &hecv_type);
assert(err == OMX_ErrorNone);
#ifndef QCOM2
// setup HEVC
OMX_VIDEO_PARAM_HEVCTYPE hecv_type = {0};
hecv_type.nSize = sizeof(hecv_type);
hecv_type.nPortIndex = (OMX_U32) PORT_INDEX_OUT;
err = OMX_GetParameter(s->handle, (OMX_INDEXTYPE)OMX_IndexParamVideoHevc,
(OMX_PTR) &hecv_type);
assert(err == OMX_ErrorNone);
hecv_type.eProfile = OMX_VIDEO_HEVCProfileMain;
hecv_type.eLevel = OMX_VIDEO_HEVCHighTierLevel5;
hecv_type.eProfile = OMX_VIDEO_HEVCProfileMain;
hecv_type.eLevel = OMX_VIDEO_HEVCHighTierLevel5;
err = OMX_SetParameter(s->handle, (OMX_INDEXTYPE)OMX_IndexParamVideoHevc,
(OMX_PTR) &hecv_type);
assert(err == OMX_ErrorNone);
err = OMX_SetParameter(s->handle, (OMX_INDEXTYPE)OMX_IndexParamVideoHevc,
(OMX_PTR) &hecv_type);
assert(err == OMX_ErrorNone);
#endif
} else {
// setup h264
OMX_VIDEO_PARAM_AVCTYPE avc = { 0 };
@ -552,6 +557,7 @@ void encoder_open(EncoderState *s, const char* path) {
pthread_mutex_lock(&s->lock);
snprintf(s->vid_path, sizeof(s->vid_path), "%s/%s", path, s->filename);
LOGD("encoder_open %s remuxing:%d", s->vid_path, s->remuxing);
if (s->remuxing) {
avformat_alloc_output_context2(&s->ofmt_ctx, NULL, NULL, s->vid_path);

View File

@ -41,7 +41,7 @@
#include "messaging.hpp"
#include "services.h"
#ifndef QCOM
#if !(defined(QCOM) || defined(QCOM2))
// no encoder on PC
#define DISABLE_ENCODER
#endif
@ -137,10 +137,14 @@ void encoder_thread(bool is_streaming, bool raw_clips, bool front) {
if (!encoder_inited) {
LOGD("encoder init %dx%d", buf_info.width, buf_info.height);
encoder_init(&encoder, front ? "dcamera.hevc" : "fcamera.hevc", buf_info.width, buf_info.height, CAMERA_FPS, front ? 2500000 : 5000000, true, false);
#ifndef QCOM2
// TODO: fix qcamera on tici
if (!front) {
encoder_init(&encoder_alt, "qcamera.ts", 480, 360, CAMERA_FPS, 128000, false, true);
has_encoder_alt = true;
}
#endif
encoder_inited = true;
if (is_streaming) {
encoder.zmq_ctx = zmq_ctx_new();