changeset 24342:8873c972c6aa

Decrease teletext page rendering frequency from 1/frame to about 4/sec.
author voroshil
date Sat, 08 Sep 2007 03:06:23 +0000
parents 23e69a6846ee
children bf37d4ba4b65
files mpcommon.c stream/tv.h stream/tvi_vbi.c
diffstat 3 files changed, 37 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mpcommon.c	Fri Sep 07 19:36:14 2007 +0000
+++ b/mpcommon.c	Sat Sep 08 03:06:23 2007 +0000
@@ -146,8 +146,17 @@
 {
 #ifdef HAVE_TV_TELETEXT
     tvi_handle_t* tvh=demuxer->priv;
+    int page_changed;
+
     if (demuxer->type != DEMUXER_TYPE_TV || !tvh) return;
 
+    //Also forcing page update when such ioctl is not supported or call error occured
+    if(tvh->functions->control(tvh->priv,TV_VBI_CONTROL_IS_CHANGED,&page_changed)!=TVI_CONTROL_TRUE)
+        page_changed=1;
+
+    if(!page_changed)
+        return;
+
     if(tvh->functions->control(tvh->priv,TV_VBI_CONTROL_GET_VBIPAGE,&vo_osd_teletext_page)!=TVI_CONTROL_TRUE)
         vo_osd_teletext_page=NULL;
     if(tvh->functions->control(tvh->priv,TV_VBI_CONTROL_GET_HALF_PAGE,&vo_osd_teletext_half)!=TVI_CONTROL_TRUE)
@@ -157,5 +166,7 @@
     if(tvh->functions->control(tvh->priv,TV_VBI_CONTROL_GET_FORMAT,&vo_osd_teletext_format)!=TVI_CONTROL_TRUE)
         vo_osd_teletext_format=0;
     vo_osd_changed(OSDTYPE_TELETEXT);
+
+    tvh->functions->control(tvh->priv,TV_VBI_CONTROL_MARK_UNCHANGED,NULL);
 #endif
 }
--- a/stream/tv.h	Fri Sep 07 19:36:14 2007 +0000
+++ b/stream/tv.h	Sat Sep 08 03:06:23 2007 +0000
@@ -198,6 +198,9 @@
 #define TV_VBI_CONTROL_GET_HALF_PAGE   0x51c   ///< get current half page
 #define TV_VBI_CONTROL_SET_HALF_PAGE   0x51d   ///< switch half page
 
+#define TV_VBI_CONTROL_IS_CHANGED      0x540   ///< teletext page is changed
+#define TV_VBI_CONTROL_MARK_UNCHANGED  0x541   ///< teletext page is changed
+
 #define TV_VBI_CONTROL_ADD_DEC         0x550   ///< add page number with dec
 #define TV_VBI_CONTROL_GO_LINK         0x551   ///< go link (1..6) NYI
 #define TV_VBI_CONTROL_GET_VBIPAGE     0x552   ///< get vbi_image for grabbed teletext page
--- a/stream/tvi_vbi.c	Fri Sep 07 19:36:14 2007 +0000
+++ b/stream/tvi_vbi.c	Sat Sep 08 03:06:23 2007 +0000
@@ -96,6 +96,7 @@
 #include "libmpcodecs/img_format.h"
 #include "libavutil/common.h"
 #include "input/input.h"
+#include "osdep/timer.h"
 
 //#define DEBUG_DUMP 1
 
@@ -150,6 +151,8 @@
     unsigned int  universaltime;
     unsigned char networkname[21];
     int           cache_reset;
+    /// "page changed" flag: 0-unchanged, 1-entire page, 3-only header
+    int           page_changed;
 } priv_vbi_t;
 
 static unsigned char fixParity[256];
@@ -1635,7 +1638,7 @@
 
     if (!priv && cmd!=TV_VBI_CONTROL_START)
         return TVI_CONTROL_FALSE;
-    if (!arg && cmd!=TV_VBI_CONTROL_STOP)
+    if (!arg && cmd!=TV_VBI_CONTROL_STOP && cmd!=TV_VBI_CONTROL_MARK_UNCHANGED)
         return TVI_CONTROL_FALSE;
 
     switch (cmd) {
@@ -1669,6 +1672,7 @@
                 priv->primary_language=tt_languages[i].lang_code;
             }
         }
