1 #!/usr/bin/perl 2 # 3 # This script has been (or is hereby) released into the public domain by 4 # its author, Karl J. Runge <runge (at] karlrunge.com>. This applies worldwide. 5 # 6 # In case this is not legally possible: Karl J. Runge grants anyone the 7 # right to use this work for any purpose, without any conditions, unless 8 # such conditions are required by law. 9 10 $saw_mark = 0; 11 $done = 0; 12 13 while (<>) { 14 if (! $saw_mark && /case rfbEncodingServerIdentity:/) { 15 $saw_mark = 1; 16 } 17 if ($saw_mark && !$done && /default:/) { 18 print; 19 20 print <<END; 21 /* for turbovnc */ 22 #define rfbJpegQualityLevel1 0xFFFFFE01 23 #define rfbJpegQualityLevel100 0xFFFFFE64 24 #define rfbJpegSubsamp1X 0xFFFFFD00 25 #define rfbJpegSubsamp4X 0xFFFFFD01 26 #define rfbJpegSubsamp2X 0xFFFFFD02 27 #define rfbJpegSubsampGray 0xFFFFFD03 28 29 if ( enc >= (uint32_t)rfbJpegSubsamp1X && 30 enc <= (uint32_t)rfbJpegSubsampGray ) { 31 /* XXX member really should be tightSubsample not correMaxWidth */ 32 cl->correMaxWidth = enc & 0xFF; 33 rfbLog("Using JPEG subsampling %d for client %s\\n", 34 cl->correMaxWidth, cl->host); 35 } else if ( enc >= (uint32_t)rfbEncodingQualityLevel0 && 36 enc <= (uint32_t)rfbEncodingQualityLevel9 ) { 37 static int JPEG_QUAL[10] = { 38 5, 10, 15, 25, 37, 50, 60, 70, 75, 80 39 }; 40 cl->tightQualityLevel = JPEG_QUAL[enc & 0x0F]; 41 /* XXX member really should be tightSubsample not correMaxWidth */ 42 cl->correMaxWidth = 2; 43 rfbLog("Using image level Subsample %d Quality %d for client %s\\n", 44 cl->correMaxWidth, cl->tightQualityLevel, cl->host); 45 } else if ( enc >= (uint32_t)rfbJpegQualityLevel1 && 46 enc <= (uint32_t)rfbJpegQualityLevel100 ) { 47 cl->tightQualityLevel = enc & 0xFF; 48 rfbLog("Using image quality level %d for client %s\\n", 49 cl->tightQualityLevel, cl->host); 50 } else 51 END 52 $done = 1; 53 next; 54 } 55 print; 56 } 57