OSDN Git Service

stop using trunk or dist directory in rec10 project.
[rec10/rec10-git.git] / tstools / epgdump / eit.c
index 4409434..bbd21cb 100755 (executable)
@@ -1,3 +1,6 @@
+// -*- tab-width:4 -*-
+// see TR-B14 4-296 (p.318)
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -5,18 +8,11 @@
 #include "eit.h"
 
 char           *subtitle_cnv_str[] = {
-//     "¡¡Âè",
-//     "¡¼Âè",
-//     "-Âè",
-//     " Âè",
-//     "¡¡¡Ö",
-//     "¡¡¡ô",
-//     "¡Ê",
-//     "¡Ö",
        NULL
 };
 static void timecmp(int *,int *,int *,
                                        int, int, int);
+void append_desc(EIT_CONTROL* eittop, int service_id, int event_id, EEVTDitem* eevtitem);
 
 int parseEIThead(unsigned char *data, EIThead *h) {
        int boff = 0;
@@ -62,7 +58,7 @@ int parseEITbody(unsigned char *data, EITbody *b)
        b->free_CA_mode = getBit(data, &boff, 1);
        b->descriptors_loop_length = getBit(data, &boff, 12);
 
-       /* ÆüÉÕÊÑ´¹ */
+       /* 日付変換 */
        tnum = (b->start_time[0] & 0xFF) << 8 | (b->start_time[1] & 0xFF);
   
        b->yy = (tnum - 15078.2) / 365.25;
@@ -96,14 +92,14 @@ int parseEITbody(unsigned char *data, EITbody *b)
                b->dhh = b->dhm = b->dss = 0;
        }else{
                memset(buf, '\0', sizeof(buf));
-       sprintf(buf, "%x", b->duration[0]);
-       b->dhh = atoi(buf);
+               sprintf(buf, "%x", b->duration[0]);
+               b->dhh = atoi(buf);
                memset(buf, '\0', sizeof(buf));
-       sprintf(buf, "%x", b->duration[1]);
-       b->dhm = atoi(buf);
+               sprintf(buf, "%x", b->duration[1]);
+               b->dhm = atoi(buf);
                memset(buf, '\0', sizeof(buf));
-       sprintf(buf, "%x", b->duration[2]);
-       b->dss = atoi(buf);
+               sprintf(buf, "%x", b->duration[2]);
+               b->dss = atoi(buf);
        }
        return 12;
 }
@@ -139,8 +135,12 @@ int parseContentDesc(unsigned char *data, ContentDesc *desc) {
                return -1;
        }
        desc->descriptor_length = getBit(data, &boff, 8);
-       memcpy(desc->content, data+(boff/8), desc->descriptor_length);
-       //getStr(desc->content, data, &boff, desc->descriptor_length);
+       //memcpy(desc->content, data+(boff/8), desc->descriptor_length);
+       // FIXME: 1つ目のコンテント記述子のみパース
+       desc->content_nibble_level_1 = getBit(data, &boff, 4);
+       desc->content_nibble_level_2 = getBit(data, &boff, 4);
+       desc->user_nibble_1 = getBit(data, &boff, 4);
+       desc->user_nibble_2 = getBit(data, &boff, 4);
        return desc->descriptor_length + 2;
 }
 
@@ -170,6 +170,182 @@ int parseSeriesDesc(unsigned char *data, SeriesDesc *desc) {
        return desc->descriptor_length + 2;
 }
 