+        priv->page_changed=1;
         pthread_mutex_unlock(&(priv->buffer_mutex));
         return TVI_CONTROL_TRUE;
     }
@@ -1696,6 +1700,7 @@
         init_cache(priv);
         init_vbi_consts(priv);
         pll_reset(priv,fine_tune);
+        priv->page_changed=1;
         return TVI_CONTROL_TRUE;
     }
     case TV_VBI_CONTROL_STOP:
@@ -1705,16 +1710,19 @@
         if(priv->ptsp)
             free(priv->ptsp);
         destroy_cache(priv);
+        priv->page_changed=1;
         free(priv);
         return TVI_CONTROL_TRUE;
     }
     case TV_VBI_CONTROL_SET_MODE:
         priv->on=(*(int*)arg%2);
+        priv->page_changed=1;
         return TVI_CONTROL_TRUE;
     case TV_VBI_CONTROL_GET_MODE:
         *(int*)arg=priv->on;
         return TVI_CONTROL_TRUE;
     case TV_VBI_CONTROL_SET_FORMAT:
+        priv->page_changed=1;
         return teletext_set_format(priv, *(int *) arg);
     case TV_VBI_CONTROL_GET_FORMAT:
         pthread_mutex_lock(&(priv->buffer_mutex));
@@ -1734,6 +1742,7 @@
             val+=3;
         pthread_mutex_lock(&(priv->buffer_mutex));
         priv->zoom=val;
+        priv->page_changed=1;
         pthread_mutex_unlock(&(priv->buffer_mutex));
         return TVI_CONTROL_TRUE;
     }
@@ -1756,6 +1765,7 @@
             priv->subpagenum=pgc->links[val-1].subpagenum;
         else
             priv->subpagenum=get_subpagenum_from_cache(priv,priv->pagenum);
+        priv->page_changed=1;
         pthread_mutex_unlock(&(priv->buffer_mutex));
         return TVI_CONTROL_TRUE;
     }
@@ -1768,6 +1778,7 @@
         priv->pagenum=val&0x7ff;
         priv->subpagenum=get_subpagenum_from_cache(priv,priv->pagenum);
         priv->pagenumdec=0;
+        priv->page_changed=1;
         pthread_mutex_unlock(&(priv->buffer_mutex));
         return TVI_CONTROL_TRUE;
     }
@@ -1778,6 +1789,7 @@
         priv->pagenum=steppage(priv->pagenum, direction,1);
         priv->subpagenum=get_subpagenum_from_cache(priv,priv->pagenum);
         priv->pagenumdec=0;
+        priv->page_changed=1;
         pthread_mutex_unlock(&(priv->buffer_mutex));
         return TVI_CONTROL_TRUE;
     }
@@ -1792,6 +1804,7 @@
             priv->subpagenum=0x3f7f;
         if(priv->subpagenum>=VBI_MAX_SUBPAGES)
             priv->subpagenum=VBI_MAX_SUBPAGES-1;
+        priv->page_changed=1;
         pthread_mutex_unlock(&(priv->buffer_mutex));
         return TVI_CONTROL_TRUE;
     case TV_VBI_CONTROL_GET_SUBPAGE:
@@ -1799,6 +1812,7 @@
         return TVI_CONTROL_TRUE;
     case TV_VBI_CONTROL_ADD_DEC:
         vbi_add_dec(priv, *(char **) arg);
+        priv->page_changed=1;
         return TVI_CONTROL_TRUE;
     case TV_VBI_CONTROL_DECODE_PAGE:
         vbi_decode(priv,*(unsigned char**)arg);
@@ -1812,6 +1826,14 @@
     case TV_VBI_CONTROL_GET_NETWORKNAME:
         *(void **)arg=priv->networkname;
         return TVI_CONTROL_TRUE;
+    case TV_VBI_CONTROL_MARK_UNCHANGED:
+        priv->page_changed=0;
+        return TVI_CONTROL_TRUE;
+    case TV_VBI_CONTROL_IS_CHANGED:
+        if((GetTimerMS()/250)%2)  //forcing page update every 1/4 sec
+            priv->page_changed=3; //mark that header update is enough
+        *(int*)arg=priv->page_changed;
+        return TVI_CONTROL_TRUE;
     }
     return TVI_CONTROL_UNKNOWN;
 }