コード例 #1
0
ファイル: armArch.c プロジェクト: FreeTish/MyDemos
jstring
Java_com_github_hiteshsondhi88_libffmpeg_ArmArchHelper_cpuArchFromJNI(JNIEnv* env, jobject obj)
{
	// Maximum we need to store here is ARM v7-neon
	// Which is 11 char long, so initializing a character array of length 11
	char arch_info[13] = "";

//	logI("ANDROID_CPU_FAMILY_ARM = %d",ANDROID_CPU_FAMILY_ARM);
//	logI("ANDROID_CPU_ARM_FEATURE_ARMv7 = %d",ANDROID_CPU_ARM_FEATURE_ARMv7);
//	logI("ANDROID_CPU_ARM_FEATURE_NEON = %d",ANDROID_CPU_ARM_FEATURE_NEON);
//	logI("android_getCpuFamily = %d",android_getCpuFamily());
//	logI("android_getCpuFeatures = %" PRIu64 "",android_getCpuFeatures());


	int cpu = android_getCpuFamily();
	// checking if CPU is of ARM family or not
	if (cpu == ANDROID_CPU_FAMILY_ARM) {
		strcpy(arch_info, "ARM");
	} else if (cpu == ANDROID_CPU_FAMILY_ARM64) {
		strcpy(arch_info, "ARM_64");
	}
	// checking if CPU is ARM v7 or not
	uint64_t cpuFeatures = android_getCpuFeatures();
	if ((cpuFeatures & ANDROID_CPU_ARM_FEATURE_ARMv7) != 0) {
		strcat(arch_info, " v7");

		// checking if CPU is ARM v7 Neon
		if((cpuFeatures & ANDROID_CPU_ARM_FEATURE_NEON) != 0) {
			strcat(arch_info, "-neon");
		}
	}
	return (*env)->NewStringUTF(env, arch_info);
}
コード例 #2
0
ファイル: rfx_neon.c プロジェクト: pafcioooo/openulteo
int isNeonSupported()
{
#if defined(ANDROID)
    if (android_getCpuFamily() != ANDROID_CPU_FAMILY_ARM)
    {
        DEBUG_RFX("NEON optimization disabled - No ARM CPU found");
        return 0;
    }

    uint64_t features = android_getCpuFeatures();
    if ((features & ANDROID_CPU_ARM_FEATURE_ARMv7))
    {
        if (features & ANDROID_CPU_ARM_FEATURE_NEON)
        {
            DEBUG_RFX("NEON optimization enabled!");
            return 1;
        }
        DEBUG_RFX("NEON optimization disabled - CPU not NEON capable");
    }
    else
        DEBUG_RFX("NEON optimization disabled - No ARMv7 CPU found");

    return 0;
#else
    return 1;
#endif
}
コード例 #3
0
JNIEXPORT jboolean JNICALL Java_org_linphone_mediastream_Version_nativeHasNeon(JNIEnv *env, jclass c) {
	if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0)
	{
		return 1;
	}
	return 0;
}
コード例 #4
0
EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle,
        void *Context, void (*DebugCallback)(void *, int, const char *))
{
    ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath)	dlsym(CoreLibHandle, "ConfigGetSharedDataFilepath");
	CoreVideo_GL_SwapBuffers 	= (ptr_VidExt_GL_SwapBuffers) 		dlsym(CoreLibHandle, "VidExt_GL_SwapBuffers");
	CoreVideo_SetVideoMode 		= (ptr_VidExt_SetVideoMode)			dlsym(CoreLibHandle, "VidExt_SetVideoMode");
	CoreVideo_Quit 				= (ptr_VidExt_Quit)					dlsym(CoreLibHandle, "VidExt_Quit");
	CoreVideo_Init 				= (ptr_VidExt_Init)					dlsym(CoreLibHandle, "VidExt_Init");

#ifdef __NEON_OPT
    if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
            (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0)
    {
        MathInitNeon();
        gSPInitNeon();
    }
