diff --git a/SConstruct b/SConstruct index 5894c2ab66..6e3bc44f91 100644 --- a/SConstruct +++ b/SConstruct @@ -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'], diff --git a/external/ffmpeg/larch64/.gitignore b/external/ffmpeg/larch64/.gitignore new file mode 100644 index 0000000000..565b7ee23f --- /dev/null +++ b/external/ffmpeg/larch64/.gitignore @@ -0,0 +1 @@ +ffmpeg-4.2.2* diff --git a/external/ffmpeg/larch64/build.sh b/external/ffmpeg/larch64/build.sh new file mode 100755 index 0000000000..ffa5a089e5 --- /dev/null +++ b/external/ffmpeg/larch64/build.sh @@ -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 + diff --git a/selfdrive/camerad/cameras/camera_qcom2.c b/selfdrive/camerad/cameras/camera_qcom2.c index 20c786a94f..75fa803a53 100644 --- a/selfdrive/camerad/cameras/camera_qcom2.c +++ b/selfdrive/camerad/cameras/camera_qcom2.c @@ -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; } } diff --git a/selfdrive/camerad/main.cc b/selfdrive/camerad/main.cc index 73f9a85dda..9a40e3d8d8 100644 --- a/selfdrive/camerad/main.cc +++ b/selfdrive/camerad/main.cc @@ -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 diff --git a/selfdrive/loggerd/SConscript b/selfdrive/loggerd/SConscript index 1feb899c2a..0366e47001 100644 --- a/selfdrive/loggerd/SConscript +++ b/selfdrive/loggerd/SConscript @@ -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) diff --git a/selfdrive/loggerd/encoder.c b/selfdrive/loggerd/encoder.c index 747c7a1957..b9a718dd49 100644 --- a/selfdrive/loggerd/encoder.c +++ b/selfdrive/loggerd/encoder.c @@ -15,7 +15,7 @@ #include -#include +//#include #include @@ -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); diff --git a/selfdrive/loggerd/loggerd.cc b/selfdrive/loggerd/loggerd.cc index 0e5c5457df..382cdc69bb 100644 --- a/selfdrive/loggerd/loggerd.cc +++ b/selfdrive/loggerd/loggerd.cc @@ -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();