Changeset 09b646affc8be98f194ce09d59484423423b696c

Show
Ignore:
Timestamp:
05/06/08 10:57:47 (2 months ago)
Author:
Jean-Paul Saman <jean-paul.saman@m2x.nl>
git-committer:
Jean-Paul Saman <jean-paul.saman@m2x.nl> 1210064267 +0200
git-parent:

[4dd87e5b15e3c55a90642027f256479942731815]

git-author:
Jean-Paul Saman <jean-paul.saman@m2x.nl> 1210061091 +0200
Message:

Cleanup and add workaround for FPGA bug.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/gui/fbosd.c

    r5b55ee1 r09b646a  
    22 * fbosd.c : framebuffer osd plugin for vlc 
    33 ***************************************************************************** 
    4  * Copyright (C) 2007, the VideoLAN team 
     4 * Copyright (C) 2007-2008, the VideoLAN team 
    55 * $Id$ 
    66 * 
     
    5151#include <vlc_strings.h> 
    5252 
    53 // #define FBOSD_BLENDING 1 
     53// #define FBOSD_BLENDING 
    5454 
    5555/***************************************************************************** 
     
    6767 
    6868/* Load modules needed for rendering and blending */ 
    69 #ifdef FBOSD_BLENDING 
     69#if defined(FBOSD_BLENDING) 
    7070static int  OpenBlending     ( intf_thread_t * ); 
    7171static void CloseBlending    ( intf_thread_t * ); 
     
    9292                             char * ); 
    9393 
    94 #ifdef FBOSD_BLENDING 
     94#if defined(FBOSD_BLENDING) 
    9595static int BlendPicture( intf_thread_t *, video_format_t *, 
    9696                         video_format_t *, picture_t *, picture_t * ); 
     
    193193                FBOSD_LONGTEXT, true ); 
    194194 
    195 #ifdef FBOSD_BLENDING 
     195#if defined(FBOSD_BLENDING) 
    196196    add_integer_with_range( "fbosd-alpha", 255, 0, 255, NULL, ALPHA_TEXT, 
    197197                            ALPHA_LONGTEXT, true ); 
     
    276276    /* Image and Picture rendering */ 
    277277    image_handler_t *p_image; 
    278 #ifdef FBOSD_BLENDING 
     278#if defined(FBOSD_BLENDING) 
    279279    filter_t *p_blend;                              /* alpha blending module */ 
    280280#endif 
     
    345345    } 
    346346 
    347 #ifdef FBOSD_BLENDING 
     347#if defined(FBOSD_BLENDING) 
    348348    p_sys->i_alpha = var_CreateGetIntegerCommand( p_intf, "fbosd-alpha" ); 
    349349    var_AddCallback( p_intf, "fbosd-alpha", OverlayCallback, NULL ); 
     
    454454    Init( p_intf ); 
    455455 
    456 #ifdef FBOSD_BLENDING 
     456#if defined(FBOSD_BLENDING) 
    457457    /* Load the blending module */ 
    458458    if( OpenBlending( p_intf ) ) 
     
    501501    p_sys->b_clear = false; 
    502502 
    503 #ifdef FBOSD_BLENDING 
     503#if defined(FBOSD_BLENDING) 
    504504    var_DelCallback( p_intf, "fbosd-alpha", OverlayCallback, NULL ); 
    505505    var_Destroy( p_intf, "fbosd-alpha" ); 
     
    540540    } 
    541541 
    542 #ifdef FBOSD_BLENDING 
     542#if defined(FBOSD_BLENDING) 
    543543    if( p_sys->p_blend ) CloseBlending( p_intf ); 
    544544#endif 
     
    556556} 
    557557 
    558 #ifdef FBOSD_BLENDING 
     558#if defined(FBOSD_BLENDING) 
    559559static int OpenBlending( intf_thread_t *p_intf ) 
    560560{ 
     
    771771} 
    772772 
    773 #ifdef FBOSD_BLENDING 
     773#if defined(FBOSD_BLENDING) 
    774774/***************************************************************************** 
    775775 * BlendPicture: Blend two pictures together.. 
     
    823823#endif 
    824824 
     825static int InvertAlpha( intf_thread_t *p_intf, picture_t **p_pic, video_format_t fmt ) 
     826{ 
     827    uint8_t *p_begin = NULL, *p_end = NULL; 
     828    uint8_t i_skip = 0; 
     829 
     830    if( *p_pic && ((*p_pic)->i_planes != 1) ) 
     831    { 
     832        msg_Err( p_intf, 
     833                 "cannot invert alpha channel too many planes %d (only 1 supported)", 
     834                 (*p_pic)->i_planes ); 
     835        return VLC_EGENERIC; 
     836    } 
     837 
     838    switch( fmt.i_chroma ) 
     839    { 
     840        case VLC_FOURCC('R','V','2','4'): 
     841            p_begin = (uint8_t *)(*p_pic)->p[Y_PLANE].p_pixels; 
     842            p_end   = (uint8_t *)(*p_pic)->p[Y_PLANE].p_pixels + 
     843                      ( fmt.i_height * (*p_pic)->p[Y_PLANE].i_pitch ); 
     844            i_skip = 3; 
     845            break; 
     846        case VLC_FOURCC('R','V','3','2'): 
     847            p_begin = (uint8_t *)(*p_pic)->p[Y_PLANE].p_pixels; 
     848            p_end   = (uint8_t *)(*p_pic)->p[Y_PLANE].p_pixels + 
     849                      ( fmt.i_height * (*p_pic)->p[Y_PLANE].i_pitch ); 
     850            i_skip = 4; 
     851            break; 
     852        default: 
     853            msg_Err( p_intf, "cannot invert alpha channel chroma not supported %4.4s", 
     854                    (char *)&fmt.i_chroma ); 
     855            return VLC_EGENERIC; 
     856    } 
     857 
     858    for( ; p_begin < p_end; p_begin += i_skip ) 
     859    { 
     860        uint8_t i_opacity; 
     861 
     862        if( i_opacity != 0xFF ) 
     863            i_opacity = 255 - *p_begin; 
     864        *p_begin = i_opacity; 
     865    } 
     866    /* end of kludge */ 
     867    return VLC_SUCCESS; 
     868} 
     869 
    825870/***************************************************************************** 
    826871 * RenderPicture: Render the picture into the p_dest buffer. 
     
    923968                                           p_region, p_region ); 
    924969 
    925 #ifndef FBOSD_BLENDING 
    926             fmt_out.i_chroma = p_fmt->i_chroma; 
    927             p_dest = ConvertImage( p_intf, &p_region->picture, 
    928                                    &p_region->fmt, &fmt_out ); 
    929 #else 
     970#if defined(FBOSD_BLENDING) 
    930971            fmt_out = p_region->fmt; 
    931972            fmt_out.i_bits_per_pixel = 32; 
     
    942983            } 
    943984            vout_CopyPicture( VLC_OBJECT(p_intf), p_dest, &p_region->picture ); 
     985#else 
     986            fmt_out.i_chroma = p_fmt->i_chroma; 
     987            p_dest = ConvertImage( p_intf, &p_region->picture, 
     988                                   &p_region->fmt, &fmt_out ); 
    944989#endif 
    945990            if( p_region->picture.pf_release ) 
     
    9811026} 
    9821027 
    983 #ifndef FBOSD_BLENDING 
     1028#if ! defined(FBOSD_BLENDING) 
    9841029/***************************************************************************** 
    9851030 * Convertmage: Convert image to another fourcc 
     
    12441289    { 
    12451290        picture_t *p_text; 
    1246 #ifdef FBOSD_BLENDING 
     1291#if defined(FBOSD_BLENDING) 
    12471292        video_format_t fmt_in; 
    12481293        memset( &fmt_in, 0, sizeof(video_format_t) ); 
     
    12811326    render->i_y = p_sys->i_y; 
    12821327    render->i_pos = p_sys->i_pos; 
    1283 #ifdef FBOSD_BLENDING 
    12841328    render->i_alpha = p_sys->i_alpha; 
    1285 #endif 
    12861329    render->b_absolute = p_sys->b_absolute; 
    12871330    render->i_state = FBOSD_STATE_FREE; 
     
    13411384        { 
    13421385            int ret; 
     1386#if defined(FBOSD_BLENDING) 
     1387            /* Reverse alpha channel to work around FPGA bug */ 
     1388            InvertAlpha( p_intf, &p_sys->p_overlay, p_sys->fmt_out ); 
     1389#endif 
    13431390            ret = write( p_sys->i_fd, p_sys->p_overlay->p[0].p_pixels, 
    13441391                         p_sys->i_page_size ); 
     
    14611508            p_sys->render[i].text_style.i_font_alpha = 255 - newval.i_int; 
    14621509        } 
    1463 #ifdef FBOSD_BLENDING 
     1510#if defined(FBOSD_BLENDING) 
    14641511        else if( !strncmp( psz_cmd, "fbosd-alpha", 11 ) ) 
    14651512        {