On Thu, 22 Jul 2004, Marc Gregoire wrote: > I took another image of which I do have the original to work with. > This picture can be found at the following links: > Original: http://www.nuonsoft.com/temp/07_orig.jpg > Scaled: http://www.nuonsoft.com/temp/07_scaled.jpg > Mpeg2enc result: http://www.nuonsoft.com/temp/07_mpeg2enc.png > Commercial result: http://www.nuonsoft.com/temp/07_commercial.png
Thanks for making the data available - I pulled the images in and did a bit of experimenting tonight. The results were even better than I expected! > 1360x1020. The camera automatically saves them to a low (to avoid > graphical artifacts) compressed JPG. > You clearly see that the 07_mpeg2enc.png shot is more blocky than the > 07_commercial.png. This is especially noticeable in the lower > left corner of the image. You can see block in the marble. You also see > blocks in the orange wall in the back. These blocks are not visible in the To my eyes the blocks are moderately hard to see - they're there but on a TV I'm certain noone would be able to tell the two apart easily. > took the jpeg2yuv of the mjpegtools 1.6.2 and that version does indeed have > the -R option, but like you said, this didn't fix the quality issue. You can also run the data thru "yuvcorrect -Y CONFORM" and it will adjust the data to be within the broadcast safe range. Now on to the evening's testing. What I was curious about was if doing the scaling and color space conversion with 'y4mscaler' would make a difference (hopefully for the better ;)). So, I took the 07_orig.jpg file and converted it to 24bit RGB PPM and used 07_orig.ppm as the source. 'ppmtoy4m' was used to convert to 4:4:4 Y4M format (lossless - just going from RGB to YUV, still in 24bit mode). Then the key step: I used y4mscaler with an 8 tap Sinc/Lanczos scaling kernel _and_ converted to 420_mpeg2 *and* took into account the fact that PAL pixels are really 59:54 and not 1:1 (if you just scale from 1360x1020 to 720x576 you're changing the aspect ratio when displayed on a TV!). The last step was to run the data thru the yuvcorrect program to get broadcast safe values. The result of this could have been piped directly into mpeg2enc but I created a .y4m file that I could use with other programs. Encoding was done with "-q 1" and a bitrate of 9800. The resulting .m2v file was ~84K bytes ("84095 22 Jul 19:52 xxx.m2v") To view the results it's necessary to decode the .m2v file back to PPM. That is done using 'mpeg2dec' and a couple more of the mjpegtools utilities (pgmtoy4m and y4mtoppm). y4mscaler was used to convert upsample to 4:4:4 (24bit mode). pgmtoy4m is I believe only in the CVS version of mjpegtools at the moment but I might be mistaken about that (it's been eons since I've used anything except the CVS version ;)) The script I used was this: ---------- #!/bin/sh cat 07_orig.ppm | \ ppmtoy4m -n 1 -F 25:1 -I p -S 444 | \ y4mscaler -I sar=1:1 -O sar=PAL -O size=720x576 -O chromass=420_mpeg2 -S option=sinc:8 | \ yuvcorrect -Y CONFORM > 07_orig.y4m mpeg2enc -f 8 -b 9800 -q 1 -o xxx.m2v < 07_orig.y4m mpeg2dec -o pgmpipe xxx.m2v | \ pgmtoy4m -a 59:54 -r 25:1 | \ y4mscaler -O chromass=444 | \ y4mtoppm -L > 0.ppm ---------- I have attached a script of the session so that you can see the output of the tools. The output from y4mscaler will be of interest I believe. Maybe I'm overdue for getting new glasses but to me the .m2v file produced above looks sharper and clearer than either 07_commercial.png or 07_mpeg2enc.png. The differences between the file produced above and the .png files are subtle to my eyes even at a 2x zoom in the GIMP (using Apple's 23" Cinema-HD LCD screen). I'm sure that With a higher bitrate the differences would be even smaller but the sharpness in the file created by the above script is noticeably better than the 07_commercial.png and 07_mpeg2enc.png - those almost look "blurred" in comparison ;) Perhaps someone with better eyes (or newer glasses :)) can run some tests and chime in on this - another opinion would be welcome. Cheers, Steven Schultz
Script started on Thu Jul 22 19:52:03 2004 [LARRY:~/x] sms% ./x.sh INFO: [yuvcorrect] yuvcorrect 1.6.3 (16-11-2002) is a general image correction utility for yuv frames INFO: [yuvcorrect] (C) 2002 Xavier Biquard <[EMAIL PROTECTED]>, yuvcorrect -h for usage, or man yuvcorrect INFO: [ppmtoy4m] Command-line Parameters: INFO: [ppmtoy4m] framerate: 25:1 INFO: [ppmtoy4m] pixel aspect ratio: 1:1 INFO: [ppmtoy4m] interlace: none/progressive INFO: [ppmtoy4m] starting frame: 0 INFO: [ppmtoy4m] # of frames: 1, or until input exhausted INFO: [ppmtoy4m] chroma subsampling: 4:4:4 (no subsampling) INFO: [ppmtoy4m] Output Stream parameters: INFO: [ppmtoy4m] frame size: 1360x1020 pixels (4161600 bytes) INFO: [ppmtoy4m] chroma: 4:4:4 (no subsampling) INFO: [ppmtoy4m] frame rate: 25/1 fps (~25.000000) INFO: [ppmtoy4m] interlace: none/progressive INFO: [ppmtoy4m] sample aspect ratio: 1:1 INFO: [y4mscaler] Input Stream Header: INFO: [y4mscaler] <<< frame size: 1360x1020 pixels (4161600 bytes) INFO: [y4mscaler] <<< chroma: 4:4:4 (no subsampling) INFO: [y4mscaler] <<< frame rate: 25/1 fps (~25.000000) INFO: [y4mscaler] <<< interlace: none/progressive INFO: [y4mscaler] <<< sample aspect ratio: 1:1 INFO: [y4mscaler] Source matte region defaulting to full source frame. INFO: [y4mscaler] Source active region defaulting to full source frame. INFO: [y4mscaler] Target interlacing defaulting to match source. INFO: [y4mscaler] Target active region defaulting to full target frame. INFO: [y4mscaler] Deriving ratios from active regions and SARs... INFO: [y4mscaler] ...using scaling ratios which pad target. INFO: [y4mscaler] ...using scaling ratios which are simple. ++ WARN: [y4mscaler] Target active region clipped by projection of source. INFO: [y4mscaler] === SOURCE parameters: ================= INFO: [y4mscaler] < stream: INFO: [y4mscaler] < 1360x1020, SAR 1:1, progressive INFO: [y4mscaler] < chroma subsampling: 444 INFO: [y4mscaler] < chroma ss ratios: x 1:1 y 1:1 INFO: [y4mscaler] < active region: INFO: [y4mscaler] < 1360.000000x1017.659134 at 0.000000,1.222222 INFO: [y4mscaler] < matte region: INFO: [y4mscaler] < 1360x1020 at 0,0 (bg Y'CbCr: 16,128,128) INFO: [y4mscaler] === SCALING parameters: ================ INFO: [y4mscaler] | Scaler: Matto's Generic Scaler INFO: [y4mscaler] | kernels: sinc:8, sinc:8 INFO: [y4mscaler] === TARGET parameters: ================= INFO: [y4mscaler] > stream: INFO: [y4mscaler] > 720x576, SAR 59:54, progressive INFO: [y4mscaler] < chroma subsampling: 420_MPEG2 INFO: [y4mscaler] < chroma ss ratios: x 1:2 y 1:2 INFO: [y4mscaler] > active region: INFO: [y4mscaler] > 680x556 at 20,10 (bg Y'CbCr: 16,128,128) INFO: [y4mscaler] > X ratio: 1/2 INFO: [y4mscaler] > Y ratio: 59/108 INFO: [y4mscaler] Output Stream Header: INFO: [y4mscaler] >>> frame size: 720x576 pixels (622080 bytes) INFO: [y4mscaler] >>> chroma: 4:2:0 MPEG-2 (horiz. cositing) INFO: [y4mscaler] >>> frame rate: 25/1 fps (~25.000000) INFO: [y4mscaler] >>> interlace: none/progressive INFO: [y4mscaler] >>> sample aspect ratio: 59:54 INFO: [yuvcorrect] input: frame size: 720x576 pixels (622080 bytes) INFO: [yuvcorrect] input: chroma: 4:2:0 MPEG-2 (horiz. cositing) INFO: [yuvcorrect] input: frame rate: 25/1 fps (~25.000000) INFO: [yuvcorrect] input: interlace: none/progressive INFO: [yuvcorrect] input: sample aspect ratio: 59:54 INFO: [yuvcorrect] no line switching INFO: [yuvcorrect] no time forwarding INFO: [yuvcorrect] With luminance correction INFO: [yuvcorrect] With chrominance correction INFO: [yuvcorrect] Without rgb correction INFO: [y4mscaler] Frame number 0 INFO: [y4mscaler] Frame number 1 INFO: [y4mscaler] End of stream at frame 1. INFO: [yuvcorrect] Frame number 0 INFO: [yuvcorrect] End of stream! INFO: [yuvcorrect] Normal exit: end of stream with frame number 1! INFO: [mpeg2enc] SETTING AltiVec for MOTION! INFO: [mpeg2enc] SETTING AltiVec for TRANSFORM! INFO: [mpeg2enc] SETTING AltiVec for PREDICTION! INFO: [mpeg2enc] Selecting DVD output profile INFO: [mpeg2enc] Assuming norm PAL INFO: [mpeg2enc] Progressive input - selecting progressive encoding. INFO: [mpeg2enc] Encoding MPEG-2 video to xxx.m2v INFO: [mpeg2enc] Horizontal size: 720 pel INFO: [mpeg2enc] Vertical size: 576 pel INFO: [mpeg2enc] Aspect ratio code: 2 = 4:3 display INFO: [mpeg2enc] Frame rate code: 3 = 25.0 (PAL/SECAM VIDEO / converted FILM) INFO: [mpeg2enc] Bitrate: 9800 KBit/s INFO: [mpeg2enc] Quality factor: 1 (Quantisation = 1) (1=best, 31=worst) INFO: [mpeg2enc] Field order for input: none/progressive INFO: [mpeg2enc] Sequence unlimited length INFO: [mpeg2enc] Search radius: 16 INFO: [mpeg2enc] GOP SIZE RANGE 9 TO 15 INFO: [mpeg2enc] Setting colour/gamma parameters to "PAL B/G" INFO: [mpeg2enc] Progressive format frames = 1 INFO: [mpeg2enc] Using default unmodified quantization matrices INFO: [mpeg2enc] Buffering 33 frames INFO: [mpeg2enc] Signaling last frame = 0 INFO: [mpeg2enc] SETTING AltiVec for QUANTIZER! INFO: [mpeg2enc] GOP start (1 frames) INFO: [mpeg2enc] Frame end 0 I quant=9.04 total act=242.72241 INFO: [mpeg2enc] GOP start (0 frames) INFO: [mpeg2enc] Guesstimated final muxed size = 84095 mpeg2dec-0.4.1-cvs - by Michel Lespinasse <[EMAIL PROTECTED]> and Aaron Holtzman INFO: [pgmtoy4m] P5 cols: 720 rows: 864 maxval: 255 INFO: [y4mscaler] Input Stream Header: INFO: [y4mscaler] <<< frame size: 720x576 pixels (622080 bytes) INFO: [y4mscaler] <<< chroma: 4:2:0 MPEG-2 (horiz. cositing) INFO: [y4mscaler] <<< frame rate: 25/1 fps (~25.000000) INFO: [y4mscaler] <<< interlace: top-field-first INFO: [y4mscaler] <<< sample aspect ratio: 59:54 INFO: [y4mscaler] Source matte region defaulting to full source frame. INFO: [y4mscaler] Source active region defaulting to full source frame. INFO: [y4mscaler] Target interlacing defaulting to match source. INFO: [y4mscaler] Target frame size defaulting to match source. INFO: [y4mscaler] Target active region defaulting to full target frame. INFO: [y4mscaler] Deriving ratios from active regions... INFO: [y4mscaler] === SOURCE parameters: ================= INFO: [y4mscaler] < stream: INFO: [y4mscaler] < 720x576, SAR 59:54, top-field-first INFO: [y4mscaler] < chroma subsampling: 420_MPEG2 INFO: [y4mscaler] < chroma ss ratios: x 1:2 y 1:2 INFO: [y4mscaler] < active region: INFO: [y4mscaler] < 720.000000x576.000000 at 0.000000,0.000000 INFO: [y4mscaler] < matte region: INFO: [y4mscaler] < 720x576 at 0,0 (bg Y'CbCr: 16,128,128) INFO: [y4mscaler] === SCALING parameters: ================ INFO: [y4mscaler] | Scaler: Matto's Generic Scaler INFO: [y4mscaler] | kernels: linear, linear INFO: [y4mscaler] === TARGET parameters: ================= INFO: [y4mscaler] > stream: INFO: [y4mscaler] > 720x576, SAR 59:54, top-field-first INFO: [y4mscaler] < chroma subsampling: 444 INFO: [y4mscaler] < chroma ss ratios: x 1:1 y 1:1 INFO: [y4mscaler] > active region: INFO: [y4mscaler] > 720x576 at 0,0 (bg Y'CbCr: 16,128,128) INFO: [y4mscaler] > X ratio: 1/1 INFO: [y4mscaler] > Y ratio: 1/1 INFO: [y4mscaler] Output Stream Header: INFO: [y4mscaler] >>> frame size: 720x576 pixels (1244160 bytes) INFO: [y4mscaler] >>> chroma: INFO: [y4mtoppm] input stream parameters: INFO: [y4mtoppm] <<< frame size: 720x576 pixels (1244160 bytes) INFO: [y4mtoppm] <<< chroma: 4:4:4 (no subsampling) INFO: [y4mtoppm] <<< frame rate: 25/1 fps (~25.000000) INFO: [y4mtoppm] <<< interlace: top-field-first INFO: [y4mtoppm] <<<sample aspect ratio: 59:54 4:4:4 (no subsampling) INFO: [y4mscaler] >>> frame rate: 25/1 fps (~25.000000) INFO: [y4mscaler] >>> interlace: top-field-first INFO: [y4mscaler] >>> sample aspect ratio: 59:54 INFO: [y4mscaler] Frame number 0 1 frames decoded in 0.00 seconds (0.00 fps) INFO: [y4mscaler] Frame number 1 INFO: [y4mscaler] End of stream at frame 1. [LARRY:~/x] sms% exit Script done on Thu Jul 22 19:52:10 2004