| 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 |
|
|---|
| 35 |
#include "Nsf_Emu.h" |
|---|
| 36 |
#include "Gbs_Emu.h" |
|---|
| 37 |
#include "Vgm_Emu.h" |
|---|
| 38 |
#include "Spc_Emu.h" |
|---|
| 39 |
#include "Gym_Emu.h" |
|---|
| 40 |
|
|---|
| 41 |
#ifdef HAVE_ZLIB_H |
|---|
| 42 |
#include "zlib.h" |
|---|
| 43 |
#endif |
|---|
| 44 |
|
|---|
| 45 |
using namespace std; |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
static int Open ( vlc_object_t * ); |
|---|
| 51 |
static void Close ( vlc_object_t * ); |
|---|
| 52 |
|
|---|
| 53 |
vlc_module_begin(); |
|---|
| 54 |
set_shortname( "GME"); |
|---|
| 55 |
set_description( N_("GME demuxer (Game_Music_Emu)" ) ); |
|---|
| 56 |
set_capability( "demux", 10 ); |
|---|
| 57 |
set_category( CAT_INPUT ); |
|---|
| 58 |
set_subcategory( SUBCAT_INPUT_DEMUX ); |
|---|
| 59 |
set_callbacks( Open, Close ); |
|---|
| 60 |
add_shortcut( "gme" ); |
|---|
| 61 |
vlc_module_end(); |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
enum EmuType_e |
|---|
| 68 |
{ |
|---|
| 69 |
EMU_NSF = 0, |
|---|
| 70 |
EMU_GBS = 1, |
|---|
| 71 |
EMU_VGM = 2, |
|---|
| 72 |
EMU_SPC = 3, |
|---|
| 73 |
EMU_GYM = 4 |
|---|
| 74 |
}; |
|---|
| 75 |
|
|---|
| 76 |
static const char* type_str[] = |
|---|
| 77 |
{ |
|---|
| 78 |
"NSF (Nes)", "GBS (Gameboy)", "VGM (Master System/Game Gear/Genesis)", "SPC (Super Nes)", "GYM (Genesis)" |
|---|
| 79 |
}; |
|---|
| 80 |
|
|---|
| 81 |
struct demux_sys_t |
|---|
| 82 |
{ |
|---|
| 83 |
es_format_t fmt; |
|---|
| 84 |
es_out_id_t *es; |
|---|
| 85 |
|
|---|
| 86 |
int64_t i_time; |
|---|
| 87 |
int64_t i_length; |
|---|
| 88 |
|
|---|
| 89 |
int i_data; |
|---|
| 90 |
uint8_t *p_data; |
|---|
| 91 |
int i_type; |
|---|
| 92 |
int i_tracks; |
|---|
| 93 |
Music_Emu *p_musicemu; |
|---|
| 94 |
Emu_Mem_Reader *p_reader; |
|---|
| 95 |
vlc_meta_t *p_meta; |
|---|
| 96 |
}; |
|---|
| 97 |
|
|---|
| 98 |
static int Demux ( demux_t *p_demux ); |
|---|
| 99 |
static int Control( demux_t *p_demux, int i_query, va_list args ); |
|---|
| 100 |
|
|---|
| 101 |
#ifdef HAVE_ZLIB_H |
|---|
| 102 |
static void inflate_gzbuf(uint8_t * p_buffer, size_t i_size, uint8_t ** pp_obuffer, size_t * pi_osize); |
|---|
| 103 |
#endif |
|---|
| 104 |
|
|---|
| 105 |
static const char* gme_ext[] = |
|---|
| 106 |
{ |
|---|
| 107 |
"nsf", "nsfe", "gbs", "vgm", "vgz", "spc", "gym", NULL |
|---|
| 108 |
}; |
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
static int Open( vlc_object_t *p_this ) |
|---|
| 114 |
{ |
|---|
| 115 |
demux_t *p_demux = (demux_t*)p_this; |
|---|
| 116 |
demux_sys_t *p_sys; |
|---|
| 117 |
char *ext; |
|---|
| 118 |
int i; |
|---|
| 119 |
vlc_value_t val; |
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
if( !p_demux->b_force ) |
|---|
| 123 |
{ |
|---|
| 124 |
if( ( ext = strrchr( p_demux->psz_path, '.' ) ) == NULL || |
|---|
| 125 |
stream_Size( p_demux->s ) == 0 ) return VLC_EGENERIC; |
|---|
| 126 |
|
|---|
| 127 |
ext++; |
|---|
| 128 |
for( i = 0; gme_ext[i] != NULL; i++ ) |
|---|
| 129 |
{ |
|---|
| 130 |
if( !strcasecmp( ext, gme_ext[i] ) ) |
|---|
| 131 |
{ |
|---|
| 132 |
break; |
|---|
| 133 |
} |
|---|
| 134 |
} |
|---|
| 135 |
if( gme_ext[i] == NULL ) return VLC_EGENERIC; |
|---|
| 136 |
msg_Dbg( p_demux, "running GME demuxer (ext=%s)", gme_ext[i] ); |
|---|
| 137 |
} |
|---|
| 138 |
|
|---|
| 139 |
#ifndef HAVE_ZLIB_H |
|---|
| 140 |
if (i == 4) |
|---|
| 141 |
{ |
|---|
| 142 |
msg_Dbg( p_demux, "zlib unvailable, unable to read gzipped vgz file" ); |
|---|
| 143 |
return VLC_EGENERIC; |
|---|
| 144 |
} |
|---|
| 145 |
#endif |
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
p_demux->pf_demux = Demux; |
|---|
| 149 |
p_demux->pf_control = Control; |
|---|
| 150 |
p_demux->p_sys = p_sys = (demux_sys_t *)malloc( sizeof( demux_sys_t ) ); |
|---|
| 151 |
|
|---|
| 152 |
msg_Dbg( p_demux, "loading complete file (could be long)" ); |
|---|
| 153 |
p_sys->i_data = stream_Size( p_demux->s ); |
|---|
| 154 |
p_sys->p_data = (uint8_t *)malloc( p_sys->i_data ); |
|---|
| 155 |
p_sys->i_data = stream_Read( p_demux->s, p_sys->p_data, p_sys->i_data ); |
|---|
| 156 |
if( p_sys->i_data <= 0 ) |
|---|
| 157 |
{ |
|---|
| 158 |
msg_Err( p_demux, "failed to read the complete file" ); |
|---|
| 159 |
free( p_sys->p_data ); |
|---|
| 160 |
free( p_sys ); |
|---|
| 161 |
return VLC_EGENERIC; |
|---|
| 162 |
} |
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
#ifdef HAVE_ZLIB_H |
|---|
| 167 |
if (i == 4) |
|---|
| 168 |
{ |
|---|
| 169 |
uint8_t * p_outbuffer; |
|---|
| 170 |
size_t i_outsize; |
|---|
| 171 |
|
|---|
| 172 |
inflate_gzbuf( p_sys->p_data, p_sys->i_data, &p_outbuffer, &i_outsize ); |
|---|
| 173 |
|
|---|
| 174 |
if (p_outbuffer == NULL) |
|---|
| 175 |
{ |
|---|
| 176 |
msg_Err( p_demux, "failed to understand the file : unable to inflate vgz file" ); |
|---|
| 177 |
|
|---|
| 178 |
stream_Seek( p_demux->s, 0 ); |
|---|
| 179 |
free( p_sys->p_data ); |
|---|
| 180 |
free( p_sys ); |
|---|
| 181 |
return VLC_EGENERIC; |
|---|
| 182 |
} |
|---|
| 183 |
|
|---|
| 184 |
free(p_sys->p_data); |
|---|
| 185 |
|
|---|
| 186 |
p_sys->p_data = p_outbuffer; |
|---|
| 187 |
p_sys->i_data = i_outsize; |
|---|
| 188 |
} |
|---|
| 189 |
#endif |
|---|
| 190 |
|
|---|
| 191 |
p_sys->p_reader = new Emu_Mem_Reader( p_sys->p_data, p_sys->i_data ); |
|---|
| 192 |
|
|---|
| 193 |
switch(i) |
|---|
| 194 |
{ |
|---|
| 195 |
case 0: |
|---|
| 196 |
case 1: |
|---|
| 197 |
p_sys->i_type = EMU_NSF; |
|---|
| 198 |
break; |
|---|
| 199 |
case 2: |
|---|
| 200 |
p_sys->i_type = EMU_GBS; |
|---|
| 201 |
break; |
|---|
| 202 |
case 3: |
|---|
| 203 |
case 4: |
|---|
| 204 |
p_sys->i_type = EMU_VGM; |
|---|
| 205 |
break; |
|---|
| 206 |
case 5: |
|---|
| 207 |
p_sys->i_type = EMU_SPC; |
|---|
| 208 |
break; |
|---|
| 209 |
case 6: |
|---|
| 210 |
p_sys->i_type = EMU_GYM; |
|---|
| 211 |
break; |
|---|
| 212 |
} |
|---|
| 213 |
|
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 |
#define INIT_EMU(type) \ |
|---|
| 217 |
type##_Emu::header_t header; \ |
|---|
| 218 |
type##_Emu * p_emu = new type##_Emu; \ |
|---|
| 219 |
p_emu->init( 44100 ); \ |
|---|
| 220 |
p_sys->p_musicemu = p_emu; \ |
|---|
| 221 |
p_sys->p_reader->read( &header, sizeof(header) ); \ |
|---|
| 222 |
p_error = p_emu->load( header, *(p_sys->p_reader) ); |
|---|
| 223 |
|
|---|
| 224 |
p_sys->p_meta = vlc_meta_New(); |
|---|
| 225 |
|
|---|
| 226 |
char psz_temp[512]; |
|---|
| 227 |
|
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 |
const char * p_error; |
|---|
| 232 |
|
|---|
| 233 |
switch(p_sys->i_type) |
|---|
| 234 |
{ |
|---|
| 235 |
case EMU_NSF: |
|---|
| 236 |
{ |
|---|
| 237 |
INIT_EMU(Nsf) |
|---|
| 238 |
if (p_error == NULL) |
|---|
| 239 |
{ |
|---|
| 240 |
vlc_meta_SetTitle( p_meta, header.game ); |
|---|
| 241 |
vlc_meta_SetArtist( p_meta, header.author ); |
|---|
| 242 |
vlc_meta_SetCopyright( p_meta, header.copyright ); |
|---|
| 243 |
p_sys->i_tracks = p_emu->track_count(); |
|---|
| 244 |
} |
|---|
| 245 |
} |
|---|
| 246 |
break; |
|---|
| 247 |
case EMU_GBS: |
|---|
| 248 |
{ |
|---|
| 249 |
INIT_EMU(Gbs) |
|---|
| 250 |
if (p_error == NULL) |
|---|
| 251 |
{ |
|---|
| 252 |
vlc_meta_SetTitle( p_meta, header.game ); |
|---|
| 253 |
vlc_meta_SetArtist( p_meta, header.author ); |
|---|
| 254 |
vlc_meta_SetCopyright( p_meta, header.copyright ); |
|---|
| 255 |
p_sys->i_tracks = p_emu->track_count(); |
|---|
| 256 |
} |
|---|
| 257 |
} |
|---|
| 258 |
break; |
|---|
| 259 |
case EMU_VGM: |
|---|
| 260 |
{ |
|---|
| 261 |
INIT_EMU(Vgm) |
|---|
| 262 |
if (p_error == NULL) |
|---|
| 263 |
{ |
|---|
| 264 |
p_sys->i_tracks = p_emu->track_count(); |
|---|
| 265 |
} |
|---|
| 266 |
} |
|---|
| 267 |
break; |
|---|
| 268 |
case EMU_SPC: |
|---|
| 269 |
{ |
|---|
| 270 |
INIT_EMU(Spc) |
|---|
| 271 |
if (p_error == NULL) |
|---|
| 272 |
{ |
|---|
| 273 |
snprintf( psz_temp, 511, "%s (%s)", header.song, header.game ); |
|---|
| 274 |
vlc_meta_SetTitle( p_meta, psz_temp ); |
|---|
| 275 |
vlc_meta_SetArtist( p_meta, header.author ); |
|---|
| 276 |
p_sys->i_tracks = p_emu->track_count(); |
|---|
| 277 |
} |
|---|
| 278 |
} |
|---|
| 279 |
break; |
|---|
| 280 |
case EMU_GYM: |
|---|
| 281 |
{ |
|---|
| 282 |
INIT_EMU(Gym) |
|---|
| 283 |
if (p_error == NULL) |
|---|
| 284 |
{ |
|---|
| 285 |
snprintf( psz_temp, 511, "%s (%s)", header.song, header.game ); |
|---|
| 286 |
vlc_meta_SetTitle( p_meta, psz_temp ); |
|---|
| 287 |
vlc_meta_SetCopyright( p_meta, header.copyright ); |
|---|
| 288 |
p_sys->i_tracks = p_emu->track_count(); |
|---|
| 289 |
} |
|---|
| 290 |
} |
|---|
| 291 |
break; |
|---|
| 292 |
} |
|---|
| 293 |
|
|---|
| 294 |
if( p_error != NULL ) |
|---|
| 295 |
{ |
|---|
| 296 |
msg_Err( p_demux, "failed to understand the file : %s", p_error ); |
|---|
| 297 |
|
|---|
| 298 |
stream_Seek( p_demux->s, 0 ); |
|---|
| 299 |
free( p_sys->p_data ); |
|---|
| 300 |
free( p_sys ); |
|---|
| 301 |
return VLC_EGENERIC; |
|---|
| 302 |
} |
|---|
| 303 |
|
|---|
| 304 |
|
|---|
| 305 |
p_sys->i_time = 1; |
|---|
| 306 |
p_sys->i_length = 314 * (int64_t)1000; |
|---|
| 307 |
|
|---|
| 308 |
msg_Dbg( p_demux, "GME loaded type=%s title=%s tracks=%i", type_str[p_sys->i_type], |
|---|
| 309 |
vlc_meta_GetValue( p_sys->p_meta, VLC_META_TITLE ), p_sys->i_tracks ); |
|---|
| 310 |
|
|---|
| 311 |
p_sys->p_musicemu->start_track( 0 ); |
|---|
| 312 |
|
|---|
| 313 |
#ifdef WORDS_BIGENDIAN |
|---|
| 314 |
es_format_Init( &p_sys->fmt, AUDIO_ES, VLC_FOURCC( 't', 'w', 'o', 's' ) ); |
|---|
| 315 |
#else |
|---|
| 316 |
es_format_Init( &p_sys->fmt, AUDIO_ES, VLC_FOURCC( 'a', 'r', 'a', 'w' ) ); |
|---|
| 317 |
#endif |
|---|
| 318 |
p_sys->fmt.audio.i_rate = 44100; |
|---|
| 319 |
p_sys->fmt.audio.i_channels = 2; |
|---|
| 320 |
p_sys->fmt.audio.i_bitspersample = 16; |
|---|
| 321 |
p_sys->es = es_out_Add( p_demux->out, &p_sys->fmt ); |
|---|
| 322 |
|
|---|
| 323 |
return VLC_SUCCESS; |
|---|
| 324 |
} |
|---|
| 325 |
|
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 |
|
|---|
| 329 |
static void Close( vlc_object_t *p_this ) |
|---|
| 330 |
{ |
|---|
| 331 |
demux_t *p_demux = (demux_t*)p_this; |
|---|
| 332 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 333 |
|
|---|
| 334 |
delete p_sys->p_musicemu; |
|---|
| 335 |
delete p_sys->p_reader; |
|---|
| 336 |
|
|---|
| 337 |
free( p_sys->p_data ); |
|---|
| 338 |
free( p_sys ); |
|---|
| 339 |
} |
|---|
| 340 |
|
|---|
| 341 |
|
|---|
| 342 |
|
|---|
| 343 |
|
|---|
| 344 |
|
|---|
| 345 |
static int Demux( demux_t *p_demux ) |
|---|
| 346 |
{ |
|---|
| 347 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 348 |
block_t *p_frame; |
|---|
| 349 |
int i_bk = ( p_sys->fmt.audio.i_bitspersample / 8 ) * |
|---|
| 350 |
p_sys->fmt.audio.i_channels; |
|---|
| 351 |
const unsigned int i_buf = p_sys->fmt.audio.i_rate / 10 * i_bk; |
|---|
| 352 |
const unsigned int i_emubuf = i_buf / sizeof(Music_Emu::sample_t); |
|---|
| 353 |
const char * p_error; |
|---|
| 354 |
Music_Emu::sample_t p_emubuf [i_emubuf]; |
|---|
| 355 |
|
|---|
| 356 |
p_frame = block_New( p_demux, i_buf ); |
|---|
| 357 |
|
|---|
| 358 |
p_sys->p_musicemu->play( i_emubuf, p_emubuf ); |
|---|
| 359 |
|
|---|
| 360 |
|
|---|
| 361 |
|
|---|
| 362 |
|
|---|
| 363 |
|
|---|
| 364 |
|
|---|
| 365 |
|
|---|
| 366 |
|
|---|
| 367 |
|
|---|
| 368 |
|
|---|
| 369 |
|
|---|
| 370 |
for (int i = 0; i<i_buf; i++) p_frame->p_buffer[i] = ((uint8_t *)p_emubuf)[i]; |
|---|
| 371 |
|
|---|
| 372 |
|
|---|
| 373 |
es_out_Control( p_demux->out, ES_OUT_SET_PCR, (int64_t)p_sys->i_time ); |
|---|
| 374 |
|
|---|
| 375 |
|
|---|
| 376 |
p_sys->i_time += (int64_t)1000000 * p_frame->i_buffer / i_bk / p_sys->fmt.audio.i_rate; |
|---|
| 377 |
|
|---|
| 378 |
|
|---|
| 379 |
p_frame->i_dts = p_frame->i_pts = p_sys->i_time; |
|---|
| 380 |
es_out_Send( p_demux->out, p_sys->es, p_frame ); |
|---|
| 381 |
|
|---|
| 382 |
return 1; |
|---|
| 383 |
} |
|---|
| 384 |
|
|---|
| 385 |
|
|---|
| 386 |
|
|---|
| 387 |
|
|---|
| 388 |
static int Control( demux_t *p_demux, int i_query, va_list args ) |
|---|
| 389 |
{ |
|---|
| 390 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 391 |
double f, *pf; |
|---|
| 392 |
int64_t i64, *pi64; |
|---|
| 393 |
int i_idx; |
|---|
| 394 |
vlc_meta_t **pp_meta; |
|---|
| 395 |
|
|---|
| 396 |
switch( i_query ) |
|---|
| 397 |
{ |
|---|
| 398 |
case DEMUX_GET_META: |
|---|
| 399 |
pp_meta = (vlc_meta_t **)va_arg( args, vlc_meta_t** ); |
|---|
| 400 |
if( p_sys->p_meta ) |
|---|
| 401 |
*pp_meta = vlc_meta_Duplicate( p_sys->p_meta ); |
|---|
| 402 |
else |
|---|
| 403 |
*pp_meta = NULL; |
|---|
| 404 |
return VLC_SUCCESS; |
|---|
| 405 |
|
|---|
| 406 |
case DEMUX_GET_POSITION: |
|---|
| 407 |
pf = (double*) va_arg( args, double* ); |
|---|
| 408 |
if( p_sys->i_length > 0 ) |
|---|
| 409 |
{ |
|---|
| 410 |
*pf = (double)p_sys->i_time / (double)p_sys->i_length; |
|---|
| 411 |
return VLC_SUCCESS; |
|---|
| 412 |
} |
|---|
| 413 |
return VLC_EGENERIC; |
|---|
| 414 |
|
|---|
| 415 |
|
|---|
| 416 |
|
|---|
| 417 |
|
|---|
| 418 |
|
|---|
| 419 |
|
|---|
| 420 |
|
|---|
| 421 |
|
|---|
| 422 |
|
|---|
| 423 |
|
|---|
| 424 |
|
|---|
| 425 |
|
|---|
| 426 |
|
|---|
| 427 |
|
|---|
| 428 |
|
|---|
| 429 |
case DEMUX_GET_TIME: |
|---|
| 430 |
pi64 = (int64_t*)va_arg( args, int64_t * ); |
|---|
| 431 |
*pi64 = p_sys->i_time; |
|---|
| 432 |
return VLC_SUCCESS; |
|---|
| 433 |
|
|---|
| 434 |
case DEMUX_GET_LENGTH: |
|---|
| 435 |
pi64 = (int64_t*)va_arg( args, int64_t * ); |
|---|
| 436 |
*pi64 = p_sys->i_length; |
|---|
| 437 |
return VLC_SUCCESS; |
|---|
| 438 |
|
|---|
| 439 |
|
|---|
| 440 |
|
|---|
| 441 |
|
|---|
| 442 |
|
|---|
| 443 |
|
|---|
| 444 |
|
|---|
| 445 |
|
|---|
| 446 |
|
|---|
| 447 |
|
|---|
| 448 |
|
|---|
| 449 |
|
|---|
| 450 |
|
|---|
| 451 |
|
|---|
| 452 |
case DEMUX_GET_TITLE_INFO: |
|---|
| 453 |
if( p_sys->i_tracks > 1 ) |
|---|
| 454 |
{ |
|---|
| 455 |
input_title_t ***ppp_title = (input_title_t***)va_arg( args, input_title_t*** ); |
|---|
| 456 |
int *pi_int = (int*)va_arg( args, int* ); |
|---|
| 457 |
|
|---|
| 458 |
*pi_int = p_sys->i_tracks; |
|---|
| 459 |
*ppp_title = (input_title_t**)malloc( sizeof( input_title_t**) * p_sys->i_tracks ); |
|---|
| 460 |
|
|---|
| 461 |
for( int i = 0; i < p_sys->i_tracks; i++ ) |
|---|
| 462 |
{ |
|---|
| 463 |
char psz_temp[16]; |
|---|
| 464 |
snprintf(psz_temp, 15, "Track %i", i); |
|---|
| 465 |
(*ppp_title)[i] = vlc_input_title_New(); |
|---|
| 466 |
(*ppp_title)[i]->psz_name = strdup(psz_temp); |
|---|
| 467 |
} |
|---|
| 468 |
|
|---|
| 469 |
return VLC_SUCCESS; |
|---|
| 470 |
} |
|---|
| 471 |
return VLC_EGENERIC; |
|---|
| 472 |
|
|---|
| 473 |
|
|---|
| 474 |
case DEMUX_SET_TITLE: |
|---|
| 475 |
i_idx = (int)va_arg( args, int ); |
|---|
| 476 |
p_sys->p_musicemu->start_track( i_idx ); |
|---|
| 477 |
p_demux->info.i_title = i_idx; |
|---|
| 478 |
p_demux->info.i_update = INPUT_UPDATE_TITLE; |
|---|
| 479 |
msg_Dbg( p_demux, "set title %i", i_idx); |
|---|
| 480 |
return VLC_SUCCESS; |
|---|
| 481 |
|
|---|
| 482 |
case DEMUX_GET_FPS: |
|---|
| 483 |
default: |
|---|
| 484 |
return VLC_EGENERIC; |
|---|
| 485 |
} |
|---|
| 486 |
|
|---|
| 487 |
} |
|---|
| 488 |
|
|---|
| 489 |
#ifdef HAVE_ZLIB_H |
|---|
| 490 |
static void inflate_gzbuf(uint8_t * p_buffer, size_t i_size, uint8_t ** pp_obuffer, size_t * pi_osize) |
|---|
| 491 |
{ |
|---|
| 492 |
z_stream z_str; |
|---|
| 493 |
int err; |
|---|
| 494 |
size_t offset, out_size; |
|---|
| 495 |
uint8_t * out_buffer; |
|---|
| 496 |
|
|---|
| 497 |
(*pp_obuffer) = NULL; |
|---|
| 498 |
(*pi_osize) = 0; |
|---|
| 499 |
|
|---|
| 500 |
memset(&z_str, 0, sizeof(z_str)); |
|---|
| 501 |
|
|---|
| 502 |
out_size = i_size * 2; |
|---|
| 503 |
out_buffer = (uint8_t*)malloc(out_size); |
|---|
| 504 |
|
|---|
| 505 |
z_str.next_in = (unsigned char*)p_buffer; |
|---|
| 506 |
z_str.avail_in = i_size; |
|---|
| 507 |
z_str.next_out = out_buffer; |
|---|
| 508 |
z_str.avail_out = out_size; |
|---|
| 509 |
|
|---|
| 510 |
if ((err = inflateInit2(&z_str, 31)) != Z_OK) |
|---|
| 511 |
{ |
|---|
| 512 |
free(out_buffer); |
|---|
| 513 |
return; |
|---|
| 514 |
} |
|---|
| 515 |
|
|---|
| 516 |
while ((err = inflate(&z_str, Z_FINISH)) != Z_STREAM_END) |
|---|
| 517 |
{ |
|---|
| 518 |
switch(err) |
|---|
| 519 |
{ |
|---|
| 520 |
case Z_OK: |
|---|
| 521 |
break; |
|---|
| 522 |
case Z_BUF_ERROR: |
|---|
| 523 |
offset = z_str.next_out - out_buffer; |
|---|
| 524 |
out_size *= 2; |
|---|
| 525 |
out_buffer = (uint8_t *)realloc(out_buffer, out_size); |
|---|
| 526 |
z_str.next_out = out_buffer + offset; |
|---|
| 527 |
z_str.avail_out = out_size - offset; |
|---|
| 528 |
break; |
|---|
| 529 |
default: |
|---|
| 530 |
inflateEnd(&z_str); |
|---|
| 531 |
free(out_buffer); |
|---|
| 532 |
return; |
|---|
| 533 |
} |
|---|
| 534 |
} |
|---|
| 535 |
|
|---|
| 536 |
(*pi_osize) = out_size - z_str.avail_out; |
|---|
| 537 |
|
|---|
| 538 |
inflateEnd(&z_str); |
|---|
| 539 |
|
|---|
| 540 |
out_buffer = (uint8_t *)realloc(out_buffer, *pi_osize); |
|---|
| 541 |
(*pp_obuffer) = out_buffer; |
|---|
| 542 |
} |
|---|
| 543 |
#endif |
|---|