--- dvdnav.c	2004-01-31 18:12:58.000000000 +0100
+++ dvdnav.c	2006-04-05 16:03:09.000000000 +0200
@@ -21,9 +21,13 @@
  *
  */
 
+#ifndef HAVE_MPLAYER
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+#else
+#include "config.h"
+#endif
 
 /*
 #define LOG_DEBUG
@@ -31,7 +35,27 @@
 
 #include "dvdnav_internal.h"
 #include "read_cache.h"
-#include "nav_read.h"
+#ifdef USE_MPDVDKIT
+#if (USE_MPDVDKIT == 2)
+#include "libmpdvdkit2/dvd_input.h"
+#include "libmpdvdkit2/dvd_reader.h"
+#include "libmpdvdkit2/ifo_types.h"
+#include "libmpdvdkit2/ifo_read.h"
+#include "libmpdvdkit2/nav_read.h"
+#else
+#include "libmpdvdkit/dvd_input.h"
+#include "libmpdvdkit/dvd_reader.h"
+#include "libmpdvdkit/ifo_types.h"
+#include "libmpdvdkit/ifo_read.h"
+#include "libmpdvdkit/nav_read.h"
+#endif
+#else
+#include <dvdread/dvd_input.h>
+#include <dvdread/dvd_reader.h>
+#include <dvdread/ifo_types.h>
+#include <dvdread/ifo_read.h>
+#include <dvdread/nav_read.h>
+#endif
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -39,6 +63,11 @@
 
 #include "remap.h"
 
+#ifdef USE_MPDVDNAV
+#include "../mp_msg.h"
+#include "../help_mp.h"
+#endif
+
 static dvdnav_status_t dvdnav_clear(dvdnav_t * this) {
   /* clear everything except file, vm, mutex, readahead */
 
@@ -67,7 +96,7 @@
   struct timeval time;
   
   /* Create a new structure */
-  fprintf(MSG_OUT, "libdvdnav: Using dvdnav version %s from http://dvd.sf.net\n", VERSION);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_Using, DVDNAVSVERSION);
 
   (*dest) = NULL;
   this = (dvdnav_t*)malloc(sizeof(dvdnav_t));
