diff options
Diffstat (limited to 'apps/recorder')
-rw-r--r-- | apps/recorder/jpeg_load.c | 37 | ||||
-rw-r--r-- | apps/recorder/keyboard.c | 29 | ||||
-rw-r--r-- | apps/recorder/recording.c | 286 | ||||
-rw-r--r-- | apps/recorder/resize.c | 91 | ||||
-rw-r--r-- | apps/recorder/resize.h | 56 |
5 files changed, 6 insertions, 493 deletions
diff --git a/apps/recorder/jpeg_load.c b/apps/recorder/jpeg_load.c index 61ec3bfa0e..16a2f4e3a3 100644 --- a/apps/recorder/jpeg_load.c +++ b/apps/recorder/jpeg_load.c | |||
@@ -137,21 +137,7 @@ static struct jpeg jpeg; | |||
137 | 137 | ||
138 | INLINE unsigned range_limit(int value) | 138 | INLINE unsigned range_limit(int value) |
139 | { | 139 | { |
140 | #if CONFIG_CPU == SH7034 | 140 | #if defined(CPU_COLDFIRE) |
141 | unsigned tmp; | ||
142 | asm ( /* Note: Uses knowledge that only low byte of result is used */ | ||
143 | "extu.b %[v],%[t] \n" | ||
144 | "cmp/eq %[v],%[t] \n" /* low byte == whole number ? */ | ||
145 | "bt 1f \n" /* yes: no overflow */ | ||
146 | "cmp/pz %[v] \n" /* overflow: positive? */ | ||
147 | "subc %[v],%[v] \n" /* %[r] now either 0 or 0xffffffff */ | ||
148 | "1: \n" | ||
149 | : /* outputs */ | ||
150 | [v]"+r"(value), | ||
151 | [t]"=&r"(tmp) | ||
152 | ); | ||
153 | return value; | ||
154 | #elif defined(CPU_COLDFIRE) | ||
155 | /* Note: Uses knowledge that only the low byte of the result is used */ | 141 | /* Note: Uses knowledge that only the low byte of the result is used */ |
156 | asm ( | 142 | asm ( |
157 | "cmp.l #255,%[v] \n" /* overflow? */ | 143 | "cmp.l #255,%[v] \n" /* overflow? */ |
@@ -232,7 +218,7 @@ INLINE unsigned scale_output(int value) | |||
232 | */ | 218 | */ |
233 | #define MULTIPLY(var1, var2) ((var1) * (var2)) | 219 | #define MULTIPLY(var1, var2) ((var1) * (var2)) |
234 | 220 | ||
235 | #if defined(CPU_SH) || defined(CPU_COLDFIRE) || \ | 221 | #if defined(CPU_COLDFIRE) || \ |
236 | (defined(CPU_ARM) && ARM_ARCH > 4) | 222 | (defined(CPU_ARM) && ARM_ARCH > 4) |
237 | #define MULTIPLY16(var,const) (((short) (var)) * ((short) (const))) | 223 | #define MULTIPLY16(var,const) (((short) (var)) * ((short) (const))) |
238 | #else | 224 | #else |
@@ -1687,24 +1673,6 @@ static void search_restart(struct jpeg *p_jpeg) | |||
1687 | } | 1673 | } |
1688 | 1674 | ||
1689 | /* Figure F.12: extend sign bit. */ | 1675 | /* Figure F.12: extend sign bit. */ |
1690 | #if CONFIG_CPU == SH7034 | ||
1691 | /* SH1 lacks a variable-shift instruction */ | ||
1692 | #define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) | ||
1693 | |||
1694 | static const int extend_test[16] = /* entry n is 2**(n-1) */ | ||
1695 | { | ||
1696 | 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, | ||
1697 | 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 | ||
1698 | }; | ||
1699 | |||
1700 | static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ | ||
1701 | { | ||
1702 | 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, | ||
1703 | ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, | ||
1704 | ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, | ||
1705 | ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 | ||
1706 | }; | ||
1707 | #else | ||
1708 | /* This saves some code and data size, benchmarks about the same on RAM */ | 1676 | /* This saves some code and data size, benchmarks about the same on RAM */ |
1709 | #define HUFF_EXTEND(x,s) \ | 1677 | #define HUFF_EXTEND(x,s) \ |
1710 | ({ \ | 1678 | ({ \ |
@@ -1712,7 +1680,6 @@ static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ | |||
1712 | int s__ = s; \ | 1680 | int s__ = s; \ |
1713 | x__ & BIT_N(s__- 1) ? x__ : x__ + (-1 << s__) + 1; \ | 1681 | x__ & BIT_N(s__- 1) ? x__ : x__ + (-1 << s__) + 1; \ |
1714 | }) | 1682 | }) |
1715 | #endif | ||
1716 | 1683 | ||
1717 | /* Decode a single value */ | 1684 | /* Decode a single value */ |
1718 | #define huff_decode_dc(p_jpeg, tbl, s, r) \ | 1685 | #define huff_decode_dc(p_jpeg, tbl, s, r) \ |
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c index 6e91d69b6d..4b19287b7f 100644 --- a/apps/recorder/keyboard.c +++ b/apps/recorder/keyboard.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include "settings.h" | 27 | #include "settings.h" |
28 | #include "misc.h" | 28 | #include "misc.h" |
29 | #include "rbunicode.h" | 29 | #include "rbunicode.h" |
30 | #include "buttonbar.h" | ||
31 | #include "logf.h" | 30 | #include "logf.h" |
32 | #include "hangul.h" | 31 | #include "hangul.h" |
33 | #include "action.h" | 32 | #include "action.h" |
@@ -343,15 +342,6 @@ int kbd_input(char* text, int buflen, unsigned short *kbd) | |||
343 | viewportmanager_theme_enable(l, false, NULL); | 342 | viewportmanager_theme_enable(l, false, NULL); |
344 | } | 343 | } |
345 | 344 | ||
346 | #ifdef HAVE_BUTTONBAR | ||
347 | struct gui_buttonbar buttonbar; | ||
348 | bool buttonbar_config = global_settings.buttonbar; | ||
349 | |||
350 | global_settings.buttonbar = true; | ||
351 | gui_buttonbar_init(&buttonbar); | ||
352 | gui_buttonbar_set_display(&buttonbar, &screens[SCREEN_MAIN]); | ||
353 | #endif | ||
354 | |||
355 | /* initialize state */ | 345 | /* initialize state */ |
356 | state.text = text; | 346 | state.text = text; |
357 | state.buflen = buflen; | 347 | state.buflen = buflen; |
@@ -482,12 +472,6 @@ int kbd_input(char* text, int buflen, unsigned short *kbd) | |||
482 | #endif | 472 | #endif |
483 | } | 473 | } |
484 | 474 | ||
485 | #ifdef HAVE_BUTTONBAR | ||
486 | /* draw the button bar */ | ||
487 | gui_buttonbar_set(&buttonbar, "Shift", "OK", "Del"); | ||
488 | gui_buttonbar_draw(&buttonbar); | ||
489 | #endif | ||
490 | |||
491 | FOR_NB_SCREENS(l) | 475 | FOR_NB_SCREENS(l) |
492 | screens[l].update(); | 476 | screens[l].update(); |
493 | 477 | ||
@@ -693,10 +677,6 @@ int kbd_input(char* text, int buflen, unsigned short *kbd) | |||
693 | state.changed = 0; | 677 | state.changed = 0; |
694 | } | 678 | } |
695 | 679 | ||
696 | #ifdef HAVE_BUTTONBAR | ||
697 | global_settings.buttonbar = buttonbar_config; | ||
698 | #endif | ||
699 | |||
700 | if (ret < 0) | 680 | if (ret < 0) |
701 | splash(HZ/2, ID2P(LANG_CANCEL)); | 681 | splash(HZ/2, ID2P(LANG_CANCEL)); |
702 | 682 | ||
@@ -736,7 +716,7 @@ static void kbd_calc_params(struct keyboard_parameters *pm, | |||
736 | pm->font_h = font->height; | 716 | pm->font_h = font->height; |
737 | 717 | ||
738 | /* check if FONT_UI fits the screen */ | 718 | /* check if FONT_UI fits the screen */ |
739 | if (2*pm->font_h + 3 + BUTTONBAR_HEIGHT > sc->getheight()) | 719 | if (2*pm->font_h + 3 > sc->getheight()) |
740 | { | 720 | { |
741 | pm->curfont = FONT_SYSFIXED; | 721 | pm->curfont = FONT_SYSFIXED; |
742 | font = font_get(FONT_SYSFIXED); | 722 | font = font_get(FONT_SYSFIXED); |
@@ -796,13 +776,12 @@ static void kbd_calc_params(struct keyboard_parameters *pm, | |||
796 | } | 776 | } |
797 | recalc_param: | 777 | recalc_param: |
798 | #endif | 778 | #endif |
799 | pm->lines = (sc_h - BUTTONBAR_HEIGHT) / pm->font_h - 1; | 779 | pm->lines = sc_h / pm->font_h - 1; |
800 | 780 | ||
801 | if (pm->default_lines && pm->lines > pm->default_lines) | 781 | if (pm->default_lines && pm->lines > pm->default_lines) |
802 | pm->lines = pm->default_lines; | 782 | pm->lines = pm->default_lines; |
803 | 783 | ||
804 | pm->keyboard_margin = sc_h - BUTTONBAR_HEIGHT | 784 | pm->keyboard_margin = sc_h - (pm->lines+1)*pm->font_h; |
805 | - (pm->lines+1)*pm->font_h; | ||
806 | 785 | ||
807 | if (pm->keyboard_margin < 3 && pm->lines > 1) | 786 | if (pm->keyboard_margin < 3 && pm->lines > 1) |
808 | { | 787 | { |
@@ -840,7 +819,7 @@ recalc_param: | |||
840 | #endif | 819 | #endif |
841 | 820 | ||
842 | #ifdef HAVE_MORSE_INPUT | 821 | #ifdef HAVE_MORSE_INPUT |
843 | pm->old_main_y = sc_h - pm->font_h - BUTTONBAR_HEIGHT; | 822 | pm->old_main_y = sc_h - pm->font_h; |
844 | if (state->morse_mode) | 823 | if (state->morse_mode) |
845 | { | 824 | { |
846 | int y = pm->main_y; | 825 | int y = pm->main_y; |
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index b67436839c..553f815e52 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c | |||
@@ -145,11 +145,6 @@ bool in_recording_screen(void) | |||
145 | return (rec_status & RCSTAT_IN_RECSCREEN) != 0; | 145 | return (rec_status & RCSTAT_IN_RECSCREEN) != 0; |
146 | } | 146 | } |
147 | 147 | ||
148 | #if CONFIG_KEYPAD == RECORDER_PAD | ||
149 | static bool f2_rec_screen(void); | ||
150 | static bool f3_rec_screen(void); | ||
151 | #endif | ||
152 | |||
153 | #define MAX_FILE_SIZE 0x7F800000 /* 2 GB - 4 MB */ | 148 | #define MAX_FILE_SIZE 0x7F800000 /* 2 GB - 4 MB */ |
154 | 149 | ||
155 | #ifndef HAVE_REMOTE_LCD | 150 | #ifndef HAVE_REMOTE_LCD |
@@ -1574,47 +1569,6 @@ bool recording_screen(bool no_source) | |||
1574 | } | 1569 | } |
1575 | break; | 1570 | break; |
1576 | 1571 | ||
1577 | #if CONFIG_KEYPAD == RECORDER_PAD | ||
1578 | case ACTION_REC_F2: | ||
1579 | if(audio_stat != AUDIO_STATUS_RECORD) | ||
1580 | { | ||
1581 | #if (CONFIG_LED == LED_REAL) | ||
1582 | /* led is restored at begin of loop / end of function */ | ||
1583 | led(false); | ||
1584 | #endif | ||
1585 | if (f2_rec_screen()) | ||
1586 | { | ||
1587 | rec_status |= RCSTAT_HAVE_RECORDED; | ||
1588 | done = true; | ||
1589 | } | ||
1590 | else | ||
1591 | update_countdown = 0; /* Update immediately */ | ||
1592 | } | ||
1593 | break; | ||
1594 | |||
1595 | case ACTION_REC_F3: | ||
1596 | if(audio_stat & AUDIO_STATUS_RECORD) | ||
1597 | { | ||
1598 | rec_command(RECORDING_CMD_START_NEWFILE); | ||
1599 | last_seconds = 0; | ||
1600 | } | ||
1601 | else | ||
1602 | { | ||
1603 | #if (CONFIG_LED == LED_REAL) | ||
1604 | /* led is restored at begin of loop / end of function */ | ||
1605 | led(false); | ||
1606 | #endif | ||
1607 | if (f3_rec_screen()) | ||
1608 | { | ||
1609 | rec_status |= RCSTAT_HAVE_RECORDED; | ||
1610 | done = true; | ||
1611 | } | ||
1612 | else | ||
1613 | update_countdown = 0; /* Update immediately */ | ||
1614 | } | ||
1615 | break; | ||
1616 | #endif /* CONFIG_KEYPAD == RECORDER_PAD */ | ||
1617 | |||
1618 | case SYS_POWEROFF: | 1572 | case SYS_POWEROFF: |
1619 | default_event_handler(SYS_POWEROFF); | 1573 | default_event_handler(SYS_POWEROFF); |
1620 | done = true; | 1574 | done = true; |
@@ -1941,246 +1895,6 @@ rec_abort: | |||
1941 | return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0; | 1895 | return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0; |
1942 | } /* recording_screen */ | 1896 | } /* recording_screen */ |
1943 | 1897 | ||
1944 | #if CONFIG_KEYPAD == RECORDER_PAD | ||
1945 | static bool f2_rec_screen(void) | ||
1946 | { | ||
1947 | static const char* const freq_str[6] = | ||
1948 | { | ||
1949 | "44.1kHz", | ||
1950 | "48kHz", | ||
1951 | "32kHz", | ||
1952 | "22.05kHz", | ||
1953 | "24kHz", | ||
1954 | "16kHz" | ||
1955 | }; | ||
1956 | |||
1957 | bool exit = false; | ||
1958 | bool used = false; | ||
1959 | int w, h; | ||
1960 | char buf[32]; | ||
1961 | int button; | ||
1962 | struct audio_recording_options rec_options; | ||
1963 | |||
1964 | FOR_NB_SCREENS(i) | ||
1965 | { | ||
1966 | screens[i].set_viewport(NULL); | ||
1967 | screens[i].setfont(FONT_SYSFIXED); | ||
1968 | screens[i].getstringsize("A",&w,&h); | ||
1969 | } | ||
1970 | |||
1971 | while (!exit) { | ||
1972 | const char* ptr; | ||
1973 | |||
1974 | FOR_NB_SCREENS(i) | ||
1975 | { | ||
1976 | screens[i].clear_display(); | ||
1977 | |||
1978 | /* Recording quality */ | ||
1979 | screens[i].putsxy(0, LCD_HEIGHT/2 - h*2, | ||
1980 | str(LANG_SYSFONT_RECORDING_QUALITY)); | ||
1981 | } | ||
1982 | |||
1983 | snprintf(buf, sizeof(buf), "%d", global_settings.rec_quality); | ||
1984 | FOR_NB_SCREENS(i) | ||
1985 | { | ||
1986 | screens[i].putsxy(0, LCD_HEIGHT/2-h, buf); | ||
1987 | screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], | ||
1988 | LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8); | ||
1989 | } | ||
1990 | |||
1991 | /* Frequency */ | ||
1992 | snprintf(buf, sizeof buf, "%s:", str(LANG_SYSFONT_RECORDING_FREQUENCY)); | ||
1993 | ptr = freq_str[global_settings.rec_frequency]; | ||
1994 | FOR_NB_SCREENS(i) | ||
1995 | { | ||
1996 | screens[i].getstringsize(buf,&w,&h); | ||
1997 | screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, buf); | ||
1998 | screens[i].getstringsize(ptr, &w, &h); | ||
1999 | screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr); | ||
2000 | screens[i].mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], | ||
2001 | LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8); | ||
2002 | } | ||
2003 | |||
2004 | /* Channel mode */ | ||
2005 | switch ( global_settings.rec_channels ) { | ||
2006 | case 0: | ||
2007 | ptr = str(LANG_SYSFONT_CHANNEL_STEREO); | ||
2008 | break; | ||
2009 | |||
2010 | case 1: | ||
2011 | ptr = str(LANG_SYSFONT_CHANNEL_MONO); | ||
2012 | break; | ||
2013 | } | ||
2014 | |||
2015 | FOR_NB_SCREENS(i) | ||
2016 | { | ||
2017 | screens[i].getstringsize(str(LANG_SYSFONT_CHANNELS), &w, &h); | ||
2018 | screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, | ||
2019 | str(LANG_SYSFONT_CHANNELS)); | ||
2020 | screens[i].getstringsize(str(LANG_SYSFONT_MODE), &w, &h); | ||
2021 | screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, | ||
2022 | str(LANG_SYSFONT_MODE)); | ||
2023 | screens[i].getstringsize(ptr, &w, &h); | ||
2024 | screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, ptr); | ||
2025 | screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastForward], | ||
2026 | LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8); | ||
2027 | |||
2028 | screens[i].update(); | ||
2029 | } | ||
2030 | |||
2031 | button = button_get(true); | ||
2032 | switch (button) { | ||
2033 | case BUTTON_LEFT: | ||
2034 | case BUTTON_F2 | BUTTON_LEFT: | ||
2035 | global_settings.rec_quality++; | ||
2036 | if(global_settings.rec_quality > 7) | ||
2037 | global_settings.rec_quality = 0; | ||
2038 | used = true; | ||
2039 | break; | ||
2040 | |||
2041 | case BUTTON_DOWN: | ||
2042 | case BUTTON_F2 | BUTTON_DOWN: | ||
2043 | global_settings.rec_frequency++; | ||
2044 | if(global_settings.rec_frequency > 5) | ||
2045 | global_settings.rec_frequency = 0; | ||
2046 | used = true; | ||
2047 | break; | ||
2048 | |||
2049 | case BUTTON_RIGHT: | ||
2050 | case BUTTON_F2 | BUTTON_RIGHT: | ||
2051 | global_settings.rec_channels++; | ||
2052 | if(global_settings.rec_channels > 1) | ||
2053 | global_settings.rec_channels = 0; | ||
2054 | used = true; | ||
2055 | break; | ||
2056 | |||
2057 | case BUTTON_F2 | BUTTON_REL: | ||
2058 | if ( used ) | ||
2059 | exit = true; | ||
2060 | used = true; | ||
2061 | break; | ||
2062 | |||
2063 | case BUTTON_F2 | BUTTON_REPEAT: | ||
2064 | used = true; | ||
2065 | break; | ||
2066 | |||
2067 | default: | ||
2068 | if(default_event_handler(button) == SYS_USB_CONNECTED) | ||
2069 | return true; | ||
2070 | break; | ||
2071 | } | ||
2072 | } | ||
2073 | |||
2074 | rec_init_recording_options(&rec_options); | ||
2075 | rec_set_recording_options(&rec_options); | ||
2076 | |||
2077 | set_gain(); | ||
2078 | |||
2079 | settings_save(); | ||
2080 | FOR_NB_SCREENS(i) | ||
2081 | screens[i].setfont(FONT_UI); | ||
2082 | |||
2083 | return false; | ||
2084 | } | ||
2085 | |||
2086 | static bool f3_rec_screen(void) | ||
2087 | { | ||
2088 | bool exit = false; | ||
2089 | bool used = false; | ||
2090 | int w, h; | ||
2091 | int button; | ||
2092 | const char *src_str[] = | ||
2093 | { | ||
2094 | str(LANG_SYSFONT_RECORDING_SRC_MIC), | ||
2095 | str(LANG_SYSFONT_LINE_IN), | ||
2096 | str(LANG_SYSFONT_RECORDING_SRC_DIGITAL) | ||
2097 | }; | ||
2098 | struct audio_recording_options rec_options; | ||
2099 | |||
2100 | FOR_NB_SCREENS(i) | ||
2101 | { | ||
2102 | screens[i].set_viewport(NULL); | ||
2103 | screens[i].setfont(FONT_SYSFIXED); | ||
2104 | screens[i].getstringsize("A",&w,&h); | ||
2105 | } | ||
2106 | |||
2107 | while (!exit) { | ||
2108 | const char* ptr = src_str[global_settings.rec_source]; | ||
2109 | FOR_NB_SCREENS(i) | ||
2110 | { | ||
2111 | screens[i].clear_display(); | ||
2112 | |||
2113 | /* Recording source */ | ||
2114 | screens[i].putsxy(0, LCD_HEIGHT/2 - h*2, | ||
2115 | str(LANG_SYSFONT_RECORDING_SOURCE)); | ||
2116 | |||
2117 | screens[i].getstringsize(ptr, &w, &h); | ||
2118 | screens[i].putsxy(0, LCD_HEIGHT/2-h, ptr); | ||
2119 | screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], | ||
2120 | LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8); | ||
2121 | } | ||
2122 | |||
2123 | /* trigger setup */ | ||
2124 | ptr = str(LANG_SYSFONT_RECORD_TRIGGER); | ||
2125 | FOR_NB_SCREENS(i) | ||
2126 | { | ||
2127 | screens[i].getstringsize(ptr,&w,&h); | ||
2128 | screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, ptr); | ||
2129 | screens[i].mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], | ||
2130 | LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8); | ||
2131 | |||
2132 | screens[i].update(); | ||
2133 | } | ||
2134 | |||
2135 | button = button_get(true); | ||
2136 | switch (button) { | ||
2137 | case BUTTON_DOWN: | ||
2138 | case BUTTON_F3 | BUTTON_DOWN: | ||
2139 | #ifndef SIMULATOR | ||
2140 | rectrigger(); | ||
2141 | settings_apply_trigger(); | ||
2142 | #endif | ||
2143 | exit = true; | ||
2144 | break; | ||
2145 | |||
2146 | case BUTTON_LEFT: | ||
2147 | case BUTTON_F3 | BUTTON_LEFT: | ||
2148 | global_settings.rec_source++; | ||
2149 | if(global_settings.rec_source > AUDIO_SRC_MAX) | ||
2150 | global_settings.rec_source = 0; | ||
2151 | used = true; | ||
2152 | break; | ||
2153 | |||
2154 | case BUTTON_F3 | BUTTON_REL: | ||
2155 | if ( used ) | ||
2156 | exit = true; | ||
2157 | used = true; | ||
2158 | break; | ||
2159 | |||
2160 | case BUTTON_F3 | BUTTON_REPEAT: | ||
2161 | used = true; | ||
2162 | break; | ||
2163 | |||
2164 | default: | ||
2165 | if(default_event_handler(button) == SYS_USB_CONNECTED) | ||
2166 | return true; | ||
2167 | break; | ||
2168 | } | ||
2169 | } | ||
2170 | |||
2171 | rec_init_recording_options(&rec_options); | ||
2172 | rec_set_recording_options(&rec_options); | ||
2173 | |||
2174 | set_gain(); | ||
2175 | |||
2176 | settings_save(); | ||
2177 | FOR_NB_SCREENS(i) | ||
2178 | screens[i].setfont(FONT_UI); | ||
2179 | |||
2180 | return false; | ||
2181 | } | ||
2182 | #endif /* CONFIG_KEYPAD == RECORDER_PAD */ | ||
2183 | |||
2184 | #if CONFIG_CODEC == SWCODEC | 1898 | #if CONFIG_CODEC == SWCODEC |
2185 | void audio_beep(int duration) | 1899 | void audio_beep(int duration) |
2186 | { | 1900 | { |
diff --git a/apps/recorder/resize.c b/apps/recorder/resize.c index ac6b7a3120..6f561039c3 100644 --- a/apps/recorder/resize.c +++ b/apps/recorder/resize.c | |||
@@ -63,14 +63,8 @@ | |||
63 | #endif | 63 | #endif |
64 | #include <jpeg_load.h> | 64 | #include <jpeg_load.h> |
65 | 65 | ||
66 | #if CONFIG_CPU == SH7034 | ||
67 | /* 16*16->32 bit multiplication is a single instrcution on the SH1 */ | ||
68 | #define MULUQ(a, b) ((uint32_t) (((uint16_t) (a)) * ((uint16_t) (b)))) | ||
69 | #define MULQ(a, b) ((int32_t) (((int16_t) (a)) * ((int16_t) (b)))) | ||
70 | #else | ||
71 | #define MULUQ(a, b) ((a) * (b)) | 66 | #define MULUQ(a, b) ((a) * (b)) |
72 | #define MULQ(a, b) ((a) * (b)) | 67 | #define MULQ(a, b) ((a) * (b)) |
73 | #endif | ||
74 | 68 | ||
75 | #ifdef HAVE_LCD_COLOR | 69 | #ifdef HAVE_LCD_COLOR |
76 | #define CHANNEL_BYTES (sizeof(struct uint32_argb)/sizeof(uint32_t)) | 70 | #define CHANNEL_BYTES (sizeof(struct uint32_argb)/sizeof(uint32_t)) |
@@ -151,18 +145,6 @@ int recalc_dimension(struct dim *dst, struct dim *src) | |||
151 | "movclr.l %%acc" #num ", %0" \ | 145 | "movclr.l %%acc" #num ", %0" \ |
152 | : "=d" (dest) \ | 146 | : "=d" (dest) \ |
153 | ) | 147 | ) |
154 | #elif defined(CPU_SH) | ||
155 | /* calculate the 32-bit product of unsigned 16-bit op1 and op2 */ | ||
156 | static inline int32_t mul_s16_s16(int16_t op1, int16_t op2) | ||
157 | { | ||
158 | return (int32_t)(op1 * op2); | ||
159 | } | ||
160 | |||
161 | /* calculate the 32-bit product of signed 16-bit op1 and op2 */ | ||
162 | static inline uint32_t mul_u16_u16(uint16_t op1, uint16_t op2) | ||
163 | { | ||
164 | return (uint32_t)(op1 * op2); | ||
165 | } | ||
166 | #endif | 148 | #endif |
167 | 149 | ||
168 | /* horizontal area average scaler */ | 150 | /* horizontal area average scaler */ |
@@ -171,13 +153,8 @@ static bool scale_h_area(void *out_line_ptr, | |||
171 | { | 153 | { |
172 | SDEBUGF("scale_h_area\n"); | 154 | SDEBUGF("scale_h_area\n"); |
173 | unsigned int ix, ox, oxe, mul; | 155 | unsigned int ix, ox, oxe, mul; |
174 | #if defined(CPU_SH) || defined (TEST_SH_MATH) | ||
175 | const uint32_t h_i_val = ctx->src->width, | ||
176 | h_o_val = ctx->bm->width; | ||
177 | #else | ||
178 | const uint32_t h_i_val = ctx->h_i_val, | 156 | const uint32_t h_i_val = ctx->h_i_val, |
179 | h_o_val = ctx->h_o_val; | 157 | h_o_val = ctx->h_o_val; |
180 | #endif | ||
181 | #ifdef HAVE_LCD_COLOR | 158 | #ifdef HAVE_LCD_COLOR |
182 | struct uint32_argb rgbvalacc = { 0, 0, 0, 0 }, | 159 | struct uint32_argb rgbvalacc = { 0, 0, 0, 0 }, |
183 | rgbvaltmp = { 0, 0, 0, 0 }, | 160 | rgbvaltmp = { 0, 0, 0, 0 }, |
@@ -298,15 +275,6 @@ static bool scale_h_area(void *out_line_ptr, | |||
298 | mul = h_o_val - oxe; | 275 | mul = h_o_val - oxe; |
299 | MAC(tmp, mul, 0); | 276 | MAC(tmp, mul, 0); |
300 | MAC_OUT(acc, 0); | 277 | MAC_OUT(acc, 0); |
301 | #elif defined(CPU_SH) | ||
302 | /* SH-1 16x16->32 math */ | ||
303 | /* add saved partial pixel from start of area */ | ||
304 | acc = mul_u16_u16(acc, h_o_val) + mul_u16_u16(tmp, mul); | ||
305 | |||
306 | /* get new pixel , then add its partial coverage to this area */ | ||
307 | tmp = *(part->buf); | ||
308 | mul = h_o_val - oxe; | ||
309 | acc += mul_u16_u16(tmp, mul); | ||
310 | #else | 278 | #else |
311 | /* generic C math */ | 279 | /* generic C math */ |
312 | /* add saved partial pixel from start of area */ | 280 | /* add saved partial pixel from start of area */ |
@@ -317,10 +285,8 @@ static bool scale_h_area(void *out_line_ptr, | |||
317 | mul = h_o_val - oxe; | 285 | mul = h_o_val - oxe; |
318 | acc += tmp * mul; | 286 | acc += tmp * mul; |
319 | #endif /* CPU */ | 287 | #endif /* CPU */ |
320 | #if !(defined(CPU_SH) || defined(TEST_SH_MATH)) | ||
321 | /* round, divide, and either store or accumulate to output row */ | 288 | /* round, divide, and either store or accumulate to output row */ |
322 | acc = (acc + (1 << 21)) >> 22; | 289 | acc = (acc + (1 << 21)) >> 22; |
323 | #endif | ||
324 | if (accum) | 290 | if (accum) |
325 | { | 291 | { |
326 | acc += out_line[ox]; | 292 | acc += out_line[ox]; |
@@ -346,13 +312,8 @@ static bool scale_h_area(void *out_line_ptr, | |||
346 | static inline bool scale_v_area(struct rowset *rset, struct scaler_context *ctx) | 312 | static inline bool scale_v_area(struct rowset *rset, struct scaler_context *ctx) |
347 | { | 313 | { |
348 | uint32_t mul, oy, iy, oye; | 314 | uint32_t mul, oy, iy, oye; |
349 | #if defined(CPU_SH) || defined (TEST_SH_MATH) | ||
350 | const uint32_t v_i_val = ctx->src->height, | ||
351 | v_o_val = ctx->bm->height; | ||
352 | #else | ||
353 | const uint32_t v_i_val = ctx->v_i_val, | 315 | const uint32_t v_i_val = ctx->v_i_val, |
354 | v_o_val = ctx->v_o_val; | 316 | v_o_val = ctx->v_o_val; |
355 | #endif | ||
356 | 317 | ||
357 | /* Set up rounding and scale factors */ | 318 | /* Set up rounding and scale factors */ |
358 | mul = 0; | 319 | mul = 0; |
@@ -409,13 +370,8 @@ static bool scale_h_linear(void *out_line_ptr, struct scaler_context *ctx, | |||
409 | bool accum) | 370 | bool accum) |
410 | { | 371 | { |
411 | unsigned int ix, ox, ixe; | 372 | unsigned int ix, ox, ixe; |
412 | #if defined(CPU_SH) || defined (TEST_SH_MATH) | ||
413 | const uint32_t h_i_val = ctx->src->width - 1, | ||
414 | h_o_val = ctx->bm->width - 1; | ||
415 | #else | ||
416 | const uint32_t h_i_val = ctx->h_i_val, | 373 | const uint32_t h_i_val = ctx->h_i_val, |
417 | h_o_val = ctx->h_o_val; | 374 | h_o_val = ctx->h_o_val; |
418 | #endif | ||
419 | /* type x = x is an ugly hack for hiding an unitialized data warning. The | 375 | /* type x = x is an ugly hack for hiding an unitialized data warning. The |
420 | values are conditionally initialized before use, but other values are | 376 | values are conditionally initialized before use, but other values are |
421 | set such that this will occur before these are used. | 377 | set such that this will occur before these are used. |
@@ -531,9 +487,6 @@ static bool scale_h_linear(void *out_line_ptr, struct scaler_context *ctx, | |||
531 | #if defined(CPU_COLDFIRE) | 487 | #if defined(CPU_COLDFIRE) |
532 | /* Coldfire EMAC math */ | 488 | /* Coldfire EMAC math */ |
533 | MAC(val, h_o_val, 0); | 489 | MAC(val, h_o_val, 0); |
534 | #elif defined(CPU_SH) | ||
535 | /* SH-1 16x16->32 math */ | ||
536 | val = mul_u16_u16(val, h_o_val); | ||
537 | #else | 490 | #else |
538 | /* generic C math */ | 491 | /* generic C math */ |
539 | val = val * h_o_val; | 492 | val = val * h_o_val; |
@@ -552,9 +505,6 @@ static bool scale_h_linear(void *out_line_ptr, struct scaler_context *ctx, | |||
552 | #if defined(CPU_COLDFIRE) | 505 | #if defined(CPU_COLDFIRE) |
553 | /* Coldfire EMAC math */ | 506 | /* Coldfire EMAC math */ |
554 | MAC(inc, ixe, 0); | 507 | MAC(inc, ixe, 0); |
555 | #elif defined(CPU_SH) | ||
556 | /* SH-1 16x16->32 math */ | ||
557 | val += mul_s16_s16(inc, ixe); | ||
558 | #else | 508 | #else |
559 | /* generic C math */ | 509 | /* generic C math */ |
560 | val += inc * ixe; | 510 | val += inc * ixe; |
@@ -565,16 +515,10 @@ static bool scale_h_linear(void *out_line_ptr, struct scaler_context *ctx, | |||
565 | MAC_OUT(val, 0); | 515 | MAC_OUT(val, 0); |
566 | #endif | 516 | #endif |
567 | /* Now multiply the color increment to its proper value */ | 517 | /* Now multiply the color increment to its proper value */ |
568 | #if defined(CPU_SH) | ||
569 | /* SH-1 16x16->32 math */ | ||
570 | inc = mul_s16_s16(inc, h_i_val); | ||
571 | #else | ||
572 | /* generic C math */ | 518 | /* generic C math */ |
573 | inc *= h_i_val; | 519 | inc *= h_i_val; |
574 | #endif | ||
575 | } else | 520 | } else |
576 | val += inc; | 521 | val += inc; |
577 | #if !(defined(CPU_SH) || defined(TEST_SH_MATH)) | ||
578 | /* round and scale values, and accumulate or store to output */ | 522 | /* round and scale values, and accumulate or store to output */ |
579 | if (accum) | 523 | if (accum) |
580 | { | 524 | { |
@@ -582,15 +526,6 @@ static bool scale_h_linear(void *out_line_ptr, struct scaler_context *ctx, | |||
582 | } else { | 526 | } else { |
583 | out_line[ox] = (val + (1 << 21)) >> 22; | 527 | out_line[ox] = (val + (1 << 21)) >> 22; |
584 | } | 528 | } |
585 | #else | ||
586 | /* round and scale values, and accumulate or store to output */ | ||
587 | if (accum) | ||
588 | { | ||
589 | out_line[ox] += val; | ||
590 | } else { | ||
591 | out_line[ox] = val; | ||
592 | } | ||
593 | #endif | ||
594 | #endif | 529 | #endif |
595 | ixe += h_i_val; | 530 | ixe += h_i_val; |
596 | } | 531 | } |
@@ -603,13 +538,8 @@ static inline bool scale_v_linear(struct rowset *rset, | |||
603 | { | 538 | { |
604 | uint32_t iy, iye; | 539 | uint32_t iy, iye; |
605 | int32_t oy; | 540 | int32_t oy; |
606 | #if defined(CPU_SH) || defined (TEST_SH_MATH) | ||
607 | const uint32_t v_i_val = ctx->src->height - 1, | ||
608 | v_o_val = ctx->bm->height - 1; | ||
609 | #else | ||
610 | const uint32_t v_i_val = ctx->v_i_val, | 541 | const uint32_t v_i_val = ctx->v_i_val, |
611 | v_o_val = ctx->v_o_val; | 542 | v_o_val = ctx->v_o_val; |
612 | #endif | ||
613 | /* Set up our buffers, to store the increment and current value for each | 543 | /* Set up our buffers, to store the increment and current value for each |
614 | column, and one temp buffer used to read in new rows. | 544 | column, and one temp buffer used to read in new rows. |
615 | */ | 545 | */ |
@@ -892,9 +822,6 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, | |||
892 | ctx.bm = bm; | 822 | ctx.bm = bm; |
893 | ctx.src = src; | 823 | ctx.src = src; |
894 | ctx.dither = dither; | 824 | ctx.dither = dither; |
895 | #if defined(CPU_SH) || defined (TEST_SH_MATH) | ||
896 | uint32_t div; | ||
897 | #endif | ||
898 | #if !defined(PLUGIN) | 825 | #if !defined(PLUGIN) |
899 | #if defined(HAVE_LCD_COLOR) && defined(HAVE_JPEG) | 826 | #if defined(HAVE_LCD_COLOR) && defined(HAVE_JPEG) |
900 | ctx.output_row = format_index ? output_row_32_native_fromyuv | 827 | ctx.output_row = format_index ? output_row_32_native_fromyuv |
@@ -914,23 +841,15 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, | |||
914 | { | 841 | { |
915 | #endif | 842 | #endif |
916 | ctx.h_scaler = scale_h_area; | 843 | ctx.h_scaler = scale_h_area; |
917 | #if defined(CPU_SH) || defined (TEST_SH_MATH) | ||
918 | div = sw; | ||
919 | #else | ||
920 | uint32_t h_div = (1U << 24) / sw; | 844 | uint32_t h_div = (1U << 24) / sw; |
921 | ctx.h_i_val = sw * h_div; | 845 | ctx.h_i_val = sw * h_div; |
922 | ctx.h_o_val = dw * h_div; | 846 | ctx.h_o_val = dw * h_div; |
923 | #endif | ||
924 | #ifdef HAVE_UPSCALER | 847 | #ifdef HAVE_UPSCALER |
925 | } else { | 848 | } else { |
926 | ctx.h_scaler = scale_h_linear; | 849 | ctx.h_scaler = scale_h_linear; |
927 | #if defined(CPU_SH) || defined (TEST_SH_MATH) | ||
928 | div = dw - 1; | ||
929 | #else | ||
930 | uint32_t h_div = (1U << 24) / (dw - 1); | 850 | uint32_t h_div = (1U << 24) / (dw - 1); |
931 | ctx.h_i_val = (sw - 1) * h_div; | 851 | ctx.h_i_val = (sw - 1) * h_div; |
932 | ctx.h_o_val = (dw - 1) * h_div; | 852 | ctx.h_o_val = (dw - 1) * h_div; |
933 | #endif | ||
934 | } | 853 | } |
935 | #endif | 854 | #endif |
936 | #ifdef CPU_COLDFIRE | 855 | #ifdef CPU_COLDFIRE |
@@ -941,27 +860,17 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src, | |||
941 | if (sh > dh) | 860 | if (sh > dh) |
942 | #endif | 861 | #endif |
943 | { | 862 | { |
944 | #if defined(CPU_SH) || defined (TEST_SH_MATH) | ||
945 | div *= sh; | ||
946 | ctx.recip = ((uint32_t)(-div)) / div + 1; | ||
947 | #else | ||
948 | uint32_t v_div = (1U << 22) / sh; | 863 | uint32_t v_div = (1U << 22) / sh; |
949 | ctx.v_i_val = sh * v_div; | 864 | ctx.v_i_val = sh * v_div; |
950 | ctx.v_o_val = dh * v_div; | 865 | ctx.v_o_val = dh * v_div; |
951 | #endif | ||
952 | ret = scale_v_area(rset, &ctx); | 866 | ret = scale_v_area(rset, &ctx); |
953 | } | 867 | } |
954 | #ifdef HAVE_UPSCALER | 868 | #ifdef HAVE_UPSCALER |
955 | else | 869 | else |
956 | { | 870 | { |
957 | #if defined(CPU_SH) || defined (TEST_SH_MATH) | ||
958 | div *= dh - 1; | ||
959 | ctx.recip = ((uint32_t)(-div)) / div + 1; | ||
960 | #else | ||
961 | uint32_t v_div = (1U << 22) / dh; | 871 | uint32_t v_div = (1U << 22) / dh; |
962 | ctx.v_i_val = (sh - 1) * v_div; | 872 | ctx.v_i_val = (sh - 1) * v_div; |
963 | ctx.v_o_val = (dh - 1) * v_div; | 873 | ctx.v_o_val = (dh - 1) * v_div; |
964 | #endif | ||
965 | ret = scale_v_linear(rset, &ctx); | 874 | ret = scale_v_linear(rset, &ctx); |
966 | } | 875 | } |
967 | #endif | 876 | #endif |
diff --git a/apps/recorder/resize.h b/apps/recorder/resize.h index 7e0a991eea..0282a17197 100644 --- a/apps/recorder/resize.h +++ b/apps/recorder/resize.h | |||
@@ -43,59 +43,7 @@ | |||
43 | #define MAX_SC_STACK_ALLOC 0 | 43 | #define MAX_SC_STACK_ALLOC 0 |
44 | #define HAVE_UPSCALER 1 | 44 | #define HAVE_UPSCALER 1 |
45 | 45 | ||
46 | #if defined(CPU_SH) | ||
47 | /* perform 32x32->40 unsigned multiply, round off and return top 8 bits */ | ||
48 | static inline uint32_t sc_mul_u32_rnd(uint32_t m, uint32_t n) | ||
49 | { | ||
50 | unsigned r, t1, t2, t3; | ||
51 | unsigned h = 1 << 15; | ||
52 | /* notation: | ||
53 | m = ab, n = cd | ||
54 | final result is (((a *c) << 32) + ((b * c + a * d) << 16) + b * d + | ||
55 | (1 << 31)) >> 32 | ||
56 | */ | ||
57 | asm ( | ||
58 | "swap.w %[m], %[t1]\n\t" /* t1 = ba */ | ||
59 | "mulu %[m], %[n]\n\t" /* b * d */ | ||
60 | "swap.w %[n], %[t3]\n\t" /* t3 = dc */ | ||
61 | "sts macl, %[r]\n\t" /* r = b * d */ | ||
62 | "mulu %[m], %[t3]\n\t" /* b * c */ | ||
63 | "shlr16 %[r]\n\t" | ||
64 | "sts macl, %[t2]\n\t" /* t2 = b * c */ | ||
65 | "mulu %[t1], %[t3]\n\t" /* a * c */ | ||
66 | "add %[t2], %[r]\n\t" | ||
67 | "sts macl, %[t3]\n\t" /* t3 = a * c */ | ||
68 | "mulu %[t1], %[n]\n\t" /* a * d */ | ||
69 | "shll16 %[t3]\n\t" | ||
70 | "sts macl, %[t2]\n\t" /* t2 = a * d */ | ||
71 | "add %[t2], %[r]\n\t" | ||
72 | "add %[t3], %[r]\n\t" /* r = ((b * d) >> 16) + (b * c + a * d) + | ||
73 | ((a * c) << 16) */ | ||
74 | "add %[h], %[r]\n\t" /* round result */ | ||
75 | "shlr16 %[r]\n\t" /* truncate result */ | ||
76 | : /* outputs */ | ||
77 | [r] "=&r"(r), | ||
78 | [t1]"=&r"(t1), | ||
79 | [t2]"=&r"(t2), | ||
80 | [t3]"=&r"(t3) | ||
81 | : /* inputs */ | ||
82 | [h] "r" (h), | ||
83 | [m] "r" (m), | ||
84 | [n] "r" (n) | ||
85 | ); | ||
86 | return r; | ||
87 | } | ||
88 | #elif defined(TEST_SH_MATH) | ||
89 | static inline uint32_t sc_mul_u32_rnd(uint32_t op1, uint32_t op2) | ||
90 | { | ||
91 | uint64_t tmp = (uint64_t)op1 * op2; | ||
92 | tmp += 1LU << 31; | ||
93 | tmp >>= 32; | ||
94 | return tmp; | ||
95 | } | ||
96 | #else | ||
97 | #define SC_OUT(n, c) (((n) + (1 << 23)) >> 24) | 46 | #define SC_OUT(n, c) (((n) + (1 << 23)) >> 24) |
98 | #endif | ||
99 | #ifndef SC_OUT | 47 | #ifndef SC_OUT |
100 | #define SC_OUT(n, c) (sc_mul_u32_rnd(n, (c)->recip)) | 48 | #define SC_OUT(n, c) (sc_mul_u32_rnd(n, (c)->recip)) |
101 | #endif | 49 | #endif |
@@ -125,14 +73,10 @@ struct uint32_argb { | |||
125 | horizontal scaler, and row output | 73 | horizontal scaler, and row output |
126 | */ | 74 | */ |
127 | struct scaler_context { | 75 | struct scaler_context { |
128 | #if defined(CPU_SH) || defined(TEST_SH_MATH) | ||
129 | uint32_t recip; | ||
130 | #else | ||
131 | uint32_t h_i_val; | 76 | uint32_t h_i_val; |
132 | uint32_t h_o_val; | 77 | uint32_t h_o_val; |
133 | uint32_t v_i_val; | 78 | uint32_t v_i_val; |
134 | uint32_t v_o_val; | 79 | uint32_t v_o_val; |
135 | #endif | ||
136 | struct bitmap *bm; | 80 | struct bitmap *bm; |
137 | struct dim *src; | 81 | struct dim *src; |
138 | unsigned char *buf; | 82 | unsigned char *buf; |