public ScreenMbBits(CommonEltMbDataType_t dataType) { InitializeComponent(); m_DataType = dataType; switch (m_DataType) { case CommonEltMbDataType_t.CommonEltMbDataType_Final: { m_Title = "Reconstructed"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_Predicted: { m_Title = "Predicted"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_IDCTCoeffsQuant: { m_Title = "Coeffs. (Quantized)"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_IDCTCoeffsScale: { m_Title = "Coeffs. (Scaled)"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_Residual: { m_Title = "Residual (Final)"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_ResidualBase: { m_Title = "Residual (SVC Base)"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_PreFilter: { m_Title = "Pre-Filter"; break; } default: { m_Title = "Unknown"; break; } } m_DataSourceY = new MyObservableCollection<MbBits4x4Row>(true); m_DataSourceU = new MyObservableCollection<MbBits4x4Row>(true); m_DataSourceV = new MyObservableCollection<MbBits4x4Row>(true); m_ListBoxY.ItemsSource = m_DataSourceY; m_ListBoxU.ItemsSource = m_DataSourceU; m_ListBoxV.ItemsSource = m_DataSourceV; }
public ScreenPictureView(CommonEltMbDataType_t dataType) { InitializeComponent(); m_DataType = dataType; switch (m_DataType) { case CommonEltMbDataType_t.CommonEltMbDataType_Final: { m_Title = "Reconstructed"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_Predicted: { m_Title = "Predicted"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_IDCTCoeffsQuant: { m_Title = "Coeffs. (Quantized)"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_IDCTCoeffsScale: { m_Title = "Coeffs. (Scaled)"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_Residual: { m_Title = "Residual (Final)"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_ResidualBase: { m_Title = "Residual (SVC Base)"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_PreFilter: { m_Title = "Pre-Filter"; break; } default: { m_Title = "Unknown"; break; } } }
public override String GetMd5(CommonEltMbDataType_t eType, int iLine /*Y=0,U=1,V=2,YUV=3*/) { if (iLine == 0) { return(m_Md5Y[(int)eType]); } else if (iLine == 1) { return(m_Md5U[(int)eType]); } else if (iLine == 2) { return(m_Md5V[(int)eType]); } else { return(m_Md5YUV[(int)eType]); } }
public Int32[] GetMbBits4x4(CommonYuvLine_t line, CommonEltMbDataType_t type, uint x, uint y) { if (x >= (m_Width[(int)line] >> 2) || y >= (m_Height[(int)line] >> 2)) { return(null); } Int32[] bits = GetMbBits(line, type); Int32[] bits4x4 = new Int32[16]; uint indexStart = ((y << 2) * m_Width[(int)line]) + (x << 2); uint k = 0; for (uint j = 0; j < 4; j++, indexStart += m_Width[(int)line]) { for (uint i = 0; i < 4; i++) { bits4x4[k++] = bits[indexStart + i]; } } return(bits4x4); }
String ComputeMD5(CommonYuvLine_t line, CommonEltMbDataType_t type) { String md5String; Int32[] a = Mb.GetMbBits(line, type); byte[] b = new byte[a.Length]; for (int i = 0; i < b.Length; ++i) { b[i] = /*BitConverter.GetBytes*/ (byte)(a[i] & 0xFF); } IntPtr ptr = Marshal.AllocHGlobal(b.Length); Marshal.Copy(b, 0, ptr, b.Length); Md5 md5Ctx = new Md5(); md5String = md5Ctx.compute(ptr, (uint)b.Length); Marshal.FreeHGlobal(ptr); md5Ctx.Dispose(); return(md5String); }
public Int32[] GetMbBits(CommonYuvLine_t line, CommonEltMbDataType_t type) { return(m_Data[(int)line][(int)type]); }
public unsafe void CopyAsU8(IntPtr pictDataPtr, UInt32 pictWidthForLine, UInt32 pictHeightForLine, CommonYuvLine_t eLine, CommonEltMbDataType_t eType) { byte *_pictDataPtr = (byte *)pictDataPtr.ToPointer(); UInt32 nPicStartIndex = (m_Y * (pictWidthForLine * m_Height[(int)eLine])) + (m_X * m_Width[(int)eLine]); UInt32 nLastIndex = (pictWidthForLine * pictHeightForLine); UInt32 nMbStartIndex = 0; // if (nStartIndex + ()) for (UInt32 j = 0; j < m_Height[(int)eLine]; ++j) { for (UInt32 i = 0; i < m_Width[(int)eLine]; ++i) { fixed(Int32 *pMb = m_Data[(int)eLine][(int)eType]) { _pictDataPtr[nPicStartIndex + i] = (byte)pMb[nMbStartIndex++]; } } if ((nPicStartIndex + pictWidthForLine) > nLastIndex) { break; } nPicStartIndex += pictWidthForLine; } }
public void CopyAsU8(byte[] pictData, UInt32 pictWidthForLine, UInt32 pictHeightForLine, CommonYuvLine_t eLine, CommonEltMbDataType_t eType) { UInt32 nStartIndex = (m_X * m_Y * m_Height[(int)eLine] * m_Width[(int)eLine]); for (UInt32 j = 0; j < m_Height[(int)eLine]; ++j) { for (UInt32 i = 0; i < m_Width[(int)eLine]; ++i) { pictData[nStartIndex + i] = (byte)m_Data[(int)eLine][(int)eType][i * j]; } nStartIndex += pictWidthForLine; if ((nStartIndex + pictWidthForLine) >= pictData.Length) { break; } } }
public abstract String GetMd5(CommonEltMbDataType_t eType, int iLine /*Y=0,U=1,V=2,YUV=3*/);
public override String GetMd5(CommonEltMbDataType_t eType, int iLine/*Y=0,U=1,V=2,YUV=3*/) { if (iLine == 0) return m_Md5Y[(int)eType]; else if (iLine == 1) return m_Md5U[(int)eType]; else if (iLine == 2) return m_Md5V[(int)eType]; else return m_Md5YUV[(int)eType]; }
public override Bitmap GetImage(CommonEltMbDataType_t eType) { if (m_Images[(int)eType] == null && (m_DefaultSeqParamSet != null) && m_Slices.Count > 0) { // FIXME: YUV420, and single layer int nSizeLuma = (int)(m_DefaultSeqParamSet.Width * m_DefaultSeqParamSet.Height); int nOutputSize = (int)((m_DefaultSeqParamSet.Width * m_DefaultSeqParamSet.Height) << 2); int nSizeChroma = (nSizeLuma) >> 2; IntPtr pY = Marshal.AllocHGlobal(nSizeLuma); IntPtr pU = Marshal.AllocHGlobal(nSizeChroma); IntPtr pV = Marshal.AllocHGlobal(nSizeChroma); m_Images[(int)eType] = new Bitmap((int)m_DefaultSeqParamSet.Width, (int)m_DefaultSeqParamSet.Height, PixelFormat.Format32bppArgb); BitmapData bitmapData = m_Images[(int)eType].LockBits(new Rectangle(0, 0, m_Images[(int)eType].Width, m_Images[(int)eType].Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); #if SAVE_TO_FILE_YUV FileStream file = new FileStream("C:\\Projects\\thialgou\\trunk\\Final.yuv", FileMode.Create, FileAccess.Write); int written = 0; #endif // SAVE_TO_FILE_YUV foreach (var kvp in m_Slices) { foreach (var mb in kvp.Value.Macroblocs) { mb.Value.Mb.CopyAsU8(pY, m_DefaultSeqParamSet.Width, m_DefaultSeqParamSet.Height, CommonYuvLine_t.CommonYuvLine_Y, eType); mb.Value.Mb.CopyAsU8(pU, m_DefaultSeqParamSet.Width >> 1, m_DefaultSeqParamSet.Height >> 1, CommonYuvLine_t.CommonYuvLine_U, eType); mb.Value.Mb.CopyAsU8(pV, m_DefaultSeqParamSet.Width >> 1, m_DefaultSeqParamSet.Height >> 1, CommonYuvLine_t.CommonYuvLine_V, eType); } } #if SAVE_TO_FILE_YUV NativeMethods.WriteFile(file.Handle, pY, (int)nSizeLuma, out written, IntPtr.Zero); NativeMethods.WriteFile(file.Handle, pU, (int)nSizeChroma, out written, IntPtr.Zero); NativeMethods.WriteFile(file.Handle, pV, (int)nSizeChroma, out written, IntPtr.Zero); #endif // SAVE_TO_FILE_YUV Boolean ret = VideoConverterYUV420ToRGB32.convert( pY, pU, pV, m_DefaultSeqParamSet.Width, m_DefaultSeqParamSet.Height, m_DefaultSeqParamSet.Width, bitmapData.Scan0, (uint)nOutputSize); if (ret) { //int stride = (((int)m_SeqParamSet.Width * 32 + 31) & ~31) >> 3; //m_Images[(int)eType] = new Bitmap((int)m_SeqParamSet.Width, (int)m_SeqParamSet.Height, stride, PixelFormat.Format32bppArgb, pRGB32); #if SAVE_TO_FILE_BMP m_Images[(int)eType].Save("C:\\Projects\\thialgou\\trunk\\Final.bmp"); #endif // SAVE_TO_FILE_BMP } #if SAVE_TO_FILE_YUV file.Close(); #endif // SAVE_TO_FILE_YUV /* MD5 */ if (eType == Utils.MD5_ELTMB_TYPE && m_Md5YUV[(int)eType] == null) // FIXME: Final only for now { Md5 md5Ctx = new Md5(); m_Md5Y[(int)eType] = md5Ctx.compute(pY, /*(uint)Math.Min(((0 * 16) + (13 * 16 * 352)), nSizeLuma)*/(uint)nSizeLuma); // FIXME m_Md5U[(int)eType] = md5Ctx.compute(pU, /*(uint)Math.Min(((0 * 8) + (1 * 8 * 176)), nSizeChroma)*/(uint)nSizeChroma); // FIXME m_Md5V[(int)eType] = md5Ctx.compute(pV, (uint)nSizeChroma); md5Ctx.init(); md5Ctx.update(pY, (uint)nSizeLuma); md5Ctx.update(pU, (uint)nSizeChroma); md5Ctx.update(pV, (uint)nSizeChroma); m_Md5YUV[(int)eType] = md5Ctx.final(); md5Ctx.Dispose(); } Marshal.FreeHGlobal(pY); Marshal.FreeHGlobal(pU); Marshal.FreeHGlobal(pV); m_Images[(int)eType].UnlockBits(bitmapData); } return m_Images[(int)eType]; }
public Int32[] GetMbBits4x4(CommonYuvLine_t line, CommonEltMbDataType_t type, uint x, uint y) { if (x >= (m_Width[(int)line] >> 2) || y >= (m_Height[(int)line] >> 2)) { return null; } Int32[] bits = GetMbBits(line, type); Int32[] bits4x4 = new Int32[16]; uint indexStart = ((y << 2) * m_Width[(int)line]) + (x << 2); uint k = 0; for (uint j = 0; j < 4; j++, indexStart += m_Width[(int)line]) { for (uint i = 0; i < 4; i++) { bits4x4[k++] = bits[indexStart + i]; } } return bits4x4; }
public Int32[] GetMbBits(CommonYuvLine_t line, CommonEltMbDataType_t type) { return m_Data[(int)line][(int)type]; }
public unsafe void CopyAsU8(IntPtr pictDataPtr, UInt32 pictWidthForLine, UInt32 pictHeightForLine, CommonYuvLine_t eLine, CommonEltMbDataType_t eType) { byte* _pictDataPtr = (byte*)pictDataPtr.ToPointer(); UInt32 nPicStartIndex = (m_Y * (pictWidthForLine * m_Height[(int)eLine])) + (m_X * m_Width[(int)eLine]); UInt32 nLastIndex = (pictWidthForLine * pictHeightForLine); UInt32 nMbStartIndex = 0; // if (nStartIndex + ()) for (UInt32 j = 0; j < m_Height[(int)eLine]; ++j) { for (UInt32 i = 0; i < m_Width[(int)eLine]; ++i) { fixed (Int32* pMb = m_Data[(int)eLine][(int)eType]) { _pictDataPtr[nPicStartIndex + i] = (byte)pMb[nMbStartIndex++]; } } if ((nPicStartIndex + pictWidthForLine) > nLastIndex) { break; } nPicStartIndex += pictWidthForLine; } }
public override Bitmap GetImage(CommonEltMbDataType_t eType) { if (m_Images[(int)eType] == null && (m_DefaultSeqParamSet != null) && m_Slices.Count > 0) { // FIXME: YUV420, and single layer int nSizeLuma = (int)(m_DefaultSeqParamSet.Width * m_DefaultSeqParamSet.Height); int nOutputSize = (int)((m_DefaultSeqParamSet.Width * m_DefaultSeqParamSet.Height) << 2); int nSizeChroma = (nSizeLuma) >> 2; IntPtr pY = Marshal.AllocHGlobal(nSizeLuma); IntPtr pU = Marshal.AllocHGlobal(nSizeChroma); IntPtr pV = Marshal.AllocHGlobal(nSizeChroma); m_Images[(int)eType] = new Bitmap((int)m_DefaultSeqParamSet.Width, (int)m_DefaultSeqParamSet.Height, PixelFormat.Format32bppArgb); BitmapData bitmapData = m_Images[(int)eType].LockBits(new Rectangle(0, 0, m_Images[(int)eType].Width, m_Images[(int)eType].Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); #if SAVE_TO_FILE_YUV FileStream file = new FileStream("C:\\Projects\\thialgou\\trunk\\Final.yuv", FileMode.Create, FileAccess.Write); int written = 0; #endif // SAVE_TO_FILE_YUV foreach (var kvp in m_Slices) { foreach (var mb in kvp.Value.Macroblocs) { mb.Value.Mb.CopyAsU8(pY, m_DefaultSeqParamSet.Width, m_DefaultSeqParamSet.Height, CommonYuvLine_t.CommonYuvLine_Y, eType); mb.Value.Mb.CopyAsU8(pU, m_DefaultSeqParamSet.Width >> 1, m_DefaultSeqParamSet.Height >> 1, CommonYuvLine_t.CommonYuvLine_U, eType); mb.Value.Mb.CopyAsU8(pV, m_DefaultSeqParamSet.Width >> 1, m_DefaultSeqParamSet.Height >> 1, CommonYuvLine_t.CommonYuvLine_V, eType); } } #if SAVE_TO_FILE_YUV NativeMethods.WriteFile(file.Handle, pY, (int)nSizeLuma, out written, IntPtr.Zero); NativeMethods.WriteFile(file.Handle, pU, (int)nSizeChroma, out written, IntPtr.Zero); NativeMethods.WriteFile(file.Handle, pV, (int)nSizeChroma, out written, IntPtr.Zero); #endif // SAVE_TO_FILE_YUV Boolean ret = VideoConverterYUV420ToRGB32.convert( pY, pU, pV, m_DefaultSeqParamSet.Width, m_DefaultSeqParamSet.Height, m_DefaultSeqParamSet.Width, bitmapData.Scan0, (uint)nOutputSize); if (ret) { //int stride = (((int)m_SeqParamSet.Width * 32 + 31) & ~31) >> 3; //m_Images[(int)eType] = new Bitmap((int)m_SeqParamSet.Width, (int)m_SeqParamSet.Height, stride, PixelFormat.Format32bppArgb, pRGB32); #if SAVE_TO_FILE_BMP m_Images[(int)eType].Save("C:\\Projects\\thialgou\\trunk\\Final.bmp"); #endif // SAVE_TO_FILE_BMP } #if SAVE_TO_FILE_YUV file.Close(); #endif // SAVE_TO_FILE_YUV /* MD5 */ if (eType == Utils.MD5_ELTMB_TYPE && m_Md5YUV[(int)eType] == null) // FIXME: Final only for now { Md5 md5Ctx = new Md5(); m_Md5Y[(int)eType] = md5Ctx.compute(pY, /*(uint)Math.Min(((0 * 16) + (13 * 16 * 352)), nSizeLuma)*/ (uint)nSizeLuma); // FIXME m_Md5U[(int)eType] = md5Ctx.compute(pU, /*(uint)Math.Min(((0 * 8) + (1 * 8 * 176)), nSizeChroma)*/ (uint)nSizeChroma); // FIXME m_Md5V[(int)eType] = md5Ctx.compute(pV, (uint)nSizeChroma); md5Ctx.init(); md5Ctx.update(pY, (uint)nSizeLuma); md5Ctx.update(pU, (uint)nSizeChroma); md5Ctx.update(pV, (uint)nSizeChroma); m_Md5YUV[(int)eType] = md5Ctx.final(); md5Ctx.Dispose(); } Marshal.FreeHGlobal(pY); Marshal.FreeHGlobal(pU); Marshal.FreeHGlobal(pV); m_Images[(int)eType].UnlockBits(bitmapData); } return(m_Images[(int)eType]); }
public ScreenMbBits(CommonEltMbDataType_t dataType) { InitializeComponent(); m_DataType = dataType; switch (m_DataType) { case CommonEltMbDataType_t.CommonEltMbDataType_Final: { m_Title = "Reconstructed"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_Predicted: { m_Title = "Predicted"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_IDCTCoeffsQuant: { m_Title = "Coeffs. (Quantized)"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_IDCTCoeffsScale: { m_Title = "Coeffs. (Scaled)"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_Residual: { m_Title = "Residual (Final)"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_ResidualBase: { m_Title = "Residual (SVC Base)"; break; } case CommonEltMbDataType_t.CommonEltMbDataType_PreFilter: { m_Title = "Pre-Filter"; break; } default: { m_Title = "Unknown"; break; } } m_DataSourceY = new MyObservableCollection <MbBits4x4Row>(true); m_DataSourceU = new MyObservableCollection <MbBits4x4Row>(true); m_DataSourceV = new MyObservableCollection <MbBits4x4Row>(true); m_ListBoxY.ItemsSource = m_DataSourceY; m_ListBoxU.ItemsSource = m_DataSourceU; m_ListBoxV.ItemsSource = m_DataSourceV; }
public abstract Bitmap GetImage(CommonEltMbDataType_t eType);
public virtual IntPtr getData(CommonEltMbDataType_t eType, CommonYuvLine_t eLine) { return(commonWRAPPINVOKE.CommonMb_getData(swigCPtr, (int)eType, (int)eLine)); }
public virtual IntPtr getData(CommonEltMbDataType_t eType, CommonYuvLine_t eLine) { return commonWRAPPINVOKE.CommonMb_getData(swigCPtr, (int)eType, (int)eLine); }