changeset 21193:a067e7e18b50

support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
author ben
date Sat, 25 Nov 2006 11:20:02 +0000
parents 1bcff3db7a7c
children e85426c3beb4
files libvo/sub.c libvo/sub.h mplayer.c stream/stream_dvdnav.c
diffstat 4 files changed, 92 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/sub.c	Sat Nov 25 09:53:28 2006 +0000
+++ b/libvo/sub.c	Sat Nov 25 11:20:02 2006 +0000
@@ -8,6 +8,11 @@
 #include <malloc.h>
 #endif
 
+#ifdef USE_DVDNAV
+#include <dvdnav.h>
+#define OSD_NAV_BOX_ALPHA 0x7f
+#endif
+
 #include "mp_msg.h"
 #include "help_mp.h"
 #include "video_out.h"
@@ -192,6 +197,24 @@
         }
 }
 
+#ifdef USE_DVDNAV
+inline static void vo_update_nav (mp_osd_obj_t *obj, int dxs, int dys) {
+  extern dvdnav_highlight_event_t dvd_nav_hl;
+  int len;
+
+  obj->bbox.x1 = obj->x = dvd_nav_hl.sx;
+  obj->bbox.y1 = obj->y = dvd_nav_hl.sy;
+  obj->bbox.x2 = dvd_nav_hl.ex;
+  obj->bbox.y2 = dvd_nav_hl.ey;
+  
+  alloc_buf (obj);
+  len = obj->stride * (obj->bbox.y2 - obj->bbox.y1);
+  memset (obj->bitmap_buffer, OSD_NAV_BOX_ALPHA, len);
+  memset (obj->alpha_buffer, OSD_NAV_BOX_ALPHA, len);
+  obj->flags |= OSDFLAG_BBOX | OSDFLAG_VISIBLE | OSDFLAG_CHANGED;
+}
+#endif
+
 int vo_osd_progbar_type=-1;
 int vo_osd_progbar_value=100;   // 0..256
 
@@ -817,6 +840,11 @@
         int vis=obj->flags&OSDFLAG_VISIBLE;
 	obj->flags&=~OSDFLAG_BBOX;
 	switch(obj->type){
+#ifdef USE_DVDNAV
+        case OSDTYPE_DVDNAV:
+           vo_update_nav(obj,dxs,dys);
+           break;
+#endif
 	case OSDTYPE_SUBTITLE:
 	    vo_update_text_sub(obj,dxs,dys);
 	    break;
@@ -884,6 +912,9 @@
     new_osd_obj(OSDTYPE_SUBTITLE);
     new_osd_obj(OSDTYPE_PROGBAR);
     new_osd_obj(OSDTYPE_SPU);
+#ifdef USE_DVDNAV
+    new_osd_obj(OSDTYPE_DVDNAV);
+#endif
 #ifdef HAVE_FREETYPE
     force_load_font = 1;
 #endif
@@ -919,6 +950,9 @@
 	case OSDTYPE_SPU:
 	    vo_draw_spudec_sub(obj, draw_alpha); // FIXME
 	    break;
+#ifdef USE_DVDNAV
+        case OSDTYPE_DVDNAV:
+#endif
 	case OSDTYPE_OSD:
 	case OSDTYPE_SUBTITLE:
 	case OSDTYPE_PROGBAR:
--- a/libvo/sub.h	Sat Nov 25 09:53:28 2006 +0000
+++ b/libvo/sub.h	Sat Nov 25 11:20:02 2006 +0000
@@ -10,6 +10,7 @@
 #define OSDTYPE_SUBTITLE 2
 #define OSDTYPE_PROGBAR 3
 #define OSDTYPE_SPU 4
+#define OSDTYPE_DVDNAV 5
 
 #define OSDFLAG_VISIBLE 1
 #define OSDFLAG_CHANGED 2
--- a/mplayer.c	Sat Nov 25 09:53:28 2006 +0000
+++ b/mplayer.c	Sat Nov 25 11:20:02 2006 +0000
@@ -4696,6 +4696,15 @@
 
 } // end if(sh_video)
 
