Code generated by go run gen.go; DO NOT EDIT.

package imageutil

import (
	
)
DrawYCbCr draws the YCbCr source image on the RGBA destination image with r.Min in dst aligned with sp in src. It reports whether the draw was successful. If it returns false, no dst pixels were changed. This function assumes that r is entirely within dst's bounds and the translation of r from dst coordinate space to src coordinate space is entirely within src's bounds.
This function exists in the image/internal/imageutil package because it is needed by both the image/draw and image/jpeg packages, but it doesn't seem right for one of those two to depend on the other. Another option is to have this code be exported in the image package, but we'd need to make sure we're totally happy with the API (for the rest of Go 1 compatibility), and decide if we want to have a more general purpose DrawToRGBA method for other image types. One possibility is: func (src *YCbCr) CopyToRGBA(dst *RGBA, dr, sr Rectangle) (effectiveDr, effectiveSr Rectangle) in the spirit of the built-in copy function for 1-dimensional slices, that also allowed a CopyFromRGBA method if needed.

	 := (.Min.X - .Rect.Min.X) * 4
	 := (.Max.X - .Rect.Min.X) * 4
	 := .Min.Y - .Rect.Min.Y
	 := .Max.Y - .Rect.Min.Y
	switch .SubsampleRatio {

	case image.YCbCrSubsampleRatio444:
		for ,  := , .Y;  != ; ,  = +1, +1 {
			 := .Pix[*.Stride:]
			 := (-.Rect.Min.Y)*.YStride + (.X - .Rect.Min.X)

			 := (-.Rect.Min.Y)*.CStride + (.X - .Rect.Min.X)
			for  := ;  != ; , ,  = +4, +1, +1 {
This is an inline version of image/color/ycbcr.go's func YCbCrToRGB.
				 := int32(.Y[]) * 0x10101
				 := int32(.Cb[]) - 128
				 := int32(.Cr[]) - 128
The bit twiddling below is equivalent to r := (yy1 + 91881*cr1) >> 16 if r < 0 { r = 0 } else if r > 0xff { r = ^int32(0) } but uses fewer branches and is faster. Note that the uint8 type conversion in the return statement will convert ^int32(0) to 0xff. The code below to compute g and b uses a similar pattern.
				 :=  + 91881*
				if uint32()&0xff000000 == 0 {
					 >>= 16
				} else {
					 = ^( >> 31)
				}

				 :=  - 22554* - 46802*
				if uint32()&0xff000000 == 0 {
					 >>= 16
				} else {
					 = ^( >> 31)
				}

				 :=  + 116130*
				if uint32()&0xff000000 == 0 {
					 >>= 16
				} else {
					 = ^( >> 31)
				}
use a temp slice to hint to the compiler that a single bounds check suffices
				 := [ : +4 : len()]
				[0] = uint8()
				[1] = uint8()
				[2] = uint8()
				[3] = 255
			}
		}

	case image.YCbCrSubsampleRatio422:
		for ,  := , .Y;  != ; ,  = +1, +1 {
			 := .Pix[*.Stride:]
			 := (-.Rect.Min.Y)*.YStride + (.X - .Rect.Min.X)

			 := (-.Rect.Min.Y)*.CStride - .Rect.Min.X/2
			for ,  := , .X;  != ; , ,  = +4, +1, +1 {
				 :=  + /2
This is an inline version of image/color/ycbcr.go's func YCbCrToRGB.
				 := int32(.Y[]) * 0x10101
				 := int32(.Cb[]) - 128
				 := int32(.Cr[]) - 128
The bit twiddling below is equivalent to r := (yy1 + 91881*cr1) >> 16 if r < 0 { r = 0 } else if r > 0xff { r = ^int32(0) } but uses fewer branches and is faster. Note that the uint8 type conversion in the return statement will convert ^int32(0) to 0xff. The code below to compute g and b uses a similar pattern.
				 :=  + 91881*
				if uint32()&0xff000000 == 0 {
					 >>= 16
				} else {
					 = ^( >> 31)
				}

				 :=  - 22554* - 46802*
				if uint32()&0xff000000 == 0 {
					 >>= 16
				} else {
					 = ^( >> 31)
				}

				 :=  + 116130*
				if uint32()&0xff000000 == 0 {
					 >>= 16
				} else {
					 = ^( >> 31)
				}
use a temp slice to hint to the compiler that a single bounds check suffices
				 := [ : +4 : len()]
				[0] = uint8()
				[1] = uint8()
				[2] = uint8()
				[3] = 255
			}
		}

	case image.YCbCrSubsampleRatio420:
		for ,  := , .Y;  != ; ,  = +1, +1 {
			 := .Pix[*.Stride:]
			 := (-.Rect.Min.Y)*.YStride + (.X - .Rect.Min.X)

			 := (/2-.Rect.Min.Y/2)*.CStride - .Rect.Min.X/2
			for ,  := , .X;  != ; , ,  = +4, +1, +1 {
				 :=  + /2
This is an inline version of image/color/ycbcr.go's func YCbCrToRGB.
				 := int32(.Y[]) * 0x10101
				 := int32(.Cb[]) - 128
				 := int32(.Cr[]) - 128
The bit twiddling below is equivalent to r := (yy1 + 91881*cr1) >> 16 if r < 0 { r = 0 } else if r > 0xff { r = ^int32(0) } but uses fewer branches and is faster. Note that the uint8 type conversion in the return statement will convert ^int32(0) to 0xff. The code below to compute g and b uses a similar pattern.
				 :=  + 91881*
				if uint32()&0xff000000 == 0 {
					 >>= 16
				} else {
					 = ^( >> 31)
				}

				 :=  - 22554* - 46802*
				if uint32()&0xff000000 == 0 {
					 >>= 16
				} else {
					 = ^( >> 31)
				}

				 :=  + 116130*
				if uint32()&0xff000000 == 0 {
					 >>= 16
				} else {
					 = ^( >> 31)
				}
use a temp slice to hint to the compiler that a single bounds check suffices
				 := [ : +4 : len()]
				[0] = uint8()
				[1] = uint8()
				[2] = uint8()
				[3] = 255
			}
		}

	case image.YCbCrSubsampleRatio440:
		for ,  := , .Y;  != ; ,  = +1, +1 {
			 := .Pix[*.Stride:]
			 := (-.Rect.Min.Y)*.YStride + (.X - .Rect.Min.X)

			 := (/2-.Rect.Min.Y/2)*.CStride + (.X - .Rect.Min.X)
			for  := ;  != ; , ,  = +4, +1, +1 {
This is an inline version of image/color/ycbcr.go's func YCbCrToRGB.
				 := int32(.Y[]) * 0x10101
				 := int32(.Cb[]) - 128
				 := int32(.Cr[]) - 128
The bit twiddling below is equivalent to r := (yy1 + 91881*cr1) >> 16 if r < 0 { r = 0 } else if r > 0xff { r = ^int32(0) } but uses fewer branches and is faster. Note that the uint8 type conversion in the return statement will convert ^int32(0) to 0xff. The code below to compute g and b uses a similar pattern.
				 :=  + 91881*
				if uint32()&0xff000000 == 0 {
					 >>= 16
				} else {
					 = ^( >> 31)
				}

				 :=  - 22554* - 46802*
				if uint32()&0xff000000 == 0 {
					 >>= 16
				} else {
					 = ^( >> 31)
				}

				 :=  + 116130*
				if uint32()&0xff000000 == 0 {
					 >>= 16
				} else {
					 = ^( >> 31)
				}
use a temp slice to hint to the compiler that a single bounds check suffices
				 := [ : +4 : len()]
				[0] = uint8()
				[1] = uint8()
				[2] = uint8()
				[3] = 255
			}
		}

	default:
		return false
	}
	return true