msg_Dbg( p_demux, "added new audio stream(codec:0x%x,ID:%d)",
GetWLE( p_data ), p_sp->i_stream_number );
}
- else if( ASF_CmpGUID( &p_sp->i_stream_type, &asf_object_stream_type_video ) &&
- p_sp->i_type_specific_data_length >= 11 + sizeof( BITMAPINFOHEADER ) )
+ else if( ASF_CmpGUID( &p_sp->i_stream_type,
+ &asf_object_stream_type_video ) &&
+ p_sp->i_type_specific_data_length >= 11 +
+ sizeof( BITMAPINFOHEADER ) )
{
es_format_t fmt;
uint8_t *p_data = &p_sp->p_type_specific_data[11];
es_format_Init( &fmt, VIDEO_ES,
- VLC_FOURCC( p_data[16], p_data[17], p_data[18], p_data[19] ) );
+ VLC_FOURCC( p_data[16], p_data[17],
+ p_data[18], p_data[19] ) );
fmt.video.i_width = GetDWLE( p_data + 4 );
fmt.video.i_height= GetDWLE( p_data + 8 );
- if( p_sp->i_type_specific_data_length > 11 + sizeof( BITMAPINFOHEADER ) )
+ if( p_sp->i_type_specific_data_length > 11 +
+ sizeof( BITMAPINFOHEADER ) )
{
fmt.i_extra = __MIN( GetDWLE( p_data ),
- p_sp->i_type_specific_data_length - 11 - sizeof( BITMAPINFOHEADER ) );
+ p_sp->i_type_specific_data_length - 11 -
+ sizeof( BITMAPINFOHEADER ) );
fmt.p_extra = malloc( fmt.i_extra );
- memcpy( fmt.p_extra, &p_data[sizeof( BITMAPINFOHEADER )], fmt.i_extra );
+ memcpy( fmt.p_extra, &p_data[sizeof( BITMAPINFOHEADER )],
+ fmt.i_extra );
}
+ /* Look for an aspect ratio */
+ if( p_sys->p_root->p_metadata )
+ {
+ asf_object_metadata_t *p_meta = p_sys->p_root->p_metadata;
+ int i, i_aspect_x = 0, i_aspect_y = 0;
+
+ for( i = 0; i < p_meta->i_record_entries_count; i++ )
+ {
+ if( !strcmp( p_meta->record[i].psz_name, "AspectRatioX" ) )
+ {
+ if( (!i_aspect_x && !p_meta->record[i].i_stream) ||
+ p_meta->record[i].i_stream ==
+ p_sp->i_stream_number )
+ i_aspect_x = p_meta->record[i].i_val;
+ }
+ if( !strcmp( p_meta->record[i].psz_name, "AspectRatioY" ) )
+ {
+ if( (!i_aspect_y && !p_meta->record[i].i_stream) ||
+ p_meta->record[i].i_stream ==
+ p_sp->i_stream_number )
+ i_aspect_y = p_meta->record[i].i_val;
+ }
+ }
+
+ if( i_aspect_x && i_aspect_y )
+ {
+ fmt.video.i_aspect = i_aspect_x * fmt.video.i_width *
+ VOUT_ASPECT_FACTOR /
+ (int64_t)fmt.video.i_height / i_aspect_y;
+ }
+ }
+
tk->i_cat = VIDEO_ES;
tk->p_es = es_out_Add( p_demux->out, &fmt );
es_format_Clean( &fmt );
record.p_data = 0;
/* get name */
- record.psz_name = malloc( i_name/2 );
+ record.psz_name = malloc( i_name/2 + 1 );
for( j = 0; j < i_name/2; j++ )
{
record.psz_name[j] = GetWLE( p_peek + i_peek ); i_peek += 2;
}
+ record.psz_name[j] = 0; /* just to make sure */
/* get data */
if( record.i_type == ASF_METADATA_TYPE_STRING )
{
- record.p_data = malloc( i_data/2 );
+ record.p_data = malloc( i_data/2 + 1 );
record.i_data = i_data/2;
for( j = 0; j < i_data/2; j++ )
{
record.p_data[j] = GetWLE( p_peek + i_peek ); i_peek += 2;
}
+ record.p_data[j] = 0; /* just to make sure */
+#ifdef ASF_DEBUG
msg_Dbg( s, "metadata: %s=%s", record.psz_name, record.p_data );
+#endif
}
else if( record.i_type == ASF_METADATA_TYPE_BYTE )
{
memcpy( record.p_data, p_peek + i_peek, i_data );
p_peek += i_data;
+#ifdef ASF_DEBUG
msg_Dbg( s, "metadata: %s (%i bytes)", record.psz_name,
record.i_data );
+#endif
}
else
{
record.i_val = GetWLE( p_peek + i_peek ); i_peek += 2;
}
+#ifdef ASF_DEBUG
msg_Dbg( s, "metadata: %s=%i", record.psz_name, record.i_val );
+#endif
}
p_meta->i_record_entries_count++;
p_root->p_data = NULL;
p_root->p_fp = NULL;
p_root->p_index = NULL;
- p_root->p_hdr_ext = NULL;
p_root->p_metadata = NULL;
for( ; ; )
case( ASF_OBJECT_TYPE_INDEX ):
p_root->p_index = (asf_object_index_t*)p_obj;
break;
- case( ASF_OBJECT_TYPE_HEADER_EXTENSION ):
- p_root->p_hdr_ext = (asf_object_header_extension_t*)p_obj;
- break;
default:
msg_Warn( (vlc_object_t*)s, "unknow object found" );
break;
if( p_root->p_fp )
{
-
- if( p_root->p_hdr_ext != NULL )
+ asf_object_t *p_hdr_ext =
+ ASF_FindObject( p_root->p_hdr,
+ &asf_object_header_extension_guid, 0 );
+ if( p_hdr_ext )
{
p_root->p_metadata =
- ASF_FindObject( p_root->p_hdr_ext,
+ ASF_FindObject( p_hdr_ext,
&asf_object_metadata_guid, 0 );
}
return p_root;
}
- msg_Warn( (vlc_object_t*)s, "cannot find file properties object" );
+ msg_Warn( s, "cannot find file properties object" );
}
/* Invalid file */