[libbluray-devel] commit: updated xine plugin: merged overlay support (hpi1 )

git at videolan.org git at videolan.org
Thu Nov 11 23:20:55 CET 2010


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sun Oct 24 15:32:03 2010 +0300| [f3be18be4087b4983f5d58f3795aee0007876dfa] | committer: hpi1 

updated xine plugin: merged overlay support

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=f3be18be4087b4983f5d58f3795aee0007876dfa
---

 player_wrappers/xine/input_bluray.c |   78 +++++++++++++++++++++++++++++++++++
 1 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/player_wrappers/xine/input_bluray.c b/player_wrappers/xine/input_bluray.c
index e5cada5..537312d 100644
--- a/player_wrappers/xine/input_bluray.c
+++ b/player_wrappers/xine/input_bluray.c
@@ -40,6 +40,7 @@
 #include <dlfcn.h>
 
 #include <libbluray/bluray.h>
+#include <libbluray/overlay.h>
 
 #define LOG_MODULE "input_bluray"
 #define LOG_VERBOSE
@@ -94,6 +95,8 @@ typedef struct {
   input_plugin_t        input_plugin;
 
   xine_stream_t        *stream;
+  xine_osd_t           *osd;
+
   bluray_input_class_t *class;
   char                 *mrl;
   char                 *disc_root;
@@ -104,9 +107,75 @@ typedef struct {
   int                current_title;
   BLURAY_TITLE_INFO *title_info;
   int                current_clip;
+  int                menu_open;
 
 } bluray_input_plugin_t;
 
+static void close_overlay(bluray_input_plugin_t *this)
+{
+  if (this->osd) {
+    xine_osd_free(this->osd);
+    this->osd = NULL;
+  }
+}
+
+static void overlay_proc(void *this_gen, const BD_OVERLAY * const ov)
+{
+  bluray_input_plugin_t *this = (bluray_input_plugin_t *) this_gen;
+  uint32_t color[256];
+  uint8_t  trans[256];
+  unsigned i;
+
+  if (!this) {
+    return;
+  }
+
+  if (!ov || ov->plane == 1)
+    this->menu_open = 0;
+
+  if (!ov || !ov->img) {
+    /* hide OSD */
+    close_overlay(this);
+    return;
+  }
+
+  /* open xine OSD */
+
+  if (!this->osd) {
+    this->osd = xine_osd_new(this->stream, 0, 0, 1920, 1080);
+  }
+
+  /* convert and set palette */
+
+  for(i = 0; i < 256; i++) {
+    trans[i] = ov->palette[i].T;
+    color[i] = (ov->palette[i].Y << 16) | (ov->palette[i].Cr << 8) | ov->palette[i].Cb;
+  }
+
+  xine_osd_set_palette(this->osd, color, trans);
+
+  /* uncompress and draw bitmap */
+
+  const BD_PG_RLE_ELEM *rlep = ov->img;
+  uint8_t *img = malloc(ov->w * ov->h);
+  unsigned pixels = ov->w * ov->h;
+
+  for (i = 0; i < pixels; i += rlep->len, rlep++) {
+    memset(img + i, rlep->color, rlep->len);
+  }
+
+  xine_osd_draw_bitmap(this->osd, img, ov->x, ov->y, ov->w, ov->h, NULL);
+
+  free(img);
+
+  /* display */
+
+  xine_osd_show(this->osd, 0);
+
+  if (ov->plane == 1)
+    this->menu_open = 1;
+}
+
 static void update_stream_info(bluray_input_plugin_t *this)
 {
   /* set stream info */
@@ -380,6 +449,11 @@ static void bluray_plugin_dispose (input_plugin_t *this_gen)
 {
   bluray_input_plugin_t *this = (bluray_input_plugin_t *) this_gen;
 
+  if (this->bdh)
+    bd_register_overlay_proc(this->bdh, NULL, NULL);
+
+  close_overlay(this);
+
   if (this->title_info)
     bd_free_title_info(this->title_info);
 
@@ -467,6 +541,10 @@ static int bluray_plugin_open (input_plugin_t *this_gen)
     lprintf("main title: %d (%05d.mpls)\n", title, playlist);
   }
 
+  /* register overlay (graphics) handler */
+
+  bd_register_overlay_proc(this->bdh, this, overlay_proc);
+
   /* update player settings */
   bd_set_player_setting    (this->bdh, BLURAY_PLAYER_SETTING_REGION_CODE,  this->class->region);
   bd_set_player_setting    (this->bdh, BLURAY_PLAYER_SETTING_PARENTAL,     this->class->parental);



More information about the libbluray-devel mailing list