int main(void) { unsigned char state = 0x01; //Set initial state to 1 int input; DDRB = 0xff; //Set PORTB as output DDRD = 0x00; //Set PORTD as input PORTD = 0xff; PORTB = state; //Set LEDs to initial state for(;;) { while ((input = input_check()) == 0){} //Wait for button press if (input == 5) { //According to the input state = SW5(state); //do the corresponding job PORTB = state; } else if (input == 4) { state = SW4(state); PORTB = state; } else if (input == 3) { state = SW3(state); PORTB = state; } else if (input == 2) { state = SW2(state); PORTB = state; } else { state = SW1(state); PORTB = state; } } return -1; }
static void intra_predict_vert_4x4_msa(const uint8_t *src, uint8_t *dst, int32_t dst_stride) { uint32_t src_data; src_data = LW(src); SW4(src_data, src_data, src_data, src_data, dst, dst_stride); }
static void intra_predict_128dc_4x4_msa(uint8_t *dst, int32_t dst_stride) { uint32_t out; const v16i8 store = __msa_ldi_b(128); out = __msa_copy_u_w((v4i32)store, 0); SW4(out, out, out, out, dst, dst_stride); }
static WEBP_INLINE void DC4(uint8_t* dst, const uint8_t* top) { uint32_t dc = 4; int i; for (i = 0; i < 4; ++i) dc += top[i] + top[-5 + i]; dc >>= 3; dc = dc | (dc << 8) | (dc << 16) | (dc << 24); SW4(dc, dc, dc, dc, dst, BPS); }
static void intra_predict_horiz_4x4_msa(const uint8_t *src, uint8_t *dst, int32_t dst_stride) { uint32_t out0, out1, out2, out3; out0 = src[0] * 0x01010101; out1 = src[1] * 0x01010101; out2 = src[2] * 0x01010101; out3 = src[3] * 0x01010101; SW4(out0, out1, out2, out3, dst, dst_stride); }
static WEBP_INLINE void VE4(uint8_t* dst, const uint8_t* top) { // vertical const uint64_t val_m = LD(top - 1); const v16u8 A = (v16u8)__msa_insert_d((v2i64)A, 0, val_m); const v16u8 B = SLDI_UB(A, A, 1); const v16u8 C = SLDI_UB(A, A, 2); const v16u8 AC = __msa_ave_u_b(A, C); const v16u8 B2 = __msa_ave_u_b(B, B); const v16u8 R = __msa_aver_u_b(AC, B2); const uint32_t out = __msa_copy_s_w((v4i32)R, 0); SW4(out, out, out, out, dst, BPS); }
static void intra_predict_dc_tl_4x4_msa(const uint8_t *src, uint8_t *dst, int32_t dst_stride) { uint32_t val0; v16i8 store, data = { 0 }; v8u16 sum_h; v4u32 sum_w; val0 = LW(src); data = (v16i8)__msa_insert_w((v4i32)data, 0, val0); sum_h = __msa_hadd_u_h((v16u8)data, (v16u8)data); sum_w = __msa_hadd_u_w(sum_h, sum_h); sum_w = (v4u32)__msa_srari_w((v4i32)sum_w, 2); store = __msa_splati_b((v16i8)sum_w, 0); val0 = __msa_copy_u_w((v4i32)store, 0); SW4(val0, val0, val0, val0, dst, dst_stride); }
static WEBP_INLINE void LD4(uint8_t* dst, const uint8_t* top) { const uint64_t val_m = LD(top); const v16u8 A = (v16u8)__msa_insert_d((v2i64)A, 0, val_m); const v16u8 B = SLDI_UB(A, A, 1); const v16u8 C1 = SLDI_UB(A, A, 2); const v16u8 C = (v16u8)__msa_insert_b((v16i8)C1, 6, top[7]); const v16u8 AC = __msa_ave_u_b(A, C); const v16u8 B2 = __msa_ave_u_b(B, B); const v16u8 R0 = __msa_aver_u_b(AC, B2); const v16u8 R1 = SLDI_UB(R0, R0, 1); const v16u8 R2 = SLDI_UB(R1, R1, 1); const v16u8 R3 = SLDI_UB(R2, R2, 1); const uint32_t val0 = __msa_copy_s_w((v4i32)R0, 0); const uint32_t val1 = __msa_copy_s_w((v4i32)R1, 0); const uint32_t val2 = __msa_copy_s_w((v4i32)R2, 0); const uint32_t val3 = __msa_copy_s_w((v4i32)R3, 0); SW4(val0, val1, val2, val3, dst, BPS); }
static void intra_predict_dc_4x4_msa(const uint8_t *src_top, const uint8_t *src_left, uint8_t *dst, int32_t dst_stride) { uint32_t val0, val1; v16i8 store, src = { 0 }; v8u16 sum_h; v4u32 sum_w; v2u64 sum_d; val0 = LW(src_top); val1 = LW(src_left); INSERT_W2_SB(val0, val1, src); sum_h = __msa_hadd_u_h((v16u8)src, (v16u8)src); sum_w = __msa_hadd_u_w(sum_h, sum_h); sum_d = __msa_hadd_u_d(sum_w, sum_w); sum_w = (v4u32)__msa_srari_w((v4i32)sum_d, 3); store = __msa_splati_b((v16i8)sum_w, 0); val0 = __msa_copy_u_w((v4i32)store, 0); SW4(val0, val0, val0, val0, dst, dst_stride); }