diff --git a/selfdrive/loggerd/encoder.c b/selfdrive/loggerd/encoder.c index 714293c788..d50002976d 100644 --- a/selfdrive/loggerd/encoder.c +++ b/selfdrive/loggerd/encoder.c @@ -442,6 +442,12 @@ static void handle_out_buf(EncoderState *s, OMX_BUFFERHEADERTYPE *out_buf) { } // give omx back the buffer +#ifdef QCOM2 + if ((out_buf->nFlags & OMX_BUFFERFLAG_EOS) || + (out_buf->nFlags & OMX_BUFFERFLAG_CODECCONFIG)) { + out_buf->nTimeStamp = 0; + } +#endif err = OMX_FillThisBuffer(s->handle, out_buf); assert(err == OMX_ErrorNone); } @@ -513,6 +519,7 @@ int encoder_encode_frame(EncoderState *s, in_buf->nFlags = OMX_BUFFERFLAG_ENDOFFRAME; in_buf->nOffset = 0; in_buf->nTimeStamp = extra->timestamp_eof/1000LL; // OMX_TICKS, in microseconds + s->last_t = in_buf->nTimeStamp; err = OMX_EmptyThisBuffer(s->handle, in_buf); assert(err == OMX_ErrorNone); @@ -555,9 +562,6 @@ void encoder_open(EncoderState *s, const char* path) { avformat_alloc_output_context2(&s->ofmt_ctx, NULL, NULL, s->vid_path); assert(s->ofmt_ctx); -#ifdef QCOM2 - s->ofmt_ctx->oformat->flags = AVFMT_TS_NONSTRICT; -#endif s->out_stream = avformat_new_stream(s->ofmt_ctx, NULL); assert(s->out_stream); @@ -583,7 +587,9 @@ void encoder_open(EncoderState *s, const char* path) { s->of = fopen(s->vid_path, "wb"); assert(s->of); if (s->codec_config_len > 0) { +#ifndef QCOM2 fwrite(s->codec_config, s->codec_config_len, 1, s->of); +#endif } } @@ -612,7 +618,7 @@ void encoder_close(EncoderState *s) { in_buf->nFilledLen = 0; in_buf->nOffset = 0; in_buf->nFlags = OMX_BUFFERFLAG_EOS; - in_buf->nTimeStamp = 0; + in_buf->nTimeStamp = s->last_t + 1000000LL/s->fps; err = OMX_EmptyThisBuffer(s->handle, in_buf); assert(err == OMX_ErrorNone); diff --git a/selfdrive/loggerd/encoder.h b/selfdrive/loggerd/encoder.h index abd9d18c53..8036162b24 100644 --- a/selfdrive/loggerd/encoder.h +++ b/selfdrive/loggerd/encoder.h @@ -53,6 +53,8 @@ typedef struct EncoderState { int num_out_bufs; OMX_BUFFERHEADERTYPE** out_buf_headers; + uint64_t last_t; + Queue free_in; Queue done_out;