@@ -82,13 +111,13 @@
   /* Initialise the VM */
   this->vm = vm_new_vm();
   if(!this->vm) {
-    printerr("Error initialising the DVD VM.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_ErrorInitialisingTheDVDVM);
     pthread_mutex_destroy(&this->vm_lock);
     free(this);
     return DVDNAV_STATUS_ERR;
   }
   if(!vm_reset(this->vm, path)) {
-    printerr("Error starting the VM / opening the DVD device.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_ErrorStartingTheVM);
     pthread_mutex_destroy(&this->vm_lock);
     vm_free_vm(this->vm);
     free(this);
@@ -118,18 +147,18 @@
 dvdnav_status_t dvdnav_close(dvdnav_t *this) {
 
 #ifdef LOG_DEBUG
-  fprintf(MSG_OUT, "libdvdnav: close:called\n");
+  mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: close:called\n");
 #endif
 
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
   if (this->file) {
     DVDCloseFile(this->file);
 #ifdef LOG_DEBUG
-    fprintf(MSG_OUT, "libdvdnav: close:file closing\n");
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: close:file closing\n");
 #endif
     this->file = NULL;
   }
@@ -155,26 +184,26 @@
   dvdnav_status_t result;
 
 #ifdef LOG_DEBUG
-  fprintf(MSG_OUT, "libdvdnav: reset:called\n");
+  mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: reset:called\n");
 #endif
 
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
   pthread_mutex_lock(&this->vm_lock); 
 
 #ifdef LOG_DEBUG
-  fprintf(MSG_OUT, "libdvdnav: reseting vm\n");
+  mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: reseting vm\n");
 #endif
   if(!vm_reset(this->vm, NULL)) {
-    printerr("Error restarting the VM.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_ErrorRestartingTheVM);
     pthread_mutex_unlock(&this->vm_lock); 
     return DVDNAV_STATUS_ERR;
   }
 #ifdef LOG_DEBUG
-  fprintf(MSG_OUT, "libdvdnav: clearing dvdnav\n");
+  mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: clearing dvdnav\n");
 #endif
   result = dvdnav_clear(this);
 
@@ -185,7 +214,7 @@
 dvdnav_status_t dvdnav_path(dvdnav_t *this, const char** path) {
 
   if(!this || !path) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
@@ -258,7 +287,7 @@
 
   /* we should now have a PES packet here */
   if (p[0] || p[1] || (p[2] != 1)) {
-    fprintf(MSG_OUT, "libdvdnav: demux error! %02x %02x %02x (should be 0x000001) \n",p[0],p[1],p[2]);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_Demux_error,p[0],p[1],p[2]);
     return 0;
   }
 
@@ -271,10 +300,10 @@
   if (nStreamID == 0xbf) { /* Private stream 2 */
 #if 0
     int32_t i;
-    fprintf(MSG_OUT, "libdvdnav: nav packet=%u\n",p-p_start-6);
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: nav packet=%u\n",p-p_start-6);
     for(i=0;i<80;i++)
-      fprintf(MSG_OUT, "%02x ",p[i-6]);
-    fprintf(MSG_OUT, "\n");
+      mp_msg(MSGT_FIXME,MSGL_FIXME, "%02x ",p[i-6]);
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "\n");
 #endif
 
     if(p[0] == 0x00) {
@@ -333,7 +362,7 @@
   /* FIMXE: The angle reset doesn't work for some reason for the moment */
 #if 0
   if((num_angle < angle) && (angle != 1)) {
-    fprintf(MSG_OUT, "libdvdnav: angle ends!\n");
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: angle ends!\n");
     
     /* This is to switch back to angle one when we
      * finish with angles. */
@@ -395,7 +424,7 @@
   int32_t result;
 
   if(!this || !event || !len || !buf || !*buf) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
@@ -423,9 +452,9 @@
   vm_position_get(this->vm, &this->position_next);
   
 #ifdef LOG_DEBUG
-  fprintf(MSG_OUT, "libdvdnav: POS-NEXT ");
+  mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: POS-NEXT ");
   vm_position_print(this->vm, &this->position_next);
-  fprintf(MSG_OUT, "libdvdnav: POS-CUR  ");
+  mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: POS-CUR  ");
   vm_position_print(this->vm, &this->position_current);
 #endif
 
@@ -433,7 +462,7 @@
   if(this->position_current.hop_channel != this->position_next.hop_channel) {
     (*event) = DVDNAV_HOP_CHANNEL;
 #ifdef LOG_DEBUG
-    fprintf(MSG_OUT, "libdvdnav: HOP_CHANNEL\n");
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: HOP_CHANNEL\n");
 #endif
     if (this->position_next.hop_channel - this->position_current.hop_channel >= HOP_SEEK) {
       int32_t num_angles = 0, current;
@@ -447,13 +476,13 @@
 	block = this->position_next.cell_start + this->position_next.block;
 	result = dvdnav_read_cache_block(this->cache, block, 1, buf);
 	if(result <= 0) {
-	  printerr("Error reading NAV packet.");
+	  printerr(MSGTR_LIBMPDVDNAV_Err_ErrorReadingNAVPacket);
 	  pthread_mutex_unlock(&this->vm_lock); 
 	  return DVDNAV_STATUS_ERR;
 	}
 	/* Decode nav into pci and dsi. Then get next VOBU info. */
 	if(!dvdnav_decode_packet(this, *buf, &this->dsi, &this->pci)) {
-	  printerr("Expected NAV packet but none found.");
+	  printerr(MSGTR_LIBMPDVDNAV_Err_ExpectedNAVPacketButNoneFound);
 	  pthread_mutex_unlock(&this->vm_lock); 
 	  return DVDNAV_STATUS_ERR;
 	}
@@ -485,7 +514,7 @@
 
     (*event) = DVDNAV_HIGHLIGHT;
 #ifdef LOG_DEBUG
-    fprintf(MSG_OUT, "libdvdnav: HIGHLIGHT\n");
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: HIGHLIGHT\n");
 #endif
     (*len) = sizeof(dvdnav_highlight_event_t);
     hevent->display = 1;
@@ -499,7 +528,7 @@
   if(this->sync_wait) {
     (*event) = DVDNAV_WAIT;
 #ifdef LOG_DEBUG
-    fprintf(MSG_OUT, "libdvdnav: WAIT\n");
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: WAIT\n");
 #endif
     (*len) = 0;
     pthread_mutex_unlock(&this->vm_lock);
@@ -537,7 +566,7 @@
       vtsN = this->position_next.vts; 
       break;
     default:
-      printerr("Unknown domain when changing VTS.");
+      printerr(MSGTR_LIBMPDVDNAV_Err_UnknownDomainWhenChangingVTS);
       pthread_mutex_unlock(&this->vm_lock); 
       return DVDNAV_STATUS_ERR;
     }
@@ -551,7 +580,7 @@
 
     /* If couldn't open the file for some reason, moan */
     if(this->file == NULL) {
-      printerrf("Error opening vtsN=%i, domain=%i.", vtsN, domain);
+      snprintf(this->err_str,MAX_ERR_LEN,MSGTR_LIBMPDVDNAV_ErrorOpeningVtsDomain, vtsN, domain);
       pthread_mutex_unlock(&this->vm_lock); 
       return DVDNAV_STATUS_ERR;
     }
@@ -559,7 +588,7 @@
     /* File opened successfully so return a VTS change event */
     (*event) = DVDNAV_VTS_CHANGE;
 #ifdef LOG_DEBUG
-    fprintf(MSG_OUT, "libdvdnav: VTS_CHANGE\n");
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: VTS_CHANGE\n");
 #endif
     (*len) = sizeof(dvdnav_vts_change_event_t);
 
@@ -582,7 +611,7 @@
     
     (*event) = DVDNAV_CELL_CHANGE;
 #ifdef LOG_DEBUG
-    fprintf(MSG_OUT, "libdvdnav: CELL_CHANGE\n");
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: CELL_CHANGE\n");
 #endif
     (*len) = sizeof(dvdnav_cell_change_event_t);
     
@@ -639,7 +668,7 @@
   if(this->spu_clut_changed) {
     (*event) = DVDNAV_SPU_CLUT_CHANGE;
 #ifdef LOG_DEBUG
-    fprintf(MSG_OUT, "libdvdnav: SPU_CLUT_CHANGE\n");
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: SPU_CLUT_CHANGE\n");
 #endif
     (*len) = 16 * sizeof(uint32_t);
     memcpy(*buf, &(state->pgc->palette), 16 * sizeof(uint32_t));
@@ -654,7 +683,7 @@
 
     (*event) = DVDNAV_SPU_STREAM_CHANGE;
 #ifdef LOG_DEBUG
-    fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE\n");
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: SPU_STREAM_CHANGE\n");
 #endif
     (*len) = sizeof(dvdnav_spu_stream_change_event_t);
     stream_change->physical_wide      = vm_get_subp_active_stream(this->vm, 0);
@@ -662,15 +691,15 @@
     stream_change->physical_pan_scan  = vm_get_subp_active_stream(this->vm, 2);
     this->position_current.spu_channel = this->position_next.spu_channel;
 #ifdef LOG_DEBUG
-    fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_wide=%d\n",stream_change->physical_wide);
-    fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_letterbox=%d\n",stream_change->physical_letterbox);
-    fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE stream_id_pan_scan=%d\n",stream_change->physical_pan_scan);
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: SPU_STREAM_CHANGE stream_id_wide=%d\n",stream_change->physical_wide);
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: SPU_STREAM_CHANGE stream_id_letterbox=%d\n",stream_change->physical_letterbox);
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: SPU_STREAM_CHANGE stream_id_pan_scan=%d\n",stream_change->physical_pan_scan);
 #endif
     if (stream_change->physical_wide != -1 &&
         stream_change->physical_letterbox != -1 &&
         stream_change->physical_pan_scan != -1) {
 #ifdef LOG_DEBUG
-      fprintf(MSG_OUT, "libdvdnav: SPU_STREAM_CHANGE returning DVDNAV_STATUS_OK\n");
+      mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: SPU_STREAM_CHANGE returning DVDNAV_STATUS_OK\n");
 #endif
       pthread_mutex_unlock(&this->vm_lock); 
       return DVDNAV_STATUS_OK;
@@ -683,13 +712,13 @@
     
     (*event) = DVDNAV_AUDIO_STREAM_CHANGE;
 #ifdef LOG_DEBUG
-    fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE\n");
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: AUDIO_STREAM_CHANGE\n");
 #endif
     (*len) = sizeof(dvdnav_audio_stream_change_event_t);
     stream_change->physical = vm_get_audio_active_stream( this->vm );
     this->position_current.audio_channel = this->position_next.audio_channel;
 #ifdef LOG_DEBUG
-    fprintf(MSG_OUT, "libdvdnav: AUDIO_STREAM_CHANGE stream_id=%d returning DVDNAV_STATUS_OK\n",stream_change->physical);
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: AUDIO_STREAM_CHANGE stream_id=%d returning DVDNAV_STATUS_OK\n",stream_change->physical);
 #endif
     pthread_mutex_unlock(&this->vm_lock); 
     return DVDNAV_STATUS_OK;
@@ -701,7 +730,7 @@
 
     (*event) = DVDNAV_STILL_FRAME;
 #ifdef LOG_DEBUG
-    fprintf(MSG_OUT, "libdvdnav: STILL_FRAME\n");
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: STILL_FRAME\n");
 #endif
     (*len) = sizeof(dvdnav_still_event_t);
     still_event->length = this->position_current.still;
@@ -716,7 +745,7 @@
     if(this->vobu.vobu_next == SRI_END_OF_CELL) {
       /* End of Cell from NAV DSI info */
 #ifdef LOG_DEBUG
-      fprintf(MSG_OUT, "libdvdnav: Still set to %x\n", this->position_next.still);
+      mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: Still set to %x\n", this->position_next.still);
 #endif
       this->position_current.still = this->position_next.still;
 
@@ -754,13 +783,13 @@
     result = dvdnav_read_cache_block(this->cache, this->vobu.vobu_start + this->vobu.vobu_next, 1, buf);
 
     if(result <= 0) {
-      printerr("Error reading NAV packet.");
+      printerr(MSGTR_LIBMPDVDNAV_Err_ErrorReadingNAVPacket);
       pthread_mutex_unlock(&this->vm_lock); 
       return DVDNAV_STATUS_ERR;
     }
     /* Decode nav into pci and dsi. Then get next VOBU info. */
     if(!dvdnav_decode_packet(this, *buf, &this->dsi, &this->pci)) {
-      printerr("Expected NAV packet but none found.");
+      printerr(MSGTR_LIBMPDVDNAV_Err_ExpectedNAVPacketButNoneFound);
       pthread_mutex_unlock(&this->vm_lock); 
       return DVDNAV_STATUS_ERR;
     }
@@ -783,7 +812,7 @@
     /* Successfully got a NAV packet */
     (*event) = DVDNAV_NAV_PACKET;
 #ifdef LOG_DEBUG
-    fprintf(MSG_OUT, "libdvdnav: NAV_PACKET\n");
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: NAV_PACKET\n");
 #endif
     (*len) = 2048; 
     pthread_mutex_unlock(&this->vm_lock); 
@@ -792,7 +821,7 @@
   
   /* If we've got here, it must just be a normal block. */
   if(!this->file) {
-    printerr("Attempting to read without opening file.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_AttemptingToReadWithoutOpeningFile);
     pthread_mutex_unlock(&this->vm_lock); 
     return DVDNAV_STATUS_ERR;
   }
@@ -800,7 +829,7 @@
   this->vobu.blockN++;
   result = dvdnav_read_cache_block(this->cache, this->vobu.vobu_start + this->vobu.blockN, 1, buf);
   if(result <= 0) {
-    printerr("Error reading from DVD.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_ErrorReadingFromDVD);
     pthread_mutex_unlock(&this->vm_lock); 
     return DVDNAV_STATUS_ERR;
   }
@@ -814,7 +843,7 @@
 dvdnav_status_t dvdnav_get_title_string(dvdnav_t *this, const char **title_str) {
   
   if(!this || !title_str) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
@@ -826,11 +855,11 @@
   uint8_t         retval;
   
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return -1;
   }
   if(!this->started) {
-    printerr("Virtual DVD machine not started.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_VirtualDVDMachineNotStarted);
     return -1;
   }
 
@@ -845,11 +874,11 @@
   uint8_t         retval;
   
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return -1;
   }
   if(!this->started) {
-    printerr("Virtual DVD machine not started.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_VirtualDVDMachineNotStarted);
     return -1;
   }
   
@@ -864,11 +893,11 @@
   audio_attr_t  attr;
   
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return -1;
   }
   if(!this->started) {
-    printerr("Virtual DVD machine not started.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_VirtualDVDMachineNotStarted);
     return -1;
   }
   
@@ -886,11 +915,11 @@
   subp_attr_t  attr;
   
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return -1;
   }
   if(!this->started) {
-    printerr("Virtual DVD machine not started.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_VirtualDVDMachineNotStarted);
     return -1;
   }
   
@@ -908,17 +937,17 @@
   int8_t       retval;
   
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return -1;
   }
   if(!this->started) {
-    printerr("Virtual DVD machine not started.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_VirtualDVDMachineNotStarted);
     return -1;
   }
   
   pthread_mutex_lock(&this->vm_lock);
   if (!this->vm->state.pgc) {
-    printerr("No current PGC.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_NoCurrentPGC);
     pthread_mutex_unlock(&this->vm_lock); 
     return -1;
   }
@@ -928,21 +957,39 @@
   return retval;
 }
 
+#ifdef USE_MPDVDNAV
+dvdnav_status_t dvdnav_get_audio_attr(dvdnav_t *this, uint8_t audio_num, audio_attr_t *audio_attr) {
+  if(!this || !audio_attr) {
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
+    return DVDNAV_STATUS_ERR;
+  }
+  pthread_mutex_lock(&this->vm_lock);
+  if (!this->vm->state.pgc) {
+    printerr(MSGTR_LIBMPDVDNAV_Err_NoCurrentPGC);
+    pthread_mutex_unlock(&this->vm_lock);
+    return -1;
+  }
+  *audio_attr=vm_get_audio_attr(this->vm, audio_num);
+  pthread_mutex_unlock(&this->vm_lock);
+  return DVDNAV_STATUS_OK;
+}
+#endif
+
 int8_t dvdnav_get_spu_logical_stream(dvdnav_t *this, uint8_t subp_num) {
   int8_t       retval;
 
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return -1;
   }
   if(!this->started) {
-    printerr("Virtual DVD machine not started.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_VirtualDVDMachineNotStarted);
     return -1;
   }
 
   pthread_mutex_lock(&this->vm_lock);
   if (!this->vm->state.pgc) {
-    printerr("No current PGC.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_NoCurrentPGC);
     pthread_mutex_unlock(&this->vm_lock); 
     return -1;
   }
@@ -952,21 +999,39 @@
   return retval;
 }
 
+#ifdef USE_MPDVDNAV
+dvdnav_status_t dvdnav_get_spu_attr(dvdnav_t *this, uint8_t audio_num, subp_attr_t *subp_attr) {
+  if(!this || !subp_attr) {
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
+    return DVDNAV_STATUS_ERR;
+  }
+  pthread_mutex_lock(&this->vm_lock);
+  if (!this->vm->state.pgc) {
+    printerr(MSGTR_LIBMPDVDNAV_Err_NoCurrentPGC);
+    pthread_mutex_unlock(&this->vm_lock);
+    return -1;
+  }
+  *subp_attr=vm_get_subp_attr(this->vm, audio_num);
+  pthread_mutex_unlock(&this->vm_lock);
+  return DVDNAV_STATUS_OK;
+}
+#endif
+
 int8_t dvdnav_get_active_audio_stream(dvdnav_t *this) {
   int8_t        retval;
 
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return -1;
   }
   if(!this->started) {
-    printerr("Virtual DVD machine not started.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_VirtualDVDMachineNotStarted);
     return -1;
   }
   
   pthread_mutex_lock(&this->vm_lock); 
   if (!this->vm->state.pgc) {
-    printerr("No current PGC.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_NoCurrentPGC);
     pthread_mutex_unlock(&this->vm_lock); 
     return -1;
   }
@@ -980,17 +1045,17 @@
   int8_t        retval;
 
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return -1;
   }
   if(!this->started) {
-    printerr("Virtual DVD machine not started.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_VirtualDVDMachineNotStarted);
     return -1;
   }
   
   pthread_mutex_lock(&this->vm_lock); 
   if (!this->vm->state.pgc) {
-    printerr("No current PGC.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_NoCurrentPGC);
     pthread_mutex_unlock(&this->vm_lock); 
     return -1;
   }
@@ -1004,11 +1069,11 @@
   int8_t        retval;
   
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return -1;
   }
   if(!this->started) {
-    printerr("Virtual DVD machine not started.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_VirtualDVDMachineNotStarted);
     return -1;
   }
   
@@ -1041,7 +1106,7 @@
   int32_t num, current;
   
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
@@ -1051,7 +1116,7 @@
   if((angle > 0) && (angle <= num)) {
     this->vm->state.AGL_REG = angle;
   } else {
-    printerr("Passed an invalid angle number.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedAnInvalidAngleNumber);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
@@ -1063,7 +1128,7 @@
 dvdnav_status_t dvdnav_get_angle_info(dvdnav_t *this, int32_t *current_angle,
 				      int32_t *number_of_angles) {
   if(!this || !current_angle || !number_of_angles) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
--- dvdnav.h	2003-06-09 17:17:44.000000000 +0200
+++ dvdnav.h	2006-04-05 16:03:09.000000000 +0200
@@ -33,18 +33,30 @@
 extern "C" {
 #endif
 
-#ifdef DVDNAV_COMPILE
-#  include "dvdnav_events.h"
-#  include "dvd_types.h"
-#  include "dvd_reader.h"
-#  include "ifo_types.h" /* For vm_cmd_t */
+#ifdef USE_MPDVDKIT
+#if (USE_MPDVDKIT == 2)
+#include "libmpdvdkit2/dvd_input.h"
+#include "libmpdvdkit2/dvd_reader.h"
+#include "libmpdvdkit2/ifo_types.h"
+#include "libmpdvdkit2/ifo_read.h"
+#include "libmpdvdkit2/nav_read.h"
+#else
+#include "libmpdvdkit/dvd_input.h"
+#include "libmpdvdkit/dvd_reader.h"
+#include "libmpdvdkit/ifo_types.h"
+#include "libmpdvdkit/ifo_read.h"
+#include "libmpdvdkit/nav_read.h"
+#endif
 #else
-#  include <dvdnav/dvdnav_events.h>
-#  include <dvdnav/dvd_types.h>
-#  include <dvdnav/dvd_reader.h>
-#  include <dvdnav/ifo_types.h> /* For vm_cmd_t */
+#include <dvdread/dvd_input.h>
+#include <dvdread/dvd_reader.h>
+#include <dvdread/ifo_types.h>
+#include <dvdread/ifo_read.h>
+#include <dvdread/nav_read.h>
 #endif
 
+#include "dvdnav_events.h"
+#include "dvd_types.h"
 
 
 /*********************************************************************
@@ -228,6 +240,27 @@
  */
 dvdnav_status_t dvdnav_still_skip(dvdnav_t *self);
 
+#ifdef USE_MPDVDNAV
+/*
+ * If we are currently in a still-frame this function repeat it.
+ *
+ * See also the DVDNAV_STILL_FRAME event.
+ */
+dvdnav_status_t dvdnav_still_back(dvdnav_t *self);
+/*
+ * Clear wait flags and repeat current cell.
+ */
+dvdnav_status_t dvdnav_wait_back(dvdnav_t *self);
+/*
+ * Clear wait & still flags
+ */
+dvdnav_status_t dvdnav_wait_still_clear(dvdnav_t *self);
+/*
+ * Wheather the still event will be in the current cell?
+ */
+dvdnav_status_t dvdnav_is_still_cell(dvdnav_t *self, int *flag);
+#endif
+
 /*
  * If we are currently in WAIT state, that is: the application is required to
  * wait for its fifos to become empty, calling this signals libdvdnav that this
@@ -397,6 +430,12 @@
 dvdnav_status_t dvdnav_get_position(dvdnav_t *self, uint32_t *pos,
 				    uint32_t *len);
 
+#ifdef USE_MPDVDNAV
+/*
+ * Get current PGC number
+ */
+dvdnav_status_t dvdnav_get_pgc(dvdnav_t *self, int *pg_num);
+#endif
 
 /*********************************************************************
  * menu highlights                                                   *
@@ -436,6 +475,12 @@
  */
 dsi_t* dvdnav_get_current_nav_dsi(dvdnav_t *self);
 
+#ifdef USE_MPDVDNAV
+/*
+ * Enable & disable auto action mode
+ */
+dvdnav_status_t dvdnav_button_select_auto_action(dvdnav_t *self, int mode);
+#endif
 /*
  * Get the area associated with a certain button.
  */
@@ -558,11 +603,23 @@
  */
 int8_t dvdnav_get_audio_logical_stream(dvdnav_t *self, uint8_t audio_num);
 
+#ifdef USE_MPDVDNAV
+dvdnav_status_t dvdnav_get_audio_attr(dvdnav_t *self, uint8_t audio_mum, audio_attr_t *audio_attr);
+
+int8_t dvdnav_get_active_audio_stream(dvdnav_t *self);
+#endif
+
 /*
  * Converts a *physical* (MPEG) subpicture stream id into a logical stream number.
  */
 int8_t dvdnav_get_spu_logical_stream(dvdnav_t *self, uint8_t subp_num);
 
+#ifdef USE_MPDVDNAV
+dvdnav_status_t dvdnav_get_spu_attr(dvdnav_t *self, uint8_t audio_mum, subp_attr_t *subp_attr);
+
+int8_t dvdnav_get_active_spu_stream(dvdnav_t *self);
+#endif
+
 /*
  * Get active audio stream.
  */
--- dvdnav_events.h	2003-04-27 03:26:18.000000000 +0200
+++ dvdnav_events.h	2006-04-05 16:03:09.000000000 +0200
@@ -28,9 +28,27 @@
 #ifndef DVDNAV_EVENTS_H_INCLUDED
 #define DVDNAV_EVENTS_H_INCLUDED
 
-#include "ifo_types.h"
-#include "dvd_reader.h"
-#include "nav_types.h"
+#ifdef USE_MPDVDKIT
+#if (USE_MPDVDKIT == 2)
+#include "libmpdvdkit2/dvd_input.h"
+#include "libmpdvdkit2/dvd_reader.h"
+#include "libmpdvdkit2/ifo_types.h"
+#include "libmpdvdkit2/ifo_read.h"
+#include "libmpdvdkit2/nav_read.h"
+#else
+#include "libmpdvdkit/dvd_input.h"
+#include "libmpdvdkit/dvd_reader.h"
+#include "libmpdvdkit/ifo_types.h"
+#include "libmpdvdkit/ifo_read.h"
+#include "libmpdvdkit/nav_read.h"
+#endif
+#else
+#include <dvdread/dvd_input.h>
+#include <dvdread/dvd_reader.h>
+#include <dvdread/ifo_types.h>
+#include <dvdread/ifo_read.h>
+#include <dvdread/nav_read.h>
+#endif
 
 
 /*
--- dvdnav_internal.h	2005-12-27 23:57:39.000000000 +0100
+++ dvdnav_internal.h	2006-04-05 16:03:09.000000000 +0200
@@ -28,8 +28,6 @@
 #include "config.h"
 #endif
 
-#define TRACE
-
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -38,6 +36,8 @@
 
 #ifdef WIN32
 
+/* workaround for objidl.h */
+#undef STREAM_SEEK
 /* pthread_mutex_* wrapper for win32 */
 #include <windows.h>
 #include <process.h>
@@ -59,6 +59,7 @@
 }
 #include <io.h> /* read() */
 #define lseek64 _lseeki64
+#define STREAM_SEEK (STREAM_SEEK_BW|STREAM_SEEK_FW)
 
 #else
 
--- highlight.c	2004-01-20 02:22:24.000000000 +0100
+++ highlight.c	2006-04-05 16:03:10.000000000 +0200
@@ -21,14 +21,46 @@
  *
  */
 
+#ifndef HAVE_MPLAYER
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+#else
+#include "config.h"
+#endif
 
 #include <assert.h>
-#include "nav_types.h"
+#ifdef USE_MPDVDKIT
+#if (USE_MPDVDKIT == 2)
+#include "libmpdvdkit2/dvd_input.h"
+#include "libmpdvdkit2/dvd_reader.h"
+#include "libmpdvdkit2/ifo_types.h"
+#include "libmpdvdkit2/ifo_read.h"
+#include "libmpdvdkit2/nav_read.h"
+#else
+#include "libmpdvdkit/dvd_input.h"
+#include "libmpdvdkit/dvd_reader.h"
+#include "libmpdvdkit/ifo_types.h"
+#include "libmpdvdkit/ifo_read.h"
+#include "libmpdvdkit/nav_read.h"
+#endif
+#else
+#include <dvdread/dvd_input.h>
+#include <dvdread/dvd_reader.h>
+#include <dvdread/ifo_types.h>
+#include <dvdread/ifo_read.h>
+#include <dvdread/nav_read.h>
+#endif
 #include "dvdnav_internal.h"
 
+#ifdef USE_MPDVDNAV
+#include "../mp_msg.h"
+#include "../help_mp.h"
+#endif
+#ifdef USE_MPDVDNAV_TRACE
+extern int dvdnav_trace;
+#endif
+
 /*
 #define BUTTON_TESTING
 */
@@ -45,7 +79,7 @@
   assert((dtime->second>>4) < 0x7 && (dtime->second&0xf) < 0xa);
   assert((dtime->frame_u&0xf) < 0xa);
 
-  fprintf(MSG_OUT,"%02x:%02x:%02x.%02x",
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"%02x:%02x:%02x.%02x",
          dtime->hour,
          dtime->minute,
          dtime->second,
@@ -61,32 +95,32 @@
     rate = "(please send a bug report)";
     break;
   }
-  fprintf(MSG_OUT," @ %s fps", rate);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO," @ %s fps", rate);
 }
 
 static void nav_print_PCI_GI(pci_gi_t *pci_gi) {
   int32_t i;
 
-  fprintf(MSG_OUT,"libdvdnav: pci_gi:\n");
-  fprintf(MSG_OUT,"libdvdnav: nv_pck_lbn    0x%08x\n", pci_gi->nv_pck_lbn);
-  fprintf(MSG_OUT,"libdvdnav: vobu_cat      0x%04x\n", pci_gi->vobu_cat);
-  fprintf(MSG_OUT,"libdvdnav: vobu_uop_ctl  0x%08x\n", *(uint32_t*)&pci_gi->vobu_uop_ctl);
-  fprintf(MSG_OUT,"libdvdnav: vobu_s_ptm    0x%08x\n", pci_gi->vobu_s_ptm);
-  fprintf(MSG_OUT,"libdvdnav: vobu_e_ptm    0x%08x\n", pci_gi->vobu_e_ptm);
-  fprintf(MSG_OUT,"libdvdnav: vobu_se_e_ptm 0x%08x\n", pci_gi->vobu_se_e_ptm);
-  fprintf(MSG_OUT,"libdvdnav: e_eltm        ");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: pci_gi:\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: nv_pck_lbn    0x%08x\n", pci_gi->nv_pck_lbn);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: vobu_cat      0x%04x\n", pci_gi->vobu_cat);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: vobu_uop_ctl  0x%08x\n", *(uint32_t*)&pci_gi->vobu_uop_ctl);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: vobu_s_ptm    0x%08x\n", pci_gi->vobu_s_ptm);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: vobu_e_ptm    0x%08x\n", pci_gi->vobu_e_ptm);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: vobu_se_e_ptm 0x%08x\n", pci_gi->vobu_se_e_ptm);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: e_eltm        ");
   print_time(&pci_gi->e_eltm);
-  fprintf(MSG_OUT,"\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"\n");
 
-  fprintf(MSG_OUT,"libdvdnav: vobu_isrc     \"");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: vobu_isrc     \"");
   for(i = 0; i < 32; i++) {
     char c = pci_gi->vobu_isrc[i];
     if((c >= ' ') && (c <= '~'))
-      fprintf(MSG_OUT,"%c", c);
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,"%c", c);
     else
-      fprintf(MSG_OUT,".");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,".");
   }
-  fprintf(MSG_OUT,"\"\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"\"\n");
 }
 
 static void nav_print_NSML_AGLI(nsml_agli_t *nsml_agli) {
@@ -97,10 +131,10 @@
   if(j == 0)
     return;
 
-  fprintf(MSG_OUT,"libdvdnav: nsml_agli:\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: nsml_agli:\n");
   for(i = 0; i < 9; i++)
     if(nsml_agli->nsml_agl_dsta[i])
-      fprintf(MSG_OUT,"libdvdnav: nsml_agl_c%d_dsta  0x%08x\n", i + 1,
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: nsml_agl_c%d_dsta  0x%08x\n", i + 1,
              nsml_agli->nsml_agl_dsta[i]);
 }
 
@@ -109,24 +143,24 @@
   if((hl_gi->hli_ss & 0x03) == 0)
     return;
 
-  fprintf(MSG_OUT,"libdvdnav: hl_gi:\n");
-  fprintf(MSG_OUT,"libdvdnav: hli_ss        0x%01x\n", hl_gi->hli_ss & 0x03);
-  fprintf(MSG_OUT,"libdvdnav: hli_s_ptm     0x%08x\n", hl_gi->hli_s_ptm);
-  fprintf(MSG_OUT,"libdvdnav: hli_e_ptm     0x%08x\n", hl_gi->hli_e_ptm);
-  fprintf(MSG_OUT,"libdvdnav: btn_se_e_ptm  0x%08x\n", hl_gi->btn_se_e_ptm);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: hl_gi:\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: hli_ss        0x%01x\n", hl_gi->hli_ss & 0x03);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: hli_s_ptm     0x%08x\n", hl_gi->hli_s_ptm);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: hli_e_ptm     0x%08x\n", hl_gi->hli_e_ptm);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: btn_se_e_ptm  0x%08x\n", hl_gi->btn_se_e_ptm);
 
   *btngr_ns = hl_gi->btngr_ns;
-  fprintf(MSG_OUT,"libdvdnav: btngr_ns      %d\n",  hl_gi->btngr_ns);
-  fprintf(MSG_OUT,"libdvdnav: btngr%d_dsp_ty    0x%02x\n", 1, hl_gi->btngr1_dsp_ty);
-  fprintf(MSG_OUT,"libdvdnav: btngr%d_dsp_ty    0x%02x\n", 2, hl_gi->btngr2_dsp_ty);
-  fprintf(MSG_OUT,"libdvdnav: btngr%d_dsp_ty    0x%02x\n", 3, hl_gi->btngr3_dsp_ty);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: btngr_ns      %d\n",  hl_gi->btngr_ns);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: btngr%d_dsp_ty    0x%02x\n", 1, hl_gi->btngr1_dsp_ty);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: btngr%d_dsp_ty    0x%02x\n", 2, hl_gi->btngr2_dsp_ty);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: btngr%d_dsp_ty    0x%02x\n", 3, hl_gi->btngr3_dsp_ty);
 
-  fprintf(MSG_OUT,"libdvdnav: btn_ofn       %d\n", hl_gi->btn_ofn);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: btn_ofn       %d\n", hl_gi->btn_ofn);
   *btn_ns = hl_gi->btn_ns;
-  fprintf(MSG_OUT,"libdvdnav: btn_ns        %d\n", hl_gi->btn_ns);
-  fprintf(MSG_OUT,"libdvdnav: nsl_btn_ns    %d\n", hl_gi->nsl_btn_ns);
-  fprintf(MSG_OUT,"libdvdnav: fosl_btnn     %d\n", hl_gi->fosl_btnn);
-  fprintf(MSG_OUT,"libdvdnav: foac_btnn     %d\n", hl_gi->foac_btnn);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: btn_ns        %d\n", hl_gi->btn_ns);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: nsl_btn_ns    %d\n", hl_gi->nsl_btn_ns);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: fosl_btnn     %d\n", hl_gi->fosl_btnn);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: foac_btnn     %d\n", hl_gi->foac_btnn);
 }
 
 static void nav_print_BTN_COLIT(btn_colit_t *btn_colit) {
@@ -138,10 +172,10 @@
   if(j == 0)
     return;
 
-  fprintf(MSG_OUT,"libdvdnav: btn_colit:\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: btn_colit:\n");
   for(i = 0; i < 3; i++)
     for(j = 0; j < 2; j++)
-      fprintf(MSG_OUT,"libdvdnav: btn_cqoli %d  %s_coli:  %08x\n",
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: btn_cqoli %d  %s_coli:  %08x\n",
              i, (j == 0) ? "sl" : "ac",
              btn_colit->btn_coli[i][j]);
 }
@@ -149,9 +183,9 @@
 static void nav_print_BTNIT(btni_t *btni_table, int32_t btngr_ns, int32_t btn_ns) {
   int32_t i, j, k;
 
-  fprintf(MSG_OUT,"libdvdnav: btnit:\n");
-  fprintf(MSG_OUT,"libdvdnav: btngr_ns: %i\n", btngr_ns);
-  fprintf(MSG_OUT,"libdvdnav: btn_ns: %i\n", btn_ns);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: btnit:\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: btngr_ns: %i\n", btngr_ns);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: btn_ns: %i\n", btn_ns);
 
   if(btngr_ns == 0)
     return;
@@ -161,24 +195,24 @@
       if(j < btn_ns) {
         btni_t *btni = &btni_table[(36 / btngr_ns) * i + j];
 
-        fprintf(MSG_OUT,"libdvdnav: group %d btni %d:  ", i+1, j+1);
-        fprintf(MSG_OUT,"btn_coln %d, auto_action_mode %d\n",
+        mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: group %d btni %d:  ", i+1, j+1);
+        mp_msg(MSGT_CPLAYER,MSGL_INFO,"btn_coln %d, auto_action_mode %d\n",
                btni->btn_coln, btni->auto_action_mode);
-        fprintf(MSG_OUT,"libdvdnav: coords   (%d, %d) .. (%d, %d)\n",
+        mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: coords   (%d, %d) .. (%d, %d)\n",
                btni->x_start, btni->y_start, btni->x_end, btni->y_end);
 
-        fprintf(MSG_OUT,"libdvdnav: up %d, ", btni->up);
-        fprintf(MSG_OUT,"down %d, ", btni->down);
-        fprintf(MSG_OUT,"left %d, ", btni->left);
-        fprintf(MSG_OUT,"right %d\n", btni->right);
+        mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: up %d, ", btni->up);
+        mp_msg(MSGT_CPLAYER,MSGL_INFO,"down %d, ", btni->down);
+        mp_msg(MSGT_CPLAYER,MSGL_INFO,"left %d, ", btni->left);
+        mp_msg(MSGT_CPLAYER,MSGL_INFO,"right %d\n", btni->right);
         for(k = 0; k < 8; k++) {
-          fprintf(MSG_OUT, "libdvdnav: %02x ", btni->cmd.bytes[k]);
+          mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: %02x ", btni->cmd.bytes[k]);
         }
-        fprintf(MSG_OUT, "| ");
-#ifdef TRACE
-        vm_print_mnemonic(&btni->cmd);
+        mp_msg(MSGT_CPLAYER,MSGL_INFO,, "| ");
+#ifdef USE_MPDVDNAV_TRACE
+        if (dvdnav_trace) vm_print_mnemonic(&btni->cmd);
 #endif
-        fprintf(MSG_OUT, "\n");
+        mp_msg(MSGT_CPLAYER,MSGL_INFO,"\n");
       }
     }
   }
@@ -187,14 +221,14 @@
 static void nav_print_HLI(hli_t *hli) {
   int32_t btngr_ns = 0, btn_ns = 0;
 
-  fprintf(MSG_OUT,"libdvdnav: hli:\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: hli:\n");
   nav_print_HL_GI(&hli->hl_gi, & btngr_ns, & btn_ns);
   nav_print_BTN_COLIT(&hli->btn_colit);
   nav_print_BTNIT(hli->btnit, btngr_ns, btn_ns);
 }
 
 void nav_print_PCI(pci_t *pci) {
-  fprintf(MSG_OUT,"libdvdnav: pci packet:\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: pci packet:\n");
   nav_print_PCI_GI(&pci->pci_gi);
   nav_print_NSML_AGLI(&pci->nsml_agli);
   nav_print_HLI(&pci->hli);
@@ -208,7 +242,7 @@
 dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *this, int32_t *button) {
   
   if(!this || !button) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
@@ -223,15 +257,15 @@
   int32_t button = 0;
 
   if(!this || !pci) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return NULL;
   }
   if(!pci->hli.hl_gi.hli_ss) {
-    printerr("Not in a menu.");
+    mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_NotInAMenu);
     return NULL;
   }
   if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) {
-    printerr("This NAV has already been left.");
+    mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_ThisNAVHasAlreadyBeenLeft);
     return NULL;
   }
 
@@ -244,6 +278,9 @@
 }
 
 static dvdnav_status_t button_auto_action(dvdnav_t *this, pci_t *pci) {
+#ifdef USE_MPDVDNAV
+  if (this->vm->auto_action_mode) return DVDNAV_STATUS_OK;
+#endif
   if (get_current_button(this, pci)->auto_action_mode)
     return dvdnav_button_activate(this, pci);
   return DVDNAV_STATUS_OK;
@@ -294,7 +331,7 @@
   btni_t *button_ptr;
 
 #ifdef BUTTON_TESTING
-  fprintf(MSG_OUT, "libdvdnav: Button get_highlight_area %i\n", button);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: Button get_highlight_area %i\n", button);
 #endif
   
   if(!nav_pci->hli.hl_gi.hli_ss)
@@ -317,7 +354,7 @@
   highlight->pts = nav_pci->hli.hl_gi.hli_s_ptm;
   highlight->buttonN = button;
 #ifdef BUTTON_TESTING
-  fprintf(MSG_OUT, "libdvdnav: highlight: Highlight area is (%u,%u)-(%u,%u), display = %i, button = %u\n",
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: highlight: Highlight area is (%u,%u)-(%u,%u), display = %i, button = %u\n",
                button_ptr->x_start, button_ptr->y_start,
                button_ptr->x_end, button_ptr->y_end,
                1,
@@ -332,15 +369,15 @@
   btni_t *button_ptr = NULL;
 
   if(!this || !pci) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
   if(!pci->hli.hl_gi.hli_ss) {
-    printerr("Not in a menu.");
+    mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_NotInAMenu);
     return DVDNAV_STATUS_ERR;
   }
   if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) {
-    printerr("This NAV has already been left.");
+    mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_ThisNAVHasAlreadyBeenLeft);
     return DVDNAV_STATUS_ERR;
   }
   pthread_mutex_lock(&this->vm_lock); 
@@ -376,7 +413,7 @@
   /* Finally, make the VM execute the appropriate code and probably
    * scedule a jump */
 #ifdef BUTTON_TESTING
-  fprintf(MSG_OUT, "libdvdnav: Evaluating Button Activation commands.\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: Evaluating Button Activation commands.\n");
 #endif
   if(vm_exec_cmd(this->vm, &(button_ptr->cmd)) == 1) {
     /* Command caused a jump */
@@ -392,7 +429,7 @@
 dvdnav_status_t dvdnav_button_activate_cmd(dvdnav_t *this, int32_t button, vm_cmd_t *cmd)
 {
   if(!this || !cmd) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
   
@@ -400,7 +437,7 @@
   /* make the VM execute the appropriate code and probably
    * schedule a jump */
 #ifdef BUTTON_TESTING
-  fprintf(MSG_OUT, "libdvdnav: dvdnav_button_activate_cmd: Evaluating Button Activation commands.\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: dvdnav_button_activate_cmd: Evaluating Button Activation commands.\n");
 #endif
   if(button > 0) {
     this->vm->state.HL_BTNN_REG = (button << 10);
@@ -419,24 +456,24 @@
 dvdnav_status_t dvdnav_button_select(dvdnav_t *this, pci_t *pci, int32_t button) {
   
   if(!this || !pci) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
   if(!pci->hli.hl_gi.hli_ss) {
-    printerr("Not in a menu.");
+    mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_NotInAMenu);
     return DVDNAV_STATUS_ERR;
   }
   if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) {
-    printerr("This NAV has already been left.");
+    mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_ThisNAVHasAlreadyBeenLeft);
     return DVDNAV_STATUS_ERR;
   }
  
 #ifdef BUTTON_TESTING
-  fprintf(MSG_OUT, "libdvdnav: Button select %i\n", button); 
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: Button select %i\n", button);
 #endif
   
   if((button <= 0) || (button > pci->hli.hl_gi.btn_ns)) {
-    printerr("Button does not exist.");
+    mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_ButtonDoesNotExist);
     return DVDNAV_STATUS_ERR;
   }
   
@@ -460,15 +497,15 @@
   int32_t mx,my,dx,dy;
 
   if(!this || !pci) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
   if(!pci->hli.hl_gi.hli_ss) {
-    printerr("Not in a menu.");
+    mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_NotInAMenu);
     return DVDNAV_STATUS_ERR;
   }
   if(this->last_cmd_nav_lbn == pci->pci_gi.nv_pck_lbn) {
-    printerr("This NAV has already been left.");
+    mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_ThisNAVHasAlreadyBeenLeft);
     return DVDNAV_STATUS_ERR;
   }
 
