vo_dfbmga.c
来自「君正早期ucos系统(只有早期的才不没有打包成库),MPLAYER,文件系统,图」· C语言 代码 · 共 1,527 行 · 第 1/4 页
C
1,527 行
if ((in_height > (0.95 * screen_height)) && (in_height < screen_height)) out_height = in_height; else out_height = screen_height; aspect_save_screenres( out_width, out_height ); aspect( &out_width, &out_height, (flags & VOFLAG_FULLSCREEN) ? A_ZOOM : A_NOZOOM ); if (in_width != out_width || in_height != out_height) stretch = 1; else stretch = 0; c2rect.x = (screen_width - out_width) / 2; c2rect.y = (screen_height - out_height) / 2; c2rect.w = out_width; c2rect.h = out_height; c2frame->Clear( c2frame, 0, 0, 0, 0xff ); c2frame->Flip( c2frame, NULL, 0 ); c2frame->Clear( c2frame, 0, 0, 0, 0xff ); c2frame->Flip( c2frame, NULL, 0 ); c2frame->Clear( c2frame, 0, 0, 0, 0xff ); mp_msg( MSGT_VO, MSGL_INFO, "vo_dfbmga: CRTC2 using %s buffering\n", dlc.buffermode == DLBM_TRIPLE ? "triple" : dlc.buffermode == DLBM_BACKVIDEO ? "double" : "single" ); mp_msg( MSGT_VO, MSGL_INFO, "vo_dfbmga: CRTC2 surface %dx%d %s\n", screen_width, screen_height, pixelformat_name( dlc.pixelformat ) ); } else { use_spic = 0; } /* * Sub-picture */ if (use_spic) { /* Draw OSD to sub-picture surface */ IDirectFBPalette *palette; DFBColor color; int i; struct layer_enum l = { "Matrox CRTC2 Sub-Picture", &spic, DFB_UNSUPPORTED }; dfb->EnumDisplayLayers( dfb, get_layer_by_name, &l ); if (l.res != DFB_OK) { mp_msg( MSGT_VO, MSGL_ERR, "vo_dfbmga: Can't get sub-picture layer - %s\n", DirectFBErrorString( l.res ) ); return -1; } if ((res = spic->SetCooperativeLevel( spic, DLSCL_EXCLUSIVE )) != DFB_OK) { mp_msg( MSGT_VO, MSGL_ERR, "Can't get exclusive access to sub-picture - %s\n", DirectFBErrorString( res ) ); return -1; } dlc.flags = DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE; dlc.pixelformat = DSPF_ALUT44; dlc.buffermode = buffermode;#if DIRECTFBVERSION > DFB_VERSION(0,9,16) dlc.flags |= DLCONF_OPTIONS; dlc.options = DLOP_ALPHACHANNEL;#endif if ((res = spic->TestConfiguration( spic, &dlc, &failed )) != DFB_OK) { mp_msg( MSGT_VO, MSGL_ERR, "vo_dfbmga: Invalid sub-picture configuration - %s!\n", DirectFBErrorString( res ) ); return -1; } if ((res = spic->SetConfiguration( spic, &dlc )) != DFB_OK) { mp_msg( MSGT_VO, MSGL_ERR, "vo_dfbmga: Sub-picture configuration failed - %s!\n", DirectFBErrorString( res ) ); return -1; } spic->GetSurface( spic, &spicframe ); spicframe->GetPalette( spicframe, &palette ); color.a = 0xff; for (i = 0; i < 16; i++) { color.r = i * 17; color.g = i * 17; color.b = i * 17; palette->SetEntries( palette, &color, 1, i ); } palette->Release( palette ); spicframe->Clear( spicframe, 0, 0, 0, 0 ); spicframe->Flip( spicframe, NULL, 0 ); spicframe->Clear( spicframe, 0, 0, 0, 0 ); spicframe->Flip( spicframe, NULL, 0 ); spicframe->Clear( spicframe, 0, 0, 0, 0 ); mp_msg( MSGT_VO, MSGL_INFO, "vo_dfbmga: Sub-picture layer using %s buffering\n", dlc.buffermode == DLBM_TRIPLE ? "triple" : dlc.buffermode == DLBM_BACKVIDEO ? "double" : "single" ); subframe = spicframe; subrect = NULL; } else if (use_crtc2) { /* Draw OSD to CRTC2 surface */ subframe = c2frame; subrect = &c2rect; } else { /* Draw OSD to BES surface */ subframe = besframe; subrect = &besrect; } subframe->GetSize( subframe, &sub_width, &sub_height ); subframe->GetPixelFormat( subframe, &subframe_format ); mp_msg( MSGT_VO, MSGL_INFO, "vo_dfbmga: Sub-picture surface %dx%d %s (%s)\n", sub_width, sub_height, pixelformat_name( subframe_format ), use_crtc2 ? (use_spic ? "Sub-picture layer" : "CRTC2") : "BES" ); osd_dirty = 0; osd_current = 1; blit_done = 0; return 0;}static intquery_format( uint32_t format ){ switch (format) { case IMGFMT_BGR32: case IMGFMT_BGR24: case IMGFMT_BGR16: case IMGFMT_BGR15: case IMGFMT_UYVY: case IMGFMT_YV12: case IMGFMT_I420: case IMGFMT_IYUV: if (is_g200) return 0; case IMGFMT_YUY2: break;#if DIRECTFBVERSION > DFB_VERSION(0,9,21) case IMGFMT_NV12: case IMGFMT_NV21: if (!use_bes || use_crtc2) return 0; break;#endif default: return 0; } return (VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_CSP_SUPPORTED | VFCAP_OSD);}static voidvo_draw_alpha_alut44( int w, int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dst, int dststride ){ int x; while (h--) { for (x = 0; x < w; x++) { if (srca[x]) dst[x] = ((255 - srca[x]) & 0xF0) | (src[x] >> 4); } src += srcstride; srca += srcstride; dst += dststride; }}static voidclear_alpha( int x0, int y0, int w, int h ){ if (use_spic && !flipping && vo_osd_changed_flag) subframe->FillRectangle( subframe, x0, y0, w, h );}static voiddraw_alpha( int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride ){ void *dst; int pitch; if (use_spic) { if (!osd_changed || (!flipping && !vo_osd_changed_flag)) return; osd_dirty |= osd_current; } else { if (x0 < subrect->x || y0 < subrect->y || x0 + w > subrect->x + subrect->w || y0 + h > subrect->y + subrect->h) osd_dirty |= osd_current; } if (subframe->Lock( subframe, DSLF_READ | DSLF_WRITE, &dst, &pitch ) != DFB_OK) return; switch (subframe_format) { case DSPF_ALUT44: vo_draw_alpha_alut44( w, h, src, srca, stride, ((uint8_t *) dst) + pitch * y0 + x0, pitch ); break; case DSPF_RGB32: case DSPF_ARGB: vo_draw_alpha_rgb32( w, h, src, srca, stride, (( uint8_t *) dst) + pitch * y0 + 4 * x0, pitch ); break; case DSPF_RGB24: vo_draw_alpha_rgb24( w, h, src, srca, stride, ((uint8_t *) dst) + pitch * y0 + 3 * x0, pitch ); break; case DSPF_RGB16: vo_draw_alpha_rgb16( w, h, src, srca, stride, ((uint8_t *) dst) + pitch * y0 + 2 * x0, pitch ); break; case DSPF_ARGB1555: vo_draw_alpha_rgb15( w, h, src, srca, stride, ((uint8_t *) dst) + pitch * y0 + 2 * x0, pitch ); break; case DSPF_YUY2: vo_draw_alpha_yuy2( w, h, src, srca, stride, ((uint8_t *) dst) + pitch * y0 + 2 * x0, pitch ); break; case DSPF_UYVY: vo_draw_alpha_yuy2( w, h, src, srca, stride, ((uint8_t *) dst) + pitch * y0 + 2 * x0 + 1, pitch ); break;#if DIRECTFBVERSION > DFB_VERSION(0,9,21) case DSPF_NV12: case DSPF_NV21:#endif case DSPF_I420: case DSPF_YV12: vo_draw_alpha_yv12( w, h, src, srca, stride, ((uint8_t *) dst) + pitch * y0 + x0, pitch ); break; } subframe->Unlock( subframe );}static intdraw_frame( uint8_t * src[] ){ return -1;}static intdraw_slice( uint8_t * src[], int stride[], int w, int h, int x, int y ){ void *dst; int pitch; if (frame->Lock( frame, DSLF_WRITE, &dst, &pitch ) != DFB_OK) return VO_FALSE; memcpy_pic( dst + pitch * y + x, src[0], w, h, pitch, stride[0] ); dst += pitch * buf_height; y /= 2; h /= 2;#if DIRECTFBVERSION > DFB_VERSION(0,9,21) if (frame_format == DSPF_NV12 || frame_format == DSPF_NV21) { memcpy_pic( dst + pitch * y + x, src[1], w, h, pitch, stride[1] ); } else#endif { x /= 2; w /= 2; pitch /= 2; if (frame_format == DSPF_I420 ) memcpy_pic( dst + pitch * y + x, src[1], w, h, pitch, stride[1] ); else memcpy_pic( dst + pitch * y + x, src[2], w, h, pitch, stride[2] ); dst += pitch * buf_height / 2; if (frame_format == DSPF_I420 ) memcpy_pic( dst + pitch * y + x, src[2], w, h, pitch, stride[2] ); else memcpy_pic( dst + pitch * y + x, src[1], w, h, pitch, stride[1] ); } frame->Unlock( frame ); return VO_TRUE;}static voidblit_to_screen( void ){ IDirectFBSurface *blitsrc = frame; DFBRectangle *srect = NULL; if (use_bes) {#if DIRECTFBVERSION > DFB_VERSION(0,9,15) if (vo_vsync && !flipping && !use_crtc2) bes->WaitForSync( bes );#endif besframe->Blit( besframe, blitsrc, NULL, besrect.x, besrect.y ); blitsrc = besframe; srect = &besrect; } if (use_crtc2) {#if DIRECTFBVERSION > DFB_VERSION(0,9,15) if (vo_vsync && !flipping) crtc2->WaitForSync( crtc2 );#endif if (stretch) c2frame->StretchBlit( c2frame, blitsrc, srect, &c2rect ); else c2frame->Blit( c2frame, blitsrc, srect, c2rect.x, c2rect.y ); }}static voiddraw_osd( void ){ frame = bufs[current_buf]; frame->Unlock( frame ); osd_changed = vo_osd_changed( 0 ); if (osd_dirty & osd_current) { if (use_spic) { if (flipping) subframe->Clear( subframe, 0, 0, 0, 0 ); } else { /* Clear black bars around the picture */ subframe->FillRectangle( subframe, 0, 0, sub_width, subrect->y ); subframe->FillRectangle( subframe, 0, subrect->y + subrect->h, sub_width, subrect->y ); subframe->FillRectangle( subframe, 0, subrect->y, subrect->x, subrect->h ); subframe->FillRectangle( subframe, subrect->x + subrect->w, subrect->y, subrect->x, subrect->h ); } osd_dirty &= ~osd_current; }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?