diff --git a/prodScreen_tests.c b/prodScreen_tests.c index a84a889..382dfbc 100644 --- a/prodScreen_tests.c +++ b/prodScreen_tests.c @@ -172,6 +172,93 @@ void fbtft_transpose_neon(uint16_t* src, uint16_t* dst, int w, int h){ } } } + +/* + NEON optimized matrix transpose inverse + (dimensions multiple of 4, 16bits pixels) +*/ +void fbtft_transpose_inv_neon(uint16_t* src, uint16_t* dst, int w, int h){ + + /* Vars */ + uint16x4x4_t v_tmp; + int y, x; + + /* Main loop */ + for (y=0; yh, w = image_rgb_16b->w; + uint16_t * p = (uint16_t *)image_rgb_16b->pixels; + int y, x; + + /* Rotate 90 CW */ + SDL_Surface *image_rgb_16b_rotated_90_neon = SDL_CreateRGBSurface(SDL_SWSURFACE, h, w, 16, 0,0,0,0); + uint16_t * p2 = (uint16_t *)image_rgb_16b_rotated_90_neon->pixels; + fbtft_rotate_90cw_neon(p, p2, w, h); + + /* Transpose inv */ + SDL_Surface *image_rgb_16b_transp_inv_neon = SDL_CreateRGBSurface(SDL_SWSURFACE, h, w, 16, 0,0,0,0); + uint16_t * p3 = (uint16_t *)image_rgb_16b_transp_inv_neon->pixels; + fbtft_transpose_inv_neon(p, p3, w, h); + + /* Rotate 270 CW */ + SDL_Surface *image_rgb_16b_rotated_270_neon = SDL_CreateRGBSurface(SDL_SWSURFACE, h, w, 16, 0,0,0,0); + uint16_t * p4 = (uint16_t *)image_rgb_16b_rotated_270_neon->pixels; + fbtft_rotate_270cw_neon(p, p4, w, h); + + /* Blit image */ + SDL_Surface * imgs_to_blit[] = { + image_rgb_16b, + image_rgb_16b_rotated_270_neon, + image_rgb_16b_transp_inv_neon, + image_rgb_16b_rotated_90_neon, + }; + int nb_images_to_blit = sizeof(imgs_to_blit)/sizeof(imgs_to_blit[0]); + int cur_idx_blit = 1; + + + SDL_BlitSurface(imgs_to_blit[cur_idx_blit], NULL, hw_surface, NULL); + + /// -------- Main loop --------- + while (!stop_menu_loop) + { + /// -------- Handle Keyboard Events --------- + while (SDL_PollEvent(&event)) + switch(event.type) + { + case SDL_QUIT: + stop_menu_loop = 1; + break; + case SDL_KEYDOWN: + switch (event.key.keysym.sym) + { + case SDLK_m: + stop_menu_loop = 1; + res = ERROR_MANUAL_FAIL; + break; + + case SDLK_q: + case SDLK_n: + case SDLK_ESCAPE: + stop_menu_loop = 1; + res = 0; + break; + + case SDLK_l: + cur_idx_blit = cur_idx_blit?cur_idx_blit-1:nb_images_to_blit-1; + SDL_BlitSurface(imgs_to_blit[cur_idx_blit], NULL, hw_surface, NULL); + printf("idx = %d\n", cur_idx_blit); + break; + + case SDLK_r: + cur_idx_blit = (cur_idx_blit+1)%nb_images_to_blit; + SDL_BlitSurface(imgs_to_blit[cur_idx_blit], NULL, hw_surface, NULL); + break; + + default: + break; + } + } + + /* To investigate but with Buildroot, we need this: */ + SDL_Flip(hw_surface); + + /* Sleep for some time */ + SDL_Delay(1000/60); + } + + /* free */ + SDL_FreeSurface(image_rgb_16b); + SDL_FreeSurface(image_rgb_16b_rotated_90_neon); +#endif //0 +/*************************************************************************************/ + + + + + + + + + + + + + + + +/****************************************** 3 bis (non squared) ********************************/ +#if 1 + /* Vars */ + int w = image_rgb_16b->w/2, h = image_rgb_16b->h; + SDL_Surface *image_rgb_16b_notsquare = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 16, 0,0,0,0); + //SDL_Rect dst_rect={ (image_rgb_16b->w-w)/2, 0, w, h }; + SDL_BlitSurface(image_rgb_16b, NULL, image_rgb_16b_notsquare, NULL); + uint16_t * p = (uint16_t *)image_rgb_16b_notsquare->pixels; + int y, x; + + /* Rotate 90 CW */ + SDL_Surface *image_rgb_16b_rotated_90_neon = SDL_CreateRGBSurface(SDL_SWSURFACE, h, w, 16, 0,0,0,0); + uint16_t * p2 = (uint16_t *)image_rgb_16b_rotated_90_neon->pixels; + fbtft_rotate_90cw_neon(p, p2, w, h); + + /* Transpose inv */ + SDL_Surface *image_rgb_16b_transp_inv_neon = SDL_CreateRGBSurface(SDL_SWSURFACE, h, w, 16, 0,0,0,0); + uint16_t * p3 = (uint16_t *)image_rgb_16b_transp_inv_neon->pixels; + fbtft_transpose_inv_neon(p, p3, w, h); + + /* Rotate 270 CW */ + SDL_Surface *image_rgb_16b_rotated_270_neon = SDL_CreateRGBSurface(SDL_SWSURFACE, h, w, 16, 0,0,0,0); + uint16_t * p4 = (uint16_t *)image_rgb_16b_rotated_270_neon->pixels; + fbtft_rotate_270cw_neon(p, p4, w, h); + + /* Transpose */ + SDL_Surface *image_rgb_16b_transp_neon = SDL_CreateRGBSurface(SDL_SWSURFACE, h, w, 16, 0,0,0,0); + uint16_t * p5 = (uint16_t *)image_rgb_16b_transp_neon->pixels; + fbtft_transpose_neon(p, p5, w, h); + + /* Blit image */ + SDL_Surface * imgs_to_blit[] = { + image_rgb_16b_notsquare, + image_rgb_16b_rotated_270_neon, + image_rgb_16b_rotated_90_neon, + image_rgb_16b_transp_neon, + image_rgb_16b_transp_inv_neon + }; + int nb_images_to_blit = sizeof(imgs_to_blit)/sizeof(imgs_to_blit[0]); + int cur_idx_blit = 0; + + + SDL_BlitSurface(imgs_to_blit[cur_idx_blit], NULL, hw_surface, NULL); + + /// -------- Main loop --------- + while (!stop_menu_loop) + { + /// -------- Handle Keyboard Events --------- + while (SDL_PollEvent(&event)) + switch(event.type) + { + case SDL_QUIT: + stop_menu_loop = 1; + break; + case SDL_KEYDOWN: + switch (event.key.keysym.sym) + { + case SDLK_m: + stop_menu_loop = 1; + res = ERROR_MANUAL_FAIL; + break; + + case SDLK_q: + case SDLK_n: + case SDLK_ESCAPE: + stop_menu_loop = 1; + res = 0; + break; + + case SDLK_l: + cur_idx_blit = cur_idx_blit?cur_idx_blit-1:nb_images_to_blit-1; + SDL_BlitSurface(imgs_to_blit[cur_idx_blit], NULL, hw_surface, NULL); + printf("idx = %d\n", cur_idx_blit); + break; + + case SDLK_r: + cur_idx_blit = (cur_idx_blit+1)%nb_images_to_blit; + SDL_BlitSurface(imgs_to_blit[cur_idx_blit], NULL, hw_surface, NULL); + break; + + default: + break; + } + } + + /* To investigate but with Buildroot, we need this: */ + SDL_Flip(hw_surface); + + /* Sleep for some time */ + SDL_Delay(1000/60); + } + + /* free */ + SDL_FreeSurface(image_rgb_16b); + SDL_FreeSurface(image_rgb_16b_rotated_90_neon); +#endif //0 +/*************************************************************************************/ + + + + + + + + + + + + + + /****************************************** 4 (perfs tests 240x240) ********************************/ #if 0 //* Vars */