Esempio n. 1
0
void CDVDInputStreamBluray::OverlayClose()
{
#if(BD_OVERLAY_INTERFACE_VERSION >= 2)
  for(unsigned i = 0; i < 2; ++i)
    m_planes[i].o.clear();
  CDVDOverlayGroup* group   = new CDVDOverlayGroup();
  group->bForced = true;
  m_player->OnDVDNavResult(group, 0);
  group->Release();
#endif
}
Esempio n. 2
0
void CDVDInputStreamBluray::OverlayFlush(int64_t pts)
{
#if(BD_OVERLAY_INTERFACE_VERSION >= 2)
  CDVDOverlayGroup* group   = new CDVDOverlayGroup();
  group->bForced       = true;
  group->iPTSStartTime = (double) pts;
  group->iPTSStopTime  = 0;

  for(unsigned i = 0; i < 2; ++i)
  {
    for(SOverlays::iterator it = m_planes[i].o.begin(); it != m_planes[i].o.end(); ++it)
      group->m_overlays.push_back((*it)->Acquire());
  }

  m_player->OnDVDNavResult(group, 0);
  group->Release();
#endif
}
Esempio n. 3
0
void CDVDInputStreamBluray::OverlayCallback(const BD_OVERLAY * const ov)
{

  CDVDOverlayGroup* group   = new CDVDOverlayGroup();
  group->bForced = true;

  if(ov == NULL)
  {
    for(unsigned i = 0; i < 2; ++i)
    {
      for(std::vector<CDVDOverlayImage*>::iterator it = m_overlays[i].begin(); it != m_overlays[i].end(); ++it)
        (*it)->Release();
      m_overlays[i].clear();
    }

    m_player->OnDVDNavResult(group, 0);
    return;
  }

  group->iPTSStartTime = (double) ov->pts;
  group->iPTSStopTime  = 0;

  if (ov->plane > 1)
  {
    CLog::Log(LOGWARNING, "CDVDInputStreamBluray - Ignoring overlay with multiple planes");
    group->Release();
    return;
  }

  std::vector<CDVDOverlayImage*>& plane(m_overlays[ov->plane]);

  /* fixup existing overlays */
  for(std::vector<CDVDOverlayImage*>::iterator it = plane.begin(); it != plane.end();)
  {
    /* if it's fully outside we are done */
    if(ov->x + ov->w <= (*it)->x
    || ov->x         >= (*it)->x + (*it)->width
    || ov->y + ov->h <= (*it)->y
    || ov->y         >= (*it)->y + (*it)->height)
    {
      ++it;
      continue;
    }

    int y1 = std::max<int>((*it)->y                , ov->y);
    int y2 = std::min<int>((*it)->y + (*it)->height, ov->y + ov->h);
    int x1 = std::max<int>((*it)->x                , ov->x);
    int x2 = std::min<int>((*it)->x + (*it)->width , ov->x + ov->w);

    /* if all should be cleared, delete */
    if(x1 == (*it)->x
    && x2 == (*it)->x + (*it)->width
    && y1 == (*it)->y
    && y2 == (*it)->y + (*it)->height)
    {
      CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - Delete(%d) %d-%dx%d-%d", ov->plane, x1, x2, y1, y2);
      it = plane.erase(it);
      continue;
    }
#if(1)
    CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - Clearing(%d) %d-%dx%d-%d", ov->plane, x1, x2, y1, y2);

    /* replace overlay with a new copy*/
    CDVDOverlayImage* overlay = new CDVDOverlayImage(*(*it));
    (*it)->Release();
    (*it) = overlay;

    /* any old hw overlay must be released */
    SAFE_RELEASE(overlay->m_overlay);

    /* clear out overlap */
    y1 -= overlay->y;
    y2 -= overlay->y;
    x1 -= overlay->x;
    x2 -= overlay->x;

    /* find fully transparent */
    int transp = 0;
    for(; transp < overlay->palette_colors; ++transp)
    {
      if(((overlay->palette[transp] >> PIXEL_ASHIFT) & 0xff) == 0)
        break;
    }

    if(transp == overlay->palette_colors)
    {
      CLog::Log(LOGERROR, "CDVDInputStreamBluray - failed to find transparent color");
      continue;
    }

    for(int y = y1; y < y2; ++y)
    {
      BYTE* line = overlay->data + y * overlay->linesize;
      for(int x = x1; x < x2; ++x)
        line[x] = transp;
    }
    ++it;
#endif
  }


  /* uncompress and draw bitmap */
  if (ov->img)
  {
    CDVDOverlayImage* overlay = new CDVDOverlayImage();

    if (ov->palette)
    {
      overlay->palette_colors = 256;
      overlay->palette        = (uint32_t*)calloc(overlay->palette_colors, 4);

      for(unsigned i = 0; i < 256; i++)
        overlay->palette[i] = build_rgba(ov->palette[i]);
    }

    const BD_PG_RLE_ELEM *rlep = ov->img;
    uint8_t *img = (uint8_t*) malloc(ov->w * ov->h);
    unsigned pixels = ov->w * ov->h;

    for (unsigned i = 0; i < pixels; i += rlep->len, rlep++) {
      memset(img + i, rlep->color, rlep->len);
    }

    overlay->data     = img;
    overlay->linesize = ov->w;
    overlay->x        = ov->x;
    overlay->y        = ov->y;
    overlay->height   = ov->h;
    overlay->width    = ov->w;
    plane.push_back(overlay);
  }

  for(unsigned i = 0; i < 2; ++i)
  {
    for(std::vector<CDVDOverlayImage*>::iterator it = m_overlays[i].begin(); it != m_overlays[i].end(); ++it)
      group->m_overlays.push_back((*it)->Acquire());
  }
  m_player->OnDVDNavResult(group, 0);
}