[vlc-commits] demux: ts: parse SL config
Francois Cartegnie
git at videolan.org
Fri Mar 27 14:39:55 CET 2015
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Mar 27 01:38:22 2015 +0100| [cd273368d7f6ce512876dbf98de6a08200b69a7d] | committer: Francois Cartegnie
demux: ts: parse SL config
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cd273368d7f6ce512876dbf98de6a08200b69a7d
---
modules/demux/mpeg4_iod.c | 62 ++++++++++++++++++++++++++++++++++++++++++---
modules/demux/mpeg4_iod.h | 33 ++++++++++++++++++++++++
2 files changed, 91 insertions(+), 4 deletions(-)
diff --git a/modules/demux/mpeg4_iod.c b/modules/demux/mpeg4_iod.c
index b827656..5958ab4 100644
--- a/modules/demux/mpeg4_iod.c
+++ b/modules/demux/mpeg4_iod.c
@@ -27,6 +27,7 @@
#endif
#include <vlc_common.h>
+#include <vlc_bits.h>
#include "mpeg4_iod.h"
@@ -108,17 +109,69 @@ typedef union
iod_descriptor_t *p_iod;
es_mpeg4_descriptor_t *es_descr;
decoder_config_descriptor_t *p_dec_config;
+ sl_config_descriptor_t *sl_descr;
} iod_read_params_t;
static uint8_t IOD_Desc_Read( vlc_object_t *, unsigned *, const uint8_t **, uint8_t, uint8_t, iod_read_params_t params );
+#define SL_Predefined_Custom 0x00
+#define SL_Predefined_NULL 0x01
+#define SL_Predefined_MP4 0x02
static bool IOD_SLDesc_Read( vlc_object_t *p_object, unsigned i_data, const uint8_t *p_data,
iod_read_params_t params )
{
- VLC_UNUSED(p_object);
- VLC_UNUSED(i_data);
- VLC_UNUSED(p_data);
- VLC_UNUSED(params);
+ sl_config_descriptor_t *sl_descr = params.sl_descr;
+
+ uint8_t i_predefined = IODGetBytes( &i_data, &p_data, 1 );
+ switch( i_predefined )
+ {
+ case SL_Predefined_Custom:
+ if( i_data < 15 )
+ return false;
+ sl_descr->i_flags = IODGetBytes( &i_data, &p_data, 1 );
+ sl_descr->i_timestamp_resolution = IODGetBytes( &i_data, &p_data, 4 );
+ sl_descr->i_OCR_resolution = IODGetBytes( &i_data, &p_data, 4 );
+ sl_descr->i_timestamp_length = IODGetBytes( &i_data, &p_data, 4 );
+ sl_descr->i_OCR_length = IODGetBytes( &i_data, &p_data, 1 );
+ sl_descr->i_AU_length = IODGetBytes( &i_data, &p_data, 1 );
+ sl_descr->i_instant_bitrate_length = IODGetBytes( &i_data, &p_data, 1 );
+ uint16_t i16 = IODGetBytes( &i_data, &p_data, 2 );
+ sl_descr->i_degradation_priority_length = i16 >> 12;
+ sl_descr->i_AU_seqnum_length = (i16 >> 7) & 0x1f;
+ sl_descr->i_packet_seqnum_length = (i16 >> 2) & 0x1f;
+ break;
+ case SL_Predefined_NULL:
+ memset( sl_descr, 0, sizeof(*sl_descr) );
+ sl_descr->i_timestamp_resolution = 1000;
+ sl_descr->i_timestamp_length = 32;
+ break;
+ case SL_Predefined_MP4:
+ memset( sl_descr, 0, sizeof(*sl_descr) );
+ sl_descr->i_flags = USE_TIMESTAMPS_FLAG;
+ break;
+ default:
+ /* reserved */
+ return false;
+ }
+
+ if( sl_descr->i_flags & USE_DURATION_FLAG )
+ {
+ if( i_data < 8 )
+ return false;
+ sl_descr->i_timescale = IODGetBytes( &i_data, &p_data, 4 );
+ sl_descr->i_accessunit_duration = IODGetBytes( &i_data, &p_data, 2 );
+ sl_descr->i_compositionunit_duration = IODGetBytes( &i_data, &p_data, 2 );
+ }
+
+ if( (sl_descr->i_flags & USE_TIMESTAMPS_FLAG) == 0 )
+ {
+ bs_t s;
+ bs_init( &s, p_data, i_data );
+ sl_descr->i_startdecoding_timestamp = bs_read( &s, sl_descr->i_timestamp_length );
+ sl_descr->i_startcomposition_timestamp = bs_read( &s, sl_descr->i_timestamp_length );
+ }
+
+ iod_debug( p_object, " * read sl desc predefined: 0x%x", i_predefined );
return true;
}
@@ -200,6 +253,7 @@ static bool IOD_ESDesc_Read( vlc_object_t *p_object, unsigned i_data, const uint
return false;
/* SLDescr */
+ params.sl_descr = &es_descr->sl_descr;
IOD_Desc_Read( p_object, &i_data, &p_data, IODTag_SLDescr, 1, params );
/* IPI / IP / IPMP ... */
diff --git a/modules/demux/mpeg4_iod.h b/modules/demux/mpeg4_iod.h
index af47b2b..00bf2c1 100644
--- a/modules/demux/mpeg4_iod.h
+++ b/modules/demux/mpeg4_iod.h
@@ -19,6 +19,38 @@
*****************************************************************************/
#define ES_DESCRIPTOR_COUNT 255
+typedef enum
+{
+ USE_ACCESS_UNIT_START_FLAG = 1 << 7,
+ USE_ACCESS_UNIT_END_FLAG = 1 << 6,
+ USE_RANDOM_ACCESS_POINT_FLAG = 1 << 5,
+ HAS_RANDOM_ACCESS_UNITS_ONLY_FLAG = 1 << 4,
+ USE_PADDING_FLAG = 1 << 3,
+ USE_TIMESTAMPS_FLAG = 1 << 2,
+ USE_IDLE_FLAG = 1 << 1,
+ USE_DURATION_FLAG = 1
+} sl_config_flags;
+
+typedef struct
+{
+ uint32_t i_timestamp_resolution;
+ uint32_t i_OCR_resolution;
+ uint8_t i_flags;
+ uint8_t i_timestamp_length;
+ uint8_t i_OCR_length;
+ uint8_t i_AU_length;
+ uint8_t i_instant_bitrate_length;
+ uint8_t i_degradation_priority_length;
+ uint8_t i_AU_seqnum_length;
+ uint8_t i_packet_seqnum_length;
+
+ uint32_t i_timescale;
+ uint16_t i_accessunit_duration;
+ uint16_t i_compositionunit_duration;
+
+ uint64_t i_startdecoding_timestamp;
+ uint64_t i_startcomposition_timestamp;
+} sl_config_descriptor_t;
typedef struct
{
@@ -38,6 +70,7 @@ typedef struct
char *psz_url;
decoder_config_descriptor_t dec_descr;
+ sl_config_descriptor_t sl_descr;
} es_mpeg4_descriptor_t;
More information about the vlc-commits
mailing list