void cDisplay3BPPHalf::InitOSD() { if (osd) delete osd; osd = cOsdProvider::NewOsd(OsdX0, OsdY0); if (!osd) return; int width=(Width+1)&~1; // Width has to end on byte boundary, so round up tArea Areas[] = { { 0, 0, width - 1, Height - 1, 4 } }; // Try full-size area first while (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) != oeOk) { // Out of memory, so shrink if (Upper) { // Move up lower border Areas[0].y2=Areas[0].y2-1; } else { // Move down upper border Areas[0].y1=Areas[0].y1+1; } if (Areas[0].y1>Areas[0].y2) { // Area is empty, fail miserably delete osd; osd=NULL; return; } } // Add some backup // CanHandleAreas is not accurate enough if (Upper) { Areas[0].y2=Areas[0].y2-10; } else { Areas[0].y1=Areas[0].y1+10; } osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea)); InitPalette(); InitScaler(); // In case we switched on the fly, do a full redraw Dirty=true; DirtyAll=true; Flush(); }
cDisplay2BPP::cDisplay2BPP(int x0, int y0, int width, int height) : cDisplay(width,height) { // 2BPP display with color mapping osd = cOsdProvider::NewOsd(x0, y0); if (!osd) return; width=(width+3)&~3; // Width has to end on byte boundary, so round up tArea Areas[] = { { 0, 0, width - 1, height - 1, 2 } }; if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) != oeOk) { delete osd; osd=NULL; return; } osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea)); InitPalette(); InitScaler(); }
cDisplay3BPP::cDisplay3BPP(int x0, int y0, int width, int height) : cDisplay(width,height) { // 3BPP display for memory-modded DVB cards and other OSD providers // Actually uses 4BPP, because DVB does not support 3BPP. osd = cOsdProvider::NewOsd(x0, y0); if (!osd) return; width=(width+1)&~1; // Width has to end on byte boundary, so round up tArea Areas[] = { { 0, 0, width - 1, height - 1, 4 } }; if (osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) != oeOk) { delete osd; osd=NULL; return; } osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea)); InitPalette(); InitScaler(); }
bool AndroidVideoOutput::InitCheck (AVStream *vstream) { // release resources if previously initialized CloseFrameBuffer(); #if 0 // initialize only when we have all the required parameters if (iVideoDisplayWidth <=0 || iVideoDisplayHeight <= 0 || iVideoWidth <= 0 || iVideoHeight <= 0) { ERROR ("display or frame size error! display(%d, %d), frame(%d, %d)", iVideoDisplayWidth, iVideoDisplayHeight, iVideoWidth, iVideoHeight); return false; } #endif if (InitScaler (vstream) < 0) { ERROR ("InitScaler fail!"); return false; } // copy parameters in case we need to adjust them int displayWidth = iVideoDisplayWidth; int displayHeight = iVideoDisplayHeight; int frameWidth = iVideoWidth; int frameHeight = iVideoHeight; int frameSize; // RGB-565 frames are 2 bytes/pixel displayWidth = (displayWidth + 1) & -2; displayHeight = (displayHeight + 1) & -2; frameWidth = (frameWidth + 1) & -2; frameHeight = (frameHeight + 1) & -2; frameSize = frameWidth * frameHeight * 2; iVideoFrameSize = frameSize; // create frame buffer heap and register with surfaceflinger mFrameHeap = new android::MemoryHeapBase(frameSize * kBufferCount); if (mFrameHeap->heapID() < 0) { ERROR ("Error creating frame buffer heap!"); return false; } DEBUG ("allcate buffers for surface(%p)!(%d, %d, %d, %d)", mSurface.get(), displayWidth, displayHeight, displayWidth, displayHeight); android::ISurface::BufferHeap buffers(displayWidth, displayHeight, displayWidth, displayHeight, android::PIXEL_FORMAT_RGB_565, mFrameHeap); DEBUG ("mSurface(%p)->registerBuffers", mSurface.get()); mSurface->registerBuffers(buffers); // create frame buffers for (int i = 0; i < kBufferCount; i++) { mFrameBuffers[i] = i * frameSize; } #ifdef USE_COLOR_CONVERTER // initialize software color converter iColorConverter = ColorConvert16::NewL(); iColorConverter->Init(displayWidth, displayHeight, frameWidth, displayWidth, displayHeight, displayWidth, CCROTATE_NONE); iColorConverter->SetMemHeight(frameHeight); iColorConverter->SetMode(1); #endif DEBUG ("video = %d x %d", displayWidth, displayHeight); DEBUG ("frame = %d x %d", frameWidth, frameHeight); DEBUG ("frame #bytes = %d", frameSize); // register frame buffers with SurfaceFlinger mFrameBufferIndex = 0; mInitialized = true; //mPvPlayer->sendEvent(MEDIA_SET_VIDEO_SIZE, iVideoDisplayWidth, iVideoDisplayHeight); return mInitialized; }