Page 1 of 1

YUV much slower than JPG output?

Posted: 2015-10-09T11:17:06-07:00
by manoweb
Hello. I am using:

Code: Select all

# identify -version
Version: ImageMagick 6.7.7-10 2014-03-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP
I am using it on a i5-3320M machine, 2 cores, 4 with hyperthreading. Anyway, the very same happens on Kubuntu 15.04 that uses imagemagick-6.q16 (8:6.8.9.9-5)

I see some relevant performance difference if I choose yuv output instead of jpeg output. I would expect the former to be a little bit faster than jpeg, as it should, in my opinion, perform the same exact actions but skip jpeg encoding; instead, yuv output is 50% slower:

Code: Select all

# time convert -bench 3 DSC_0372.JPG -resize "1920x1080!" -pointsize 50 -fill white -stroke black -draw "text 50,80 \"ABCDEFabcdef12345\"" -sampling-factor "4:2:0" jpeg:- >/dev/null
Performance[1]: 3i 1.442ips 1.000e 5.200u 0:02.080
Performance[2]: 3i 1.478ips 0.506e 5.190u 0:02.030
Performance[3]: 3i 1.435ips 0.499e 5.240u 0:02.090
Performance[4]: 3i 1.493ips 0.509e 5.160u 0:02.010
 
real    0m8.219s
user    0m20.199s
sys     0m0.609s
 
# time convert -bench 3 DSC_0372.JPG -resize "1920x1080!" -pointsize 50 -fill white -stroke black -draw "text 50,80 \"ABCDEFabcdef12345\"" -sampling-factor "4:2:0" yuv:- >/dev/null
Performance[1]: 3i 0.926ips 1.000e 8.940u 0:03.240
Performance[2]: 3i 0.946ips 0.505e 8.830u 0:03.170
Performance[3]: 3i 0.974ips 0.513e 8.830u 0:03.080
Performance[4]: 3i 0.962ips 0.509e 8.810u 0:03.120
 
real    0m12.617s
user    0m34.427s
sys     0m1.000s

These are the details of the image,downloaded from a Nikon camera, but images from other cameras I've tried exhibit the same behaviour:

Code: Select all

