@@ -244,17 +244,20 @@ static bool writeFile(const char* filename, uhdr_raw_image_t* img) {
244244
245245class UltraHdrAppInput {
246246 public:
247- UltraHdrAppInput (
248- const char * hdrIntentRawFile, const char * sdrIntentRawFile,
249- const char * sdrIntentCompressedFile, const char * gainmapCompressedFile,
250- const char * gainmapMetadataCfgFile, const char * exifFile, const char * outputFile,
251- size_t width, size_t height, uhdr_img_fmt_t hdrCf = UHDR_IMG_FMT_32bppRGBA1010102,
252- uhdr_img_fmt_t sdrCf = UHDR_IMG_FMT_32bppRGBA8888,
253- uhdr_color_gamut_t hdrCg = UHDR_CG_DISPLAY_P3, uhdr_color_gamut_t sdrCg = UHDR_CG_BT_709,
254- uhdr_color_transfer_t hdrTf = UHDR_CT_HLG, int quality = 95 ,
255- uhdr_color_transfer_t oTf = UHDR_CT_HLG, uhdr_img_fmt_t oFmt = UHDR_IMG_FMT_32bppRGBA1010102,
256- bool isHdrCrFull = false , int gainmapScaleFactor = 4 , int gainmapQuality = 85 ,
257- bool enableMultiChannelGainMap = false , float gamma = 1 .0f , bool enableGLES = false )
247+ UltraHdrAppInput (const char * hdrIntentRawFile, const char * sdrIntentRawFile,
248+ const char * sdrIntentCompressedFile, const char * gainmapCompressedFile,
249+ const char * gainmapMetadataCfgFile, const char * exifFile, const char * outputFile,
250+ size_t width, size_t height,
251+ uhdr_img_fmt_t hdrCf = UHDR_IMG_FMT_32bppRGBA1010102,
252+ uhdr_img_fmt_t sdrCf = UHDR_IMG_FMT_32bppRGBA8888,
253+ uhdr_color_gamut_t hdrCg = UHDR_CG_DISPLAY_P3,
254+ uhdr_color_gamut_t sdrCg = UHDR_CG_BT_709,
255+ uhdr_color_transfer_t hdrTf = UHDR_CT_HLG, int quality = 95 ,
256+ uhdr_color_transfer_t oTf = UHDR_CT_HLG,
257+ uhdr_img_fmt_t oFmt = UHDR_IMG_FMT_32bppRGBA1010102, bool isHdrCrFull = false ,
258+ int gainmapScaleFactor = 4 , int gainmapQuality = 85 ,
259+ bool enableMultiChannelGainMap = false , float gamma = 1 .0f ,
260+ bool enableGLES = false , uhdr_enc_preset_t encPreset = UHDR_USAGE_REALTIME)
258261 : mHdrIntentRawFile (hdrIntentRawFile),
259262 mSdrIntentRawFile (sdrIntentRawFile),
260263 mSdrIntentCompressedFile(sdrIntentCompressedFile),
@@ -279,6 +282,7 @@ class UltraHdrAppInput {
279282 mUseMultiChannelGainMap(enableMultiChannelGainMap),
280283 mGamma(gamma),
281284 mEnableGLES(enableGLES),
285+ mEncPreset(encPreset),
282286 mMode(0 ){};
283287
284288 UltraHdrAppInput (const char * gainmapMetadataCfgFile, const char * uhdrFile, const char * outputFile,
@@ -308,6 +312,7 @@ class UltraHdrAppInput {
308312 mUseMultiChannelGainMap(false ),
309313 mGamma(1 .0f ),
310314 mEnableGLES(enableGLES),
315+ mEncPreset(UHDR_USAGE_REALTIME),
311316 mMode(1 ){};
312317
313318 ~UltraHdrAppInput () {
@@ -387,6 +392,7 @@ class UltraHdrAppInput {
387392 const bool mUseMultiChannelGainMap ;
388393 const float mGamma ;
389394 const bool mEnableGLES ;
395+ const uhdr_enc_preset_t mEncPreset ;
390396 const int mMode ;
391397
392398 uhdr_raw_image_t mRawP010Image {};
@@ -683,6 +689,7 @@ bool UltraHdrAppInput::encode() {
683689 RET_IF_ERR (uhdr_enc_set_using_multi_channel_gainmap (handle, mUseMultiChannelGainMap ))
684690 RET_IF_ERR (uhdr_enc_set_gainmap_scale_factor (handle, mMapDimensionScaleFactor ))
685691 RET_IF_ERR (uhdr_enc_set_gainmap_gamma (handle, mGamma ))
692+ RET_IF_ERR (uhdr_enc_set_preset (handle, mEncPreset ))
686693 if (mEnableGLES ) {
687694 RET_IF_ERR (uhdr_enable_gpu_acceleration (handle, mEnableGLES ))
688695 }
@@ -1348,6 +1355,9 @@ static void usage(const char* name) {
13481355 " real number (1.0 : default)].\n " );
13491356 fprintf (stderr,
13501357 " -M select multi channel gain map, optional. [0:disable (default), 1:enable]. \n " );
1358+ fprintf (
1359+ stderr,
1360+ " -D select encoding preset, optional. [0:real time (default), 1:best quality]. \n " );
13511361 fprintf (stderr, " -x binary input resource containing exif data to insert, optional. \n " );
13521362 fprintf (stderr, " \n ## decoder options : \n " );
13531363 fprintf (stderr, " -j ultra hdr compressed input resource, required. \n " );
@@ -1425,7 +1435,7 @@ static void usage(const char* name) {
14251435 fprintf (stderr, " \n ## encode at high quality :\n " );
14261436 fprintf (stderr,
14271437 " ultrahdr_app -m 0 -p hdr_intent.raw -y sdr_intent.raw -w 640 -h 480 -c <select> -C "
1428- " <select> -t <select> -s 1 -M 1 -Q 98 -q 98\n " );
1438+ " <select> -t <select> -s 1 -M 1 -Q 98 -q 98 -D 1 \n " );
14291439
14301440 fprintf (stderr, " \n ## decode api :\n " );
14311441 fprintf (stderr, " ultrahdr_app -m 1 -j cosmat_1920x1080_hdr.jpg \n " );
@@ -1435,7 +1445,7 @@ static void usage(const char* name) {
14351445}
14361446
14371447int main (int argc, char * argv[]) {
1438- char opt_string[] = " p:y:i:g:f:w:h:C:c:t:q:o:O:m:j:e:a:b:z:R:s:M:Q:G:x:u:" ;
1448+ char opt_string[] = " p:y:i:g:f:w:h:C:c:t:q:o:O:m:j:e:a:b:z:R:s:M:Q:G:x:u:D: " ;
14391449 char *hdr_intent_raw_file = nullptr , *sdr_intent_raw_file = nullptr , *uhdr_file = nullptr ,
14401450 *sdr_intent_compressed_file = nullptr , *gainmap_compressed_file = nullptr ,
14411451 *gainmap_metadata_cfg_file = nullptr , *output_file = nullptr , *exif_file = nullptr ;
@@ -1456,6 +1466,7 @@ int main(int argc, char* argv[]) {
14561466 int compute_psnr = 0 ;
14571467 float gamma = 1 .0f ;
14581468 bool enable_gles = false ;
1469+ uhdr_enc_preset_t enc_preset = UHDR_USAGE_REALTIME;
14591470 int ch;
14601471 while ((ch = getopt_s (argc, argv, opt_string)) != -1 ) {
14611472 switch (ch) {
@@ -1541,6 +1552,9 @@ int main(int argc, char* argv[]) {
15411552 case ' u' :
15421553 enable_gles = atoi (optarg_s) == 1 ? true : false ;
15431554 break ;
1555+ case ' D' :
1556+ enc_preset = static_cast <uhdr_enc_preset_t >(atoi (optarg_s));
1557+ break ;
15441558 default :
15451559 usage (argv[0 ]);
15461560 return -1 ;
@@ -1568,7 +1582,7 @@ int main(int argc, char* argv[]) {
15681582 gainmap_compressed_file, gainmap_metadata_cfg_file, exif_file,
15691583 output_file ? output_file : " out.jpeg" , width, height, hdr_cf, sdr_cf, hdr_cg, sdr_cg,
15701584 hdr_tf, quality, out_tf, out_cf, use_full_range_color_hdr, gainmap_scale_factor,
1571- gainmap_compression_quality, use_multi_channel_gainmap, gamma, enable_gles);
1585+ gainmap_compression_quality, use_multi_channel_gainmap, gamma, enable_gles, enc_preset );
15721586 if (!appInput.encode ()) return -1 ;
15731587 if (compute_psnr == 1 ) {
15741588 if (!appInput.decode ()) return -1 ;
0 commit comments