Skip to content

toxav.c causing low FPS due to bad memory allocationΒ #1601

@vassad

Description

@vassad

Android tox client (Antox) is suffering from low FPS. Investigating this issue, i came to the native implementation of tox, which could faster up much the FPS.

toxav_video_send_frame method in toxav.c has quite heavy and unnecessary memory allocation for each frame to encode.

vpx_img_alloc(&img, VPX_IMG_FMT_I420, width, height, 0);

  • this one could be allocated only once, when the video capture is started.
memcpy(img.planes[VPX_PLANE_Y], y, width * height);
memcpy(img.planes[VPX_PLANE_U], u, (width / 2) * (height / 2));
memcpy(img.planes[VPX_PLANE_V], v, (width / 2) * (height / 2));
  • these could use the links to y,u,v arrays, instead of copying the data each frame. Or am i wrong, and vpx codec needs the y,u,v data to be side-by-side organized in memory, and we cannot avoid copying the data?

So:

  1. We can create the static field for the img each time the video capture begins, and free it when video capture stops. This could lead to the proplems when several threads will want to access this object, so i want a discussion to decide the best way to solve the issue.
  2. We can pass the link to y,u,v arrays instead of copying the data - or no?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions