Skip to content

Commit abcd8ed

Browse files
committed
core: add basic support for the tfxd UUID box.
1 parent ee28f8d commit abcd8ed

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

core/box.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,9 @@ struct lsmash_root_tag
21302130
#define ISOM_BOX_TYPE_HVCC lsmash_form_iso_box_type( LSMASH_4CC( 'h', 'v', 'c', 'C' ) )
21312131
#define ISOM_BOX_TYPE_WFEX lsmash_form_iso_box_type( LSMASH_4CC( 'w', 'f', 'e', 'x' ) )
21322132

2133+
/* MS Smooth Streaming UUID boxes */
2134+
#define ISOM_BOX_TYPE_TFXD lsmash_form_iso_box_type( LSMASH_4CC( 't', 'f', 'x', 'd' ) )
2135+
21332136
#define QT_BOX_TYPE_ALLF lsmash_form_qtff_box_type( LSMASH_4CC( 'A', 'l', 'l', 'F' ) )
21342137
#define QT_BOX_TYPE_CLEF lsmash_form_qtff_box_type( LSMASH_4CC( 'c', 'l', 'e', 'f' ) )
21352138
#define QT_BOX_TYPE_CLIP lsmash_form_qtff_box_type( LSMASH_4CC( 'c', 'l', 'i', 'p' ) )

core/read.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838

3939
static int isom_bs_read_box_common( lsmash_bs_t *bs, isom_box_t *box )
4040
{
41+
static const uint8_t tfxd_uuid[] = {
42+
0x6d, 0x1d, 0x9b, 0x05, 0x42, 0xd5, 0x44, 0xe6,
43+
0x80, 0xe2, 0x14, 0x1d, 0xaf, 0xf7, 0x57, 0xb2
44+
};
45+
uint8_t read_uuid[16] = { 0 };
46+
4147
assert( bs && box && box->file );
4248
/* Reset the counter so that we can use it to get position within the box. */
4349
lsmash_bs_reset_counter( bs );
@@ -80,13 +86,24 @@ static int isom_bs_read_box_common( lsmash_bs_t *bs, isom_box_t *box )
8086
if( box->type.fourcc == ISOM_BOX_TYPE_UUID.fourcc
8187
&& box->size >= lsmash_bs_count( bs ) + 16 )
8288
{
83-
/* Get UUID. */
84-
lsmash_box_type_t *type = &box->type;
89+
/* First parse the UUID into a local variable. */
8590
uint64_t temp64 = lsmash_bs_get_be64( bs );
86-
type->user.fourcc = (temp64 >> 32) & 0xffffffff;
87-
LSMASH_SET_BE32( &type->user.id[0], temp64 );
91+
LSMASH_SET_BE64( &read_uuid[0], temp64 );
8892
temp64 = lsmash_bs_get_be64( bs );
89-
LSMASH_SET_BE64( &type->user.id[4], temp64 );
93+
LSMASH_SET_BE64( &read_uuid[8], temp64 );
94+
95+
/* Compare against known vendor extension UUIDs */
96+
if(!memcmp( read_uuid, tfxd_uuid, 16)) {
97+
box->type.fourcc = ISOM_BOX_TYPE_TFXD.fourcc;
98+
} else {
99+
/* This is a generic UUID box, mark it down as such */
100+
lsmash_box_type_t *type = &box->type;
101+
102+
LSMASH_SET_BE32( &type->user.fourcc, *((uint32_t *)&read_uuid[0]) );
103+
LSMASH_SET_LE32( &type->user.id[0], *((uint32_t *)&read_uuid[4]) );
104+
LSMASH_SET_LE32( &type->user.id[4], *((uint32_t *)&read_uuid[8]) );
105+
LSMASH_SET_LE32( &type->user.id[8], *((uint32_t *)&read_uuid[12]) );
106+
}
90107
}
91108
return bs->eob;
92109
}

0 commit comments

Comments
 (0)