The JPEG encoder object provides methods to compress video frames to the JPEG image formats. It is presented in the class library for editing and format-conversion purposes. The object permits compression based on a quality factor.
To learn more about the UMSJPEGEncoder object, see:
For introductory information, see Video Codec Objects.
To avoid name collision on defines, integer values have been captured as enumerated lists. The set of valid values from an enumerated list can vary with the application. The detailed method descriptions describe the valid or possible values for the specific use. The enumerated lists that are defined for this object are:
enum ReturnCode { Success, Failure, UnsupportedFormat, InvalidSubimage, InvalidImageSize, Uninitialized, InvalidQualityFactor };
enum ImageFormatIn { RGB24, Mono8, RGB };
enum SubsampleDirection { NoSubsampling, Vertical, Horizontal, HorizontalVertical };
The JPEG encoder object defines the following type definitions:
This method accepts an image frame and produces a JPEG compressed image.
Note: The compress_frame_seq method is preferred to the compress_frame method because it provides the same method using sequence parameters rather than pointer parameters. This allows the object to be used in distributed applications written with DSOM.
in char *image_frame | Pointer to the start of the image data. |
in char *comp_frame | Pointer to the start of the compressed frame data. |
This method accepts an image frame and produces a JPEG compressed image. This method is similar to the compress_frame method. However, this method is preferred because the buffers are specified as sequences instead of as pointers.
in ImageFrame image_frame | The image data is passed in as an ImageFrame sequence of octets. |
inout CompressedFrame comp_frame | The compressed frame is returned as a CompressedFrame sequence of octets. |
This method allows the application to query the size of the compressed image.
The return value is the number of bytes in the compressed image.
This method allows the application to query the current image format.
This method allows the application to query the current image size.
inout long width | Current setting of the x dimension. |
inout long height | Current setting of the y dimension. |
This method allows the application to query the current quality factor.
The return value is the current quality factor setting. Valid values are between 0 and 100.
This method allows the application to query the current sub-image parameters.
This method sets the format of the input image data that the encoder accepts.
in ImageFormatIn image_format | Possible values are Mono8, RGB24, and RGB. |
This method allows the application to specify the dimensions of the input image frame.
in l ong width | Number of pixels in the x dimension. |
in long height | Number of pixels in the y dimension. |
The quality factor enables you to trade off compressed file size against quality of the reconstructed image. The higher the factor setting, the larger the JPEG compressed frame and the better the quality. The range of the factor is between 0 and 100.
in long factor | The quality factor of JPEG compression. |
This method allows a subframe within an image to be compressed. This method does not need to be called if the full image is to be encoded. The offsets must be non-negative integer values. The set_image_size method must also be called to specify the actual input image size.
For color images, the red, green, and blue (RGB) input image components are converted to Y, U, and V (YUV) components before compression. This method provides subsampling of the chrominance components before compression. Calling this method with the Horizontal or Vertical argument causes the chrominance to be subsampled by a factor of two in the horizontal or vertical direction. If the HorizontalVertical argument is used, subsampling takes place in both directions. If the argument NoSubsampling is used, the chrominance components are not subsampled.
in SubsampleDirection key | The directions of subsampling. Possible values are NoSubsampling, Vertical, Horizontal, and HorizontalVertical. |
For introductory information, see Video Codec Objects.