CompositionObject::CompositionObject()
{
    m_pRLEData      = NULL;
    m_nRLEDataSize  = 0;
    m_nRLEPos       = 0;
	
    memsetd(m_Colors, 0x00000000, sizeof(m_Colors));
}
CompositionObject::CompositionObject()
{
    m_rtStart       = 0;
    m_rtStop        = 0;
    m_pRLEData      = NULL;
    m_nRLEDataSize  = 0;
    m_nRLEPos       = 0;
    m_nColorNumber  = 0;
    memsetd(m_Colors, 0xFF000000, sizeof(m_Colors));
}
Exemple #3
0
static int ndStart(unsigned char **buf, int  *len)
{
	uint32_t initval;
	uint32_t dmalen;

	initval=(smpOpt&SMP_SIGNEDOUT)?0:0x80808080;
	if (smpOpt&SMP_16BIT)
		initval&=0xFF00FF00;

	dmalen=(*len)>>((!!(smpOpt&SMP_STEREO))+(!!(smpOpt&SMP_16BIT)));
	memsetd(*buf, initval, dmalen);
	
	smpGetBufPos=getbufpos;
	sampbuf=*buf=calloc(*len, 1);
	return 1;
}
void CompositionObject::Init()
{
    m_pRLEData = nullptr;
    m_nRLEDataSize = m_nRLEPos = 0;
    m_nColorNumber = 0;
    m_object_id_ref = 0;
    m_window_id_ref = 0;
    m_object_cropped_flag = false;
    m_forced_on_flag = false;
    m_version_number = 0;
    m_horizontal_position = m_vertical_position = 0;
    m_width = m_height = 0;
    m_cropping_horizontal_position = m_cropping_vertical_position = 0;
    m_cropping_width = m_cropping_height = 0;

    memsetd(m_Colors, 0xff000000, sizeof(m_Colors));
}
Exemple #5
0
void  DrawRectBASE(PixelBlock& w, int x, int y, int cx, int cy, Color c)
{
	RTIMING("DrawRect");
	Rect r = RectC(x, y, cx, cy);
	r.Intersect(w.GetSize());
	if(r.IsEmpty())
		return;
	dword color = c.GetRaw();
	dword *a = w.PointAdr(r.left, r.top);
	int d = w.LineDelta();
	cy = r.Height();
	cx = r.Width();
	while(cy--) {
		memsetd(a, color, cx);
		a += d;
	}
}
u32t _std mod_unpack1(u32t datalen, u8t* src, u8t *dst) {
   struct LX_Iter *ir = (struct LX_Iter*)src;
   u8t *page = dst;
   u32t save;
   if (datalen>=PAGESIZE) return 0;
   save = *(u32t*)(src+datalen);
   *(u32t*)(src+datalen) = 0;

   while (ir->LX_nIter) {
      switch (ir->LX_nBytes) {
         case 1:
            memset(dst, ir->LX_Iterdata, ir->LX_nIter);
            dst+=ir->LX_nIter;
            break;
         case 2:
            memsetw((u16t*)dst, *(u16t*)&ir->LX_Iterdata, ir->LX_nIter);
            dst+=ir->LX_nIter<<1;
            break;
         case 4:
            memsetd((u32t*)dst, *(u32t*)&ir->LX_Iterdata, ir->LX_nIter);
            dst+=ir->LX_nIter<<2;
            break;
         default: {
            u32t cnt;
            for (cnt=0; cnt<ir->LX_nIter; cnt++) {
               memcpy(dst,&ir->LX_Iterdata,ir->LX_nBytes);
               dst+=ir->LX_nBytes;
            }
            break;
         }
      }
      ir = (struct LX_Iter*)((u8t*)ir+4+ir->LX_nBytes);
   }
   *(u32t*)(src+datalen) = save;
   return dst - page;
}
Exemple #7
0
HRESULT CSubtitleStream::FillBuffer(IMediaSample* pSample)
{
	HRESULT hr;

	{
		CAutoLock cAutoLockShared(&m_cSharedState);

		BYTE* pData = NULL;
		if (FAILED(hr = pSample->GetPointer(&pData)) || !pData) {
			return S_FALSE;
		}

		AM_MEDIA_TYPE* pmt;
		if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
			CMediaType mt(*pmt);
			SetMediaType(&mt);
			DeleteMediaType(pmt);
		}

		int len = 0;
		REFERENCE_TIME rtStart, rtStop;

		if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32) {
			rtStart = (REFERENCE_TIME)((m_nPosition*_ATPF - m_rtStart) / m_dRateSeeking);
			rtStop = (REFERENCE_TIME)(((m_nPosition+1)*_ATPF - m_rtStart) / m_dRateSeeking);
			if (m_rtStart+rtStart >= m_rtDuration) {
				return S_FALSE;
			}

			BITMAPINFOHEADER& bmi = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader;

			SubPicDesc spd;
			spd.w = _WIDTH;
			spd.h = _HEIGHT;
			spd.bpp = 32;
			spd.pitch = bmi.biWidth*4;
			spd.bits = pData;

			len = spd.h*spd.pitch;

			for (int y = 0; y < spd.h; y++) {
				memsetd((DWORD*)(pData + spd.pitch*y), 0xff000000, spd.w*4);
			}

			RECT bbox;
			m_rts.Render(spd, m_nPosition*_ATPF, 10000000.0/_ATPF, bbox);

			for (int y = 0; y < spd.h; y++) {
				DWORD* p = (DWORD*)(pData + spd.pitch*y);
				for (int x = 0; x < spd.w; x++, p++) {
					*p = (0xff000000-(*p&0xff000000))|(*p&0xffffff);
				}
			}
		} else if (m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32) {
			const STSSegment* stss = m_rts.GetSegment(m_nPosition);
			if (!stss) {
				return S_FALSE;
			}

			BITMAPINFOHEADER& bmi = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader;

			SubPicDesc spd;
			spd.w = _WIDTH;
			spd.h = _HEIGHT;
			spd.bpp = 32;
			spd.pitch = bmi.biWidth*4;
			spd.bits = pData;

			len = spd.h*spd.pitch;

			for (int y = 0; y < spd.h; y++) {
				DWORD c1 = 0xff606060, c2 = 0xffa0a0a0;
				if (y&32) {
					c1 ^= c2, c2 ^= c1, c1 ^= c2;
				}
				DWORD* p = (DWORD*)(pData + spd.pitch*y);
				for (int x = 0; x < spd.w; x+=32, p+=32) {
					memsetd(p, (x&32) ? c1 : c2, min(spd.w-x,32)*4);
				}
			}

			RECT bbox;
			m_rts.Render(spd, 10000i64*(stss->start+stss->end)/2, 10000000.0/_ATPF, bbox);

			rtStart = (REFERENCE_TIME)((10000i64*stss->start - m_rtStart) / m_dRateSeeking);
			rtStop = (REFERENCE_TIME)((10000i64*stss->end - m_rtStart) / m_dRateSeeking);
		} else {
			if ((size_t)m_nPosition >= m_rts.GetCount()) {
				return S_FALSE;
			}

			STSEntry& stse = m_rts[m_nPosition];

			if (stse.start >= m_rtStop/10000) {
				return S_FALSE;
			}

			if (m_mt.majortype == MEDIATYPE_Subtitle && m_mt.subtype == MEDIASUBTYPE_UTF8) {
				CStringA str = UTF16To8(m_rts.GetStrW(m_nPosition, false));
				memcpy((char*)pData, str, len = str.GetLength());
			} else if (m_mt.majortype == MEDIATYPE_Subtitle && (m_mt.subtype == MEDIASUBTYPE_SSA || m_mt.subtype == MEDIASUBTYPE_ASS)) {
				CStringW line;
				line.Format(L"%d,%d,%s,%s,%d,%d,%d,%s,%s",
							stse.readorder, stse.layer, CStringW(stse.style), CStringW(stse.actor),
							stse.marginRect.left, stse.marginRect.right, (stse.marginRect.top+stse.marginRect.bottom)/2,
							CStringW(stse.effect), m_rts.GetStrW(m_nPosition, true));

				CStringA str = UTF16To8(line);
				memcpy((char*)pData, str, len = str.GetLength());
			} else if (m_mt.majortype == MEDIATYPE_Text && m_mt.subtype == MEDIASUBTYPE_NULL) {
				CStringA str = m_rts.GetStrA(m_nPosition, false);
				memcpy((char*)pData, str, len = str.GetLength());
			} else {
				return S_FALSE;
			}

			rtStart = (REFERENCE_TIME)((10000i64*stse.start - m_rtStart) / m_dRateSeeking);
			rtStop = (REFERENCE_TIME)((10000i64*stse.end - m_rtStart) / m_dRateSeeking);
		}

		pSample->SetTime(&rtStart, &rtStop);
		pSample->SetActualDataLength(len);

		m_nPosition++;
	}

	pSample->SetSyncPoint(TRUE);

	if (m_bDiscontinuity) {
		pSample->SetDiscontinuity(TRUE);
		m_bDiscontinuity = FALSE;
	}

	return S_OK;
}
Exemple #8
0
void DisplaySignature(HDC MyDC, int x, int y)
{
    static DWORD *Signature=NULL; //This holds the DIBSection signature

    if(!MyDC) //This is called when window is destroyed, so delete signature data
    {
        delete[] Signature;
        Signature=NULL;
        return;
    }
    else if(Signature==NULL) //Signature data has not yet been extracted, so do so
    {
        //Prepare to decode signature
        //const UCHAR BytesPerPixel=4, TranspMask=255; //32 bits per pixel (for quicker copies and such - variable not used due to changing BYTE*s to DWORD*s), and white=transparent background color - also not used anymore since we directly write in the background color
        //Load data from executable
        HGLOBAL GetData=LoadResource(NULL, FindResource(NULL, "DakSig", "Sig")); //Load the resource from the executable
        BYTE *Input=(BYTE*)LockResource(GetData); //Get the resource data

        //Prepare header and decoding data
        UINT BitOn=0; //Bit we are currently on in reading
        EncodedFileHeader H=*(EncodedFileHeader*)Input; //Save header locally so we have quick memory lookups
        DWORD *Output=Signature=new DWORD[H.Width*H.Height]; //Allocate signature memory

        //Prepare the index colors
        DWORD Indexes[17], IndexSize=NumBitsRequired(H.NumIndexes); //Save full color indexes locally so we have quick lookups, use 17 index array so we don't have to allocate memory (since we already know how many there will be), #16=transparent color
        DWORD BackgroundColor=GetSysColor(COLOR_BTNFACE), FontColor=0x067906;
        BYTE *BGC=(BYTE*)&BackgroundColor, *FC=(BYTE*)&FontColor;
        for(UINT i=0; i<16; i++) //Alpha blend the indexes
        {
            float Alpha=((EncodedFileHeader*)Input)->Indexes[i] / 255.0f;
            BYTE IndexColor[4];
            for(int n=0; n<3; n++)
                IndexColor[n]=(BYTE)(BGC[n]*Alpha + FC[n]*(1-Alpha));
            //IndexColor[3]=0; //Don't really need to worry about the last byte as it is unused
            Indexes[i]=*(DWORD*)IndexColor;
        }
        Indexes[16]=BackgroundColor; //Translucent background = window background color

        //Unroll/unencode all the pixels
        Input+=(sizeof(EncodedFileHeader)+H.NumIndexes); //Start reading input past the header
        do
        {
            UINT l; //Length (transparent and then index)
            //Transparent pixels
            memsetd(Output, Indexes[16], l=ReadBits(Input, BitOn, H.TranspSize));
            Output+=l;

            //Translucent pixels
            l=ReadBits(Input, BitOn+=H.TranspSize, H.TranslSize);
            BitOn+=H.TranslSize;
            for(i=0; i<l; i++) //Write the gray scale out to the 3 pixels, this should technically be done in a for loop, which would unroll itself anyways, but this way ReadBits+index lookup is only done once - ** Would need to be in a for loop if not using gray-scale or 24 bit output
                Output[i]=Indexes[ReadBits(Input, BitOn+i*IndexSize, IndexSize)];
            Output+=l;
            BitOn+=l*IndexSize;
        } while(BitOn<H.DataSize);
    }

    //Output the signature
    const BITMAPINFOHEADER MyBitmapInfo= {sizeof(BITMAPINFOHEADER), 207, 42, 1, 32, BI_RGB, 0, 0, 0, 0, 0};
    SetDIBitsToDevice(MyDC, x, y, MyBitmapInfo.biWidth, MyBitmapInfo.biHeight, 0, 0, 0, MyBitmapInfo.biHeight, Signature, (BITMAPINFO*)&MyBitmapInfo, DIB_RGB_COLORS);
}
Exemple #9
0
void KERNEL_CALL
semaphores_install(void)
{
    memsetd(gSemaphores, 0, NUM_SEMAPHORES);
    semaphore_init(KEYBOARD_SEMAPHORE, 1);
}