1 #include "colormodels.h"
2 #include "funcprotos.h"
4 #include "workarounds.h"
13 unsigned char *work_buffer
;
14 } quicktime_v308_codec_t
;
16 static int delete_codec(quicktime_video_map_t
*vtrack
)
18 quicktime_v308_codec_t
*codec
;
20 codec
= ((quicktime_codec_t
*)vtrack
->codec
)->priv
;
21 if(codec
->work_buffer
) free(codec
->work_buffer
);
26 static int reads_colormodel(quicktime_t
*file
,
30 return (colormodel
== BC_RGB888
||
31 colormodel
== BC_RGBA8888
||
32 colormodel
== BC_RGB161616
||
33 colormodel
== BC_RGBA16161616
||
34 colormodel
== BC_YUV888
||
35 colormodel
== BC_YUVA8888
||
36 colormodel
== BC_YUV161616
||
37 colormodel
== BC_YUVA16161616
||
38 colormodel
== BC_RGB8
||
39 colormodel
== BC_RGB565
||
40 colormodel
== BC_BGR888
||
41 colormodel
== BC_BGR8888
);
44 static int writes_colormodel(quicktime_t
*file
,
48 return (colormodel
== BC_RGB888
||
49 colormodel
== BC_RGBA8888
||
50 colormodel
== BC_RGB161616
||
51 colormodel
== BC_RGBA16161616
||
52 colormodel
== BC_YUV888
||
53 colormodel
== BC_YUVA8888
||
54 colormodel
== BC_YUV161616
||
55 colormodel
== BC_YUVA16161616
);
71 static int decode(quicktime_t
*file
, unsigned char **row_pointers
, int track
)
76 quicktime_video_map_t
*vtrack
= &(file
->vtracks
[track
]);
77 quicktime_v308_codec_t
*codec
= ((quicktime_codec_t
*)vtrack
->codec
)->priv
;
78 int width
= vtrack
->track
->tkhd
.track_width
;
79 int height
= vtrack
->track
->tkhd
.track_height
;
80 unsigned char **input_rows
;
81 if(!codec
->work_buffer
)
82 codec
->work_buffer
= malloc(vtrack
->track
->tkhd
.track_width
*
83 vtrack
->track
->tkhd
.track_height
*
88 quicktime_set_video_position(file
, vtrack
->current_position
, track
);
89 bytes
= quicktime_frame_size(file
, vtrack
->current_position
, track
);
90 result
= !quicktime_read_data(file
, codec
->work_buffer
, bytes
);
94 input_rows
= malloc(sizeof(unsigned char*) * height
);
95 for(i
= 0; i
< height
; i
++)
96 input_rows
[i
] = codec
->work_buffer
+ i
* width
* 3;
98 cmodel_transfer(row_pointers
,
131 static int encode(quicktime_t
*file
, unsigned char **row_pointers
, int track
)
133 int64_t offset
= quicktime_position(file
);
134 quicktime_video_map_t
*vtrack
= &(file
->vtracks
[track
]);
135 quicktime_v308_codec_t
*codec
= ((quicktime_codec_t
*)vtrack
->codec
)->priv
;
136 quicktime_trak_t
*trak
= vtrack
->track
;
137 int width
= vtrack
->track
->tkhd
.track_width
;
138 int height
= vtrack
->track
->tkhd
.track_height
;
139 int bytes
= width
* height
* 3;
141 unsigned char **output_rows
;
143 quicktime_atom_t chunk_atom
;
144 if(!codec
->work_buffer
)
145 codec
->work_buffer
= malloc(vtrack
->track
->tkhd
.track_width
*
146 vtrack
->track
->tkhd
.track_height
*
150 output_rows
= malloc(sizeof(unsigned char*) * height
);
151 for(i
= 0; i
< height
; i
++)
152 output_rows
[i
] = codec
->work_buffer
+ i
* width
* 3;
154 cmodel_transfer(output_rows
,
176 quicktime_write_chunk_header(file
, trak
, &chunk_atom
);
177 result
= !quicktime_write_data(file
, codec
->work_buffer
, bytes
);
178 quicktime_write_chunk_footer(file
,
180 vtrack
->current_chunk
,
184 vtrack
->current_chunk
++;
190 void quicktime_init_codec_v308(quicktime_video_map_t
*vtrack
)
192 quicktime_codec_t
*codec_base
= (quicktime_codec_t
*)vtrack
->codec
;
194 /* Init public items */
195 codec_base
->priv
= calloc(1, sizeof(quicktime_v308_codec_t
));
196 codec_base
->delete_vcodec
= delete_codec
;
197 codec_base
->decode_video
= decode
;
198 codec_base
->encode_video
= encode
;
199 codec_base
->decode_audio
= 0;
200 codec_base
->encode_audio
= 0;
201 codec_base
->reads_colormodel
= reads_colormodel
;
202 codec_base
->writes_colormodel
= writes_colormodel
;
203 codec_base
->fourcc
= QUICKTIME_YUV444
;
204 codec_base
->title
= "Component Y'CbCr 8-bit 4:4:4";
205 codec_base
->desc
= "Component Y'CbCr 8-bit 4:4:4";