@@ -751,21 +751,34 @@ void UltraHdrAppInput::computeYUVSdrPSNR() {
751751}
752752
753753static void usage (const char * name) {
754- fprintf (stderr, " Usage: %s \n " , name);
755- fprintf (stderr, " ultra hdr demo application \n " );
756- fprintf (stderr, " -p p010 file path, mandatory in encode mode \n " );
757- fprintf (stderr, " -y yuv420 file path, optional \n " );
758- fprintf (stderr, " -w input width, mandatory in encode mode \n " );
759- fprintf (stderr, " -h input height, mandatory in encode mode \n " );
760- fprintf (stderr, " -C p010 color gamut, optional [0:bt709, 1:p3, 2:bt2100] \n " );
761- fprintf (stderr, " -c yuv420 color gamut, optional [0:bt709, 1:p3, 2:bt2100] \n " );
762- fprintf (stderr, " -t input transfer function, optional [0:linear, 1:hlg, 2:pq] \n " );
763- fprintf (stderr, " -q quality factor, optional [0-100] \n " );
764- fprintf (stderr, " -j jpegr file path, mandatory in decode mode \n " );
765- fprintf (stderr, " -m mode [0: encode, 1:decode] \n " );
766- fprintf (stderr,
767- " -o output transfer function, optional [0:sdr, 1:hdr_linear, 2:hdr_pq, "
768- " 3:hdr_hlg] \n " );
754+ fprintf (stderr, " \n ## ultra hdr demo application.\n Usage : %s \n " , name);
755+ fprintf (stderr, " -m mode of operation. [0: encode, 1:decode] \n " );
756+ fprintf (stderr, " \n ## encoder options : \n " );
757+ fprintf (stderr, " -p raw 10 bit input resource in p010 color format, mandatory. \n " );
758+ fprintf (stderr, " -y raw 8 bit input resource in yuv420, optional. \n "
759+ " if not provided tonemapping happens internally. \n " );
760+ fprintf (stderr, " -w input file width, mandatory. \n " );
761+ fprintf (stderr, " -h input file height, mandatory. \n " );
762+ fprintf (stderr, " -C 10 bit input color gamut, optional. [0:bt709, 1:p3, 2:bt2100] \n " );
763+ fprintf (stderr, " -c 8 bit input color gamut, optional. [0:bt709, 1:p3, 2:bt2100] \n " );
764+ fprintf (stderr, " -t input transfer function, optional. [0:linear, 1:hlg, 2:pq] \n " );
765+ fprintf (stderr, " -q quality factor to be used while encoding 8 bit image, optional. [0-100].\n "
766+ " gain map image does not use this quality factor. \n "
767+ " for now gain map image quality factor is not configurable. \n " );
768+ fprintf (stderr, " -e compute psnr, optional. [0:yes, 1:no] \n " );
769+ fprintf (stderr, " \n ## decoder options : \n " );
770+ fprintf (stderr, " -j ultra hdr input resource, mandatory in decode mode. \n " );
771+ fprintf (stderr, " -o output transfer function, optional. [0:sdr, 1:hdr_linear, 2:hdr_pq, 3:hdr_hlg] \n " );
772+ fprintf (stderr, " \n ## examples of usage :\n " );
773+ fprintf (stderr, " ultrahdr_app -m 0 -p cosmat_1920x1080_p010.yuv -w 1920 -h 1080 -q 97\n " );
774+ fprintf (stderr, " ultrahdr_app -m 0 -p cosmat_1920x1080_p010.yuv -y cosmat_1920x1080_420.yuv -w 1920 -h 1080 -q 97\n " );
775+ fprintf (stderr, " ultrahdr_app -m 0 -p cosmat_1920x1080_p010.yuv -y cosmat_1920x1080_420.yuv -w 1920 -h 1080 -q 97\n " );
776+ fprintf (stderr, " ultrahdr_app -m 0 -p cosmat_1920x1080_p010.yuv -w 1920 -h 1080 -q 97 -C 2 -t 2\n " );
777+ fprintf (stderr, " ultrahdr_app -m 0 -p cosmat_1920x1080_p010.yuv -y cosmat_1920x1080_420.yuv -w 1920 -h 1080 -q 97 -C 2 -c 1 -t 1\n " );
778+ fprintf (stderr, " ultrahdr_app -m 0 -p cosmat_1920x1080_p010.yuv -y cosmat_1920x1080_420.yuv -w 1920 -h 1080 -q 97 -C 2 -c 1 -t 1 -e 1\n " );
779+ fprintf (stderr, " ultrahdr_app -m 1 -j cosmat_1920x1080_hdr.jpg \n " );
780+ fprintf (stderr, " ultrahdr_app -m 1 -j cosmat_1920x1080_hdr.jpg -o 2\n " );
781+ fprintf (stderr, " \n " );
769782}
770783
771784int main (int argc, char * argv[]) {
@@ -777,8 +790,9 @@ int main(int argc, char* argv[]) {
777790 int quality = 100 ;
778791 ultrahdr_output_format of = ULTRAHDR_OUTPUT_HDR_HLG;
779792 int mode = 0 ;
793+ int compute_psnr = 0 ;
780794 int ch;
781- while ((ch = getopt (argc, argv, " p:y:w:h:C:c:t:q:o:m:j:" )) != -1 ) {
795+ while ((ch = getopt (argc, argv, " p:y:w:h:C:c:t:q:o:m:j:e: " )) != -1 ) {
782796 switch (ch) {
783797 case ' p' :
784798 p010_file = optarg;
@@ -813,35 +827,38 @@ int main(int argc, char* argv[]) {
813827 case ' j' :
814828 jpegr_file = optarg;
815829 break ;
830+ case ' e' :
831+ compute_psnr = atoi (optarg);
832+ break ;
816833 default :
817834 usage (argv[0 ]);
818835 return -1 ;
819836 }
820837 }
821838 if (mode == 0 ) {
822839 if (width <= 0 || height <= 0 || p010_file == nullptr ) {
823- std::cerr << " invalid raw file name or raw image dimensions" << std::endl;
824840 usage (argv[0 ]);
825841 return -1 ;
826842 }
827843 UltraHdrAppInput appInput (p010_file, yuv420_file, width, height, p010Cg, yuv420Cg, tf,
828844 quality, of);
829845 if (!appInput.encode ()) return -1 ;
830- if (!appInput.decode ()) return -1 ;
831- if (of == ULTRAHDR_OUTPUT_SDR && yuv420_file != nullptr ) {
832- appInput.convertYuv420ToRGBImage ();
833- appInput.computeRGBSdrPSNR ();
834- appInput.convertRgba8888ToYUV444Image ();
835- appInput.computeYUVSdrPSNR ();
836- } else if (of == ULTRAHDR_OUTPUT_HDR_HLG || of == ULTRAHDR_OUTPUT_HDR_PQ) {
837- appInput.convertP010ToRGBImage ();
838- appInput.computeRGBHdrPSNR ();
839- appInput.convertRgba1010102ToYUV444Image ();
840- appInput.computeYUVHdrPSNR ();
846+ if (compute_psnr == 1 ) {
847+ if (!appInput.decode ()) return -1 ;
848+ if (of == ULTRAHDR_OUTPUT_SDR && yuv420_file != nullptr ) {
849+ appInput.convertYuv420ToRGBImage ();
850+ appInput.computeRGBSdrPSNR ();
851+ appInput.convertRgba8888ToYUV444Image ();
852+ appInput.computeYUVSdrPSNR ();
853+ } else if (of == ULTRAHDR_OUTPUT_HDR_HLG || of == ULTRAHDR_OUTPUT_HDR_PQ) {
854+ appInput.convertP010ToRGBImage ();
855+ appInput.computeRGBHdrPSNR ();
856+ appInput.convertRgba1010102ToYUV444Image ();
857+ appInput.computeYUVHdrPSNR ();
858+ }
841859 }
842860 } else if (mode == 1 ) {
843861 if (jpegr_file == nullptr ) {
844- std::cerr << " invalid jpegr image file name " << std::endl;
845862 usage (argv[0 ]);
846863 return -1 ;
847864 }
0 commit comments