--- navigation.c	2004-01-07 20:34:28.000000000 +0100
+++ navigation.c	2006-04-05 16:03:10.000000000 +0200
@@ -21,17 +21,26 @@
  *
  */
 
+#ifndef HAVE_MPLAYER
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+#else
+#include "config.h"
+#endif
 
 #include "dvdnav_internal.h"
 
+#ifdef USE_MPDVDNAV
+#include "../mp_msg.h"
+#include "../help_mp.h"
+#endif
+
 /* Navigation API calls */
 
 dvdnav_status_t dvdnav_still_skip(dvdnav_t *this) {
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
@@ -43,9 +52,73 @@
   return DVDNAV_STATUS_OK;
 }
 
+#ifdef USE_MPDVDNAV
+dvdnav_status_t dvdnav_still_back(dvdnav_t *this) {
+  if(!this) {
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_PassedANullPointer);
+    return DVDNAV_STATUS_ERR;
+  }
+
+  this->position_current.still = 0;
+  this->skip_still = 0;
+  this->sync_wait = 0;
+  this->sync_wait_skip = 1;
+
+  pthread_mutex_lock(&this->vm_lock);
+  vm_play_cell(this->vm);
+//  vm_play_pgc(this->vm);
+  pthread_mutex_unlock(&this->vm_lock);
+
+  return DVDNAV_STATUS_OK;
+}
+
+dvdnav_status_t dvdnav_wait_back(dvdnav_t *this) {
+  if(!this) {
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_PassedANullPointer);
+    return DVDNAV_STATUS_ERR;
+  }
+
+  this->position_current.still = 0;
+  this->skip_still = 0;
+  this->sync_wait = 0;
+  this->sync_wait_skip = 0;
+
+  pthread_mutex_lock(&this->vm_lock);
+  vm_play_cell(this->vm);
+//  vm_play_pgc(this->vm);
+  pthread_mutex_unlock(&this->vm_lock);
+
+  return DVDNAV_STATUS_OK;
+}
+
+dvdnav_status_t dvdnav_wait_still_clear(dvdnav_t *this) {
+  if(!this) {
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_PassedANullPointer);
+    return DVDNAV_STATUS_ERR;
+  }
+
+  this->position_current.still = 0;
+  this->skip_still = 0;
+  this->sync_wait = 0;
+  this->sync_wait_skip = 0;
+
+  return DVDNAV_STATUS_OK;
+}
+
+dvdnav_status_t dvdnav_is_still_cell(dvdnav_t *this, int *flag)
+{
+  if(!this || !flag) {
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_PassedANullPointer);
+    return DVDNAV_STATUS_ERR;
+  }
+  *flag=this->position_current.still;
+  return DVDNAV_STATUS_OK;
+}
+#endif
+
 dvdnav_status_t dvdnav_wait_skip(dvdnav_t *this) {
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
@@ -57,11 +130,11 @@
 
 dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int32_t *titles) {
   if(!this || !titles) {
-    printerr("Passed a NULL pointer.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
   if(!this->started) {
-    printerr("Virtual DVD machine not started.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_VirtualDVDMachineNotStarted);
     return DVDNAV_STATUS_ERR;
   }
 
@@ -72,15 +145,15 @@
 
 dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *this, int32_t title, int32_t *parts) {
   if(!this || !parts) {
-    printerr("Passed a NULL pointer.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
   if(!this->started) {
-    printerr("Virtual DVD machine not started.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_VirtualDVDMachineNotStarted);
     return DVDNAV_STATUS_ERR;
   }
   if ((title < 1) || (title > vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts) ) {
-    printerr("Passed a title number out of range.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_PassedATitleNumberOutOfRange);
     return DVDNAV_STATUS_ERR;
   }
 
@@ -93,18 +166,18 @@
   int32_t retval;
   
   if(!this || !title || !part) {
-    printerr("Passed a NULL pointer.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
   
   pthread_mutex_lock(&this->vm_lock);
   if (!this->vm->vtsi || !this->vm->vmgi) {
-    printerr("Bad VM state.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_BadVMState);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
   if (!this->vm->state.pgc) {
-    printerr("No current PGC.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_NoCurrentPGC);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
@@ -123,14 +196,14 @@
     pthread_mutex_unlock(&this->vm_lock);
     return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR;
   }
-  printerr("Not in a title or menu.");
+  mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_NotInATitleOrMenu);
   pthread_mutex_unlock(&this->vm_lock);
   return DVDNAV_STATUS_ERR;
 }
 
 dvdnav_status_t dvdnav_title_play(dvdnav_t *this, int32_t title) {
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
   return dvdnav_part_play(this, title, 1);
@@ -140,28 +213,28 @@
   int32_t retval;
 
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
   
   pthread_mutex_lock(&this->vm_lock);
   if (!this->vm->vmgi) {
-    printerr("Bad VM state.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_BadVMState);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
   if (!this->vm->state.pgc) {
-    printerr("No current PGC.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_NoCurrentPGC);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
   if((title < 1) || (title > this->vm->vmgi->tt_srpt->nr_of_srpts)) {
-    printerr("Title out of range.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_TitleOutOfRange);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
   if((part < 1) || (part > this->vm->vmgi->tt_srpt->title[title-1].nr_of_ptts)) {
-    printerr("Part out of range.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_PartOutOfRange);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
@@ -178,25 +251,25 @@
 					   int32_t part, int32_t parts_to_play) {
   /* FIXME: Implement auto-stop */
  if (dvdnav_part_play(this, title, part) == DVDNAV_STATUS_OK)
-   printerr("Not implemented yet.");
+   mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_NotImplementedYet);
  return DVDNAV_STATUS_ERR;
 }
 
 dvdnav_status_t dvdnav_time_play(dvdnav_t *this, int32_t title,
 				 uint64_t time) {
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
   
   /* FIXME: Implement */
-  printerr("Not implemented yet.");
+   mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_NotImplementedYet);
   return DVDNAV_STATUS_ERR;
 }
 
 dvdnav_status_t dvdnav_stop(dvdnav_t *this) {
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
   
@@ -208,7 +281,7 @@
 
 dvdnav_status_t dvdnav_go_up(dvdnav_t *this) {
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_LIBMPDVDNAV_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
--- read_cache.c	2004-03-03 17:48:36.000000000 +0100
+++ read_cache.c	2006-04-05 16:03:10.000000000 +0200
@@ -27,9 +27,13 @@
  * search the CVS attic.
  */
 
+#ifndef HAVE_MPLAYER
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+#else
+#include "config.h"
+#endif
 
 #include "dvdnav.h"
 #include "dvdnav_internal.h"
@@ -45,6 +49,11 @@
 #define READ_AHEAD_SIZE_MIN 4
 #define READ_AHEAD_SIZE_MAX 512
 
+#ifdef USE_MPDVDNAV
+#include "../mp_msg.h"
+#include "../help_mp.h"
+#endif
+
 typedef struct read_cache_chunk_s {
   uint8_t     *cache_buffer;
   uint8_t     *cache_buffer_base;  /* used in malloc and free for alignment */
@@ -73,25 +82,6 @@
 #define READ_CACHE_TRACE 0
 */
 
-#ifdef __GNUC__
-# if READ_CACHE_TRACE
-#  define dprintf(fmt, args...) fprintf(MSG_OUT, "libdvdnav: %s: "fmt,  __func__ , ## args)
-# else
-#  define dprintf(fmt, args...) /* Nowt */
-# endif
-#else
-# if READ_CACHE_TRACE
-#  define dprintf(fmt, ...) fprintf(MSG_OUT, "libdvdnav: %s: "fmt,  __func__ , __VA_ARGS__)
-# else
-#ifdef _MSC_VER
-#  define dprintf(fmt, str) /* Nowt */
-#else
-#  define dprintf(fmt, ...) /* Nowt */
-#endif /* _MSC_VER */
-# endif
-#endif
-
-
 read_cache_t *dvdnav_read_cache_new(dvdnav_t* dvd_self) {
   read_cache_t *self;
   int i;
@@ -183,7 +173,7 @@
         block_count * DVD_VIDEO_LB_LEN + ALIGNMENT);
       self->chunk[use].cache_buffer =
         (uint8_t *)(((uintptr_t)self->chunk[use].cache_buffer_base & ~((uintptr_t)(ALIGNMENT - 1))) + ALIGNMENT);
-      dprintf("pre_cache DVD read realloc happened\n");
+      mp_msg(MSGT_CPLAYER,MSGL_DBG2,MSGTR_LIBMPDVDNAV_PreCacheDVDReadReallocHappened);
       self->chunk[use].cache_malloc_size = block_count;
     } else {
       /* we still haven't found a cache chunk, let's allocate a new one */
@@ -202,7 +192,7 @@
 	self->chunk[i].cache_buffer =
 	  (uint8_t *)(((uintptr_t)self->chunk[i].cache_buffer_base & ~((uintptr_t)(ALIGNMENT - 1))) + ALIGNMENT);
 	self->chunk[i].cache_malloc_size = block_count > 500 ? block_count : 500;
-	dprintf("pre_cache DVD read malloc %d blocks\n",
+      mp_msg(MSGT_CPLAYER,MSGL_DBG2,MSGTR_LIBMPDVDNAV_PreCacheDVDReadMalloc,
 	  (block_count > 500 ? block_count : 500 ));
       }
     }
@@ -215,7 +205,7 @@
     self->chunk[use].cache_valid = 1;
     self->current = use;
   } else {
-    dprintf("pre_caching was impossible, no cache chunk available\n");
+    mp_msg(MSGT_CPLAYER,MSGL_DBG2,MSGTR_LIBMPDVDNAV_PreCachingWasImpossible);
   }
   pthread_mutex_unlock(&self->lock);
 }
@@ -274,7 +264,7 @@
     chunk->usage_count++;
     pthread_mutex_unlock(&self->lock);
 
-    dprintf("libdvdnav: sector=%d, start_sector=%d, last_sector=%d\n", sector, chunk->cache_start_sector, chunk->cache_start_sector + chunk->cache_block_count);
+    mp_msg(MSGT_CPLAYER,MSGL_DBG2,MSGTR_LIBMPDVDNAV_ReadCacheSectorInfo, sector, chunk->cache_start_sector, chunk->cache_start_sector + chunk->cache_block_count);
 
     /* read_ahead_size */
     incr = self->read_ahead_incr >> 1;
@@ -294,7 +284,7 @@
       if (sector >= chunk->cache_start_sector + chunk->cache_read_count + size)
         size = sector - chunk->cache_start_sector - chunk->cache_read_count;
     }
-    dprintf("libdvdnav: read_ahead_size=%d, size=%d\n", self->read_ahead_size, size);
+    mp_msg(MSGT_CPLAYER,MSGL_DBG2,MSGTR_LIBMPDVDNAV_ReadCacheReadAheadSize, self->read_ahead_size, size);
 
     if (size)
       chunk->cache_read_count += DVDReadBlocks(self->dvd_self->file,
@@ -307,7 +297,7 @@
   } else {
 
     if (self->dvd_self->use_read_ahead)
-      dprintf("cache miss on sector %d\n", sector);
+    mp_msg(MSGT_CPLAYER,MSGL_DBG2,MSGTR_LIBMPDVDNAV_CacheMissOnSector, sector);
 
     res = DVDReadBlocks(self->dvd_self->file,
                         sector,
--- remap.c	2003-08-27 15:54:19.000000000 +0200
+++ remap.c	2006-04-05 16:40:59.000000000 +0200
@@ -31,10 +31,19 @@
 #endif
 #endif /* _MSC_VER */
 
+#ifdef HAVE_MPLAYER
+#include "config.h"
+#endif
+
 #include <assert.h>
 #include "remap.h"
 #include "dvdnav_internal.h"
 
+#ifdef USE_MPDVDNAV
+#include "../mp_msg.h"
+#include "../help_mp.h"
+#endif
+
 struct block_s {
     int domain;
     int title;
@@ -189,16 +198,18 @@
     remap_t *map;
 
     /* Build the map filename */
-    home = getenv("HOME"); assert(home);
-    strncpy(fname, home, sizeof(fname));
-    strncat(fname, "/.dvdnav/", sizeof(fname));
-    strncat(fname, title, sizeof(fname));
-    strncat(fname, ".map", sizeof(fname));
-
+    home = getenv("HOME");
+#ifdef WIN32
+    if(!home) home = getenv("USERPROFILE");
+    if(!home) home = getenv("HOMEPATH");
+    if(!home) home = (char*)get_path("");
+#endif
+    assert(home);
+    snprintf(fname, sizeof(fname), "%s/.dvdnav/%s.map", home, title);
     /* Open the map file */
     fp = fopen( fname, "r");
     if (!fp) {
-	fprintf(MSG_OUT, "libdvdnav: Unable to find map file '%s'\n", fname);
+        mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_UnableToFindMapFile, fname);
 	return NULL;
     }
 
@@ -212,7 +223,7 @@
 	    res = parseblock( buf, 
 		&tmp.domain, &tmp.title, &tmp.program, &tmp.start_block, &tmp.end_block);
 	    if (res != 5) {
-		fprintf(MSG_OUT, "libdvdnav: Ignoring map line (%d): %s\n", res, buf);
+		mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_IgnoringMapLine, res, buf);
 		continue;
 	    }
 	    remap_add_node( map, tmp);
@@ -231,7 +242,7 @@
     block_t *b;
 
     if (map->debug) {
-	fprintf(MSG_OUT, "libdvdnav: %s: domain %d, title %d, program %d, start %lx, next %lx\n",
+	mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_RemapInfo,
 	    map->title, domain, title, program, cblock, cblock+offset);
     }
 
@@ -243,7 +254,7 @@
     
     if (b) {
        if (map->debug) {
-	   fprintf(MSG_OUT, "libdvdnav: Redirected to %lx\n", b->end_block);
+	   mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_RedirectedTo, b->end_block);
        }
        return b->end_block - cblock;
     }
--- searching.c	2004-01-07 20:35:12.000000000 +0100
+++ searching.c	2006-04-05 16:03:10.000000000 +0200
@@ -21,9 +21,13 @@
  *
  */
 
+#ifndef HAVE_MPLAYER
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+#else
+#include "config.h"
+#endif
 
 #include <assert.h>
 #include "dvdnav_internal.h"
@@ -32,6 +36,11 @@
 #define LOG_DEBUG
 */
 
+#ifdef USE_MPDVDNAV
+#include "../mp_msg.h"
+#include "../help_mp.h"
+#endif
+
 /* Searching API calls */
 
 dvdnav_status_t dvdnav_time_search(dvdnav_t *this,
@@ -48,7 +57,7 @@
   vobu_admap_t *admap = NULL;
 
 #ifdef LOG_DEBUG
-  fprintf(MSG_OUT, "libdvdnav: Seeking to target %u ...\n", seekto_block);
+  mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: Seeking to target %u ...\n", seekto_block);
 #endif
   *vobu = -1;
 
@@ -66,7 +75,7 @@
     admap = this->vm->vtsi->vts_vobu_admap;
     break;
   default:
-    fprintf(MSG_OUT, "libdvdnav: Error: Unknown domain for seeking.\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_UnknownDomainForSeeking);
   }
   if(admap) {
     uint32_t address = 0;
@@ -79,7 +88,7 @@
     while((!found) && ((address<<2) < admap->last_byte)) {
       next_vobu = admap->vobu_start_sectors[address];
 
-      /* fprintf(MSG_OUT, "libdvdnav: Found block %u\n", next_vobu); */
+      /* mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: Found block %u\n", next_vobu); */
 
       if(vobu_start <= seekto_block &&
           next_vobu > seekto_block) {
@@ -93,11 +102,11 @@
       *vobu = vobu_start;
       return DVDNAV_STATUS_OK;
     } else {
-      fprintf(MSG_OUT, "libdvdnav: Could not locate block\n");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_CouldNotLocateBlock);
       return DVDNAV_STATUS_ERR;
     }
   }
-  fprintf(MSG_OUT, "libdvdnav: admap not located\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_AdmapNotLocated);
   return DVDNAV_STATUS_ERR;
 }
 
@@ -112,7 +121,7 @@
   dvdnav_status_t result;
 
   if(this->position_current.still != 0) {
-    printerr("Cannot seek in a still frame.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_CannotSeekInAStillFrame);
     return DVDNAV_STATUS_ERR;
   }
   
@@ -124,19 +133,19 @@
   pthread_mutex_lock(&this->vm_lock);
   state = &(this->vm->state);
   if(!state->pgc) {
-    printerr("No current PGC.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_NoCurrentPGC);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
 #ifdef LOG_DEBUG
-  fprintf(MSG_OUT, "libdvdnav: seeking to offset=%lu pos=%u length=%u\n", offset, target, length); 
-  fprintf(MSG_OUT, "libdvdnav: Before cellN=%u blockN=%u\n", state->cellN, state->blockN);
+  mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: seeking to offset=%lu pos=%u length=%u\n", offset, target, length);
+  mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: Before cellN=%u blockN=%u\n", state->cellN, state->blockN);
 #endif
 
   switch(origin) {
    case SEEK_SET:
     if(offset > length) {
-      printerr("Request to seek behind end.");
+      printerr(MSGTR_LIBMPDVDNAV_Err_RequestToSeekBehindEnd);
       pthread_mutex_unlock(&this->vm_lock);
       return DVDNAV_STATUS_ERR;
     }
@@ -144,7 +153,7 @@
     break;
    case SEEK_CUR:
     if(target + offset > length) {
-      printerr("Request to seek behind end.");
+      printerr(MSGTR_LIBMPDVDNAV_Err_RequestToSeekBehindEnd);
       pthread_mutex_unlock(&this->vm_lock);
       return DVDNAV_STATUS_ERR;
     }
@@ -152,7 +161,7 @@
     break;
    case SEEK_END:
     if(length - offset < 0) {
-      printerr("Request to seek before start.");
+      printerr(MSGTR_LIBMPDVDNAV_Err_RequestToSeekBeforeStart);
       pthread_mutex_unlock(&this->vm_lock);
       return DVDNAV_STATUS_ERR;
     }
@@ -160,7 +169,7 @@
     break;
    default:
     /* Error occured */
-    printerr("Illegal seek mode.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_IllegalSeekMode);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
@@ -195,7 +204,7 @@
   if(found) {
     int32_t vobu;
 #ifdef LOG_DEBUG
-    fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n",
+    mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: Seeking to cell %i from choice of %i to %i\n",
 	    cell_nr, first_cell_nr, last_cell_nr);
 #endif
     if (dvdnav_scan_admap(this, state->domain, target, &vobu) == DVDNAV_STATUS_OK) {
@@ -203,7 +212,7 @@
       
       if (vm_jump_cell_block(this->vm, cell_nr, vobu - start)) {
 #ifdef LOG_DEBUG
-        fprintf(MSG_OUT, "libdvdnav: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" ,
+        mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" ,
           state->cellN, state->blockN, target, vobu, start);
 #endif
         this->vm->hop_channel += HOP_SEEK;
@@ -213,9 +222,9 @@
     }
   }
   
-  fprintf(MSG_OUT, "libdvdnav: Error when seeking\n");
-  fprintf(MSG_OUT, "libdvdnav: FIXME: Implement seeking to location %u\n", target); 
-  printerr("Error when seeking.");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_ErrorWhenSeeking);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_FIXMEImplementSeekingToLocation, target);
+  printerr(MSGTR_LIBMPDVDNAV_Err_ErrorWhenSeeking);
   pthread_mutex_unlock(&this->vm_lock);
   return DVDNAV_STATUS_ERR;
 }
@@ -231,30 +240,30 @@
 dvdnav_status_t dvdnav_prev_pg_search(dvdnav_t *this) {
 
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
   
   pthread_mutex_lock(&this->vm_lock);
   if(!this->vm->state.pgc) {
-    printerr("No current PGC.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_NoCurrentPGC);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
 
 #ifdef LOG_DEBUG
-  fprintf(MSG_OUT, "libdvdnav: previous chapter\n");
+  mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: previous chapter\n");
 #endif
   if (!vm_jump_prev_pg(this->vm)) {
-    fprintf(MSG_OUT, "libdvdnav: previous chapter failed.\n");
-    printerr("Skip to previous chapter failed.");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_PreviousChapterFailed);
+    printerr(MSGTR_LIBMPDVDNAV_Err_SkipToPreviousChapterFailed);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
   this->position_current.still = 0;
   this->vm->hop_channel++;
 #ifdef LOG_DEBUG
-  fprintf(MSG_OUT, "libdvdnav: previous chapter done\n");
+  mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: previous chapter done\n");
 #endif
   pthread_mutex_unlock(&this->vm_lock);
 
@@ -264,30 +273,30 @@
 dvdnav_status_t dvdnav_top_pg_search(dvdnav_t *this) {
 
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
     
   pthread_mutex_lock(&this->vm_lock);
   if(!this->vm->state.pgc) {
-    printerr("No current PGC.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_NoCurrentPGC);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
 
 #ifdef LOG_DEBUG
-  fprintf(MSG_OUT, "libdvdnav: top chapter\n");
+  mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: top chapter\n");
 #endif
   if (!vm_jump_top_pg(this->vm)) {
-    fprintf(MSG_OUT, "libdvdnav: top chapter failed.\n");
-    printerr("Skip to top chapter failed.");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_TopChapterFailed);
+    printerr(MSGTR_LIBMPDVDNAV_Err_SkipToTopChapterFailed);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
   this->position_current.still = 0;
   this->vm->hop_channel++;
 #ifdef LOG_DEBUG
-  fprintf(MSG_OUT, "libdvdnav: top chapter done\n");
+  mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: top chapter done\n");
 #endif
   pthread_mutex_unlock(&this->vm_lock);
 
@@ -298,19 +307,19 @@
   vm_t *try_vm;
 
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
   pthread_mutex_lock(&this->vm_lock);
   if(!this->vm->state.pgc) {
-    printerr("No current PGC.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_NoCurrentPGC);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
 
 #ifdef LOG_DEBUG
-  fprintf(MSG_OUT, "libdvdnav: next chapter\n");
+  mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: next chapter\n");
 #endif
   /* make a copy of current VM and try to navigate the copy to the next PG */
   try_vm = vm_new_copy(this->vm);
@@ -321,8 +330,8 @@
     vm_get_next_cell(try_vm);
     if (try_vm->stopped) {
       vm_free_copy(try_vm);
-      fprintf(MSG_OUT, "libdvdnav: next chapter failed.\n");
-      printerr("Skip to next chapter failed.");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_NextChapterFailed);
+      printerr(MSGTR_LIBMPDVDNAV_Err_SkipToNextChapterFailed);
       pthread_mutex_unlock(&this->vm_lock);
       return DVDNAV_STATUS_ERR;
     }
@@ -333,7 +342,7 @@
   this->position_current.still = 0;
   this->vm->hop_channel++;
 #ifdef LOG_DEBUG
-  fprintf(MSG_OUT, "libdvdnav: next chapter done\n");
+  mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: next chapter done\n");
 #endif
   pthread_mutex_unlock(&this->vm_lock);
 
@@ -344,13 +353,13 @@
   vm_t *try_vm;
   
   if(!this) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
   pthread_mutex_lock(&this->vm_lock);
   if(!this->vm->state.pgc) {
-    printerr("No current PGC.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_NoCurrentPGC);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
@@ -381,7 +390,7 @@
     return DVDNAV_STATUS_OK;
   } else {
     vm_free_copy(try_vm);
-    printerr("No such menu or menu not reachable.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_NoSuchMenuOrMenuNotReachable);
     pthread_mutex_unlock(&this->vm_lock); 
     return DVDNAV_STATUS_ERR;
   }
@@ -395,18 +404,18 @@
   dvd_state_t *state;
 
   if(!this || !pos || !len) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
   if(!this->started) {
-    printerr("Virtual DVD machine not started.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_VirtualDVDMachineNotStarted);
     return DVDNAV_STATUS_ERR;
   }
 
   pthread_mutex_lock(&this->vm_lock);
   state = &(this->vm->state);
   if(!state->pgc || this->vm->stopped) {
-    printerr("No current PGC.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_NoCurrentPGC);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
@@ -414,7 +423,7 @@
       this->position_current.domain       != state->domain         ||
       this->position_current.vts          != state->vtsN           ||
       this->position_current.cell_restart != state->cell_restart) {
-    printerr("New position not yet determined.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_NewPositionNotYetDetermined);
     pthread_mutex_unlock(&this->vm_lock);
     return DVDNAV_STATUS_ERR;
   }
@@ -465,13 +474,13 @@
   dvd_state_t *state;
 
   if(!this || !pos || !len) {
-    printerr("Passed a NULL pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
   state = &(this->vm->state);
   if(!state->pgc) {
-    printerr("No current PGC.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_NoCurrentPGC);
     return DVDNAV_STATUS_ERR;
   }
 
@@ -489,3 +498,26 @@
   
   return DVDNAV_STATUS_OK;
 }
+
+#ifdef USE_MPDVDNAV
+dvdnav_status_t dvdnav_get_pgc(dvdnav_t *this, int *pg_num)
+{
+  if(!this || !pg_num) {
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
+    return DVDNAV_STATUS_ERR;
+  }
+
+  pthread_mutex_lock(&this->vm_lock);
+  if(!this->vm->state.pgc) {
+    printerr(MSGTR_LIBMPDVDNAV_Err_NoCurrentPGC);
+    pthread_mutex_unlock(&this->vm_lock);
+    return DVDNAV_STATUS_ERR;
+  }
+#ifdef LOG_DEBUG
+  mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: get pgc\n");
+#endif
+  *pg_num = vm_get_PGCN(this->vm);
+  pthread_mutex_unlock(&this->vm_lock);
+  return DVDNAV_STATUS_OK;
+}
+#endif
--- settings.c	2003-12-31 22:37:16.000000000 +0100
+++ settings.c	2006-04-05 16:03:10.000000000 +0200
@@ -21,17 +21,26 @@
  *
  */
 
+#ifndef HAVE_MPLAYER
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+#else
+#include "config.h"
+#endif
 
 #include "dvdnav_internal.h"
 
+#ifdef USE_MPDVDNAV
+#include "../mp_msg.h"
+#include "../help_mp.h"
+#endif
+
 /* Characteristics/setting API calls */
 
 dvdnav_status_t dvdnav_get_region_mask(dvdnav_t *this, int32_t *region) {
   if(!this || !region) {
-    printerr("Passed a NULL this pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
@@ -41,7 +50,7 @@
 
 dvdnav_status_t dvdnav_set_region_mask(dvdnav_t *this, int32_t mask) {
   if(!this) {
-    printerr("Passed a NULL this pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
@@ -53,7 +62,7 @@
 
 dvdnav_status_t dvdnav_set_readahead_flag(dvdnav_t *this, int32_t use_readahead) {
   if(!this) {
-    printerr("Passed a NULL this pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
@@ -63,7 +72,7 @@
 
 dvdnav_status_t dvdnav_get_readahead_flag(dvdnav_t *this, int32_t *flag) {
   if(!this || !flag) {
-    printerr("Passed a NULL this pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
@@ -73,12 +82,12 @@
 
 static dvdnav_status_t set_language_register(dvdnav_t *this, char *code, int reg) {
   if(!this || !code) {
-    printerr("Passed a NULL this pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
     
   if(!code[0] || !code[1]) {
-    printerr("Passed illegal language code.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedIllegalLanguageCode);
     return DVDNAV_STATUS_ERR;
   }
   
@@ -102,7 +111,7 @@
 
 dvdnav_status_t dvdnav_set_PGC_positioning_flag(dvdnav_t *this, int32_t pgc) {
   if(!this) {
-    printerr("Passed a NULL this pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
@@ -112,10 +121,25 @@
 
 dvdnav_status_t dvdnav_get_PGC_positioning_flag(dvdnav_t *this, int32_t *flag) {
   if(!this || !flag) {
-    printerr("Passed a NULL this pointer.");
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
     return DVDNAV_STATUS_ERR;
   }
 
   (*flag) = this->pgc_based;
   return DVDNAV_STATUS_OK;
 }
+
+#ifdef USE_MPDVDNAV
+dvdnav_status_t dvdnav_button_select_auto_action(dvdnav_t *this, int mode)
+{
+  if(!this) {
+    printerr(MSGTR_LIBMPDVDNAV_Err_PassedANullPointer);
+    return DVDNAV_STATUS_ERR;
+  }
+
+  pthread_mutex_lock(&this->vm_lock);
+  this->vm->auto_action_mode = mode;
+  pthread_mutex_unlock(&this->vm_lock);
+  return DVDNAV_STATUS_OK;
+}
+#endif
--- vm/decoder.c	2004-03-03 17:50:42.000000000 +0100
+++ decoder.c	2006-04-05 16:03:09.000000000 +0200
@@ -23,18 +23,52 @@
  *
  */
 
+#ifndef HAVE_MPLAYER
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+#else
+#include "config.h"
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <inttypes.h>
 #include <string.h>  /* For memset */
-#include "ifo_types.h" /* vm_cmd_t */
+
+#ifdef USE_MPDVDKIT
+#if (USE_MPDVDKIT == 2)
+#include "libmpdvdkit2/dvd_input.h"
+#include "libmpdvdkit2/dvd_reader.h"
+#include "libmpdvdkit2/ifo_types.h"
+#include "libmpdvdkit2/ifo_read.h"
+#include "libmpdvdkit2/nav_read.h"
+#else
+#include "libmpdvdkit/dvd_input.h"
+#include "libmpdvdkit/dvd_reader.h"
+#include "libmpdvdkit/ifo_types.h"
+#include "libmpdvdkit/ifo_read.h"
+#include "libmpdvdkit/nav_read.h"
+#endif
+#else
+#include <dvdread/dvd_input.h>
+#include <dvdread/dvd_reader.h>
+#include <dvdread/ifo_types.h>
+#include <dvdread/ifo_read.h>
+#include <dvdread/nav_read.h>
+#endif
 
 #include "dvdnav_internal.h"
 
+#ifdef USE_MPDVDNAV
+#include "../mp_msg.h"
+#include "../help_mp.h"
+#endif
+
+#ifdef USE_MPDVDNAV_TRACE
+extern int dvdnav_trace;
+#endif
+
 uint32_t vm_getbits(command_t *command, int32_t start, int32_t count) {
   uint64_t result = 0;
   uint64_t bit_mask = 0;
@@ -48,7 +82,7 @@
        (start > 63) ||
        (count < 0) ||
        (start < 0) ) {
-    fprintf(MSG_OUT, "libdvdnav: Bad call to vm_getbits. Parameter out of range\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_BadCallToVMGetbits);
     abort();
   }
   /* all ones, please */
@@ -66,7 +100,7 @@
     struct timeval current_time, time_offset;
     uint16_t result;
     /* Counter mode */
-    /* fprintf(MSG_OUT, "libdvdnav: Getting counter %d\n",reg);*/
+    /* mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: Getting counter %d\n",reg);*/
     gettimeofday(&current_time, NULL);
     time_offset.tv_sec = current_time.tv_sec - registers->GPRM_time[reg].tv_sec;
     time_offset.tv_usec = current_time.tv_usec - registers->GPRM_time[reg].tv_usec;
@@ -89,7 +123,7 @@
   if (registers->GPRM_mode[reg] & 0x01) {
     struct timeval current_time;
     /* Counter mode */
-    /* fprintf(MSG_OUT, "libdvdnav: Setting counter %d\n",reg); */
+    /* mp_msg(MSGT_FIXME,MSGL_FIXME, "libdvdnav: Setting counter %d\n",reg); */
     gettimeofday(&current_time, NULL);
     registers->GPRM_time[reg] = current_time;
     registers->GPRM_time[reg].tv_sec -= value;
@@ -102,7 +136,7 @@
 static uint16_t eval_reg(command_t* command, uint8_t reg) {
   if(reg & 0x80) {
     if ((reg & 0x1f) == 20) {
-      fprintf(MSG_OUT, "libdvdnav: Suspected RCE Region Protection!!!\n");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_SuspectedRCERegionProtection);
     }
     return command->registers->SPRM[reg & 0x1f]; /*  FIXME max 24 not 32 */
   } else {
@@ -153,7 +187,7 @@
     case 7:
       return data1 <  data2;
   }
-  fprintf(MSG_OUT, "libdvdnav: eval_compare: Invalid comparison code\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_EvalCompareInvalidComparisonCode);
   return 0;
 }
 
@@ -511,7 +545,7 @@
       cond = eval_if_version_1(&command);
       res = eval_special_instruction(&command, cond);
       if(res == -1) {
-	fprintf(MSG_OUT, "libdvdnav: Unknown Instruction!\n");
+	mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_UnknownInstrution);
 	abort();
       }
       break;
@@ -565,15 +599,15 @@
 	res = -1;
       break;
     default: /* Unknown command */
-      fprintf(MSG_OUT, "libdvdnav: WARNING: Unknown Command=%x\n", vm_getbits(&command, 63, 3));
+       mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_WarningUnknownComman, vm_getbits(&command, 63, 3));
       abort();
   }
   /*  Check if there are bits not yet examined */
 
   if(command.instruction & ~ command.examined) {
-    fprintf(MSG_OUT, "libdvdnav: decoder.c: [WARNING, unknown bits:");
-    fprintf(MSG_OUT, " %08llx", (command.instruction & ~ command.examined) );
-    fprintf(MSG_OUT, "]\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_DecoderCWarningUnknownBits);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO," %08llx", (command.instruction & ~ command.examined) );
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "]\n");
   }
 
   return res;
@@ -585,15 +619,16 @@
   int32_t i = 0;
   int32_t total = 0;
   
-#ifdef TRACE
+#ifdef USE_MPDVDNAV_TRACE
   /*  DEBUG */
-  fprintf(MSG_OUT, "libdvdnav: Registers before transaction\n");
+  if (dvdnav_trace) {
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: Registers before transaction\n");
   vm_print_registers( registers );
-  fprintf(MSG_OUT, "libdvdnav: Full list of commands to execute\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: Full list of commands to execute\n");
   for(i = 0; i < num_commands; i++)
     vm_print_cmd(i, &commands[i]);
-  fprintf(MSG_OUT, "libdvdnav: --------------------------------------------\n");
-  fprintf(MSG_OUT, "libdvdnav: Single stepping commands\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: --------------------------------------------\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: Single stepping commands\n");}
 #endif
 
   i = 0; 
@@ -601,16 +636,17 @@
     int32_t line;
     
 #ifdef TRACE
-    vm_print_cmd(i, &commands[i]);
+  if (dvdnav_trace) vm_print_cmd(i, &commands[i]);
 #endif
 
     line = eval_command(&commands[i].bytes[0], registers, return_values);
     
     if (line < 0) { /*  Link command */
-#ifdef TRACE
-      fprintf(MSG_OUT, "libdvdnav: Registers after transaction\n");
+#ifdef USE_MPDVDNAV_TRACE
+    if (dvdnav_trace) {
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: Registers after transaction\n");
       vm_print_registers( registers );
-      fprintf(MSG_OUT, "libdvdnav: eval: Doing Link/Jump/Call\n"); 
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: eval: Doing Link/Jump/Call\n"); }
 #endif
       return 1;
     }
@@ -624,14 +660,15 @@
   }
   
   memset(return_values, 0, sizeof(link_t));
-#ifdef TRACE
-  fprintf(MSG_OUT, "libdvdnav: Registers after transaction\n");
-  vm_print_registers( registers );
+#ifdef USE_MPDVDNAV_TRACE
+  if (dvdnav_trace) {
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,"libdvdnav: Registers after transaction\n");
+  vm_print_registers( registers ); }
 #endif
   return 0;
 }
 
-#ifdef TRACE
+#ifdef USE_MPDVDNAV_TRACE
 
 static char *linkcmd2str(link_cmd_t cmd) {
   switch(cmd) {
@@ -716,63 +753,63 @@
   case LinkGoUpPGC:
   case LinkTailPGC:
   case LinkRSM:
-    fprintf(MSG_OUT, "libdvdnav: %s (button %d)\n", cmd, value.data1);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_DecoderCButton, cmd, value.data1);
     break;
   case LinkPGCN:
   case JumpTT:
   case JumpVTS_TT:
   case JumpSS_VMGM_MENU: /*  == 2 -> Title Menu */
   case JumpSS_VMGM_PGC:
-    fprintf(MSG_OUT, "libdvdnav: %s %d\n", cmd, value.data1);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: %s %d\n", cmd, value.data1);
     break;
   case LinkPTTN:
   case LinkPGN:
   case LinkCN:
-    fprintf(MSG_OUT, "libdvdnav: %s %d (button %d)\n", cmd, value.data1, value.data2);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_DecoderCButton2, cmd, value.data1, value.data2);
     break;
   case Exit:
   case JumpSS_FP:
   case PlayThis: /*  Humm.. should we have this at all.. */
-    fprintf(MSG_OUT, "libdvdnav: %s\n", cmd);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: %s\n", cmd);
     break;
   case JumpVTS_PTT:
-    fprintf(MSG_OUT, "libdvdnav: %s %d:%d\n", cmd, value.data1, value.data2);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: %s %d:%d\n", cmd, value.data1, value.data2);
     break;
   case JumpSS_VTSM:
-    fprintf(MSG_OUT, "libdvdnav: %s vts %d title %d menu %d\n", 
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_DecoderCVtsTitleMenu,
 	    cmd, value.data1, value.data2, value.data3);
     break;
   case CallSS_FP:
-    fprintf(MSG_OUT, "libdvdnav: %s resume cell %d\n", cmd, value.data1);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_DecoderCResumeCell, cmd, value.data1);
     break;
   case CallSS_VMGM_MENU: /*  == 2 -> Title Menu */
   case CallSS_VTSM:
-    fprintf(MSG_OUT, "libdvdnav: %s %d resume cell %d\n", cmd, value.data1, value.data2);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_DecoderCResumeCell2, cmd, value.data1, value.data2);
     break;
   case CallSS_VMGM_PGC:
-    fprintf(MSG_OUT, "libdvdnav: %s %d resume cell %d\n", cmd, value.data1, value.data2);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_DecoderCResumeCell2, cmd, value.data1, value.data2);
     break;
   }
  }
 
 void vm_print_registers( registers_t *registers ) {
   int32_t i;
-  fprintf(MSG_OUT, "libdvdnav:    #   ");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav:    #   ");
   for(i = 0; i < 24; i++)
-    fprintf(MSG_OUT, " %2d |", i);
-  fprintf(MSG_OUT, "\nlibdvdnav: SRPMS: ");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, " %2d |", i);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "\nlibdvdnav: SRPMS: ");
   for(i = 0; i < 24; i++)
-    fprintf(MSG_OUT, "%04x|", registers->SPRM[i]);
-  fprintf(MSG_OUT, "\nlibdvdnav: GRPMS: ");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "%04x|", registers->SPRM[i]);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "\nlibdvdnav: GRPMS: ");
   for(i = 0; i < 16; i++)
-    fprintf(MSG_OUT, "%04x|", get_GPRM(registers, i) );
-  fprintf(MSG_OUT, "\nlibdvdnav: Gmode: ");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "%04x|", get_GPRM(registers, i) );
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "\nlibdvdnav: Gmode: ");
   for(i = 0; i < 16; i++)
-    fprintf(MSG_OUT, "%04x|", registers->GPRM_mode[i]);
-  fprintf(MSG_OUT, "\nlibdvdnav: Gtime: ");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "%04x|", registers->GPRM_mode[i]);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "\nlibdvdnav: Gtime: ");
   for(i = 0; i < 16; i++)
-    fprintf(MSG_OUT, "%04lx|", registers->GPRM_time[i].tv_sec & 0xffff);
-  fprintf(MSG_OUT, "\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "%04lx|", registers->GPRM_time[i].tv_sec & 0xffff);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "\n");
 }
 
 #endif
--- vm/decoder.h	2004-01-11 22:43:13.000000000 +0100
+++ decoder.h	2006-04-05 16:03:09.000000000 +0200
@@ -28,7 +28,27 @@
 #include <inttypes.h>
 #include <sys/time.h>
 
-#include "ifo_types.h" /*  vm_cmd_t */
+#ifdef USE_MPDVDKIT
+#if (USE_MPDVDKIT == 2)
+#include "libmpdvdkit2/dvd_input.h"
+#include "libmpdvdkit2/dvd_reader.h"
+#include "libmpdvdkit2/ifo_types.h"
+#include "libmpdvdkit2/ifo_read.h"
+#include "libmpdvdkit2/nav_read.h"
+#else
+#include "libmpdvdkit/dvd_input.h"
+#include "libmpdvdkit/dvd_reader.h"
+#include "libmpdvdkit/ifo_types.h"
+#include "libmpdvdkit/ifo_read.h"
+#include "libmpdvdkit/nav_read.h"
+#endif
+#else
+#include <dvdread/dvd_input.h>
+#include <dvdread/dvd_reader.h>
+#include <dvdread/ifo_types.h>
+#include <dvdread/ifo_read.h>
+#include <dvdread/nav_read.h>
+#endif
 #include "dvdnav_internal.h"
 
 /* link command types */
@@ -107,7 +127,7 @@
 /* extracts some bits from the command */
 uint32_t vm_getbits(command_t* command, int32_t start, int32_t count);
 
-#ifdef TRACE
+#ifdef USE_MPDVDNAV_TRACE
 /* for debugging: prints a link in readable form */
 void vm_print_link(link_t value);
 
--- vm/vm.c	2004-05-21 21:32:25.000000000 +0200
+++ vm.c	2006-04-05 16:41:51.000000000 +0200
@@ -24,9 +24,13 @@
  *
  */
 
+#ifndef HAVE_MPLAYER
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+#else
+#include "config.h"
+#endif
 
 #include <stdio.h>
 #include <string.h>
@@ -38,8 +42,27 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#include "ifo_types.h"
-#include "ifo_read.h"
+#ifdef USE_MPDVDKIT
+#if (USE_MPDVDKIT == 2)
+#include "libmpdvdkit2/dvd_input.h"
+#include "libmpdvdkit2/dvd_reader.h"
+#include "libmpdvdkit2/ifo_types.h"
+#include "libmpdvdkit2/ifo_read.h"
+#include "libmpdvdkit2/nav_read.h"
+#else
+#include "libmpdvdkit/dvd_input.h"
+#include "libmpdvdkit/dvd_reader.h"
+#include "libmpdvdkit/ifo_types.h"
+#include "libmpdvdkit/ifo_read.h"
+#include "libmpdvdkit/nav_read.h"
+#endif
+#else
+#include <dvdread/dvd_input.h>
+#include <dvdread/dvd_reader.h>
+#include <dvdread/ifo_types.h>
+#include <dvdread/ifo_read.h>
+#include <dvdread/nav_read.h>
+#endif
 
 #include "dvdnav_internal.h"
 
@@ -47,6 +70,14 @@
 #include <io.h>   /* read() */
 #endif /* _MSC_VER */
 
+#ifdef USE_MPDVDNAV
+#include "../mp_msg.h"
+#include "../help_mp.h"
+#endif
+#ifdef USE_MPDVDNAV_TRACE
+extern int dvdnav_trace;
+#endif
+
 /*
 #define STRICT
 */
@@ -91,30 +122,30 @@
 
 /* Helper functions */
 
-#ifdef TRACE
+#ifdef USE_MPDVDNAV_TRACE
 static void vm_print_current_domain_state(vm_t *vm) {
   switch((vm->state).domain) {
     case VTS_DOMAIN:
-      fprintf(MSG_OUT, "libdvdnav: Video Title Domain: -\n");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: Video Title Domain: -\n");
       break;
 
     case VTSM_DOMAIN:
-      fprintf(MSG_OUT, "libdvdnav: Video Title Menu Domain: -\n");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: Video Title Menu Domain: -\n");
       break;
 
     case VMGM_DOMAIN:
-      fprintf(MSG_OUT, "libdvdnav: Video Manager Menu Domain: -\n");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: Video Manager Menu Domain: -\n");
       break;
 
     case FP_DOMAIN: 
-      fprintf(MSG_OUT, "libdvdnav: First Play Domain: -\n");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: First Play Domain: -\n");
       break;
 
     default:
-      fprintf(MSG_OUT, "libdvdnav: Unknown Domain: -\n");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: Unknown Domain: -\n");
       break;
   }
-  fprintf(MSG_OUT, "libdvdnav: VTS:%d PGC:%d PG:%u CELL:%u BLOCK:%u VTS_TTN:%u TTN:%u TT_PGCN:%u\n", 
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: VTS:%d PGC:%d PG:%u CELL:%u BLOCK:%u VTS_TTN:%u TTN:%u TT_PGCN:%u\n",
                    (vm->state).vtsN,
                    get_PGCN(vm),
                    (vm->state).pgN,
@@ -131,56 +162,58 @@
      * all off_t are 64bit.
      */
     off_t off;
-    int fd, i;
+    int i;
+    dvd_input_t fd;
     uint8_t data[DVD_VIDEO_LB_LEN];
 
     /* Read DVD name */
-    fd = open(device, O_RDONLY);
+    fd = dvdinput_open(device);
     if (fd > 0) { 
-      off = lseek( fd, 32 * (off_t) DVD_VIDEO_LB_LEN, SEEK_SET );
-      if( off == ( 32 * (off_t) DVD_VIDEO_LB_LEN ) ) {
-        off = read( fd, data, DVD_VIDEO_LB_LEN ); 
-        close(fd);
-        if (off == ( (off_t) DVD_VIDEO_LB_LEN )) {
-          fprintf(MSG_OUT, "libdvdnav: DVD Title: ");
-          for(i=25; i < 73; i++ ) {
+      off = dvdinput_seek( fd, 16 );
+      if( off == 16 ) {
+        off = dvdinput_read( fd, data, 1, DVDINPUT_NOFLAGS );
+        if (off == 1 ) {
+	  mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCDVDTitle);
+          for(i=40; i < 73; i++ ) {
             if((data[i] == 0)) break;
             if((data[i] > 32) && (data[i] < 127)) {
-              fprintf(MSG_OUT, "%c", data[i]);
+	    mp_msg(MSGT_CPLAYER,MSGL_INFO, "%c", data[i]);
             } else {
-              fprintf(MSG_OUT, " ");
+	      mp_msg(MSGT_CPLAYER,MSGL_INFO, " ");
             }
           }
-          strncpy(name, &data[25], 48);
-          name[48] = 0;
-          fprintf(MSG_OUT, "\nlibdvdnav: DVD Serial Number: ");
-          for(i=73; i < 89; i++ ) {
+          strncpy(name, &data[40], 32);
+          i=31;
+          while( (i >= 0) && (name[i] <= ' ')) --i;
+          name[i+1] = '\0';
+	  mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCDVDSerialNumber);
+          for(i=813; i < 829; i++ ) {
             if((data[i] == 0)) break;
             if((data[i] > 32) && (data[i] < 127)) {
-              fprintf(MSG_OUT, "%c", data[i]);
+	      mp_msg(MSGT_CPLAYER,MSGL_INFO, "%c", data[i]);
             } else {
-              fprintf(MSG_OUT, " ");
+	      mp_msg(MSGT_CPLAYER,MSGL_INFO, " ");
             } 
           }
-          fprintf(MSG_OUT, "\nlibdvdnav: DVD Title (Alternative): ");
+	  mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCDVDTitleAlternative);
           for(i=89; i < 128; i++ ) {
             if((data[i] == 0)) break;
             if((data[i] > 32) && (data[i] < 127)) {
-              fprintf(MSG_OUT, "%c", data[i]);
+	      mp_msg(MSGT_CPLAYER,MSGL_INFO, "%c", data[i]);
             } else {
-              fprintf(MSG_OUT, " ");
+	      mp_msg(MSGT_CPLAYER,MSGL_INFO, " ");
             }
           }
-          fprintf(MSG_OUT, "\n");
+	  mp_msg(MSGT_CPLAYER,MSGL_INFO, "\n");
         } else {
-          fprintf(MSG_OUT, "libdvdnav: Can't read name block. Probably not a DVD-ROM device.\n");
+	  mp_msg(MSGT_CPLAYER,MSGL_INFO, MSGTR_LIBMPDVDNAV_VmCCantReadNameBlock);
         }
       } else {
-        fprintf(MSG_OUT, "libdvdnav: Can't seek to block %u\n", 32 );
+        mp_msg(MSGT_CPLAYER,MSGL_INFO, MSGTR_LIBMPDVDNAV_VmCCantSeekToBlock);
       }
-      close(fd);
+      dvdinput_close(fd);
     } else {
-    fprintf(MSG_OUT, "NAME OPEN FAILED\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, MSGTR_LIBMPDVDNAV_VmCNameOpenFailed);
   }
 }
 
@@ -194,27 +228,27 @@
   
   vm->vtsi = ifoOpenVTSI(dvd, vtsN);
   if(vm->vtsi == NULL) {
-    fprintf(MSG_OUT, "libdvdnav: ifoOpenVTSI failed - CRASHING!!!\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCIfoOpenVTSIFailed);
     assert(0);
   }
   if(!ifoRead_VTS_PTT_SRPT(vm->vtsi)) {
-    fprintf(MSG_OUT, "libdvdnav: ifoRead_VTS_PTT_SRPT failed - CRASHING!!!\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCIfoReadVTSPTTSRPTFailed);
     assert(0);
   }
   if(!ifoRead_PGCIT(vm->vtsi)) {
-    fprintf(MSG_OUT, "libdvdnav: ifoRead_PGCIT failed - CRASHING!!!\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCIfoReadPGCITFailed);
     assert(0);
   }
   if(!ifoRead_PGCI_UT(vm->vtsi)) {
-    fprintf(MSG_OUT, "libdvdnav: ifoRead_PGCI_UT failed - CRASHING!!!\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCIfoReadPGCIUTFailed);
     assert(0);
   }
   if(!ifoRead_VOBU_ADMAP(vm->vtsi)) {
-    fprintf(MSG_OUT, "libdvdnav: ifoRead_VOBU_ADMAP vtsi failed - CRASHING\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCIfoReadVOBUADMAPVtsiFailed);
     assert(0);
   }
   if(!ifoRead_TITLE_VOBU_ADMAP(vm->vtsi)) {
-    fprintf(MSG_OUT, "libdvdnav: ifoRead_TITLE_VOBU_ADMAP vtsi failed - CRASHING\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCIfoReadTITLEVOBUADMAPVtsiFailed);
     assert(0);
   }
   (vm->state).vtsN = vtsN;
@@ -316,50 +350,50 @@
   if (!vm->dvd) {
     vm->dvd = DVDOpen(dvdroot);
     if(!vm->dvd) {
-      fprintf(MSG_OUT, "libdvdnav: vm: faild to open/read the DVD\n");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCVmFaildToOpenReadTheDVD);
       return 0;
     }
     dvd_read_name(vm->dvd_name, dvdroot);
     vm->map  = remap_loadmap(vm->dvd_name);
     vm->vmgi = ifoOpenVMGI(vm->dvd);
     if(!vm->vmgi) {
-      fprintf(MSG_OUT, "libdvdnav: vm: faild to read VIDEO_TS.IFO\n");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCVmFaildToReadVIDEOTSIFO);
       return 0;
     }
     if(!ifoRead_FP_PGC(vm->vmgi)) {
-      fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_FP_PGC failed\n");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCVmIfoReadFPPGCFailed);
       return 0;
     }
     if(!ifoRead_TT_SRPT(vm->vmgi)) {
-      fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_TT_SRPT failed\n");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCVmIfoReadTTSRPTFailed);
       return 0;
     }
     if(!ifoRead_PGCI_UT(vm->vmgi)) {
-      fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_PGCI_UT failed\n");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCVmIfoReadPGCIUTFailed);
       return 0;
     }
     if(!ifoRead_PTL_MAIT(vm->vmgi)) {
-      fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_PTL_MAIT failed\n");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCVmIfoReadPRLMAITFailed);
       /* return 0; Not really used for now.. */
     }
     if(!ifoRead_VTS_ATRT(vm->vmgi)) {
-      fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_VTS_ATRT failed\n");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCVmIfoReadVTSATRTFailed);
       /* return 0; Not really used for now.. */
     }
     if(!ifoRead_VOBU_ADMAP(vm->vmgi)) {
-      fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_VOBU_ADMAP vgmi failed\n");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCVmIfoReadVOBUADMAPVgmiFailed);
       /* return 0; Not really used for now.. */
     }
     /* ifoRead_TXTDT_MGI(vmgi); Not implemented yet */
   }
   if (vm->vmgi) {
     int i, mask;
-    fprintf(MSG_OUT, "libdvdnav: DVD disk reports itself with Region mask 0x%08x. Regions:",
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCDVDDiskReportsItselfWithRegionMask,
       vm->vmgi->vmgi_mat->vmg_category);
     for (i = 1, mask = 1; i <= 8; i++, mask <<= 1)
       if (((vm->vmgi->vmgi_mat->vmg_category >> 16) & mask) == 0)
-        fprintf(MSG_OUT, " %d", i);
-    fprintf(MSG_OUT, "\n");
+	mp_msg(MSGT_CPLAYER,MSGL_INFO, " %d", i);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "\n");
   }
   return 1;
 }
@@ -636,16 +670,16 @@
   part++;
   
   if (!found) {
-    fprintf(MSG_OUT, "libdvdnav: chapter NOT FOUND!\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCChapterNotFound);
     return 0;
   }
 
   title = get_TT(vm, vm->state.vtsN, vts_ttn);
 
-#ifdef TRACE
-  if (title) {
-    fprintf(MSG_OUT, "libdvdnav: ************ this chapter FOUND!\n");
-    fprintf(MSG_OUT, "libdvdnav: VTS_PTT_SRPT - Title %3i part %3i: PGC: %3i PG: %3i\n",
+#ifdef USE_MPDVDNAV_TRACE
+  if (dvdnav_trace && title) {
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: ************ this chapter FOUND!\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: VTS_PTT_SRPT - Title %3i part %3i: PGC: %3i PG: %3i\n",
              title, part,
              vts_ptt_srpt->title[vts_ttn-1].ptt[part-1].pgcn ,
              vts_ptt_srpt->title[vts_ttn-1].ptt[part-1].pgn );
@@ -667,8 +701,8 @@
   
   if(audioN < 8) {
     /* Is there any control info for this logical stream */ 
-    if((vm->state).pgc->audio_control[audioN] & (1<<15)) {
-      streamN = ((vm->state).pgc->audio_control[audioN] >> 8) & 0x07;  
+    if( (vm->state).pgc->audio_control[audioN].present) {
+      streamN = (vm->state).pgc->audio_control[audioN].s_audio;
     }
   }
   
@@ -695,19 +729,19 @@
   
   if(subpN < 32) { /* a valid logical stream */
     /* Is this logical stream present */ 
-    if((vm->state).pgc->subp_control[subpN] & (1<<31)) {
+    if((vm->state).pgc->subp_control[subpN].present) {
       if(source_aspect == 0) /* 4:3 */	     
-	streamN = ((vm->state).pgc->subp_control[subpN] >> 24) & 0x1f;  
+	streamN = (vm->state).pgc->subp_control[subpN].s_4p3;
       if(source_aspect == 3) /* 16:9 */
         switch (mode) {
 	case 0:
-	  streamN = ((vm->state).pgc->subp_control[subpN] >> 16) & 0x1f;
+	  streamN = (vm->state).pgc->subp_control[subpN].s_wide;
 	  break;
 	case 1:
-	  streamN = ((vm->state).pgc->subp_control[subpN] >> 8) & 0x1f;
+	  streamN = (vm->state).pgc->subp_control[subpN].s_lbox;
 	  break;
 	case 2:
-	  streamN = (vm->state).pgc->subp_control[subpN] & 0x1f;
+	  streamN = (vm->state).pgc->subp_control[subpN].s_panscan;
 	}
     }
   }
@@ -728,7 +762,11 @@
   /* If no such stream, then select the first one that exists. */
   if(streamN == -1) {
     for(audioN = 0; audioN < 8; audioN++) {
+#ifdef USE_MPDVDKIT
+      if((vm->state).pgc->audio_control[audioN].present) {
+#else
       if((vm->state).pgc->audio_control[audioN] & (1<<15)) {
+#endif
         if ((streamN = vm_get_audio_stream(vm, audioN)) >= 0)
           break;
       }
@@ -747,7 +785,11 @@
   /* If no such stream, then select the first one that exists. */
   if(streamN == -1) {
     for(subpN = 0; subpN < 32; subpN++) {
+#ifdef USE_MPDVDKIT
+      if((vm->state).pgc->subp_control[subpN].present) {
+#else
       if((vm->state).pgc->subp_control[subpN] & (1<<31)) {
+#endif
         if ((streamN = vm_get_subp_stream(vm, subpN, mode)) >= 0)
           break;
       }
@@ -844,6 +886,22 @@
 }
 #endif
 
+#if 0
+int vm_get_audio_id(vm_t *vm, int streamN) {
+  switch ((vm->state).domain) {
+  case VTS_DOMAIN:
+    return vm->vtsi->vtsi_mat->vts_audio_attr[streamN].s_audio;
+  case VTSM_DOMAIN:
+    return vm->vtsi->vtsi_mat->vtsm_audio_attr.s_audio;
+  case VMGM_DOMAIN:
+  case FP_DOMAIN:
+    return vm->vmgi->vmgi_mat->vmgm_audio_attr.s_audio;;
+  default:
+    abort();
+  }
+}
+#endif
+
 int vm_get_video_aspect(vm_t *vm) {
   int aspect = vm_get_video_attr(vm).display_aspect_ratio;
   
@@ -906,13 +964,14 @@
 static link_t play_PGC(vm_t *vm) {
   link_t link_values;
   
-#ifdef TRACE
-  fprintf(MSG_OUT, "libdvdnav: play_PGC:");
+#ifdef USE_MPDVDNAV_TRACE
+  if (dvdnav_trace) {
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: play_PGC:");
   if((vm->state).domain != FP_DOMAIN) {
-    fprintf(MSG_OUT, " (vm->state).pgcN (%i)\n", get_PGCN(vm));
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, " (vm->state).pgcN (%i)\n", get_PGCN(vm));
   } else {
-    fprintf(MSG_OUT, " first_play_pgc\n");
-  }
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, " first_play_pgc\n");
+  } }
 #endif
 
   /* This must be set before the pre-commands are executed because they
@@ -935,8 +994,8 @@
       /*  link_values contains the 'jump' return value */
       return link_values;
     } else {
-#ifdef TRACE
-      fprintf(MSG_OUT, "libdvdnav: PGC pre commands didn't do a Jump, Link or Call\n");
+#ifdef USE_MPDVDNAV_TRACE
+    if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: PGC pre commands didn't do a Jump, Link or Call\n");
 #endif
     }
   }
@@ -946,13 +1005,14 @@
 static link_t play_PGC_PG(vm_t *vm, int pgN) {    
   link_t link_values;
   
-#ifdef TRACE
-  fprintf(MSG_OUT, "libdvdnav: play_PGC_PG:");
+#ifdef USE_MPDVDNAV_TRACE
+  if (dvdnav_trace) {
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: play_PGC_PG:");
   if((vm->state).domain != FP_DOMAIN) {
-    fprintf(MSG_OUT, " (vm->state).pgcN (%i)\n", get_PGCN(vm));
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, " (vm->state).pgcN (%i)\n", get_PGCN(vm));
   } else {
-    fprintf(MSG_OUT, " first_play_pgc\n");
-  }
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, " first_play_pgc\n");
+  } }
 #endif
 
   /*  This must be set before the pre-commands are executed because they
@@ -975,8 +1035,8 @@
       /*  link_values contains the 'jump' return value */
       return link_values;
     } else {
-#ifdef TRACE
-      fprintf(MSG_OUT, "libdvdnav: PGC pre commands didn't do a Jump, Link or Call\n");
+#ifdef USE_MPDVDNAV_TRACE
+    if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: PGC pre commands didn't do a Jump, Link or Call\n");
 #endif
     }
   }
@@ -986,8 +1046,8 @@
 static link_t play_PGC_post(vm_t *vm) {
   link_t link_values;
 
-#ifdef TRACE
-  fprintf(MSG_OUT, "libdvdnav: play_PGC_post:\n");
+#ifdef USE_MPDVDNAV_TRACE
+  if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: play_PGC_post:\n");
 #endif
   
   /* eval -> updates the state and returns either 
@@ -1002,26 +1062,28 @@
     return link_values;
   }
   
-#ifdef TRACE
-  fprintf(MSG_OUT, "libdvdnav: ** Fell of the end of the pgc, continuing in NextPGC\n");
+#ifdef USE_MPDVDNAV_TRACE
+  if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: ** Fell of the end of the pgc, continuing in NextPGC\n");
 #endif
   /* Should end up in the STOP_DOMAIN if next_pgc is 0. */
+//#ifndef USE_MPDVDNAV
   if(!set_PGCN(vm, (vm->state).pgc->next_pgc_nr)) {
     link_values.command = Exit;
     return link_values;
   }
+//#endif
   return play_PGC(vm);
 }
 
 static link_t play_PG(vm_t *vm) {
-#ifdef TRACE
-  fprintf(MSG_OUT, "libdvdnav: play_PG: (vm->state).pgN (%i)\n", (vm->state).pgN);
+#ifdef USE_MPDVDNAV_TRACE
+  if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: play_PG: (vm->state).pgN (%i)\n", (vm->state).pgN);
 #endif
   
   assert((vm->state).pgN > 0);
   if((vm->state).pgN > (vm->state).pgc->nr_of_programs) {
-#ifdef TRACE
-    fprintf(MSG_OUT, "libdvdnav: play_PG: (vm->state).pgN (%i) > pgc->nr_of_programs (%i)\n", 
+#ifdef USE_MPDVDNAV_TRACE
+    if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: play_PG: (vm->state).pgN (%i) > pgc->nr_of_programs (%i)\n",
 	    (vm->state).pgN, (vm->state).pgc->nr_of_programs );
 #endif
     assert((vm->state).pgN == (vm->state).pgc->nr_of_programs + 1); 
@@ -1036,14 +1098,14 @@
 static link_t play_Cell(vm_t *vm) {
   static const link_t play_this = {PlayThis, /* Block in Cell */ 0, 0, 0};
 
-#ifdef TRACE
-  fprintf(MSG_OUT, "libdvdnav: play_Cell: (vm->state).cellN (%i)\n", (vm->state).cellN);
+#ifdef USE_MPDVDNAV_TRACE
+  if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: play_Cell: (vm->state).cellN (%i)\n", (vm->state).cellN);
 #endif
   
   assert((vm->state).cellN > 0);
   if((vm->state).cellN > (vm->state).pgc->nr_of_cells) {
-#ifdef TRACE
-    fprintf(MSG_OUT, "libdvdnav: (vm->state).cellN (%i) > pgc->nr_of_cells (%i)\n", 
+#ifdef USE_MPDVDNAV_TRACE
+    if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: (vm->state).cellN (%i) > pgc->nr_of_cells (%i)\n",
 	    (vm->state).cellN, (vm->state).pgc->nr_of_cells );
 #endif
     assert((vm->state).cellN == (vm->state).pgc->nr_of_cells + 1); 
@@ -1071,7 +1133,7 @@
       if (!((vm->state).cellN <= (vm->state).pgc->nr_of_cells) ||
           !((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode != 0) ||
 	  !((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 1)) {
-	fprintf(MSG_OUT, "libdvdnav: Invalid angle block\n");
+	mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCInvalidAngleBlock);
 	(vm->state).cellN -= (vm->state).AGL_REG - 1;
       }
 #endif
@@ -1079,7 +1141,7 @@
     case 2: /*  ?? */
     case 3: /*  ?? */
     default:
-      fprintf(MSG_OUT, "libdvdnav: Invalid? Cell block_mode (%d), block_type (%d)\n",
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCInvalidBlockMode,
 	      (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode,
 	      (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type);
       assert(0);
@@ -1089,7 +1151,7 @@
   case 3: /*  Last cell in the block */
   /* These might perhaps happen for RSM or LinkC commands? */
   default:
-    fprintf(MSG_OUT, "libdvdnav: Cell is in block but did not enter at first cell!\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCCellIsInBlockButDidNotEnter);
   }
   
   /* Updates (vm->state).pgN and PTTN_REG */
@@ -1100,8 +1162,8 @@
   }
   (vm->state).cell_restart++;
   (vm->state).blockN = 0;
-#ifdef TRACE
-  fprintf(MSG_OUT, "libdvdnav: Cell should restart here\n");
+#ifdef USE_MPDVDNAV_TRACE
+  if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: Cell should restart here\n");
 #endif
   return play_this;
 }
@@ -1109,8 +1171,8 @@
 static link_t play_Cell_post(vm_t *vm) {
   cell_playback_t *cell;
   
-#ifdef TRACE
-  fprintf(MSG_OUT, "libdvdnav: play_Cell_post: (vm->state).cellN (%i)\n", (vm->state).cellN);
+#ifdef USE_MPDVDNAV_TRACE
+  if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: play_Cell_post: (vm->state).cellN (%i)\n", (vm->state).cellN);
 #endif
   
   cell = &(vm->state).pgc->cell_playback[(vm->state).cellN - 1];
@@ -1132,20 +1194,20 @@
 
     if ((vm->state).pgc->command_tbl != NULL &&
         (vm->state).pgc->command_tbl->nr_of_cell >= cell->cell_cmd_nr) {
-#ifdef TRACE
-      fprintf(MSG_OUT, "libdvdnav: Cell command present, executing\n");
+#ifdef USE_MPDVDNAV_TRACE
+      if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: Cell command present, executing\n");
 #endif
       if(vmEval_CMD(&(vm->state).pgc->command_tbl->cell_cmds[cell->cell_cmd_nr - 1], 1,
 		    &(vm->state).registers, &link_values)) {
         return link_values;
       } else {
-#ifdef TRACE
-        fprintf(MSG_OUT, "libdvdnav: Cell command didn't do a Jump, Link or Call\n");
+#ifdef USE_MPDVDNAV_TRACE
+        if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: Cell command didn't do a Jump, Link or Call\n");
 #endif
       }
     } else {
-#ifdef TRACE
-      fprintf(MSG_OUT, "libdvdnav: Invalid Cell command\n");
+#ifdef USE_MPDVDNAV_TRACE
+      if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: Invalid Cell command\n");
 #endif
     }
   }
@@ -1176,7 +1238,7 @@
     case 2: /*  ?? */
     case 3: /*  ?? */
     default:
-      fprintf(MSG_OUT, "libdvdnav: Invalid? Cell block_mode (%d), block_type (%d)\n",
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCInvalidBlockMode,
 	      (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode,
 	      (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type);
       assert(0);
@@ -1186,8 +1248,8 @@
   
   /* Figure out the correct pgN for the new cell */ 
   if(!set_PGN(vm)) {
-#ifdef TRACE
-    fprintf(MSG_OUT, "libdvdnav: last cell in this PGC\n");
+#ifdef USE_MPDVDNAV_TRACE
+    if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: last cell in this PGC\n");
 #endif
     return play_PGC_post(vm);
   }
@@ -1201,13 +1263,14 @@
   
   while(link_values.command != PlayThis) {
     
-#ifdef TRACE
-    fprintf(MSG_OUT, "libdvdnav: Before printout starts:\n");
+#ifdef USE_MPDVDNAV_TRACE
+    if (dvdnav_trace) {
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: Before printout starts:\n");
     vm_print_link(link_values);
-    fprintf(MSG_OUT, "libdvdnav: Link values %i %i %i %i\n", link_values.command, 
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: Link values %i %i %i %i\n", link_values.command,
 	    link_values.data1, link_values.data2, link_values.data3);
     vm_print_current_domain_state(vm);
-    fprintf(MSG_OUT, "libdvdnav: Before printout ends.\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: Before printout ends.\n"); }
 #endif
     
     switch(link_values.command) {
@@ -1319,7 +1382,7 @@
 	
 	/* Check and see if there is any rsm info!! */
 	if (!(vm->state).rsm_vtsN) {
-	  fprintf(MSG_OUT, "libdvdnav: trying to resume without any resume info set\n");
+          mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCTryingToResumeWithoutAnyResume);
 	  link_values.command = Exit;
 	  break;
 	}
@@ -1542,10 +1605,11 @@
       break;
     }
 
-#ifdef TRACE
-    fprintf(MSG_OUT, "libdvdnav: After printout starts:\n");
+#ifdef USE_MPDVDNAV_TRACE
+    if (dvdnav_trace) {
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: After printout starts:\n");
     vm_print_current_domain_state(vm);
-    fprintf(MSG_OUT, "libdvdnav: After printout ends.\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: After printout ends.\n"); }
 #endif
     
   }
@@ -1619,8 +1683,8 @@
   assert(pgcit != NULL);  /* ?? Make this return -1 instead */
 
   if(pgcN < 1 || pgcN > pgcit->nr_of_pgci_srp) {
-#ifdef TRACE
-    fprintf(MSG_OUT, "libdvdnav:  ** No such pgcN = %d\n", pgcN);
+#ifdef USE_MPDVDNAV_TRACE
+    if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav:  ** No such pgcN = %d\n", pgcN);
 #endif
     return 0;
   }
@@ -1660,7 +1724,7 @@
       (vm->state).PTTN_REG = part;
     } else {
       /* FIXME: Handle RANDOM or SHUFFLE titles. */
-      fprintf(MSG_OUT, "libdvdnav: RANDOM or SHUFFLE titles are NOT handled yet.\n");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCRandomOrShuffleTitlesAreNotHandledYet);
     }
   }
   return 1;
@@ -1718,8 +1782,8 @@
   /* Relies on state to get the correct pgcit. */
   pgcit = get_PGCIT(vm);
   assert(pgcit != NULL);
-#ifdef TRACE
-  fprintf(MSG_OUT, "libdvdnav: ** Searching for menu (0x%x) entry PGC\n", id);
+#ifdef USE_MPDVDNAV_TRACE
+  if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: ** Searching for menu (0x%x) entry PGC\n", id);
 #endif
 
   /* Force high bit set. */
@@ -1729,20 +1793,21 @@
   for(i = 0; i < pgcit->nr_of_pgci_srp; i++) {
     if( (pgcit->pgci_srp[i].entry_id) == id) {
       pgcN = i + 1;
-#ifdef TRACE
-      fprintf(MSG_OUT, "libdvdnav: Found menu.\n");
+#ifdef USE_MPDVDNAV_TRACE
+      if (dvdnav_trace) mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: Found menu.\n");
 #endif
       return pgcN;
     }
   }
-#ifdef TRACE
-  fprintf(MSG_OUT, "libdvdnav: ** No such id/menu (0x%02x) entry PGC\n", id & 0x7f);
+#ifdef USE_MPDVDNAV_TRACE
+  if (dvdnav_trace) {
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: ** No such id/menu (0x%02x) entry PGC\n", id & 0x7f);
   for(i = 0; i < pgcit->nr_of_pgci_srp; i++) {
     if ( (pgcit->pgci_srp[i].entry_id & 0x80) == 0x80) {
-      fprintf(MSG_OUT, "libdvdnav: Available menus: 0x%x\n",
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: Available menus: 0x%x\n",
                      pgcit->pgci_srp[i].entry_id & 0x7f);
     }
-  }
+  } }
 #endif
   return 0; /*  error */
 }
@@ -1763,7 +1828,7 @@
       pgcN++;
     }
   }
-  fprintf(MSG_OUT, "libdvdnav: get_PGCN failed. Was trying to find pgcN in domain %d\n", 
+  mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCGetPGCNFailed,
          (vm->state).domain);
   return 0; /*  error */
 }
@@ -1772,7 +1837,7 @@
   int i;
   
   if(h == NULL || h->pgci_ut == NULL) {
-    fprintf(MSG_OUT, "libdvdnav: *** pgci_ut handle is NULL ***\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCPgciUtHandleIsNULL);
     return NULL; /*  error? */
   }
   
@@ -1781,17 +1846,17 @@
 	&& h->pgci_ut->lu[i].lang_code != lang)
     i++;
   if(i == h->pgci_ut->nr_of_lus) {
-    fprintf(MSG_OUT, "libdvdnav: Language '%c%c' not found, using '%c%c' instead\n",
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCLanguageNotFound,
 	    (char)(lang >> 8), (char)(lang & 0xff),
  	    (char)(h->pgci_ut->lu[0].lang_code >> 8),
 	    (char)(h->pgci_ut->lu[0].lang_code & 0xff));
-    fprintf(MSG_OUT, "libdvdnav: Menu Languages available: ");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LIBMPDVDNAV_VmCMenuLanguagesAvailable);
     for(i = 0; i < h->pgci_ut->nr_of_lus; i++) {
-      fprintf(MSG_OUT, "%c%c ",
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "%c%c ",
  	    (char)(h->pgci_ut->lu[i].lang_code >> 8),
 	    (char)(h->pgci_ut->lu[i].lang_code & 0xff));
     }
-    fprintf(MSG_OUT, "\n");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "\n");
     i = 0; /*  error? */
   }
   
@@ -1823,9 +1888,9 @@
 
 /* Debug functions */
 
-#ifdef TRACE
+#ifdef USE_MPDVDNAV_TRACE
 void vm_position_print(vm_t *vm, vm_position_t *position) {
-  fprintf(MSG_OUT, "libdvdnav: But=%x Spu=%x Aud=%x Ang=%x Hop=%x vts=%x dom=%x cell=%x cell_restart=%x cell_start=%x still=%x block=%x\n",
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "libdvdnav: But=%x Spu=%x Aud=%x Ang=%x Hop=%x vts=%x dom=%x cell=%x cell_restart=%x cell_start=%x still=%x block=%x\n",
   position->button,
   position->spu_channel,
   position->audio_channel,
@@ -1841,3 +1906,16 @@
 }
 #endif
 
+#ifdef USE_MPDVDNAV
+void vm_play_pgc(vm_t *vm)
+{
+  process_command(vm, play_PGC(vm));
+}
+
+void vm_play_cell(vm_t *vm)
+{
+  play_Cell(vm);
+}
+
+int vm_get_PGCN(vm_t *vm) { return get_PGCN(vm); }
+#endif
--- vm/vm.h	2004-01-11 22:43:13.000000000 +0100
+++ vm.h	2006-04-05 16:03:10.000000000 +0200
@@ -90,6 +90,10 @@
   char          dvd_name[50];
   remap_t      *map;
   int           stopped;
+#ifdef USE_MPDVDNAV
+  int 	   	pgc_post_flag;
+  int		auto_action_mode;
+#endif
 } vm_t;
 
 /* magic number for seeking hops */
@@ -172,10 +176,19 @@
 audio_attr_t vm_get_audio_attr(vm_t *vm, int streamN);
 subp_attr_t  vm_get_subp_attr(vm_t *vm, int streamN);
 
-#ifdef TRACE
+#ifdef USE_MPDVDNAV
+void vm_play_pgc(vm_t *vm);
+void vm_play_cell(vm_t *vm);
+#endif
+
+#ifdef USE_MPDVDNAV_TRACE
 /* Debug */
 void vm_position_print(vm_t *vm, vm_position_t *position);
 #endif
 
+#ifdef USE_MPDVDNAV
+int vm_get_PGCN(vm_t *vm);
+#endif
+
 
 #endif /* VM_HV_INCLUDED */
--- vm/vmcmd.c	2004-03-03 17:50:42.000000000 +0100
+++ vmcmd.c	2006-04-05 16:03:10.000000000 +0200
@@ -23,9 +23,13 @@
  *
  */
 
+#ifndef HAVE_MPLAYER
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+#else
+#include "config.h"
+#endif
 
 #include <stdio.h>
 #include <ctype.h>
@@ -33,6 +37,12 @@
 
 #include "dvdnav_internal.h"
 
+#ifdef USE_MPDVDNAV
+#include "../mp_msg.h"
+#include "../help_mp.h"
+#endif
+
+
 /*  freebsd compatibility */
 #ifndef PRIu8
 #define PRIu8 "d"
@@ -114,16 +124,16 @@
 
 static void print_system_reg(uint16_t reg) {
   if(reg < sizeof(system_reg_abbr_table) / sizeof(char *))
-    fprintf(MSG_OUT, "%s (SRPM:%d)", system_reg_table[reg], reg);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "%s (SRPM:%d)", system_reg_table[reg], reg);
   else
-    fprintf(MSG_OUT, " WARNING: Unknown system register ( reg=%d ) ", reg);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, " WARNING: Unknown system register ( reg=%d ) ", reg);
 }
 
 static void print_g_reg(uint8_t reg) {
     if(reg < 16)
-      fprintf(MSG_OUT, "g[%" PRIu8 "]", reg);
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "g[%" PRIu8 "]", reg);
     else
-      fprintf(MSG_OUT, " WARNING: Unknown general register ");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, " WARNING: Unknown general register ");
 }
 
 static void print_reg(uint8_t reg) {
@@ -135,25 +145,25 @@
 
 static void print_cmp_op(uint8_t op) {
   if(op < sizeof(cmp_op_table) / sizeof(char *) && cmp_op_table[op] != NULL)
-    fprintf(MSG_OUT, " %s ", cmp_op_table[op]);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, " %s ", cmp_op_table[op]);
   else
-    fprintf(MSG_OUT, " WARNING: Unknown compare op ");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, " WARNING: Unknown compare op ");
 }
 
 static void print_set_op(uint8_t op) {
   if(op < sizeof(set_op_table) / sizeof(char *) && set_op_table[op] != NULL)
-    fprintf(MSG_OUT, " %s ", set_op_table[op]);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, " %s ", set_op_table[op]);
   else
-    fprintf(MSG_OUT, " WARNING: Unknown set op ");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, " WARNING: Unknown set op ");
 }
 
 static void print_reg_or_data(command_t* command, int immediate, int start) {
   if(immediate) {
     uint32_t i = vm_getbits(command, start, 16);
     
-    fprintf(MSG_OUT, "0x%x", i);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "0x%x", i);
     if(isprint(i & 0xff) && isprint((i>>8) & 0xff))
-      fprintf(MSG_OUT, " (\"%c%c\")", (char)((i>>8) & 0xff), (char)(i & 0xff));
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, " (\"%c%c\")", (char)((i>>8) & 0xff), (char)(i & 0xff));
   } else {
     print_reg(vm_getbits(command, start - 8, 8));
   }
@@ -161,18 +171,18 @@
 
 static void print_reg_or_data_2(command_t* command, int immediate, int start) {
   if(immediate)
-    fprintf(MSG_OUT, "0x%x", vm_getbits(command, start - 1, 7));
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "0x%x", vm_getbits(command, start - 1, 7));
   else
-    fprintf(MSG_OUT, "g[%" PRIu8 "]", vm_getbits(command, start - 4, 4));
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "g[%" PRIu8 "]", vm_getbits(command, start - 4, 4));
 }
 
 static void print_reg_or_data_3(command_t* command, int immediate, int start) {
   if(immediate) {
     uint32_t i = vm_getbits(command, start, 16);
     
-    fprintf(MSG_OUT, "0x%x", i);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "0x%x", i);
     if(isprint(i & 0xff) && isprint((i>>8) & 0xff))
-      fprintf(MSG_OUT, " (\"%c%c\")", (char)((i>>8) & 0xff), (char)(i & 0xff));
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, " (\"%c%c\")", (char)((i>>8) & 0xff), (char)(i & 0xff));
   } else {
     print_reg(vm_getbits(command, start, 8));
   }
@@ -183,11 +193,11 @@
   uint8_t op = vm_getbits(command, 54, 3);
   
   if(op) {
-    fprintf(MSG_OUT, "if (");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "if (");
     print_g_reg(vm_getbits(command,39,8));
     print_cmp_op(op);
     print_reg_or_data(command, vm_getbits(command, 55,1), 31);
-    fprintf(MSG_OUT, ") ");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, ") ");
   }
 }
 
@@ -195,11 +205,11 @@
   uint8_t op = vm_getbits(command, 54, 3);
   
   if(op) {
-    fprintf(MSG_OUT, "if (");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "if (");
     print_reg(vm_getbits(command, 15, 8));
     print_cmp_op(op);
     print_reg(vm_getbits(command, 7, 8));
-    fprintf(MSG_OUT, ") ");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, ") ");
   }
 }
 
@@ -207,11 +217,11 @@
   uint8_t op = vm_getbits(command, 54, 3);
   
   if(op) {
-    fprintf(MSG_OUT, "if (");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "if (");
     print_g_reg(vm_getbits(command, 43, 4));
     print_cmp_op(op);
     print_reg_or_data(command, vm_getbits(command, 55, 1), 15);
-    fprintf(MSG_OUT, ") ");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, ") ");
   }
 }
 
@@ -219,11 +229,11 @@
   uint8_t op = vm_getbits(command, 54, 3);
 
   if(op) {
-    fprintf(MSG_OUT, "if (");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "if (");
     print_g_reg(vm_getbits(command, 51, 4));
     print_cmp_op(op);
     print_reg_or_data(command, vm_getbits(command, 55, 1), 31);
-    fprintf(MSG_OUT, ") ");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, ") ");
   }
 }
 
@@ -233,17 +243,17 @@
   
   if(op) {
     if (set_immediate) {
-      fprintf(MSG_OUT, "if (");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "if (");
       print_g_reg(vm_getbits(command, 31, 8));
       print_cmp_op(op);
       print_reg(vm_getbits(command, 23, 8));
-      fprintf(MSG_OUT, ") ");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, ") ");
     } else {
-      fprintf(MSG_OUT, "if (");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "if (");
       print_g_reg(vm_getbits(command, 39, 8));
       print_cmp_op(op);
       print_reg_or_data(command, vm_getbits(command, 55, 1), 31);
-      fprintf(MSG_OUT, ") ");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, ") ");
     }
   }
 }
@@ -253,20 +263,20 @@
   
   switch(op) {
     case 0: /*  NOP */
-      fprintf(MSG_OUT, "Nop");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "Nop");
       break;
     case 1: /*  Goto line */
-      fprintf(MSG_OUT, "Goto %" PRIu8, vm_getbits(command, 7, 8));
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "Goto %" PRIu8, vm_getbits(command, 7, 8));
       break;
     case 2: /*  Break */
-      fprintf(MSG_OUT, "Break");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "Break");
       break;
     case 3: /*  Parental level */
-      fprintf(MSG_OUT, "SetTmpPML %" PRIu8 ", Goto %" PRIu8, 
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "SetTmpPML %" PRIu8 ", Goto %" PRIu8,
 	      vm_getbits(command, 11, 4), vm_getbits(command, 7, 8));
       break;
     default:
-      fprintf(MSG_OUT, "WARNING: Unknown special instruction (%i)", 
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "WARNING: Unknown special instruction (%i)",
 	      vm_getbits(command, 51, 4));
   }
 }
@@ -276,99 +286,99 @@
   uint32_t button = vm_getbits(command, 15, 6);
   
   if(linkop < sizeof(link_table)/sizeof(char *) && link_table[linkop] != NULL)
-    fprintf(MSG_OUT, "%s (button %" PRIu8 ")", link_table[linkop], button);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "%s (button %" PRIu8 ")", link_table[linkop], button);
   else
-    fprintf(MSG_OUT, "WARNING: Unknown linksub instruction (%i)", linkop);
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "WARNING: Unknown linksub instruction (%i)", linkop);
 }
 
 static void print_link_instruction(command_t* command, int optional) {
   uint8_t op = vm_getbits(command, 51, 4);
   
   if(optional && op)
-    fprintf(MSG_OUT, ", ");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, ", ");
   
   switch(op) {
     case 0:
       if(!optional)
-      fprintf(MSG_OUT, "WARNING: NOP (link)!");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "WARNING: NOP (link)!");
       break;
     case 1:
       print_linksub_instruction(command);
       break;
     case 4:
-      fprintf(MSG_OUT, "LinkPGCN %" PRIu16, vm_getbits(command, 14, 15));
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "LinkPGCN %" PRIu16, vm_getbits(command, 14, 15));
       break;
     case 5:
-      fprintf(MSG_OUT, "LinkPTT %" PRIu16 " (button %" PRIu8 ")", 
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "LinkPTT %" PRIu16 " (button %" PRIu8 ")",
 	      vm_getbits(command, 9, 10), vm_getbits(command, 15, 6));
       break;
     case 6:
-      fprintf(MSG_OUT, "LinkPGN %" PRIu8 " (button %" PRIu8 ")", 
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "LinkPGN %" PRIu8 " (button %" PRIu8 ")",
 	      vm_getbits(command, 6, 7), vm_getbits(command, 15, 6));
       break;
     case 7:
-      fprintf(MSG_OUT, "LinkCN %" PRIu8 " (button %" PRIu8 ")", 
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "LinkCN %" PRIu8 " (button %" PRIu8 ")",
 	      vm_getbits(command, 7, 8), vm_getbits(command, 15, 6));
       break;
     default:
-      fprintf(MSG_OUT, "WARNING: Unknown link instruction");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "WARNING: Unknown link instruction");
   }
 }
 
 static void print_jump_instruction(command_t* command) {
   switch(vm_getbits(command, 51, 4)) {
     case 1:
-      fprintf(MSG_OUT, "Exit");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "Exit");
       break;
     case 2:
-      fprintf(MSG_OUT, "JumpTT %" PRIu8, vm_getbits(command, 22, 7));
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "JumpTT %" PRIu8, vm_getbits(command, 22, 7));
       break;
     case 3:
-      fprintf(MSG_OUT, "JumpVTS_TT %" PRIu8, vm_getbits(command, 22, 7));
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "JumpVTS_TT %" PRIu8, vm_getbits(command, 22, 7));
       break;
     case 5:
-      fprintf(MSG_OUT, "JumpVTS_PTT %" PRIu8 ":%" PRIu16, 
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "JumpVTS_PTT %" PRIu8 ":%" PRIu16,
 	      vm_getbits(command, 22, 7), vm_getbits(command, 41, 10));
       break;
     case 6:
       switch(vm_getbits(command, 23, 2)) {
         case 0:
-          fprintf(MSG_OUT, "JumpSS FP");
+          mp_msg(MSGT_CPLAYER,MSGL_INFO, "JumpSS FP");
           break;
         case 1:
-          fprintf(MSG_OUT, "JumpSS VMGM (menu %" PRIu8 ")", vm_getbits(command, 19, 4));
+          mp_msg(MSGT_CPLAYER,MSGL_INFO, "JumpSS VMGM (menu %" PRIu8 ")", vm_getbits(command, 19, 4));
           break;
         case 2:
-          fprintf(MSG_OUT, "JumpSS VTSM (vts %" PRIu8 ", title %" PRIu8 
+          mp_msg(MSGT_CPLAYER,MSGL_INFO, "JumpSS VTSM (vts %" PRIu8 ", title %" PRIu8
 		  ", menu %" PRIu8 ")", vm_getbits(command, 30, 7), vm_getbits(command, 38, 7), vm_getbits(command, 19, 4));
           break;
         case 3:
-          fprintf(MSG_OUT, "JumpSS VMGM (pgc %" PRIu8 ")", vm_getbits(command, 46, 15));
+          mp_msg(MSGT_CPLAYER,MSGL_INFO, "JumpSS VMGM (pgc %" PRIu8 ")", vm_getbits(command, 46, 15));
           break;
         }
       break;
     case 8:
       switch(vm_getbits(command, 23, 2)) {
         case 0:
-          fprintf(MSG_OUT, "CallSS FP (rsm_cell %" PRIu8 ")",
+          mp_msg(MSGT_CPLAYER,MSGL_INFO, "CallSS FP (rsm_cell %" PRIu8 ")",
               vm_getbits(command, 31, 8));
           break;
         case 1:
-          fprintf(MSG_OUT, "CallSS VMGM (menu %" PRIu8 
+          mp_msg(MSGT_CPLAYER,MSGL_INFO, "CallSS VMGM (menu %" PRIu8
 		  ", rsm_cell %" PRIu8 ")", vm_getbits(command, 19, 4), vm_getbits(command, 31, 8));
           break;
         case 2:
-          fprintf(MSG_OUT, "CallSS VTSM (menu %" PRIu8 
+          mp_msg(MSGT_CPLAYER,MSGL_INFO, "CallSS VTSM (menu %" PRIu8
 		  ", rsm_cell %" PRIu8 ")", vm_getbits(command, 19, 4), vm_getbits(command, 31, 8));
           break;
         case 3:
-          fprintf(MSG_OUT, "CallSS VMGM (pgc %" PRIu8 ", rsm_cell %" PRIu8 ")", 
+          mp_msg(MSGT_CPLAYER,MSGL_INFO, "CallSS VMGM (pgc %" PRIu8 ", rsm_cell %" PRIu8 ")",
 		  vm_getbits(command, 46, 15), vm_getbits(command, 31, 8));
           break;
       }
       break;
     default:
-      fprintf(MSG_OUT, "WARNING: Unknown Jump/Call instruction");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "WARNING: Unknown Jump/Call instruction");
   }
 }
 
@@ -382,26 +392,26 @@
       for(i = 1; i <= 3; i++) {
         if(vm_getbits(command, 47 - (i*8), 1)) {
           print_system_reg(i);
-          fprintf(MSG_OUT, " = ");
+          mp_msg(MSGT_CPLAYER,MSGL_INFO, " = ");
           print_reg_or_data_2(command, vm_getbits(command, 60, 1), 47 - (i*8) );
-          fprintf(MSG_OUT, " ");
+          mp_msg(MSGT_CPLAYER,MSGL_INFO, " ");
         }
       }
       break;
     case 2: /*  Set system reg 9 & 10 (Navigation timer, Title PGC number) */
       print_system_reg(9);
-      fprintf(MSG_OUT, " = ");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, " = ");
       print_reg_or_data(command, vm_getbits(command, 60, 1), 47);
-      fprintf(MSG_OUT, " ");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, " ");
       print_system_reg(10);
-      fprintf(MSG_OUT, " = %" PRIu16, vm_getbits(command, 30, 15)); /*  ?? */
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, " = %" PRIu16, vm_getbits(command, 30, 15)); /*  ?? */
       break;
     case 3: /*  Mode: Counter / Register + Set */
