Home | History | Annotate | Download | only in jni

Lines Matching refs:buffer

87     void returnLockedBuffer(CpuConsumer::LockedBuffer* buffer);
123 CpuConsumer::LockedBuffer *buffer = new CpuConsumer::LockedBuffer;
124 mBuffers.push_back(buffer);
159 CpuConsumer::LockedBuffer* buffer = *it;
161 return buffer;
164 void JNIImageReaderContext::returnLockedBuffer(CpuConsumer::LockedBuffer* buffer) {
165 mBuffers.push_back(buffer);
261 const CpuConsumer::LockedBuffer* buffer)
263 env->SetLongField(thiz, gSurfaceImageClassInfo.mLockedBuffer, reinterpret_cast<jlong>(buffer));
289 static uint32_t Image_getJpegSize(CpuConsumer::LockedBuffer* buffer, bool usingRGBAOverride)
291 ALOG_ASSERT(buffer != NULL, "Input buffer is NULL!!!");
293 uint32_t width = buffer->width;
294 uint8_t* jpegBuffer = buffer->data;
297 width = (buffer->width + buffer->stride * (buffer->height - 1)) * 4;
300 // First check for JPEG transport header at the end of the buffer
308 // failed to find size, default to whole buffer
338 static void Image_getLockedBufferInfo(JNIEnv* env, CpuConsumer::LockedBuffer* buffer, int idx,
341 ALOG_ASSERT(buffer != NULL, "Input buffer is NULL!!!");
346 ALOGV("%s: buffer: %p", __FUNCTION__, buffer);
354 int32_t fmt = buffer->flexFormat;
362 buffer->data :
364 buffer->dataCb :
365 buffer->dataCr;
368 dataSize = buffer->stride * (buffer->height - 1) + buffer->width;
370 dataSize = buffer->chromaStride * (buffer->height / 2 - 1) +
371 buffer->chromaStep * (buffer->width / 2 - 1) + 1;
376 cr = buffer->data + (buffer->stride * buffer->height);
379 ySize = buffer->width * (buffer->height - 1) + buffer->width;
380 cSize = buffer->width * (buffer->height / 2 - 1) + buffer->width - 1;
384 buffer->data :
393 LOG_ALWAYS_FATAL_IF(buffer->stride % 16,
394 "Stride is not 16 pixel aligned %d", buffer->stride);
396 ySize = buffer->stride * buffer->height;
397 cStride = ALIGN(buffer->stride / 2, 16);
398 cr = buffer->data + ySize;
399 cSize = cStride * buffer->height / 2;
404 buffer->data :
414 pData = buffer->data;
415 dataSize = buffer->stride * buffer->height;
422 pData = buffer->data;
423 dataSize = buffer->stride * buffer->height * bytesPerPixel;
428 ALOG_ASSERT(buffer->height == 1, "JPEG should has height value %d", buffer->height);
430 pData = buffer->data;
431 dataSize = Image_getJpegSize(buffer, usingRGBAOverride);
437 pData = buffer->data;
438 dataSize = buffer->stride * buffer->height * bytesPerPixel;
443 LOG_ALWAYS_FATAL_IF(buffer->width % 4,
444 "Width is not multiple of 4 %d", buffer->width);
445 LOG_ALWAYS_FATAL_IF(buffer->height % 2,
446 "Height is not even %d", buffer->height);
447 LOG_ALWAYS_FATAL_IF(buffer->stride < (buffer->width * 10 / 8),
449 buffer->stride, buffer->width * 10 / 8);
450 pData = buffer->data;
451 dataSize = buffer->stride * buffer->height;
458 pData = buffer->data;
459 dataSize = buffer->stride * buffer->height * bytesPerPixel;
465 pData = buffer->data;
466 dataSize = buffer->stride * buffer->height * bytesPerPixel;
472 pData = buffer->data;
473 dataSize = buffer->stride * buffer->height * bytesPerPixel;
485 static jint Image_imageGetPixelStride(JNIEnv* env, CpuConsumer::LockedBuffer* buffer, int idx,
488 ALOGV("%s: buffer
492 ALOG_ASSERT(buffer != NULL, "buffer is NULL");
494 int32_t fmt = buffer->flexFormat;
500 pixelStride = (idx == 0) ? 1 : buffer->chromaStep;
546 static jint Image_imageGetRowStride(JNIEnv* env, CpuConsumer::LockedBuffer* buffer, int idx,
549 ALOGV("%s: buffer index: %d", __FUNCTION__, idx);
553 ALOG_ASSERT(buffer != NULL, "buffer is NULL");
555 int32_t fmt = buffer->flexFormat;
561 rowStride = (idx == 0) ? buffer->stride : buffer->chromaStride;
564 rowStride = buffer->width;
567 LOG_ALWAYS_FATAL_IF(buffer->stride % 16,
568 "Stride is not 16 pixel aligned %d", buffer->stride);
569 rowStride = (idx == 0) ? buffer->stride : ALIGN(buffer->stride / 2, 16);
579 rowStride = buffer->stride;
583 LOG_ALWAYS_FATAL_IF(buffer->stride % 16,
584 "Stride is not 16 pixel aligned %d", buffer->stride);
585 rowStride = buffer->stride;
593 LOG_ALWAYS_FATAL_IF(buffer->stride % 16,
594 "Stride is not 16 pixel aligned %d", buffer->stride);
595 rowStride = buffer->stride * 2;
599 rowStride = buffer->stride * 2;
604 rowStride = buffer->stride * 4;
609 rowStride = buffer->stride * 3;
614 "unsupported buffer format");
621 static int Image_getBufferWidth(CpuConsumer::LockedBuffer* buffer) {
622 if (buffer == NULL) return -1;
624 if (!buffer->crop.isEmpty()) {
625 return buffer->crop.getWidth();
627 return buffer->width;
630 static int Image_getBufferHeight(CpuConsumer::LockedBuffer* buffer) {
631 if (buffer == NULL) return -1;
633 if (!buffer->crop.isEmpty()) {
634 return buffer->crop.getHeight();
636 return buffer->height;
721 "Failed to set CpuConsumer buffer size");
727 "Failed to set CpuConsumer buffer format");
759 CpuConsumer::LockedBuffer* buffer = Image_getLockedBuffer(env, image);
760 if (!buffer) {
764 consumer->unlockBuffer(*buffer);
766 ctx->returnLockedBuffer(buffer);
780 CpuConsumer::LockedBuffer* buffer = ctx->getLockedBuffer();
781 if (buffer == NULL) {
786 status_t res = consumer->lockNextBuffer(buffer);
788 ctx->returnLockedBuffer(buffer);
796 "Unknown error (%d) when we tried to lock buffer.",
803 if (buffer->flexFormat == HAL_PIXEL_FORMAT_YCrCb_420_SP) {
811 Point lt = buffer->crop.leftTop();
818 // Check if the producer buffer configurations match what ImageReader configured.
819 int outputWidth = Image_getBufferWidth(buffer);
820 int outputHeight = Image_getBufferHeight(buffer);
825 if ((buffer->format != HAL_PIXEL_FORMAT_BLOB) && (imgReaderFmt != HAL_PIXEL_FORMAT_BLOB) &&
827 ALOGV("%s: Producer buffer size: %dx%d, doesn't match ImageReader configured size: %dx%d",
831 int bufFmt = buffer->format;
833 bufFmt = buffer->flexFormat;
841 ALOGD("%s: Overriding buffer format YUV_420_888 to %x.", __FUNCTION__, bufFmt);
845 ALOGD("%s: Receiving JPEG in HAL_PIXEL_FORMAT_RGBA_8888 buffer.", __FUNCTION__);
847 // Return the buffer to the queue.
848 consumer->unlockBuffer(*buffer);
849 ctx->returnLockedBuffer(buffer);
852 ALOGE("Producer output buffer format: 0x%x, ImageReader configured format: 0x%x",
853 buffer->format, ctx->getBufferFormat());
855 msg.appendFormat("The producer output buffer format 0x%x doesn't "
856 "match the ImageReader's configured buffer format 0x%x.",
864 Image_setBuffer(env, image, buffer);
866 static_cast<jlong>(buffer->timestamp));
888 ALOGV("%s: buffer index: %d", __FUNCTION__, idx);
890 CpuConsumer::LockedBuffer* buffer = Image_getLockedBuffer(env, thiz);
892 ALOG_ASSERT(buffer != NULL);
893 if (buffer == NULL) {
899 rowStride = Image_imageGetRowStride(env, buffer, idx, readerFormat);
900 buffer, idx, readerFormat);
914 ALOGV("%s: buffer index: %d", __FUNCTION__, idx);
916 CpuConsumer::LockedBuffer* buffer = Image_getLockedBuffer(env, thiz);
918 if (buffer == NULL) {
924 // Create byteBuffer from native buffer
925 Image_getLockedBufferInfo(env, buffer, idx, &base, &size, readerFormat);
928 // Byte buffer have 'int capacity', so check the range
945 CpuConsumer::LockedBuffer* buffer = Image_getLockedBuffer(env, thiz);
946 return Image_getBufferWidth(buffer);
951 CpuConsumer::LockedBuffer* buffer = Image_getLockedBuffer(env, thiz);
952 return Image_getBufferHeight(buffer);