#endif
    ticksInitialize();

    //int max_frames = Android_JNI_GetMaxFrameSkip();
	//int max_frames = 1;
// TODO: get rid of this, it should be handled through the config file:
  //  if( Android_JNI_GetAutoFrameSkip() )
    //    frameSkipper.setSkips( FrameSkipper::AUTO, max_frames );
   // else
        //frameSkipper.setSkips( FrameSkipper::MANUAL, max_frames );
//
    return M64ERR_SUCCESS;
}
コード例 #5
0
 AnrdoidNeonChecker()
 {
     if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0)
         _isNeonEnabled = true;
     else
         _isNeonEnabled = false;
 }
コード例 #6
0
jboolean jni_nativetester_is_neon(JNIEnv *env, jobject thiz) {
#ifdef FEATURE_NEON
	uint64_t features;
	if (android_getCpuFamily() != ANDROID_CPU_FAMILY_ARM) {
		LOGI(5, "Not an ARM CPU\n");
		return JNI_FALSE;
	}

	features = android_getCpuFeatures();

	if ((features & ANDROID_CPU_ARM_FEATURE_ARMv7) == 0) {
		LOGI(5, "Not an ARMv7 CPU\n");
		return JNI_FALSE;
	}

	if ((features & ANDROID_CPU_ARM_FEATURE_NEON) == 0) {
		LOGI(5, "CPU doesn't support NEON\n");
		return JNI_FALSE;
	}

	return JNI_TRUE;
#else
	return JNI_FALSE;
#endif
}
コード例 #7
0
ファイル: benchscaw.cpp プロジェクト: kripton/benchscaw
 jstring
 Java_ws_websca_benchscaw_MainActivity_stringFromJNI( JNIEnv* env,
         jobject thiz )
 {
     AndroidCpuFamily acf = android_getCpuFamily();
     switch(android_getCpuFamily()) {
     case ANDROID_CPU_FAMILY_ARM:
         return env->NewStringUTF("ANDROID_CPU_FAMILY_ARM");
         break;
     case ANDROID_CPU_FAMILY_X86:
         return env->NewStringUTF("ANDROID_CPU_FAMILY_X86");
         break;
     case ANDROID_CPU_FAMILY_MIPS:
         return env->NewStringUTF("ANDROID_CPU_FAMILY_MIPS");
         break;
     }
     return env->NewStringUTF("UNKNOWN");
 }
コード例 #8
0
JNIEXPORT jint JNICALL Java_com_vipercn_viper4android_1v2_activity_V4AJniInterface_CheckCPUHasNEON
(
	JNIEnv *env, jclass cls
)
{
	if (android_getCpuFamily() != ANDROID_CPU_FAMILY_ARM) return (jint)0;
	uint64_t uiCPUFeatures = android_getCpuFeatures();
	if ((uiCPUFeatures & ANDROID_CPU_ARM_FEATURE_NEON) == 0) return (jint)0;
	return (jint)1;
}
コード例 #9
0
ファイル: benchscaw.cpp プロジェクト: kripton/benchscaw
 jboolean Java_ws_websca_benchscaw_MainActivity_getCpuX86MOVBE( JNIEnv* env,
         jobject thiz )
 {
     if(android_getCpuFamily()!=ANDROID_CPU_FAMILY_X86)
         return JNI_FALSE;
     if ((android_getCpuFeatures() & ANDROID_CPU_X86_FEATURE_MOVBE) != 0)
         return JNI_TRUE;
     else
         return JNI_FALSE;
 }
コード例 #10
0
ファイル: benchscaw.cpp プロジェクト: kripton/benchscaw
 jboolean Java_ws_websca_benchscaw_MainActivity_getCpuArmVFPv3( JNIEnv* env,
         jobject thiz )
 {
     if(android_getCpuFamily()!=ANDROID_CPU_FAMILY_ARM)
         return JNI_FALSE;
     if ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_VFPv3) != 0)
         return JNI_TRUE;
     else
         return JNI_FALSE;
 }
