Index: libmpdemux/asfheader.c =================================================================== --- libmpdemux/asfheader.c £¨ÐÞ¶©°æ 21328£© +++ libmpdemux/asfheader.c £¨¹¤×÷¿½±´£© @@ -6,6 +6,7 @@ #include #include "config.h" +#include "common.h" #include "mp_msg.h" #include "help_mp.h" @@ -60,23 +61,19 @@ const char asf_ext_stream_header[16] = {0xCB, 0xA5, 0xE6, 0x14, 0x72, 0xC6, 0x32, 0x43, 0x83, 0x99, 0xA9, 0x69, 0x52, 0x06, 0x5B, 0x5A}; - -// the variable string is modify in this function -void pack_asf_string(char* string, int length) { - int i,j; - if( string==NULL ) return; - for( i=0, j=0; i= 0) { ASF_content_description_t *contenth = (ASF_content_description_t *)&hdr[pos]; char *string=NULL; + uint16_t* wstring = NULL; + uint16_t len; pos += sizeof(ASF_content_description_t); if (pos > hdr_len) goto len_err_out; le2me_ASF_content_description_t(contenth); mp_msg(MSGT_HEADER,MSGL_V,"\n"); // extract the title - if( contenth->title_size!=0 ) { - string = &hdr[pos]; - pos += contenth->title_size; + if((len = contenth->title_size) != 0) { + wstring = (uint16_t*)&hdr[pos]; + pos += len; if (pos > hdr_len) goto len_err_out; + string = malloc(len * 2); + get_ucs2str(wstring, len, string, len * 2); if( mp_msg_test(MSGT_HEADER,MSGL_V) ) - print_asf_string(" Title: ", string, contenth->title_size); - else - pack_asf_string(string, contenth->title_size); + mp_msg(MSGT_HEADER,MSGL_V,"%s%s\n", " Title: ", string); demux_info_add(demuxer, "name", string); + free(string); } // extract the author - if( contenth->author_size!=0 ) { - string = &hdr[pos]; - pos += contenth->author_size; + if((len = contenth->author_size) != 0) { + wstring = (uint16_t*)&hdr[pos]; + pos += len; if (pos > hdr_len) goto len_err_out; + string = malloc(len * 2); + get_ucs2str(wstring, len, string, len * 2); if( mp_msg_test(MSGT_HEADER,MSGL_V) ) - print_asf_string(" Author: ", string, contenth->author_size); - else - pack_asf_string(string, contenth->author_size); + mp_msg(MSGT_HEADER,MSGL_V,"%s%s\n", " Author: ", string); demux_info_add(demuxer, "author", string); + free(string); } // extract the copyright - if( contenth->copyright_size!=0 ) { - string = &hdr[pos]; - pos += contenth->copyright_size; + if((len = contenth->copyright_size) != 0) { + wstring = (uint16_t*)&hdr[pos]; + pos += len; if (pos > hdr_len) goto len_err_out; + string = malloc(len * 2); + get_ucs2str(wstring, len, string, len * 2); if( mp_msg_test(MSGT_HEADER,MSGL_V) ) - print_asf_string(" Copyright: ", string, contenth->copyright_size); - else - pack_asf_string(string, contenth->copyright_size); + mp_msg(MSGT_HEADER,MSGL_V,"%s%s\n", " Copyright: ", string); demux_info_add(demuxer, "copyright", string); + free(string); } // extract the comment - if( contenth->comment_size!=0 ) { - string = &hdr[pos]; - pos += contenth->comment_size; + if((len = contenth->comment_size) != 0) { + wstring = (uint16_t*)&hdr[pos]; + pos += len; if (pos > hdr_len) goto len_err_out; + string = malloc(len * 2); + get_ucs2str(wstring, len, string, len * 2); if( mp_msg_test(MSGT_HEADER,MSGL_V) ) - print_asf_string(" Comment: ", string, contenth->comment_size); - else - pack_asf_string(string, contenth->comment_size); + mp_msg(MSGT_HEADER,MSGL_V,"%s%s\n", " Comment: ", string); demux_info_add(demuxer, "comments", string); + free(string); } // extract the rating - if( contenth->rating_size!=0 ) { - string = &hdr[pos]; - pos += contenth->rating_size; + if((len = contenth->rating_size) != 0) { + wstring = (uint16_t*)&hdr[pos]; + pos += len; if (pos > hdr_len) goto len_err_out; + string = malloc(len * 2); + get_ucs2str(wstring, len, string, len * 2); if( mp_msg_test(MSGT_HEADER,MSGL_V) ) - print_asf_string(" Rating: ", string, contenth->rating_size); + mp_msg(MSGT_HEADER,MSGL_V,"%s%s\n", " Rating: ", string); + free(string); } mp_msg(MSGT_HEADER,MSGL_V,"\n"); }