bool CRendererMediaCodec::CreateTexture(int index) { YUVBUFFER &buf(m_buffers[index]); buf.image.height = m_sourceHeight; buf.image.width = m_sourceWidth; for (int f=0; f<3; ++f) { YUVPLANE &plane = buf.fields[f][0]; plane.texwidth = m_sourceWidth; plane.texheight = m_sourceHeight; plane.pixpertex_x = 1; plane.pixpertex_y = 1; if(m_renderMethod & RENDER_POT) { plane.texwidth = NP2(plane.texwidth); plane.texheight = NP2(plane.texheight); } } return true; }
bool CRendererMediaCodec::CreateTexture(int index) { YV12Image &im = m_buffers[index].image; YUVFIELDS &fields = m_buffers[index].fields; memset(&im , 0, sizeof(im)); memset(&fields, 0, sizeof(fields)); im.height = m_sourceHeight; im.width = m_sourceWidth; for (int f=0; f<3; ++f) { YUVPLANE &plane = fields[f][0]; plane.texwidth = im.width; plane.texheight = im.height; plane.pixpertex_x = 1; plane.pixpertex_y = 1; if(m_renderMethod & RENDER_POT) { plane.texwidth = NP2(plane.texwidth); plane.texheight = NP2(plane.texheight); } } return true; }
uint32_t* convert_rgba(CDVDOverlayImage* o, bool mergealpha) { uint32_t* rgba = (uint32_t*)malloc(NP2(o->width) * NP2(o->height) * sizeof(uint32_t)); if(!rgba) return NULL; uint32_t palette[256]; memset(palette, 0, 256 * sizeof(palette[0])); for(int i = 0; i < o->palette_colors; i++) palette[i] = build_rgba((o->palette[i] >> PIXEL_ASHIFT) & 0xff , (o->palette[i] >> PIXEL_RSHIFT) & 0xff , (o->palette[i] >> PIXEL_GSHIFT) & 0xff , (o->palette[i] >> PIXEL_BSHIFT) & 0xff , mergealpha); for(int row = 0; row < o->height; row++) for(int col = 0; col < o->width; col++) rgba[row * o->width + col] = palette[ o->data[row * o->linesize + col] ]; return rgba; }
uint32_t* convert_rgba(CDVDOverlaySpu* o, bool mergealpha , int& min_x, int& max_x , int& min_y, int& max_y) { uint32_t* rgba = (uint32_t*)malloc(NP2(o->width) * NP2(o->height) * sizeof(uint32_t)); if(!rgba) return NULL; uint32_t palette[8]; for(int i = 0; i < 4; i++) { palette[i] = build_rgba(o->color[i] , o->alpha[i] , mergealpha); palette[i+4] = build_rgba(o->highlight_color[i], o->highlight_alpha[i], mergealpha); } uint32_t color; uint32_t* trg; uint16_t* src; int len, idx, draw; int btn_x_start = 0 , btn_x_end = 0 , btn_y_start = 0 , btn_y_end = 0; if(o->bForced) { btn_x_start = o->crop_i_x_start - o->x; btn_x_end = o->crop_i_x_end - o->x; btn_y_start = o->crop_i_y_start - o->y; btn_y_end = o->crop_i_y_end - o->y; } min_x = o->width; max_x = 0; min_y = o->height; max_y = 0; trg = rgba; src = (uint16_t*)o->result; for (int y = 0; y < o->height; y++) { for (int x = 0; x < o->width ; x += len) { /* Get the RLE part, then draw the line */ idx = *src & 0x3; len = *src++ >> 2; while( len > 0 ) { draw = len; color = palette[idx]; if (y >= btn_y_start && y <= btn_y_end) { if ( x < btn_x_start && x + len >= btn_x_start) // starts outside draw = btn_x_start - x; else if( x >= btn_x_start && x <= btn_x_end) // starts inside { color = palette[idx + 4]; draw = btn_x_end - x + 1; } } /* make sure we are not requested to draw to far */ /* that part will be taken care of in next pass */ if( draw > len ) draw = len; /* calculate cropping */ if(color & 0xff000000) { if(x < min_x) min_x = x; if(y < min_y) min_y = y; if(x + draw > max_x) max_x = x + draw; if(y + 1 > max_y) max_y = y + 1; } for(int i = 0; i < draw; i++) trg[x + i] = color; len -= draw; x += draw; } } trg += o->width; } return rgba; }