Esempio n. 1
0
uint32_t mm_camera_get_msm_frame_len(cam_format_t fmt_type,
                                     camera_mode_t mode,
                                     int width,
                                     int height,
                                     int image_type,
                                     uint8_t *num_planes,
                                     uint32_t plane[])
{
    uint32_t size;
    *num_planes = 0;
    int local_height;

    switch (fmt_type) {
    case CAMERA_YUV_420_NV12:
    case CAMERA_YUV_420_NV21:
        *num_planes = 2;
        if(CAMERA_MODE_3D == mode) {
            size = (uint32_t)(PAD_TO_2K(width*height)*3/2);
            plane[0] = PAD_TO_WORD(width*height);
        } else {
            if (image_type == OUTPUT_TYPE_V) {
                plane[0] = PAD_TO_2K(width * height);
                plane[1] = PAD_TO_2K(width * height/2);
            } else if (image_type == OUTPUT_TYPE_P) {
                plane[0] = PAD_TO_WORD(width * height);
                plane[1] = PAD_TO_WORD(width * height/2);
            } else {
                plane[0] = PAD_TO_WORD(width * CEILING16(height));
                plane[1] = PAD_TO_WORD(width * CEILING16(height)/2);
            }
            size = plane[0] + plane[1];
        }
        break;
    case CAMERA_BAYER_SBGGR10:
        *num_planes = 1;
        plane[0] = PAD_TO_WORD(width * height);
        size = plane[0];
        break;
    case CAMERA_YUV_422_NV16:
    case CAMERA_YUV_422_NV61:
      if( image_type == OUTPUT_TYPE_S || image_type == OUTPUT_TYPE_V) {
        local_height = CEILING16(height);
      } else {
        local_height = height;
      }
        *num_planes = 2;
        plane[0] = PAD_TO_WORD(width * height);
        plane[1] = PAD_TO_WORD(width * height);
        size = plane[0] + plane[1];
        break;
    default:
        CDBG("%s: format %d not supported.\n",
            __func__, fmt_type);
        size = 0;
    }
    CDBG("%s:fmt=%d,image_type=%d,width=%d,height=%d,frame_len=%d\n",
        __func__, fmt_type, image_type, width, height, size);
    return size;
}
/* input buf processing */
int jpege_engine_hw_input_buf_enq (jpege_hw_obj_t gmn_obj,
  jpege_engine_hw_t *p_engine)
{
  unsigned int i;
  long n;
  int lumaHeight;
  int lumaWidth;
  int chromaHeight;
  int chromaWidth;

  if(p_engine->color_format == JPEGE_INPUT_H2V2){
      lumaHeight =  CEILING16(p_engine->luma_height);
      lumaWidth = CEILING16(p_engine->luma_width);
  }
  else{
      lumaHeight =  p_engine->luma_height;
      lumaWidth = p_engine->luma_width;
  }
  chromaHeight = p_engine->chroma_height;
  chromaWidth = p_engine->chroma_width;

  JPEG_DBG_MED("%s:%d jpeg input pmem %d offset %d \n", __func__, __LINE__,
    p_engine->input_pmem_flag, p_engine->p_input_luma->phy_offset);
  if (p_engine->input_pmem_flag) {
    input_buf[0].y_len = lumaWidth * lumaHeight;
    if (p_engine->num_of_input_planes == 2) {
      input_buf[0].cbcr_len = chromaWidth * chromaHeight;
      input_buf[0].cr_len = 0;
    }
    else if (p_engine->num_of_input_planes == 3) {
      input_buf[0].cbcr_len = floor(chromaWidth * chromaHeight)/2;
      input_buf[0].cr_len = floor(chromaWidth * chromaHeight)/2;
    }
    else{
      input_buf[0].cbcr_len = 0;
      input_buf[0].cr_len = 0;
    }
    input_buf[0].cr_offset = 0;
    input_buf[0].vaddr = p_engine->p_input_luma->ptr;
    input_buf[0].fd = p_engine->p_input_luma->pmem_fd;
    input_buf[0].num_of_mcu_rows = lumaHeight >> MCU_SIZE;
    input_buf[0].offset = p_engine->p_input_luma->phy_offset;
    JPEG_DBG_ERROR ("%s: lumaHeight =%d lumaWidth=%d chromaWidth =%d ylen = %d,"
      "chromaHeight=%d cbcr_length=%d offset=%d y_off = %d cbcr_off = %d\n",
      __func__, lumaHeight, lumaWidth,chromaWidth, input_buf[0].y_len,
      chromaHeight, input_buf[0].cbcr_len, input_buf[0].offset,
      input_buf[0].y_off, input_buf[0].cbcr_off);

    jpege_lib_input_buf_enq (gmn_obj, &input_buf[0]);
  }
static int decode_init(jpeg_test_input_t *p_input, mm_jpegdec_intf_test_t *p_obj)
{
  int rc = -1;
  int size = CEILING16(p_input->width) * CEILING16(p_input->height);
  float cScale;
  mm_jpeg_decode_params_t *p_params = &p_obj->params;
  mm_jpeg_decode_job_t *p_job_params = &p_obj->job.decode_job;

  p_obj->filename = p_input->filename;
  p_obj->width = p_input->width;
  p_obj->height = p_input->height;
  p_obj->out_filename = p_input->out_filename;
  p_obj->use_ion = 1;

  pthread_mutex_init(&p_obj->lock, NULL);
  pthread_cond_init(&p_obj->cond, NULL);

  chromaScale(p_input->format, &cScale);
  p_obj->output.size = size * cScale;
  rc = mm_jpegdec_test_alloc(&p_obj->output, p_obj->use_ion);
  if (rc) {
    CDBG_ERROR("%s:%d] Error",__func__, __LINE__);
    return -1;
  }

  rc = mm_jpegdec_test_read(p_obj);
  if (rc) {
    CDBG_ERROR("%s:%d] Error",__func__, __LINE__);
    return -1;
  }

  /* set encode parameters */
  p_params->jpeg_cb = mm_jpegdec_decode_callback;
  p_params->userdata = p_obj;
  p_params->color_format = p_input->format;

  /* dest buffer config */
  p_params->dest_buf[0].buf_size = p_obj->output.size;
  p_params->dest_buf[0].buf_vaddr = p_obj->output.addr;
  p_params->dest_buf[0].fd = p_obj->output.p_pmem_fd;
  p_params->dest_buf[0].format = MM_JPEG_FMT_YUV;
  p_params->dest_buf[0].offset.mp[0].len = size;
  p_params->dest_buf[0].offset.mp[1].len = size * (cScale-1.0);
  p_params->dest_buf[0].offset.mp[0].stride = CEILING16(p_input->width);
  p_params->dest_buf[0].offset.mp[0].scanline = CEILING16(p_input->height);
  p_params->dest_buf[0].offset.mp[1].stride = CEILING16(p_input->width);
  p_params->dest_buf[0].offset.mp[1].scanline = CEILING16(p_input->height);
  p_params->dest_buf[0].index = 0;
  p_params->num_dst_bufs = 1;

  /* src buffer config*/
  p_params->src_main_buf[0].buf_size = p_obj->input.size;
  p_params->src_main_buf[0].buf_vaddr = p_obj->input.addr;
  p_params->src_main_buf[0].fd = p_obj->input.p_pmem_fd;
  p_params->src_main_buf[0].index = 0;
  p_params->src_main_buf[0].format = MM_JPEG_FMT_BITSTREAM;
  /*
  p_params->src_main_buf[0].offset.mp[0].len = size;
  p_params->src_main_buf[0].offset.mp[1].len = size >> 1;
  */
  p_params->num_src_bufs = 1;

  p_job_params->dst_index = 0;
  p_job_params->src_index = 0;
  p_job_params->rotation = 0;

  /* main dimension */
  p_job_params->main_dim.src_dim.width = p_obj->width;
  p_job_params->main_dim.src_dim.height = p_obj->height;
  p_job_params->main_dim.dst_dim.width = p_obj->width;
  p_job_params->main_dim.dst_dim.height = p_obj->height;
  p_job_params->main_dim.crop.top = 0;
  p_job_params->main_dim.crop.left = 0;
  p_job_params->main_dim.crop.width = p_obj->width;
  p_job_params->main_dim.crop.height = p_obj->height;


  return 0;
}