/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
#include "net_sourceforge_dvb_projectx_video_IDCTRefNative.h"
#include <stdio.h>
/* Header for class net_sourceforge_dvb_projectx_video_IDCTRefNative */

/*
 * Class:     net_sourceforge_dvb_projectx_video_IDCTRefNative
 * Method:    init
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_net_sourceforge_dvb_projectx_video_IDCTRefNative_init
  (JNIEnv *env, jobject obj)
  {
	  Initialize_REF_IDCT();
  }


/*
 * Class:     net_sourceforge_dvb_projectx_video_IDCTRefNative
 * Method:    referenceIDCT
 * Signature: ([S)[S
 */
JNIEXPORT jobjectArray JNICALL Java_net_sourceforge_dvb_projectx_video_IDCTRefNative_referenceIDCT___3_3S
  (JNIEnv *env, jobject obj, jobjectArray arr)
  {
	jobjectArray ret;
	jshortArray row;
	int i,j;  
	short localArrayCopy[8][8];
	
	for(i=0; i<8; i++) 
	{
	     jshortArray oneDim= 
		(jshortArray)(*env)->GetObjectArrayElement(env, arr, i);
	     jshort *element=(*env)->GetShortArrayElements(env, oneDim, 0);
	     for(j=0; j<8; j++) 
	     {
		localArrayCopy[i][j]= element[j];
	     }
	  }

	REF_IDCT(localArrayCopy);

	// Create array to send back
	  row = (jshortArray)(*env)->NewShortArray(env, 8);
	  ret=(jobjectArray)(*env)->NewObjectArray(env, 8, (*env)->GetObjectClass(env, row), 0);

	  for(i=0;i<8;i++) 
	  {
	    row= (jshortArray)(*env)->NewShortArray(env, 8);
	    (*env)->SetShortArrayRegion(env, (jshortArray)row,(jsize)0,8,(jshort *)localArrayCopy[i]);
	    (*env)->SetObjectArrayElement(env, ret,i,row);
	  }

  	return ret;
  }

/*
 * Class:     net_sourceforge_dvb_projectx_video_IDCTRefNative
 * Method:    referenceIDCT
 * Signature: ([S)[[S
 */
JNIEXPORT void JNICALL Java_net_sourceforge_dvb_projectx_video_IDCTRefNative_referenceIDCT___3S
  (JNIEnv *env, jobject obj, jshortArray arr)
{
	jshortArray ret;
	short *localArrayCopy;
	
	localArrayCopy =(short *)(*env)->GetShortArrayElements(env, arr, JNI_FALSE);

	REF_IDCT(localArrayCopy);

	(*env)->ReleaseShortArrayElements(env, arr, localArrayCopy, 0);
}
