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


C++ PVideoFrame::SetTimestamp方法代码示例

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


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

示例1: GetFrame

PVideoFrame __stdcall SimpleSample::GetFrame(int n, IScriptEnvironment* env) {
// This is the implementation of the GetFrame function.
// See the header definition for further info.

  PVideoFrame src = child->GetFrame(n, env);
   // Request frame 'n' from the child (source) clip.
  PVideoFrame window = WindowVideo->GetFrame(n, env);
  // Request frame "'n" from the WindowVideo clip
  PVideoFrame dst = env->NewVideoFrame(vi);
   // Construct a frame based on the information of the current frame
   // contained in the "vi" struct.

  /* GstAVSynth: copy timestamp from source to destination buffer
   * without modifying it
   */
  dst->SetTimestamp (src->GetTimestamp ());
  
  const unsigned char* srcp = src->GetReadPtr();
  // Request a Read pointer from the source frame.
  // This will return the position of the upperleft pixel in YUY2 images,
  // and return the lower-left pixel in RGB.
  // RGB images are stored upside-down in memory. 
  // You should still process images from line 0 to height.

  unsigned char* dstp = dst->GetWritePtr();
  // Request a Write pointer from the newly created destination image.
  // You can request a writepointer to images that have just been
  // created by NewVideoFrame. If you recieve a frame from PClip->GetFrame(...)
  // you must call env->MakeWritable(&frame) be recieve a valid write pointer.
  
  const int dst_pitch = dst->GetPitch();
  // Requests pitch (length of a line) of the destination image.
  // For more information on pitch see: http://www.avisynth.org/index.php?page=WorkingWithImages
  // (short version - pitch is always equal to or greater than width to allow for seriously fast assembly code)

  const int dst_width = dst->GetRowSize();
  // Requests rowsize (number of used bytes in a line.
  // See the link above for more information.

  const int dst_height = dst->GetHeight();
  // Requests the height of the destination image.

  const int src_pitch = src->GetPitch();
  const int src_width = src->GetRowSize();
  const int src_height = src->GetHeight();

  const unsigned char* windowp=window->GetReadPtr();
  const int window_pitch = window->GetPitch();
  const int window_width = window->GetRowSize();
  const int window_height = window->GetHeight();
  // Get info on the Windowed Clip (see src definitions for more information)

  
  int w, h;

  // This version of SimpleSample is intended to show how to utilise information from 2 clips in YUY2
  // colourspace only.  The original V1.6 code has been left in place fro all other
  // colourspaces.
  // It is designed purely for clarity and not as good or clever code :-)
  

  if (vi.IsRGB24()) {
    // The code just deals with RGB24 colourspace where each pixel is represented by
    // 3 bytes, Blue, Green and Red.
    // Although this colourspace is the easiest to understand, it is very rarely used because
    // a 3 byte sequence (24bits) cannot be processed easily using normal 32 bit registers.
/*    
    for (h=0; h < src_height;h++) {       // Loop from bottom line to top line.
      for (w = 0; w < src_width; w+=3) {   // Loop from left side of the image to the right side 1 pixel (3 bytes) at a time
        // stepping 3 bytes (a pixel width in RGB24 space)
        
        *(dstp + w) = *(srcp + w);          // Copy each Blue byte from source to destination.
        *(dstp + w + 1) = *(srcp + w + 1);     // Copy Green.
        *(dstp + w + 2) = *(srcp + w + 2);    // Copy Red
      }                              
      srcp = srcp + src_pitch; // Add the pitch (note use of pitch and not width) of one line (in bytes) to the source pointer
      dstp = dstp + dst_pitch; // Add the pitch to the destination pointer.
    }
*/
    env->BitBlt(dst->GetWritePtr(), dst->GetPitch(), src->GetReadPtr(), src->GetPitch(), src->GetRowSize(), src->GetHeight());
    // end copy src to dst
    
    //Now draw a white square in the middle of the frame
    // Normally you'd do this code within the loop above but here it is in a separate loop for clarity;
    dstp = dst->GetWritePtr();  // reset the destination pointer to the bottom, left pixel. (RGB colourspaces only)
    dstp = dstp + (dst_height/2 - SquareSize/2)*dst_pitch;  // move pointer to SquareSize/2 lines from the middle of the frame;
    for (h=0; h < SquareSize;h++) { // only scan 100 lines 
      for (w = dst_width/2 - SquareSize*3/2; w < dst_width/2 + SquareSize*3/2; w+=3) { // only scans the middle SquareSize pixels of a line 
        *(dstp + w) = 255;    // Set Blue to maximum value.
        *(dstp + w + 1) = 255;     // and Green.
        *(dstp + w + 2) = 255;    // and Red - therefore the whole pixel is now white.
      }                              
      dstp = dstp + dst_pitch; 
    }
  }

  if (vi.IsRGB32()) {
    // This code deals with RGB32 colourspace where each pixel is represented by
    // 4 bytes, Blue, Green and Red and "spare" byte that could/should be used for alpha
    // keying but usually isn't.
//.........这里部分代码省略.........
开发者ID:LRN,项目名称:gst-avsynth,代码行数:101,代码来源:gstavsynth-test.cpp


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