Changeset 7cf2ad43cf62ac71a286ea593782e6f4292e8b5c

Show
Ignore:
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
  • modules/demux/asf/asf.c

    r24f83b8 r7cf2ad4  
    680680                    GetWLE( p_data ), p_sp->i_stream_number ); 
    681681        } 
    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 ) ) 
    684686        { 
    685687            es_format_t  fmt; 
     
    687689 
    688690            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] ) ); 
    690693            fmt.video.i_width = GetDWLE( p_data + 4 ); 
    691694            fmt.video.i_height= GetDWLE( p_data + 8 ); 
    692695 
    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 ) ) 
    694698            { 
    695699                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 ) ); 
    697702                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        } 
    700738 
    701739            tk->i_cat = VIDEO_ES; 
  • modules/demux/asf/libasf.c

    r6c84da2 r7cf2ad4  
    349349 
    350350        /* get name */ 
    351         record.psz_name = malloc( i_name/2 ); 
     351        record.psz_name = malloc( i_name/2 + 1 ); 
    352352        for( j = 0; j < i_name/2; j++ ) 
    353353        { 
    354354            record.psz_name[j] = GetWLE( p_peek + i_peek ); i_peek += 2; 
    355355        } 
     356        record.psz_name[j] = 0; /* just to make sure */ 
    356357 
    357358        /* get data */ 
    358359        if( record.i_type == ASF_METADATA_TYPE_STRING ) 
    359360        { 
    360             record.p_data = malloc( i_data/2 ); 
     361            record.p_data = malloc( i_data/2 + 1 ); 
    361362            record.i_data = i_data/2; 
    362363            for( j = 0; j < i_data/2; j++ ) 
     
    364365                record.p_data[j] = GetWLE( p_peek + i_peek ); i_peek += 2; 
    365366            } 
    366  
     367            record.p_data[j] = 0; /* just to make sure */ 
     368 
     369#ifdef ASF_DEBUG 
    367370            msg_Dbg( s, "metadata: %s=%s", record.psz_name, record.p_data ); 
     371#endif 
    368372        } 
    369373        else if( record.i_type == ASF_METADATA_TYPE_BYTE ) 
     
    374378            p_peek += i_data; 
    375379 
     380#ifdef ASF_DEBUG 
    376381            msg_Dbg( s, "metadata: %s (%i bytes)", record.psz_name, 
    377382                     record.i_data ); 
     383#endif 
    378384        } 
    379385        else 
     
    392398            } 
    393399 
     400#ifdef ASF_DEBUG 
    394401            msg_Dbg( s, "metadata: %s=%i", record.psz_name, record.i_val ); 
     402#endif 
    395403        } 
    396404 
     
    881889    p_root->p_fp    = NULL; 
    882890    p_root->p_index = NULL; 
    883     p_root->p_hdr_ext = NULL; 
    884891    p_root->p_metadata = NULL; 
    885892 
     
    904911                p_root->p_index = (asf_object_index_t*)p_obj; 
    905912                break; 
    906             case( ASF_OBJECT_TYPE_HEADER_EXTENSION ): 
    907                 p_root->p_hdr_ext = (asf_object_header_extension_t*)p_obj; 
    908                 break; 
    909913            default: 
    910914                msg_Warn( (vlc_object_t*)s, "unknow object found" ); 
     
    936940        if( p_root->p_fp ) 
    937941        { 
    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 ) 
    940946            { 
    941947                p_root->p_metadata = 
    942                     ASF_FindObject( p_root->p_hdr_ext, 
     948                    ASF_FindObject( p_hdr_ext, 
    943949                                    &asf_object_metadata_guid, 0 ); 
    944950            } 
     
    946952            return p_root; 
    947953        } 
    948         msg_Warn( (vlc_object_t*)s, "cannot find file properties object" ); 
     954        msg_Warn( s, "cannot find file properties object" ); 
    949955    } 
    950956 
  • modules/demux/asf/libasf.h

    r6c84da2 r7cf2ad4  
    309309    /* could be NULL if !b_seekable or not-present */ 
    310310    asf_object_index_t  *p_index; 
    311     asf_object_header_extension_t *p_hdr_ext; 
    312311 
    313312    /* from asf_object_header_t */