1 #include "funcprotos.h"
4 void quicktime_dref_table_init(quicktime_dref_table_t
*table
)
12 table
->flags
= 0x0001;
13 table
->data_reference
= malloc(256);
14 table
->data_reference
[0] = 0;
17 void quicktime_dref_table_delete(quicktime_dref_table_t
*table
)
19 if(table
->data_reference
) free(table
->data_reference
);
20 table
->data_reference
= 0;
23 void quicktime_read_dref_table(quicktime_t
*file
, quicktime_dref_table_t
*table
)
25 table
->size
= quicktime_read_int32(file
);
26 quicktime_read_char32(file
, table
->type
);
27 table
->version
= quicktime_read_char(file
);
28 table
->flags
= quicktime_read_int24(file
);
29 if(table
->data_reference
) free(table
->data_reference
);
31 table
->data_reference
= malloc(table
->size
);
33 quicktime_read_data(file
, table
->data_reference
, table
->size
- 12);
34 table
->data_reference
[table
->size
- 12] = 0;
37 void quicktime_write_dref_table(quicktime_t
*file
, quicktime_dref_table_t
*table
)
39 int len
= strlen(table
->data_reference
);
40 quicktime_write_int32(file
, 12 + len
);
41 quicktime_write_char32(file
, table
->type
);
42 quicktime_write_char(file
, table
->version
);
43 quicktime_write_int24(file
, table
->flags
);
45 quicktime_write_data(file
, table
->data_reference
, len
);
48 void quicktime_dref_table_dump(quicktime_dref_table_t
*table
)
50 printf(" data reference table (dref)\n");
51 printf(" type %c%c%c%c\n", table
->type
[0], table
->type
[1], table
->type
[2], table
->type
[3]);
52 printf(" version %d\n", table
->version
);
53 printf(" flags %d\n", table
->flags
);
54 printf(" data %s\n", table
->data_reference
);
58 void quicktime_dref_init(quicktime_dref_t
*dref
)
62 dref
->total_entries
= 0;
66 void quicktime_dref_init_all(quicktime_dref_t
*dref
)
68 if(!dref
->total_entries
)
70 dref
->total_entries
= 1;
71 dref
->table
= (quicktime_dref_table_t
*)malloc(sizeof(quicktime_dref_table_t
) * dref
->total_entries
);
72 quicktime_dref_table_init(&(dref
->table
[0]));
76 void quicktime_dref_delete(quicktime_dref_t
*dref
)
81 for(i
= 0; i
< dref
->total_entries
; i
++)
82 quicktime_dref_table_delete(&(dref
->table
[i
]));
85 dref
->total_entries
= 0;
88 void quicktime_dref_dump(quicktime_dref_t
*dref
)
92 printf(" data reference (dref)\n");
93 printf(" version %d\n", dref
->version
);
94 printf(" flags %d\n", dref
->flags
);
95 for(i
= 0; i
< dref
->total_entries
; i
++)
97 quicktime_dref_table_dump(&(dref
->table
[i
]));
101 void quicktime_read_dref(quicktime_t
*file
, quicktime_dref_t
*dref
)
105 dref
->version
= quicktime_read_char(file
);
106 dref
->flags
= quicktime_read_int24(file
);
107 dref
->total_entries
= quicktime_read_int32(file
);
108 dref
->table
= (quicktime_dref_table_t
*)malloc(sizeof(quicktime_dref_table_t
) * dref
->total_entries
);
109 for(i
= 0; i
< dref
->total_entries
; i
++)
111 quicktime_dref_table_init(&(dref
->table
[i
]));
112 quicktime_read_dref_table(file
, &(dref
->table
[i
]));
116 void quicktime_write_dref(quicktime_t
*file
, quicktime_dref_t
*dref
)
119 quicktime_atom_t atom
;
120 quicktime_atom_write_header(file
, &atom
, "dref");
122 quicktime_write_char(file
, dref
->version
);
123 quicktime_write_int24(file
, dref
->flags
);
124 quicktime_write_int32(file
, dref
->total_entries
);
126 for(i
= 0; i
< dref
->total_entries
; i
++)
128 quicktime_write_dref_table(file
, &(dref
->table
[i
]));
130 quicktime_atom_write_footer(file
, &atom
);