6 int quicktime_init_codec_rtjpeg(quicktime_video_map_t
*vtrack
, int jpeg_type
)
8 quicktime_rtjpeg_codec_t
*codec
= &(vtrack
->codecs
.rtjpeg_codec
);
11 codec
->output_buffer
= 0;
12 codec
->buffer_size
= codec
->image_size
= 0;
13 RTjpeg_init_compress(&(codec
->compress_struct
), vtrack
->track
->tkhd
.track_width
, vtrack
->track
->tkhd
.track_height
, (int)((float)codec
->quality
/ 100 * 255));
14 RTjpeg_init_decompress(&(codec
->decompress_struct
), vtrack
->track
->tkhd
.track_width
, vtrack
->track
->tkhd
.track_height
);
15 codec
->yuv_frame
= malloc(vtrack
->track
->tkhd
.track_width
* vtrack
->track
->tkhd
.track_height
* 3);
18 int quicktime_delete_codec_rtjpeg(quicktime_video_map_t
*vtrack
)
20 quicktime_rtjpeg_codec_t
*codec
= &(vtrack
->codecs
.rtjpeg_codec
);
21 if(codec
->output_buffer
)
22 free(codec
->output_buffer
);
24 free(codec
->yuv_frame
);
25 codec
->output_buffer
= 0;
29 int quicktime_decode_rtjpeg(quicktime_t
*file
, unsigned char **row_pointers
, int track
)
34 quicktime_trak_t
*trak
= file
->vtracks
[track
].track
;
35 quicktime_video_map_t
*vtrack
= &(file
->vtracks
[track
]);
36 quicktime_rtjpeg_codec_t
*codec
= &(vtrack
->codecs
.rtjpeg_codec
);
38 /* Read the entire chunk from disk. */
39 quicktime_set_video_position(file
, vtrack
->current_position
, track
);
40 size
= quicktime_frame_size(file
, vtrack
->current_position
, track
);
41 if(size
> codec
->buffer_size
&& codec
->output_buffer
)
43 free(codec
->output_buffer
);
44 codec
->output_buffer
= 0;
46 if(!codec
->output_buffer
)
48 codec
->output_buffer
= malloc(size
);
49 codec
->buffer_size
= size
;
51 result
= !quicktime_read_data(file
, codec
->output_buffer
, size
);
55 /* Decompress the frame */
56 RTjpeg_init_Q(&(codec
->decompress_struct
), codec
->output_buffer
[0]);
57 RTjpeg_decompressYUV420(&(codec
->decompress_struct
), &(codec
->output_buffer
[8]), codec
->yuv_frame
);
58 RTjpeg_yuv420rgb(&(codec
->decompress_struct
), codec
->yuv_frame
, row_pointers
[0], 0);
65 int quicktime_encode_jpeg(quicktime_t
*file
, unsigned char **row_pointers
, int track
)
67 long offset
= quicktime_position(file
);
70 quicktime_trak_t
*trak
= file
->vtracks
[track
].track
;
71 quicktime_video_map_t
*vtrack
= &(file
->vtracks
[track
]);
72 quicktime_jpeg_codec_t
*codec
= &(vtrack
->codecs
.jpeg_codec
);
76 bytes
= quicktime_position(file
) - offset
;
77 quicktime_update_tables(file
,
80 vtrack
->current_chunk
,
81 vtrack
->current_position
,
85 vtrack
->current_chunk
++;