-      fprintf(MSG_OUT, "SetMode ");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "SetMode ");
       if(vm_getbits(command, 23, 1))
-	fprintf(MSG_OUT, "Counter ");
+	mp_msg(MSGT_CPLAYER,MSGL_INFO, "Counter ");
       else
-	fprintf(MSG_OUT, "Register ");
+	mp_msg(MSGT_CPLAYER,MSGL_INFO, "Register ");
       print_g_reg(vm_getbits(command, 19, 4));
       print_set_op(0x1); /*  '=' */
       print_reg_or_data(command, vm_getbits(command, 60, 1), 47);
@@ -409,12 +419,12 @@
     case 6: /*  Set system reg 8 (Highlighted button) */
       print_system_reg(8);
       if(vm_getbits(command, 60, 1)) /*  immediate */
-        fprintf(MSG_OUT, " = 0x%x (button no %d)", vm_getbits(command, 31, 16), vm_getbits(command, 31, 6));
+        mp_msg(MSGT_CPLAYER,MSGL_INFO, " = 0x%x (button no %d)", vm_getbits(command, 31, 16), vm_getbits(command, 31, 6));
       else
-        fprintf(MSG_OUT, " = g[%" PRIu8 "]", vm_getbits(command, 19, 4));
+        mp_msg(MSGT_CPLAYER,MSGL_INFO, " = g[%" PRIu8 "]", vm_getbits(command, 19, 4));
       break;
     default:
