[MPlayer-cvslog] r29875 - in trunk: DOCS/man/en/mplayer.1 libmpcodecs/dec_teletext.c libmpcodecs/dec_teletext.h mpcommon.c

reimar subversion at mplayerhq.hu
Tue Nov 10 12:31:47 CET 2009


Author: reimar
Date: Tue Nov 10 12:31:47 2009
New Revision: 29875

Log:
Add support for DVB teletext.
Patch by Francesco Lavra [francescolavra interfree it] with modifications by me.

Modified:
   trunk/libmpcodecs/dec_teletext.c
   trunk/libmpcodecs/dec_teletext.h
   trunk/mpcommon.c

Changes in other areas also in this revision:
Modified:
   trunk/DOCS/man/en/mplayer.1

Modified: trunk/libmpcodecs/dec_teletext.c
==============================================================================
--- trunk/libmpcodecs/dec_teletext.c	Tue Nov 10 12:26:03 2009	(r29874)
+++ trunk/libmpcodecs/dec_teletext.c	Tue Nov 10 12:31:47 2009	(r29875)
@@ -1537,6 +1537,29 @@ static void vbi_decode(priv_vbi_t* priv,
 
 }
 
+/**
+ * \brief decodes a vbi line from a DVB teletext stream
+ * \param priv private data structure
+ * \param buf buffer with DVB teletext data
+ *
+ * No locking is done since this is only called from a single-threaded context
+ */
+static void vbi_decode_dvb(priv_vbi_t *priv, const uint8_t buf[44]){
+    int i;
+    uint8_t data[42];
+
+    mp_msg(MSGT_TELETEXT,MSGL_DBG3, "vbi: vbi_decode_dvb\n");
+
+    /* Reverse bit order, skipping the first two bytes (field parity, line
+       offset and framing code). */
+    for (i = 0; i < sizeof(data); i++)
+        data[i] = av_reverse[buf[2 + i]];
+
+    vbi_decode_line(priv, data);
+    if (priv->cache_reset)
+        priv->cache_reset--;
+}
+
 /*
 ---------------------------------------------------------------------------------
     Public routines
@@ -1846,6 +1869,9 @@ int teletext_control(void* p, int cmd, v
     case TV_VBI_CONTROL_DECODE_PAGE:
         vbi_decode(priv,*(unsigned char**)arg);
         return VBI_CONTROL_TRUE;
+    case TV_VBI_CONTROL_DECODE_DVB:
+        vbi_decode_dvb(priv, arg);
+        return VBI_CONTROL_TRUE;
     case TV_VBI_CONTROL_GET_VBIPAGE:
         if(!priv->on)
             return VBI_CONTROL_FALSE;

Modified: trunk/libmpcodecs/dec_teletext.h
==============================================================================
--- trunk/libmpcodecs/dec_teletext.h	Tue Nov 10 12:26:03 2009	(r29874)
+++ trunk/libmpcodecs/dec_teletext.h	Tue Nov 10 12:31:47 2009	(r29875)
@@ -69,6 +69,7 @@ int teletext_control(void* p, int cmd, v
 #define TV_VBI_CONTROL_STOP            0x555   ///< vbi stop
 #define TV_VBI_CONTROL_DECODE_PAGE     0x556   ///< decode vbi page
 #define TV_VBI_CONTROL_GET_NETWORKNAME 0x557   ///< get current network name
+#define TV_VBI_CONTROL_DECODE_DVB      0x558   ///< decode DVB teletext
 
 #define VBI_TFORMAT_TEXT    0               ///< text mode
 #define VBI_TFORMAT_BW      1               ///< black&white mode

Modified: trunk/mpcommon.c
==============================================================================
--- trunk/mpcommon.c	Tue Nov 10 12:26:03 2009	(r29874)
+++ trunk/mpcommon.c	Tue Nov 10 12:31:47 2009	(r29875)
@@ -141,9 +141,15 @@ void update_subtitles(sh_video_t *sh_vid
 
         if (spudec_changed(vo_spudec))
             vo_osd_changed(OSDTYPE_SPU);
-    } else if (dvdsub_id >= 0 && (type == 't' || type == 'm' || type == 'a')) {
+    } else if (dvdsub_id >= 0 && (type == 't' || type == 'm' || type == 'a' || type == 'd')) {
         double curpts = refpts + sub_delay;
         double endpts;
+        if (type == 'd' && !d_dvdsub->demuxer->teletext) {
+            tt_stream_props tsp = {0};
+            void *ptr = &tsp;
+            if (teletext_control(NULL, TV_VBI_CONTROL_START, &ptr) == VBI_CONTROL_TRUE)
+                d_dvdsub->demuxer->teletext = ptr;
+        }
         if (d_dvdsub->non_interleaved)
             ds_get_next_pts(d_dvdsub);
         while (d_dvdsub->first) {
@@ -157,6 +163,22 @@ void update_subtitles(sh_video_t *sh_vid
                 len = FFMIN(len - 2, AV_RB16(packet));
                 packet += 2;
             }
+            if (type == 'd') {
+                if (d_dvdsub->demuxer->teletext) {
+                    uint8_t *p = packet;
+                    p++;
+                    len--;
+                    while (len >= 46) {
+                        int sublen = p[1];
+                        if (p[0] == 2 || p[0] == 3)
+                            teletext_control(d_dvdsub->demuxer->teletext,
+                                TV_VBI_CONTROL_DECODE_DVB, p + 2);
+                        p   += sublen + 2;
+                        len -= sublen + 2;
+                    }
+                }
+                continue;
+            }
 #ifdef CONFIG_ASS
             if (ass_enabled) {
                 sh_sub_t* sh = d_dvdsub->sh;


More information about the MPlayer-cvslog mailing list