Exemple #1
0
JNIEXPORT jint Java_ryulib_VideoZip_VPX_DecodeBitmap(JNIEnv* env,
		jclass clazz, jint handle, jobject bitmap, jbyteArray buffer, jint bufferSize)
{
	int result = 0;

	RyuVPX *pHandle = (RyuVPX *) handle;

	jbyte *pByteBuffer = (*env)->GetByteArrayElements(env, buffer, 0);

	unsigned char *pFrame = (unsigned char *) pByteBuffer;
	int *pFrameSize;
	int frameSize = 0;
	int count = 0;
	vpx_image_t *img;
	vpx_codec_iter_t iter;

	while (count < bufferSize) {
		pFrameSize = (int *) pFrame;
		frameSize = *pFrameSize;
		pFrame = pFrame + sizeof(int);

		if (vpx_codec_decode(&pHandle->codec, (unsigned char*) pFrame, frameSize, NULL, 0)) {
		goto EXIT;
		}
		pFrame = pFrame + frameSize;

		count = count + sizeof(int) + frameSize;

		iter = NULL;
		while((img = vpx_codec_get_frame(&pHandle->codec, &iter))) {
			void *pixelBitmap;
			if (AndroidBitmap_lockPixels(env, bitmap, &pixelBitmap) >= 0) {
				I420ToARGB(
					(unsigned char *) img->planes[0], img->stride[0],
					(unsigned char *) img->planes[1], img->stride[1],
					(unsigned char *) img->planes[2], img->stride[2],
					(unsigned char *) pixelBitmap,
					img->d_w * _PixelSize,
					img->d_w, img->d_h
				);

				AndroidBitmap_unlockPixels(env, bitmap);
			}

			result = 1;
		}
	}

EXIT:
	(*env)->ReleaseByteArrayElements(env, buffer, pByteBuffer, 0);

	return result;
}
Exemple #2
0
void decodeBGRX(struct Theoraplayer_PixelTransform* t)
{
	I420ToARGB(t->y, t->yStride, t->u, t->uStride, t->v, t->vStride, t->out, t->w * 4, t->w, t->h);
}
Exemple #3
0
void decodeBGRA(struct Theoraplayer_PixelTransform* t)
{
	I420ToARGB(t->y, t->yStride, t->u, t->uStride, t->v, t->vStride, t->out, t->w * 4, t->w, t->h);
	_decodeAlpha(incOut(t, 3), t->w * 4);
}