-      fprintf(MSG_OUT, "WARNING: Unknown system set instruction (%i)", 
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "WARNING: Unknown system set instruction (%i)",
 	      vm_getbits(command, 59, 4));
   }
 }
@@ -427,7 +437,7 @@
     print_set_op(set_op);
     print_reg_or_data(command, vm_getbits(command, 60, 1), 31);
   } else {
-    fprintf(MSG_OUT, "NOP");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "NOP");
   }
 }
 
@@ -439,7 +449,7 @@
     print_set_op(set_op);
     print_reg_or_data(command, vm_getbits(command, 60, 1), 47);
   } else {
-    fprintf(MSG_OUT, "NOP");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "NOP");
   }
 }
 
@@ -451,7 +461,7 @@
     print_set_op(set_op);
     print_reg_or_data_3(command, vm_getbits(command, 60, 1), 47);
   } else {
-    fprintf(MSG_OUT, "NOP");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "NOP");
   }
 }
 
@@ -494,46 +504,46 @@
       break;
     case 4: /*  Set, Compare -> LinkSub instructions */
       print_set_version_2(&command);
-      fprintf(MSG_OUT, ", ");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, ", ");
       print_if_version_4(&command);
       print_linksub_instruction(&command);
       break;
     case 5: /*  Compare -> (Set and LinkSub) instructions */
       print_if_version_5(&command);