+int parseComponentDesc(unsigned char *data, ComponentDesc *desc) {
+       int boff = 0;
+  
+       memset(desc, 0, sizeof(ComponentDesc));
+
+       desc->descriptor_tag = getBit(data, &boff, 8);
+       if((desc->descriptor_tag & 0xFF) != 0x50) {
+               return -1;
+       }
+       desc->descriptor_length = getBit(data, &boff, 8);
+       desc->reserved_future_use = getBit(data, &boff, 4);
+       desc->stream_content = getBit(data, &boff, 4);
+       desc->component_type = getBit(data, &boff, 8);
+       desc->component_tag = getBit(data, &boff, 8);
+       memcpy(desc->ISO_639_language_code, data + boff / 8, 3);
+       boff += 24;
+       getStr(desc->text_char, data, &boff, desc->descriptor_length - 6);
+       return desc->descriptor_length + 2;
+}
+
+int parseAudioComponentDesc(unsigned char *data, AudioComponentDesc *desc) {
+       int boff = 0;
+  
+       memset(desc, 0, sizeof(AudioComponentDesc));
+
+       desc->descriptor_tag = getBit(data, &boff, 8);
+       if((desc->descriptor_tag & 0xFF) != 0xC4) {
+               return -1;
+       }
+       desc->descriptor_length = getBit(data, &boff, 8);
+       desc->reserved_future_use_1 = getBit(data, &boff, 4);
+       desc->stream_content = getBit(data, &boff, 4);
+       desc->component_type = getBit(data, &boff, 8);
+       desc->component_tag = getBit(data, &boff, 8);
+       desc->stream_type = getBit(data, &boff, 8);
+       desc->simulcast_group_tag = getBit(data, &boff, 8);
+       desc->ES_multi_lingual_flag = getBit(data, &boff, 1);
+       desc->main_component_flag = getBit(data, &boff, 1);
+       desc->quality_indicator = getBit(data, &boff, 2);
+       desc->sampling_rate = getBit(data, &boff, 3);
+       desc->reserved_future_use_2 = getBit(data, &boff, 1);
+       memcpy(desc->ISO_639_language_code_1, data + boff / 8, 3);
+       boff += 24;
+       memcpy(desc->ISO_639_language_code_2, data + boff / 8, 3);
+       boff += 24;
+       getStr(desc->text_char, data, &boff, desc->descriptor_length - desc->ES_multi_lingual_flag ? 12 : 9);
+       return desc->descriptor_length + 2;
+}
+
+char* parseComponentDescType(int componentDescType) {
+       static char str[MAXSECLEN];
+       memset(str, '\0', sizeof(str));
+       char *strpart;
+
+       switch (componentDescType & 0xF0) {
+       case 0x00 :
+               strpart = "映像480i ";
+               break;
+       case 0x90 :
+               strpart = "映像2160p ";
+               break;
+       case 0xA0 :
+               strpart = "映像480p ";
+               break;
+       case 0xB0 :
+               strpart = "映像1080i ";
+               break;
+       case 0xC0 :
+               strpart = "映像720p ";
+               break;
+       case 0xD0 :
+               strpart = "映像240p ";
+               break;
+       case 0xE0 :
+               strpart = "映像1080p ";
+               break;
+       default :
+               strpart = "映像不明 ";
+               break;
+       }
+       strcat(str, strpart);
+
+       switch (componentDescType & 0x0F) {
+       case 0x01 :
+               strpart = "アスペクト比4:3";
+               break;
+       case 0x02 :
+               strpart = "アスペクト比16:9 パンベクトルあり";
+               break;
+       case 0x03 :
+               strpart = "アスペクト比16:9 パンベクトルなし";
+               break;
+       case 0x04 :
+               strpart = "アスペクト比 > 16:9";
+               break;
+       default :
+               strpart = "アスペクト比不明";
+               break;
+       }
+       strcat(str, strpart);
+
+       return str;
+}
+
+char* parseAudioComponentDescType(int AudiocomponentDescType) {
+       static char str[MAXSECLEN];
+       memset(str, '\0', sizeof(str));
+       char *strpart;
+
+       switch (AudiocomponentDescType) {
+       case 0x01 :
+               strpart = "音声1/0モード(シングルモノ)";
+               break;
+       case 0x02 :
+               strpart = "音声1/0+1/0モード(デュアルモノ)";
+               break;
+       case 0x03 :
+               strpart = "音声2/0モード(ステレオ)";
+               break;
+       case 0x04 :
+               strpart = "音声2/1モード";
+               break;
+       case 0x05 :
+               strpart = "音声3/0モード";
+               break;
+       case 0x06 :
+               strpart = "音声2/2モード";
+               break;
+       case 0x07 :
+               strpart = "音声3/1モード";
+               break;
+       case 0x08 :
+               strpart = "音声3/2モード";
+               break;
+       case 0x09 :
+               strpart = "音声3/2+LFEモード(3/2.1モード)";
+               break;
+       case 0x0A :
+               strpart = "音声3/3.1モード";
+               break;
+       case 0x0B :
+               strpart = "音声2/0/0-2/0/2-0.1モード";
+               break;
+       case 0x0C :
+               strpart = "音声5/2.1モード";
+               break;
+       case 0x0D :
+               strpart = "音声3/2/2.1モード";
+               break;
+       case 0x0E :
+               strpart = "音声2/0/0-3/0/2-0.1モード";
+               break;
+       case 0x0F :
+               strpart = "音声0/2/0-3/0/2-0.1モード";
+               break;
+       case 0x10 :
+               strpart = "音声2/0/0-3/2/3-0.2モード";
+               break;
+       case 0x11 :
+               strpart = "音声3/3/3-5/2/3-3/0/0.2モード";
+               break;
+       case 0x40 :
+               strpart = "音声視覚障害者用解説";
+               break;
+       case 0x41 :
+               strpart = "音声聴覚障害者用";
+               break;
+       default :
+               strpart = "音声不明";
+               break;
+       }
+       strcat(str, strpart);
+
+       return str;
+}
+
 int parseEEVTDhead(unsigned char *data, EEVTDhead *desc) {
        int boff = 0;
   
@@ -197,11 +373,13 @@ int parseEEVTDitem(unsigned char *data, EEVTDitem *desc) {
        memset(desc, 0, sizeof(EEVTDitem));
 
        desc->item_description_length = getBit(data, &boff, 8);
+       memset(desc->item_description, 0, MAXSECLEN);
        getStr(desc->item_description, data, &boff, desc->item_description_length);
 
        desc->item_length = getBit(data, &boff, 8);
-//     memcpy(desc->item, data + (boff / 8), desc->item_length);
-       getStr(desc->item, data, &boff, desc->item_length);
+       memset(desc->item, 0, MAXSECLEN);
+       memcpy(desc->item, data + (boff / 8), desc->item_length);
+       /* getStr(desc->item, data, &boff, desc->item_length); */
 
        return desc->item_description_length + desc->item_length + 2;
 }
@@ -212,6 +390,7 @@ int parseEEVTDtail(unsigned char *data, EEVTDtail *desc) {
        memset(desc, 0, sizeof(EEVTDtail));
 
        desc->text_length = getBit(data, &boff, 8);
+       memset(desc->text, 0, MAXSECLEN);
        getStr(desc->text, data, &boff, desc->text_length);
 
        return desc->text_length + 1;
@@ -221,76 +400,44 @@ int checkEEVTDitem(EEVTDitem *save, EEVTDitem *new, int descriptor_number) {
 
        EEVTDitem swap;
        int boff = 0;
+
        if(new == NULL) {
                if(save->item_length != 0) {
                        swap = *save;
+                       memset(save->item, 0, MAXSECLEN);
                        getStr(save->item, (unsigned char*)swap.item, &boff, swap.item_length);
-
-
-                        //save->descriptor_number = descriptor_number;
-                        //*new = swap;
-                       //*save = swap;
-                        if (swap.descriptor_number==1){
-//                            printf("descriptor_num %d   typeB\n",swap.descriptor_number);
-                        }
-
                        return 1;
                } else {
-
-
-                        //printf("descriptor_num %d   typeC\n",swap.descriptor_number);
-
-
-
                        return 0;
                }
        }
 
        if(new->item_description_length == 0) {
-               /* Â³¤­ Êݸ */
+               /* 続き 保存 */
                memcpy(save->item + save->item_length, new->item, new->item_length);
                save->item_length += new->item_length;
-
-
-                if (swap.descriptor_number==1){
-                            printf("descriptor_num %d   typeD\n",swap.descriptor_number);
-                        }
-
-
                return 0;
        } else {
-               /* ¥Ö¥ì¡¼¥¯¡£save¤ò°õºþÂоݤˤ¹¤ë¡£save¤ò¥¯¥ê¥¢? */
+               /* ã\83\96ã\83¬ã\83¼ã\82¯ã\80\82saveã\82\92å\8d°å\88·å¯¾è±¡ã\81«ã\81\99ã\82\8bã\80\82saveã\82\92ã\82¯ã\83ªã\82¢? */
                if(save->item_length != 0) {
-                       /* ÂàÈòºÑ¤ß¤¬¤¢¤ê */
+                       /* 退避済みがあり */
                        swap = *save;
+                       memset(save->item, 0, MAXSECLEN);
                        getStr(save->item, (unsigned char*)swap.item, &boff, swap.item_length);
+
+                       // swap save new -> swap save new
+                       //         b   c -> ( c)    c   b
                        swap = *new;
                        *new = *save;
                        *save = swap;
                        save->descriptor_number = descriptor_number;
-                       
-
-
-
-                        if (swap.descriptor_number==1){
-                            printf("descriptor_num %d   typeE\n",swap.descriptor_number);
-                        }
-                        
-
+                       return 1;
                } else {
                        *save = *new;
                        save->descriptor_number = descriptor_number;
-
-                        if (swap.descriptor_number==1){
-                            printf("descriptor_num %d   typeF\n",swap.descriptor_number);
-                        }
-
-
                        return 0;
                }
        }
-
-       return 1;
 }
 EIT_CONTROL    *searcheit(EIT_CONTROL *top, int servid, int eventid)
 {
@@ -306,11 +453,34 @@ EIT_CONTROL       *searcheit(EIT_CONTROL *top, int servid, int eventid)
        }
        return NULL ;
 }
+char   *strstr_eucjp(const char *str, const char *search)
+{
+       char *pos ;
+       pos = (char *)str ;
+
+       while (*pos != '\0') {
+               if (*pos == *search) {
+                       if (strncmp(pos, search, strlen(search)) == 0) {
+                               return pos ;
+                       }
+               }
+               if ((unsigned char)*pos == 0x8Fu) {
+                       pos += 3 ;
+               } else if ((unsigned char)*pos >= 0x80u) {
+                       pos += 2 ;
+               } else {
+                       pos += 1 ;
+               }
+       }
+
+       return NULL ;
+}
 void   conv_title_subtitle(EIT_CONTROL *eitptr)
 {
        int             lp = 0 ;
-       size_t  addsize ;
+//     size_t  addsize ;
        char    *ptr ;
+       char    *ptr2 ;
        char    *newsubtitle ;
 
        for(lp = 0 ; subtitle_cnv_str[lp] != NULL ; lp++){
@@ -318,14 +488,25 @@ void      conv_title_subtitle(EIT_CONTROL *eitptr)
                if(ptr == NULL){
                        continue ;
                }
-               // ¥¿¥¤¥È¥ë¤¬¤Ê¤¯¤Ê¤é¤Ê¤¤¤è¤¦¤Ë
+               // タイトルがなくならないように
                if(ptr == eitptr->title){
                        continue ;
                }
+               /*
+               ptr2 = ptr ;
+               for( ; (unsigned char)*ptr2 == 0x20u ; ptr2++ );
+               for( ; (unsigned char)*ptr2 == 0xA1u && (unsigned char)*(ptr2+1) == 0xA1u ; ptr2 += 2);
+               for( ; (unsigned char)*ptr2 == 0x20u ; ptr2++ );
+               newsubtitle = calloc(1, ((strlen(ptr2) + 2) + (strlen(eitptr->subtitle) + 1)));
+               memcpy(newsubtitle, ptr2, strlen(ptr2));
+//             *(newsubtitle+strlen(ptr)) = ' ';
+               strcat(newsubtitle, "▽");
+               */
                newsubtitle = calloc(1, ((strlen(ptr) + 1) + (strlen(eitptr->subtitle) + 1)));
                memcpy(newsubtitle, ptr, strlen(ptr));
                newsubtitle[strlen(ptr)] = ' ';
-               *ptr = NULL ;
+
+               *ptr = '\0';
                strcat(newsubtitle, eitptr->subtitle);
                free(eitptr->subtitle);
                eitptr->subtitle = newsubtitle ;
@@ -407,7 +588,6 @@ void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int trans
        int loop_len = 0;
        int loop_blen = 0;
        int loop_elen = 0;
-       int str_alen = 0;
 
        int ehh, emm, ess;
 
@@ -415,24 +595,25 @@ void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int trans
        len = parseEIThead(ptr, &eith); 
 
        ptr += len;
-       loop_len = eith.section_length - (len - 3 + 4); // 3¤Ï¶¦Ḁ̈إåÀĹ 4¤ÏCRC
+       loop_len = eith.section_length - (len - 3 + 4); // 3は共通ヘッダ長 4はCRC
        while(loop_len > 0) {
-               /* Ï¢Â³¤¹¤ë³ÈÄ¥¥¤¥Ù¥ó¥È¤Ï¡¢´Á»ú¥³¡¼¥É¤¬µã¤­Ê̤줷¤Æ
-                  Ê¬³ä¤µ¤ì¤ë¤è¤¦¤À¡£Ï¢Â³¤«¤É¤¦¤«¤Ï¡¢item_description_length¤¬
-                  ÀßÄꤵ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤ÇȽÃǤǤ­¤ë¤è¤¦¤À¡£ */
+               /* 連続する拡張イベントは、漢字コードが泣き別れして
+                  分割されるようだ。連続かどうかは、item_description_lengthが
+                  設定されているかどうかで判断できるようだ。 */
                memset(&save_eevtitem, 0, sizeof(EEVTDitem));
 
                len = parseEITbody(ptr, &eitb);
                ptr += len;
                loop_len -= len;
-    
+
                /* printf("evtid:%d\n", eitb.event_id); */
-    
+
                loop_blen = eitb.descriptors_loop_length;
                loop_len -= loop_blen;
+
                while(loop_blen > 0) {
 
-/*yukikaze-test*/
+                       /*yukikaze-test*/
                        //printf("desc_tag");
                        //int itt=getBit(*ptr,0,8);
                        //printf("%x",itt);
@@ -488,10 +669,10 @@ void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int trans
                                len = parseEEVTDhead(ptr, &eevthead);
 
                                /*
-                                 if(eith.service_id == 19304 && 
-                                 eitb.event_id == 46564) {
-                                 printf("aa");
-                                 }
+                               if(eith.service_id == 19304 && 
+                               eitb.event_id == 46564) {
+                               printf("aa");
+                               }
                                */
 
                                if(len > 0) {
@@ -506,60 +687,27 @@ void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int trans
                                                ptr += len;
                                                loop_elen -= len;
                                                loop_blen -= len;
-                                                
-                                               if (1||checkEEVTDitem(&save_eevtitem, &eevtitem,
-                                                                                 eevthead.descriptor_number)) {
-#if 0
-                                                       {
-                                                            if (eevtitem.descriptor_number>0){
-                                                                //printf("descriptor_num %d\n",eevtitem.descriptor_number);
-                                                            }
-
-                                                            /* long format */
-                                                            //printf("descriptor_num %d\n",eevtitem.descriptor_number);
-#if 1
-                                                            printf("EEVT,%d,%d,%d,%s,%s\n",
-                                                                               eith.service_id,
-                                                                                       eitb.event_id,
-                                                                                       eevtitem.descriptor_number, // ÂàÈò¹àÌÜ
-                                                                               eevtitem.item_description,
-                                                                               eevtitem.item);
-#endif
 
-                                                       }
-#endif
-                                                       cur = searcheit(eittop, eith.service_id, eitb.event_id);
-                                                       if(cur == NULL){
-                                                               curtmp = NULL;
-                                                               cur = calloc(1, sizeof(EIT_CONTROL));
-                                                       }
-                                                       else {
-                                                               curtmp = cur;
-                                                       }
+                                               if(checkEEVTDitem(&save_eevtitem, &eevtitem, 
+                                                       eevthead.descriptor_number)) {
 
-#if 1
-                                                       if ( cur->desc ) {
-                                                               str_alen = strlen( cur->desc );
-                                                       }
-                                                       else {
-                                                               str_alen = 0;
-                                                       }
-                                                       eevtitem.item_description_length = strlen(eevtitem.item_description);
-                                                       eevtitem.item_length = strlen(eevtitem.item);
-                                                       cur->desc = realloc(cur->desc, str_alen + eevtitem.item_description_length + eevtitem.item_length + 1000);
-                                                       if ( !str_alen ) *cur->desc = '\0';
-
-                                                       if ( eevtitem.item_description_length && !strstr(cur->desc, eevtitem.item_description) ) {
-                                                               strcat(cur->desc, eevtitem.item_description);
-                                                               strcat(cur->desc, "\t");
+                                                       {
+                                                               if (eevtitem.descriptor_number>0){
+                                                                       //printf("descriptor_num %d\n",eevtitem.descriptor_number);
+                                                               }
+                                                               /* long format */
+                                                               //printf("descriptor_num %d\n",eevtitem.descriptor_number);
+#if 0
+                                                               printf("EEVT,%d,%d,%d,%s,%s\n",
+                                                                       eith.service_id,
+                                                                       eitb.event_id,
+                                                                       eevtitem.descriptor_number, // 退避項目
+                                                                       eevtitem.item_description,
+                                                                       eevtitem.item);
+#endif
                                                        }
+                                                       append_desc(eittop, eith.service_id, eitb.event_id, &eevtitem);
 
-                                                       if ( eevtitem.item_length && !strstr(cur->desc, eevtitem.item)  ) {
-                                                               strcat(cur->desc, eevtitem.item);
-                                                               strcat(cur->desc, "\\n");
-                                                       }
-#endif
-                                                       if ( !curtmp ) enqueue(eittop, cur);
                                                }
                                        }
 
@@ -574,77 +722,90 @@ void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int trans
                                        }
 #endif
                                } else {
-                                       ContentDesc contentDesc;
-                                       len = parseContentDesc(ptr, &contentDesc);
-                                       if (len > 0) {
-                                               int header_printed = 0;
-                                               for (int i = 0; i < contentDesc.descriptor_length - 1; i+=2) {
-                                                       /*
-                                                       if (0xff == (unsigned char)contentDesc.content[i])
-                                                               continue;
-                                                       */
-#if 0
-                                                       if (!header_printed) {
-                                                               fprintf(out, "Content,%d,%d",
-                                                                       eith.service_id,
-                                                                       eitb.event_id);
-                                                               header_printed = 1;
-                                                       }
-#endif
+                                       ContentDesc                     contentDesc;
+                                       SeriesDesc                      seriesDesc;
+                                       ComponentDesc           componentDesc;
+                                       AudioComponentDesc      audioComponentDesc;
 
-#if 0
-                                                       fprintf(out, ",%02x%02x", (unsigned char)contentDesc.content[i], (unsigned char)contentDesc.content[i+1]);
-#endif
-                                               }
-                                               if((eith.original_network_id == original_network_id) && (eith.transport_stream_id == transport_stream_id)){
-                                                       cur = searcheit(eittop, eith.service_id, eitb.event_id);
-                                                       if(cur != NULL){
-                                                               cur->content_type = (unsigned char)(contentDesc.content[0] >> 4);
-#if 0
-                                                               fprintf(stdout, "%s:", cur->title);
-                                                               fprintf(stdout, ",%02x%02x", (unsigned char)contentDesc.content[0], (unsigned char)contentDesc.content[1]);
-                                                               fprintf(stdout, ",%02x%02x\n", (unsigned char)contentDesc.content[2], (unsigned char)contentDesc.content[3]);
-#endif
+                                       if((eith.original_network_id == original_network_id) && (eith.transport_stream_id == transport_stream_id)){
+                                               cur = searcheit(eittop, eith.service_id, eitb.event_id);
+                                       }
+                                       else {
+                                               cur = NULL;
+                                       }
 
+                                       switch (*ptr) {
+                                       case 0x54 :
+                                               len = parseContentDesc(ptr, &contentDesc);
+                                               if (len > 0) {
+                                                       if(cur != NULL){
+                                                               cur->content_type = (unsigned char)contentDesc.content_nibble_level_1;
                                                        }
-#if 0
-                                                       if (header_printed) {
-                                                               fprintf(out, "\n");
-                                                       }
-#endif
                                                }
-                                       } else {
-                                               SeriesDesc seriesDesc;
+                                               break;
+                                       case 0xD5 :
                                                len = parseSeriesDesc(ptr, &seriesDesc);
                                                if (len > 0) {
-#if 0
-                                                       printf("Series,%d,%d,series=%d,repeat=%01x,pattern=%d,expire_valid=%d,expire=%04x,epinum=%d,lastepinum=%d,%s\n",
-                                                               eith.service_id,
-                                                               eitb.event_id,
-                                                               seriesDesc.series_id,
-                                                               seriesDesc.repeat_label,
-                                                               seriesDesc.program_pattern,
-                                                               seriesDesc.expire_date_valid_flag,
-                                                               seriesDesc.expire_date,
-                                                               seriesDesc.episode_number,
-                                                               seriesDesc.last_episode_number,
-                                                               seriesDesc.series_name_char);
-#endif
-                                               } else {
-                                                       len = parseOTHERdesc(ptr);
+                                                       #if 0
+                                                               printf("Series,%d,%d,series=%d,repeat=%01x,pattern=%d,expire_valid=%d,expire=%04x,epinum=%d,lastepinum=%d,%s\n",
+                                                                       eith.service_id,
+                                                                       eitb.event_id,
+                                                                       seriesDesc.series_id,
+                                                                       seriesDesc.repeat_label,
+                                                                       seriesDesc.program_pattern,
+                                                                       seriesDesc.expire_date_valid_flag,
+                                                                       seriesDesc.expire_date,
+                                                                       seriesDesc.episode_number,
+                                                                       seriesDesc.last_episode_number,
+                                                                       seriesDesc.series_name_char);
+                                                       #endif
+                                               }
+                                               break;
+                                       case 0x50 :
+                                               len = parseComponentDesc(ptr, &componentDesc);
+                                               if (len > 0) {
+                                                       if(cur != NULL){
+                                                               cur->video_type = componentDesc.component_type;
+                                                       }
+                                                       #if 0
+                                                       printf("Component,%d %d %s\n",
+                                                               componentDesc.stream_content, 
+                                                               componentDesc.component_type, 
+                                                               parseComponentDescType(componentDesc.component_type));
+                                                       #endif
                                                }
+                                               break;
+                                       case 0xC4 :
+                                               len = parseAudioComponentDesc(ptr, &audioComponentDesc);
+                                               if (len > 0) {
+                                                       if(cur != NULL){
+                                                               cur->audio_type = audioComponentDesc.component_type;
+                                                               cur->multi_type = audioComponentDesc.ES_multi_lingual_flag;
+                                                       }
+                                                       #if 0
+                                                       printf("AudioComponent,%d %d %d %s\n",
+                                                               audioComponentDesc.component_type, 
+                                                               audioComponentDesc.ES_multi_lingual_flag, 
+                                                               audioComponentDesc.sampling_rate, 
+                                                               parseAudioComponentDescType(audioComponentDesc.component_type)
+                                                               );
+                                                       #endif
+                                               }
+                                               break;
+                                       default :
+                                               len = parseOTHERdesc(ptr);
                                        }
                                }
                        }
                        ptr += len;
                        loop_blen -= len;
                }
-               /* ºÇ¸å¤Î¥Ö¥ì¡¼¥¯¥Á¥§¥Ã¥¯ */
-    
+               /* æ\9c\80å¾\8cã\81®ã\83\96ã\83¬ã\83¼ã\82¯ã\83\81ã\82§ã\83\83ã\82¯ */
+
                if(checkEEVTDitem(&save_eevtitem, NULL, 0)) {
 #if 0
-                       if(mode == 1) { /* long format */
-                               fprintf(out, "EEVT,%d,%d,%d,%s,%s\n", 
+                       { /* long format */
+                               fprintf(stdout, "EEVT,%d,%d,%d,%s,%s\n", 
                                                eith.service_id,
                                                eitb.event_id,
                                                save_eevtitem.descriptor_number,
@@ -652,12 +813,45 @@ void dumpEIT(unsigned char *ptr, int serv_id, int original_network_id, int trans
                                                save_eevtitem.item);
                        }
 #endif
+                       append_desc(eittop, eith.service_id, eitb.event_id, &save_eevtitem);
                }
        }
 
        return;
 }
 
+void append_desc(EIT_CONTROL* eittop, int service_id, int event_id, EEVTDitem* eevtitem) {
+       EIT_CONTROL *cur;
+       int str_alen = 0;
+
+       cur = searcheit(eittop, service_id, event_id);
+       if (cur == NULL) {
+               return;
+       }
+
+       if ( cur->desc ) {
+               str_alen = strlen( cur->desc );
+       }
+       else {
+               str_alen = 0;
+       }
+       //eevtitem->item_description_length = strlen(eevtitem->item_description);
+       //eevtitem->item_length = strlen(eevtitem->item);
+       cur->desc = realloc(cur->desc, str_alen + eevtitem->item_description_length + eevtitem->item_length + 1000);
+       if ( !str_alen ) *cur->desc = '\0';
+
+       if ( eevtitem->item_description_length && !strstr(cur->desc, eevtitem->item_description) ) {
+               strcat(cur->desc + str_alen, eevtitem->item_description);
+               strcat(cur->desc, "\t");
+       }
+
+       if ( eevtitem->item_length && !strstr(cur->desc, eevtitem->item) ) {
+               strcat(cur->desc + str_alen, eevtitem->item);
+       //printf("%s\n",eevtitem->item);
+               strcat(cur->desc, "\\n");
+       }
+}
+
 void timecmp(int *thh, int *tmm, int *tss,
                         int dhh, int dmm, int dss) {