| 621 | | GetDWBE( &header[8] ), GetDWBE( &header[12] ) ); |
|---|
| 622 | | msg_Dbg( p_demux, " - packets count=%d", GetDWBE( &header[16] ) ); |
|---|
| 623 | | msg_Dbg( p_demux, " - duration=%d ms", GetDWBE( &header[20] ) ); |
|---|
| 624 | | msg_Dbg( p_demux, " - preroll=%d ms", GetDWBE( &header[24] ) ); |
|---|
| 625 | | msg_Dbg( p_demux, " - index offset=%d", GetDWBE( &header[28] ) ); |
|---|
| 626 | | msg_Dbg( p_demux, " - data offset=%d", GetDWBE( &header[32] ) ); |
|---|
| 627 | | msg_Dbg( p_demux, " - num streams=%d", GetWBE( &header[36] ) ); |
|---|
| 628 | | i_flags = GetWBE( &header[38]); |
|---|
| | 619 | GetDWBE(&header[8]), GetDWBE(&header[12]) ); |
|---|
| | 620 | msg_Dbg( p_demux, " - packets count=%d", GetDWBE(&header[16]) ); |
|---|
| | 621 | msg_Dbg( p_demux, " - duration=%d ms", GetDWBE(&header[20]) ); |
|---|
| | 622 | msg_Dbg( p_demux, " - preroll=%d ms", GetDWBE(&header[24]) ); |
|---|
| | 623 | msg_Dbg( p_demux, " - index offset=%d", GetDWBE(&header[28]) ); |
|---|
| | 624 | msg_Dbg( p_demux, " - data offset=%d", GetDWBE(&header[32]) ); |
|---|
| | 625 | msg_Dbg( p_demux, " - num streams=%d", GetWBE(&header[36]) ); |
|---|
| | 626 | i_flags = GetWBE(&header[38]); |
|---|
| 705 | | msg_Dbg( p_demux, " - max bitrate=%d avg bitrate=%d", GetDWBE( &header[2] ), GetDWBE( &header[6] ) ); |
|---|
| 706 | | msg_Dbg( p_demux, " - max packet size=%d avg packet size=%d", GetDWBE( &header[10] ), GetDWBE( &header[14] )); |
|---|
| 707 | | msg_Dbg( p_demux, " - start time=%d", GetDWBE( &header[18] ) ); |
|---|
| 708 | | msg_Dbg( p_demux, " - preroll=%d", GetDWBE( &header[22] ) ); |
|---|
| 709 | | msg_Dbg( p_demux, " - duration=%d", GetDWBE( &header[26] )); |
|---|
| | 701 | msg_Dbg( p_demux, " - max bitrate=%d avg bitrate=%d", |
|---|
| | 702 | GetDWBE(&header[2]), GetDWBE(&header[6]) ); |
|---|
| | 703 | msg_Dbg( p_demux, " - max packet size=%d avg packet size=%d", |
|---|
| | 704 | GetDWBE(&header[10]), GetDWBE(&header[14]) ); |
|---|
| | 705 | msg_Dbg( p_demux, " - start time=%d", GetDWBE(&header[18]) ); |
|---|
| | 706 | msg_Dbg( p_demux, " - preroll=%d", GetDWBE(&header[22]) ); |
|---|
| | 707 | msg_Dbg( p_demux, " - duration=%d", GetDWBE(&header[26]) ); |
|---|
| 742 | | es_format_t fmt; |
|---|
| 743 | | real_track_t *tk; |
|---|
| 744 | | uint8_t *p_peek; |
|---|
| 745 | | |
|---|
| 746 | | msg_Dbg( p_demux, " - specific data len=%d", i_len ); |
|---|
| 747 | | if( stream_Peek( p_demux->s, &p_peek, 34 ) >= 34 ) |
|---|
| 748 | | { |
|---|
| 749 | | if( !strncmp( (char *)&p_peek[4], "VIDO", 4 ) ) |
|---|
| 750 | | { |
|---|
| 751 | | es_format_Init( &fmt, VIDEO_ES, |
|---|
| 752 | | VLC_FOURCC( p_peek[8], p_peek[9], p_peek[10], p_peek[11] ) ); |
|---|
| 753 | | fmt.video.i_width = GetWBE( &p_peek[12] ); |
|---|
| 754 | | fmt.video.i_height= GetWBE( &p_peek[14] ); |
|---|
| 755 | | |
|---|
| 756 | | fmt.i_extra = 8; |
|---|
| 757 | | fmt.p_extra = malloc( 8 ); |
|---|
| 758 | | ((uint32_t*)fmt.p_extra)[0] = GetDWBE( &p_peek[26] ); |
|---|
| 759 | | ((uint32_t*)fmt.p_extra)[1] = GetDWBE( &p_peek[30] ); |
|---|
| 760 | | |
|---|
| 761 | | msg_Dbg( p_demux, " - video 0x%08x 0x%08x", |
|---|
| 762 | | ((uint32_t*)fmt.p_extra)[0], |
|---|
| 763 | | ((uint32_t*)fmt.p_extra)[1] ); |
|---|
| 764 | | |
|---|
| 765 | | if( GetDWBE( &p_peek[30] ) == 0x10003000 || |
|---|
| 766 | | GetDWBE( &p_peek[30] ) == 0x10003001 ) |
|---|
| 767 | | { |
|---|
| 768 | | fmt.i_codec = VLC_FOURCC( 'R','V','1','3' ); |
|---|
| 769 | | } |
|---|
| 770 | | |
|---|
| 771 | | msg_Dbg( p_demux, " - video %4.4s %dx%d", |
|---|
| 772 | | (char*)&fmt.i_codec, |
|---|
| 773 | | fmt.video.i_width, fmt.video.i_height ); |
|---|
| 774 | | |
|---|
| 775 | | tk = malloc( sizeof( real_track_t ) ); |
|---|
| 776 | | tk->i_id = i_num; |
|---|
| 777 | | tk->fmt = fmt; |
|---|
| 778 | | tk->i_frame = 0; |
|---|
| 779 | | tk->p_frame = NULL; |
|---|
| 780 | | tk->p_es = es_out_Add( p_demux->out, &fmt ); |
|---|
| 781 | | |
|---|
| 782 | | TAB_APPEND( p_sys->i_track, p_sys->track, tk ); |
|---|
| 783 | | } |
|---|
| 784 | | else if( !strncmp( (char *)p_peek, ".ra\xfd", 4 ) ) |
|---|
| 785 | | { |
|---|
| 786 | | int i_version = GetWBE( &p_peek[4] ); |
|---|
| 787 | | uint8_t *p_extra = NULL; |
|---|
| 788 | | msg_Dbg( p_demux, " - audio version=%d", i_version ); |
|---|
| 789 | | |
|---|
| 790 | | es_format_Init( &fmt, AUDIO_ES, 0 ); |
|---|
| 791 | | if( i_version == 4 && stream_Peek( p_demux->s, &p_peek, 56 ) >= 56 ) |
|---|
| 792 | | { |
|---|
| 793 | | fmt.audio.i_channels = GetWBE( &p_peek[54] ); |
|---|
| 794 | | fmt.audio.i_rate = GetWBE( &p_peek[48] ); |
|---|
| 795 | | |
|---|
| 796 | | if( stream_Peek( p_demux->s, &p_peek, 57 ) >= 57 ) |
|---|
| 797 | | { |
|---|
| 798 | | int i_extra = p_peek[56] + 1 + 4; |
|---|
| 799 | | if( stream_Peek( p_demux->s, &p_peek, 57 + i_extra ) >= 57 + i_extra ) |
|---|
| 800 | | { |
|---|
| 801 | | memcpy( &fmt.i_codec, &p_peek[57 + p_peek[56] + 1], 4 ); |
|---|
| 802 | | } |
|---|
| 803 | | p_extra = &p_peek[57 + p_peek[56] + 1+ 4 + 3]; |
|---|
| 804 | | } |
|---|
| 805 | | } |
|---|
| 806 | | else if( i_version == 5 && stream_Peek( p_demux->s, &p_peek, 70 ) >= 70 ) |
|---|
| 807 | | { |
|---|
| 808 | | memcpy( &fmt.i_codec, &p_peek[66], 4 ); |
|---|
| 809 | | fmt.audio.i_channels = GetWBE( &p_peek[60] ); |
|---|
| 810 | | fmt.audio.i_rate = GetWBE( &p_peek[54] ); |
|---|
| 811 | | |
|---|
| 812 | | p_extra = &p_peek[66+4+3+1]; |
|---|
| 813 | | } |
|---|
| 814 | | msg_Dbg( p_demux, " - audio codec=%4.4s channels=%d rate=%dHz", |
|---|
| 815 | | (char*)&fmt.i_codec, |
|---|
| 816 | | fmt.audio.i_channels, fmt.audio.i_rate ); |
|---|
| 817 | | |
|---|
| 818 | | if( fmt.i_codec == VLC_FOURCC( 'd', 'n', 'e', 't' ) ) |
|---|
| 819 | | { |
|---|
| 820 | | fmt.i_codec = VLC_FOURCC( 'a', '5', '2', ' ' ); |
|---|
| 821 | | } |
|---|
| 822 | | else if( fmt.i_codec == VLC_FOURCC( 'r', 'a', 'a', 'c' ) || |
|---|
| 823 | | fmt.i_codec == VLC_FOURCC( 'r', 'a', 'c', 'p' ) ) |
|---|
| 824 | | { |
|---|
| 825 | | int i_peek = p_extra - p_peek; |
|---|
| 826 | | if( stream_Peek( p_demux->s, &p_peek, i_peek + 4 ) >= i_peek + 4 ) |
|---|
| 827 | | { |
|---|
| 828 | | int i_extra = GetDWBE( &p_peek[i_peek] ); |
|---|
| 829 | | |
|---|
| 830 | | if( i_extra > 1 && i_peek + 4 + i_extra <= i_len && |
|---|
| 831 | | stream_Peek( p_demux->s, &p_peek, i_peek + 4 + i_extra ) >= i_peek + 4 + i_extra ) |
|---|
| 832 | | { |
|---|
| 833 | | fmt.i_extra = i_extra - 1; |
|---|
| 834 | | fmt.p_extra = malloc ( i_extra - 1 ); |
|---|
| 835 | | memcpy( fmt.p_extra, &p_peek[i_peek+4+1], i_extra - 1 ); |
|---|
| 836 | | |
|---|
| 837 | | msg_Dbg( p_demux, " - extra data=%d", i_extra ); |
|---|
| 838 | | { |
|---|
| 839 | | int i; |
|---|
| 840 | | for( i = 0; i < fmt.i_extra; i++ ) |
|---|
| 841 | | { |
|---|
| 842 | | msg_Dbg( p_demux, " data[%d] = 0x%x", i,((uint8_t*)fmt.p_extra)[i] ); |
|---|
| 843 | | } |
|---|
| 844 | | } |
|---|
| 845 | | } |
|---|
| 846 | | } |
|---|
| 847 | | fmt.i_codec = VLC_FOURCC( 'm', 'p', '4', 'a' ); |
|---|
| 848 | | } |
|---|
| 849 | | |
|---|
| 850 | | if( fmt.i_codec != 0 ) |
|---|
| 851 | | { |
|---|
| 852 | | tk = malloc( sizeof( real_track_t ) ); |
|---|
| 853 | | tk->i_id = i_num; |
|---|
| 854 | | tk->fmt = fmt; |
|---|
| 855 | | tk->i_frame = 0; |
|---|
| 856 | | tk->p_frame = NULL; |
|---|
| 857 | | tk->p_es = es_out_Add( p_demux->out, &fmt ); |
|---|
| 858 | | |
|---|
| 859 | | TAB_APPEND( p_sys->i_track, p_sys->track, tk ); |
|---|
| 860 | | } |
|---|
| 861 | | } |
|---|
| 862 | | } |
|---|
| | 739 | ReadCodecSpecificData( p_demux, i_len, i_num ); |
|---|
| 904 | | |
|---|
| | 778 | static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num ) |
|---|
| | 779 | { |
|---|
| | 780 | demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| | 781 | es_format_t fmt; |
|---|
| | 782 | real_track_t *tk; |
|---|
| | 783 | uint8_t *p_peek; |
|---|
| | 784 | |
|---|
| | 785 | msg_Dbg( p_demux, " - specific data len=%d", i_len ); |
|---|
| | 786 | if( stream_Peek(p_demux->s, &p_peek, i_len) < i_len ) return VLC_EGENERIC; |
|---|
| | 787 | |
|---|
| | 788 | if( !strncmp( (char *)&p_peek[4], "VIDO", 4 ) ) |
|---|
| | 789 | { |
|---|
| | 790 | es_format_Init( &fmt, VIDEO_ES, VLC_FOURCC( p_peek[8], p_peek[9], |
|---|
| | 791 | p_peek[10], p_peek[11] ) ); |
|---|
| | 792 | fmt.video.i_width = GetWBE( &p_peek[12] ); |
|---|
| | 793 | fmt.video.i_height= GetWBE( &p_peek[14] ); |
|---|
| | 794 | |
|---|
| | 795 | fmt.i_extra = 8; |
|---|
| | 796 | fmt.p_extra = malloc( 8 ); |
|---|
| | 797 | ((uint32_t*)fmt.p_extra)[0] = GetDWBE( &p_peek[26] ); |
|---|
| | 798 | ((uint32_t*)fmt.p_extra)[1] = GetDWBE( &p_peek[30] ); |
|---|
| | 799 | |
|---|
| | 800 | msg_Dbg( p_demux, " - video 0x%08x 0x%08x", |
|---|
| | 801 | ((uint32_t*)fmt.p_extra)[0], ((uint32_t*)fmt.p_extra)[1] ); |
|---|
| | 802 | |
|---|
| | 803 | if( GetDWBE( &p_peek[30] ) == 0x10003000 || |
|---|
| | 804 | GetDWBE( &p_peek[30] ) == 0x10003001 ) |
|---|
| | 805 | { |
|---|
| | 806 | fmt.i_codec = VLC_FOURCC( 'R','V','1','3' ); |
|---|
| | 807 | } |
|---|
| | 808 | |
|---|
| | 809 | msg_Dbg( p_demux, " - video %4.4s %dx%d", |
|---|
| | 810 | (char*)&fmt.i_codec, fmt.video.i_width, fmt.video.i_height ); |
|---|
| | 811 | |
|---|
| | 812 | tk = malloc( sizeof( real_track_t ) ); |
|---|
| | 813 | tk->i_id = i_num; |
|---|
| | 814 | tk->fmt = fmt; |
|---|
| | 815 | tk->i_frame = 0; |
|---|
| | 816 | tk->p_frame = NULL; |
|---|
| | 817 | tk->p_es = es_out_Add( p_demux->out, &fmt ); |
|---|
| | 818 | |
|---|
| | 819 | TAB_APPEND( p_sys->i_track, p_sys->track, tk ); |
|---|
| | 820 | } |
|---|
| | 821 | else if( !strncmp( (char *)p_peek, ".ra\xfd", 4 ) ) |
|---|
| | 822 | { |
|---|
| | 823 | int i_version = GetWBE( &p_peek[4] ); |
|---|
| | 824 | int i_header_size, i_flavor, i_coded_frame_size, i_subpacket_h; |
|---|
| | 825 | int i_frame_size, i_subpacket_size; |
|---|
| | 826 | |
|---|
| | 827 | msg_Dbg( p_demux, " - audio version=%d", i_version ); |
|---|
| | 828 | |
|---|
| | 829 | p_peek += 6; |
|---|
| | 830 | es_format_Init( &fmt, AUDIO_ES, 0 ); |
|---|
| | 831 | |
|---|
| | 832 | if( i_version == 3 ) |
|---|
| | 833 | { |
|---|
| | 834 | msg_Dbg( p_demux, " - audio version 3 is not supported!" ); |
|---|
| | 835 | return VLC_EGENERIC; |
|---|
| | 836 | } |
|---|
| | 837 | |
|---|
| | 838 | p_peek += 2; /* 00 00 */ |
|---|
| | 839 | p_peek += 4; /* .ra4 or .ra5 */ |
|---|
| | 840 | p_peek += 4; /* ?? */ |
|---|
| | 841 | p_peek += 2; /* version (4 or 5) */ |
|---|
| | 842 | i_header_size = GetDWBE( p_peek ); p_peek += 4; /* header size */ |
|---|
| | 843 | i_flavor = GetWBE( p_peek ); p_peek += 2; /* codec flavor */ |
|---|
| | 844 | i_coded_frame_size = GetDWBE( p_peek ); p_peek += 4; |
|---|
| | 845 | p_peek += 4; /* ?? */ |
|---|
| | 846 | p_peek += 4; /* ?? */ |
|---|
| | 847 | p_peek += 4; /* ?? */ |
|---|
| | 848 | i_subpacket_h = GetWBE( p_peek ); p_peek += 2; |
|---|
| | 849 | i_frame_size = GetWBE( p_peek ); p_peek += 2; |
|---|
| | 850 | i_subpacket_size = GetWBE( p_peek ); p_peek += 2; |
|---|
| | 851 | p_peek += 2; /* ?? */ |
|---|
| | 852 | |
|---|
| | 853 | if( i_version == 5 ) p_peek += 6; /* 0, srate, 0 */ |
|---|
| | 854 | |
|---|
| | 855 | fmt.audio.i_rate = GetWBE( p_peek ); p_peek += 2; |
|---|
| | 856 | p_peek += 2; /* ?? */ |
|---|
| | 857 | fmt.audio.i_bitspersample = GetWBE( p_peek ); p_peek += 2; |
|---|
| | 858 | fmt.audio.i_channels = GetWBE( p_peek ); p_peek += 2; |
|---|
| | 859 | fmt.audio.i_blockalign = i_frame_size; |
|---|
| | 860 | |
|---|
| | 861 | if( i_version == 5 ) |
|---|
| | 862 | { |
|---|
| | 863 | p_peek += 4; /* genr */ |
|---|
| | 864 | memcpy( (char *)&fmt.i_codec, p_peek, 4 ); p_peek += 4; |
|---|
| | 865 | } |
|---|
| | 866 | else |
|---|
| | 867 | { |
|---|
| | 868 | p_peek += p_peek[0] + 1; /* descr 1 */ |
|---|
| | 869 | memcpy( (char *)&fmt.i_codec, p_peek + 1, 4 ); /* descr 2 */ |
|---|
| | 870 | p_peek += p_peek[0] + 1; |
|---|
| | 871 | } |
|---|
| | 872 | |
|---|
| | 873 | msg_Dbg( p_demux, " - audio codec=%4.4s channels=%d rate=%dHz", |
|---|
| | 874 | (char*)&fmt.i_codec, fmt.audio.i_channels, fmt.audio.i_rate ); |
|---|
| | 875 | |
|---|
| | 876 | p_peek += 3; /* ?? */ |
|---|
| | 877 | if( i_version == 5 ) p_peek++; |
|---|
| | 878 | |
|---|
| | 879 | switch( fmt.i_codec ) |
|---|
| | 880 | { |
|---|
| | 881 | case VLC_FOURCC( 'd', 'n', 'e', 't' ): |
|---|
| | 882 | fmt.i_codec = VLC_FOURCC( 'a', '5', '2', ' ' ); |
|---|
| | 883 | break; |
|---|
| | 884 | |
|---|
| | 885 | case VLC_FOURCC( 'r', 'a', 'a', 'c' ): |
|---|
| | 886 | case VLC_FOURCC( 'r', 'a', 'c', 'p' ): |
|---|
| | 887 | fmt.i_extra = GetDWBE( p_peek ); p_peek += 4; |
|---|
| | 888 | if( fmt.i_extra > 0 ) { fmt.i_extra--; p_peek++; } |
|---|
| | 889 | if( fmt.i_extra > 0 ) |
|---|
| | 890 | { |
|---|
| | 891 | fmt.p_extra = malloc( fmt.i_extra ); |
|---|
| | 892 | memcpy( fmt.p_extra, p_peek, fmt.i_extra ); |
|---|
| | 893 | } |
|---|
| | 894 | |
|---|
| | 895 | fmt.i_codec = VLC_FOURCC( 'm', 'p', '4', 'a' ); |
|---|
| | 896 | break; |
|---|
| | 897 | |
|---|
| | 898 | case VLC_FOURCC('c','o','o','k'): |
|---|
| | 899 | fmt.i_extra = GetDWBE( p_peek ); p_peek += 4; |
|---|
| | 900 | fmt.p_extra = malloc( fmt.i_extra + 10 ); |
|---|
| | 901 | |
|---|
| | 902 | ((short*)(fmt.p_extra))[0] = i_subpacket_size; |
|---|
| | 903 | ((short*)(fmt.p_extra))[1] = i_subpacket_h; |
|---|
| | 904 | ((short*)(fmt.p_extra))[2] = i_flavor; |
|---|
| | 905 | ((short*)(fmt.p_extra))[3] = i_coded_frame_size; |
|---|
| | 906 | ((short*)(fmt.p_extra))[4] = fmt.i_extra; |
|---|
| | 907 | if( fmt.i_extra ) memcpy( fmt.p_extra + 10, p_peek, fmt.i_extra ); |
|---|
| | 908 | fmt.i_extra += 10; |
|---|
| | 909 | break; |
|---|
| | 910 | |
|---|
| | 911 | default: |
|---|
| | 912 | msg_Dbg( p_demux, " - unknown audio codec=%4.4s", |
|---|
| | 913 | (char*)&fmt.i_codec ); |
|---|
| | 914 | break; |
|---|
| | 915 | } |
|---|
| | 916 | |
|---|
| | 917 | if( fmt.i_codec != 0 ) |
|---|
| | 918 | { |
|---|
| | 919 | msg_Dbg( p_demux, " - extra data=%d", fmt.i_extra ); |
|---|
| | 920 | { |
|---|
| | 921 | int i; |
|---|
| | 922 | for( i = 0; i < fmt.i_extra; i++ ) |
|---|
| | 923 | { |
|---|
| | 924 | msg_Dbg( p_demux, " data[%d] = 0x%x", i, |
|---|
| | 925 | ((uint8_t*)fmt.p_extra)[i] ); |
|---|
| | 926 | } |
|---|
| | 927 | } |
|---|
| | 928 | |
|---|
| | 929 | tk = malloc( sizeof( real_track_t ) ); |
|---|
| | 930 | tk->i_id = i_num; |
|---|
| | 931 | tk->fmt = fmt; |
|---|
| | 932 | tk->i_frame = 0; |
|---|
| | 933 | tk->p_frame = NULL; |
|---|
| | 934 | tk->p_es = es_out_Add( p_demux->out, &fmt ); |
|---|
| | 935 | |
|---|
| | 936 | TAB_APPEND( p_sys->i_track, p_sys->track, tk ); |
|---|
| | 937 | } |
|---|
| | 938 | } |
|---|
| | 939 | |
|---|
| | 940 | return VLC_SUCCESS; |
|---|
| | 941 | } |
|---|