| 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_demux.h> |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
static int Open ( vlc_object_t * ); |
|---|
| 46 |
static void Close ( vlc_object_t * ); |
|---|
| 47 |
|
|---|
| 48 |
vlc_module_begin(); |
|---|
| 49 |
set_description( N_("NullSoft demuxer" ) ); |
|---|
| 50 |
set_capability( "demux", 10 ); |
|---|
| 51 |
set_category( CAT_INPUT ); |
|---|
| 52 |
set_subcategory( SUBCAT_INPUT_DEMUX ); |
|---|
| 53 |
set_callbacks( Open, Close ); |
|---|
| 54 |
add_shortcut( "nsv" ); |
|---|
| 55 |
vlc_module_end(); |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
struct demux_sys_t |
|---|
| 62 |
{ |
|---|
| 63 |
es_format_t fmt_audio; |
|---|
| 64 |
es_out_id_t *p_audio; |
|---|
| 65 |
|
|---|
| 66 |
es_format_t fmt_video; |
|---|
| 67 |
es_out_id_t *p_video; |
|---|
| 68 |
|
|---|
| 69 |
es_format_t fmt_sub; |
|---|
| 70 |
es_out_id_t *p_sub; |
|---|
| 71 |
|
|---|
| 72 |
int64_t i_pcr; |
|---|
| 73 |
int64_t i_time; |
|---|
| 74 |
int64_t i_pcr_inc; |
|---|
| 75 |
|
|---|
| 76 |
bool b_start_record; |
|---|
| 77 |
}; |
|---|
| 78 |
|
|---|
| 79 |
static int Demux ( demux_t *p_demux ); |
|---|
| 80 |
static int Control( demux_t *p_demux, int i_query, va_list args ); |
|---|
| 81 |
|
|---|
| 82 |
static int ReSynch( demux_t *p_demux ); |
|---|
| 83 |
|
|---|
| 84 |
static int ReadNSVf( demux_t *p_demux ); |
|---|
| 85 |
static int ReadNSVs( demux_t *p_demux ); |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
static int Open( vlc_object_t *p_this ) |
|---|
| 91 |
{ |
|---|
| 92 |
demux_t *p_demux = (demux_t*)p_this; |
|---|
| 93 |
demux_sys_t *p_sys; |
|---|
| 94 |
|
|---|
| 95 |
const uint8_t *p_peek; |
|---|
| 96 |
|
|---|
| 97 |
if( stream_Peek( p_demux->s, &p_peek, 8 ) < 8 ) |
|---|
| 98 |
return VLC_EGENERIC; |
|---|
| 99 |
|
|---|
| 100 |
if( memcmp( p_peek, "NSVf", 4 ) && memcmp( p_peek, "NSVs", 4 ) ) |
|---|
| 101 |
{ |
|---|
| 102 |
|
|---|
| 103 |
if( !p_demux->b_force || ReSynch( p_demux ) ) |
|---|
| 104 |
return VLC_EGENERIC; |
|---|
| 105 |
} |
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
p_demux->pf_demux = Demux; |
|---|
| 109 |
p_demux->pf_control = Control; |
|---|
| 110 |
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); |
|---|
| 111 |
|
|---|
| 112 |
es_format_Init( &p_sys->fmt_audio, AUDIO_ES, 0 ); |
|---|
| 113 |
p_sys->p_audio = NULL; |
|---|
| 114 |
|
|---|
| 115 |
es_format_Init( &p_sys->fmt_video, VIDEO_ES, 0 ); |
|---|
| 116 |
p_sys->p_video = NULL; |
|---|
| 117 |
|
|---|
| 118 |
es_format_Init( &p_sys->fmt_sub, SPU_ES, 0 ); |
|---|
| 119 |
p_sys->p_sub = NULL; |
|---|
| 120 |
|
|---|
| 121 |
p_sys->i_pcr = 1; |
|---|
| 122 |
p_sys->i_time = 0; |
|---|
| 123 |
p_sys->i_pcr_inc = 0; |
|---|
| 124 |
|
|---|
| 125 |
p_sys->b_start_record = false; |
|---|
| 126 |
|
|---|
| 127 |
return VLC_SUCCESS; |
|---|
| 128 |
} |
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
static void Close( vlc_object_t *p_this ) |
|---|
| 134 |
{ |
|---|
| 135 |
demux_t *p_demux = (demux_t*)p_this; |
|---|
| 136 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 137 |
|
|---|
| 138 |
free( p_sys ); |
|---|
| 139 |
} |
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
static int Demux( demux_t *p_demux ) |
|---|
| 146 |
{ |
|---|
| 147 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 148 |
|
|---|
| 149 |
uint8_t header[5]; |
|---|
| 150 |
const uint8_t *p_peek; |
|---|
| 151 |
|
|---|
| 152 |
int i_size; |
|---|
| 153 |
block_t *p_frame; |
|---|
| 154 |
|
|---|
| 155 |
for( ;; ) |
|---|
| 156 |
{ |
|---|
| 157 |
if( stream_Peek( p_demux->s, &p_peek, 8 ) < 8 ) |
|---|
| 158 |
{ |
|---|
| 159 |
msg_Warn( p_demux, "cannot peek" ); |
|---|
| 160 |
return 0; |
|---|
| 161 |
} |
|---|
| 162 |
|
|---|
| 163 |
if( !memcmp( p_peek, "NSVf", 4 ) ) |
|---|
| 164 |
{ |
|---|
| 165 |
if( ReadNSVf( p_demux ) ) |
|---|
| 166 |
return -1; |
|---|
| 167 |
} |
|---|
| 168 |
else if( !memcmp( p_peek, "NSVs", 4 ) ) |
|---|
| 169 |
{ |
|---|
| 170 |
if( p_sys->b_start_record ) |
|---|
| 171 |
{ |
|---|
| 172 |
|
|---|
| 173 |
stream_Control( p_demux->s, STREAM_SET_RECORD_STATE, true, "nsv" ); |
|---|
| 174 |
p_sys->b_start_record = false; |
|---|
| 175 |
} |
|---|
| 176 |
|
|---|
| 177 |
if( ReadNSVs( p_demux ) ) |
|---|
| 178 |
return -1; |
|---|
| 179 |
break; |
|---|
| 180 |
} |
|---|
| 181 |
else if( GetWLE( p_peek ) == 0xbeef ) |
|---|
| 182 |
{ |
|---|
| 183 |
|
|---|
| 184 |
if( stream_Read( p_demux->s, NULL, 2 ) < 2 ) |
|---|
| 185 |
{ |
|---|
| 186 |
msg_Warn( p_demux, "cannot read" ); |
|---|
| 187 |
return 0; |
|---|
| 188 |
} |
|---|
| 189 |
break; |
|---|
| 190 |
} |
|---|
| 191 |
else |
|---|
| 192 |
{ |
|---|
| 193 |
msg_Err( p_demux, "invalid signature 0x%x (%4.4s)", GetDWLE( p_peek ), (const char*)p_peek ); |
|---|
| 194 |
if( ReSynch( p_demux ) ) |
|---|
| 195 |
return -1; |
|---|
| 196 |
} |
|---|
| 197 |
} |
|---|
| 198 |
|
|---|
| 199 |
if( stream_Read( p_demux->s, header, 5 ) < 5 ) |
|---|
| 200 |
{ |
|---|
| 201 |
msg_Warn( p_demux, "cannot read" ); |
|---|
| 202 |
return 0; |
|---|
| 203 |
} |
|---|
| 204 |
|
|---|
| 205 |
|
|---|
| 206 |
es_out_Control( p_demux->out, ES_OUT_SET_PCR, (int64_t)p_sys->i_pcr ); |
|---|
| 207 |
|
|---|
| 208 |
|
|---|
| 209 |
i_size = ( header[0] >> 4 ) | ( header[1] << 4 ) | ( header[2] << 12 ); |
|---|
| 210 |
if( i_size > 0 ) |
|---|
| 211 |
{ |
|---|
| 212 |
|
|---|
| 213 |
if( (header[0]&0x0f) != 0x0 ) |
|---|
| 214 |
{ |
|---|
| 215 |
uint8_t aux[6]; |
|---|
| 216 |
int i_aux; |
|---|
| 217 |
vlc_fourcc_t fcc; |
|---|
| 218 |
if( stream_Read( p_demux->s, aux, 6 ) < 6 ) |
|---|
| 219 |
{ |
|---|
| 220 |
msg_Warn( p_demux, "cannot read" ); |
|---|
| 221 |
return 0; |
|---|
| 222 |
} |
|---|
| 223 |
i_aux = GetWLE( aux ); |
|---|
| 224 |
fcc = VLC_FOURCC( aux[2], aux[3], aux[4], aux[5] ); |
|---|
| 225 |
|
|---|
| 226 |
msg_Dbg( p_demux, "Belekas: %d - size=%d fcc=%4.4s", |
|---|
| 227 |
header[0]&0xf, i_aux, (char*)&fcc ); |
|---|
| 228 |
|
|---|
| 229 |
if( fcc == VLC_FOURCC( 'S', 'U', 'B', 'T' ) && i_aux > 2 ) |
|---|
| 230 |
{ |
|---|
| 231 |
if( p_sys->p_sub == NULL ) |
|---|
| 232 |
{ |
|---|
| 233 |
p_sys->fmt_sub.i_codec = VLC_FOURCC( 's', 'u', 'b', 't' ); |
|---|
| 234 |
p_sys->p_sub = es_out_Add( p_demux->out, &p_sys->fmt_sub ); |
|---|
| 235 |
es_out_Control( p_demux->out, ES_OUT_SET_ES, p_sys->p_sub ); |
|---|
| 236 |
} |
|---|
| 237 |
stream_Read( p_demux->s, NULL, 2 ); |
|---|
| 238 |
|
|---|
| 239 |
if( ( p_frame = stream_Block( p_demux->s, i_aux - 2 ) ) ) |
|---|
| 240 |
{ |
|---|
| 241 |
uint8_t *p = p_frame->p_buffer; |
|---|
| 242 |
|
|---|
| 243 |
while( p < &p_frame->p_buffer[p_frame->i_buffer] && *p != 0 ) |
|---|
| 244 |
{ |
|---|
| 245 |
p++; |
|---|
| 246 |
} |
|---|
| 247 |
if( *p == 0 && p + 1 < &p_frame->p_buffer[p_frame->i_buffer] ) |
|---|
| 248 |
{ |
|---|
| 249 |
p_frame->i_buffer -= p + 1 - p_frame->p_buffer; |
|---|
| 250 |
p_frame->p_buffer = p + 1; |
|---|
| 251 |
} |
|---|
| 252 |
|
|---|
| 253 |
|
|---|
| 254 |
p_frame->i_pts = p_sys->i_pcr; |
|---|
| 255 |
p_frame->i_dts = p_sys->i_pcr + 4000000; |
|---|
| 256 |
|
|---|
| 257 |
es_out_Send( p_demux->out, p_sys->p_sub, p_frame ); |
|---|
| 258 |
} |
|---|
| 259 |
} |
|---|
| 260 |
else |
|---|
| 261 |
{ |
|---|
| 262 |
|
|---|
| 263 |
if( stream_Read( p_demux->s, NULL, i_aux ) < i_aux ) |
|---|
| 264 |
{ |
|---|
| 265 |
msg_Warn( p_demux, "cannot read" ); |
|---|
| 266 |
return 0; |
|---|
| 267 |
} |
|---|
| 268 |
} |
|---|
| 269 |
i_size -= 6 + i_aux; |
|---|
| 270 |
} |
|---|
| 271 |
|
|---|
| 272 |
|
|---|
| 273 |
if( i_size > 0 && ( p_frame = stream_Block( p_demux->s, i_size ) ) ) |
|---|
| 274 |
{ |
|---|
| 275 |
p_frame->i_dts = p_sys->i_pcr; |
|---|
| 276 |
es_out_Send( p_demux->out, p_sys->p_video, p_frame ); |
|---|
| 277 |
} |
|---|
| 278 |
} |
|---|
| 279 |
|
|---|
| 280 |
|
|---|
| 281 |
i_size = header[3] | ( header[4] << 8 ); |
|---|
| 282 |
if( i_size > 0 ) |
|---|
| 283 |
{ |
|---|
| 284 |
|
|---|
| 285 |
if( p_sys->fmt_audio.i_codec == VLC_FOURCC( 'a', 'r', 'a', 'w' ) ) |
|---|
| 286 |
{ |
|---|
| 287 |
uint8_t h[4]; |
|---|
| 288 |
stream_Read( p_demux->s, h, 4 ); |
|---|
| 289 |
|
|---|
| 290 |
p_sys->fmt_audio.audio.i_channels = h[1]; |
|---|
| 291 |
p_sys->fmt_audio.audio.i_rate = GetWLE( &h[2] ); |
|---|
| 292 |
|
|---|
| 293 |
i_size -= 4; |
|---|
| 294 |
} |
|---|
| 295 |
if( p_sys->p_audio == NULL ) |
|---|
| 296 |
{ |
|---|
| 297 |
p_sys->p_audio = es_out_Add( p_demux->out, &p_sys->fmt_audio ); |
|---|
| 298 |
} |
|---|
| 299 |
|
|---|
| 300 |
if( ( p_frame = stream_Block( p_demux->s, i_size ) ) ) |
|---|
| 301 |
{ |
|---|
| 302 |
p_frame->i_dts = |
|---|
| 303 |
p_frame->i_pts = p_sys->i_pcr; |
|---|
| 304 |
es_out_Send( p_demux->out, p_sys->p_audio, p_frame ); |
|---|
| 305 |
} |
|---|
| 306 |
} |
|---|
| 307 |
|
|---|
| 308 |
p_sys->i_pcr += p_sys->i_pcr_inc; |
|---|
| 309 |
if( p_sys->i_time >= 0 ) |
|---|
| 310 |
{ |
|---|
| 311 |
p_sys->i_time += p_sys->i_pcr_inc; |
|---|
| 312 |
} |
|---|
| 313 |
|
|---|
| 314 |
return 1; |
|---|
| 315 |
} |
|---|
| 316 |
|
|---|
| 317 |
|
|---|
| 318 |
|
|---|
| 319 |
|
|---|
| 320 |
static int Control( demux_t *p_demux, int i_query, va_list args ) |
|---|
| 321 |
{ |
|---|
| 322 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 323 |
double f, *pf; |
|---|
| 324 |
bool b_bool, *pb_bool; |
|---|
| 325 |
int64_t i64, *pi64; |
|---|
| 326 |
|
|---|
| 327 |
switch( i_query ) |
|---|
| 328 |
{ |
|---|
| 329 |
case DEMUX_GET_POSITION: |
|---|
| 330 |
pf = (double*) va_arg( args, double* ); |
|---|
| 331 |
i64 = stream_Size( p_demux->s ); |
|---|
| 332 |
if( i64 > 0 ) |
|---|
| 333 |
{ |
|---|
| 334 |
*pf = (double)stream_Tell( p_demux->s ) / (double)i64; |
|---|
| 335 |
} |
|---|
| 336 |
else |
|---|
| 337 |
{ |
|---|
| 338 |
*pf = 0.0; |
|---|
| 339 |
} |
|---|
| 340 |
return VLC_SUCCESS; |
|---|
| 341 |
|
|---|
| 342 |
case DEMUX_SET_POSITION: |
|---|
| 343 |
f = (double) va_arg( args, double ); |
|---|
| 344 |
i64 = stream_Size( p_demux->s ); |
|---|
| 345 |
|
|---|
| 346 |
es_out_Control( p_demux->out, ES_OUT_RESET_PCR ); |
|---|
| 347 |
if( stream_Seek( p_demux->s, (int64_t)(i64 * f) ) || ReSynch( p_demux ) ) |
|---|
| 348 |
{ |
|---|
| 349 |
return VLC_EGENERIC; |
|---|
| 350 |
} |
|---|
| 351 |
p_sys->i_time = -1; |
|---|
| 352 |
return VLC_SUCCESS; |
|---|
| 353 |
|
|---|
| 354 |
case DEMUX_GET_TIME: |
|---|
| 355 |
pi64 = (int64_t*)va_arg( args, int64_t * ); |
|---|
| 356 |
if( p_sys->i_time < 0 ) |
|---|
| 357 |
{ |
|---|
| 358 |
*pi64 = 0; |
|---|
| 359 |
return VLC_EGENERIC; |
|---|
| 360 |
} |
|---|
| 361 |
*pi64 = p_sys->i_time; |
|---|
| 362 |
return VLC_SUCCESS; |
|---|
| 363 |
|
|---|
| 364 |
#if 0 |
|---|
| 365 |
case DEMUX_GET_LENGTH: |
|---|
| 366 |
pi64 = (int64_t*)va_arg( args, int64_t * ); |
|---|
| 367 |
if( p_sys->i_mux_rate > 0 ) |
|---|
| 368 |
{ |
|---|
| 369 |
*pi64 = (int64_t)1000000 * ( stream_Size( p_demux->s ) / 50 ) / p_sys->i_mux_rate; |
|---|
| 370 |
return VLC_SUCCESS; |
|---|
| 371 |
} |
|---|
| 372 |
*pi64 = 0; |
|---|
| 373 |
return VLC_EGENERIC; |
|---|
| 374 |
|
|---|
| 375 |
#endif |
|---|
| 376 |
case DEMUX_GET_FPS: |
|---|
| 377 |
pf = (double*)va_arg( args, double * ); |
|---|
| 378 |
*pf = (double)1000000.0 / (double)p_sys->i_pcr_inc; |
|---|
| 379 |
return VLC_SUCCESS; |
|---|
| 380 |
|
|---|
| 381 |
case DEMUX_CAN_RECORD: |
|---|
| 382 |
pb_bool = (bool*)va_arg( args, bool * ); |
|---|
| 383 |
*pb_bool = true; |
|---|
| 384 |
return VLC_SUCCESS; |
|---|
| 385 |
|
|---|
| 386 |
case DEMUX_SET_RECORD_STATE: |
|---|
| 387 |
b_bool = (bool)va_arg( args, int ); |
|---|
| 388 |
|
|---|
| 389 |
if( !b_bool ) |
|---|
| 390 |
stream_Control( p_demux->s, STREAM_SET_RECORD_STATE, false ); |
|---|
| 391 |
p_sys->b_start_record = b_bool; |
|---|
| 392 |
return VLC_SUCCESS; |
|---|
| 393 |
|
|---|
| 394 |
|
|---|
| 395 |
case DEMUX_SET_TIME: |
|---|
| 396 |
default: |
|---|
| 397 |
return VLC_EGENERIC; |
|---|
| 398 |
} |
|---|
| 399 |
} |
|---|
| 400 |
|
|---|
| 401 |
|
|---|
| 402 |
|
|---|
| 403 |
|
|---|
| 404 |
static int ReSynch( demux_t *p_demux ) |
|---|
| 405 |
{ |
|---|
| 406 |
const uint8_t *p_peek; |
|---|
| 407 |
int i_skip; |
|---|
| 408 |
int i_peek; |
|---|
| 409 |
|
|---|
| 410 |
while( vlc_object_alive (p_demux) ) |
|---|
| 411 |
{ |
|---|
| 412 |
if( ( i_peek = stream_Peek( p_demux->s, &p_peek, 1024 ) ) < 8 ) |
|---|
| 413 |
{ |
|---|
| 414 |
return VLC_EGENERIC; |
|---|
| 415 |
} |
|---|
| 416 |
i_skip = 0; |
|---|
| 417 |
|
|---|
| 418 |
while( i_skip < i_peek - 4 ) |
|---|
| 419 |
{ |
|---|
| 420 |
if( !memcmp( p_peek, "NSVf", 4 ) |
|---|
| 421 |
|| !memcmp( p_peek, "NSVs", 4 ) ) |
|---|
| 422 |
{ |
|---|
| 423 |
if( i_skip > 0 ) |
|---|
| 424 |
{ |
|---|
| 425 |
stream_Read( p_demux->s, NULL, i_skip ); |
|---|
| 426 |
} |
|---|
| 427 |
return VLC_SUCCESS; |
|---|
| 428 |
} |
|---|
| 429 |
p_peek++; |
|---|
| 430 |
i_skip++; |
|---|
| 431 |
} |
|---|
| 432 |
|
|---|
| 433 |
stream_Read( p_demux->s, NULL, i_skip ); |
|---|
| 434 |
} |
|---|
| 435 |
return VLC_EGENERIC; |
|---|
| 436 |
} |
|---|
| 437 |
|
|---|
| 438 |
|
|---|
| 439 |
|
|---|
| 440 |
|
|---|
| 441 |
static int ReadNSVf( demux_t *p_demux ) |
|---|
| 442 |
{ |
|---|
| 443 |
|
|---|
| 444 |
const uint8_t *p; |
|---|
| 445 |
int i_size; |
|---|
| 446 |
|
|---|
| 447 |
msg_Dbg( p_demux, "new NSVf chunk" ); |
|---|
| 448 |
if( stream_Peek( p_demux->s, &p, 8 ) < 8 ) |
|---|
| 449 |
{ |
|---|
| 450 |
return VLC_EGENERIC; |
|---|
| 451 |
} |
|---|
| 452 |
|
|---|
| 453 |
i_size = GetDWLE( &p[4] ); |
|---|
| 454 |
msg_Dbg( p_demux, " - size=%d", i_size ); |
|---|
| 455 |
|
|---|
| 456 |
return stream_Read( p_demux->s, NULL, i_size ) == i_size ? VLC_SUCCESS : VLC_EGENERIC; |
|---|
| 457 |
} |
|---|
| 458 |
|
|---|
| 459 |
|
|---|
| 460 |
|
|---|
| 461 |
static int ReadNSVs( demux_t *p_demux ) |
|---|
| 462 |
{ |
|---|
| 463 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 464 |
uint8_t header[19]; |
|---|
| 465 |
vlc_fourcc_t fcc; |
|---|
| 466 |
|
|---|
| 467 |
if( stream_Read( p_demux->s, header, 19 ) < 19 ) |
|---|
| 468 |
{ |
|---|
| 469 |
msg_Warn( p_demux, "cannot read" ); |
|---|
| 470 |
return VLC_EGENERIC; |
|---|
| 471 |
} |
|---|
| 472 |
|
|---|
| 473 |
|
|---|
| 474 |
switch( ( fcc = VLC_FOURCC( header[4], header[5], header[6], header[7] ) ) ) |
|---|
| 475 |
{ |
|---|
| 476 |
case VLC_FOURCC( 'V', 'P', '3', ' ' ): |
|---|
| 477 |
case VLC_FOURCC( 'V', 'P', '3', '1' ): |
|---|
| 478 |
fcc = VLC_FOURCC( 'V', 'P', '3', '1' ); |
|---|
| 479 |
break; |
|---|
| 480 |
case VLC_FOURCC( 'V', 'P', '6', '0' ): |
|---|
| 481 |
case VLC_FOURCC( 'V', 'P', '6', '1' ): |
|---|
| 482 |
case VLC_FOURCC( 'V', 'P', '6', '2' ): |
|---|
| 483 |
case VLC_FOURCC( 'H', '2', '6', '4' ): |
|---|
| 484 |
case VLC_FOURCC( 'N', 'O', 'N', 'E' ): |
|---|
| 485 |
break; |
|---|
| 486 |
default: |
|---|
| 487 |
msg_Warn( p_demux, "unknown codec %4.4s", (char *)&fcc ); |
|---|
| 488 |
break; |
|---|
| 489 |
} |
|---|
| 490 |
if( fcc != VLC_FOURCC( 'N', 'O', 'N', 'E' ) && fcc != p_sys->fmt_video.i_codec ) |
|---|
| 491 |
{ |
|---|
| 492 |
es_format_Init( &p_sys->fmt_video, VIDEO_ES, fcc ); |
|---|
| 493 |
p_sys->fmt_video.video.i_width = GetWLE( &header[12] ); |
|---|
| 494 |
p_sys->fmt_video.video.i_height = GetWLE( &header[14] ); |
|---|
| 495 |
if( p_sys->p_video ) |
|---|
| 496 |
{ |
|---|
| 497 |
es_out_Del( p_demux->out, p_sys->p_video ); |
|---|
| 498 |
} |
|---|
| 499 |
p_sys->p_video = es_out_Add( p_demux->out, &p_sys->fmt_video ); |
|---|
| 500 |
|
|---|
| 501 |
msg_Dbg( p_demux, " - video `%4.4s' %dx%d", |
|---|
| 502 |
(char*)&fcc, |
|---|
| 503 |
p_sys->fmt_video.video.i_width, |
|---|
| 504 |
p_sys->fmt_video.video.i_height ); |
|---|
| 505 |
} |
|---|
| 506 |
|
|---|
| 507 |
|
|---|
| 508 |
switch( ( fcc = VLC_FOURCC( header[8], header[9], header[10], header[11] ) ) ) |
|---|
| 509 |
{ |
|---|
| 510 |
case VLC_FOURCC( 'M', 'P', '3', ' ' ): |
|---|
| 511 |
fcc = VLC_FOURCC( 'm', 'p', 'g', 'a' ); |
|---|
| 512 |
break; |
|---|
| 513 |
case VLC_FOURCC( 'P', 'C', 'M', ' ' ): |
|---|
| 514 |
fcc = VLC_FOURCC( 'a', 'r', 'a', 'w' ); |
|---|
| 515 |
break; |
|---|
| 516 |
case VLC_FOURCC( 'A', 'A', 'C', ' ' ): |
|---|
| 517 |
case VLC_FOURCC( 'A', 'A', 'C', 'P' ): |
|---|
| 518 |
fcc = VLC_FOURCC( 'm', 'p', '4', 'a' ); |
|---|
| 519 |
break; |
|---|
| 520 |
case VLC_FOURCC( 'N', 'O', 'N', 'E' ): |
|---|
| 521 |
break; |
|---|
| 522 |
default: |
|---|
| 523 |
msg_Warn( p_demux, "unknown codec %4.4s", (char *)&fcc ); |
|---|
| 524 |
break; |
|---|
| 525 |
} |
|---|
| 526 |
|
|---|
| 527 |
if( fcc != VLC_FOURCC( 'N', 'O', 'N', 'E' ) && fcc != p_sys->fmt_audio.i_codec ) |
|---|
| 528 |
{ |
|---|
| 529 |
msg_Dbg( p_demux, " - audio `%4.4s'", (char*)&fcc ); |
|---|
| 530 |
|
|---|
| 531 |
if( p_sys->p_audio ) |
|---|
| 532 |
{ |
|---|
| 533 |
es_out_Del( p_demux->out, p_sys->p_audio ); |
|---|
| 534 |
p_sys->p_audio = NULL; |
|---|
| 535 |
} |
|---|
| 536 |
es_format_Init( &p_sys->fmt_audio, AUDIO_ES, fcc ); |
|---|
| 537 |
} |
|---|
| 538 |
|
|---|
| 539 |
if( header[16]&0x80 ) |
|---|
| 540 |
{ |
|---|
| 541 |
|
|---|
| 542 |
switch( header[16]&0x03 ) |
|---|
| 543 |
{ |
|---|
| 544 |
case 0: |
|---|
| 545 |
p_sys->i_pcr_inc = 33333; |
|---|
| 546 |
break; |
|---|
| 547 |
case 1: |
|---|
| 548 |
p_sys->i_pcr_inc = 33367; |
|---|
| 549 |
break; |
|---|
| 550 |
case 2: |
|---|
| 551 |
p_sys->i_pcr_inc = 40000; |
|---|
| 552 |
break; |
|---|
| 553 |
case 3: |
|---|
| 554 |
p_sys->i_pcr_inc = 41700; |
|---|
| 555 |
break; |
|---|
| 556 |
} |
|---|
| 557 |
|
|---|
| 558 |
if( header[16] < 0xc0 ) |
|---|
| 559 |
p_sys->i_pcr_inc = p_sys->i_pcr_inc * (((header[16] ^ 0x80) >> 2 ) +1 ); |
|---|
| 560 |
else |
|---|
| 561 |
p_sys->i_pcr_inc = p_sys->i_pcr_inc / (((header[16] ^ 0xc0) >> 2 ) +1 ); |
|---|
| 562 |
} |
|---|
| 563 |
else if( header[16] != 0 ) |
|---|
| 564 |
{ |
|---|
| 565 |
|
|---|
| 566 |
p_sys->i_pcr_inc = 1000000 / header[16]; |
|---|
| 567 |
} |
|---|
| 568 |
else |
|---|
| 569 |
{ |
|---|
| 570 |
msg_Dbg( p_demux, "invalid fps (0x00)" ); |
|---|
| 571 |
p_sys->i_pcr_inc = 40000; |
|---|
| 572 |
} |
|---|
| 573 |
|
|---|
| 574 |
|
|---|
| 575 |
return VLC_SUCCESS; |
|---|
| 576 |
} |
|---|
| 577 |
|
|---|