Function turbojpeg_sys::tj3CompressFromYUVPlanes8
source · pub unsafe extern "C" fn tj3CompressFromYUVPlanes8(
handle: tjhandle,
srcPlanes: *const *const c_uchar,
width: c_int,
strides: *const c_int,
height: c_int,
jpegBuf: *mut *mut c_uchar,
jpegSize: *mut size_t
) -> c_int
Expand description
Compress a set of 8-bit-per-sample Y, U (Cb), and V (Cr) image planes into an 8-bit-per-sample JPEG image.
@param handle handle to a TurboJPEG instance that has been initialized for compression
@param srcPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if compressing a grayscale image) that contain a YUV source image to be compressed. These planes can be contiguous or non-contiguous in memory. The size of each plane should match the value returned by #tj3YUVPlaneSize() for the given image width, height, strides, and level of chrominance subsampling (see #TJPARAM_SUBSAMP.) Refer to @ref YUVnotes “YUV Image Format Notes” for more details.
@param width width (in pixels) of the source image. If the width is not an even multiple of the MCU block width (see #tjMCUWidth), then an intermediate buffer copy will be performed.
@param strides an array of integers, each specifying the number of bytes per
row in the corresponding plane of the YUV source image. Setting the stride
for any plane to 0 is the same as setting it to the plane width (see
@ref YUVnotes “YUV Image Format Notes”.) If strides
is NULL, then the
strides for all planes will be set to their respective plane widths. You
can adjust the strides in order to specify an arbitrary amount of row
padding in each plane or to create a JPEG image from a subregion of a larger
planar YUV image.
@param height height (in pixels) of the source image. If the height is not an even multiple of the MCU block height (see #tjMCUHeight), then an intermediate buffer copy will be performed.
@param jpegBuf address of a pointer to a byte buffer that will receive the
JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to
accommodate the size of the JPEG image. Thus, you can choose to:
-# pre-allocate the JPEG buffer with an arbitrary size using #tj3Alloc() and
let TurboJPEG grow the buffer as needed,
-# set *jpegBuf
to NULL to tell TurboJPEG to allocate the buffer for you,
or
-# pre-allocate the buffer to a “worst case” size determined by calling
#tj3JPEGBufSize(). This should ensure that the buffer never has to be
re-allocated. (Setting #TJPARAM_NOREALLOC guarantees that it won’t be.)
.
If you choose option 1, then *jpegSize
should be set to the size of your
pre-allocated buffer. In any case, unless you have set #TJPARAM_NOREALLOC,
you should always check *jpegBuf
upon return from this function, as it may
have changed.
@param jpegSize pointer to a size_t variable that holds the size of the JPEG
buffer. If *jpegBuf
points to a pre-allocated buffer, then *jpegSize
should be set to the size of the buffer. Upon return, *jpegSize
will
contain the size of the JPEG image (in bytes.) If *jpegBuf
points to a
JPEG buffer that is being reused from a previous call to one of the JPEG
compression functions, then *jpegSize
is ignored.
@return 0 if successful, or -1 if an error occurred (see #tj3GetErrorStr() and #tj3GetErrorCode().)