1 #include "funcprotos.h"
5 void quicktime_dref_table_init(quicktime_dref_table_t
*table
)
13 table
->flags
= 0x0001;
14 table
->data_reference
= malloc(256);
15 table
->data_reference
[0] = 0;
18 void quicktime_dref_table_delete(quicktime_dref_table_t
*table
)
20 if(table
->data_reference
) free(table
->data_reference
);
21 table
->data_reference
= 0;
24 void quicktime_read_dref_table(quicktime_t
*file
, quicktime_dref_table_t
*table
)
26 table
->size
= quicktime_read_int32(file
);
27 quicktime_read_char32(file
, table
->type
);
28 table
->version
= quicktime_read_char(file
);
29 table
->flags
= quicktime_read_int24(file
);
30 if(table
->data_reference
) free(table
->data_reference
);
32 table
->data_reference
= malloc(table
->size
);
34 quicktime_read_data(file
, table
->data_reference
, table
->size
- 12);
35 table
->data_reference
[table
->size
- 12] = 0;
38 void quicktime_write_dref_table(quicktime_t
*file
, quicktime_dref_table_t
*table
)
40 int len
= strlen(table
->data_reference
);
41 quicktime_write_int32(file
, 12 + len
);
42 quicktime_write_char32(file
, table
->type
);
43 quicktime_write_char(file
, table
->version
);
44 quicktime_write_int24(file
, table
->flags
);
46 quicktime_write_data(file
, table
->data_reference
, len
);
49 void quicktime_dref_table_dump(quicktime_dref_table_t
*table
)
51 printf(" data reference table (dref)\n");
52 printf(" type %c%c%c%c\n", table
->type
[0], table
->type
[1], table
->type
[2], table
->type
[3]);
53 printf(" version %d\n", table
->version
);
54 printf(" flags %d\n", table
->flags
);
55 printf(" data %s\n", table
->data_reference
);
59 void quicktime_dref_init(quicktime_dref_t
*dref
)
63 dref
->total_entries
= 0;
67 void quicktime_dref_init_all(quicktime_dref_t
*dref
)
69 if(!dref
->total_entries
)
71 dref
->total_entries
= 1;
72 dref
->table
= (quicktime_dref_table_t
*)malloc(sizeof(quicktime_dref_table_t
) * dref
->total_entries
);
73 quicktime_dref_table_init(&(dref
->table
[0]));
77 void quicktime_dref_delete(quicktime_dref_t
*dref
)
82 for(i
= 0; i
< dref
->total_entries
; i
++)
83 quicktime_dref_table_delete(&(dref
->table
[i
]));
86 dref
->total_entries
= 0;
89 void quicktime_dref_dump(quicktime_dref_t
*dref
)
93 printf(" data reference (dref)\n");
94 printf(" version %d\n", dref
->version
);
95 printf(" flags %d\n", dref
->flags
);
96 for(i
= 0; i
< dref
->total_entries
; i
++)
98 quicktime_dref_table_dump(&(dref
->table
[i
]));
102 void quicktime_read_dref(quicktime_t
*file
, quicktime_dref_t
*dref
)
106 dref
->version
= quicktime_read_char(file
);
107 dref
->flags
= quicktime_read_int24(file
);
108 dref
->total_entries
= quicktime_read_int32(file
);
109 dref
->table
= (quicktime_dref_table_t
*)malloc(sizeof(quicktime_dref_table_t
) * dref
->total_entries
);
110 for(i
= 0; i
< dref
->total_entries
; i
++)
112 quicktime_dref_table_init(&(dref
->table
[i
]));
113 quicktime_read_dref_table(file
, &(dref
->table
[i
]));
117 void quicktime_write_dref(quicktime_t
*file
, quicktime_dref_t
*dref
)
120 quicktime_atom_t atom
;
121 quicktime_atom_write_header(file
, &atom
, "dref");
123 quicktime_write_char(file
, dref
->version
);
124 quicktime_write_int24(file
, dref
->flags
);
125 quicktime_write_int32(file
, dref
->total_entries
);
127 for(i
= 0; i
< dref
->total_entries
; i
++)
129 quicktime_write_dref_table(file
, &(dref
->table
[i
]));
131 quicktime_atom_write_footer(file
, &atom
);