}
}
+static void __mm_util_crop_nv12(const unsigned char *src, unsigned int src_width, unsigned int src_height,
+unsigned int crop_start_x, unsigned int crop_start_y, unsigned int crop_dest_width, unsigned int crop_dest_height, unsigned char *dst)
+{
+ unsigned int idx = 0;
+ unsigned int start_x = crop_start_x;
+ unsigned int start_y = crop_start_y;
+
+ const unsigned char *_src = src + start_y * src_width + start_x;
+
+ /* Y */
+ for (idx = 0; idx < crop_dest_height; idx++) {
+ memcpy(dst, _src, crop_dest_width);
+ _src += src_width;
+ dst += crop_dest_width;
+ }
+
+ /* UV */
+ _src = src + src_height * src_width + (start_y / 2) * src_width + start_x;
+ for (idx = 0; idx < crop_dest_height / 2; idx++) {
+ memcpy(dst, _src, crop_dest_width);
+ _src += src_width;
+ dst += crop_dest_width;
+ }
+}
+
static IMGPInfoFunc __mm_util_initialize(GModule **module)
{
GModule *_module = NULL;
if (_src->color == MM_UTIL_COLOR_I420 || _src->color == MM_UTIL_COLOR_YUV420) {
if ((_width % 2) != 0) {
- _width = ((_width+1)>>1)<<1;
+ _width = ((_width + 1) >> 1) << 1;
mm_util_warn("width must be even. change from [%d] to [%d]", width, _width);
}
if ((_height % 2) != 0) {
- _height = ((_height+1)>>1)<<1;
+ _height = ((_height + 1) >> 1) << 1;
mm_util_warn("height must be even. change from [%d] to [%d]", height, _height);
}
}
_buffer = g_malloc0(_buffer_size);
switch (_src->color) {
- case MM_UTIL_COLOR_RGB16: {
+ case MM_UTIL_COLOR_RGB16:
__mm_util_crop_rgb16(_src->data, _src->width, _src->height, start_x, start_y, _width, _height, _buffer);
break;
- }
- case MM_UTIL_COLOR_RGB24: {
+ case MM_UTIL_COLOR_RGB24:
__mm_util_crop_rgb24(_src->data, _src->width, _src->height, start_x, start_y, _width, _height, _buffer);
break;
- }
case MM_UTIL_COLOR_ARGB:
case MM_UTIL_COLOR_BGRA:
case MM_UTIL_COLOR_RGBA:
- case MM_UTIL_COLOR_BGRX: {
+ case MM_UTIL_COLOR_BGRX:
__mm_util_crop_rgb32(_src->data, _src->width, _src->height, start_x, start_y, _width, _height, _buffer);
break;
- }
case MM_UTIL_COLOR_I420:
- case MM_UTIL_COLOR_YUV420: {
+ case MM_UTIL_COLOR_YUV420:
__mm_util_crop_yuv420(_src->data, _src->width, _src->height, start_x, start_y, _width, _height, _buffer);
break;
- }
+ case MM_UTIL_COLOR_NV12:
+ __mm_util_crop_nv12(_src->data, _src->width, _src->height, start_x, start_y, _width, _height, _buffer);
+ break;
default:
mm_util_error("Not supported format [%d]", _src->color);
g_free(_buffer);