コード例 #11
0
/*
 * Function: cpuHasNeon
 * Purpose: Check if we have an ARM CPU with NEON instructions
 * Parameters: none
 * Returns: boolean: (true) if NEON is available, (false) otherwise
 * Exceptions: none
 */
static jboolean android_security_cts_EncryptionTest_cpuHasNeon(JNIEnv *, jobject)
{
    jboolean rc = false;
    AndroidCpuFamily family = android_getCpuFamily();

    if (family == ANDROID_CPU_FAMILY_ARM) {
        rc = (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
    } else {
        rc = (family == ANDROID_CPU_FAMILY_ARM64);
    }

    ALOGE("EncryptionTest::cpuHasNeon: %d", rc);
    return rc;
}
コード例 #12
0
/*
 * Function: cpuHasAes
 * Purpose: Check if we have an ARM CPU with AES instruction
 * Parameters: none
 * Returns: boolean: (true) if AES is available, (false) otherwise
 * Exceptions: none
 */
static jboolean android_security_cts_EncryptionTest_cpuHasAes(JNIEnv *, jobject)
{
    jboolean rc = false;
    AndroidCpuFamily family = android_getCpuFamily();
    uint64_t features = android_getCpuFeatures();

    if (family == ANDROID_CPU_FAMILY_ARM) {
        rc = (features & ANDROID_CPU_ARM_FEATURE_AES) != 0;
    } else if (family == ANDROID_CPU_FAMILY_ARM64) {
        rc = (features & ANDROID_CPU_ARM64_FEATURE_AES) != 0;
    }

    ALOGE("EncryptionTest::cpuHasAes: %d", rc);
    return rc;
}
コード例 #13
0
EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle,
        void *Context, void (*DebugCallback)(void *, int, const char *))
{
    ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath)
            dlsym(CoreLibHandle, "ConfigGetSharedDataFilepath");

#ifdef __NEON_OPT
    if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
            (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0)
    {
        MathInitNeon();
        gSPInitNeon();
    }
