[libdvbpsi-devel] [PATCH 2/2] dvbinfo : make a separate function for obtaining a description of the AAC profile value

Daniel Kamil Kozar dkk089 at gmail.com
Tue Mar 17 23:09:49 CET 2015


---
 examples/dvbinfo/libdvbpsi.c | 147 ++++++++++++++++++++++++-------------------
 1 file changed, 83 insertions(+), 64 deletions(-)

diff --git a/examples/dvbinfo/libdvbpsi.c b/examples/dvbinfo/libdvbpsi.c
index 714d143..e44294e 100644
--- a/examples/dvbinfo/libdvbpsi.c
+++ b/examples/dvbinfo/libdvbpsi.c
@@ -1252,6 +1252,86 @@ static void DumpSubtitleDescriptor(const void *p_descriptor)
     }
 }
 
+static const char *AACProfileToString(dvbpsi_aac_profile_and_level_t profile)
+{
+    switch(profile)
+    {
+    /* 0x00-0x0E Reserved */
+    case DVBPSI_AAC_PROFILE_NOT_DEFINED:
+        return "No audio profile and level defined for the associated MPEG-4 "
+            "audio stream";
+    
+    case DVBPSI_AAC_PROFILE_MAIN_LEVEL_1: return "Main profile, level 1";
+    case DVBPSI_AAC_PROFILE_MAIN_LEVEL_2: return "Main profile, level 2";
+    case DVBPSI_AAC_PROFILE_MAIN_LEVEL_3: return "Main profile, level 3";
+    case DVBPSI_AAC_PROFILE_MAIN_LEVEL_4: return "Main profile, level 4";
+    /* 0x14-0x17 Reserved */
+    case DVBPSI_AAC_PROFILE_SCALABLE_LEVEL_1: return "Scalable Profile, level 1";
+    case DVBPSI_AAC_PROFILE_SCALABLE_LEVEL_2: return "Scalable Profile, level 2";
+    case DVBPSI_AAC_PROFILE_SCALABLE_LEVEL_3: return "Scalable Profile, level 3";
+    case DVBPSI_AAC_PROFILE_SCALABLE_LEVEL_4: return "Scalable Profile, level 4";
+    /* 0x1C-0x1F Reserved */
+    case DVBPSI_AAC_PROFILE_SPEECH_LEVEL_1: return "Speech profile, level 1";
+    case DVBPSI_AAC_PROFILE_SPEECH_LEVEL_2: return "Speech profile, level 2";
+    /* 0x22-0x27 Reserved */
+    case DVBPSI_AAC_PROFILE_SYNTHESIS_LEVEL_1: return "Synthesis profile, level 1";
+    case DVBPSI_AAC_PROFILE_SYNTHESIS_LEVEL_2: return "Synthesis profile, level 2";
+    case DVBPSI_AAC_PROFILE_SYNTHESIS_LEVEL_3: return "Synthesis profile, level 3";
+    /* 0x2B-0x2F Reserved */
+    case DVBPSI_AAC_PROFILE_HQ_LEVEL_1: return "High quality audio profile, level 1";
+    case DVBPSI_AAC_PROFILE_HQ_LEVEL_2: return "High quality audio profile, level 2";
+    case DVBPSI_AAC_PROFILE_HQ_LEVEL_3: return "High quality audio profile, level 3";
+    case DVBPSI_AAC_PROFILE_HQ_LEVEL_4: return "High quality audio profile, level 4";
+    case DVBPSI_AAC_PROFILE_HQ_LEVEL_5: return "High quality audio profile, level 5";
+    case DVBPSI_AAC_PROFILE_HQ_LEVEL_6: return "High quality audio profile, level 6";
+    case DVBPSI_AAC_PROFILE_HQ_LEVEL_7: return "High quality audio profile, level 7";
+    case DVBPSI_AAC_PROFILE_HQ_LEVEL_8: return "High quality audio profile, level 8";
+
+    case DVBPSI_AAC_PROFILE_LOW_DELAY_LEVEL_1: return "Low delay audio profile, level 1";
+    case DVBPSI_AAC_PROFILE_LOW_DELAY_LEVEL_2: return "Low delay audio profile, level 2";
+    case DVBPSI_AAC_PROFILE_LOW_DELAY_LEVEL_3: return "Low delay audio profile, level 3";
+    case DVBPSI_AAC_PROFILE_LOW_DELAY_LEVEL_4: return "Low delay audio profile, level 4";
+    case DVBPSI_AAC_PROFILE_LOW_DELAY_LEVEL_5: return "Low delay audio profile, level 5";
+    case DVBPSI_AAC_PROFILE_LOW_DELAY_LEVEL_6: return "Low delay audio profile, level 6";
+    case DVBPSI_AAC_PROFILE_LOW_DELAY_LEVEL_7: return "Low delay audio profile, level 7";
+    case DVBPSI_AAC_PROFILE_LOW_DELAY_LEVEL_8: return "Low delay audio profile, level 8";
+
+    case DVBPSI_AAC_PROFILE_NATURAL_LEVEL_1: return "Natural audio profile, level 1";
+    case DVBPSI_AAC_PROFILE_NATURAL_LEVEL_2: return "Natural audio profile, level 2";
+    case DVBPSI_AAC_PROFILE_NATURAL_LEVEL_3: return "Natural audio profile, level 3";
+    case DVBPSI_AAC_PROFILE_NATURAL_LEVEL_4: return "Natural audio profile, level 4";
+    /* 0x44-0x47 Reserved */
+    case DVBPSI_AAC_PROFILE_MOBILE_LEVEL_1: return "Mobile audio internetworking profile, level 1";
+    case DVBPSI_AAC_PROFILE_MOBILE_LEVEL_2: return "Mobile audio internetworking profile, level 2";
+    case DVBPSI_AAC_PROFILE_MOBILE_LEVEL_3: return "Mobile audio internetworking profile, level 3";
+    case DVBPSI_AAC_PROFILE_MOBILE_LEVEL_4: return "Mobile audio internetworking profile, level 4";
+    case DVBPSI_AAC_PROFILE_MOBILE_LEVEL_5: return "Mobile audio internetworking profile, level 5";
+    case DVBPSI_AAC_PROFILE_MOBILE_LEVEL_6: return "Mobile audio internetworking profile, level 6";
+    /* 0x4E-0x4F Reserved */
+    case DVBPSI_AAC_PROFILE_LEVEL_1: return "AAC profile, level 1";
+    case DVBPSI_AAC_PROFILE_LEVEL_2: return "AAC profile, level 2";
+    case DVBPSI_AAC_PROFILE_LEVEL_4: return "AAC profile, level 4";
+    case DVBPSI_AAC_PROFILE_LEVEL_5: return "AAC profile, level 5";
+    /* 0x54-0x57 RESERVED */
+    case DVBPSI_HE_AAC_PROFILE_LEVEL_2: return "High efficiency AAC profile, level 2";
+    case DVBPSI_HE_AAC_PROFILE_LEVEL_3: return "High efficiency AAC profile, level 3";
+    case DVBPSI_HE_AAC_PROFILE_LEVEL_4: return "High efficiency AAC profile, level 4";
+    case DVBPSI_HE_AAC_PROFILE_LEVEL_5: return "High efficiency AAC profile, level 5";
+    /* 0x5C-0x5F RESERVED */
+    case DVBPSI_HE_AAC_V2_PROFILE_LEVEL_2: return "High efficiency AAC v2 profile, level 2";
+    case DVBPSI_HE_AAC_V2_PROFILE_LEVEL_3: return "High efficiency AAC v2 profile, level 3";
+    case DVBPSI_HE_AAC_V2_PROFILE_LEVEL_4: return "High efficiency AAC v2 profile, level 4";
+    case DVBPSI_HE_AAC_V2_PROFILE_LEVEL_5: return "High efficiency AAC v2 profile, level 5";
+    /* 0x64-0xFE RESERVED */
+    case DVBPSI_AAC_PROFILE_NOT_SPECIFIED:
+        return "Audio profile and level not specified by the "
+            "MPEG-4_audio_profile_and_level field in this descriptor";
+    /* RESERVED */
+    case DVBPSI_AAC_PROFILE_RESERVED:
+    default: return "reserved";
+    }
+}
+
 /*****************************************************************************
  * DumpAACDescriptor
  *****************************************************************************/
