Changeset 7cf2ad43cf62ac71a286ea593782e6f4292e8b5c
- Timestamp:
- 10/09/04 14:43:08
(4 years ago)
- Author:
- Gildas Bazin <gbazin@videolan.org>
- git-committer:
- Gildas Bazin <gbazin@videolan.org> 1094820188 +0000
- git-parent:
[6c84da28c658041cf1d9090d4414f0b5acfc947b]
- git-author:
- Gildas Bazin <gbazin@videolan.org> 1094820188 +0000
- Message:
* modules/demux/asf/*: get video aspect ratio from metadata object.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r24f83b8 |
r7cf2ad4 |
|
| 680 | 680 | GetWLE( p_data ), p_sp->i_stream_number ); |
|---|
| 681 | 681 | } |
|---|
| 682 | | else if( ASF_CmpGUID( &p_sp->i_stream_type, &asf_object_stream_type_video ) && |
|---|
| 683 | | p_sp->i_type_specific_data_length >= 11 + sizeof( BITMAPINFOHEADER ) ) |
|---|
| | 682 | else if( ASF_CmpGUID( &p_sp->i_stream_type, |
|---|
| | 683 | &asf_object_stream_type_video ) && |
|---|
| | 684 | p_sp->i_type_specific_data_length >= 11 + |
|---|
| | 685 | sizeof( BITMAPINFOHEADER ) ) |
|---|
| 684 | 686 | { |
|---|
| 685 | 687 | es_format_t fmt; |
|---|
| … | … | |
| 687 | 689 | |
|---|
| 688 | 690 | es_format_Init( &fmt, VIDEO_ES, |
|---|
| 689 | | VLC_FOURCC( p_data[16], p_data[17], p_data[18], p_data[19] ) ); |
|---|
| | 691 | VLC_FOURCC( p_data[16], p_data[17], |
|---|
| | 692 | p_data[18], p_data[19] ) ); |
|---|
| 690 | 693 | fmt.video.i_width = GetDWLE( p_data + 4 ); |
|---|
| 691 | 694 | fmt.video.i_height= GetDWLE( p_data + 8 ); |
|---|
| 692 | 695 | |
|---|
| 693 | | if( p_sp->i_type_specific_data_length > 11 + sizeof( BITMAPINFOHEADER ) ) |
|---|
| | 696 | if( p_sp->i_type_specific_data_length > 11 + |
|---|
| | 697 | sizeof( BITMAPINFOHEADER ) ) |
|---|
| 694 | 698 | { |
|---|
| 695 | 699 | fmt.i_extra = __MIN( GetDWLE( p_data ), |
|---|
| 696 | | p_sp->i_type_specific_data_length - 11 - sizeof( BITMAPINFOHEADER ) ); |
|---|
| | 700 | p_sp->i_type_specific_data_length - 11 - |
|---|
| | 701 | sizeof( BITMAPINFOHEADER ) ); |
|---|
| 697 | 702 | fmt.p_extra = malloc( fmt.i_extra ); |
|---|
| 698 | | memcpy( fmt.p_extra, &p_data[sizeof( BITMAPINFOHEADER )], fmt.i_extra ); |
|---|
| 699 | | } |
|---|
| | 703 | memcpy( fmt.p_extra, &p_data[sizeof( BITMAPINFOHEADER )], |
|---|
| | 704 | fmt.i_extra ); |
|---|
| | 705 | } |
|---|
| | 706 | |
|---|
| | 707 | /* Look for an aspect ratio */ |
|---|
| | 708 | if( p_sys->p_root->p_metadata ) |
|---|
| | 709 | { |
|---|
| | 710 | asf_object_metadata_t *p_meta = p_sys->p_root->p_metadata; |
|---|
| | 711 | int i, i_aspect_x = 0, i_aspect_y = 0; |
|---|
| | 712 | |
|---|
| | 713 | for( i = 0; i < p_meta->i_record_entries_count; i++ ) |
|---|
| | 714 | { |
|---|
| | 715 | if( !strcmp( p_meta->record[i].psz_name, "AspectRatioX" ) ) |
|---|
| | 716 | { |
|---|
| | 717 | if( (!i_aspect_x && !p_meta->record[i].i_stream) || |
|---|
| | 718 | p_meta->record[i].i_stream == |
|---|
| | 719 | p_sp->i_stream_number ) |
|---|
| | 720 | i_aspect_x = p_meta->record[i].i_val; |
|---|
| | 721 | } |
|---|
| | 722 | if( !strcmp( p_meta->record[i].psz_name, "AspectRatioY" ) ) |
|---|
| | 723 | { |
|---|
| | 724 | if( (!i_aspect_y && !p_meta->record[i].i_stream) || |
|---|
| | 725 | p_meta->record[i].i_stream == |
|---|
| | 726 | p_sp->i_stream_number ) |
|---|
| | 727 | i_aspect_y = p_meta->record[i].i_val; |
|---|
| | 728 | } |
|---|
| | 729 | } |
|---|
| | 730 | |
|---|
| | 731 | if( i_aspect_x && i_aspect_y ) |
|---|
| | 732 | { |
|---|
| | 733 | fmt.video.i_aspect = i_aspect_x * fmt.video.i_width * |
|---|
| | 734 | VOUT_ASPECT_FACTOR / |
|---|
| | 735 | (int64_t)fmt.video.i_height / i_aspect_y; |
|---|
| | 736 | } |
|---|
| | 737 | } |
|---|
| 700 | 738 | |
|---|
| 701 | 739 | tk->i_cat = VIDEO_ES; |
|---|
| r6c84da2 |
r7cf2ad4 |
|
| 349 | 349 | |
|---|
| 350 | 350 | /* get name */ |
|---|
| 351 | | record.psz_name = malloc( i_name/2 ); |
|---|
| | 351 | record.psz_name = malloc( i_name/2 + 1 ); |
|---|
| 352 | 352 | for( j = 0; j < i_name/2; j++ ) |
|---|
| 353 | 353 | { |
|---|
| 354 | 354 | record.psz_name[j] = GetWLE( p_peek + i_peek ); i_peek += 2; |
|---|
| 355 | 355 | } |
|---|
| | 356 | record.psz_name[j] = 0; /* just to make sure */ |
|---|
| 356 | 357 | |
|---|
| 357 | 358 | /* get data */ |
|---|
| 358 | 359 | if( record.i_type == ASF_METADATA_TYPE_STRING ) |
|---|
| 359 | 360 | { |
|---|
| 360 | | record.p_data = malloc( i_data/2 ); |
|---|
| | 361 | record.p_data = malloc( i_data/2 + 1 ); |
|---|
| 361 | 362 | record.i_data = i_data/2; |
|---|
| 362 | 363 | for( j = 0; j < i_data/2; j++ ) |
|---|
| … | … | |
| 364 | 365 | record.p_data[j] = GetWLE( p_peek + i_peek ); i_peek += 2; |
|---|
| 365 | 366 | } |
|---|
| 366 | | |
|---|
| | 367 | record.p_data[j] = 0; /* just to make sure */ |
|---|
| | 368 | |
|---|
| | 369 | #ifdef ASF_DEBUG |
|---|
| 367 | 370 | msg_Dbg( s, "metadata: %s=%s", record.psz_name, record.p_data ); |
|---|
| | 371 | #endif |
|---|
| 368 | 372 | } |
|---|
| 369 | 373 | else if( record.i_type == ASF_METADATA_TYPE_BYTE ) |
|---|
| … | … | |
| 374 | 378 | p_peek += i_data; |
|---|
| 375 | 379 | |
|---|
| | 380 | #ifdef ASF_DEBUG |
|---|
| 376 | 381 | msg_Dbg( s, "metadata: %s (%i bytes)", record.psz_name, |
|---|
| 377 | 382 | record.i_data ); |
|---|
| | 383 | #endif |
|---|
| 378 | 384 | } |
|---|
| 379 | 385 | else |
|---|
| … | … | |
| 392 | 398 | } |
|---|
| 393 | 399 | |
|---|
| | 400 | #ifdef ASF_DEBUG |
|---|
| 394 | 401 | msg_Dbg( s, "metadata: %s=%i", record.psz_name, record.i_val ); |
|---|
| | 402 | #endif |
|---|
| 395 | 403 | } |
|---|
| 396 | 404 | |
|---|
| … | … | |
| 881 | 889 | p_root->p_fp = NULL; |
|---|
| 882 | 890 | p_root->p_index = NULL; |
|---|
| 883 | | p_root->p_hdr_ext = NULL; |
|---|
| 884 | 891 | p_root->p_metadata = NULL; |
|---|
| 885 | 892 | |
|---|
| … | … | |
| 904 | 911 | p_root->p_index = (asf_object_index_t*)p_obj; |
|---|
| 905 | 912 | break; |
|---|
| 906 | | case( ASF_OBJECT_TYPE_HEADER_EXTENSION ): |
|---|
| 907 | | p_root->p_hdr_ext = (asf_object_header_extension_t*)p_obj; |
|---|
| 908 | | break; |
|---|
| 909 | 913 | default: |
|---|
| 910 | 914 | msg_Warn( (vlc_object_t*)s, "unknow object found" ); |
|---|
| … | … | |
| 936 | 940 | if( p_root->p_fp ) |
|---|
| 937 | 941 | { |
|---|
| 938 | | |
|---|
| 939 | | if( p_root->p_hdr_ext != NULL ) |
|---|
| | 942 | asf_object_t *p_hdr_ext = |
|---|
| | 943 | ASF_FindObject( p_root->p_hdr, |
|---|
| | 944 | &asf_object_header_extension_guid, 0 ); |
|---|
| | 945 | if( p_hdr_ext ) |
|---|
| 940 | 946 | { |
|---|
| 941 | 947 | p_root->p_metadata = |
|---|
| 942 | | ASF_FindObject( p_root->p_hdr_ext, |
|---|
| | 948 | ASF_FindObject( p_hdr_ext, |
|---|
| 943 | 949 | &asf_object_metadata_guid, 0 ); |
|---|
| 944 | 950 | } |
|---|
| … | … | |
| 946 | 952 | return p_root; |
|---|
| 947 | 953 | } |
|---|
| 948 | | msg_Warn( (vlc_object_t*)s, "cannot find file properties object" ); |
|---|
| | 954 | msg_Warn( s, "cannot find file properties object" ); |
|---|
| 949 | 955 | } |
|---|
| 950 | 956 | |
|---|
| r6c84da2 |
r7cf2ad4 |
|
| 309 | 309 | /* could be NULL if !b_seekable or not-present */ |
|---|
| 310 | 310 | asf_object_index_t *p_index; |
|---|
| 311 | | asf_object_header_extension_t *p_hdr_ext; |
|---|
| 312 | 311 | |
|---|
| 313 | 312 | /* from asf_object_header_t */ |
|---|