⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xvmc.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 4 页
字号:
        for (x = 0; x < src_width;)        {            i_color = *p_source & 0x3;            i_len = *p_source++ >> 2;            if( (i_len > 0) && ((x+i_len) <= src_width) )            {                /* Get the RLE part, then draw the line */                uint32_t color = (sub_img->p_sys->pi_yuv[i_color][0] << 16) |                                 (sub_img->p_sys->pi_yuv[i_color][1] << 0) |                                 (sub_img->p_sys->pi_yuv[i_color][2] << 8);                norm_pixel = (uint8_t)(                            (xx44_paletteIndex( palette,i_color, color ) << 4) |                            (sub_img->p_sys->pi_alpha[i_color] & 0x0F) );                clip_pixel = (uint8_t)(                            (xx44_paletteIndex( palette,i_color + OVL_PALETTE_SIZE,                                                sub_img->p_sys->pi_yuv[i_color][0] ) << 4) |                            (sub_img->p_sys->pi_alpha[i_color] & 0x0F));                if( !ia44 )                {                    norm_pixel = ((norm_pixel & 0x0F) << 4) | ((norm_pixel & 0xF0) >> 4);                    clip_pixel = ((clip_pixel & 0x0F) << 4) | ((clip_pixel & 0xF0) >> 4);                }                if( mask )                {                    if( x < sub_img->p_sys->i_x_start )                    {                        if( (x + i_len) <= sub_img->p_sys->i_x_start )                        {                            memblend_xx44( dst, norm_pixel, i_len, alphamask );                            dst += i_len;                        }                        else                        {                            memblend_xx44( dst, norm_pixel,                                           sub_img->p_sys->i_x_start - x,                                           alphamask );                            dst += sub_img->p_sys->i_x_start - x;                            i_len -= sub_img->p_sys->i_x_start - x;                            if( i_len <= (sub_img->p_sys->i_x_end -                                          sub_img->p_sys->i_x_start) )                            {                                memblend_xx44( dst, clip_pixel,                                               i_len, alphamask);                                dst += i_len;                            }                            else                            {                                memblend_xx44( dst, clip_pixel,                                               sub_img->p_sys->i_x_end -                                                    sub_img->p_sys->i_x_start,                                               alphamask );                                dst += (sub_img->p_sys->i_x_end -                                        sub_img->p_sys->i_x_start);                                i_len -= (sub_img->p_sys->i_x_end -                                          sub_img->p_sys->i_x_start);                                memblend_xx44( dst, norm_pixel,                                               i_len, alphamask );                                dst += i_len;                            }                        }                    }                    else if( x < sub_img->p_sys->i_x_end )                    {                        if( i_len <= (sub_img->p_sys->i_x_end - x) )                        {                            memblend_xx44( dst, clip_pixel, i_len, alphamask);                            dst += i_len;                        }                        else                        {                            memblend_xx44( dst, clip_pixel,                                           sub_img->p_sys->i_x_end - x,                                           alphamask);                            dst += (sub_img->p_sys->i_x_end - x);                            i_len -= (sub_img->p_sys->i_x_end - x);                            memblend_xx44( dst, norm_pixel, i_len, alphamask);                            dst += i_len;                        }                    }                    else                    {                        memblend_xx44( dst, norm_pixel, i_len, alphamask );                        dst += i_len;                    }                }                else                {                    memblend_xx44( dst, norm_pixel, i_len, alphamask );                    dst += i_len;                }            }            else            {                return;            }            x += i_len;        }        dst_y += dst_pitch;    }#endif}int xxmc_xvmc_surface_valid( vout_thread_t *p_vout, XvMCSurface *surf ){    xvmc_surface_handler_t *handler = &p_vout->p_sys->xvmc_surf_handler;    unsigned long index = surf - handler->surfaces;    int ret;    if( index >= XVMC_MAX_SURFACES )        return 0;    pthread_mutex_lock(&handler->mutex);    ret = handler->surfValid[index];    pthread_mutex_unlock(&handler->mutex);    return ret;}static void xxmc_xvmc_dump_subpictures( vout_thread_t *p_vout ){    int i;    xvmc_surface_handler_t *handler = &p_vout->p_sys->xvmc_surf_handler;    for( i=0; i < XVMC_MAX_SUBPICTURES; ++i )    {        msg_Dbg( p_vout, "handler in use %d, valid %d",                         handler->subInUse[i],                         handler->subValid[i]);    }}XvMCSubpicture *xxmc_xvmc_alloc_subpicture( vout_thread_t *p_vout,                    XvMCContext *context, unsigned short width,                    unsigned short height, int xvimage_id ){    int i;    xvmc_surface_handler_t *handler = &p_vout->p_sys->xvmc_surf_handler;    int status;    pthread_mutex_lock(&handler->mutex);    /* xxmc_xvmc_dump_subpictures(p_vout); */    for( i=0; i<XVMC_MAX_SUBPICTURES; ++i )    {        if( handler->subValid[i] && !handler->subInUse[i] )        {            XVMCLOCKDISPLAY( p_vout->p_sys->p_display );            if( XvMCGetSubpictureStatus( p_vout->p_sys->p_display,                                         handler->subpictures + i,                                         &status ) )            {                XVMCUNLOCKDISPLAY( p_vout->p_sys->p_display );                continue;            }            XVMCUNLOCKDISPLAY( p_vout->p_sys->p_display );            if( status & XVMC_DISPLAYING )                continue;            handler->subInUse[i] = 1;            /* xxmc_xvmc_dump_subpictures(p_vout); */            pthread_mutex_unlock(&handler->mutex);            return (handler->subpictures + i);        }    }    for (i=0; i<XVMC_MAX_SUBPICTURES; ++i)    {        if( !handler->subInUse[i] )        {            XVMCLOCKDISPLAY( p_vout->p_sys->p_display );            if( Success != XvMCCreateSubpicture( p_vout->p_sys->p_display,                                                 context,                                                 handler->subpictures + i,                                                 width, height, xvimage_id ) )            {                XVMCUNLOCKDISPLAY( p_vout->p_sys->p_display );                pthread_mutex_unlock( &handler->mutex );                return NULL;            }            XVMCUNLOCKDISPLAY( p_vout->p_sys->p_display );            msg_Dbg( p_vout, "video_out_xxmc: created subpicture %d\n", i );            handler->subInUse[i] = 1;            handler->subValid[i] = 1;            pthread_mutex_unlock( &handler->mutex );            return (handler->subpictures + i);        }    }    pthread_mutex_unlock( &handler->mutex );    return NULL;}void xxmc_xvmc_free_subpicture( vout_thread_t *p_vout, XvMCSubpicture *sub ){    xvmc_surface_handler_t *handler = &p_vout->p_sys->xvmc_surf_handler;    unsigned int index = sub - handler->subpictures;    if( index >= XVMC_MAX_SUBPICTURES )        return;    pthread_mutex_lock( &handler->mutex );    handler->subInUse[index] = 0;    /* xxmc_xvmc_dump_subpictures(p_vout); */    pthread_mutex_unlock( &handler->mutex );}static void xxmc_xvmc_surface_handler_construct( vout_thread_t *p_vout ){    int i;    xvmc_surface_handler_t *handler = &p_vout->p_sys->xvmc_surf_handler;     pthread_mutex_init( &handler->mutex, NULL );    for( i=0; i<XVMC_MAX_SURFACES; ++i )    {        handler->surfInUse[i] = 0;        handler->surfValid[i] = 0;    }    for( i=0; i<XVMC_MAX_SUBPICTURES; ++i )    {        handler->subInUse[i] = 0;        handler->subValid[i] = 0;    }}static void xxmc_xvmc_dump_surfaces( vout_thread_t *p_vout ){    int i;    xvmc_surface_handler_t *handler = &p_vout->p_sys->xvmc_surf_handler;    for (i=0; i<XVMC_MAX_SURFACES; ++i)    {        msg_Dbg(p_vout, "surfaces in use %d, valid %d;",                        handler->surfInUse[i],                        handler->surfValid[i]);    }}void xxmc_xvmc_free_surface( vout_thread_t *p_vout, XvMCSurface *surf ){    xvmc_surface_handler_t *handler = &p_vout->p_sys->xvmc_surf_handler;    unsigned int index = 0;    index = (surf - handler->surfaces);    if (index < XVMC_MAX_SURFACES)    {        pthread_mutex_lock(&handler->mutex);        msg_Dbg( p_vout,"free surface %d",index );        handler->surfInUse[index]--;        xxmc_xvmc_dump_surfaces(p_vout);        pthread_mutex_unlock(&handler->mutex);    }}int checkXvMCCap( vout_thread_t *p_vout ){    int i_xvport = 0;    int numSurf = 0;    int numSub = 0;    int i,j;    XvMCSurfaceInfo     *surfaceInfo =NULL;    XvMCSurfaceInfo     *curInfo = NULL;    XvMCContext         c;    xvmc_capabilities_t *curCap = NULL;    XvImageFormatValues *formatValues = NULL;    i_xvport = p_vout->p_sys->i_xvport;    p_vout->p_sys->xvmc_cap = 0;    init_context_lock( &p_vout->p_sys->xvmc_lock );    xvmc_context_writer_lock( &p_vout->p_sys->xvmc_lock );    p_vout->p_sys->old_subpic = NULL;    p_vout->p_sys->new_subpic = NULL;    p_vout->p_sys->contextActive = 0;    p_vout->p_sys->subImage = NULL;    p_vout->p_sys->hwSubpictures = 0;    p_vout->p_sys->xvmc_palette = NULL;    XVMCLOCKDISPLAY( p_vout->p_sys->p_display );    if( !XvMCQueryExtension( p_vout->p_sys->p_display,                             &p_vout->p_sys->xvmc_eventbase,                             &p_vout->p_sys->xvmc_errbase ) )    {        XVMCUNLOCKDISPLAY( p_vout->p_sys->p_display );        xvmc_context_writer_unlock( &p_vout->p_sys->xvmc_lock );        return VLC_EGENERIC;    }    msg_Dbg( p_vout,"XvMC extension found" );    surfaceInfo = XvMCListSurfaceTypes(p_vout->p_sys->p_display, i_xvport, &numSurf);    if( !surfaceInfo )    {        XVMCUNLOCKDISPLAY( p_vout->p_sys->p_display );        xvmc_context_writer_unlock( &p_vout->p_sys->xvmc_lock );        return VLC_EGENERIC;    }    p_vout->p_sys->xvmc_cap =            (xvmc_capabilities_t *) malloc( numSurf *                                            sizeof(xvmc_capabilities_t) );    if( !p_vout->p_sys->xvmc_cap )    {        XVMCUNLOCKDISPLAY( p_vout->p_sys->p_display );        xvmc_context_writer_unlock( &p_vout->p_sys->xvmc_lock );        return VLC_EGENERIC;    }    p_vout->p_sys->xvmc_num_cap = numSurf;    curInfo = surfaceInfo;    curCap = p_vout->p_sys->xvmc_cap;    msg_Dbg( p_vout,"found %d XvMC surface types", numSurf );    for( i=0; i< numSurf; ++i )    {        curCap->mpeg_flags = 0;        curCap->accel_flags = 0;        if( curInfo->chroma_format == XVMC_CHROMA_FORMAT_420 )        {            curCap->mpeg_flags |= ((curInfo->mc_type & XVMC_MPEG_1) ?                                                VLC_XVMC_MPEG_1 : 0);            curCap->mpeg_flags |= ((curInfo->mc_type & XVMC_MPEG_2) ?                                                VLC_XVMC_MPEG_2 : 0);            curCap->mpeg_flags |= ((curInfo->mc_type & XVMC_MPEG_4) ?                                                VLC_XVMC_MPEG_4 : 0);            curCap->accel_flags |= ((curInfo->mc_type & XVMC_VLD) ?                                              VLC_XVMC_ACCEL_VLD : 0);            curCap->accel_flags |= ((curInfo->mc_type & XVMC_IDCT) ?                                             VLC_XVMC_ACCEL_IDCT : 0);            curCap->accel_flags |= ((curInfo->mc_type & (XVMC_VLD | XVMC_IDCT)) ?                                            0 : VLC_XVMC_ACCEL_MOCOMP);            curCap->max_width = curInfo->max_width;            curCap->max_height = curInfo->max_height;            curCap->sub_max_width = curInfo->subpicture_max_width;            curCap->sub_max_height = curInfo->subpicture_max_height;            curCap->flags = curInfo->flags;            msg_Dbg (p_vout, "surface type %d: Max size: %d %d.",                            i, curCap->max_width, curCap->max_height);            msg_Dbg (p_vout, "surface subtype %d: Max subpic size: %d %d.",                            i, curCap->sub_max_width, curCap->sub_max_height);            curCap->type_id = curInfo->surface_type_id;            formatValues = XvMCListSubpictureTypes( p_vout->p_sys->p_display,                                                    i_xvport,                                                    curCap->type_id,                                                    &numSub );            curCap->subPicType.id = 0;            if( formatValues )            {                msg_Dbg( p_vout, "surface type %d: found %d XvMC subpicture types",                                i, numSub);                for( j = 0; j<numSub; ++j )                {                    if( formatValues[j].id == FOURCC_IA44 )                    {                        curCap->subPicType = formatValues[j];                        msg_Dbg( p_vout,                                    "surface type %d: detected and using "                                    "IA44 subpicture type.", i );                        /* Prefer IA44 */                        break;                    }                    else if( formatValues[j].id == FOURCC_AI44 )                    {                        curCap->subPicType = formatValues[j];                        msg_Dbg( p_vout,                                 "surface type %d: detected AI44 "

⌨️ 快捷键说明

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