void syncFramebufferInt( uint8_t withisr ) { uint8_t i,j, k,portoffset; uint8_t mask; /* decompose the PWM on/off for LED rows * and 4bit brightness into portpin on off states * first on abstract virtual IO ports and then divided into * real distributed pins */ for( i = 0; i < (PWMROWCYCLES); i++ ) { setVirtPort( VPORT1, (1<< i)); portoffset = ((PWMROWCYCLES)*i); for( j = 0; j < (PWMSUBCYCLES); j++) { mask = 0; for( k = 0; k < FRAMEBUFFER_WIDTH; k++) { if( framebuffer[k][i] & (1 << j) ) { mask |= (1 << (k)); } } setVirtPort( VPORT0, mask); bufportbseq[portoffset+j] = getBufferedPort( BUF_PORTB ); bufportcseq[portoffset+j] = getBufferedPort( BUF_PORTC); bufportdseq[portoffset+j] = getBufferedPort( BUF_PORTD ); } } if( withisr == 1) { /* swap the buffer if the display output is running only in phase * after complete cycle to prevent tearing */ buffer_ready = 0; while( buffer_ready== 0); cli(); swapBuffer(); sei(); } else { swapBuffer(); } }
char* play() { Alert("vplay\n"); delay=1000000000/ot->dmx->fps; next=sceKernelGetSystemTimeWide(); for(u32 s=0; (s<ot->dmx->Vlen); s++) { if(ot->sys->pad&PSP_CTRL_CIRCLE)break; ot->me->nal.nal=ot->dmx->getVSample(s,&ot->me->nal.nalLen); ot->me->nal.mode=s?0:3; sceMpegGetAvcNalAu(Mpeg,&ot->me->nal,ot->me->mpegAu); if(sceMpegAvcDecode(Mpeg,ot->me->mpegAu,ot->lcd->size,0,&ot->me->pics)<0) { blitErr(); //("VdecErr"); continue; } sceMpegAvcDecodeDetail2(Mpeg,&ot->me->d);// ot->me->d = *Mpeg[414]<7?*Mpeg[424]+0x2C:*Mpeg[419]; SceMpegAvcMode mode= {-1,ot->lcd->type}; sceMpegAvcDecodeMode(&ot->me->mpeg,&mode); for(int i=0; i<ot->me->pics; i++) { Mp4AvcYuvStruct*yuv=ot->me->d->yuv+i; Mp4AvcCscStruct csc= {(ot->me->d->info->height+15)>>4,(ot->me->d->info->width+15)>>4,0,0,yuv->b0,yuv->b1,yuv->b2,yuv->b3,yuv->b4,yuv->b5,yuv->b6,yuv->b7}; sceMpegBaseCscAvc(swapBuffer(),0,ot->lcd->size, &csc); if(ot->gui)Draw(2);//draw some overlay stuff } } return NULL; } char* seek(int t,int o) { Alert("vseek\n"); return NULL; }
void Window::update() { swapBuffer(); waitForEvents(); glfwGetFramebufferSize(window, &width, &height); glViewport(0, 0, width, height); }
void blitErr() { void* vram=swapBuffer(); for(int y=0; y<4; y++) memcpy(vram+4*y*ot->lcd->size,vdecErr+48*y,48*4); }
Status EntityIDBuffer::sort() { // TODO quicksort chunks int chunkCount = THREAD_NUMBER; size_t chunkSize = getSize() / chunkCount; int i = 0; ID * p; for( i = 0; i < chunkCount; i++ ) { p = buffer + i * chunkSize * IDCount; if( i == chunkCount -1 ) CThreadPool::getInstance().AddTask(boost::bind(&SortTask::Run, p,getSize() - chunkSize * (chunkCount - 1), sortKey, IDCount)); else CThreadPool::getInstance().AddTask(boost::bind(&SortTask::Run, p, chunkSize , sortKey, IDCount)); } // TODO waiting for the task completing. CThreadPool::getInstance().Wait(); //TODO merge the chunks into a buffer. ID* tempBuffer = (ID*)malloc(totalSize * 4); if(tempBuffer == NULL) { cout<<totalSize * 4<<endl; tempBuffer = (ID*)malloc(4096); size_t tempSize = 4096; while(tempSize < totalSize * 4) { tempBuffer = (ID*)realloc(tempBuffer, tempSize + 4096); tempSize = tempSize + 4096; } assert(tempSize >= totalSize * 4); } #ifdef DEBUG cout<<"totalsize: "<<totalSize<<endl; #endif double j = 1; int slot; int max = (int)ceil( log((double)chunkCount) / log (2.0) ); while (1) { slot = (int) pow(2, j); if (j > max) break; for (i = 0; i < chunkCount; i += slot) { if(i + slot == chunkCount) { CThreadPool::getInstance().AddTask(boost::bind(&EntityIDBuffer::merge, this, i * chunkSize, ( i + slot / 2 - 1) * chunkSize, (i + slot / 2) * chunkSize, getSize(), tempBuffer)); } else { CThreadPool::getInstance().AddTask(boost::bind(&EntityIDBuffer::merge, this, i * chunkSize, ( i + slot / 2 - 1) * chunkSize, (i + slot / 2) * chunkSize, (i + slot) * chunkSize, tempBuffer)); } } CThreadPool::getInstance().Wait(); swapBuffer(tempBuffer); j++; } sorted = true; free(tempBuffer); return OK; }