| 325 | | if( p_dec->fmt_in.i_extra ) |
|---|
| 326 | | { |
|---|
| 327 | | int i_size = p_dec->fmt_in.i_extra; |
|---|
| 328 | | |
|---|
| 329 | | if( p_sys->i_codec_id == CODEC_ID_SVQ3 ) |
|---|
| 330 | | { |
|---|
| 331 | | uint8_t *p; |
|---|
| 332 | | |
|---|
| 333 | | p_sys->p_context->extradata_size = i_size + 12; |
|---|
| 334 | | p = p_sys->p_context->extradata = |
|---|
| 335 | | malloc( p_sys->p_context->extradata_size ); |
|---|
| 336 | | |
|---|
| 337 | | memcpy( &p[0], "SVQ3", 4 ); |
|---|
| 338 | | memset( &p[4], 0, 8 ); |
|---|
| 339 | | memcpy( &p[12], p_dec->fmt_in.p_extra, i_size ); |
|---|
| 340 | | |
|---|
| 341 | | /* Now remove all atoms before the SMI one */ |
|---|
| 342 | | if( p_sys->p_context->extradata_size > 0x5a && |
|---|
| 343 | | strncmp( &p[0x56], "SMI ", 4 ) ) |
|---|
| 344 | | { |
|---|
| 345 | | uint8_t *psz = &p[0x52]; |
|---|
| 346 | | |
|---|
| 347 | | while( psz < &p[p_sys->p_context->extradata_size - 8] ) |
|---|
| 348 | | { |
|---|
| 349 | | int i_size = GetDWBE( psz ); |
|---|
| 350 | | if( i_size <= 1 ) |
|---|
| 351 | | { |
|---|
| 352 | | /* FIXME handle 1 as long size */ |
|---|
| 353 | | break; |
|---|
| 354 | | } |
|---|
| 355 | | if( !strncmp( &psz[4], "SMI ", 4 ) ) |
|---|
| 356 | | { |
|---|
| 357 | | memmove( &p[0x52], psz, |
|---|
| 358 | | &p[p_sys->p_context->extradata_size] - psz ); |
|---|
| 359 | | break; |
|---|
| 360 | | } |
|---|
| 361 | | |
|---|
| 362 | | psz += i_size; |
|---|
| 363 | | } |
|---|
| 364 | | } |
|---|
| 365 | | } |
|---|
| 366 | | else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '1', '0' ) || |
|---|
| 367 | | p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '1', '3' ) || |
|---|
| 368 | | p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '2', '0' ) ) |
|---|
| 369 | | { |
|---|
| 370 | | if( p_dec->fmt_in.i_extra == 8 ) |
|---|
| 371 | | { |
|---|
| 372 | | p_sys->p_context->extradata_size = 8; |
|---|
| 373 | | p_sys->p_context->extradata = malloc( 8 ); |
|---|
| 374 | | |
|---|
| 375 | | memcpy( p_sys->p_context->extradata, |
|---|
| 376 | | p_dec->fmt_in.p_extra, |
|---|
| 377 | | p_dec->fmt_in.i_extra ); |
|---|
| 378 | | p_sys->p_context->sub_id= ((uint32_t*)p_dec->fmt_in.p_extra)[1]; |
|---|
| 379 | | |
|---|
| 380 | | msg_Warn( p_dec, "using extra data for RV codec sub_id=%08x", |
|---|
| 381 | | p_sys->p_context->sub_id ); |
|---|
| 382 | | } |
|---|
| 383 | | } |
|---|
| 384 | | /* FIXME: remove when ffmpeg deals properly with avc1 */ |
|---|
| 385 | | else if( p_dec->fmt_in.i_codec == VLC_FOURCC('a','v','c','1') ) |
|---|
| 386 | | { |
|---|
| 387 | | ; |
|---|
| 388 | | } |
|---|
| 389 | | /* End FIXME */ |
|---|
| 390 | | else |
|---|
| 391 | | { |
|---|
| 392 | | p_sys->p_context->extradata_size = i_size; |
|---|
| 393 | | p_sys->p_context->extradata = |
|---|
| 394 | | malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE ); |
|---|
| 395 | | memcpy( p_sys->p_context->extradata, |
|---|
| 396 | | p_dec->fmt_in.p_extra, i_size ); |
|---|
| 397 | | memset( &((uint8_t*)p_sys->p_context->extradata)[i_size], |
|---|
| 398 | | 0, FF_INPUT_BUFFER_PADDING_SIZE ); |
|---|
| 399 | | } |
|---|
| 400 | | } |
|---|
| | 326 | ffmpeg_InitCodec( p_dec ); |
|---|
| | 668 | * ffmpeg_InitCodec: setup codec extra initialization data for ffmpeg |
|---|
| | 669 | *****************************************************************************/ |
|---|
| | 670 | static void ffmpeg_InitCodec( decoder_t *p_dec ) |
|---|
| | 671 | { |
|---|
| | 672 | decoder_sys_t *p_sys = p_dec->p_sys; |
|---|
| | 673 | int i_size = p_dec->fmt_in.i_extra; |
|---|
| | 674 | |
|---|
| | 675 | if( !i_size ) return; |
|---|
| | 676 | |
|---|
| | 677 | if( p_sys->i_codec_id == CODEC_ID_SVQ3 ) |
|---|
| | 678 | { |
|---|
| | 679 | uint8_t *p; |
|---|
| | 680 | |
|---|
| | 681 | p_sys->p_context->extradata_size = i_size + 12; |
|---|
| | 682 | p = p_sys->p_context->extradata = |
|---|
| | 683 | malloc( p_sys->p_context->extradata_size ); |
|---|
| | 684 | |
|---|
| | 685 | memcpy( &p[0], "SVQ3", 4 ); |
|---|
| | 686 | memset( &p[4], 0, 8 ); |
|---|
| | 687 | memcpy( &p[12], p_dec->fmt_in.p_extra, i_size ); |
|---|
| | 688 | |
|---|
| | 689 | /* Now remove all atoms before the SMI one */ |
|---|
| | 690 | if( p_sys->p_context->extradata_size > 0x5a && |
|---|
| | 691 | strncmp( &p[0x56], "SMI ", 4 ) ) |
|---|
| | 692 | { |
|---|
| | 693 | uint8_t *psz = &p[0x52]; |
|---|
| | 694 | |
|---|
| | 695 | while( psz < &p[p_sys->p_context->extradata_size - 8] ) |
|---|
| | 696 | { |
|---|
| | 697 | int i_size = GetDWBE( psz ); |
|---|
| | 698 | if( i_size <= 1 ) |
|---|
| | 699 | { |
|---|
| | 700 | /* FIXME handle 1 as long size */ |
|---|
| | 701 | break; |
|---|
| | 702 | } |
|---|
| | 703 | if( !strncmp( &psz[4], "SMI ", 4 ) ) |
|---|
| | 704 | { |
|---|
| | 705 | memmove( &p[0x52], psz, |
|---|
| | 706 | &p[p_sys->p_context->extradata_size] - psz ); |
|---|
| | 707 | break; |
|---|
| | 708 | } |
|---|
| | 709 | |
|---|
| | 710 | psz += i_size; |
|---|
| | 711 | } |
|---|
| | 712 | } |
|---|
| | 713 | } |
|---|
| | 714 | else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '1', '0' ) || |
|---|
| | 715 | p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '1', '3' ) || |
|---|
| | 716 | p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '2', '0' ) ) |
|---|
| | 717 | { |
|---|
| | 718 | if( p_dec->fmt_in.i_extra == 8 ) |
|---|
| | 719 | { |
|---|
| | 720 | p_sys->p_context->extradata_size = 8; |
|---|
| | 721 | p_sys->p_context->extradata = malloc( 8 ); |
|---|
| | 722 | |
|---|
| | 723 | memcpy( p_sys->p_context->extradata, |
|---|
| | 724 | p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra ); |
|---|
| | 725 | p_sys->p_context->sub_id= ((uint32_t*)p_dec->fmt_in.p_extra)[1]; |
|---|
| | 726 | |
|---|
| | 727 | msg_Warn( p_dec, "using extra data for RV codec sub_id=%08x", |
|---|
| | 728 | p_sys->p_context->sub_id ); |
|---|
| | 729 | } |
|---|
| | 730 | } |
|---|
| | 731 | /* FIXME: remove when ffmpeg deals properly with avc1 */ |
|---|
| | 732 | else if( p_dec->fmt_in.i_codec == VLC_FOURCC('a','v','c','1') ) |
|---|
| | 733 | { |
|---|
| | 734 | ; |
|---|
| | 735 | } |
|---|
| | 736 | /* End FIXME */ |
|---|
| | 737 | else |
|---|
| | 738 | { |
|---|
| | 739 | p_sys->p_context->extradata_size = i_size; |
|---|
| | 740 | p_sys->p_context->extradata = |
|---|
| | 741 | malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE ); |
|---|
| | 742 | memcpy( p_sys->p_context->extradata, |
|---|
| | 743 | p_dec->fmt_in.p_extra, i_size ); |
|---|
| | 744 | memset( &((uint8_t*)p_sys->p_context->extradata)[i_size], |
|---|
| | 745 | 0, FF_INPUT_BUFFER_PADDING_SIZE ); |
|---|
| | 746 | } |
|---|
| | 747 | } |
|---|
| | 748 | |
|---|
| | 749 | /***************************************************************************** |
|---|