@@ -1259,70 +1339,9 @@ static void DumpAACDescriptor(const void *p_descriptor)
 {
     const dvbpsi_aac_dr_t *p_aac_descriptor = p_descriptor;
     printf("AAC audio descriptor\n");
-    printf("\tprofile and level: ");
-    switch(p_aac_descriptor->i_profile_and_level)
-    {
-        /* 0x00-0x0F Reserved */
-    case DVBPSI_AAC_PROFILE_MAIN_LEVEL_1: printf("Main profile, level 1\n"); break;
-    case DVBPSI_AAC_PROFILE_MAIN_LEVEL_2: printf("Main profile, level 2\n"); break;
-    case DVBPSI_AAC_PROFILE_MAIN_LEVEL_3: printf("Main profile, level 3\n"); break;
-    case DVBPSI_AAC_PROFILE_MAIN_LEVEL_4: printf("Main profile, level 4\n"); break;
-        /* 0x14-0x17 Reserved */
-    case DVBPSI_AAC_PROFILE_SCALABLE_LEVEL_1: printf("Scalable Profile, level 1\n"); break;
-    case DVBPSI_AAC_PROFILE_SCALABLE_LEVEL_2: printf("Scalable Profile, level 2\n"); break;
-    case DVBPSI_AAC_PROFILE_SCALABLE_LEVEL_3: printf("Scalable Profile, level 3\n"); break;
-    case DVBPSI_AAC_PROFILE_SCALABLE_LEVEL_4: printf("Scalable Profile, level 4\n"); break;
-        /* 0x1C-0x1F Reserved */
-    case DVBPSI_AAC_PROFILE_SPEECH_LEVEL_1: printf("Speech profile, level 1\n"); break;
-    case DVBPSI_AAC_PROFILE_SPEECH_LEVEL_2: printf("Speech profile, level 2\n"); break;
-        /* 0x22-0x27 Reserved */
-    case DVBPSI_AAC_PROFILE_SYNTHESIS_LEVEL_1: printf("Synthesis profile, level 1\n"); break;
-    case DVBPSI_AAC_PROFILE_SYNTHESIS_LEVEL_2: printf("Synthesis profile, level 2\n"); break;
-    case DVBPSI_AAC_PROFILE_SYNTHESIS_LEVEL_3: printf("Synthesis profile, level 3\n"); break;
-        /* 0x2B-0x2F Reserved */
-    case DVBPSI_AAC_PROFILE_HQ_LEVEL_1: printf("High quality audio profile, level 1\n"); break;
-    case DVBPSI_AAC_PROFILE_HQ_LEVEL_2: printf("High quality audio profile, level 2\n"); break;
-    case DVBPSI_AAC_PROFILE_HQ_LEVEL_3: printf("High quality audio profile, level 3\n"); break;
-    case DVBPSI_AAC_PROFILE_HQ_LEVEL_4: printf("High quality audio profile, level 4\n"); break;
-    case DVBPSI_AAC_PROFILE_HQ_LEVEL_5: printf("High quality audio profile, level 5\n"); break;
-    case DVBPSI_AAC_PROFILE_HQ_LEVEL_6: printf("High quality audio profile, level 6\n"); break;
-    case DVBPSI_AAC_PROFILE_HQ_LEVEL_7: printf("High quality audio profile, level 7\n"); break;
-    case DVBPSI_AAC_PROFILE_HQ_LEVEL_8: printf("High quality audio profile, level 8\n"); break;
-
-    case DVBPSI_AAC_PROFILE_LOW_DELAY_LEVEL_1: printf("Low delay audio profile, level 1\n"); break;
-    case DVBPSI_AAC_PROFILE_LOW_DELAY_LEVEL_2: printf("Low delay audio profile, level 2\n"); break;
-    case DVBPSI_AAC_PROFILE_LOW_DELAY_LEVEL_3: printf("Low delay audio profile, level 3\n"); break;
-    case DVBPSI_AAC_PROFILE_LOW_DELAY_LEVEL_4: printf("Low delay audio profile, level 4\n"); break;
-    case DVBPSI_AAC_PROFILE_LOW_DELAY_LEVEL_5: printf("Low delay audio profile, level 5\n"); break;
-    case DVBPSI_AAC_PROFILE_LOW_DELAY_LEVEL_6: printf("Low delay audio profile, level 6\n"); break;
-    case DVBPSI_AAC_PROFILE_LOW_DELAY_LEVEL_7: printf("Low delay audio profile, level 7\n"); break;
-    case DVBPSI_AAC_PROFILE_LOW_DELAY_LEVEL_8: printf("Low delay audio profile, level 8\n"); break;
-
-    case DVBPSI_AAC_PROFILE_NATURAL_LEVEL_1: printf("Natural audio profile, level 1\n"); break;
-    case DVBPSI_AAC_PROFILE_NATURAL_LEVEL_2: printf("Natural audio profile, level 2\n"); break;
-    case DVBPSI_AAC_PROFILE_NATURAL_LEVEL_3: printf("Natural audio profile, level 3\n"); break;
-    case DVBPSI_AAC_PROFILE_NATURAL_LEVEL_4: printf("Natural audio profile, level 4\n"); break;
-        /* 0x44-0x47 Reserved */
-    case DVBPSI_AAC_PROFILE_MOBILE_LEVEL_1: printf("Mobile audio internetworking profile, level 1\n"); break;
-    case DVBPSI_AAC_PROFILE_MOBILE_LEVEL_2: printf("Mobile audio internetworking profile, level 2\n"); break;
-    case DVBPSI_AAC_PROFILE_MOBILE_LEVEL_3: printf("Mobile audio internetworking profile, level 3\n"); break;
-    case DVBPSI_AAC_PROFILE_MOBILE_LEVEL_4: printf("Mobile audio internetworking profile, level 4\n"); break;
-    case DVBPSI_AAC_PROFILE_MOBILE_LEVEL_5: printf("Mobile audio internetworking profile, level 5\n"); break;
-    case DVBPSI_AAC_PROFILE_MOBILE_LEVEL_6: printf("Mobile audio internetworking profile, level 6\n"); break;
-        /* 0x4E-0x4F Reserved */
-    case DVBPSI_AAC_PROFILE_LEVEL_1: printf("AAC profile, level 1\n"); break;
-    case DVBPSI_AAC_PROFILE_LEVEL_2: printf("AAC profile, level 2\n"); break;
-    case DVBPSI_AAC_PROFILE_LEVEL_4: printf("AAC profile, level 4\n"); break;
-    case DVBPSI_AAC_PROFILE_LEVEL_5: printf("AAC profile, level 5\n"); break;
-        /* 0x54-0x57 RESERVED */
-    case DVBPSI_HE_AAC_PROFILE_LEVEL_2: printf("High efficiency AAC profile, level 2\n"); break;
-    case DVBPSI_HE_AAC_PROFILE_LEVEL_3: printf("High efficiency AAC profile, level 3\n"); break;
-    case DVBPSI_HE_AAC_PROFILE_LEVEL_4: printf("High efficiency AAC profile, level 4\n"); break;
-    case DVBPSI_HE_AAC_PROFILE_LEVEL_5: printf("High efficiency AAC profile, level 5\n"); break;
-        /* RESERVED */
-    case DVBPSI_AAC_PROFILE_RESERVED:
-    default: printf("reserved\n"); break;
-    }
+    printf("\tprofile and level: %s (0x%02x)\n",
+        AACProfileToString(p_aac_descriptor->i_profile_and_level),
+        p_aac_descriptor->i_profile_and_level);
 
     if (p_aac_descriptor->b_type)
     {
-- 
2.3.3



More information about the libdvbpsi-devel mailing list