diff --git a/src/common_video/libyuv/include/libyuv.h b/src/common_video/libyuv/include/libyuv.h index f016a3f9d..9034bf700 100644 --- a/src/common_video/libyuv/include/libyuv.h +++ b/src/common_video/libyuv/include/libyuv.h @@ -41,8 +41,6 @@ enum VideoType { kNV21, kNV12, kBGRA, - kARGBMac, // TODO (mikhal): remove - kRGBAMac, // TODO (mikhal): remove }; // Conversion between the RawVideoType and the LibYuv videoType. @@ -79,37 +77,8 @@ int CalcBufferSize(VideoType src_video_type, int length); // TODO (mikhal): Merge the two functions above. -// TODO(mikhal): If WebRTC doesn't switch to three plane representation, -// use helper functions for the planes and widths. -// Convert To/From I420 -// The following two functions convert an image to/from a I420 type to/from -// a specified format. -// -// Input: -// - src_video_type : Type of input video -// - src_frame : Pointer to a source frame. -// - width : Image width in pixels. -// - height : Image height in pixels. -// - dst_frame : Pointer to a destination frame. -// - interlaced : Flag indicating if interlaced I420 output. -// - rotate : Rotation mode of output image. -// Return value: 0 if OK, < 0 otherwise. -// -// Note: the following functions includes the most common usage cases; for -// a more specific usage, refer to explicit function. -int ConvertToI420(VideoType src_video_type, - const uint8_t* src_frame, - int width, - int height, - uint8_t* dst_frame, - bool interlaced, - VideoRotationMode rotate); - -// The previous function will soon be removed. -// TODO(mikhal): Remove legacy function after integration. - -// Convert From/To I420 +// Convert To I420 // Input: // - src_video_type : Type of input video. // - src_frame : Pointer to a source frame. @@ -132,20 +101,7 @@ int ConvertToI420(VideoType src_video_type, VideoRotationMode rotation, uint8_t* dst_frame); -// TODO(andrew): return to the int width and height types. This was swapped -// temporarily to satisfy a linking error with the libjingle revision we and -// Chrome pull, due to the removed vplib. -int ConvertFromI420(VideoType dst_video_type, - const uint8_t* src_frame, - //int width, - //int height, - WebRtc_UWord32 width, - WebRtc_UWord32 height, - uint8_t* dst_frame, - bool interlaced, - VideoRotationMode rotate); -// The previous function will soon be removed. -// TODO(mikhal): Remove legacy function after integration. +// Convert From I420 // Input: // - src_frame : Pointer to a source frame. // - src_stride : Number of bytes in a row of the src Y plane. @@ -168,19 +124,12 @@ int ConvertFromYV12(const uint8_t* src_frame, int src_stride, int width, int height, uint8_t* dst_frame); -// The following list describes the designated conversion function which -// are called by the two prior general conversion function. +// The following list describes designated conversion functions which +// are not covered by the previous general functions. // Input and output descriptions mostly match the above descriptions, and are // therefore omitted. // Possible additional input value - dst_stride - stride of the dst frame. -int ConvertI420ToRGB24(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height); -int ConvertI420ToARGB(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height, - int dst_stride); int ConvertI420ToARGB4444(const uint8_t* src_frame, uint8_t* dst_frame, int width, @@ -190,140 +139,19 @@ int ConvertI420ToRGB565(const uint8_t* src_frame, uint8_t* dst_frame, int width, int height); -int ConvertI420ToRGB565Android(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, - int height); int ConvertI420ToARGB1555(const uint8_t* src_frame, uint8_t* dst_frame, int width, int height, int dst_stride); -int ConvertI420ToARGBMac(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height, - int dst_stride); -int ConvertI420ToRGBAMac(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height, - int dst_stride); -int ConvertI420ToI420(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height, - int dst_stride = 0); -int ConvertI420ToUYVY(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height, - int dst_stride = 0); -int ConvertI420ToYUY2(const uint8_t* src_frame, uint8_t* dst_frame, - int width, int height, - int dst_stride = 0); -int ConvertI420ToYV12(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height, - int dst_stride); -int ConvertYUY2ToI420(int width, int height, - const uint8_t* src_frame, - uint8_t* dst_frame); -int ConvertYV12ToI420(const uint8_t* src_frame, - int width, int height, - uint8_t* dst_frame); int ConvertRGB24ToARGB(const uint8_t* src_frame, uint8_t* dst_frame, int width, int height, int dst_stride); -int ConvertRGB24ToI420(int width, int height, - const uint8_t* src_frame, - uint8_t* dst_frame); - -int ConvertARGBMacToI420(int width, int height, - const uint8_t* src_frame, - uint8_t* dst_frame); -int ConvertUYVYToI420(int width, int height, - const uint8_t* src_frame, - uint8_t* dst_frame); - -// NV12 conversion and rotation -int ConvertNV12ToI420(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height); -int ConvertNV12ToI420AndRotate180(const uint8_t* src_frame, - uint8_t* dst_frame, int width, - int height); -int ConvertNV12ToI420AndRotateAntiClockwise(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, - int height); -int ConvertNV12ToI420AndRotateClockwise(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, - int height); int ConvertNV12ToRGB565(const uint8_t* src_frame, uint8_t* dst_frame, int width, int height); -// NV21 Conversion/Rotation -int ConvertNV21ToI420(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height); -int ConvertNV21ToI420AndRotate180(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height); -// TODO (mikhal): Rename to counterClockwise. -int ConvertNV21ToI420AndRotateAntiClockwise(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, - int height); -int ConvertNV21ToI420AndRotateClockwise(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, - int height); - -// IPhone -int ConvertI420ToRGBAIPhone(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height, - int dst_stride); - -int I420Rotate(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height, - VideoRotationMode rotation_mode); -// Following three functions: -// Convert from I420/YV12 to I420 and rotate. -// Input: -// - src_frame : Pointer to a source frame. -// - src_width : Width of source frame in pixels. -// - src_height : Height of source frame in pixels. -// - dst_frame : Pointer to a destination frame. -// - dst_width : Width of destination frame in pixels. -// - dst_height : Height of destination frame in pixels. -// - src_color_space : Input color space. -// Return value: 0 if OK, < 0 otherwise. -int ConvertToI420AndRotateClockwise(const uint8_t* src_frame, - int src_width, - int src_height, - uint8_t* dst_frame, - int dst_width, - int dst_height, - VideoType src_video_type); - -int ConvertToI420AndRotateAntiClockwise(const uint8_t* src_frame, - int src_width, - int src_height, - uint8_t* dst_frame, - int dst_width, - int dst_height, - VideoType src_video_type); - -int ConvertToI420AndRotate180(const uint8_t* srcBuffer, - int srcWidth, - int srcHeight, - uint8_t* dstBuffer, - int dst_width, - int dst_height, - VideoType src_video_type); - // Mirror functions // The following 2 functions perform mirroring on a given image // (LeftRight/UpDown). @@ -355,12 +183,6 @@ int ConvertToI420AndMirrorUpDown(const uint8_t* src_frame, int src_height, VideoType src_video_type); -int ConvertToI420AndRotate(const uint8_t* src_frame, - uint8_t* dst_frame, - int height, - int width, - VideoType src_video_type, - VideoRotationMode mode); // Compute PSNR for an I420 frame (all planes). double I420PSNR(const uint8_t* ref_frame, const uint8_t* test_frame, diff --git a/src/common_video/libyuv/libyuv.cc b/src/common_video/libyuv/libyuv.cc index af80968a8..4a70747bc 100644 --- a/src/common_video/libyuv/libyuv.cc +++ b/src/common_video/libyuv/libyuv.cc @@ -145,54 +145,6 @@ int CalcBufferSize(VideoType src_video_type, return (length * dst_bits_per_pixel) / src_bits_per_pixel; } -int ConvertI420ToRGB24(const uint8_t* src_frame, uint8_t* dst_frame, - int width, int height) { - const uint8_t* yplane = src_frame; - const uint8_t* uplane = yplane + width * height; - const uint8_t* vplane = uplane + (width * height / 4); - - return libyuv::I420ToRGB24(yplane, width, - uplane, width / 2, - vplane, width / 2, - dst_frame, width * 3, - width, height); -} - -int ConvertI420ToARGB(const uint8_t* src_frame, uint8_t* dst_frame, - int width, int height, - int dst_stride) { - if (dst_stride == 0 || dst_stride == width) - dst_stride = width * 4; - const uint8_t* yplane = src_frame; - const uint8_t* uplane = src_frame + width * height; - const uint8_t* vplane = uplane + (width * height / 4); - - return libyuv::I420ToARGB(yplane, width, - uplane, width / 2, - vplane, width / 2, - dst_frame, dst_stride, - width, height); -} - -int ConvertI420ToRGBAMac(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height, - int dst_stride) { - // Equivalent to Convert YV12ToBGRA. - // YV12 same as I420 with U and V swapped. - if (dst_stride == 0 || dst_stride == width) - dst_stride = 4 * width; - const uint8_t* yplane = src_frame; - const uint8_t* uplane = src_frame + width * height; - const uint8_t* vplane = uplane + (width * height / 4); - - return libyuv::I420ToBGRA(yplane, width, - vplane, width / 2, - uplane, width / 2, - dst_frame, dst_stride, - width, height); -} - int ConvertI420ToARGB4444(const uint8_t* src_frame, uint8_t* dst_frame, int width, int height, @@ -225,25 +177,6 @@ int ConvertI420ToRGB565(const uint8_t* src_frame, width, height); } - -// Same as ConvertI420ToRGB565 with a vertical flip. -// TODO (mikhal): Deprecate -int ConvertI420ToRGB565Android(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height) { - const uint8_t* yplane = src_frame; - const uint8_t* uplane = src_frame + width * height; - const uint8_t* vplane = uplane + (width * height / 4); - - // Same as RGB565 + inversion - set negative height. - height = -height; - return libyuv::I420ToRGB565(yplane, width, - uplane, width / 2, - vplane, width / 2, - dst_frame, width, - width, height); -} - int ConvertI420ToARGB1555(const uint8_t* src_frame, uint8_t* dst_frame, int width, int height, @@ -264,155 +197,6 @@ int ConvertI420ToARGB1555(const uint8_t* src_frame, width, height); } -int ConvertI420ToYUY2(const uint8_t* src_frame, uint8_t* dst_frame, - int width, int height, - int dst_stride) { - const uint8_t* yplane = src_frame; - const uint8_t* uplane = src_frame + width * height; - const uint8_t* vplane = uplane + (width * height / 4); - if (dst_stride == 0 || dst_stride == width) - dst_stride = 2 * width; - - return libyuv::I420ToYUY2(yplane, width, - uplane, width / 2, - vplane, width / 2, - dst_frame, dst_stride, - width, height); -} - -int ConvertI420ToUYVY(const uint8_t* src_frame, uint8_t* dst_frame, - int width, int height, - int dst_stride) { - if (dst_stride == 0 || dst_stride == width) - dst_stride = 2 * width; - else if (dst_stride < width) - return -1; - const uint8_t* yplane = src_frame; - const uint8_t* uplane = src_frame + width * height; - const uint8_t* vplane = uplane + (width * height / 4); - - return libyuv::I420ToUYVY(yplane, width, - uplane, width / 2, - vplane, width / 2, - dst_frame, dst_stride, - width, height); -} - -int ConvertI420ToYV12(const uint8_t* src_frame, uint8_t* dst_frame, - int width, int height, - int dst_stride) { - if (dst_stride == 0 || dst_stride == width) - dst_stride = width; - else if (dst_stride < width) - return -1; - - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uplane = src_frame + width * height; - const uint8_t* src_vplane = src_uplane + (width * height / 4); - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + width * height; - uint8_t* dst_vplane = dst_uplane + (width * height / 4); - - // YV12 is YVU => Use I420(YUV) copy and flip U and V. - return libyuv::I420Copy(src_yplane, width, - src_vplane, width / 2, - src_uplane, width / 2, - dst_yplane, dst_stride, - dst_uplane, dst_stride / 2, - dst_vplane, dst_stride / 2, - width, height); -} - -int ConvertYV12ToI420(const uint8_t* src_frame, - int width, int height, - uint8_t* dst_frame) { - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uplane = src_frame + width * height; - const uint8_t* src_vplane = src_uplane + (width * height / 4); - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + width * height; - uint8_t* dst_vplane = dst_uplane + (width * height / 4); - - // YV12 is YVU => Use I420(YUV) copy and flip U and V. - return libyuv::I420Copy(src_yplane, width, - src_vplane, width / 2, - src_uplane, width / 2, - dst_yplane, width, - dst_uplane, width / 2, - dst_vplane, width / 2, - width, height); -} - -int ConvertNV12ToI420(const uint8_t* src_frame, uint8_t* dst_frame, - int width, int height) { - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uvplane = src_frame + width * height; - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + width * height; - uint8_t* dst_vplane = dst_uplane + (width * height / 4); - return libyuv::NV12ToI420(src_yplane, width, - src_uvplane, width, - dst_yplane, width, - dst_uplane, width / 2, - dst_vplane, width / 2, - width, height); -} - -int ConvertNV12ToI420AndRotate180(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height) { - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uvplane = src_frame + width * height; - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + width * height; - uint8_t* dst_vplane = dst_uplane + (width * height / 4); - - return libyuv::NV12ToI420Rotate(src_yplane, width, - src_uvplane, width, - dst_yplane, width, - dst_uplane, width / 2, - dst_vplane, width / 2, - width, height, - libyuv::kRotate180); -} - -int ConvertNV12ToI420AndRotateClockwise(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height) { - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uvplane = src_frame + width * height; - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + width * height; - uint8_t* dst_vplane = dst_uplane + (width * height / 4); - - return libyuv::NV12ToI420Rotate(src_yplane, width, - src_uvplane, width, - dst_yplane, width, - dst_uplane, width / 2, - dst_vplane, width / 2, - width, height, - libyuv::kRotate90); -} - -int ConvertNV12ToI420AndRotateAntiClockwise(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, - int height) { - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uvplane = src_frame + width * height; - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + width * height; - uint8_t* dst_vplane = dst_uplane + (width * height / 4); - - return libyuv::NV12ToI420Rotate(src_yplane, width, - src_uvplane, width, - dst_yplane, width, - dst_uplane, width / 2, - dst_vplane, width / 2, - width, height, - libyuv::kRotate270); -} - int ConvertNV12ToRGB565(const uint8_t* src_frame, uint8_t* dst_frame, int width, int height) { @@ -425,144 +209,6 @@ int ConvertNV12ToRGB565(const uint8_t* src_frame, width, height); } -int ConvertNV21ToI420(const uint8_t* src_frame, uint8_t* dst_frame, - int width, int height) { - // NV21 = y plane followed by an interleaved V/U plane, i.e. same as NV12 - // but the U and the V are switched. Use the NV12 function and switch the U - // and V planes. - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uvplane = src_frame + width * height; - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + width * height; - uint8_t* dst_vplane = dst_uplane + (width * height / 4); - return libyuv::NV12ToI420(src_yplane, width, - src_uvplane, width, - dst_yplane, width, - dst_vplane, width / 2, - dst_uplane, width / 2, - width, height); -} - -int ConvertNV21ToI420AndRotate180(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height) { - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uvplane = src_frame + width * height; - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + width * height; - uint8_t* dst_vplane = dst_uplane + (width * height / 4); - - return libyuv::NV12ToI420Rotate(src_yplane, width, - src_uvplane, width, - dst_yplane, width, - dst_vplane, width / 2, - dst_uplane, width / 2, - width, height, - libyuv::kRotate180); -} - -int ConvertNV21ToI420AndRotateClockwise(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height) { - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uvplane = src_frame + width * height; - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + width * height; - uint8_t* dst_vplane = dst_uplane + (width * height / 4); - - return libyuv::NV12ToI420Rotate(src_yplane, width, - src_uvplane, width, - dst_yplane, width, - dst_vplane, width / 2, - dst_uplane, width / 2, - width, height, - libyuv::kRotate90); -} - -int ConvertNV21ToI420AndRotateAntiClockwise(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, - int height) { - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uvplane = src_frame + width * height; - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + width * height; - uint8_t* dst_vplane = dst_uplane + (width * height / 4); - - return libyuv::NV12ToI420Rotate(src_yplane, width, - src_uvplane, width, - dst_yplane, width, - dst_vplane, width / 2, - dst_uplane, width / 2, - width, height, - libyuv::kRotate270); -} - -int ConvertI420ToRGBAIPhone(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height, - int dst_stride) { - if (dst_stride == 0 || dst_stride == width) - dst_stride = 4 * width; - else if (dst_stride < 4 * width) - return -1; - - const uint8_t* yplane = src_frame; - const uint8_t* uplane = src_frame + width * height; - const uint8_t* vplane = uplane + (width * height / 4); - - // RGBAIPhone = ABGR - return libyuv::I420ToABGR(yplane, width, - uplane, width / 2, - vplane, width / 2, - dst_frame, dst_stride, - width, height); -} - -int ConvertI420ToI420(const uint8_t* src_frame, uint8_t* dst_frame, - int width, - int height, int dst_stride) { - if (dst_stride == 0) - dst_stride = width; - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uplane = src_frame + width * height; - const uint8_t* src_vplane = src_uplane + (width * height / 4); - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + width * height; - uint8_t* dst_vplane = dst_uplane + (width * height / 4); - return libyuv::I420Copy(src_yplane, width, - src_uplane, width / 2, - src_vplane, width / 2, - dst_yplane, dst_stride, - dst_uplane, dst_stride / 2, - dst_vplane, dst_stride / 2, - width, height); -} - -int ConvertUYVYToI420(int width, int height, - const uint8_t* src_frame, uint8_t* dst_frame) { - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + width * height; - uint8_t* dst_vplane = dst_uplane + (width * height / 4); - return libyuv::UYVYToI420(src_frame, 2 * width, - dst_yplane, width, - dst_uplane, width / 2, - dst_vplane, width / 2, - width, height); -} - -int ConvertYUY2ToI420(int width, int height, - const uint8_t* src_frame, uint8_t* dst_frame) { - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + width * height; - uint8_t* dst_vplane = dst_uplane + (width * height / 4); - return libyuv::YUY2ToI420(src_frame, 2 * width, - dst_yplane, width, - dst_uplane, width / 2, - dst_vplane, width / 2, - width, height); -} - int ConvertRGB24ToARGB(const uint8_t* src_frame, uint8_t* dst_frame, int width, int height, int dst_stride) { if (dst_stride == 0 || dst_stride == width) @@ -573,51 +219,6 @@ int ConvertRGB24ToARGB(const uint8_t* src_frame, uint8_t* dst_frame, width, height); } -int ConvertRGB24ToI420(int width, int height, - const uint8_t* src_frame, uint8_t* dst_frame) { - uint8_t* yplane = dst_frame; - uint8_t* uplane = yplane + width * height; - uint8_t* vplane = uplane + (width * height / 4); - return libyuv::RGB24ToI420(src_frame, width * 3, - yplane, width, - uplane, width / 2, - vplane, width / 2, - width, height); -} - -int ConvertI420ToARGBMac(const uint8_t* src_frame, uint8_t* dst_frame, - int width, int height, int dst_stride) { - // Equivalent to YV12ToARGB. - // YV12 = YVU => use I420 and interchange U and V. - const uint8_t* yplane = src_frame; - const uint8_t* uplane = yplane + width * height; - const uint8_t* vplane = uplane + (width * height / 4); - - if (dst_stride == 0 || dst_stride == width) - dst_stride = 4 * width; - else if (dst_stride < 4 * width) - return -1; - - return libyuv::I420ToARGB(yplane, width, - vplane, width / 2, - uplane, width / 2, - dst_frame, dst_stride, - width, height); -} - -int ConvertARGBMacToI420(int width, int height, - const uint8_t* src_frame, uint8_t* dst_frame) { - // Equivalent to BGRAToI420 - uint8_t* yplane = dst_frame; - uint8_t* uplane = yplane + width * height; - uint8_t* vplane = uplane + (width * height / 4); - return libyuv::BGRAToI420(src_frame, width * 4, - yplane, width, - uplane, width / 2, - vplane, width / 2, - width, height); -} - libyuv::RotationMode ConvertRotationMode(VideoRotationMode rotation) { switch(rotation) { case kRotateNone: @@ -647,6 +248,12 @@ int ConvertVideoType(VideoType video_type) { return libyuv::FOURCC_24BG; case kABGR: return libyuv::FOURCC_ABGR; + case kARGB4444: + case kRGB565: + case kARGB1555: + // TODO(mikhal): Not supported; + assert(false); + return libyuv::FOURCC_ANY; case kYUY2: return libyuv::FOURCC_YUY2; case kUYVY: @@ -721,138 +328,6 @@ int ConvertFromYV12(const uint8_t* src_frame, int src_stride, ConvertVideoType(dst_video_type)); } -int ConvertToI420(VideoType src_video_type, - const uint8_t* src_frame, - int width, - int height, - uint8_t* dst_frame, - bool interlaced, - VideoRotationMode rotate /* = kRotateNone */) { - switch (src_video_type) { - case kRGB24: - return ConvertRGB24ToI420(width, height, src_frame, - dst_frame); - case kARGB: - return ConvertARGBMacToI420(width, height, src_frame, - dst_frame); - case kI420: - return I420Rotate(src_frame, - dst_frame, - width, height, - rotate); - case kYUY2: - return ConvertYUY2ToI420(width, height, - src_frame, dst_frame); - case kUYVY: - return ConvertUYVYToI420(width, height, src_frame, - dst_frame); - case kYV12: - switch (rotate) { - case kRotateNone: - return ConvertYV12ToI420(src_frame, - width, height, - dst_frame); - case kRotate90: - return ConvertToI420AndRotateClockwise(src_frame, - width, - height, - dst_frame, - height, width, - kYV12); - case kRotate270: - return ConvertToI420AndRotateAntiClockwise(src_frame, - width, height, - dst_frame, - height, width, - kYV12); - case kRotate180: - return ConvertToI420AndRotate180(src_frame, - width, height, - dst_frame, - height, width, - kYV12); - } - case kNV12: - switch (rotate) { - case kRotateNone: - return ConvertNV12ToI420(src_frame, dst_frame, - width, height); - case kRotate90: - return ConvertNV12ToI420AndRotateClockwise(src_frame, - dst_frame, - width, height); - case kRotate270: - return ConvertNV12ToI420AndRotateAntiClockwise(src_frame, - dst_frame, - width, height); - case kRotate180: - return ConvertNV12ToI420AndRotate180(src_frame, - dst_frame, - width, height); - } - case kNV21: - switch (rotate) { - case kRotateNone: - return ConvertNV21ToI420(src_frame, - dst_frame, - width, height); - case kRotate90: - return ConvertNV21ToI420AndRotateClockwise(src_frame, - dst_frame, - width, height); - case kRotate270: - return ConvertNV21ToI420AndRotateAntiClockwise(src_frame, - dst_frame, - width, height); - case kRotate180: - return ConvertNV21ToI420AndRotate180(src_frame, - dst_frame, - width, height); - } - break; - default: - return -1; - } - return -1; -} - -int ConvertFromI420(VideoType dst_video_type, - const uint8_t* src_frame, - //int width, - //int height, - WebRtc_UWord32 width, - WebRtc_UWord32 height, - uint8_t* dst_frame, - bool interlaced, - VideoRotationMode rotate) { - switch (dst_video_type) { - case kRGB24: - return ConvertI420ToRGB24(src_frame, dst_frame, width, height); - case kARGB: - return ConvertI420ToARGB(src_frame, dst_frame, width, height, 0); - case kARGB4444: - return ConvertI420ToARGB4444(src_frame, dst_frame, width, height, 0); - case kARGB1555: - return ConvertI420ToARGB1555(src_frame, dst_frame, width, height, 0); - case kRGB565: - return ConvertI420ToRGB565(src_frame, dst_frame, width, height); - case kI420: - return ConvertI420ToI420(src_frame, dst_frame, width, height, width); - case kUYVY: - return ConvertI420ToUYVY(src_frame, dst_frame, width, height); - case kYUY2: - return ConvertI420ToYUY2(src_frame, dst_frame, width, height, 0); - case kYV12: - return ConvertI420ToYV12(src_frame, dst_frame, width, height, 0); - case kRGBAMac: - return ConvertI420ToRGBAMac(src_frame, dst_frame, width, height, 0); - case kARGBMac: - return ConvertI420ToARGBMac(src_frame, dst_frame, width, height, 0); - default: - return -1; - } -} - int MirrorI420LeftRight(const uint8_t* src_frame, uint8_t* dst_frame, int width, int height) { @@ -920,119 +395,6 @@ int ConvertToI420AndMirrorUpDown(const uint8_t* src_frame, src_width, -src_height); } -int I420Rotate(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height, - VideoRotationMode rotation_mode) { - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uplane = src_frame + width * height; - const uint8_t* src_vplane = src_uplane + (width * height / 4); - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + width * height; - uint8_t* dst_vplane = dst_uplane + (width * height / 4); - return libyuv::I420Rotate(src_yplane, width, - src_uplane, width / 2, - src_vplane, width / 2, - dst_yplane, width, - dst_uplane, width / 2, - dst_vplane, width / 2, - width, height, - static_cast(rotation_mode)); -} - -// TODO(mikhal): modify API to use only the general function. -int ConvertToI420AndRotateClockwise(const uint8_t* src_frame, - int src_width, - int src_height, - uint8_t* dst_frame, - int dst_width, - int dst_height, - VideoType src_video_type) { - if (src_video_type != kI420 && src_video_type != kYV12) - return -1; - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uplane = src_frame + src_width * src_height; - const uint8_t* src_vplane = src_uplane + (src_width * src_height / 4); - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + src_width * src_height; - uint8_t* dst_vplane = dst_uplane + (src_width * src_height / 4); - if (src_video_type == kYV12) { - // Switch U and V - dst_vplane = dst_frame + src_width * src_height; - dst_uplane = dst_vplane + (src_width * src_height / 4); - } - return libyuv::I420Rotate(src_yplane, src_width, - src_uplane, src_width / 2, - src_vplane, src_width / 2, - dst_yplane, src_width, - dst_uplane, src_width / 2, - dst_vplane, src_width / 2, - src_width, src_height, - libyuv::kRotate90); -} - -// TODO(mikhal): modify API to use only the general function. -int ConvertToI420AndRotateAntiClockwise(const uint8_t* src_frame, - int src_width, - int src_height, - uint8_t* dst_frame, - int dst_width, - int dst_height, - VideoType src_video_type) { - if (src_video_type != kI420 && src_video_type != kYV12) - return -1; - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uplane = src_frame + src_width * src_height; - const uint8_t* src_vplane = src_uplane + (src_width * src_height / 4); - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + src_width * src_height; - uint8_t* dst_vplane = dst_uplane + (src_width * src_height / 4); - if (src_video_type == kYV12) { - // Switch U and V - dst_vplane = dst_frame + src_width * src_height; - dst_uplane = dst_vplane + (src_width * src_height / 4); - } - return libyuv::I420Rotate(src_yplane, src_width, - src_uplane, src_width / 2, - src_vplane, src_width / 2, - dst_yplane, src_width, - dst_uplane, src_width / 2, - dst_vplane, src_width / 2, - src_width, src_height, - libyuv::kRotate270); -} - -// TODO(mikhal): modify API to use only the general function. -int ConvertToI420AndRotate180(const uint8_t* src_frame, - int src_width, - int src_height, - uint8_t* dst_frame, - int dst_width, - int dst_height, - VideoType src_video_type) { - if (src_video_type != kI420 && src_video_type != kYV12) - return -1; - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uplane = src_frame + src_width * src_height; - const uint8_t* src_vplane = src_uplane + (src_width * src_height / 4); - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + src_width * src_height; - uint8_t* dst_vplane = dst_uplane + (src_width * src_height / 4); - if (src_video_type == kYV12) { - // Switch U and V - dst_vplane = dst_frame + src_width * src_height; - dst_uplane = dst_vplane + (src_width * src_height / 4); - } - return libyuv::I420Rotate(src_yplane, src_width, - src_uplane, src_width / 2, - src_vplane, src_width / 2, - dst_yplane, src_width, - dst_uplane, src_width / 2, - dst_vplane, src_width / 2, - src_width, src_height, - libyuv::kRotate180); -} - // Compute PSNR for an I420 frame (all planes) double I420PSNR(const uint8_t* ref_frame, const uint8_t* test_frame,