# identify -verbose DSC_0372.JPG
Image: DSC_0372.JPG
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Class: DirectClass
  Geometry: 4256x2832+0+0
  Resolution: 300x300
  Print size: 14.1867x9.44
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 58.6984 (0.23019)
      standard deviation: 49.8747 (0.195587)
      kurtosis: 1.28686
      skewness: 1.0992
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 70.3994 (0.276076)
      standard deviation: 53.3634 (0.209268)
      kurtosis: 0.177182
      skewness: 0.719736
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 50.7307 (0.198944)
      standard deviation: 54.8303 (0.215021)
      kurtosis: 4.25704
      skewness: 2.00269
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 59.9428 (0.23507)
      standard deviation: 52.7305 (0.206786)
      kurtosis: 1.87431
      skewness: 1.30313
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Interlace: None
  Background color: white
  Border color: srgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Compose: Over
  Page geometry: 4256x2832+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 99
  Orientation: TopLeft
  Properties:
    date:create: 2015-10-09T10:28:03-07:00
    date:modify: 2015-10-09T10:28:03-07:00
    exif:Artist:                                     
    exif:CFAPattern: 0, 2, 0, 2, 0, 1, 1, 2
    exif:ColorSpace: 1
    exif:ComponentsConfiguration: 1, 2, 3, 0
    exif:CompressedBitsPerPixel: 4/1
    exif:Compression: 6
    exif:Contrast: 0
    exif:Copyright:                                                       
    exif:CustomRendered: 0
    exif:DateTime: 2013:03:24 15:12:42
    exif:DateTimeDigitized: 2013:03:24 15:12:42
    exif:DateTimeOriginal: 2013:03:24 15:12:42
    exif:DigitalZoomRatio: 1/1
    exif:ExifImageLength: 2832
    exif:ExifImageWidth: 4256
    exif:ExifOffset: 348
    exif:ExifVersion: 48, 50, 50, 49
    exif:ExposureBiasValue: -2/6
    exif:ExposureMode: 0
    exif:ExposureProgram: 2
    exif:ExposureTime: 10/5000
    exif:FileSource: 3
    exif:Flash: 0
    exif:FlashPixVersion: 48, 49, 48, 48
    exif:FNumber: 110/10
    exif:FocalLength: 420/10
    exif:FocalLengthIn35mmFilm: 42
    exif:GainControl: 0
    exif:GPSInfo: 34080
    exif:GPSVersionID: 2, 2, 0, 0
    exif:InteroperabilityIndex: R98
    exif:InteroperabilityOffset: 34050
    exif:InteroperabilityVersion: 48, 49, 48, 48
    exif:ISOSpeedRatings: 200
    exif:JPEGInterchangeFormat: 34208
    exif:JPEGInterchangeFormatLength: 8927
    exif:LightSource: 0
    exif:Make: NIKON CORPORATION
    exif:MakerNote: 78, 105, 107, 111, 110, 0, 2, 16, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 50, 0, 1, 0, 7, 0, 0, 0, 4, 48, 50, 49, 48, 0, 2, 0, 3, 0, 0, 0, 2, 0, 0, 0, 200, 0, 4, 0, 2, 0, 0, 0, 8, 0, 0, 2, 102, 0, 5, 0, 2, 0, 0, 0, 13, 0, 0, 2, 110, 0, 7, 0, 2, 0, 0, 0, 7, 0, 0, 2, 126, 0, 8, 0, 2, 0, 0, 0, 13, 0, 0, 2, 134, 0, 9, 0, 2, 0, 0, 0, 20, 0, 0, 2, 150, 0, 11, 0, 8, 0, 0, 0, 2, 0, 0, 0, 0, 0, 12, 0, 5, 0, 0, 0, 4, 0, 0, 2, 170, 0, 13, 0, 7, 0, 0, 0, 4, 0, 1, 6, 0, 0, 14, 0, 7, 0, 0, 0, 4, 0, 1, 12, 0, 0, 17, 0, 4, 0, 0, 0, 1, 0, 0, 31, 98, 0, 18, 0, 7, 0, 0, 0, 4, 0, 1, 6, 0, 0, 19, 0, 3, 0, 0, 0, 2, 0, 0, 0, 200, 0, 22, 0, 3, 0, 0, 0, 4, 0, 0, 2, 202, 0,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0, 22, 0, 0, 30, 102, 0, 176, 0, 7, 0, 0, 0, 16, 0, 0, 30, 126, 0, 177, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 182, 0, 7, 0, 0, 0, 8, 0, 0, 30, 142, 0, 183, 0, 7, 0, 0, 0, 30, 0, 0, 30, 150, 0, 184, 0, 7, 0, 0, 0, 172, 0, 0, 30, 182, 0, 185, 0, 7, 0, 0, 0, 4, 0, 255, 0, 0, 0, 0, 0, 0, 70, 73, 78, 69, 32, 32, 32, 0, 65, 85, 84, 79, 32, 32, 32, 32, 32, 32, 32, 32, 0, 0, 0, 0, 65, 70, 45, 83, 32, 32, 0, 0, 78, 79, 82, 77, 65, 76, 32, 32, 32, 32, 32, 32, 0, 0, 0, 0, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 0, 0, 0, 1, 176, 0, 0, 1, 0, 0, 0, 1, 119, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 16, 160, 11, 16, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 16, 192, 11, 28, 16, 192, 11, 28, 0, 0, 0, 0, 0, 0, 50, 48, 48, 50, 57, 52, 51, 0, 48, 49, 48, 48, 2, 2, 0, 0, 48, 49, 48, 48, 86, 73, 86, 73, 68, 45, 48, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 86, 73, 86, 73, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 195, 1, 0, 2, 255, 134, 128, 128, 128, 125, 255, 255, 255, 0, 0, 72, 1, 12, 0, 0, 0, 72, 1, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 0, 0, 0, 10, 0, 0, 4, 176, 0, 0, 0, 10, 0, 0, 0, 35, 0, 0, 0, 10, 0, 0, 0, 56, 0, 0, 0, 10, 48, 50, 49, 50, 78, 200, 36, 59, 162, 72, 164, 156, 140, 62, 128, 168, 161, 16, 148, 38, 55, 14, 172, 114, 61, 48, 234, 107, 179, 226, 178, 3, 209, 176, 182, 111, 239, 54, 68, 213, 121, 212, 189, 204, 20, 52, 176, 189, 145, 60, 142, 183, 163, 68, 220, 33, 40, 53, 154, 251, 43, 33, 200, 69, 141, 47, 103, 46, 94, 221, 110, 233, 163, 88, 242, 195, 91, 186, 224, 142, 129, 252, 62, 70, 23, 170, 12, 49, 29, 208, 74, 169, 147, 55, 248, 84, 121, 103, 22, 142, 207, 38, 164, 57, 149, 161, 162, 83, 203, 23, 42, 220, 112, 205, 239, 214, 134, 255, 61, 64, 12, 161, 251, 26, 2, 136, 34, 254, 125, 52, 199, 159, 56, 235, 40, 26, 133, 251, 83, 157, 61, 241, 64, 236, 97, 158, 159, 103, 10, 206, 109, 17, 1, 55, 171, 64, 105, 194, 166, 10, 88, 53, 246, 174, 175, 152, 5, 64, 117, 88, 2, 115, 171, 170, 112, 253, 81, 108, 78, 247, 103, 158, 156, 97, 237, 64, 90, 59, 227, 82, 136, 133, 73, 212, 38, 63, 31, 198, 52, 105, 101, 40, 178, 3, 27, 250, 160, 13, 65, 60, 254, 135, 215, 238, 204, 113, 221, 16, 169, 205, 78, 85, 153, 145, 53, 105, 43, 129, 143, 70, 122, 6, 116, 201, 96, 165, 137, 124, 211, 31, 50, 192, 174, 194, 71, 237, 252, 235, 205, 145, 1
    exif:MaxApertureValue: 42/10
    exif:MeteringMode: 3
    exif:Model: NIKON D700
    exif:Orientation: 1
    exif:ResolutionUnit: 2
    exif:Saturation: 0
    exif:SceneCaptureType: 0
    exif:SceneType: 1
    exif:SensingMethod: 2
    exif:Sharpness: 2
    exif:Software: Ver.1.02
    exif:SubjectDistanceRange: 0
    exif:SubSecTime: 41
    exif:SubSecTimeDigitized: 41
    exif:SubSecTimeOriginal: 41
    exif:UserComment: 65, 83, 67, 73, 73, 0, 0, 0, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32
    exif:WhiteBalance: 0
    exif:XResolution: 300/1
    exif:YCbCrPositioning: 2
    exif:YResolution: 300/1
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x1,1x1,1x1
    signature: f8a278434a894ed48523e5929b731e0c6210fc254b6ae53d1acbbc1538203aa2
  Profiles:
    Profile-exif: 65532 bytes
  Artifacts:
    filename: DSC_0372.JPG
    verbose: true
  Tainted: False
  Filesize: 10.3MB
  Number pixels: 12.05M
  Pixels per second: 52.4MB
  User time: 0.220u
  Elapsed time: 0:01.230
  Version: ImageMagick 6.7.7-10 2014-03-06 Q16 http://www.imagemagick.org

