static void mm_app_rdi_notify_cb(mm_camera_super_buf_t *bufs,
                                 void *user_data)
{
    int rc;
    mm_camera_buf_def_t *frame = NULL;
    mm_camera_app_obj_t *pme = NULL;
    CDBG("%s: BEGIN\n", __func__); 
    frame = bufs->bufs[0] ;
    pme = (mm_camera_app_obj_t *)user_data;

    CDBG("%s: BEGIN - length=%d, frame idx = %d\n", __func__, frame->frame_len, frame->frame_idx);

    //dumpFrameToFile(frame->frame,pme->dim.display_width,pme->dim.display_height,"preview", 1);
    dumpFrameToFile(frame,pme->dim.rdi0_width,pme->dim.rdi0_height,"rdi", 1);

    if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->cam->camera_handle,pme->ch_id,frame)) {
        CDBG_ERROR("%s: Failed in Preview Qbuf\n", __func__);
        return;
    }
    if (my_cam_app.run_sanity) {
        mm_camera_app_done(pme);
    }
    CDBG("%s: END\n", __func__); 

}
Ejemplo n.º 2
0
static void mm_app_rdi_notify_cb(mm_camera_super_buf_t *bufs,
                                 void *user_data)
{
    int rc;
    mm_camera_buf_def_t *frame = NULL;
    mm_camera_app_obj_t *pme = NULL;
    CDBG("%s: BEGIN\n", __func__); 
    frame = bufs->bufs[0] ;
    pme = (mm_camera_app_obj_t *)user_data;

    CDBG("%s: BEGIN - length=%d, frame idx = %d\n", __func__, frame->frame_len, frame->frame_idx);

    if (rdi_op_mode == MM_CAMERA_OP_MODE_VIDEO)
      dumpFrameToFile(frame,pme->dim.rdi0_width,pme->dim.rdi0_height,"rdi_p", 1,"raw");
    else {
      rdi_counter++;
      if (rdi_counter <=5)
        dumpRdi(frame,pme->dim.rdi0_width,pme->dim.rdi0_height,"rdi_s", 1);
    }
    if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->cam->camera_handle,
                                            pme->ch_id,
                                            frame)) {
        CDBG_ERROR("%s: Failed in Preview Qbuf\n", __func__);
        return;
    }
    mm_stream_invalid_cache(pme,frame);
    if (my_cam_app.run_sanity) {
        mm_camera_app_done(pme);
    }
    CDBG("%s: END\n", __func__); 

}
Ejemplo n.º 3
0
void mm_app_preview_notify_cb(mm_camera_super_buf_t *bufs,
                              void *user_data)
{
    int rc;
    mm_camera_buf_def_t *frame = NULL;
    mm_camera_app_obj_t *pme = NULL;
    CDBG("%s: BEGIN\n", __func__); 
    frame = bufs->bufs[MM_CAMERA_PREVIEW] ;
    pme = (mm_camera_app_obj_t *)user_data;

    CDBG("%s: BEGIN - length=%d, frame idx = %d\n", __func__, frame->frame_len, frame->frame_idx);

    //dumpFrameToFile(frame->frame,pme->dim.display_width,pme->dim.display_height,"preview", 1);
    dumpFrameToFile(frame,pme->dim.display_width,pme->dim.display_height,"preview", 1);
    if (!my_cam_app.run_sanity) {
        if (0 != (rc = mm_app_dl_render(frame->fd, NULL))) {
            CDBG("%s:DL rendering err=%d, frame fd=%d,frame idx = %d\n",
                 __func__, rc, frame->fd, frame->frame_idx);
        }
    }

    CDBG("In CB function i/p = %p o/p = %p",bufs->bufs[MM_CAMERA_PREVIEW],frame);

    if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->cam->camera_handle,pme->ch_id,frame)) {
        CDBG_ERROR("%s: Failed in Preview Qbuf\n", __func__);
        return;
    }
    if (my_cam_app.run_sanity) {
        preview_cb_signal(pme);
    }
    CDBG("%s: END\n", __func__); 

}
Ejemplo n.º 4
0
static void mm_app_zsl_notify_cb(mm_camera_super_buf_t *bufs,
                                 void *user_data)
{
    int rc;
    int i = 0;
    mm_camera_buf_def_t *preview_frame = NULL;
    mm_camera_buf_def_t *main_frame = NULL;
    mm_camera_buf_def_t *thumb_frame = NULL;
    mm_camera_app_obj_t *pme = NULL;
    CDBG("%s: BEGIN\n", __func__); 

    pme = (mm_camera_app_obj_t *)user_data;

    CDBG("%s : total streams = %d",__func__,bufs->num_bufs);
    preview_frame = bufs->bufs[0] ;
    main_frame = bufs->bufs[1];
    thumb_frame = bufs->bufs[0];

    //dumpFrameToFile(preview_frame->frame,pme->dim.display_width,pme->dim.display_height,"preview", 1);
    dumpFrameToFile(preview_frame,pme->dim.display_width,pme->dim.display_height,"zsl_preview", 1);
    if (0 != (rc = mm_app_dl_render(preview_frame->fd, NULL))) {
        CDBG("%s:DL rendering err=%d, frame fd=%d,frame idx = %d\n",
             __func__, rc, preview_frame->fd, preview_frame->frame_idx);
    }

    if (bufs->num_bufs == 2 && main_frame != NULL) {
        CDBG("mainframe frame_idx = %d fd = %d frame length = %d",main_frame->frame_idx,main_frame->fd,main_frame->frame_len);
        CDBG("thumnail frame_idx = %d fd = %d frame length = %d",thumb_frame->frame_idx,thumb_frame->fd,thumb_frame->frame_len);

        //dumpFrameToFile(main_frame->frame,pme->dim.picture_width,pme->dim.picture_height,"main", 1);
        //dumpFrameToFile(thumb_frame->frame,pme->dim.thumbnail_width,pme->dim.thumbnail_height,"thumb", 1);

        dumpFrameToFile(main_frame,pme->dim.picture_width,pme->dim.picture_height,"zsl_main", 1);
        dumpFrameToFile(thumb_frame,pme->dim.thumbnail_width,pme->dim.thumbnail_height,"zsl_thumb", 1);

        if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->cam->camera_handle,pme->ch_id,main_frame)) {
            CDBG_ERROR("%s: Failed in thumbnail Qbuf\n", __func__); 
        }
    }

    if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->cam->camera_handle,pme->ch_id,preview_frame)) {
        CDBG_ERROR("%s: Failed in Preview Qbuf\n", __func__); 
    }
    CDBG("%s: END\n", __func__);
}
Ejemplo n.º 5
0
/* This callback is received once the complete JPEG encoding is done */
static void snapshot_raw_cb(mm_camera_super_buf_t *bufs,
                            void *user_data)
{

    int rc;
    int i = 0;
    mm_camera_buf_def_t *main_frame = NULL;
    mm_camera_buf_def_t *thumb_frame = NULL;
    mm_camera_app_obj_t *pme = NULL;
    CDBG("%s: BEGIN\n", __func__);

    pme = (mm_camera_app_obj_t *)user_data;

    CDBG("%s : total streams = %d",__func__,bufs->num_bufs);
    main_frame = bufs->bufs[0];
    thumb_frame = bufs->bufs[1];

    CDBG("mainframe frame_idx = %d fd = %d frame length = %d",main_frame->frame_idx,main_frame->fd,main_frame->frame_len);
    CDBG("thumnail frame_idx = %d fd = %d frame length = %d",thumb_frame->frame_idx,thumb_frame->fd,thumb_frame->frame_len);

    //dumpFrameToFile(main_frame->frame,pme->dim.picture_width,pme->dim.picture_height,"main", 1);
    //dumpFrameToFile(thumb_frame->frame,pme->dim.thumbnail_width,pme->dim.thumbnail_height,"thumb", 1);

    dumpFrameToFile(main_frame,pme->dim.picture_width,pme->dim.picture_height,"main", 1);
    dumpFrameToFile(thumb_frame,pme->dim.thumbnail_width,pme->dim.thumbnail_height,"thumb", 1);

    if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->cam->camera_handle,pme->ch_id,main_frame)) {
        CDBG_ERROR("%s: Failed in thumbnail Qbuf\n", __func__);
    }
    if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->cam->camera_handle,pme->ch_id,thumb_frame)) {
        CDBG_ERROR("%s: Failed in thumbnail Qbuf\n", __func__);
    }

    mm_app_snapshot_done();
    CDBG("%s: END\n", __func__);


}
static void mm_app_video_notify_cb(mm_camera_super_buf_t *bufs,
	void *user_data)
{
	int rc;
	mm_camera_buf_def_t *frame = NULL;
	mm_camera_app_obj_t *pme = NULL;
	CDBG("%s: BEGIN\n", __func__); 
	frame = bufs->bufs[MM_CAMERA_PREVIEW] ;
	pme = (mm_camera_app_obj_t *)user_data;
	
	CDBG("%s: BEGIN - length=%d, frame idx = %d\n", __func__, frame->frame_len, frame->frame_idx);
	//Need to code to Send to Encoder .. Simulat
	CDBG("In CB function i/p = %p o/p = %p",bufs->bufs[MM_CAMERA_PREVIEW],frame);

	dumpFrameToFile(frame,pme->dim.orig_video_width,pme->dim.orig_video_height,"video", 1);
	if(MM_CAMERA_OK != pme->cam->ops->qbuf(pme->cam->camera_handle,pme->ch_id,frame))
	{
		CDBG_ERROR("%s: Failed in Snapshot Qbuf\n", __func__);
		return;
	}
    video_cb_signal(pme);
	CDBG("%s: END\n", __func__); 

}
Ejemplo n.º 7
0
static void snapshot_raw_cb(mm_camera_super_buf_t *recvd_frame,
                            void *user_data)
{
    int rc;
    int i = 0;
    mm_camera_buf_def_t *main_frame = NULL;
    mm_camera_app_obj_t *pme = NULL;

    CDBG("%s: BEGIN\n", __func__);

    pme = (mm_camera_app_obj_t *)user_data;

    if (pme->stream[MM_CAMERA_SNAPSHOT_MAIN].id == recvd_frame->bufs[i]->stream_id) {
        main_frame = recvd_frame->bufs[i];
        CDBG("mainframe frame_idx = %d fd = %d frame length = %d",main_frame->frame_idx,main_frame->fd,main_frame->frame_len);
        dumpFrameToFile(main_frame,pme->dim.raw_picture_width,pme->dim.raw_picture_height,"raw_main", 1,"raw");
    }
    if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->cam->camera_handle,pme->ch_id,
                                            main_frame)) {
        CDBG_ERROR("%s: Failed in Qbuf\n", __func__);
    }

    mm_app_snapshot_done();
}
Ejemplo n.º 8
0
static int encodeData(mm_camera_app_obj_t *pme,
                      mm_camera_super_buf_t* recvd_frame)
{
    int rc = -1;
    int i,index = -1;
    mm_jpeg_job job;
    mm_camera_buf_def_t *main_frame = NULL;
    mm_camera_buf_def_t *thumb_frame = NULL;
    src_image_buffer_info* main_buf_info = NULL;
    src_image_buffer_info* thumb_buf_info = NULL;
    mm_camera_frame_len_offset main_offset;
    mm_camera_frame_len_offset thumb_offset;

    /* dump raw img for debug purpose */
    CDBG("%s : total streams = %d",__func__,recvd_frame->num_bufs);
    for (i=0; i<recvd_frame->num_bufs; i++) {
        if (pme->stream[MM_CAMERA_SNAPSHOT_MAIN].id == recvd_frame->bufs[i]->stream_id) {
            main_frame = recvd_frame->bufs[i];
            CDBG("mainframe frame_idx = %d fd = %d frame length = %d",main_frame->frame_idx,main_frame->fd,main_frame->frame_len);
            dumpFrameToFile(main_frame,pme->dim.picture_width,pme->dim.picture_height,"main", 1,"yuv");
        } else if (pme->stream[MM_CAMERA_SNAPSHOT_THUMBNAIL].id == recvd_frame->bufs[i]->stream_id) {
            thumb_frame = recvd_frame->bufs[1];
            CDBG("thumnail frame_idx = %d fd = %d frame length = %d",thumb_frame->frame_idx,thumb_frame->fd,thumb_frame->frame_len);
            dumpFrameToFile(thumb_frame,pme->dim.thumbnail_width,pme->dim.thumbnail_height,"thumb", 1,"yuv");
        }
    }

    if (main_frame == NULL) {
        CDBG_ERROR("%s: Main frame is NULL", __func__);
        return rc;
    }

    /* remember current frames being encoded */
    pme->current_job_frames =
        (mm_camera_super_buf_t *)malloc(sizeof(mm_camera_super_buf_t));
    if (!pme->current_job_frames) {
        CDBG_ERROR("%s: No memory for current_job_frames", __func__);
        return rc;
    }
    memcpy(pme->current_job_frames, recvd_frame, sizeof(mm_camera_super_buf_t));

    memset(&job, 0, sizeof(job));
    job.job_type = JPEG_JOB_TYPE_ENCODE;
    job.encode_job.jpeg_cb = jpeg_encode_cb;
    job.encode_job.userdata = (void*)pme;
    job.encode_job.encode_parm.exif_data = NULL;
    job.encode_job.encode_parm.exif_numEntries = 0;
    job.encode_job.encode_parm.rotation = 0;
    job.encode_job.encode_parm.buf_info.src_imgs.src_img_num = recvd_frame->num_bufs;
    job.encode_job.encode_parm.rotation = 0;
    if (pme->my_id == 0) {
        /* back camera, rotate 90 */
        job.encode_job.encode_parm.rotation = 90;
    }

    /* fill in main src img encode param */
    main_buf_info = &job.encode_job.encode_parm.buf_info.src_imgs.src_img[JPEG_SRC_IMAGE_TYPE_MAIN];
    main_buf_info->type = JPEG_SRC_IMAGE_TYPE_MAIN;
    main_buf_info->color_format = MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V2; //TODO
    main_buf_info->quality = 85;
    main_buf_info->src_dim.width = pme->dim.picture_width;
    main_buf_info->src_dim.height = pme->dim.picture_height;
    main_buf_info->out_dim.width = pme->dim.picture_width;
    main_buf_info->out_dim.height = pme->dim.picture_height;
    main_buf_info->crop.width = pme->dim.picture_width;
    main_buf_info->crop.height = pme->dim.picture_height;
    main_buf_info->crop.offset_x = 0;
    main_buf_info->crop.offset_y = 0;
    main_buf_info->img_fmt = JPEG_SRC_IMAGE_FMT_YUV;
    main_buf_info->num_bufs = 1;
    main_buf_info->src_image[0].fd = main_frame->fd;
    main_buf_info->src_image[0].buf_vaddr = main_frame->buffer;
    pme->cam->ops->get_stream_parm(pme->cam->camera_handle,
                                   pme->ch_id,
                                   pme->stream[MM_CAMERA_SNAPSHOT_MAIN].id,
                                   MM_CAMERA_STREAM_OFFSET,
                                   &main_buf_info->src_image[0].offset);
    CDBG("%s: main offset: num_planes=%d, frame length=%d, y_offset=%d, cbcr_offset=%d",
         __func__, main_buf_info->src_image[0].offset.num_planes,
         main_buf_info->src_image[0].offset.frame_len,
         main_buf_info->src_image[0].offset.mp[0].offset,
         main_buf_info->src_image[0].offset.mp[1].offset);

    mm_stream_clear_invalid_cache(pme,main_frame);

    if (thumb_frame) {
        /* fill in thumbnail src img encode param */
        thumb_buf_info = &job.encode_job.encode_parm.buf_info.src_imgs.src_img[JPEG_SRC_IMAGE_TYPE_THUMB];
        thumb_buf_info->type = JPEG_SRC_IMAGE_TYPE_THUMB;
        thumb_buf_info->color_format = MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V2; //TODO
        thumb_buf_info->quality = 85;
        thumb_buf_info->src_dim.width = pme->dim.thumbnail_width;
        thumb_buf_info->src_dim.height = pme->dim.thumbnail_height;
        thumb_buf_info->out_dim.width = pme->dim.thumbnail_width;
        thumb_buf_info->out_dim.height = pme->dim.thumbnail_height;
        thumb_buf_info->crop.width = pme->dim.thumbnail_width;
        thumb_buf_info->crop.height = pme->dim.thumbnail_height;
        thumb_buf_info->crop.offset_x = 0;
        thumb_buf_info->crop.offset_y = 0;
        thumb_buf_info->img_fmt = JPEG_SRC_IMAGE_FMT_YUV;
        thumb_buf_info->num_bufs = 1;
        thumb_buf_info->src_image[0].fd = thumb_frame->fd;
        thumb_buf_info->src_image[0].buf_vaddr = thumb_frame->buffer;
        pme->cam->ops->get_stream_parm(pme->cam->camera_handle,
                                       pme->ch_id,
                                       pme->stream[MM_CAMERA_SNAPSHOT_THUMBNAIL].id,
                                       MM_CAMERA_STREAM_OFFSET,
                                       &thumb_buf_info->src_image[0].offset);
    }

    /* fill in sink img param */
    job.encode_job.encode_parm.buf_info.sink_img.buf_len = pme->jpeg_buf.bufs[0].frame_len;
    job.encode_job.encode_parm.buf_info.sink_img.buf_vaddr = pme->jpeg_buf.bufs[0].buffer;
    job.encode_job.encode_parm.buf_info.sink_img.fd = pme->jpeg_buf.bufs[0].fd;

    mm_stream_clear_invalid_cache(pme,thumb_frame);

    rc = pme->jpeg_ops.start_job(pme->jpeg_hdl, &job, &pme->current_job_id);
    if ( 0 != rc ) {
        free(pme->current_job_frames);
        pme->current_job_frames = NULL;
    }

    return rc;
}