Shrink the code by 16 bytes by using an array to map values

This commit is contained in:
Ari Sundholm 2017-11-02 22:37:27 +02:00
parent ab61fd0c67
commit 571b588da7
3 changed files with 18 additions and 11 deletions

View File

@ -809,7 +809,6 @@ int main()
switch (target_mode) {
case AV1_RGBs:
phy_input_sel = PHY_AV1;
target_input = TVP_INPUT1;
target_format = FORMAT_RGBS;
target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV;
@ -817,7 +816,6 @@ int main()
target_pcm = PCM_INPUT4;
break;
case AV1_RGsB:
phy_input_sel = PHY_AV1;
target_input = TVP_INPUT1;
target_format = FORMAT_RGsB;
target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV;
@ -825,7 +823,6 @@ int main()
target_pcm = PCM_INPUT4;
break;
case AV1_YPBPR:
phy_input_sel = PHY_AV1;
target_input = TVP_INPUT1;
target_format = FORMAT_YPbPr;
target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV;
@ -833,7 +830,6 @@ int main()
target_pcm = PCM_INPUT4;
break;
case AV2_YPBPR:
phy_input_sel = PHY_AV2;
target_input = TVP_INPUT1;
target_format = FORMAT_YPbPr;
target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV;
@ -841,7 +837,6 @@ int main()
target_pcm = PCM_INPUT3;
break;
case AV2_RGsB:
phy_input_sel = PHY_AV2;
target_input = TVP_INPUT1;
target_format = FORMAT_RGsB;
target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV;
@ -849,7 +844,6 @@ int main()
target_pcm = PCM_INPUT3;
break;
case AV3_RGBHV:
phy_input_sel = PHY_AV3;
target_input = TVP_INPUT3;
target_format = FORMAT_RGBHV;
target_typemask = VIDEO_PC;
@ -857,7 +851,6 @@ int main()
target_pcm = PCM_INPUT2;
break;
case AV3_RGBs:
phy_input_sel = PHY_AV3;
target_input = TVP_INPUT3;
target_format = FORMAT_RGBS;
target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV;
@ -865,7 +858,6 @@ int main()
target_pcm = PCM_INPUT2;
break;
case AV3_RGsB:
phy_input_sel = PHY_AV3;
target_input = TVP_INPUT3;
target_format = FORMAT_RGsB;
target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV;
@ -873,7 +865,6 @@ int main()
target_pcm = PCM_INPUT2;
break;
case AV3_YPBPR:
phy_input_sel = PHY_AV3;
target_input = TVP_INPUT3;
target_format = FORMAT_YPbPr;
target_typemask = VIDEO_LDTV|VIDEO_SDTV|VIDEO_EDTV|VIDEO_HDTV;
@ -887,6 +878,8 @@ int main()
if (target_mode != AV_KEEP) {
printf("### SWITCH MODE TO %s ###\n", avinput_str[target_mode]);
phy_input_sel = avinput_to_phyinput[target_mode];
// The input changed, so load the appropriate profile
if (profile_sel != input_profiles[phy_input_sel]) {
profile_sel = input_profiles[phy_input_sel];

View File

@ -78,9 +78,24 @@ typedef enum {
typedef enum {
PHY_AV1 = 0,
PHY_AV2 = 1,
PHY_AV3 = 2
PHY_AV3 = 2,
PHY_INVALID = 3
} phyinput_t;
static phyinput_t avinput_to_phyinput[] = {
[AV_KEEP] = PHY_INVALID,
[AV1_RGBs] = PHY_AV1,
[AV1_RGsB] = PHY_AV1,
[AV1_YPBPR] = PHY_AV1,
[AV2_YPBPR] = PHY_AV2,
[AV2_RGsB] = PHY_AV2,
[AV3_RGBHV] = PHY_AV3,
[AV3_RGBs] = PHY_AV3,
[AV3_RGsB] = PHY_AV3,
[AV3_YPBPR] = PHY_AV3,
[AV_LAST] = PHY_INVALID
};
// In reverse order of importance
typedef enum {
NO_CHANGE = 0,

View File

@ -29,7 +29,6 @@ extern avmode_t cm;
extern avconfig_t tc;
extern mode_data_t video_modes[];
extern avinput_t target_mode;
extern phyinput_t phy_input_sel;
extern alt_u8 update_cur_vm;
extern alt_u8 input_profiles[3];
extern alt_u8 profile_sel;