# HG changeset patch # User reimar # Date 1257852707 0 # Node ID b06429c8c1048a6f401a663592698f20ee9191d5 # Parent 07a96d93694326f14d2684f6dd47d54834eb640d Add support for DVB teletext. Patch by Francesco Lavra [francescolavra interfree it] with modifications by me. diff -r 07a96d936943 -r b06429c8c104 DOCS/man/en/mplayer.1 --- a/DOCS/man/en/mplayer.1 Tue Nov 10 11:26:03 2009 +0000 +++ b/DOCS/man/en/mplayer.1 Tue Nov 10 11:31:47 2009 +0000 @@ -431,7 +431,8 @@ .RS . (The following keys are only valid if teletext support is enabled during -compilation: They are used for controlling TV teletext.) +compilation: They are used for controlling TV teletext, whose data may come +from either an analog TV source or an MPEG Transport Stream.) .RE .PP .PD 0 diff -r 07a96d936943 -r b06429c8c104 libmpcodecs/dec_teletext.c --- a/libmpcodecs/dec_teletext.c Tue Nov 10 11:26:03 2009 +0000 +++ b/libmpcodecs/dec_teletext.c Tue Nov 10 11:31:47 2009 +0000 @@ -1537,6 +1537,29 @@ } +/** + * \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 @@ 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; diff -r 07a96d936943 -r b06429c8c104 libmpcodecs/dec_teletext.h --- a/libmpcodecs/dec_teletext.h Tue Nov 10 11:26:03 2009 +0000 +++ b/libmpcodecs/dec_teletext.h Tue Nov 10 11:31:47 2009 +0000 @@ -69,6 +69,7 @@ #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 diff -r 07a96d936943 -r b06429c8c104 mpcommon.c --- a/mpcommon.c Tue Nov 10 11:26:03 2009 +0000 +++ b/mpcommon.c Tue Nov 10 11:31:47 2009 +0000 @@ -141,9 +141,15 @@ 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 @@ 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;