1 #include "colormodels.h"
2 #include "funcprotos.h"
4 #include "workarounds.h"
12 unsigned char *work_buffer
;
13 } quicktime_v408_codec_t
;
15 static int delete_codec(quicktime_video_map_t
*vtrack
)
17 quicktime_v408_codec_t
*codec
;
19 codec
= ((quicktime_codec_t
*)vtrack
->codec
)->priv
;
20 if(codec
->work_buffer
) free(codec
->work_buffer
);
25 static int reads_colormodel(quicktime_t
*file
,
29 return (colormodel
== BC_RGB888
||
30 colormodel
== BC_RGBA8888
||
31 colormodel
== BC_RGB161616
||
32 colormodel
== BC_RGBA16161616
||
33 colormodel
== BC_YUV888
||
34 colormodel
== BC_YUVA8888
||
35 colormodel
== BC_YUV161616
||
36 colormodel
== BC_YUVA16161616
||
37 colormodel
== BC_RGB8
||
38 colormodel
== BC_RGB565
||
39 colormodel
== BC_BGR888
||
40 colormodel
== BC_BGR8888
);
43 static int writes_colormodel(quicktime_t
*file
,
47 return (colormodel
== BC_RGB888
||
48 colormodel
== BC_RGBA8888
||
49 colormodel
== BC_RGB161616
||
50 colormodel
== BC_RGBA16161616
||
51 colormodel
== BC_YUV888
||
52 colormodel
== BC_YUVA8888
||
53 colormodel
== BC_YUV161616
||
54 colormodel
== BC_YUVA16161616
);
70 static int decode(quicktime_t
*file
, unsigned char **row_pointers
, int track
)
75 quicktime_video_map_t
*vtrack
= &(file
->vtracks
[track
]);
76 quicktime_v408_codec_t
*codec
= ((quicktime_codec_t
*)vtrack
->codec
)->priv
;
77 int width
= vtrack
->track
->tkhd
.track_width
;
78 int height
= vtrack
->track
->tkhd
.track_height
;
79 unsigned char **input_rows
;
80 if(!codec
->work_buffer
)
81 codec
->work_buffer
= malloc(vtrack
->track
->tkhd
.track_width
*
82 vtrack
->track
->tkhd
.track_height
*
86 quicktime_set_video_position(file
, vtrack
->current_position
, track
);
87 bytes
= quicktime_frame_size(file
, vtrack
->current_position
, track
);
88 result
= !quicktime_read_data(file
, codec
->work_buffer
, bytes
);
92 input_rows
= malloc(sizeof(unsigned char*) * height
);
93 for(i
= 0; i
< height
; i
++)
94 input_rows
[i
] = codec
->work_buffer
+ i
* width
* 4;
96 cmodel_transfer(row_pointers
,
129 static int encode(quicktime_t
*file
, unsigned char **row_pointers
, int track
)
131 int64_t offset
= quicktime_position(file
);
132 quicktime_video_map_t
*vtrack
= &(file
->vtracks
[track
]);
133 quicktime_v408_codec_t
*codec
= ((quicktime_codec_t
*)vtrack
->codec
)->priv
;
134 quicktime_trak_t
*trak
= vtrack
->track
;
135 int width
= vtrack
->track
->tkhd
.track_width
;
136 int height
= vtrack
->track
->tkhd
.track_height
;
137 int bytes
= width
* height
* 4;
139 unsigned char **output_rows
;
141 quicktime_atom_t chunk_atom
;
142 if(!codec
->work_buffer
)
143 codec
->work_buffer
= malloc(vtrack
->track
->tkhd
.track_width
*
144 vtrack
->track
->tkhd
.track_height
*
148 output_rows
= malloc(sizeof(unsigned char*) * height
);
149 for(i
= 0; i
< height
; i
++)
150 output_rows
[i
] = codec
->work_buffer
+ i
* width
* 4;
152 cmodel_transfer(output_rows
,
174 quicktime_write_chunk_header(file
, trak
, &chunk_atom
);
175 result
= !quicktime_write_data(file
, codec
->work_buffer
, bytes
);
176 quicktime_write_chunk_footer(file
,
178 vtrack
->current_chunk
,
182 vtrack
->current_chunk
++;
188 void quicktime_init_codec_v408(quicktime_video_map_t
*vtrack
)
190 quicktime_codec_t
*codec_base
= (quicktime_codec_t
*)vtrack
->codec
;
192 /* Init public items */
193 codec_base
->priv
= calloc(1, sizeof(quicktime_v408_codec_t
));
194 codec_base
->delete_vcodec
= delete_codec
;
195 codec_base
->decode_video
= decode
;
196 codec_base
->encode_video
= encode
;
197 codec_base
->decode_audio
= 0;
198 codec_base
->encode_audio
= 0;
199 codec_base
->reads_colormodel
= reads_colormodel
;
200 codec_base
->writes_colormodel
= writes_colormodel
;
201 codec_base
->fourcc
= QUICKTIME_YUVA4444
;
202 codec_base
->title
= "Component Y'CbCrA 8-bit 4:4:4:4";
203 codec_base
->desc
= "Component Y'CbCrA 8-bit 4:4:4:4";