-      fprintf(MSG_OUT, "{ ");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "{ ");
       print_set_version_3(&command);
-      fprintf(MSG_OUT, ", ");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, ", ");
       print_linksub_instruction(&command);
-      fprintf(MSG_OUT, " }");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, " }");
       break;
     case 6: /*  Compare -> Set, always LinkSub instructions */
       print_if_version_5(&command);
-      fprintf(MSG_OUT, "{ ");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "{ ");
       print_set_version_3(&command);
-      fprintf(MSG_OUT, " } ");
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, " } ");
       print_linksub_instruction(&command);
       break;
     default:
-      fprintf(MSG_OUT, "WARNING: Unknown instruction type (%i)", vm_getbits(&command, 63, 3));
+      mp_msg(MSGT_CPLAYER,MSGL_INFO, "WARNING: Unknown instruction type (%i)", vm_getbits(&command, 63, 3));
   }
   /*  Check if there still are bits set that were not examined */
   
   if(command.instruction & ~ command.examined) {
-    fprintf(MSG_OUT, " libdvdnav: vmcmd.c: [WARNING, unknown bits:");
-    fprintf(MSG_OUT, " %08llx", (command.instruction & ~ command.examined) );
-    fprintf(MSG_OUT, "]");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, " libdvdnav: vmcmd.c: [WARNING, unknown bits:");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, " %08llx", (command.instruction & ~ command.examined) );
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "]");
   }
 }
 
 void vm_print_cmd(int row, vm_cmd_t *vm_command) {
   int i;
 
-  fprintf(MSG_OUT, "(%03d) ", row + 1);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "(%03d) ", row + 1);
   for(i = 0; i < 8; i++)
-    fprintf(MSG_OUT, "%02x ", vm_command->bytes[i]);
-  fprintf(MSG_OUT, "| ");
+    mp_msg(MSGT_CPLAYER,MSGL_INFO, "%02x ", vm_command->bytes[i]);
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "| ");
 
   vm_print_mnemonic(vm_command);
-  fprintf(MSG_OUT, "\n");
+  mp_msg(MSGT_CPLAYER,MSGL_INFO, "\n");
 }
 
