当前位置: 首页>>代码示例>>C++>>正文


C++ DllBcmHost::vc_tv_hdmi_power_on_explicit方法代码示例

本文整理汇总了C++中DllBcmHost::vc_tv_hdmi_power_on_explicit方法的典型用法代码示例。如果您正苦于以下问题:C++ DllBcmHost::vc_tv_hdmi_power_on_explicit方法的具体用法?C++ DllBcmHost::vc_tv_hdmi_power_on_explicit怎么用?C++ DllBcmHost::vc_tv_hdmi_power_on_explicit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DllBcmHost的用法示例。


在下文中一共展示了DllBcmHost::vc_tv_hdmi_power_on_explicit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetVideoMode

void SetVideoMode(int width, int height, float fps, bool is3d)
{
  int32_t num_modes;
  HDMI_RES_GROUP_T prefer_group;
  int i = 0;
  uint32_t prefer_mode;
  #define TV_MAX_SUPPORTED_MODES 60
  TV_SUPPORTED_MODE_T supported_modes[TV_MAX_SUPPORTED_MODES];
  uint32_t group = HDMI_RES_GROUP_CEA;

  if(is3d)
    group = HDMI_RES_GROUP_CEA_3D;
  else
    group = HDMI_RES_GROUP_CEA;

  num_modes = m_BcmHost.vc_tv_hdmi_get_supported_modes((HDMI_RES_GROUP_T)group,
                                          supported_modes, TV_MAX_SUPPORTED_MODES,
                                          &prefer_group, &prefer_mode);

  TV_SUPPORTED_MODE_T *tv_found = NULL;
  int ifps = (int)(fps+0.5f);
  //printf("num_modes %d, %d, %d\n", num_modes, prefer_group, prefer_mode);

  if (num_modes > 0 && prefer_group != HDMI_RES_GROUP_INVALID)
  {
    TV_SUPPORTED_MODE_T *tv = supported_modes;
    uint32_t best_score = 1<<30;
    uint32_t isNative = tv->native ? 1:0;
    uint32_t w = tv->width;
    uint32_t h = tv->height;
    uint32_t r = tv->frame_rate;
    uint32_t match_flag = HDMI_MODE_MATCH_FRAMERATE | HDMI_MODE_MATCH_RESOLUTION;
    uint32_t scan_mode = 0;
    uint32_t score = 0;

    for (i=0; i<num_modes; i++, tv++)
    {
      isNative = tv->native ? 1:0;
      w = tv->width;
      h = tv->height;
      r = tv->frame_rate;

      //printf("mode %dx%[email protected]%d %s%s:%x\n", tv->width, tv->height, 
      //       tv->frame_rate, tv->native?"N":"", tv->scan_mode?"I":"", tv->code);

      /* Check if frame rate match (equal or exact multiple) */
      if(ifps) 
      {
        if(r == ((r/ifps)*ifps))
          score += abs((int)(r/ifps-1)) * (1<<8); // prefer exact framerate to multiples. Ideal is 1
        else
          score += ((match_flag & HDMI_MODE_MATCH_FRAMERATE) ? (1<<28):(1<<12))/r; // bad - but prefer higher framerate
      }
      /* Check size too, only choose, bigger resolutions */
      if(width && height) 
      {
        /* cost of too small a resolution is high */
        score += max((int)(width - w), 0) * (1<<16);
        score += max((int)(height- h), 0) * (1<<16);
        /* cost of too high a resolution is lower */
        score += max((int)(w-width),   0) * ((match_flag & HDMI_MODE_MATCH_RESOLUTION) ? (1<<8):(1<<0));
        score += max((int)(h-height),  0) * ((match_flag & HDMI_MODE_MATCH_RESOLUTION) ? (1<<8):(1<<0));
      } 
      else if (!isNative) 
      {
        // native is good
        score += 1<<16;
      }

      if (scan_mode != tv->scan_mode) 
        score += (match_flag & HDMI_MODE_MATCH_SCANMODE) ? (1<<20):(1<<8);

      if (w*9 != h*16) // not 16:9 is a small negative
        score += 1<<12;

      printf("mode %dx%[email protected]%d %s%s:%x score=%d\n", tv->width, tv->height, 
             tv->frame_rate, tv->native?"N":"", tv->scan_mode?"I":"", tv->code, score);

      if (score < best_score) 
      {
        tv_found = tv;
        best_score = score;
      }
      /* reset score */
      score = 0;
    }
  }

  if(tv_found)
  {
    printf("Output mode %d: %dx%[email protected]%d %s%s:%x\n", tv_found->code, tv_found->width, tv_found->height, 
           tv_found->frame_rate, tv_found->native?"N":"", tv_found->scan_mode?"I":"", tv_found->code);
    // if we are closer to ntsc version of framerate, let gpu know
    int ifps = (int)(fps+0.5f);
    bool ntsc_freq = fabs(fps*1001.0f/1000.0f - ifps) < fabs(fps-ifps);
    printf("ntsc_freq:%d\n", ntsc_freq);
    char response[80];
    vc_gencmd(response, sizeof response, "hdmi_ntsc_freqs %d", ntsc_freq);
    m_BcmHost.vc_tv_hdmi_power_on_explicit(HDMI_MODE_HDMI, (HDMI_RES_GROUP_T)group, tv_found->code);
  }
//.........这里部分代码省略.........
开发者ID:Bengt,项目名称:omxplayer,代码行数:101,代码来源:omxplayer.cpp


注:本文中的DllBcmHost::vc_tv_hdmi_power_on_explicit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。