Пример #1
0
/**
 * \fn getNextFrame
 * @param fn
 * @param image
 * @return 
 */
bool AVDM_FadeTo::getNextFrame(uint32_t *fn,ADMImage *image)
{
  *fn=nextFrame;
  ADMImage *next= vidCache->getImage(nextFrame);
  if(!next)
  {
      ADM_info("[Fade] Cant get image \n");
      return false;
  }
  
  image->Pts=next->Pts;
  
  uint64_t absPts=next->Pts+getAbsoluteStartTime();
  
  bool out_of_scope=false;
  if(absPts<param.startFade*1000LL) out_of_scope=true;
  if(absPts>param.endFade*1000LL)   out_of_scope=true;
  
  
  if(!out_of_scope && !first)
  {
      first=new ADMImageDefault(next->GetWidth (PLANAR_Y),next->GetHeight(PLANAR_Y));
      first->duplicateFull (next);
  }
  if( out_of_scope || !first)
  {
      image->duplicate(next);
      nextFrame++;
      vidCache->unlockAll();
      return true;
  }
  
  double scope=1000LL*(param.endFade-param.startFade);
  double in;
    if(!scope) 
    {
        scope=1;
        in=1;
    }else
    {
        in=absPts-param.startFade*1000LL;
    }
    in=in/scope;
    in*=255;
  
  
  uint32_t offset=(uint32_t)floor(in+0.4); // normalized to 0--255, begin -- end
  
  
    process(first,next,image,offset);
  
    vidCache->unlockAll();
    nextFrame++;
    return 1;
}
Пример #2
0
/**
 * \fn getNextFrame
 * @param fn
 * @param image
 * @return 
 */
bool AVDM_Fade::getNextFrame(uint32_t *fn,ADMImage *image)
{
  *fn=nextFrame;
  ADMImage *next= vidCache->getImage(nextFrame);
  if(!next)
  {
      ADM_info("[Fade] Cant get image \n");
      return false;
  }
  
  image->Pts=next->Pts;
  
  uint64_t absPts=next->Pts+getAbsoluteStartTime();
  
  bool out_of_scope=false;
  if(absPts<param.startFade*1000LL) out_of_scope=true;
  if(absPts>param.endFade*1000LL)   out_of_scope=true;
  
  
  if( out_of_scope)
  {
      image->duplicate(next);
      nextFrame++;
      vidCache->unlockAll();
      return true;
  }
  
  double scope=1000LL*(param.endFade-param.startFade);
  double in;
  if(!scope) 
  {
      scope=1;
      in=1;
  }else
  {
        in=absPts-param.startFade*1000LL;
  }
    in=in/scope;
    in*=255;
  
  
  uint32_t offset=(uint32_t)floor(in+0.4); // normalized to 0--255
  

  if(param.toBlack)
  {
    uint8_t *splanes[3],*dplanes[3];
    int  spitches[3],dpitches[3];

    next->GetReadPlanes(splanes);
    next->GetPitches(spitches);
    image->GetReadPlanes(dplanes);
    image->GetPitches(dpitches);

    for(int i=0;i<3;i++)
    {
        uint16_t *indx=lookupChroma[offset];
        if(!i) indx=lookupLuma[offset];
        int    w=(int)image->GetWidth((ADM_PLANE)i);
        int    h=(int)image->GetHeight((ADM_PLANE)i);
        uint8_t *s=splanes[i];
        uint8_t *d=dplanes[i];
        for(int y=0;y<h;y++)
        {
            for(int x=0;x<w;x++)
            {
                d[x]=indx[s[x]]>>8;
            }
            d+=dpitches[i];
            s+=spitches[i];
        }        
    }
    vidCache->unlockAll();
    nextFrame++;
    return 1;
  }