int num_bos;
tbm_surface_h surface = NULL;
tbm_surface_info_s surface_info;
+ tbm_bo_handle handle_bo;
if (!pkt) {
LOGE("output is null");
mm_vbuffer->stride_height[0] = surface_info.planes[0].size / surface_info.planes[0].stride;
mm_vbuffer->stride_width[1] = surface_info.planes[1].stride;
mm_vbuffer->stride_height[1] = surface_info.planes[1].size / surface_info.planes[1].stride;
+
+ if (mm_vbuffer->handle.bo[0]) {
+ handle_bo = tbm_bo_get_handle(mm_vbuffer->handle.bo[0], TBM_DEVICE_CPU);
+ mm_vbuffer->data[0]= handle_bo.ptr;
+
+ handle_bo = tbm_bo_get_handle(mm_vbuffer->handle.bo[0], TBM_DEVICE_MM);
+ mm_vbuffer->handle.dmabuf_fd[0]= handle_bo.u32;
+ }
+
+ if (mm_vbuffer->handle.bo[1]) {
+ handle_bo = tbm_bo_get_handle(mm_vbuffer->handle.bo[1], TBM_DEVICE_CPU);
+ mm_vbuffer->data[1]= handle_bo.ptr;
+
+ handle_bo = tbm_bo_get_handle(mm_vbuffer->handle.bo[1], TBM_DEVICE_MM);
+ mm_vbuffer->handle.dmabuf_fd[1]= handle_bo.u32;
+ } else {
+ mm_vbuffer->data[1] = mm_vbuffer->data[0] + mm_vbuffer->stride_width[0] * mm_vbuffer->stride_height[0];
+ }
mm_vbuffer->plane_num = 2;
LOGD("size[0] : %d, size[1] : %d, bo[0] :%p, bo[1] :%p", mm_vbuffer->size[0], mm_vbuffer->size[1], mm_vbuffer->handle.bo[0], mm_vbuffer->handle.bo[1]);
return MC_ERROR;
}
- media_packet_pool_get_size(pool, &min_size, &max_size, &curr_size);
- LOGD("curr_size is %d min_size is %d and max_size is %d \n", curr_size, min_size, max_size);
-
ret = media_packet_pool_allocate(pool);
if (ret != MEDIA_PACKET_ERROR_NONE) {
LOGE("media_packet_pool_allocate failed");
return MC_OUT_OF_MEMORY;
}
+ media_packet_pool_get_size(pool, &min_size, &max_size, &curr_size);
+ LOGD("curr_size is %d min_size is %d and max_size is %d \n", curr_size, min_size, max_size);
+
*pkt_pool = pool;
return MC_ERROR_NONE;
}
((state & (expected_state)) == (expected_state))
#define AAC_CODECDATA_SIZE 16
+#define USE_POOL 1
unsigned char buf_adts[ADTS_HEADER_SIZE];
media_packet_h pkt = NULL;
unsigned char *tmp;
int read;
+ int size;
int offset;
- int stride_width, stride_height;
+ int stride_width;
for (i = 0; i < app->frame; i++) {
g_print("----------read data------------\n");
extractor(app, &tmp, &read, &have_frame);
if (have_frame) {
- if (media_packet_create_alloc(fmt, NULL, NULL, &pkt) != MEDIA_PACKET_ERROR_NONE) {
- fprintf(stderr, "media_packet_create_alloc failed\n");
- return;
- }
+#ifdef USE_POOL
+ if (media_packet_pool_acquire_packet(pkt_pool, &pkt, -1) != MEDIA_PACKET_ERROR_NONE) {
+ fprintf(stderr, "media_packet_pool_aquire_packet failed\n");
+ return;
+ }
+#else
+ if (media_packet_create_alloc(fmt, NULL, NULL, &pkt) != MEDIA_PACKET_ERROR_NONE) {
+ fprintf(stderr, "media_packet_create_alloc failed\n");
+ return;
+ }
+#endif
if (media_packet_set_pts(pkt, (uint64_t)(pts)) != MEDIA_PACKET_ERROR_NONE) {
fprintf(stderr, "media_packet_set_pts failed\n");
/* Y */
media_packet_get_video_plane_data_ptr(pkt, 0, &buf_data_ptr);
media_packet_get_video_stride_width(pkt, 0, &stride_width);
- media_packet_get_video_stride_height(pkt, 0, &stride_height);
+ offset = app->width*app->height;
+
+ for (i = 0; i < app->height; i++) {
+ memcpy(buf_data_ptr, tmp, app->width);
+ buf_data_ptr += stride_width;
+ tmp += app->width;
+ }
- offset = stride_width*stride_height;
+ if (app->hardware == TRUE) {
+ media_packet_get_video_plane_data_ptr(pkt, 1, &buf_data_ptr);
+ media_packet_get_video_stride_width(pkt, 1, &stride_width);
+ size = app->width * app->height / 2;
- memcpy(buf_data_ptr, tmp, offset);
+ for (i = 0; i< app->height / 2; i++) {
+ memcpy(buf_data_ptr, tmp, app->width);
+ buf_data_ptr += stride_width;
+ tmp += app->width;
+ }
+ } else {
+ /* U */
+ media_packet_get_video_plane_data_ptr(pkt, 1, &buf_data_ptr);
+ media_packet_get_video_stride_width(pkt, 1, &stride_width);
+ size = (app->width>>1) * (app->height>>1);
- /* UV or U*/
- media_packet_get_video_plane_data_ptr(pkt, 1, &buf_data_ptr);
- media_packet_get_video_stride_width(pkt, 1, &stride_width);
- media_packet_get_video_stride_height(pkt, 1, &stride_height);
- memcpy(buf_data_ptr, tmp + offset, stride_width*stride_height);
+ for (i = 0; i < app->height/2; i++) {
+ memcpy(buf_data_ptr, tmp, app->width/2);
+ buf_data_ptr += stride_width;
+ tmp += app->width/2;
+ }
- if (app->hardware == FALSE) {
/* V */
media_packet_get_video_plane_data_ptr(pkt, 2, &buf_data_ptr);
media_packet_get_video_stride_width(pkt, 2, &stride_width);
- media_packet_get_video_stride_height(pkt, 2, &stride_height);
+ offset += size;
- offset += stride_width * stride_height;
+ for (i = 0; i < app->height/2; i++) {
+ memcpy(buf_data_ptr, tmp, app->width/2);
+ buf_data_ptr += stride_width;
+ tmp += app->width/2;
+ }
-
- memcpy(buf_data_ptr, tmp + offset, stride_width*stride_height);
}
}
mc_hex_dump("inbuf", tmp, 48);
void *buf_data_ptr = NULL;
media_packet_h pkt = NULL;
unsigned char *tmp;
+ int i;
int read;
+ int size;
int offset;
- int stride_width, stride_height;
+ int stride_width;
if (app->offset == 0) {
app->frame_count = 0;
return FALSE;
}
+
if (app->type != VIDEO_ENC) {
media_packet_get_buffer_data_ptr(pkt, &buf_data_ptr);
media_packet_set_buffer_size(pkt, (uint64_t)read);
/* Y */
media_packet_get_video_plane_data_ptr(pkt, 0, &buf_data_ptr);
media_packet_get_video_stride_width(pkt, 0, &stride_width);
- media_packet_get_video_stride_height(pkt, 0, &stride_height);
+ offset = app->width*app->height;
+
+ for (i = 0; i < app->height; i++) {
+ memcpy(buf_data_ptr, tmp, app->width);
+ buf_data_ptr += stride_width;
+ tmp += app->width;
+ }
+
+ if (app->hardware == TRUE) {
+ media_packet_get_video_plane_data_ptr(pkt, 1, &buf_data_ptr);
+ media_packet_get_video_stride_width(pkt, 1, &stride_width);
+ size = app->width * app->height>>1;
- offset = stride_width*stride_height;
+ for (i = 0; i < app->height>>1; i++) {
+ memcpy(buf_data_ptr, tmp, app->width);
+ buf_data_ptr += stride_width;
+ tmp += app->width;
+ }
- memcpy(buf_data_ptr, tmp, offset);
+ } else {
+ /* U */
+ media_packet_get_video_plane_data_ptr(pkt, 1, &buf_data_ptr);
+ media_packet_get_video_stride_width(pkt, 1, &stride_width);
+ size = (app->width>>1) * (app->height>>1);
- /* UV or U*/
- media_packet_get_video_plane_data_ptr(pkt, 1, &buf_data_ptr);
- media_packet_get_video_stride_width(pkt, 1, &stride_width);
- media_packet_get_video_stride_height(pkt, 1, &stride_height);
- memcpy(buf_data_ptr, tmp + offset, stride_width*stride_height);
+ for (i = 0; i < app->height/2; i++) {
+ memcpy(buf_data_ptr, tmp, app->width>>1);
+ buf_data_ptr += stride_width;
+ tmp += (app->width>>1);
+ }
- if (app->hardware == FALSE) {
/* V */
media_packet_get_video_plane_data_ptr(pkt, 2, &buf_data_ptr);
media_packet_get_video_stride_width(pkt, 2, &stride_width);
- media_packet_get_video_stride_height(pkt, 2, &stride_height);
-
- offset += stride_width * stride_height;
+ offset += size;
+ for (i = 0; i < app->height/2; i++) {
+ memcpy(buf_data_ptr, tmp, app->width>>1);
+ buf_data_ptr += stride_width;
+ tmp += (app->width>>1);
+ }
- memcpy(buf_data_ptr, tmp + offset, stride_width*stride_height);
}
}
mc_hex_dump("inbuf", tmp, 48);