vo_dga.c

来自「君正早期ucos系统(只有早期的才不没有打包成库),MPLAYER,文件系统,图」· C语言 代码 · 共 989 行 · 第 1/3 页

C
989
字号
/* * * X11 DGA Interface * * Copyright ( C ) 2001, Andreas Ackermann. All Rights Reserved. * * <acki@acki-netz.de> * * Sourceforge username: acki2 *  */#include <mplaylib.h>#include <mplaylib.h>#include <mplaylib.h>#include <errno.h>#include "config.h"#include "video_out.h"#include "video_out_internal.h"#include "aspect.h"#include "x11_common.h"#include "fastmemcpy.h"#include "mp_msg.h"#include <X11/Xlib.h>#include <X11/extensions/xf86dga.h>#ifdef HAVE_XF86VM#include <X11/extensions/xf86vmode.h>#endifstatic vo_info_t info = {#ifdef HAVE_DGA2    "DGA ( Direct Graphic Access V2.0 )",#else#ifdef HAVE_XF86VM    "DGA ( Direct Graphic Access V1.0+XF86VidModeExt. )",#else    "DGA ( Direct Graphic Access V1.0 )",#endif#endif    "dga",    "Andreas Ackermann <acki@acki-netz.de>",    ""};LIBVO_EXTERN(dga)//------------------------------------------------------------------//#define BITSPP (vo_dga_modes[vo_dga_active_mode].vdm_bitspp)//#define BYTESPP (vo_dga_modes[vo_dga_active_mode].vdm_bytespp)#define VO_DGA_INVALID_RES 100000#define HW_MODE (vo_dga_modes[vo_dga_hw_mode])#define SRC_MODE (vo_dga_modes[vo_dga_src_mode])struct vd_modes{    int vdm_mplayer_depth;    int vdm_supported;    int vdm_depth;    int vdm_bitspp;    int vdm_bytespp;    int vdm_rmask;    int vdm_gmask;    int vdm_bmask;    int vdm_hw_mode;};//------------------------------------------------------------------static struct vd_modes vo_dga_modes[] = {    // these entries describe HW modes    // however, we use the same entries to tell mplayer what we support    // so the last two values describe, which HW mode to use and which conversion     // function to use for a mode that is not supported by HW    {0, 0, 0, 0, 0, 0, 0, 0, 0,},    {15, 0, 15, 16, 2, 0x7c00, 0x03e0, 0x001f, 2,},    {16, 0, 16, 16, 2, 0xf800, 0x07e0, 0x001f, 2,},    {24, 0, 24, 24, 3, 0xff0000, 0x00ff00, 0x0000ff, 4},    {32, 0, 24, 32, 4, 0x00ff0000, 0x0000ff00, 0x000000ff, 4}};static int vo_dga_mode_num =    sizeof(vo_dga_modes) / sizeof(struct vd_modes);// enable a HW mode (by description)static int vd_EnableMode(int depth, int bitspp,                         int rmask, int gmask, int bmask){    int i;    for (i = 1; i < vo_dga_mode_num; i++)    {        if (vo_dga_modes[i].vdm_depth == depth &&            vo_dga_modes[i].vdm_bitspp == bitspp &&            vo_dga_modes[i].vdm_rmask == rmask &&            vo_dga_modes[i].vdm_gmask == gmask &&            vo_dga_modes[i].vdm_bmask == bmask)        {            vo_dga_modes[i].vdm_supported = 1;            vo_dga_modes[i].vdm_hw_mode = i;            return i;        }    }    return 0;}static int vd_ModeEqual(int depth, int bitspp,                        int rmask, int gmask, int bmask, int index){    return ((vo_dga_modes[index].vdm_depth == depth &&             vo_dga_modes[index].vdm_bitspp == bitspp &&             vo_dga_modes[index].vdm_rmask == rmask &&             vo_dga_modes[index].vdm_gmask == gmask &&             vo_dga_modes[index].vdm_bmask == bmask) ? 1 : 0);}// enable a HW mode (mplayer_depth decides which)static int vd_ValidateMode(int mplayer_depth){    int i;    if (mplayer_depth == 0)        return 0;    for (i = 1; i < vo_dga_mode_num; i++)    {        if (vo_dga_modes[i].vdm_mplayer_depth == mplayer_depth)        {            vo_dga_modes[i].vdm_supported = 1;            vo_dga_modes[i].vdm_hw_mode = i;            return i;        }    }    return 0;}// do we support this mode? (not important whether native or conversion)static int vd_ModeValid(int mplayer_depth){    int i;    if (mplayer_depth == 0)        return 0;    for (i = 1; i < vo_dga_mode_num; i++)    {        if (vo_dga_modes[i].vdm_mplayer_depth == mplayer_depth &&            vo_dga_modes[i].vdm_supported != 0)        {            return i;        }    }    return 0;}static char *vd_GetModeString(int index){#define VO_DGA_MAX_STRING_LEN 100    static char stringbuf[VO_DGA_MAX_STRING_LEN];    stringbuf[VO_DGA_MAX_STRING_LEN - 1] = 0;    snprintf(stringbuf, VO_DGA_MAX_STRING_LEN - 2,             "depth=%d, bpp=%d, r=%06x, g=%06x, b=%06x, %s (-bpp %d)",             vo_dga_modes[index].vdm_depth,             vo_dga_modes[index].vdm_bitspp,             vo_dga_modes[index].vdm_rmask,             vo_dga_modes[index].vdm_gmask,             vo_dga_modes[index].vdm_bmask,             vo_dga_modes[index].             vdm_supported ? "native" : "not supported",             vo_dga_modes[index].vdm_mplayer_depth);    return stringbuf;}//-----------------------------------------------------------------#if defined(HAVE_XF86VM) && !defined(HAVE_DGA2)static XF86VidModeModeInfo **vo_dga_vidmodes = NULL;#endifstatic int vo_dga_src_format;static int vo_dga_width;        // bytes per line in framebufferstatic int vo_dga_vp_width;     // visible pixels per line in                                          // framebufferstatic int vo_dga_vp_height;    // visible lines in framebufferstatic int vo_dga_is_running = 0;static int vo_dga_src_width;    // width of video in pixelsstatic int vo_dga_src_height;   // height of video in pixelsstatic int vo_dga_src_offset = 0;       // offset in srcstatic int vo_dga_vp_offset = 0;        // offset in deststatic int vo_dga_bytes_per_line;       // bytes per line to copystatic int vo_dga_vp_skip;      // dto. for dest static int vo_dga_lines;        // num of lines to copy                                static int vo_dga_hw_mode = 0;  // index in mode list that is actually                                         // used by framebufferstatic int vo_dga_src_mode = 0; // index in mode list that is used by                                          // codecstatic int vo_dga_XServer_mode = 0;     // index in mode list for resolution#ifdef HAVE_DGA2static XDGAMode *vo_modelines;static int vo_modecount;#endif#define MAX_NR_VIDEO_BUFFERS 3#define CURRENT_VIDEO_BUFFER \        (vo_dga_video_buffer[vo_dga_current_video_buffer])static int vo_dga_nr_video_buffers;     // Total number of frame buffers.static int vo_dga_current_video_buffer; // Buffer available for rendering.static struct video_buffer{    int y;    uint8_t *data;} vo_dga_video_buffer[MAX_NR_VIDEO_BUFFERS];/* saved src and dst dimensions for SwScaler */static unsigned int scale_srcW = 0,    scale_dstW = 0, scale_srcH = 0, scale_dstH = 0;//---------------------------------------------------------static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,                       unsigned char *srca, int stride){    char *d;    unsigned int offset;    int buffer_stride;    offset = vo_dga_width * y0 + x0;    buffer_stride = vo_dga_width;    d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset;    switch (HW_MODE.vdm_mplayer_depth)    {        case 32:            vo_draw_alpha_rgb32(w, h, src, srca, stride, d + 4 * offset,                                4 * buffer_stride);            break;        case 24:            vo_draw_alpha_rgb24(w, h, src, srca, stride, d + 3 * offset,                                3 * buffer_stride);            break;        case 15:            vo_draw_alpha_rgb15(w, h, src, srca, stride, d + 2 * offset,                                2 * buffer_stride);            break;        case 16:            vo_draw_alpha_rgb16(w, h, src, srca, stride, d + 2 * offset,                                2 * buffer_stride);            break;    }}//---------------------------------------------------------// quick & dirty - for debugging only #if 0static void fillblock(char *strt, int yoff, int lines, int val){    char *i;    for (i = strt + yoff * vo_dga_width * HW_MODE.vdm_bytespp;         i < strt + (lines + yoff) * vo_dga_width * HW_MODE.vdm_bytespp;)    {        *i++ = val;    }}#endif//---------------------------------------------------------static int draw_frame(uint8_t * src[]){    int numlines = vo_dga_lines;    char *s, *d;    s = *src;    d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset;    mem2agpcpy_pic(d, s,                   vo_dga_bytes_per_line,                   numlines,                   vo_dga_bytes_per_line + vo_dga_vp_skip,                   vo_dga_bytes_per_line);    // DBG-COde#if 0    d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset;    fillblock(d, 0, 10, 0x800000ff);    fillblock(d, 10, 10, 0x8000ff00);    fillblock(d, 20, 10, 0x80ff0000);    fillblock(d, 30, 10, 0xff0000ff);    fillblock(d, 40, 10, 0x800000ff);    fillblock(d, 50, 10, 0x0f0000ff);#endif    return 0;}//---------------------------------------------------------static void check_events(void){    vo_x11_check_events(mDisplay);}//---------------------------------------------------------#include "sub.h"static void draw_osd(void){    vo_draw_text(vo_dga_src_width, vo_dga_src_height, draw_alpha);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?