Exemplo n.º 1
0
        internal static Elt New(CommonElt elt)
        {
            System.Diagnostics.Debug.Assert(elt != null);
            switch (elt.getType())
            {
            case CommonElementType_t.CommonEltType_Syntax:
            {
                return(new EltSyntax(SwigHelper.CastTo <CommonSyntax>(elt)));
            }

            case CommonElementType_t.CommonEltType_Control:
            {
                return(new EltControl(SwigHelper.CastTo <CommonControl>(elt)));
            }

            case CommonElementType_t.CommonEltType_Header:
            {
                return(new EltHeader(SwigHelper.CastTo <CommonHeader>(elt)));
            }

            case CommonElementType_t.CommonEltType_Function:
            {
                return(new EltFunction(SwigHelper.CastTo <CommonFunction>(elt)));
            }

            case CommonElementType_t.CommonEltType_Error:
            {
                return(new EltError(SwigHelper.CastTo <CommonError>(elt)));
            }

            case CommonElementType_t.CommonEltType_Mb:
            {
                CommonMb mb = SwigHelper.CastTo <CommonMb>(elt);
                return(mb.getMbType() == CommonEltMbType_t.CommonEltMbType_H264 ? new H264Mb(SwigHelper.CastTo <CommonMbH264>(elt)) : new EltMb(mb));
            }

            /* === H.264 === */
            case CommonElementType_t.CommonEltType_Nalu:
            {
                return(new EltH264Nalu(SwigHelper.CastTo <CommonH264Nalu>(elt)));
            }

            case CommonElementType_t.CommonEltType_Section:
            {
                return(new EltH264Section(SwigHelper.CastTo <CommonH264Section>(elt)));
            }

            default:
            {
                throw new NotImplementedException("No constructor for element with type = " + elt.getType());
            }
            }
        }
Exemplo n.º 2
0
        public EltMb(CommonMb mb)
            : base(mb)
        {
            m_Address = mb.getAddress();
            m_X       = mb.getX();
            m_Y       = mb.getY();
            m_Data    = new Int32[LINES_COUNT][][];
            m_Width   = new UInt32[LINES_COUNT];
            m_Height  = new UInt32[LINES_COUNT];

            for (int iLine = 0; iLine < LINES_COUNT; iLine++) // Y,U,V
            {
                m_Width[iLine]  = mb.getWidth((CommonYuvLine_t)iLine);
                m_Height[iLine] = mb.getHeight((CommonYuvLine_t)iLine);

                m_Data[iLine] = new Int32[TYPES_COUNT][];
                for (int iType = 0; iType < TYPES_COUNT; iType++) // Final, Residual, Predicted...
                {
                    m_Data[iLine][iType] = new Int32[m_Width[iLine] * m_Height[iLine]];
#if COMPUTE_RESIDUAL
                    if ((int)CommonEltMbDataType_t.CommonEltMbDataType_Residual == iType)
                    {
                        // Residual not generated by the native code: do it ourself. Requires Final and Predicted.
                        int s = (int)(m_Width[iLine] * m_Height[iLine]);
                        for (int i = 0; i < s; i++)
                        {
                            m_Data[iLine][iType][i] = m_Data[iLine][(int)CommonEltMbDataType_t.CommonEltMbDataType_Final][i] - m_Data[iLine][(int)CommonEltMbDataType_t.CommonEltMbDataType_Predicted][i];
                        }
                    }
                    else
#endif
                    {
                        Marshal.Copy(mb.getData((CommonEltMbDataType_t)iType, (CommonYuvLine_t)iLine), m_Data[iLine][iType], 0, (int)(m_Width[iLine] * m_Height[iLine]));
                    }
                }
            }
        }