Changeset 09b646affc8be98f194ce09d59484423423b696c
- 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
| r5b55ee1 |
r09b646a |
|
| 2 | 2 | * fbosd.c : framebuffer osd plugin for vlc |
|---|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | | * Copyright (C) 2007, the VideoLAN team |
|---|
| | 4 | * Copyright (C) 2007-2008, the VideoLAN team |
|---|
| 5 | 5 | * $Id$ |
|---|
| 6 | 6 | * |
|---|
| … | … | |
| 51 | 51 | #include <vlc_strings.h> |
|---|
| 52 | 52 | |
|---|
| 53 | | // #define FBOSD_BLENDING 1 |
|---|
| | 53 | // #define FBOSD_BLENDING |
|---|
| 54 | 54 | |
|---|
| 55 | 55 | /***************************************************************************** |
|---|
| … | … | |
| 67 | 67 | |
|---|
| 68 | 68 | /* Load modules needed for rendering and blending */ |
|---|
| 69 | | #ifdef FBOSD_BLENDING |
|---|
| | 69 | #if defined(FBOSD_BLENDING) |
|---|
| 70 | 70 | static int OpenBlending ( intf_thread_t * ); |
|---|
| 71 | 71 | static void CloseBlending ( intf_thread_t * ); |
|---|
| … | … | |
| 92 | 92 | char * ); |
|---|
| 93 | 93 | |
|---|
| 94 | | #ifdef FBOSD_BLENDING |
|---|
| | 94 | #if defined(FBOSD_BLENDING) |
|---|
| 95 | 95 | static int BlendPicture( intf_thread_t *, video_format_t *, |
|---|
| 96 | 96 | video_format_t *, picture_t *, picture_t * ); |
|---|
| … | … | |
| 193 | 193 | FBOSD_LONGTEXT, true ); |
|---|
| 194 | 194 | |
|---|
| 195 | | #ifdef FBOSD_BLENDING |
|---|
| | 195 | #if defined(FBOSD_BLENDING) |
|---|
| 196 | 196 | add_integer_with_range( "fbosd-alpha", 255, 0, 255, NULL, ALPHA_TEXT, |
|---|
| 197 | 197 | ALPHA_LONGTEXT, true ); |
|---|
| … | … | |
| 276 | 276 | /* Image and Picture rendering */ |
|---|
| 277 | 277 | image_handler_t *p_image; |
|---|
| 278 | | #ifdef FBOSD_BLENDING |
|---|
| | 278 | #if defined(FBOSD_BLENDING) |
|---|
| 279 | 279 | filter_t *p_blend; /* alpha blending module */ |
|---|
| 280 | 280 | #endif |
|---|
| … | … | |
| 345 | 345 | } |
|---|
| 346 | 346 | |
|---|
| 347 | | #ifdef FBOSD_BLENDING |
|---|
| | 347 | #if defined(FBOSD_BLENDING) |
|---|
| 348 | 348 | p_sys->i_alpha = var_CreateGetIntegerCommand( p_intf, "fbosd-alpha" ); |
|---|
| 349 | 349 | var_AddCallback( p_intf, "fbosd-alpha", OverlayCallback, NULL ); |
|---|
| … | … | |
| 454 | 454 | Init( p_intf ); |
|---|
| 455 | 455 | |
|---|
| 456 | | #ifdef FBOSD_BLENDING |
|---|
| | 456 | #if defined(FBOSD_BLENDING) |
|---|
| 457 | 457 | /* Load the blending module */ |
|---|
| 458 | 458 | if( OpenBlending( p_intf ) ) |
|---|
| … | … | |
| 501 | 501 | p_sys->b_clear = false; |
|---|
| 502 | 502 | |
|---|
| 503 | | #ifdef FBOSD_BLENDING |
|---|
| | 503 | #if defined(FBOSD_BLENDING) |
|---|
| 504 | 504 | var_DelCallback( p_intf, "fbosd-alpha", OverlayCallback, NULL ); |
|---|
| 505 | 505 | var_Destroy( p_intf, "fbosd-alpha" ); |
|---|
| … | … | |
| 540 | 540 | } |
|---|
| 541 | 541 | |
|---|
| 542 | | #ifdef FBOSD_BLENDING |
|---|
| | 542 | #if defined(FBOSD_BLENDING) |
|---|
| 543 | 543 | if( p_sys->p_blend ) CloseBlending( p_intf ); |
|---|
| 544 | 544 | #endif |
|---|
| … | … | |
| 556 | 556 | } |
|---|
| 557 | 557 | |
|---|
| 558 | | #ifdef FBOSD_BLENDING |
|---|
| | 558 | #if defined(FBOSD_BLENDING) |
|---|
| 559 | 559 | static int OpenBlending( intf_thread_t *p_intf ) |
|---|
| 560 | 560 | { |
|---|
| … | … | |
| 771 | 771 | } |
|---|
| 772 | 772 | |
|---|
| 773 | | #ifdef FBOSD_BLENDING |
|---|
| | 773 | #if defined(FBOSD_BLENDING) |
|---|
| 774 | 774 | /***************************************************************************** |
|---|
| 775 | 775 | * BlendPicture: Blend two pictures together.. |
|---|
| … | … | |
| 823 | 823 | #endif |
|---|
| 824 | 824 | |
|---|
| | 825 | static 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 | |
|---|
| 825 | 870 | /***************************************************************************** |
|---|
| 826 | 871 | * RenderPicture: Render the picture into the p_dest buffer. |
|---|
| … | … | |
| 923 | 968 | p_region, p_region ); |
|---|
| 924 | 969 | |
|---|
| 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) |
|---|
| 930 | 971 | fmt_out = p_region->fmt; |
|---|
| 931 | 972 | fmt_out.i_bits_per_pixel = 32; |
|---|
| … | … | |
| 942 | 983 | } |
|---|
| 943 | 984 | 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 ); |
|---|
| 944 | 989 | #endif |
|---|
| 945 | 990 | if( p_region->picture.pf_release ) |
|---|
| … | … | |
| 981 | 1026 | } |
|---|
| 982 | 1027 | |
|---|
| 983 | | #ifndef FBOSD_BLENDING |
|---|
| | 1028 | #if ! defined(FBOSD_BLENDING) |
|---|
| 984 | 1029 | /***************************************************************************** |
|---|
| 985 | 1030 | * Convertmage: Convert image to another fourcc |
|---|
| … | … | |
| 1244 | 1289 | { |
|---|
| 1245 | 1290 | picture_t *p_text; |
|---|
| 1246 | | #ifdef FBOSD_BLENDING |
|---|
| | 1291 | #if defined(FBOSD_BLENDING) |
|---|
| 1247 | 1292 | video_format_t fmt_in; |
|---|
| 1248 | 1293 | memset( &fmt_in, 0, sizeof(video_format_t) ); |
|---|
| … | … | |
| 1281 | 1326 | render->i_y = p_sys->i_y; |
|---|
| 1282 | 1327 | render->i_pos = p_sys->i_pos; |
|---|
| 1283 | | #ifdef FBOSD_BLENDING |
|---|
| 1284 | 1328 | render->i_alpha = p_sys->i_alpha; |
|---|
| 1285 | | #endif |
|---|
| 1286 | 1329 | render->b_absolute = p_sys->b_absolute; |
|---|
| 1287 | 1330 | render->i_state = FBOSD_STATE_FREE; |
|---|
| … | … | |
| 1341 | 1384 | { |
|---|
| 1342 | 1385 | 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 |
|---|
| 1343 | 1390 | ret = write( p_sys->i_fd, p_sys->p_overlay->p[0].p_pixels, |
|---|
| 1344 | 1391 | p_sys->i_page_size ); |
|---|
| … | … | |
| 1461 | 1508 | p_sys->render[i].text_style.i_font_alpha = 255 - newval.i_int; |
|---|
| 1462 | 1509 | } |
|---|
| 1463 | | #ifdef FBOSD_BLENDING |
|---|
| | 1510 | #if defined(FBOSD_BLENDING) |
|---|
| 1464 | 1511 | else if( !strncmp( psz_cmd, "fbosd-alpha", 11 ) ) |
|---|
| 1465 | 1512 | { |
|---|