From c5f4358c48d6e50b2affb3ad6c2c0f59546f5b04 Mon Sep 17 00:00:00 2001 From: Kyle Repinski Date: Wed, 7 Jan 2015 08:39:28 -0600 Subject: camera: Update camera HAL. OmapZoom p-jb-release branch with 'CameraHal: Camera Capabilities query update' reverted, as well as a bunch of stuff ifdef'd out. Needs a lot of work still. At this point it's a regression, but it has to be done. --- camera/Encoder_libjpeg.cpp | 103 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 87 insertions(+), 16 deletions(-) (limited to 'camera/Encoder_libjpeg.cpp') diff --git a/camera/Encoder_libjpeg.cpp b/camera/Encoder_libjpeg.cpp index 6e99a25..e11e3bf 100644 --- a/camera/Encoder_libjpeg.cpp +++ b/camera/Encoder_libjpeg.cpp @@ -23,11 +23,9 @@ * */ -#define LOG_TAG "CameraHAL" - -#include "CameraHal.h" #include "Encoder_libjpeg.h" #include "NV12_resize.h" +#include "TICameraParameters.h" #include #include @@ -46,7 +44,9 @@ extern "C" { #define ARRAY_SIZE(array) (sizeof((array)) / sizeof((array)[0])) #define MIN(x,y) ((x < y) ? x : y) -namespace android { +namespace Ti { +namespace Camera { + struct integer_string_pair { unsigned int integer; const char* string; @@ -151,7 +151,7 @@ static void uyvy_to_yuv(uint8_t* dst, uint32_t* src, int width) { " blt 5f \n\t" "0: @ 16 pixel swap \n\t" " vld2.8 {q0, q1} , [%[src]]! @ q0 = uv q1 = y \n\t" - " vuzp.8 q0, q2 @ d1 = u d5 = v \n\t" + " vuzp.8 q0, q2 @ d0 = u d4 = v \n\t" " vmov d1, d0 @ q0 = u0u1u2..u0u1u2... \n\t" " vmov d5, d4 @ q2 = v0v1v2..v0v1v2... \n\t" " vzip.8 d0, d1 @ q0 = u0u0u1u1u2u2... \n\t" @@ -173,6 +173,61 @@ static void uyvy_to_yuv(uint8_t* dst, uint32_t* src, int width) { } } +static void yuyv_to_yuv(uint8_t* dst, uint32_t* src, int width) { + if (!dst || !src) { + return; + } + + if (width % 2) { + return; // not supporting odd widths + } + + // currently, neon routine only supports multiple of 16 width + if (width % 16) { + while ((width-=2) >= 0) { + uint8_t y0 = (src[0] >> 0) & 0xFF; + uint8_t u0 = (src[0] >> 8) & 0xFF; + uint8_t y1 = (src[0] >> 16) & 0xFF; + uint8_t v0 = (src[0] >> 24) & 0xFF; + dst[0] = y0; + dst[1] = u0; + dst[2] = v0; + dst[3] = y1; + dst[4] = u0; + dst[5] = v0; + dst += 6; + src++; + } + } else { + int n = width; + asm volatile ( + " pld [%[src], %[src_stride], lsl #2] \n\t" + " cmp %[n], #16 \n\t" + " blt 5f \n\t" + "0: @ 16 pixel swap \n\t" + " vld2.8 {q0, q1} , [%[src]]! @ q0 = yyyy.. q1 = uvuv.. \n\t" + " vuzp.8 q1, q2 @ d2 = u d4 = v \n\t" + " vmov d3, d2 @ q1 = u0u1u2..u0u1u2... \n\t" + " vmov d5, d4 @ q2 = v0v1v2..v0v1v2... \n\t" + " vzip.8 d2, d3 @ q1 = u0u0u1u1u2u2... \n\t" + " vzip.8 d4, d5 @ q2 = v0v0v1v1v2v2... \n\t" + " @ now q0 = y q1 = u q2 = v \n\t" + " vst3.8 {d0,d2,d4},[%[dst]]! \n\t" + " vst3.8 {d1,d3,d5},[%[dst]]! \n\t" + " sub %[n], %[n], #16 \n\t" + " cmp %[n], #16 \n\t" + " bge 0b \n\t" + "5: @ end \n\t" +#ifdef NEEDS_ARM_ERRATA_754319_754320 + " vmov s0,s0 @ add noop for errata item \n\t" +#endif + : [dst] "+r" (dst), [src] "+r" (src), [n] "+r" (n) + : [src_stride] "r" (width) + : "cc", "memory", "q0", "q1", "q2" + ); + } +} + static void resize_nv12(Encoder_libjpeg::params* params, uint8_t* dst_buffer) { structConvImage o_img_ptr, i_img_ptr; @@ -269,7 +324,11 @@ void ExifElementsTable::insertExifToJpeg(unsigned char* jpeg, size_t jpeg_size) ResetJpgfile(); if (ReadJpegSectionsFromBuffer(jpeg, jpeg_size, read_mode)) { jpeg_opened = true; +#ifdef ANDROID_API_JB_OR_LATER create_EXIF(table, exif_tag_count, gps_tag_count, has_datetime_tag); +#else + create_EXIF(table, exif_tag_count, gps_tag_count); +#endif } } @@ -336,7 +395,14 @@ status_t ExifElementsTable::insertElement(const char* tag, const char* value) { exif_tag_count++; if (strcmp(tag, TAG_DATETIME) == 0) { +#ifdef ANDROID_API_JB_OR_LATER has_datetime_tag = true; +#else + // jhead isn't taking datetime tag...this is a WA + ImageInfo.numDateTimeTags = 1; + memcpy(ImageInfo.DateTime, value, + MIN(ARRAY_SIZE(ImageInfo.DateTime), value_length + 1)); +#endif } } @@ -388,20 +454,21 @@ size_t Encoder_libjpeg::encode(params* input) { goto exit; } - if (strcmp(input->format, CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { + if (strcmp(input->format, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { bpp = 1; if ((in_width != out_width) || (in_height != out_height)) { resize_src = (uint8_t*) malloc(input->dst_size); resize_nv12(input, resize_src); if (resize_src) src = resize_src; } - } else if ((in_width != out_width) || (in_height != out_height)) { - CAMHAL_LOGEB("Encoder: resizing is not supported for this format: %s", input->format); - goto exit; - } else if (strcmp(input->format, CameraParameters::PIXEL_FORMAT_YUV422I)) { + } else if (strcmp(input->format, android::CameraParameters::PIXEL_FORMAT_YUV422I) && + strcmp(input->format, TICameraParameters::PIXEL_FORMAT_YUV422I_UYVY)) { // we currently only support yuv422i and yuv420sp CAMHAL_LOGEB("Encoder: format not supported: %s", input->format); goto exit; + } else if ((in_width != out_width) || (in_height != out_height)) { + CAMHAL_LOGEB("Encoder: resizing is not supported for this format: %s", input->format); + goto exit; } cinfo.err = jpeg_std_error(&jerr); @@ -413,9 +480,10 @@ size_t Encoder_libjpeg::encode(params* input) { "height:%d \n\t" "dest %p \n\t" "dest size:%d \n\t" - "mSrc %p", + "mSrc %p \n\t" + "format: %s", out_width, out_height, input->dst, - input->dst_size, src); + input->dst_size, src, input->format); cinfo.dest = &dest_mgr; cinfo.image_width = out_width - right_crop; @@ -438,10 +506,12 @@ size_t Encoder_libjpeg::encode(params* input) { JSAMPROW row[1]; /* pointer to JSAMPLE row[s] */ // convert input yuv format to yuv444 - if (strcmp(input->format, CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { + if (strcmp(input->format, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { nv21_to_yuv(row_tmp, row_src, row_uv, out_width - right_crop); - } else { + } else if (strcmp(input->format, TICameraParameters::PIXEL_FORMAT_YUV422I_UYVY) == 0) { uyvy_to_yuv(row_tmp, (uint32_t*)row_src, out_width - right_crop); + } else if (strcmp(input->format, android::CameraParameters::PIXEL_FORMAT_YUV422I) == 0) { + yuyv_to_yuv(row_tmp, (uint32_t*)row_src, out_width - right_crop); } row[0] = row_tmp; @@ -449,7 +519,7 @@ size_t Encoder_libjpeg::encode(params* input) { row_src = row_src + out_width*bpp; // move uv row if input format needs it - if (strcmp(input->format, CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { + if (strcmp(input->format, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { if (!(cinfo.next_scanline % 2)) row_uv = row_uv + out_width * bpp; } @@ -469,4 +539,5 @@ size_t Encoder_libjpeg::encode(params* input) { return dest_mgr.jpegsize; } -} // namespace android +} // namespace Camera +} // namespace Ti -- cgit v1.1