private unsafe int OnFormatCallback(void** opaque, char* chroma, int* width, int* height, int* pitches, int* lines) { IntPtr pChroma = new IntPtr(chroma); string chromaStr = Marshal.PtrToStringAnsi(pChroma); ChromaType type; if (!Enum.TryParse<ChromaType>(chromaStr, out type)) { throw new ArgumentException("Unsupported chroma type " + chromaStr); } m_format = new BitmapFormat(*width, *height, type); if (m_formatSetupCB != null) { m_format = m_formatSetupCB(m_format); } Marshal.Copy(m_format.Chroma.ToUtf8(), 0, pChroma, 4); *width = m_format.Width; *height = m_format.Height; for (int i = 0; i < m_format.Planes; i++) { pitches[i] = m_format.Pitches[i]; lines[i] = m_format.Lines[i]; } m_pixelData = new PlanarPixelData(m_format.PlaneSizes); return m_format.Planes; }
/// <summary> /// /// </summary> /// <param name="format"></param> /// <returns></returns> public static StreamInfo FromBitmapFormat(BitmapFormat format) { return(new StreamInfo() { Category = StreamCategory.Video, Codec = VideoCodecs.BGR24, Width = format.Width, Height = format.Height, Size = format.ImageSize }); }
public void SetFormat(BitmapFormat format) { m_format = format; LibVlcMethods.libvlc_video_set_format(m_hMediaPlayer, m_format.Chroma.ToUtf8(), m_format.Width, m_format.Height, m_format.Pitch); m_pBuffer = MemoryHeap.Alloc(m_format.ImageSize); m_pixelData = new PixelData(m_format.ImageSize); m_pixelDataPtr = GCHandle.Alloc(m_pixelData, GCHandleType.Pinned); LibVlcMethods.libvlc_video_set_callbacks(m_hMediaPlayer, pLockCallback, pUnlockCallback, pDisplayCallback, m_pixelDataPtr.AddrOfPinnedObject()); }
/// <summary> /// Invoked before video stream starts in order to set the frame format /// </summary> /// <param name="format"></param> public abstract void FormatSetup(BitmapFormat format);
private void SetupInput(BitmapFormat format) { var streamInfo = new StreamInfo(); streamInfo.Category = StreamCategory.Video; streamInfo.Codec = VideoCodecs.Bgr24; streamInfo.Width = format.Width; streamInfo.Height = format.Height; streamInfo.Size = format.ImageSize; _mInputMedia.Initialize(streamInfo); _mInputMedia.SetExceptionHandler(OnErrorCallback); _mRenderPlayer.Open(_mInputMedia); }
private BitmapFormat OnSetupCallback(BitmapFormat format) { SetupInput(format); return new BitmapFormat(format.Width, format.Height, ChromaType.Rv24); }
private BitmapFormat OnFormatSetup(BitmapFormat format) { m_format = format; SetSurface(format); return new BitmapFormat(format.Width, format.Height, ChromaType.I420); }
private void SetSurface(BitmapFormat format) { CreateRenderer(); m_render.CreateVideoSurface(format.Width, format.Height, PixelFormat.YV12, m_source.SAR.Ratio); m_image.Dispatcher.Invoke(new Action(delegate { m_image.Lock(); m_image.SetBackBuffer(D3DResourceType.IDirect3DSurface9, m_render.RenderTargetSurface); m_image.Unlock(); }), DispatcherPriority.Send); }
public void SetFormat(BitmapFormat format) { if (m_data == default(PixelData)) { m_format = format; m_data = new PixelData(m_format.ImageSize); m_pData = GCHandle.Alloc(m_data, GCHandleType.Pinned); InitMedia(); } else { throw new InvalidOperationException("Bitmap format already set"); } }
public static VideoSequenceItem FromPlanarFrame(PlanarFrame data, BitmapFormat format) { VideoSequenceItem frame = new VideoSequenceItem(); frame.Target = new PlanarImage(format.Width, format.Height, GetYuvType(format.ChromaType), data.Planes); return frame; }
/// <summary> /// Invoked before video stream starts in order to set and/or change the frame format /// </summary> /// <param name="format"></param> /// <returns></returns> public virtual BitmapFormat FormatSetup(BitmapFormat format) { Nodes.ForEach(n => n.FormatSetup(format)); return format; }
private BitmapFormat OnFormatSetup(BitmapFormat input) { m_format = new BitmapFormat(input.Width, input.Height, ChromaType.I420); InitRenderer(); return m_format; }
private unsafe int OnFormatCallback(void** opaque, char* chroma, int* width, int* height, int* pitches, int* lines) { var pChroma = new IntPtr(chroma); var chromaStr = Marshal.PtrToStringAnsi(pChroma); ChromaType type; if (!Enum.TryParse<ChromaType>(chromaStr, out type)) { var exc = new ArgumentException("Unsupported chroma type " + chromaStr); if (_mExcHandler != null) { _mExcHandler(exc); return 0; } else { throw exc; } } _mFormat = new BitmapFormat(*width, *height, type); if (_mFormatSetupCb != null) { _mFormat = _mFormatSetupCb(_mFormat); } Marshal.Copy(_mFormat.Chroma.ToUtf8(), 0, pChroma, 4); *width = _mFormat.Width; *height = _mFormat.Height; for (var i = 0; i < _mFormat.Planes; i++) { pitches[i] = _mFormat.Pitches[i]; lines[i] = _mFormat.Lines[i]; } _mPixelData = new PlanarPixelData(_mFormat.PlaneSizes); return _mFormat.Planes; }