+#ifdef USE_DVDNAV
+ if (stream->type == STREAMTYPE_DVDNAV) {
+   extern int dvd_nav_hl_on;
+
+   if (dvd_nav_hl_on)
+     vo_osd_changed (OSDTYPE_DVDNAV);
+ }
+#endif
+ 
 //============================ Handle PAUSE ===============================
 
   current_module="pause";
--- a/stream/stream_dvdnav.c	Sat Nov 25 09:53:28 2006 +0000
+++ b/stream/stream_dvdnav.c	Sat Nov 25 11:20:02 2006 +0000
@@ -11,6 +11,7 @@
 #include "libmpdemux/demuxer.h"
 #include "stream_dvdnav.h"
 #include "libvo/video_out.h"
+#include "libavutil/common.h"
 #include "spudec.h"
 #include "m_option.h"
 #include "m_struct.h"
@@ -53,6 +54,8 @@
 int osd_show_dvd_nav_sy;
 int osd_show_dvd_nav_ey;
 int dvd_nav_still=0;            /* are we on a still picture? */
+dvdnav_highlight_event_t dvd_nav_hl;
+int dvd_nav_hl_on = 0;
 
 static int seek(stream_t *s, off_t newpos);
 
@@ -108,6 +111,46 @@
   return priv;
 }
 
+static void dvdnav_get_highlight (dvdnav_priv_t *priv,
+                                  dvdnav_highlight_event_t *hlev,
+                                  int display_mode) {
+  pci_t *pnavpci = NULL;
+  int btnum = -1;
+  
+  if (!priv || !priv->dvdnav || !hlev)
+    return;
+
+  pnavpci = dvdnav_get_current_nav_pci (priv->dvdnav);
+  if (!pnavpci)
+    return;
+  
+  dvdnav_get_current_highlight (priv->dvdnav, &(hlev->buttonN));
+  hlev->display = display_mode; /* show */
+  
+  if (hlev->buttonN > 0 && pnavpci->hli.hl_gi.btn_ns > 0 && hlev->display) {
+    for (btnum = 0; btnum < pnavpci->hli.hl_gi.btn_ns; btnum++) {
+      btni_t *btni = &(pnavpci->hli.btnit[btnum]);
+
+      if (hlev->buttonN == btnum + 1) {
+        hlev->sx = FFMIN (btni->x_start, btni->x_end);
+        hlev->ex = FFMAX (btni->x_start, btni->x_end);
+        hlev->sy = FFMIN (btni->y_start, btni->y_end);
+        hlev->ey = FFMAX (btni->y_start, btni->y_end);
+
+        hlev->palette = (btni->btn_coln == 0) ? 0 :
+          pnavpci->hli.btn_colit.btn_coli[btni->btn_coln - 1][0];
+        dvd_nav_hl_on = 1;
+        break;
+      }
+    }
+  } else { /* hide button or no button */
+    hlev->sx = hlev->ex = 0;
+    hlev->sy = hlev->ey = 0;
+    hlev->palette = hlev->buttonN = 0;
+    dvd_nav_hl_on = 0;
+  }
+}
+
 static int dvdnav_stream_read(dvdnav_priv_t * priv, unsigned char *buf, int *len) {
   int event = DVDNAV_NOP;
 
@@ -137,6 +180,10 @@
 
         break;
       }
+      case DVDNAV_HIGHLIGHT: {
+        dvdnav_get_highlight (priv, &dvd_nav_hl, 1);
+        break;
+      }
       case DVDNAV_CELL_CHANGE: {
         dvdnav_cell_change_event_t *ev =  (dvdnav_cell_change_event_t*)buf;
         if(ev->pgc_length)
@@ -222,6 +269,7 @@
           update_title_len(s);
           if(dvdnav_current_title_info(priv->dvdnav, &tit, &part) == DVDNAV_STATUS_OK) {
             mp_msg(MSGT_CPLAYER,MSGL_V, "\r\nDVDNAV, NEW TITLE %d\r\n", tit);
+            dvdnav_get_highlight (priv, &dvd_nav_hl, 0);
             if(priv->title > 0 && tit != priv->title)
               return 0;
           }