[MPlayer-dev-eng] [PATCH] stream_dvd: include audio and sub track type.

Nicolas George nicolas.george at normalesup.org
Sun Jul 8 16:01:05 CEST 2012


The code_extension field from libdvdread has a little information
about the track contents: commentary, for children, etc.

On most DVDs, this field is just left to 0.
---
 help/help_mp-en.h   |    4 ++--
 stream/stream_dvd.c |   22 +++++++++++++++++++++-
 2 files changed, 23 insertions(+), 3 deletions(-)


Not tested much: most the DVD I tried have 0 in all fields.


diff --git a/help/help_mp-en.h b/help/help_mp-en.h
index 4d8a864..7ee77a6 100644
--- a/help/help_mp-en.h
+++ b/help/help_mp-en.h
@@ -1976,11 +1976,11 @@ static const char help_text[]=
 #define MSGTR_DVDnoVOBs "Cannot open title VOBS (VTS_%02d_1.VOB).\n"
 #define MSGTR_DVDnoMatchingAudio "No matching DVD audio language found!\n"
 #define MSGTR_DVDaudioChannel "Selected DVD audio channel: %d language: %c%c\n"
-#define MSGTR_DVDaudioStreamInfo "audio stream: %d format: %s (%s) language: %s aid: %d.\n"
+#define MSGTR_DVDaudioStreamInfo "audio stream: %d format: %s (%s) language: %s aid: %d (%s).\n"
 #define MSGTR_DVDnumAudioChannels "number of audio channels on disk: %d.\n"
 #define MSGTR_DVDnoMatchingSubtitle "No matching DVD subtitle language found!\n"
 #define MSGTR_DVDsubtitleChannel "Selected DVD subtitle channel: %d language: %c%c\n"
-#define MSGTR_DVDsubtitleLanguage "subtitle ( sid ): %d language: %s\n"
+#define MSGTR_DVDsubtitleLanguage "subtitle ( sid ): %d language: %s (%s)\n"
 #define MSGTR_DVDnumSubtitles "number of subtitles on disk: %d\n"
 
 // stream_bluray.c
diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c
index c9cddc1..a4bab5d 100644
--- a/stream/stream_dvd.c
+++ b/stream/stream_dvd.c
@@ -43,6 +43,10 @@
 #include "stream_dvd_common.h"
 #include "libmpdemux/demuxer.h"
 
+static const char *const dvd_audio_stream_subtype[] = {
+    "generic", "normal", "impaired", "comments", "comments (bis)",
+};
+
 static char* dvd_device_current;
 int dvd_angle=1;
 
@@ -930,6 +934,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
             audio_attr_t * audio = &vts_file->vtsi_mat->vts_audio_attr[i];
             int language = 0;
             char tmp[] = "unknown";
+            char *subtype = "unknown";
             stream_language_t *audio_stream = &d->audio_streams[d->nr_of_channels];
 
             if(audio->lang_type == 1) {
@@ -938,6 +943,8 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
               tmp[1]=language&0xff;
               tmp[2]=0;
             }
+            if (audio->code_extension < 5)
+                subtype = dvd_audio_stream_subtype[audio->code_extension];
 
             audio_stream->language=language;
             audio_stream->id=pgc->audio_control[i] >> 8 & 7;
@@ -967,11 +974,13 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
              dvd_audio_stream_types[ audio->audio_format ],
              dvd_audio_stream_channels[ audio->channels ],
              tmp,
-             audio_stream->id
+             audio_stream->id,
+             subtype
            );
            mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_ID=%d\n", audio_stream->id);
            if(language && tmp[0])
              mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_LANG=%s\n", audio_stream->id, tmp);
+           mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_SUBTYPE=%s\n", audio_stream->id, subtype);
 
            d->nr_of_channels++;
          }
@@ -992,6 +1001,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
         video_attr_t *video = &vts_file->vtsi_mat->vts_video_attr;
         int language = 0;
         char tmp[] = "unknown";
+        char subtype[64] = "unknown";
         stream_language_t *sub_stream = &d->subtitles[d->nr_of_subtitles];
 
         if(subtitle->type == 1) {
@@ -1000,6 +1010,15 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
           tmp[1]=language&0xff;
           tmp[2]=0;
         }
+        if (subtitle->code_extension < 16) {
+            static const char *const high[] =
+                { "normal", "closed captions", "forced", "commentary" };
+            static const char *const low[] =
+                { "undefined", "content", "large", "children" };
+            snprintf(subtype, sizeof(subtype), "%s, %s",
+                high[subtitle->code_extension >> 2],
+                low [subtitle->code_extension &  3]);
+        }
 
         sub_stream->language=language;
         sub_stream->id=d->nr_of_subtitles;
@@ -1012,6 +1031,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
         mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", sub_stream->id);
         if(language && tmp[0])
           mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_LANG=%s\n", sub_stream->id, tmp);
+        mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_SUBTYPE=%s\n", sub_stream->id, subtype);
         d->nr_of_subtitles++;
       }
       mp_msg(MSGT_OPEN,MSGL_STATUS,MSGTR_DVDnumSubtitles,d->nr_of_subtitles);
-- 
1.7.10



More information about the MPlayer-dev-eng mailing list