| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
#ifdef HAVE_CONFIG_H |
|---|
| 29 |
# include "config.h" |
|---|
| 30 |
#endif |
|---|
| 31 |
|
|---|
| 32 |
#include <vlc_common.h> |
|---|
| 33 |
#include <vlc_plugin.h> |
|---|
| 34 |
#include <vlc_vout.h> |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
static int Create ( vlc_object_t * ); |
|---|
| 40 |
static void Destroy ( vlc_object_t * ); |
|---|
| 41 |
|
|---|
| 42 |
static int Init ( vout_thread_t * ); |
|---|
| 43 |
static void End ( vout_thread_t * ); |
|---|
| 44 |
static int LockPicture ( vout_thread_t *, picture_t * ); |
|---|
| 45 |
static int UnlockPicture ( vout_thread_t *, picture_t * ); |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
#define T_WIDTH N_( "Width" ) |
|---|
| 51 |
#define LT_WIDTH N_( "Video memory buffer width." ) |
|---|
| 52 |
|
|---|
| 53 |
#define T_HEIGHT N_( "Height" ) |
|---|
| 54 |
#define LT_HEIGHT N_( "Video memory buffer height." ) |
|---|
| 55 |
|
|---|
| 56 |
#define T_PITCH N_( "Pitch" ) |
|---|
| 57 |
#define LT_PITCH N_( "Video memory buffer pitch in bytes." ) |
|---|
| 58 |
|
|---|
| 59 |
#define T_CHROMA N_( "Chroma" ) |
|---|
| 60 |
#define LT_CHROMA N_( "Output chroma for the memory image as a 4-character " \ |
|---|
| 61 |
"string, eg. \"RV32\"." ) |
|---|
| 62 |
|
|---|
| 63 |
#define T_LOCK N_( "Lock function" ) |
|---|
| 64 |
#define LT_LOCK N_( "Address of the locking callback function. This " \ |
|---|
| 65 |
"function must return a valid memory address for use " \ |
|---|
| 66 |
"by the video renderer." ) |
|---|
| 67 |
|
|---|
| 68 |
#define T_UNLOCK N_( "Unlock function" ) |
|---|
| 69 |
#define LT_UNLOCK N_( "Address of the unlocking callback function" ) |
|---|
| 70 |
|
|---|
| 71 |
#define T_DATA N_( "Callback data" ) |
|---|
| 72 |
#define LT_DATA N_( "Data for the locking and unlocking functions" ) |
|---|
| 73 |
|
|---|
| 74 |
vlc_module_begin( ); |
|---|
| 75 |
set_description( N_( "Video memory module" ) ); |
|---|
| 76 |
set_shortname( N_("Video memory") ); |
|---|
| 77 |
|
|---|
| 78 |
set_category( CAT_VIDEO ); |
|---|
| 79 |
set_subcategory( SUBCAT_VIDEO_VOUT ); |
|---|
| 80 |
set_capability( "video output", 0 ); |
|---|
| 81 |
|
|---|
| 82 |
add_integer( "vmem-width", 320, NULL, T_WIDTH, LT_WIDTH, false ); |
|---|
| 83 |
add_integer( "vmem-height", 200, NULL, T_HEIGHT, LT_HEIGHT, false ); |
|---|
| 84 |
add_integer( "vmem-pitch", 640, NULL, T_PITCH, LT_PITCH, false ); |
|---|
| 85 |
add_string( "vmem-chroma", "RV16", NULL, T_CHROMA, LT_CHROMA, true ); |
|---|
| 86 |
add_string( "vmem-lock", "0", NULL, T_LOCK, LT_LOCK, true ); |
|---|
| 87 |
add_string( "vmem-unlock", "0", NULL, T_UNLOCK, LT_UNLOCK, true ); |
|---|
| 88 |
add_string( "vmem-data", "0", NULL, T_DATA, LT_DATA, true ); |
|---|
| 89 |
|
|---|
| 90 |
set_callbacks( Create, Destroy ); |
|---|
| 91 |
vlc_module_end(); |
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
struct vout_sys_t |
|---|
| 97 |
{ |
|---|
| 98 |
int i_width, i_height, i_pitch; |
|---|
| 99 |
|
|---|
| 100 |
void * (*pf_lock) (void *); |
|---|
| 101 |
void (*pf_unlock) (void *); |
|---|
| 102 |
void *p_data; |
|---|
| 103 |
}; |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
static int Create( vlc_object_t *p_this ) |
|---|
| 111 |
{ |
|---|
| 112 |
vout_thread_t *p_vout = ( vout_thread_t * )p_this; |
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
p_vout->p_sys = malloc( sizeof( vout_sys_t ) ); |
|---|
| 116 |
if( ! p_vout->p_sys ) |
|---|
| 117 |
return VLC_ENOMEM; |
|---|
| 118 |
|
|---|
| 119 |
p_vout->pf_init = Init; |
|---|
| 120 |
p_vout->pf_end = End; |
|---|
| 121 |
p_vout->pf_manage = NULL; |
|---|
| 122 |
p_vout->pf_render = NULL; |
|---|
| 123 |
p_vout->pf_display = NULL; |
|---|
| 124 |
|
|---|
| 125 |
return VLC_SUCCESS; |
|---|
| 126 |
} |
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
static int Init( vout_thread_t *p_vout ) |
|---|
| 132 |
{ |
|---|
| 133 |
int i_index; |
|---|
| 134 |
picture_t *p_pic; |
|---|
| 135 |
char *psz_chroma, *psz_tmp; |
|---|
| 136 |
int i_width, i_height, i_pitch, i_chroma; |
|---|
| 137 |
|
|---|
| 138 |
i_width = config_GetInt( p_vout, "vmem-width" ); |
|---|
| 139 |
i_height = config_GetInt( p_vout, "vmem-height" ); |
|---|
| 140 |
i_pitch = config_GetInt( p_vout, "vmem-pitch" ); |
|---|
| 141 |
|
|---|
| 142 |
psz_chroma = config_GetPsz( p_vout, "vmem-chroma" ); |
|---|
| 143 |
if( psz_chroma ) |
|---|
| 144 |
{ |
|---|
| 145 |
if( strlen( psz_chroma ) < 4 ) |
|---|
| 146 |
{ |
|---|
| 147 |
msg_Err( p_vout, "vmem-chroma should be 4 characters long" ); |
|---|
| 148 |
free( psz_chroma ); |
|---|
| 149 |
return VLC_EGENERIC; |
|---|
| 150 |
} |
|---|
| 151 |
i_chroma = VLC_FOURCC( psz_chroma[0], psz_chroma[1], |
|---|
| 152 |
psz_chroma[2], psz_chroma[3] ); |
|---|
| 153 |
free( psz_chroma ); |
|---|
| 154 |
} |
|---|
| 155 |
else |
|---|
| 156 |
{ |
|---|
| 157 |
msg_Err( p_vout, "Cannot find chroma information." ); |
|---|
| 158 |
return VLC_EGENERIC; |
|---|
| 159 |
} |
|---|
| 160 |
|
|---|
| 161 |
psz_tmp = config_GetPsz( p_vout, "vmem-lock" ); |
|---|
| 162 |
p_vout->p_sys->pf_lock = (void * (*) (void *))(intptr_t)atoll( psz_tmp ); |
|---|
| 163 |
free( psz_tmp ); |
|---|
| 164 |
|
|---|
| 165 |
psz_tmp = config_GetPsz( p_vout, "vmem-unlock" ); |
|---|
| 166 |
p_vout->p_sys->pf_unlock = (void (*) (void *))(intptr_t)atoll( psz_tmp ); |
|---|
| 167 |
free( psz_tmp ); |
|---|
| 168 |
|
|---|
| 169 |
psz_tmp = config_GetPsz( p_vout, "vmem-data" ); |
|---|
| 170 |
p_vout->p_sys->p_data = (void *)(intptr_t)atoll( psz_tmp ); |
|---|
| 171 |
free( psz_tmp ); |
|---|
| 172 |
|
|---|
| 173 |
if( !p_vout->p_sys->pf_lock || !p_vout->p_sys->pf_unlock ) |
|---|
| 174 |
{ |
|---|
| 175 |
msg_Err( p_vout, "Invalid lock or unlock callbacks" ); |
|---|
| 176 |
return VLC_EGENERIC; |
|---|
| 177 |
} |
|---|
| 178 |
|
|---|
| 179 |
I_OUTPUTPICTURES = 0; |
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
p_vout->output.i_chroma = i_chroma; |
|---|
| 183 |
p_vout->output.pf_setpalette = NULL; |
|---|
| 184 |
p_vout->output.i_width = i_width; |
|---|
| 185 |
p_vout->output.i_height = i_height; |
|---|
| 186 |
p_vout->output.i_aspect = p_vout->output.i_width |
|---|
| 187 |
* VOUT_ASPECT_FACTOR / p_vout->output.i_height; |
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
switch( i_chroma ) |
|---|
| 191 |
{ |
|---|
| 192 |
case VLC_FOURCC( 'R','V','1','5' ): |
|---|
| 193 |
p_vout->output.i_rmask = 0x001f; |
|---|
| 194 |
p_vout->output.i_gmask = 0x03e0; |
|---|
| 195 |
p_vout->output.i_bmask = 0x7c00; |
|---|
| 196 |
break; |
|---|
| 197 |
|
|---|
| 198 |
case VLC_FOURCC( 'R','V','1','6' ): |
|---|
| 199 |
p_vout->output.i_rmask = 0x001f; |
|---|
| 200 |
p_vout->output.i_gmask = 0x07e0; |
|---|
| 201 |
p_vout->output.i_bmask = 0xf800; |
|---|
| 202 |
break; |
|---|
| 203 |
|
|---|
| 204 |
case VLC_FOURCC( 'R','V','2','4' ): |
|---|
| 205 |
p_vout->output.i_rmask = 0xff0000; |
|---|
| 206 |
p_vout->output.i_gmask = 0x00ff00; |
|---|
| 207 |
p_vout->output.i_bmask = 0x0000ff; |
|---|
| 208 |
break; |
|---|
| 209 |
|
|---|
| 210 |
case VLC_FOURCC( 'R','V','3','2' ): |
|---|
| 211 |
p_vout->output.i_rmask = 0xff0000; |
|---|
| 212 |
p_vout->output.i_gmask = 0x00ff00; |
|---|
| 213 |
p_vout->output.i_bmask = 0x0000ff; |
|---|
| 214 |
break; |
|---|
| 215 |
} |
|---|
| 216 |
|
|---|
| 217 |
|
|---|
| 218 |
p_pic = NULL; |
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 |
for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ ) |
|---|
| 222 |
{ |
|---|
| 223 |
if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE ) |
|---|
| 224 |
{ |
|---|
| 225 |
p_pic = p_vout->p_picture + i_index; |
|---|
| 226 |
break; |
|---|
| 227 |
} |
|---|
| 228 |
} |
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 |
if( p_pic == NULL ) |
|---|
| 232 |
{ |
|---|
| 233 |
return VLC_SUCCESS; |
|---|
| 234 |
} |
|---|
| 235 |
|
|---|
| 236 |
vout_InitPicture( VLC_OBJECT(p_vout), p_pic, p_vout->output.i_chroma, |
|---|
| 237 |
p_vout->output.i_width, p_vout->output.i_height, |
|---|
| 238 |
p_vout->output.i_aspect ); |
|---|
| 239 |
|
|---|
| 240 |
p_pic->p->i_pitch = i_pitch; |
|---|
| 241 |
|
|---|
| 242 |
p_pic->pf_lock = LockPicture; |
|---|
| 243 |
p_pic->pf_unlock = UnlockPicture; |
|---|
| 244 |
|
|---|
| 245 |
p_pic->i_status = DESTROYED_PICTURE; |
|---|
| 246 |
p_pic->i_type = DIRECT_PICTURE; |
|---|
| 247 |
|
|---|
| 248 |
PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic; |
|---|
| 249 |
|
|---|
| 250 |
I_OUTPUTPICTURES++; |
|---|
| 251 |
|
|---|
| 252 |
return VLC_SUCCESS; |
|---|
| 253 |
} |
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 |
|
|---|
| 257 |
|
|---|
| 258 |
static void End( vout_thread_t *p_vout ) |
|---|
| 259 |
{ |
|---|
| 260 |
(void)p_vout; |
|---|
| 261 |
} |
|---|
| 262 |
|
|---|
| 263 |
|
|---|
| 264 |
|
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 268 |
static void Destroy( vlc_object_t *p_this ) |
|---|
| 269 |
{ |
|---|
| 270 |
vout_thread_t *p_vout = ( vout_thread_t * )p_this; |
|---|
| 271 |
|
|---|
| 272 |
|
|---|
| 273 |
free( p_vout->p_sys ); |
|---|
| 274 |
} |
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 |
|
|---|
| 280 |
|
|---|
| 281 |
static int LockPicture( vout_thread_t *p_vout, picture_t *p_pic ) |
|---|
| 282 |
{ |
|---|
| 283 |
p_pic->p->p_pixels = p_vout->p_sys->pf_lock( p_vout->p_sys->p_data ); |
|---|
| 284 |
|
|---|
| 285 |
return VLC_SUCCESS; |
|---|
| 286 |
} |
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 |
|
|---|
| 290 |
|
|---|
| 291 |
|
|---|
| 292 |
|
|---|
| 293 |
static int UnlockPicture( vout_thread_t *p_vout, picture_t *p_pic ) |
|---|
| 294 |
{ |
|---|
| 295 |
p_vout->p_sys->pf_unlock( p_vout->p_sys->p_data ); |
|---|
| 296 |
|
|---|
| 297 |
(void)p_pic; |
|---|
| 298 |
|
|---|
| 299 |
return VLC_SUCCESS; |
|---|
| 300 |
} |
|---|
| 301 |
|
|---|