[MPlayer-cvslog] r24362 - in trunk: mpcommon.c stream/tv.h stream/tvi_vbi.c

voroshil subversion at mplayerhq.hu
Sat Sep 8 05:06:23 CEST 2007


Author: voroshil
Date: Sat Sep  8 05:06:23 2007
New Revision: 24362

Log:
Decrease teletext page rendering frequency from 1/frame to about 4/sec.



Modified:
   trunk/mpcommon.c
   trunk/stream/tv.h
   trunk/stream/tvi_vbi.c

Modified: trunk/mpcommon.c
==============================================================================
--- trunk/mpcommon.c	(original)
+++ trunk/mpcommon.c	Sat Sep  8 05:06:23 2007
@@ -146,8 +146,17 @@ void update_teletext(sh_video_t *sh_vide
 {
 #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 @@ void update_teletext(sh_video_t *sh_vide
     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
 }

Modified: trunk/stream/tv.h
==============================================================================
--- trunk/stream/tv.h	(original)
+++ trunk/stream/tv.h	Sat Sep  8 05:06:23 2007
@@ -198,6 +198,9 @@ typedef struct {
 #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

Modified: trunk/stream/tvi_vbi.c
==============================================================================
--- trunk/stream/tvi_vbi.c	(original)
+++ trunk/stream/tvi_vbi.c	Sat Sep  8 05:06:23 2007
@@ -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 @@ typedef struct {
     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 @@ int teletext_control(void* p, int cmd, v
 
     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 @@ int teletext_control(void* p, int cmd, v
                 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 @@ int teletext_control(void* p, int cmd, v
         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 @@ int teletext_control(void* p, int cmd, v
         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 @@ int teletext_control(void* p, int cmd, v
             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 @@ int teletext_control(void* p, int cmd, v
             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 @@ int teletext_control(void* p, int cmd, v
         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 @@ int teletext_control(void* p, int cmd, v
         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 @@ int teletext_control(void* p, int cmd, v
             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 @@ int teletext_control(void* p, int cmd, v
         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 @@ int teletext_control(void* p, int cmd, v
     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;
 }



More information about the MPlayer-cvslog mailing list