Re: YUV much slower than JPG output?

Posted: 2015-10-09T11:25:03-07:00
by manoweb
Maybe even more interesting is an even smaller command line:

Code: Select all

# time convert -bench 3 DSC_0372.JPG jpeg:- >/dev/null
Performance[1]: 3i 1.840ips 1.000e 1.630u 0:01.630
Performance[2]: 3i 1.840ips 0.500e 1.620u 0:01.630
Performance[3]: 3i 1.840ips 0.500e 1.630u 0:01.630
Performance[4]: 3i 1.852ips 0.502e 1.620u 0:01.620

real    0m6.511s
user    0m6.386s
sys     0m0.124s
# time convert -bench 3 DSC_0372.JPG yuv:- >/dev/null
Performance[1]: 3i 0.444ips 1.000e 20.140u 0:06.760
Performance[2]: 3i 0.445ips 0.501e 20.210u 0:06.740
Performance[3]: 3i 0.443ips 0.500e 20.110u 0:06.770
Performance[4]: 3i 0.444ips 0.500e 20.030u 0:06.760

real    0m27.029s
user    1m18.692s
sys     0m1.806s
In this case yuv takes 4x the time it takes jpeg. Is it perhaps in "yuv:-" mode Imagemagick re-arranges the whole image in memory? In this case I have removed the -resize 1920x1080! so convert will not perform a scale down, and the time it has taken to process the yuv has increased greatly, this supports some sort of expensive re-arrangement of the yuv data?