[vlc-commits] Smooth Streaming: read PacketSize attribute in manifest

Frédéric Yhuel git at videolan.org
Fri Sep 28 11:06:35 CEST 2012


vlc | branch: master | Frédéric Yhuel <yhuelf at gmail.com> | Thu Sep 27 21:03:08 2012 +0200| [344f840663a64ba37bdcfeea993fbae1f6ac65da] | committer: Jean-Baptiste Kempf

Smooth Streaming: read PacketSize attribute in manifest

PacketSize == nBlockAlign attribute of WaveFormatEx structure.

We also remove the AvgBytesPerSec attribute of the quality_level_t
structure, since it is equal to the Bitrate attribute (divided per 8).

This fixes streams done by Expression Encoder 4

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=344f840663a64ba37bdcfeea993fbae1f6ac65da
---

 modules/demux/mp4/libmp4.c                |    2 --
 modules/demux/mp4/libmp4.h                |    2 --
 modules/demux/mp4/mp4.c                   |    2 +-
 modules/stream_filter/smooth/downloader.c |   16 +++++++---------
 modules/stream_filter/smooth/smooth.c     |    3 ++-
 modules/stream_filter/smooth/smooth.h     |    2 --
 6 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index afd4dd1..1fd580b 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -514,9 +514,7 @@ static int MP4_ReadBox_stra( stream_t *p_stream, MP4_Box_t *p_box )
     MP4_GET4BYTES( p_stra->SamplingRate );
     MP4_GET4BYTES( p_stra->Channels );
     MP4_GET4BYTES( p_stra->BitsPerSample );
-    MP4_GET4BYTES( p_stra->PacketSize );
     MP4_GET4BYTES( p_stra->AudioTag );
-    MP4_GET4BYTES( p_stra->AvgBytesPerSec );
     MP4_GET2BYTES( p_stra->nBlockAlign );
 
     MP4_GET1BYTE( i_reserved );
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 22ede26..3e5cb97 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -1140,10 +1140,8 @@ typedef struct
     uint32_t MaxWidth;
     uint32_t MaxHeight;
     uint32_t SamplingRate;
-    uint32_t AvgBytesPerSec;
     uint32_t Channels;
     uint32_t BitsPerSample;
-    uint32_t PacketSize;
     uint32_t AudioTag;
     uint16_t nBlockAlign;
     uint8_t  cpd_len;
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index d2e0530..e210d4d 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -3207,7 +3207,7 @@ static int MP4_frg_TrackCreate( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_
             fmt->audio.i_bitspersample = p_data->BitsPerSample;
             fmt->audio.i_blockalign = p_data->nBlockAlign;
 
-            fmt->i_bitrate = p_data->AvgBytesPerSec * 8;
+            fmt->i_bitrate = p_data->Bitrate;
 
             ret = MP4_SetCodecExtraData( fmt, p_data );
             if( ret != VLC_SUCCESS )
diff --git a/modules/stream_filter/smooth/downloader.c b/modules/stream_filter/smooth/downloader.c
index f019af2..8f6582e 100644
--- a/modules/stream_filter/smooth/downloader.c
+++ b/modules/stream_filter/smooth/downloader.c
@@ -277,8 +277,8 @@ static int get_new_chunks( stream_t *s, chunk_t *ck )
     return VLC_SUCCESS;
 }
 
-#define STRA_SIZE 342
-#define SMOO_SIZE (STRA_SIZE * 3 + 24) /* 1050 */
+#define STRA_SIZE 334
+#define SMOO_SIZE (STRA_SIZE * 3 + 24) /* 1026 */
 
 /* SmooBox is a very simple MP4 box, used only to pass information
  * to the demux layer. As this box is not aimed to travel accross networks,
@@ -356,16 +356,14 @@ static int build_smoo_box( stream_t *s, uint8_t *smoo_box )
         ((uint32_t *)stra_box)[20] = bswap32( qlvl->SamplingRate );
         ((uint32_t *)stra_box)[21] = bswap32( qlvl->Channels );
         ((uint32_t *)stra_box)[22] = bswap32( qlvl->BitsPerSample );
-        ((uint32_t *)stra_box)[23] = bswap32( qlvl->PacketSize );
-        ((uint32_t *)stra_box)[24] = bswap32( qlvl->AudioTag );
-        ((uint32_t *)stra_box)[25] = bswap32( qlvl->AvgBytesPerSec );
-        ((uint16_t *)stra_box)[52] = bswap16( qlvl->nBlockAlign );
+        ((uint32_t *)stra_box)[23] = bswap32( qlvl->AudioTag );
+        ((uint16_t *)stra_box)[48] = bswap16( qlvl->nBlockAlign );
 
-        stra_box[106] = stra_box[107] = stra_box[108] = 0; /* reserved */
+        stra_box[98] = stra_box[99] = stra_box[100] = 0; /* reserved */
         assert( strlen( qlvl->CodecPrivateData ) < 512 );
-        stra_box[109] = strlen( qlvl->CodecPrivateData ) / 2;
+        stra_box[101] = strlen( qlvl->CodecPrivateData ) / 2;
         uint8_t *binary_cpd = decode_string_hex_to_binary( qlvl->CodecPrivateData );
-        memcpy( stra_box + 110, binary_cpd, stra_box[109] );
+        memcpy( stra_box + 102, binary_cpd, stra_box[101] );
         free( binary_cpd );
     }
 
diff --git a/modules/stream_filter/smooth/smooth.c b/modules/stream_filter/smooth/smooth.c
index 08bf8ed..07e8391 100644
--- a/modules/stream_filter/smooth/smooth.c
+++ b/modules/stream_filter/smooth/smooth.c
@@ -247,6 +247,8 @@ static int parse_Manifest( stream_t *s )
                             ql->Index = strtol( value, NULL, 10 );
                         if( !strcmp( name, "Bitrate" ) )
                             ql->Bitrate = strtoull( value, NULL, 10 );
+                        if( !strcmp( name, "PacketSize" ) )
+                            ql->nBlockAlign = strtoull( value, NULL, 10 );
                         if( !strcmp( name, "FourCC" ) )
                             ql->FourCC = VLC_FOURCC( value[0], value[1],
                                                      value[2], value[3] );
@@ -263,7 +265,6 @@ static int parse_Manifest( stream_t *s )
 
                             ql->Channels = ((uint16_t *)WaveFormatEx)[1];
                             ql->SamplingRate = ((uint32_t *)WaveFormatEx)[1];
-                            ql->AvgBytesPerSec = ((uint32_t *)WaveFormatEx)[2];
                             ql->nBlockAlign = ((uint16_t *)WaveFormatEx)[6];
                             ql->BitsPerSample = ((uint16_t *)WaveFormatEx)[7];
                             free( WaveFormatEx );
diff --git a/modules/stream_filter/smooth/smooth.h b/modules/stream_filter/smooth/smooth.h
index 6d85567..da8283d 100644
--- a/modules/stream_filter/smooth/smooth.h
+++ b/modules/stream_filter/smooth/smooth.h
@@ -60,10 +60,8 @@ typedef struct quality_level_s
     unsigned        MaxWidth;
     unsigned        MaxHeight;
     unsigned        SamplingRate;
-    unsigned        AvgBytesPerSec;
     unsigned        Channels;
     unsigned        BitsPerSample;
-    unsigned        PacketSize;
     unsigned        AudioTag;
     unsigned        nBlockAlign;
     unsigned        id;



More information about the vlc-commits mailing list