Image JPEG Encode (nvmimg_jpgenc)
The NvMedia Image JPEG Encode application, nvmimg_jpgenc, demonstrates how to encode image surfaces into JPEG bitstreams using NvMedia JPEG encode APIs. It parses the command line with required parameter sets for JPEG encoder including:
• Input file name
• Resolution
• Output bitstream file name
• Quality, etc.
It then reads the input file into the image surface and sends the information to the NvMedia JPEG encoder. It saves the resulting bitstreams into a set of output files.
The application also supports CRC generation and CRC checking modes. CRC generation is mainly for developers to provide an original CRC. It can be a different CRC for different Tegra chip versions. CRC checking mode is for QA to verify the application for new releases.
The following diagram describes the basic function flow:
Example Commands
To encode a set of 720 x 480 JPEG files with quality 75
• Enter this command:
./nvmimg_jpgenc -f input.yuv -fr 720x480 -of output%d.jpg -q 75
To encode with CRC generation
• Enter this command:
./nvmimg_jpgenc -f input.yuv -fr 720x480 -of output%d.jpg -q 75 -crcgen crc.txt
To encode with CRC checking
• Enter this command:
./nvmimg_jpgenc -f input.yuv -fr 720x480 -of output%d.jpg -q 75 -crcchk crc.txt
Command Line Switches
To run the Image Encode sample application, enter this command:
./nvmimg_jpgenc [switches]
This table describes the command line switches:
e | Description | Default |
-h | Prints the help menu. | N/A |
-f <file> | Specifies the pathname of an input YUV file. | N/A |
-fr <W>x<H> | Specifies the input file resolution in width × height format, for example: 640x480. | N/A |
-of <file> | Specifies the pathname of an output file. If outputd.jpg is specified, the application generates a set of JPG files as output1.jpg, output2.jpg, etc. Otherwise, the last JPEG bitstream is saved to the specified file. | N/A |
-q <value> | Specifies the encode quality. The value must be in the range [1,100]. | 50 |
-crcgen <file> | Generates a CRC and saves it to the specified file. | N/A |
-crcchk <file> | Generates a CRC and checks it against the specified CRC file. | N/A |
-v <level> | Logging level. Value may be: 0 (Errors) 1 (Warnings) 2 (Information) 3 (Debug) | If the switch is omitted, 0. If the switch is specified but <level> is omitted, 3. |
-HuffTable <file> | Specifies the pathname of a configuration file containing a Huffman table. | N/A |
-QuantTable | Specifies the pathname of a configuration file containing a quant table. | N/A |