Beispiel #1
0
void AvisynthVideoSource::OutputField(const FFMS_Frame *Frame, PVideoFrame &Dst, int Field, IScriptEnvironment *Env) {
	const FFMS_Frame *SrcPicture = (Frame);
	
	if (VI.pixel_type == VideoInfo::CS_I420) {
		if (Field) {
			Env->BitBlt(Dst->GetWritePtr(PLANAR_Y), Dst->GetPitch(PLANAR_Y) * 2, SrcPicture->Data[0], SrcPicture->Linesize[0] * 2, Dst->GetRowSize(PLANAR_Y), Dst->GetHeight(PLANAR_Y) / 2); 
			Env->BitBlt(Dst->GetWritePtr(PLANAR_U), Dst->GetPitch(PLANAR_U) * 2, SrcPicture->Data[1], SrcPicture->Linesize[1] * 2, Dst->GetRowSize(PLANAR_U), Dst->GetHeight(PLANAR_U) / 2); 
			Env->BitBlt(Dst->GetWritePtr(PLANAR_V), Dst->GetPitch(PLANAR_V) * 2, SrcPicture->Data[2], SrcPicture->Linesize[2] * 2, Dst->GetRowSize(PLANAR_V), Dst->GetHeight(PLANAR_V) / 2); 
		} else {
			Env->BitBlt(Dst->GetWritePtr(PLANAR_Y) + Dst->GetPitch(PLANAR_Y), Dst->GetPitch(PLANAR_Y) * 2, SrcPicture->Data[0] + SrcPicture->Linesize[0], SrcPicture->Linesize[0] * 2, Dst->GetRowSize(PLANAR_Y), Dst->GetHeight(PLANAR_Y) / 2); 
			Env->BitBlt(Dst->GetWritePtr(PLANAR_U) + Dst->GetPitch(PLANAR_U), Dst->GetPitch(PLANAR_U) * 2, SrcPicture->Data[1] + SrcPicture->Linesize[1], SrcPicture->Linesize[1] * 2, Dst->GetRowSize(PLANAR_U), Dst->GetHeight(PLANAR_U) / 2); 
			Env->BitBlt(Dst->GetWritePtr(PLANAR_V) + Dst->GetPitch(PLANAR_V), Dst->GetPitch(PLANAR_V) * 2, SrcPicture->Data[2] + SrcPicture->Linesize[2], SrcPicture->Linesize[2] * 2, Dst->GetRowSize(PLANAR_V), Dst->GetHeight(PLANAR_V) / 2); 
		}
	} else if (VI.IsYUY2()) {
		if (Field)
			Env->BitBlt(Dst->GetWritePtr(), Dst->GetPitch() * 2, SrcPicture->Data[0], SrcPicture->Linesize[0] * 2, Dst->GetRowSize(), Dst->GetHeight() / 2); 
		else
			Env->BitBlt(Dst->GetWritePtr() + Dst->GetPitch(), Dst->GetPitch() * 2, SrcPicture->Data[0] + SrcPicture->Linesize[0], SrcPicture->Linesize[0] * 2, Dst->GetRowSize(), Dst->GetHeight() / 2); 
	} else { // RGB
		if (Field)
			Env->BitBlt(Dst->GetWritePtr() + Dst->GetPitch() * (Dst->GetHeight() - 1), -Dst->GetPitch() * 2, SrcPicture->Data[0], SrcPicture->Linesize[0] * 2, Dst->GetRowSize(), Dst->GetHeight() / 2); 
		else
			Env->BitBlt(Dst->GetWritePtr() + Dst->GetPitch() * (Dst->GetHeight() - 2), -Dst->GetPitch() * 2, SrcPicture->Data[0] + SrcPicture->Linesize[0], SrcPicture->Linesize[0] * 2, Dst->GetRowSize(), Dst->GetHeight() / 2); 
	}
}
Beispiel #2
0
static void make_black_background_planar_yuv
(
    PVideoFrame &frame,
    int          bitdepth_minus_8
)
{
    memset( frame->GetWritePtr( PLANAR_Y ), 0x00, frame->GetPitch( PLANAR_Y ) * frame->GetHeight( PLANAR_Y ) );
    memset( frame->GetWritePtr( PLANAR_U ), 0x80, frame->GetPitch( PLANAR_U ) * frame->GetHeight( PLANAR_U ) );
    memset( frame->GetWritePtr( PLANAR_V ), 0x80, frame->GetPitch( PLANAR_V ) * frame->GetHeight( PLANAR_V ) );
}
Beispiel #3
0
PVideoFrame __stdcall Null::GetFrame(int n, IScriptEnvironment* env) 
{
  PVideoFrame src = child->GetFrame(n, env);
    
  BYTE * foo = new BYTE[256];
  BYTE * bar = new BYTE[256];
  MemDebug md;
  
  md.randomFill(foo, 8, 8, 8);
  BitBlt(bar, 8, foo, 8, 8, 8);

  md.reset();
  int i = md.randomCheck(bar, 9, 8, 8);
  
  if (i)
    env->ThrowError("bug found");

  delete [] foo;
  delete [] bar;

  if (!lstrcmpi(copy, "makewritable"))
  {
    env->MakeWritable(&src);
    return src;
  }

  // TODO: no support for planar formats!
  if (!lstrcmpi(copy, "memcopy"))
  {
    PVideoFrame dst = env->NewVideoFrame(child->GetVideoInfo(), 16);
    if (dst->IsWritable() == false)
      env->ThrowError("new frame not writable"); // honestly don't know whether to expect this condition

    memcpy( dst->GetWritePtr(), src->GetReadPtr(), src->GetPitch() * src->GetHeight() );
    return dst;
  }
  
  if (!lstrcmpi(copy, "bitblt"))
  {
    PVideoFrame dst = env->NewVideoFrame(child->GetVideoInfo(), 16);
    if (dst->IsWritable() == false)
      env->ThrowError("new frame not writable"); // honestly don't know whether to expect this condition

    BitBlt( dst->GetWritePtr(), src->GetPitch(), src->GetReadPtr(), src->GetPitch(), 
            src->GetRowSize(), src->GetHeight() );
    return dst;
  }

  //if (!lstrcmpi(copy, "none"))
    // do nothing
  return src;
}
Beispiel #4
0
PVideoFrame __stdcall TEMmod::GetFrame(int n, IScriptEnvironment* env)
{
    const int planes[3] = {PLANAR_Y, PLANAR_U, PLANAR_V};

    PVideoFrame src = child->GetFrame(n, env);
    PVideoFrame dst = env->NewVideoFrame(vi);

    for (int i = 0; i < 3; i++) {
        if (process[i] == 0) {
            break;
        }
        int p = planes[i];
        int dst_pitch = dst->GetPitch(p);
        uint8_t* dstp = dst->GetWritePtr(p);
        int height = src->GetHeight(p);

        if (process[i] == 2) {
            memset(dstp, 0, dst_pitch * height);
            continue;
        }
        int src_pitch = src->GetPitch(p);
        int width = src->GetRowSize(p);
        const uint8_t* srcp = src->GetReadPtr(p);

        if (((intptr_t)srcp & 15) && type > 2) {
            env->ThrowError("TEMmod: invalid memory alignment found!");
        }

        calc_map(srcp, dstp, buff, src_pitch, dst_pitch, buff_pitch,
                 width, height, threshold[i], scale);

    }

    if (link > 0) {
        link_planes(dst);
    }

    if (!invert) {
        return dst;
    }

    for (int i = 0; i < 3; i++) {
        if (process[i] == 0) {
            break;
        }
        invert_plane(dst->GetWritePtr(planes[i]), dst->GetPitch(planes[i]),
                     dst->GetHeight(planes[i]));
    }

    return dst;
}
Beispiel #5
0
void AvisynthVideoSource::OutputFrame(const FFMS_Frame *Frame, PVideoFrame &Dst, IScriptEnvironment *Env) {
	if (VI.pixel_type == VideoInfo::CS_I420) {
		BlitPlane(Frame, Dst, Env, 0);
		BlitPlane(Frame, Dst, Env, 1);
		BlitPlane(Frame, Dst, Env, 2);
	} else if (VI.IsYUY2()) {
		BlitPlane(Frame, Dst, Env, 0);
	} else { // RGB
		Env->BitBlt(
			Dst->GetWritePtr() + Dst->GetPitch() * (Dst->GetHeight() - 1), -Dst->GetPitch(),
			Frame->Data[0], Frame->Linesize[0],
			Dst->GetRowSize(), Dst->GetHeight());
	}
}
Beispiel #6
0
PVideoFrame VerticalReduceBy2::GetFrame(int n, IScriptEnvironment* env) {
  PVideoFrame src = child->GetFrame(n, env);
  PVideoFrame dst = env->NewVideoFrame(vi);
  int src_pitch = src->GetPitch();
  int dst_pitch = dst->GetPitch();
  int row_size = src->GetRowSize();
  BYTE* dstp = dst->GetWritePtr();
  const BYTE* srcp = src->GetReadPtr();

  if (vi.IsPlanar()) {
    mmx_process(srcp,src_pitch, row_size, dstp,dst_pitch,dst->GetHeight(PLANAR_Y));

    if (src->GetRowSize(PLANAR_V)) {
      src_pitch = src->GetPitch(PLANAR_V);
      dst_pitch = dst->GetPitch(PLANAR_V);
      row_size = src->GetRowSize(PLANAR_V_ALIGNED);
      dstp = dst->GetWritePtr(PLANAR_V);
      srcp = src->GetReadPtr(PLANAR_V);
      mmx_process(srcp,src_pitch, row_size, dstp,dst_pitch,dst->GetHeight(PLANAR_V));

      src_pitch = src->GetPitch(PLANAR_U);
      dst_pitch = dst->GetPitch(PLANAR_U);
      row_size = src->GetRowSize(PLANAR_U_ALIGNED);
      dstp = dst->GetWritePtr(PLANAR_U);
      srcp = src->GetReadPtr(PLANAR_U);
      mmx_process(srcp,src_pitch, row_size, dstp,dst_pitch,dst->GetHeight(PLANAR_U));
    }
    return dst;

  }

  //if ((env->GetCPUFlags() & CPUF_MMX)) {
    if ((row_size&3)==0) {  // row width divideable with 4 (one dword per loop)
      mmx_process(srcp,src_pitch, row_size, dstp,dst_pitch,vi.height);
      return dst;
    }
  //} 
    
  for (int y=0; y<vi.height; ++y) {
    const BYTE* line0 = src->GetReadPtr() + (y*2)*src_pitch;
    const BYTE* line1 = line0 + src_pitch;
    const BYTE* line2 = (y*2 < original_height-2) ? (line1 + src_pitch) : line0;
    for (int x=0; x<row_size; ++x)
      dstp[x] = (line0[x] + 2*line1[x] + line2[x] + 2) >> 2;
    dstp += dst_pitch;
  }

  return dst;
}
Beispiel #7
0
static void BlitField(const FFMS_Frame *Frame, PVideoFrame &Dst, IScriptEnvironment *Env, int Plane, int Field) {
	int PlaneId = 1 << Plane;
	Env->BitBlt(
		Dst->GetWritePtr(PlaneId) + Dst->GetPitch(PlaneId) * Field, Dst->GetPitch(PlaneId) * 2,
		Frame->Data[Plane] + Frame->Linesize[Plane] * Field, Frame->Linesize[Plane] * 2,
		Dst->GetRowSize(PlaneId), Dst->GetHeight(PlaneId) / 2);
}
Beispiel #8
0
void AvisynthVideoSource::OutputField(const FFMS_Frame *Frame, PVideoFrame &Dst, int Field, IScriptEnvironment *Env) {
	const FFMS_Frame *SrcPicture = (Frame);

	if (VI.pixel_type == VideoInfo::CS_I420) {
		BlitField(Frame, Dst, Env, 0, Field);
		BlitField(Frame, Dst, Env, 1, Field);
		BlitField(Frame, Dst, Env, 2, Field);
	} else if (VI.IsYUY2()) {
		BlitField(Frame, Dst, Env, 0, Field);
	} else { // RGB
        Env->BitBlt(
			Dst->GetWritePtr() + Dst->GetPitch() * (Dst->GetHeight() - 1 - Field), -Dst->GetPitch() * 2,
			SrcPicture->Data[0] + SrcPicture->Linesize[0] * Field, SrcPicture->Linesize[0] * 2,
			Dst->GetRowSize(), Dst->GetHeight() / 2);
	}
}
Beispiel #9
0
PVideoFrame SkewRows::GetFrame(int n, IScriptEnvironment* env) {

  PVideoFrame src = child->GetFrame(n, env);
  PVideoFrame dst = env->NewVideoFrame(vi);

  const int srowsize = src->GetRowSize();
  const int spitch   = src->GetPitch();
  const BYTE *sptr   = src->GetReadPtr();

  const int drowsize = dst->GetRowSize();
  const int dpitch   = dst->GetPitch();
  BYTE *dptr         = dst->GetWritePtr();

  const int ssize = src->GetHeight()*srowsize;

  int s=0, d=0;
  for (int i=0; i < ssize; i++) {
    if (s >= srowsize) {
      s = 0;
      sptr += spitch;
    }
    if (d >= drowsize) {
      d = 0;
      dptr += dpitch;
    }
    dptr[d++] = sptr[s++];
  }

  while (d < drowsize)
    dptr[d++] = 128;

  return dst;

}
Beispiel #10
0
PVideoFrame __stdcall MergeAll::GetFrame(int n, IScriptEnvironment* env)
{
  if (weight<0.0039f) return child->GetFrame(n, env);
  if (weight>0.9961f) return clip->GetFrame(n, env);

  PVideoFrame src  = child->GetFrame(n, env);
  PVideoFrame src2 =  clip->GetFrame(n, env);

  env->MakeWritable(&src);
  BYTE* srcp  = src->GetWritePtr();
  const BYTE* srcp2 = src2->GetReadPtr();

  const int src_pitch = src->GetPitch();
  const int src_rowsize = src->GetRowSize();

  merge_plane(srcp, srcp2, src_pitch, src2->GetPitch(), src_rowsize, src->GetHeight(), weight, env);

  if (vi.IsPlanar()) {
    BYTE* srcpU  = (BYTE*)src->GetWritePtr(PLANAR_U);
    BYTE* srcpV  = (BYTE*)src->GetWritePtr(PLANAR_V);
    BYTE* srcp2U = (BYTE*)src2->GetReadPtr(PLANAR_U);
    BYTE* srcp2V = (BYTE*)src2->GetReadPtr(PLANAR_V);
 
    int src_rowsize = src->GetRowSize(PLANAR_U);

    merge_plane(srcpU, srcp2U, src->GetPitch(PLANAR_U), src2->GetPitch(PLANAR_U), src_rowsize, src->GetHeight(PLANAR_U), weight, env);
    merge_plane(srcpV, srcp2V, src->GetPitch(PLANAR_V), src2->GetPitch(PLANAR_V), src_rowsize, src->GetHeight(PLANAR_V), weight, env);
  }

  return src;
}
Beispiel #11
0
static void make_black_background_packed_all_zero
(
    PVideoFrame &frame,
    int          bitdepth_minus_8
)
{
    memset( frame->GetWritePtr(), 0x00, frame->GetPitch() * frame->GetHeight() );
}
Beispiel #12
0
PVideoFrame WeaveRows::GetFrame(int n, IScriptEnvironment* env) 
{
  const int b = n * period;
  const int e = b + period;

  PVideoFrame dst = env->NewVideoFrame(vi);
  BYTE *dstp = dst->GetWritePtr();
  const int dstpitch = dst->GetPitch();

  if (vi.IsRGB()) { // RGB upsidedown
    dstp += dstpitch * period;
    for (int i=b; i<e; i++) {
      dstp -= dstpitch;
      const int j = i < inframes ? i : inframes-1;
      PVideoFrame src = child->GetFrame(j, env);
      BitBlt( dstp,              dstpitch * period,
              src->GetReadPtr(), src->GetPitch(),
              src->GetRowSize(), src->GetHeight() );
    }
  }
  else {
    BYTE *dstpU = dst->GetWritePtr(PLANAR_U);
    BYTE *dstpV = dst->GetWritePtr(PLANAR_V);
    const int dstpitchUV = dst->GetPitch(PLANAR_U);
    for (int i=b; i<e; i++) {
      const int j = i < inframes ? i : inframes-1;
      PVideoFrame src = child->GetFrame(j, env);
      BitBlt( dstp,              dstpitch * period,
              src->GetReadPtr(), src->GetPitch(),
              src->GetRowSize(), src->GetHeight() );
      dstp += dstpitch;
      if (dstpitchUV) {
        BitBlt( dstpU,                     dstpitchUV * period,
                src->GetReadPtr(PLANAR_U), src->GetPitch(PLANAR_U),
                src->GetRowSize(PLANAR_U), src->GetHeight(PLANAR_U) );
        BitBlt( dstpV,                     dstpitchUV * period,
                src->GetReadPtr(PLANAR_V), src->GetPitch(PLANAR_V),
                src->GetRowSize(PLANAR_V), src->GetHeight(PLANAR_V) );
        dstpU += dstpitchUV;
        dstpV += dstpitchUV;
      }
    }
  }
  return dst;
}
PVideoFrame TMaskCleaner::GetFrame(int n, IScriptEnvironment* env) {
    PVideoFrame src = child->GetFrame(n,env);
    PVideoFrame dst = env->NewVideoFrame(child->GetVideoInfo());

    memset(dst->GetWritePtr(PLANAR_Y), 0, dst->GetPitch(PLANAR_Y) * dst->GetHeight(PLANAR_Y));
    memset(lookup, 0, child->GetVideoInfo().height * child->GetVideoInfo().width / 8);

    ClearMask(dst->GetWritePtr(PLANAR_Y), src->GetReadPtr(PLANAR_Y), dst->GetRowSize(PLANAR_Y), dst->GetHeight(PLANAR_Y),src->GetPitch(PLANAR_Y), dst->GetPitch(PLANAR_Y));
    return dst;
}
Beispiel #14
0
extern "C" HRESULT __stdcall read_data(VF_FileHandle in, DWORD stream, void *out)
{
	if (stream == VF_STREAM_VIDEO)
	{
		LPVF_ReadData_Video data = (LPVF_ReadData_Video)out;
		unsigned char *dst = (unsigned char *)data->lpData;

		if (data == NULL)
			return VF_ERROR;
		
		if (data->dwSize != sizeof(VF_ReadData_Video))
			return VF_ERROR;

		vfMI *i = (vfMI*)in;

		if (i->type == D2V_TYPE)
		{
			unsigned char *src = i->getRGBFrameMI(data->dwFrameNumberL, i->ident);
			int y, height = i->vi->height;
			for (y = 0; y < height; y++)
				memcpy(dst+y*data->lPitch, src+y*i->vi->width*3, i->vi->width*3);
		}
		else
		{
			PVideoFrame src = (*i->clip)->GetFrame(data->dwFrameNumberL, i->avsEnv);
			i->avsEnv->BitBlt(dst, data->lPitch, src->GetReadPtr(), src->GetPitch(),
				src->GetRowSize(), src->GetHeight());
		}
	}
	else if (stream == VF_STREAM_AUDIO)
	{
		LPVF_ReadData_Audio data = (LPVF_ReadData_Audio)out;

		if (data == NULL)
			return VF_ERROR;
		
		if (data->dwSize != sizeof(VF_ReadData_Audio))
			return VF_ERROR;

		vfMI *i = (vfMI*)in;

		if (i->type == D2V_TYPE)
			return VF_ERROR;
		else
		{
			if (!(*i->clip)->GetVideoInfo().HasAudio()) return VF_ERROR;
			(*i->clip)->GetAudio(data->lpBuf, data->dwSamplePosL, data->dwSampleCount, i->avsEnv);
			data->dwReadedSampleCount = (unsigned long) min(data->dwSampleCount,
				max((*i->clip)->GetVideoInfo().num_audio_samples-data->dwSamplePosL,0));
		}
	}
	else return VF_ERROR;

	return VF_OK;
}
Beispiel #15
0
PVideoFrame __stdcall Turn::GetFrame(int n, IScriptEnvironment* env) {

	PVideoFrame src = child->GetFrame(n, env);

    PVideoFrame dst = env->NewVideoFrame(vi);

	if (vi.IsPlanar())
		TurnPlanFunc(src->GetReadPtr(PLANAR_Y), dst->GetWritePtr(PLANAR_Y),
					 src->GetReadPtr(PLANAR_U), dst->GetWritePtr(PLANAR_U),
					 src->GetReadPtr(PLANAR_V), dst->GetWritePtr(PLANAR_V),
					 src->GetRowSize(PLANAR_Y), src->GetHeight(PLANAR_Y),
					 src->GetRowSize(PLANAR_U), src->GetHeight(PLANAR_U),
					 src->GetPitch(PLANAR_Y), dst->GetPitch(PLANAR_Y),
					 src->GetPitch(PLANAR_U), dst->GetPitch(PLANAR_U),
					 src->GetPitch(PLANAR_V), direction);
	else
		TurnFunc(src->GetReadPtr(),dst->GetWritePtr(),src->GetRowSize(),
				 src->GetHeight(),src->GetPitch(),dst->GetPitch(),direction);
    return dst;
}
Beispiel #16
0
void AvisynthVideoSource::OutputFrame(const FFMS_Frame *Frame, PVideoFrame &Dst, IScriptEnvironment *Env) {
	if (VI.pixel_type == VideoInfo::CS_I420) {
		Env->BitBlt(Dst->GetWritePtr(PLANAR_Y), Dst->GetPitch(PLANAR_Y), Frame->Data[0], Frame->Linesize[0], Dst->GetRowSize(PLANAR_Y), Dst->GetHeight(PLANAR_Y)); 
		Env->BitBlt(Dst->GetWritePtr(PLANAR_U), Dst->GetPitch(PLANAR_U), Frame->Data[1], Frame->Linesize[1], Dst->GetRowSize(PLANAR_U), Dst->GetHeight(PLANAR_U)); 
		Env->BitBlt(Dst->GetWritePtr(PLANAR_V), Dst->GetPitch(PLANAR_V), Frame->Data[2], Frame->Linesize[2], Dst->GetRowSize(PLANAR_V), Dst->GetHeight(PLANAR_V)); 
	} else if (VI.IsYUY2()) {
		Env->BitBlt(Dst->GetWritePtr(), Dst->GetPitch(), Frame->Data[0], Frame->Linesize[0], Dst->GetRowSize(), Dst->GetHeight()); 
	} else { // RGB
		Env->BitBlt(Dst->GetWritePtr() + Dst->GetPitch() * (Dst->GetHeight() - 1), -Dst->GetPitch(), Frame->Data[0], Frame->Linesize[0], Dst->GetRowSize(), Dst->GetHeight()); 
	}
}
Beispiel #17
0
void AvisynthVideoSource::OutputFrame(const FFMS_Frame *Frame, PVideoFrame &Dst, IScriptEnvironment *Env) {
	if (VI.IsPlanar()) {
		BlitPlane(Frame, Dst, Env, 0, VI.IsRGB() ? PLANAR_G : PLANAR_Y);
        if (HighBitDepth ? !VI.IsY() : !VI.IsY8()) {
            BlitPlane(Frame, Dst, Env, 1, VI.IsRGB() ? PLANAR_B : PLANAR_U);
            BlitPlane(Frame, Dst, Env, 2, VI.IsRGB() ? PLANAR_R : PLANAR_V);
        }
        if (VI.IsYUVA() || VI.IsPlanarRGBA())
            BlitPlane(Frame, Dst, Env, 3, PLANAR_A);
	} else if (VI.IsYUY2()) {
		BlitPlane(Frame, Dst, Env, 0, 0);
    } else if (VI.IsRGB24() || VI.IsRGB32()) {
		Env->BitBlt(
			Dst->GetWritePtr() + Dst->GetPitch() * (Dst->GetHeight() - 1), -Dst->GetPitch(),
			Frame->Data[0], Frame->Linesize[0],
			Dst->GetRowSize(), Dst->GetHeight());
    } else {
        assert(false);
    }
}
Beispiel #18
0
static void make_black_background_packed_yuv422
(
    PVideoFrame &frame,
    int          bitdepth_minus_8
)
{
    uint32_t *dst = (uint32_t *)frame->GetWritePtr();
    int num_loops = frame->GetPitch() * frame->GetHeight() / 4;
    for( int i = 0; i < num_loops; i++ )
        *dst++ = 0x00800080;
}
PVideoFrame __stdcall MVSCDetection::GetFrame(int n, IScriptEnvironment* env)
{
   PVideoFrame dst = env->NewVideoFrame(vi);

	PVideoFrame mvn = mvClip.GetFrame(n, env);
   mvClip.Update(mvn, env);

   if ( mvClip.IsUsable() )
	{
	   if(vi.IsYV12())
	   {
//      MemZoneSet(YWPLAN(dst), 0, nWidth, nHeight, 0, 0, YPITCH(dst));
//      MemZoneSet(UWPLAN(dst), 0, nWidth/2, nHeight/2, 0, 0, UPITCH(dst));
//      MemZoneSet(VWPLAN(dst), 0, nWidth/2, nHeight/2, 0, 0, VPITCH(dst));
		  MemZoneSet(dst->GetWritePtr(PLANAR_Y), 0, dst->GetRowSize(PLANAR_Y), dst->GetHeight(PLANAR_Y), 0, 0, dst->GetPitch(PLANAR_Y));
		  MemZoneSet(dst->GetWritePtr(PLANAR_U), 0, dst->GetRowSize(PLANAR_U), dst->GetHeight(PLANAR_U), 0, 0, dst->GetPitch(PLANAR_U));
		  MemZoneSet(dst->GetWritePtr(PLANAR_V), 0, dst->GetRowSize(PLANAR_V), dst->GetHeight(PLANAR_V), 0, 0, dst->GetPitch(PLANAR_V));
	   }
	   else
	   {
		  MemZoneSet(dst->GetWritePtr(), 0, dst->GetRowSize(), dst->GetHeight(), 0, 0, dst->GetPitch());
	   }
	}
   else {
	   if(vi.IsYV12())
	   {
//      MemZoneSet(YWPLAN(dst), sceneChangeValue, nWidth, nHeight, 0, 0, YPITCH(dst));
//      MemZoneSet(UWPLAN(dst), sceneChangeValue, nWidth/2, nHeight/2, 0, 0, UPITCH(dst));
//      MemZoneSet(VWPLAN(dst), sceneChangeValue, nWidth/2, nHeight/2, 0, 0, VPITCH(dst));
		  MemZoneSet(dst->GetWritePtr(PLANAR_Y), sceneChangeValue, dst->GetRowSize(PLANAR_Y), dst->GetHeight(PLANAR_Y), 0, 0, dst->GetPitch(PLANAR_Y));
		  MemZoneSet(dst->GetWritePtr(PLANAR_U), sceneChangeValue, dst->GetRowSize(PLANAR_U), dst->GetHeight(PLANAR_U), 0, 0, dst->GetPitch(PLANAR_U));
		  MemZoneSet(dst->GetWritePtr(PLANAR_V), sceneChangeValue, dst->GetRowSize(PLANAR_V), dst->GetHeight(PLANAR_V), 0, 0, dst->GetPitch(PLANAR_V));
	   }
	   else
	   {
		  MemZoneSet(dst->GetWritePtr(), sceneChangeValue, dst->GetRowSize(), dst->GetHeight(), 0, 0, dst->GetPitch());
	   }
   }

	return dst;
}
Beispiel #20
0
void AvisynthVideoSource::OutputField(const FFMS_Frame *Frame, PVideoFrame &Dst, int Field, IScriptEnvironment *Env) {
	const FFMS_Frame *SrcPicture = Frame;
	if (VI.IsPlanar()) {
		BlitField(Frame, Dst, Env, 0, VI.IsRGB() ? PLANAR_G : PLANAR_Y, Field);
        if (HighBitDepth ? !VI.IsY() : !VI.IsY8()) {
            BlitField(Frame, Dst, Env, 1, VI.IsRGB() ? PLANAR_B : PLANAR_U, Field);
            BlitField(Frame, Dst, Env, 2, VI.IsRGB() ? PLANAR_R : PLANAR_V, Field);
        }
        if (VI.IsYUVA() || VI.IsPlanarRGBA())
            BlitField(Frame, Dst, Env, 3, PLANAR_A, Field);
	} else if (VI.IsYUY2()) {
		BlitField(Frame, Dst, Env, 0, 0, Field);
	} else if (VI.IsRGB24() || VI.IsRGB32()) {
		Env->BitBlt(
			Dst->GetWritePtr() + Dst->GetPitch() * (Dst->GetHeight() - 1 - Field), -Dst->GetPitch() * 2,
			SrcPicture->Data[0] + SrcPicture->Linesize[0] * Field, SrcPicture->Linesize[0] * 2,
			Dst->GetRowSize(), Dst->GetHeight() / 2);
    } else {
        assert(false);
    }
}
Beispiel #21
0
static void make_black_background_planar_yuv_interleaved
(
    PVideoFrame &frame,
    int          bitdepth_minus_8
)
{
    memset( frame->GetWritePtr( PLANAR_Y ), 0x00, frame->GetPitch( PLANAR_Y ) * frame->GetHeight( PLANAR_Y ) );
    uint8_t msb  = (uint8_t)((0x80U << bitdepth_minus_8) >> 8);
    int     size = frame->GetPitch( PLANAR_U ) * frame->GetHeight( PLANAR_U );
    for( int i = 0; i < size; i++ )
        if( i & 1 )
        {
            *(frame->GetWritePtr( PLANAR_U ) + i) = msb;
            *(frame->GetWritePtr( PLANAR_V ) + i) = msb;
        }
        else
        {
            *(frame->GetWritePtr( PLANAR_U ) + i) = 0x00;
            *(frame->GetWritePtr( PLANAR_V ) + i) = 0x00;
        }
}
Beispiel #22
0
void copyPlanar(const uchar* srcp, PVideoFrame &dst, int bpp) {
	const int bytes_per_pixel = bpp / 8;
	const int cols = dst->GetRowSize();
	const int rows = dst->GetHeight();
	const int dst_pitch = dst->GetPitch();
	const int src_pitch = cols / bytes_per_pixel;
	uchar* dstp = dst->GetWritePtr();
	int y, x;

	const int dst_pitchUV = dst->GetPitch(PLANAR_U);
	const int dst_widthUV = dst->GetRowSize(PLANAR_U);
	const int dst_heightUV = dst->GetHeight(PLANAR_U);

	for (y = 0; y < rows; y++) {                 // copy mask to Y plane
		for (x = 0; x < cols; x++) {
			dstp[x] = srcp[x / bytes_per_pixel];
		}
		srcp += src_pitch;
		dstp += dst_pitch;
	}

	dstp = dst->GetWritePtr(PLANAR_U);           // set U plane to no color

	for (y = 0; y < dst_heightUV; y++) {
		for (x = 0; x < dst_widthUV; x++) {
			dstp[x] = 128;                       // set chroma to none
		}
		dstp += dst_pitchUV;
	}

	// set V plane to no color
	dstp = dst->GetWritePtr(PLANAR_V);

	for (y = 0; y < dst_heightUV; y++) {
		for (x = 0; x < dst_widthUV; x++) {
			dstp[x] = 128;                       // set chroma to none
		}
		dstp += dst_pitchUV;
	}
}
Beispiel #23
0
static int make_frame_packed_rgb
(
    lw_video_output_handler_t *vohp,
    int                        height,
    AVFrame                   *av_frame,
    PVideoFrame               &as_frame
)
{
    as_picture_t as_picture = { { { NULL } } };
    as_picture.data    [0] = as_frame->GetWritePtr() + as_frame->GetPitch() * (as_frame->GetHeight() - 1);
    as_picture.linesize[0] = -as_frame->GetPitch();
    return convert_av_pixel_format( vohp->scaler.sws_ctx, height, av_frame, &as_picture );
}
Beispiel #24
0
PVideoFrame FTurn::GetFrame(int n, IScriptEnvironment* env) {
    PVideoFrame src = child->GetFrame(n,env);
    auto dst = env->NewVideoFrame(vi);
    auto pSrcY = src->GetReadPtr(PLANAR_Y);
    auto pDstY = dst->GetWritePtr(PLANAR_Y);
    int srcPitchY = src->GetPitch(PLANAR_Y);
    int dstPitchY = dst->GetPitch(PLANAR_Y);
    int srcWidthY = src->GetRowSize(PLANAR_Y);
    int srcHeightY = src->GetHeight(PLANAR_Y);

    if (!(chroma_ && hasChroma(vi.pixel_type))) {
        turnFunction_(pDstY, pSrcY, srcWidthY, srcHeightY, dstPitchY, srcPitchY);
    } else {
        auto pDstU = dst->GetWritePtr(PLANAR_U);
        auto pDstV = dst->GetWritePtr(PLANAR_V);
        auto pSrcU = src->GetReadPtr(PLANAR_U);
        auto pSrcV = src->GetReadPtr(PLANAR_V);
        int srcPitchUV = src->GetPitch(PLANAR_U);
        int dstPitchUV = dst->GetPitch(PLANAR_U);
        int srcWidthUV = src->GetRowSize(PLANAR_U);
        int srcHeightUV = src->GetHeight(PLANAR_V);
        
        if (mt_) {
            auto thread2 = std::async(launch::async, [=] { 
                turnFunction_(pDstU, pSrcU, srcWidthUV, srcHeightUV, dstPitchUV, srcPitchUV);
                turnFunction_(pDstV, pSrcV, srcWidthUV, srcHeightUV, dstPitchUV, srcPitchUV);
            });
            turnFunction_(pDstY, pSrcY, srcWidthY, srcHeightY, dstPitchY, srcPitchY);
            thread2.wait();
        } else {
            turnFunction_(pDstU, pSrcU, srcWidthUV, srcHeightUV, dstPitchUV, srcPitchUV);
            turnFunction_(pDstV, pSrcV, srcWidthUV, srcHeightUV, dstPitchUV, srcPitchUV);
            turnFunction_(pDstY, pSrcY, srcWidthY, srcHeightY, dstPitchY, srcPitchY);
        }
    }
    return dst;
}
Beispiel #25
0
PVideoFrame __stdcall ConvertToY8::GetFrame(int n, IScriptEnvironment* env) {
  PVideoFrame src = child->GetFrame(n, env);

  if (blit_luma_only) {
    // Abuse Subframe to snatch the Y plane
    return env->Subframe(src, 0, src->GetPitch(PLANAR_Y), src->GetRowSize(PLANAR_Y), src->GetHeight(PLANAR_Y));
  }

  PVideoFrame dst = env->NewVideoFrame(vi);

  if (yuy2_input) {

    const BYTE* srcP = src->GetReadPtr();
    const int srcPitch = src->GetPitch();
    const int awidth = min(srcPitch>>1, (vi.width+7) & -8);

    BYTE* dstY = dst->GetWritePtr(PLANAR_Y);
    const int dstPitch = dst->GetPitch(PLANAR_Y);

    if (!(awidth & 7)) {
      this->convYUV422toY8(srcP, dstY, srcPitch, dstPitch, awidth, vi.height);
      return dst;
    }

    const int w = dst->GetRowSize(PLANAR_Y);
    const int h = dst->GetHeight(PLANAR_Y);

    for (int y=0; y<h; y++) {
      for (int x=0; x<w; x++) {
        dstY[x] = srcP[x*2];
      }
      srcP+=srcPitch;
      dstY+=dstPitch;
    }
  }
  else if (rgb_input) {
Beispiel #26
0
	void copyplane(PVideoFrame &result, const PVideoFrame &source, int plane, IScriptEnvironment *env)
	{
	//  void __stdcall IScriptEnvironment::BitBlt
		//(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) = 0

		unsigned char *resultpointer = result->GetWritePtr(plane);
		const unsigned char *sourcepointer = source->GetReadPtr(plane);

		const int width = source->GetRowSize(plane);
		const int height = source->GetHeight(plane);
		const int sourcepitch = source->GetPitch(plane);
		const int resultpitch = result->GetPitch(plane);

		env->BitBlt(resultpointer, resultpitch, sourcepointer, sourcepitch, width, height);
	}
Beispiel #27
0
PVideoFrame __stdcall FixBrokenChromaUpsampling::GetFrame(int n, IScriptEnvironment* env) 
{
  PVideoFrame frame = child->GetFrame(n, env);
  env->MakeWritable(&frame);
  const int pitch = frame->GetPitch();
  BYTE* p = frame->GetWritePtr() + pitch;
  for (int y = (frame->GetHeight()+1)/4; y > 0; --y) {
    for (int x = 0; x < frame->GetRowSize(); x += 4) {
      BYTE t1 = p[x+1], t3 = p[x+3];
      p[x+1] = p[pitch+x+1]; p[x+3] = p[pitch+x+3];
      p[pitch+x+1] = t1; p[pitch+x+3] = t3;
    }
    p += pitch*4;
  }
  return frame;
}
Beispiel #28
0
const AegiVideoFrame AvisynthVideoProvider::GetFrame(int n) {
	if (n == last_fnum) return iframe;

	wxMutexLocker lock(avs.GetMutex());

	PVideoFrame frame = RGB32Video->GetFrame(n, avs.GetEnv());
	iframe.pitch = frame->GetPitch();
	iframe.w = frame->GetRowSize() / (vi.BitsPerPixel() / 8);
	iframe.h = frame->GetHeight();

	iframe.Allocate();

	memcpy(iframe.data, frame->GetReadPtr(), iframe.pitch * iframe.h);

	last_fnum = n;
	return iframe;
}
Beispiel #29
0
void copyRGB(const uchar* srcp, PVideoFrame &dst, int bpp) {
	const int bytes_per_pixel = bpp / 8;
	const int cols = dst->GetRowSize();
	const int rows = dst->GetHeight();
	const int dst_pitch = dst->GetPitch();
	const int src_pitch = cols / bytes_per_pixel;
	uchar* dstp = dst->GetWritePtr();
	int y, x;

	for (y = 0; y < rows; y++) {
		for (x = 0; x < cols; x++) {
			dstp[x] = srcp[x / bytes_per_pixel];   // copy the same mask pixel to all channels
		}
		srcp += src_pitch;
		dstp += dst_pitch;
	}
}
Beispiel #30
0
void copyYUY2(const uchar* srcp, PVideoFrame &dst) {
	const int cols = dst->GetRowSize();
	const int rows = dst->GetHeight();
	const int dst_pitch = dst->GetPitch();
	const int width = cols / 2;
	const int src_pitch = width;
	uchar* dstp = dst->GetWritePtr();
	int y, x;

	for (y = 0; y < rows; y++) {
		for (x = 0; x < width; x++) {
			dstp[x * 2] = srcp[x];                 // copy luma from mask
			dstp[x * 2 + 1] = 128;                 // set chroma to none
		}
		srcp += src_pitch;
		dstp += dst_pitch;
	}
}