diff --git a/camera.cpp b/camera.cpp index 7b2084b..9ecec38 100644 --- a/camera.cpp +++ b/camera.cpp @@ -293,8 +293,6 @@ static void on_request_complete(Request *request) { camp->frame_cb( camp->mapped_buffers.at(buffer), - camp->video_stream->configuration().stride, - camp->video_stream->configuration().size.height, buffer->planes()[0].fd.get(), buffer_size(buffer->planes()), ts); @@ -310,12 +308,12 @@ static void on_request_complete(Request *request) { camp->camera->queueRequest(request); } -int camera_get_mode_stride(camera_t *cam) { +int camera_get_stride(camera_t *cam) { CameraPriv *camp = (CameraPriv *)cam; return camp->video_stream->configuration().stride; } -int camera_get_mode_colorspace(camera_t *cam) { +int camera_get_colorspace(camera_t *cam) { CameraPriv *camp = (CameraPriv *)cam; return get_v4l2_colorspace(camp->video_stream->configuration().colorSpace); } diff --git a/camera.h b/camera.h index 467a7cc..e2c70c4 100644 --- a/camera.h +++ b/camera.h @@ -7,8 +7,6 @@ typedef void camera_t; typedef void (*camera_frame_cb)( uint8_t *mapped_buffer, - int stride, - int height, int buffer_fd, uint64_t size, uint64_t timestamp); @@ -19,8 +17,8 @@ extern "C" { const char *camera_get_error(); bool camera_create(const parameters_t *params, camera_frame_cb frame_cb, camera_t **cam); -int camera_get_mode_stride(camera_t *cam); -int camera_get_mode_colorspace(camera_t *cam); +int camera_get_stride(camera_t *cam); +int camera_get_colorspace(camera_t *cam); bool camera_start(camera_t *cam); void camera_reload_params(camera_t *cam, const parameters_t *params); diff --git a/encoder.h b/encoder.h index 8fc6518..6f6e7af 100644 --- a/encoder.h +++ b/encoder.h @@ -5,7 +5,10 @@ typedef void encoder_t; -typedef void (*encoder_output_cb)(uint64_t ts, const uint8_t *buf, uint64_t size); +typedef void (*encoder_output_cb)( + uint64_t ts, + const uint8_t *buf, + uint64_t size); const char *encoder_get_error(); bool encoder_create(const parameters_t *params, int stride, int colorspace, encoder_output_cb output_cb, encoder_t **enc); diff --git a/main.c b/main.c index 4a1df04..c3337d1 100644 --- a/main.c +++ b/main.c @@ -19,12 +19,10 @@ static encoder_t *enc; static void on_frame( uint8_t *mapped_buffer, - int stride, - int height, int buffer_fd, uint64_t size, uint64_t timestamp) { - text_draw(text, mapped_buffer, stride, height); + text_draw(text, mapped_buffer); encoder_encode(enc, mapped_buffer, buffer_fd, size, timestamp); } @@ -67,7 +65,10 @@ int main() { return -1; } - ok = text_create(¶ms, &text); + ok = text_create( + ¶ms, + camera_get_stride(cam), + &text); if (!ok) { pipe_write_error(pipe_video_fd, "text_create(): %s", text_get_error()); return -1; @@ -75,8 +76,8 @@ int main() { ok = encoder_create( ¶ms, - camera_get_mode_stride(cam), - camera_get_mode_colorspace(cam), + camera_get_stride(cam), + camera_get_colorspace(cam), on_encoder_output, &enc); if (!ok) { diff --git a/text.c b/text.c index fd7e50e..da28a94 100644 --- a/text.c +++ b/text.c @@ -22,17 +22,21 @@ const char *text_get_error() { typedef struct { bool enabled; char *text_overlay; + int stride; + int height; FT_Library library; FT_Face face; } text_priv_t; -bool text_create(const parameters_t *params, text_t **text) { +bool text_create(const parameters_t *params, int stride, text_t **text) { *text = malloc(sizeof(text_priv_t)); text_priv_t *textp = (text_priv_t *)(*text); memset(textp, 0, sizeof(text_priv_t)); textp->enabled = params->text_overlay_enable; textp->text_overlay = strdup(params->text_overlay); + textp->stride = stride; + textp->height = params->height; if (textp->enabled) { int error = FT_Init_FreeType(&textp->library); @@ -130,7 +134,7 @@ static int get_text_width(FT_Face face, const char *text) { return ret; } -void text_draw(text_t *text, uint8_t *buf, int stride, int height) { +void text_draw(text_t *text, uint8_t *buf) { text_priv_t *textp = (text_priv_t *)text; if (textp->enabled) { @@ -142,8 +146,8 @@ void text_draw(text_t *text, uint8_t *buf, int stride, int height) { draw_rect( buf, - stride, - height, + textp->stride, + textp->height, 7, 7, get_text_width(textp->face, buffer) + 10, @@ -160,8 +164,8 @@ void text_draw(text_t *text, uint8_t *buf, int stride, int height) { draw_bitmap( buf, - stride, - height, + textp->stride, + textp->height, &textp->face->glyph->bitmap, x + textp->face->glyph->bitmap_left, y - textp->face->glyph->bitmap_top); diff --git a/text.h b/text.h index 235bf7a..b7b5888 100644 --- a/text.h +++ b/text.h @@ -9,7 +9,7 @@ typedef void text_t; const char *text_get_error(); -bool text_create(const parameters_t *params, text_t **text); -void text_draw(text_t *text, uint8_t *buf, int stride, int height); +bool text_create(const parameters_t *params, int stride, text_t **text); +void text_draw(text_t *text, uint8_t *buf); #endif