示例#1
0
C_RESULT video_encode_picture( video_controller_t* controller, const vp_api_picture_t* picture, bool_t* got_image )
{
  vp_api_picture_t blockline = { 0 };

  controller->mode  = VIDEO_ENCODE;

  video_controller_set_format( controller, picture->width, picture->height );

  blockline                   = *picture;
  blockline.height            = MB_HEIGHT_Y;
  blockline.complete          = 1;
  blockline.vision_complete   = 0;

  // Reset internal stream for new blockline/picture
  controller->in_stream.used  = 0;
  controller->in_stream.index = 0;

  while( !controller->picture_complete )
  {
    video_encode_blockline( controller, &blockline, blockline.blockline == (controller->num_blockline-1) );

    blockline.y_buf  += MB_HEIGHT_Y * picture->y_line_size;
    blockline.cb_buf += MB_HEIGHT_C * picture->cb_line_size;
    blockline.cr_buf += MB_HEIGHT_C * picture->cr_line_size;

    blockline.blockline++;
  }

  if( picture->complete )
  {
    video_write_data( &controller->in_stream, 0, controller->in_stream.length+1 );
    controller->in_stream.length = 32;
    controller->picture_complete = 0;
    *got_image = TRUE;
  }

  return C_OK;
}
示例#2
0
C_RESULT vlib_stage_encoding_transform(vlib_stage_encoding_config_t *cfg, vp_api_io_data_t *in, vp_api_io_data_t *out)
{
  static int32_t local_subsampl = 0;

  vp_os_mutex_lock(&out->lock);

  if( out->status == VP_API_STATUS_INIT )
  {
    out->numBuffers   = 1;
    out->buffers      = (int8_t**)(int8_t*)&cfg->controller.in_stream.bytes;
    out->indexBuffer  = 0;

    out->status = VP_API_STATUS_PROCESSING;

    cfg->current_size = 0;
  }

  if( local_subsampl == 0 && out->status == VP_API_STATUS_PROCESSING )
  {
    RTMON_USTART(VIDEO_VLIB_ENCODE_EVENT);
    if(cfg->block_mode_enable)
      video_encode_blockline( &cfg->controller, cfg->picture, cfg->picture->complete );
    else
      video_encode_picture( &cfg->controller, cfg->picture, (bool_t*)&cfg->picture->complete );
    RTMON_USTOP(VIDEO_VLIB_ENCODE_EVENT);

    if(cfg->picture->complete)
    {
      RTMON_UVAL(ENCODED_PICTURE_UVAL, cfg->controller.num_frames);
      local_subsampl++;
    }

    cfg->current_size = cfg->controller.in_stream.used;

    if( cfg->controller.in_stream.length != 32 )
    {
      // flush & reset internal stream
      video_write_data( &cfg->controller.in_stream, 0, cfg->controller.in_stream.length+1 );
      cfg->controller.in_stream.length = 32;
    }
    out->size = cfg->controller.in_stream.used;

    RTMON_UVAL(ENCODED_BLOCKLINE_SIZE_UVAL, out->size);

    cfg->controller.in_stream.used  = 0;
    cfg->controller.in_stream.index = 0;
  }
  else
  {
    out->size = 0;

    if( cfg->picture->complete )
    {
      local_subsampl++;
    }
  }

  if(local_subsampl >= (int32_t)cfg->subsampl)
    local_subsampl = 0;

  vp_os_mutex_unlock( &out->lock );

  return C_OK;
}