void v4lconvert_destroy(struct v4lconvert_data *data) { if (data->jdec) { unsigned char *comps[3] = { NULL, NULL, NULL }; tinyjpeg_set_components(data->jdec, comps, 3); tinyjpeg_free(data->jdec); } free(data->convert_buf); free(data->rotate_buf); free(data->convert_pixfmt_buf); free(data); }
void v4lconvert_destroy(struct v4lconvert_data *data) { v4lprocessing_destroy(data->processing); v4lcontrol_destroy(data->control); if (data->jdec) { unsigned char *comps[3] = { NULL, NULL, NULL }; tinyjpeg_set_components(data->jdec, comps, 3); tinyjpeg_free(data->jdec); } v4lconvert_helper_cleanup(data); free(data->convert1_buf); free(data->convert2_buf); free(data->rotate90_buf); free(data->flip_buf); free(data->convert_pixfmt_buf); free(data); }
unsigned char *RasterMapManager::DecodeJPEG(unsigned char *readBuffer, unsigned int length, unsigned int& width, unsigned int& height) { unsigned char *imgComponents[3]; static struct jdec_private *jdec = 0; if (jdec != 0) { tinyjpeg_free(jdec); } jdec = tinyjpeg_init(); if (tinyjpeg_parse_header(jdec, readBuffer, length) < 0) { LogPrintf("RasterMapManager: JPEG codec error: %s", tinyjpeg_get_errorstring(jdec)); return NULL; } tinyjpeg_decode(jdec, TINYJPEG_FMT_RGB24); tinyjpeg_get_components(jdec, imgComponents); tinyjpeg_get_size(jdec, &width, &height); return imgComponents[0]; }
void v4lconvert_destroy(struct v4lconvert_data *data) { v4lprocessing_destroy(data->processing); v4lcontrol_destroy(data->control); if (data->tinyjpeg) { unsigned char *comps[3] = { NULL, NULL, NULL }; tinyjpeg_set_components(data->tinyjpeg, comps, 3); tinyjpeg_free(data->tinyjpeg); } if (data->cinfo_initialized) jpeg_destroy_decompress(&data->cinfo); v4lconvert_helper_cleanup(data); free(data->convert1_buf); free(data->convert2_buf); free(data->rotate90_buf); free(data->flip_buf); free(data->convert_pixfmt_buf); free(data->previous_frame); free(data); }