#endif
    return M64ERR_SUCCESS;
}
コード例 #14
0
jstring Java_com_github_shadowsocks_system_getabi(JNIEnv *env, jobject thiz) {
  AndroidCpuFamily family = android_getCpuFamily();
  uint64_t features = android_getCpuFeatures();
  const char *abi;

  if (family == ANDROID_CPU_FAMILY_X86) {
    abi = "x86";
  } else if (family == ANDROID_CPU_FAMILY_MIPS) {
    abi = "mips";
  } else if (family == ANDROID_CPU_FAMILY_ARM) {
    if (features & ANDROID_CPU_ARM_FEATURE_ARMv7) {
      abi = "armeabi-v7a";
    } else {
      abi = "armeabi";
    }
  }
  return env->NewStringUTF(abi);
}
コード例 #15
0
ファイル: cpu.cpp プロジェクト: emmasteimann/nds4droid
jint JNI_NOARGS(getCPUType)
{
	AndroidCpuFamily cpuFamily = android_getCpuFamily();
	uint64_t cpuFeatures = android_getCpuFeatures();
	if (cpuFamily == ANDROID_CPU_FAMILY_ARM &&
        (cpuFeatures & ANDROID_CPU_ARM_FEATURE_NEON) != 0)
    {
		return CPUTYPE_NEON;
    }
	else if (cpuFamily == ANDROID_CPU_FAMILY_ARM &&
        (cpuFeatures & ANDROID_CPU_ARM_FEATURE_ARMv7) != 0)
	{
		return CPUTYPE_V7;
	}
    else
    {
        return CPUTYPE_COMPAT;
    }
}
コード例 #16
0
ファイル: Jni.cpp プロジェクト: fifanav/ShadowsocksRDroid
jstring Java_com_proxy_shadowsocksr_Jni_getABI
        (JNIEnv *env, jobject thiz) {
    AndroidCpuFamily family = android_getCpuFamily();
    uint64_t features = android_getCpuFeatures();
    const char *abi;

    if (family == ANDROID_CPU_FAMILY_X86) {
        abi = "x86";
    } else if (family == ANDROID_CPU_FAMILY_MIPS) {
        abi = "mips";
    } else if (family == ANDROID_CPU_FAMILY_ARM) {
        abi = "armeabi-v7a";
    } else if (family == ANDROID_CPU_FAMILY_ARM64) {
        abi = "arm64-v8a";
    } else if (family == ANDROID_CPU_FAMILY_X86_64) {
        abi = "x86_64";
    }
    return env->NewStringUTF(abi);
}
コード例 #17
0
ファイル: msresample.c プロジェクト: clzhan/conference
static void resample_init(MSFilter *obj){
#ifdef SPEEX_LIB_SET_CPU_FEATURES
	int cpuFeatures = 0;
#ifdef __arm__
	#ifdef ANDROID
	if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM 
		&& (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0) {
		cpuFeatures = SPEEX_LIB_CPU_FEATURE_NEON;
	}
	#elif defined(__ARM_NEON__)
	cpuFeatures = SPEEX_LIB_CPU_FEATURE_NEON;
	#endif
	ms_message("speex_lib_ctl init with neon ? %d", (cpuFeatures == SPEEX_LIB_CPU_FEATURE_NEON));
#endif
	speex_lib_ctl(SPEEX_LIB_SET_CPU_FEATURES, &cpuFeatures);
#else
	ms_message("speex_lib_ctl does not support SPEEX_LIB_CPU_FEATURE_NEON");
#endif
	obj->data=resample_data_new();
}
コード例 #18
0
ファイル: jnihooks.c プロジェクト: jvernet/apple2
static void discover_cpu_family(void) {
    LOG("Discovering CPU family...");

    AndroidCpuFamily family = android_getCpuFamily();
    uint64_t features = android_getCpuFeatures();
    if (family == ANDROID_CPU_FAMILY_X86) {
        if (features & ANDROID_CPU_X86_FEATURE_SSSE3) {
            LOG("nANDROID_CPU_X86_FEATURE_SSSE3");
            android_x86SSSE3Enabled = true;
        }
        if (features & ANDROID_CPU_X86_FEATURE_MOVBE) {
            LOG("ANDROID_CPU_X86_FEATURE_MOVBE");
        }
        if (features & ANDROID_CPU_X86_FEATURE_POPCNT) {
            LOG("ANDROID_CPU_X86_FEATURE_POPCNT");
        }
    } else if (family == ANDROID_CPU_FAMILY_ARM) {
        if (features & ANDROID_CPU_ARM_FEATURE_ARMv7) {
            LOG("ANDROID_CPU_ARM_FEATURE_ARMv7");
            android_armArchV7A = true;
        } else {
            LOG("!!! NOT ANDROID_CPU_ARM_FEATURE_ARMv7");
            android_armArch = true;
        }

        if (features & ANDROID_CPU_ARM_FEATURE_VFPv3) {
            LOG("ANDROID_CPU_ARM_FEATURE_VFPv3");
        }
        if (features & ANDROID_CPU_ARM_FEATURE_NEON) {
            LOG("ANDROID_CPU_ARM_FEATURE_NEON");
            android_armNeonEnabled = true;
        }
        if (features & ANDROID_CPU_ARM_FEATURE_LDREX_STREX) {
            LOG("ANDROID_CPU_ARM_FEATURE_LDREX_STREX");
        }
    } else if (family == ANDROID_CPU_FAMILY_ARM64) {
#warning FIXME TODO ...
        //android_arm64Arch = true;
        android_armArchV7A = true;
    }
}
JNIEXPORT jboolean JNICALL
Java_com_h6ah4i_android_media_opensl_OpenSLMediaPlayerNativeLibraryLoader_checkIsNeonDisabledLibRequired(
    JNIEnv *env, jclass clazz) noexcept
{
    const AndroidCpuFamily cpu_family = android_getCpuFamily();
    const uint64_t cpu_features = android_getCpuFeatures();

    const bool is_arm_v7a =
        (cpu_family == ANDROID_CPU_FAMILY_ARM) &&
        ((cpu_features & ANDROID_CPU_ARM_FEATURE_ARMv7) != 0);

    if (!is_arm_v7a) {
        return false;
    }

    const bool support_neon = ((cpu_features & ANDROID_CPU_ARM_FEATURE_NEON) != 0);

    if (support_neon) {
        return false;
    }

    return true;
}
コード例 #20
0
ファイル: pixman-arm.c プロジェクト: CODECOMMUNITY/pixman
static arm_cpu_features_t
detect_cpu_features (void)
{
    arm_cpu_features_t features = 0;
    AndroidCpuFamily cpu_family;
    uint64_t cpu_features;

    cpu_family = android_getCpuFamily();
    cpu_features = android_getCpuFeatures();

    if (cpu_family == ANDROID_CPU_FAMILY_ARM)
    {
        if (cpu_features & ANDROID_CPU_ARM_FEATURE_ARMv7)
            features |= ARM_V7;

        if (cpu_features & ANDROID_CPU_ARM_FEATURE_VFPv3)
            features |= ARM_VFP;

        if (cpu_features & ANDROID_CPU_ARM_FEATURE_NEON)
            features |= ARM_NEON;
    }

    return features;
}
コード例 #21
0
static void enc_init(MSFilter *f){
	SpeexEncState *s=ms_new0(SpeexEncState,1);
#ifdef SPEEX_LIB_SET_CPU_FEATURES
	int cpuFeatures = 0;
#endif
	s->rate=8000;
	s->bitrate=-1;
	s->maxbitrate=-1;
	s->ip_bitrate=-1;
	s->ptime=20;
	s->mode=-1;
	s->vbr=0;
	s->cng=0;
	s->frame_size=0;
	s->state=0;
	s->ts=0;
	s->bufferizer=ms_bufferizer_new();
	f->data=s;

#ifdef SPEEX_LIB_SET_CPU_FEATURES
#ifdef __ARM_NEON__
	#ifdef ANDROID
	if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM
		&& (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0) {
		cpuFeatures = SPEEX_LIB_CPU_FEATURE_NEON;
	}
	#else
	cpuFeatures = SPEEX_LIB_CPU_FEATURE_NEON;
	#endif
#endif
	ms_message("speex_lib_ctl init %s neon", (cpuFeatures == SPEEX_LIB_CPU_FEATURE_NEON)?"with":"without");
	speex_lib_ctl(SPEEX_LIB_SET_CPU_FEATURES, &cpuFeatures);
#else
	ms_message("speex_lib_ctl does not support SPEEX_LIB_CPU_FEATURE_NEON");
#endif
}
コード例 #22
0
bool hasNeon()
{
    AndroidCpuFamily family = android_getCpuFamily();
    switch (family) {
       case ANDROID_CPU_FAMILY_ARM:
    	   DP("CPU family is ARM\n");
           break;
       case ANDROID_CPU_FAMILY_X86:
    	   DP("CPU family is x86\n");
           break;
       case ANDROID_CPU_FAMILY_MIPS:
    	   DP("CPU family is MIPS\n");
           break;
       default:
    	   DP("Unsupported CPU family: %d\n", family);
           return 0;
       }
    	if (family == ANDROID_CPU_FAMILY_ARM) {
           uint64_t features = android_getCpuFeatures();
           DP( "Supported ARM features:\n");
           if ((features & ANDROID_CPU_ARM_FEATURE_ARMv7) != 0) {
               DP( "  ARMv7\n" );
           }
           if ((features & ANDROID_CPU_ARM_FEATURE_VFPv3) != 0) {
        	   DP( "  VFPv3\n" );
           }
           if ((features & ANDROID_CPU_ARM_FEATURE_NEON) != 0) {
        	   DP( "  NEON\n" );
               return 1;
           }
           if ((features & ANDROID_CPU_ARM_FEATURE_LDREX_STREX) != 0) {
        	   DP( "  ldrex/strex\n" );
           }
       }
    	return 0;
}
コード例 #23
0
ファイル: hw.c プロジェクト: yoanlcq/FATE
    static void static_arm_features_fill(void) {
        #ifdef FE_HW_TARGET_ARM32
            fe_hw_arm32_features_struct *arm32 = (void*)&fe_hw_arm32_cpu_info;
        #else
            fe_hw_arm64_features_struct *arm64 = (void*)&fe_hw_arm64_cpu_info;
        #endif
        #ifdef FE_TARGET_ANDROID
            AndroidCpuFamily family = android_getCpuFamily();
            uint64_t feats          = android_getCpuFeatures();

            #ifdef FE_HW_TARGET_ARM32

                fe_dbg_assert(family == ANDROID_CPU_FAMILY_ARM);
                arm32->cpuid = android_getCpuIdArm();
                #define HELPER(CST,cst) \
    if(feats & ANDROID_CPU_ARM_FEATURE_##CST) arm32->has_##cst = true
                HELPER(ARMv7      , armv7      ); 
                HELPER(VFPv3      , vfpv3      ); 
                HELPER(NEON       , neon       ); 
                HELPER(LDREX_STREX, ldrex_strex); 
                HELPER(VFPv2      , vfpv2      ); 
                HELPER(VFP_D32    , vfp_d32    ); 
                HELPER(VFP_FP16   , vfp_fp16   ); 
                HELPER(VFP_FMA    , vfp_fma    ); 
                HELPER(NEON_FMA   , neon_fma   ); 
                HELPER(IDIV_ARM   , idiv_arm   ); 
                HELPER(IDIV_THUMB2, idiv_thumb2); 
                HELPER(iWMMXt     , iwmmxt     ); 
                HELPER(AES        , aes        ); 
                HELPER(PMULL      , pmull      ); 
                HELPER(SHA1       , sha1       ); 
                HELPER(SHA2       , sha2       ); 
                HELPER(CRC32      , crc32      );
                #undef HELPER

            #elif defined(FE_HW_TARGET_ARM64)

                fe_dbg_assert(family == ANDROID_CPU_FAMILY_ARM64);
                arm64->cpuid = android_getCpuIdArm();
                #define HELPER(CST,cst) \
    if(feats & ANDROID_CPU_ARM64_FEATURE_##CST) arm64->has_##cst = true
                HELPER(FP   , fp   );
                HELPER(ASIMD, asimd);
                HELPER(AES  , aes  );
                HELPER(PMULL, pmull);
                HELPER(SHA1 , sha1 );
                HELPER(SHA2 , sha2 );
                HELPER(CRC32, crc32);
                #undef HELPER

            #endif /* FE_HW_TARGET_ARM32 */

        #elif defined(FE_TARGET_IOS)

            /* On iOS, we don't have to check for cpu features support because
             * our app gets compiled twice into a fat binary - one part with
             * NEON support and the other part without.
             * The OS decides which part to use at lauch-time. 
             * See http://wanderingcoder.net/2010/07/19/ought-arm/
             */
            #ifdef FE_HW_TARGET_ARM_IWMMXT
                arm32->has_wmmx = true;
            #endif
            #ifdef FE_HW_TARGET_ARM_NEON
                arm32->has_neon = true;
            #endif

        #endif /* FE_TARGET_ANDROID */

    }
コード例 #24
0
ファイル: AndroidFeatures.cpp プロジェクト: MrMC/mrmc
bool CAndroidFeatures::HasNeon()
{
  if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM) 
    return ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
  return false;
}
コード例 #25
0
ファイル: msvideo.c プロジェクト: korobool/linphonecdbus
/* Destination and source images may have their dimensions inverted.*/
mblk_t *copy_ycbcrbiplanar_to_true_yuv_with_rotation_and_down_scale_by_2(uint8_t* y, uint8_t * cbcr, int rotation, int w, int h, int y_byte_per_row,int cbcr_byte_per_row, bool_t uFirstvSecond, bool_t down_scale) {
	MSPicture pict;
	int uv_w;
	int uv_h;
	uint8_t* ysrc;
	uint8_t* ydst;
	uint8_t* uvsrc;
	uint8_t* srcu;
	uint8_t* dstu;
	uint8_t* srcv;
	uint8_t* dstv;

	mblk_t *yuv_block = ms_yuv_buf_alloc(&pict, w, h);
#ifdef ANDROID
	if (hasNeon == -1) {
		hasNeon = (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
	}
#endif
#ifdef __arm__
	if (down_scale && !hasNeon) {
		ms_error("down scaling by two requires NEON, returning empty block");
		return yuv_block;
	}
#endif

	if (!uFirstvSecond) {
		unsigned char* tmp = pict.planes[1];
		pict.planes[1] = pict.planes[2];
		pict.planes[2] = tmp;
	}

	uv_w = w/2;
	uv_h = h/2;

	if (rotation % 180 == 0) {
		int i,j;
		uint8_t* u_dest=pict.planes[1], *v_dest=pict.planes[2];

		if (rotation == 0) {
#ifdef __arm__
			if (hasNeon) {
				deinterlace_down_scale_neon(y, cbcr, pict.planes[0], u_dest, v_dest, w, h, y_byte_per_row, cbcr_byte_per_row,down_scale);
			} else 
#endif
			{	
				// plain copy
				for(i=0; i<h; i++) {
					memcpy(&pict.planes[0][i*w], &y[i*y_byte_per_row], w);
				}
				// de-interlace u/v
				for (i=0; i<uv_h; i++) {
					for(j=0; j<uv_w; j++) {
						*u_dest++ = cbcr[cbcr_byte_per_row*i + 2*j];
						*v_dest++ = cbcr[cbcr_byte_per_row*i + 2*j + 1];
					}
				}
			}
		} else {
#ifdef __arm__
			if (hasNeon) {
				deinterlace_down_scale_and_rotate_180_neon(y, cbcr, pict.planes[0], u_dest, v_dest, w, h, y_byte_per_row, cbcr_byte_per_row,down_scale);
			} else 
#endif
{
				// 180° y rotation
				ysrc=y;
				ydst=&pict.planes[0][h*w-1];
				for(i=0; i<h*w; i++) {
					*ydst-- = *ysrc++;
				}
				// 180° rotation + de-interlace u/v
				uvsrc=&cbcr[uv_h*uv_w*2-2];
				for (i=0; i<uv_h*uv_w*2; i++) {
					*u_dest++ = *uvsrc--;
					*v_dest++ = *uvsrc--;
				}
			}
		}
	} else {
		bool_t clockwise = rotation == 90 ? TRUE : FALSE;
		// Rotate Y
#ifdef __arm__
		if (hasNeon) {
			if (clockwise) {
				rotate_down_scale_plane_neon_clockwise(w,h,y_byte_per_row,(uint8_t*)y,pict.planes[0],down_scale);
			} else {
				rotate_down_scale_plane_neon_anticlockwise(w,h,y_byte_per_row,(uint8_t*)y,pict.planes[0], down_scale);
			}
		} else 
#endif
{
			uint8_t* dsty = pict.planes[0];
			uint8_t* srcy = (uint8_t*) y;
			rotate_plane(w,h,y_byte_per_row,srcy,dsty,1, clockwise);
		}

#ifdef __arm__
		if (hasNeon) {
			rotate_down_scale_cbcr_to_cr_cb(uv_w,uv_h, cbcr_byte_per_row/2, (uint8_t*)cbcr, pict.planes[2], pict.planes[1],clockwise,down_scale);
		} else 
#endif
{
			// Copying U
			srcu = cbcr;
			dstu = pict.planes[1];
			rotate_plane(uv_w,uv_h,cbcr_byte_per_row/2,srcu,dstu, 2, clockwise);
			// Copying V
			srcv = srcu + 1;
			dstv = pict.planes[2];
			rotate_plane(uv_w,uv_h,cbcr_byte_per_row/2,srcv,dstv, 2, clockwise);
		}
	}

	return yuv_block;
}