Hi,
I am using the TI h264 encoder. I wanted to evaluate how much load and time is consumed if I were to copy the encoded buffer to a malloc buffer. I have seen some inconsistencies between the memory access of shared buffers.
Experiment 1:
I have used the videnc2test application. I have added copy from the encoded buffer to a malloc buffer. I have encoded 1080p60 frames using this. I see that the ARM load is about 2% and time taken to copy is around 1ms
Experiment 2:
I have written a separate test appication which copies 1920x1080 bytes from shared buffer to malloc buffer every 16ms. I see that it consumes 50% load and takes around 36ms to copy.
I want to usderstand the difference between the two
I have copied my test application below:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libdce.h>
#include <xf86drm.h>
#include <omap_drm.h>
#include <omap_drmif.h>
int get_time()
{
struct timeval time_val;
int cur_time;
/* Get time of the day */
gettimeofday(&time_val, NULL);
/* Convert time in seconds and micro seconds into milliseconds time */
cur_time = time_val.tv_sec*1000 + time_val.tv_usec/1000;
return cur_time;
}
int sleep(int milli_seconds)
{
struct timespec timer;
/* Convert time in milliseconds into seconds and nano seconds */
timer.tv_sec = milli_seconds / 1000;
milli_seconds -= (timer.tv_sec * 1000);
timer.tv_nsec = milli_seconds * 1000 * 1000;
if(0 == nanosleep(&timer, NULL))
return 0;
return -1;
}
void main(int argc, char *argv[])
{
int u4_buf_size, u4_time = 0;
int u4_start, u4_end, u4_copy_time = 0;
int i4_sleep_time = 0;
int u4_i, u4_num_bufs = 0;
char* pi1_src[20] = {0};
char* pi1_dst[20] = {0};
struct omap_bo *pps_buffer_obj[20] = {0};
struct omap_device *dev = NULL;
int i4_status = 0;
int i4_fd[20] = {0};
if(3 != argc)
{
printf("usage: ./profile.out <Buffer size> <time in ms>\n");
return;
}
u4_buf_size = atoi(argv[1]);
u4_time = atoi(argv[2]);
if(0 == u4_buf_size || 0 == u4_time)
{
printf("Invalid buffer size or time\n");
return;
}
u4_num_bufs = 20;
printf("buffer size:%d\n",u4_buf_size);
dev = dce_init();
if(dev == NULL)
{
printf("Failed to initialize dce\n");
return;
}
for(u4_i=0; u4_i<u4_num_bufs; u4_i++)
{
pps_buffer_obj[u4_i] = omap_bo_new(dev, u4_buf_size, OMAP_BO_WC);
if(NULL == pps_buffer_obj[u4_i])
{
printf("Failed to allocate memory for source\n");
return;
}
i4_fd[u4_i] = omap_bo_dmabuf(pps_buffer_obj[u4_i]);
pi1_src[u4_i] = omap_bo_map(pps_buffer_obj[u4_i]);
if(NULL == pi1_src[u4_i])
{
printf("Failed to map sorce buffers\n");
return;
}
i4_status = omap_bo_cpu_prep(\
pps_buffer_obj[u4_i], \
OMAP_GEM_WRITE);
if(0 != i4_status)
{
printf("Failed to prep\n");
}
memset(pi1_src[u4_i],128,u4_buf_size);
pi1_dst[u4_i] = malloc(u4_buf_size);
if(NULL == pi1_dst[u4_i])
{
printf("Failed to allocate memory for destination\n");
return;
}
memset(pi1_dst[u4_i],0,u4_buf_size);
}
while(1)
{
for(u4_i=0; u4_i<u4_num_bufs; u4_i++)
{
u4_start = get_time();
memcpy(pi1_dst[u4_i],pi1_src[u4_i],u4_buf_size);
u4_end = get_time();
u4_copy_time = u4_end - u4_start;
printf("time taken to copy:%d\n",u4_copy_time);
i4_sleep_time = u4_time - u4_copy_time;
if(0 < i4_sleep_time)
{
sleep(i4_sleep_time);
}
}
u4_i = 0;
}
}