Fixed (partially) parsing of E-AC3 not using 1536 samples per frame.
authorLaurent Aimar <fenrir@videolan.org>
Tue, 5 May 2009 22:10:55 +0000 (00:10 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Tue, 5 May 2009 22:10:55 +0000 (00:10 +0200)
modules/codec/a52.c
modules/codec/a52.h

index 21dd406..474a1d0 100644 (file)
@@ -359,7 +359,7 @@ static uint8_t *GetOutBuffer( decoder_t *p_dec, void **pp_out_buffer )
     p_dec->fmt_out.audio.i_channels = p_sys->frame.i_channels;
     if( p_dec->fmt_out.audio.i_bytes_per_frame < p_sys->frame.i_size )
         p_dec->fmt_out.audio.i_bytes_per_frame = p_sys->frame.i_size;
-    p_dec->fmt_out.audio.i_frame_length = A52_FRAME_NB;
+    p_dec->fmt_out.audio.i_frame_length = p_sys->frame.i_samples;
 
     p_dec->fmt_out.audio.i_original_channels = p_sys->frame.i_channels_conf;
     p_dec->fmt_out.audio.i_physical_channels =
@@ -391,11 +391,11 @@ static aout_buffer_t *GetAoutBuffer( decoder_t *p_dec )
     decoder_sys_t *p_sys = p_dec->p_sys;
     aout_buffer_t *p_buf;
 
-    p_buf = decoder_NewAudioBuffer( p_dec, A52_FRAME_NB  );
+    p_buf = decoder_NewAudioBuffer( p_dec, p_sys->frame.i_samples );
     if( p_buf == NULL ) return NULL;
 
     p_buf->start_date = aout_DateGet( &p_sys->end_date );
-    p_buf->end_date = aout_DateIncrement( &p_sys->end_date, A52_FRAME_NB );
+    p_buf->end_date = aout_DateIncrement( &p_sys->end_date, p_sys->frame.i_samples );
 
     return p_buf;
 }
@@ -414,7 +414,7 @@ static block_t *GetSoutBuffer( decoder_t *p_dec )
     p_block->i_pts = p_block->i_dts = aout_DateGet( &p_sys->end_date );
 
     p_block->i_length =
-        aout_DateIncrement( &p_sys->end_date, A52_FRAME_NB ) - p_block->i_pts;
+        aout_DateIncrement( &p_sys->end_date, p_sys->frame.i_samples ) - p_block->i_pts;
 
     return p_block;
 }
index 824ef10..204be33 100644 (file)
@@ -54,6 +54,7 @@ typedef struct
     unsigned int i_bitrate;
 
     unsigned int i_size;
+    unsigned int i_samples;
 
 } vlc_a52_header_t;
 
@@ -122,6 +123,8 @@ static inline int vlc_a52_header_ParseAc3( vlc_a52_header_t *p_header,
     default:
         return VLC_EGENERIC;
     }
+    p_header->i_samples = 6*256;
+
     p_header->b_eac3 = false;
     return VLC_SUCCESS;
 }
@@ -170,6 +173,7 @@ static inline int vlc_a52_header_ParseEac3( vlc_a52_header_t *p_header,
     p_header->i_channels      = p_acmod[i_acmod].i_count + i_lfeon;
     p_header->i_channels_conf = p_acmod[i_acmod].i_configuration | ( i_lfeon ? AOUT_CHAN_LFE : 0);
     p_header->i_bitrate = 8 * p_header->i_size * (p_header->i_rate) / (i_numblkscod * 256);
+    p_header->i_samples = i_numblkscod * 256;
 
     p_header->b_eac3 = true;
     return VLC_SUCCESS;