home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2001 September / PC-WELT 9-2001.ISO / software / hw / brennen / flask_src.exe / Input / IFOParser / print_ifo_cell_addr.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-10  |  3.3 KB  |  136 lines

  1.  
  2. /*
  3.  * VIDEO TITLE SET CELL ADDRESS
  4.  *
  5.  * Copyright (C) 1998,1999  Thomas Mirlacher
  6.  *
  7.  * This program is free software; you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License as published by
  9.  * the Free Software Foundation; either version 2 of the License, or
  10.  * (at your option) any later version.
  11.  * 
  12.  * This program is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with this program; if not, write to the Free Software
  19.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  * 
  21.  * The author may be reached as dent@cosy.sbg.ac.at, or
  22.  * Thomas Mirlacher, Jakob-Haringerstr. 2, A-5020 Salzburg,
  23.  * Austria
  24.  *
  25.  *------------------------------------------------------------
  26.  *
  27.  */
  28.  
  29. #include "IFOparser.h"
  30. extern CIFOParser *IFOGlobal;
  31.  
  32. #include <stdio.h>
  33. #include <malloc.h>
  34.  
  35. #include <sys/types.h>
  36. //#include <unistd.h>
  37. #include "ifo.h"
  38.  
  39. #include "misc.h"
  40. #include "decode.h"
  41.  
  42. #define CADDR_HDR_LEN 8
  43.  
  44. typedef struct {
  45.     u_short    num        : 16;    // Number of Video Objects
  46.     u_short unknown        : 16;    // don't know
  47.     u_int    len        : 32;    // length of table
  48. } cell_addr_hdr_t;
  49.  
  50. static void _ifoPrint_cell_addr (u_char *ptr);
  51.  
  52.  
  53. #ifdef PARSER
  54. /**
  55.  *
  56.  */
  57.  
  58. void ifoPrint_vts_cell_addr (ifo_t *ifo)
  59. {
  60.     printf ("\nTITLE SET ");
  61.  
  62.     if (ifo->data[ID_TITLE_CELL_ADDR])
  63.         _ifoPrint_cell_addr (ifo->data[ID_TITLE_CELL_ADDR]);
  64. }
  65.  
  66.  
  67. /**
  68.  *
  69.  */
  70.  
  71. void ifoPrint_vtsm_cell_addr (ifo_t *ifo)
  72. {
  73.     printf ("\nMENU ");
  74.  
  75.     if (ifo->data[ID_MENU_CELL_ADDR])
  76.         _ifoPrint_cell_addr (ifo->data[ID_MENU_CELL_ADDR]);
  77. }
  78.  
  79.  
  80. /**
  81.  *
  82.  */
  83.  
  84. void _ifoPrint_cell_addr (u_char *ptr)
  85. {
  86.     cell_addr_hdr_t *cell_addr_hdr = (cell_addr_hdr_t *) ptr;
  87.     ifo_cell_addr_t *cell_addr;
  88.     int i;
  89.  
  90.     if (!ptr)
  91.         return;
  92.  
  93.     printf ("CELL ADDRESS\n");
  94.     printf ("---\n");
  95.     printf ("number of VOBs: %d\n", bswap_16 (cell_addr_hdr->num));    
  96.     printf ("???: 0x%x\n", bswap_32 (cell_addr_hdr->unknown));    
  97.     printf ("len: 0x%x\n", bswap_32 (cell_addr_hdr->len));    
  98.  
  99.     ptr += CADDR_HDR_LEN;
  100.     cell_addr = (ifo_cell_addr_t *) ptr;
  101.  
  102.  
  103.     int vob_id  = -1;
  104.     int cell_id = -1;
  105.     int id_count = -1;
  106.  
  107.     for (i=0; i<bswap_32 (cell_addr_hdr->len)/sizeof (ifo_cell_addr_t); i++) {
  108.         printf ("\tVOB ID: 0x%x Cell ID: 0x%x Start: 0x%x End: 0x%x\n",
  109.             bswap_16 (cell_addr->vob_id), cell_addr->cell_id,
  110.             bswap_32 (cell_addr->start), bswap_32 (cell_addr->end));
  111.  
  112.         if(vob_id  != bswap_16 (cell_addr->vob_id) ||
  113.             cell_id != cell_addr->cell_id ){
  114.             id_count++;
  115.             IFOGlobal->cell_address.SetArraySize( id_count+1 );
  116.             IFOGlobal->cell_address[id_count].pos.EmptyArray();
  117.             vob_id  = bswap_16 (cell_addr->vob_id);
  118.             cell_id = cell_addr->cell_id;
  119.         }
  120.  
  121.  
  122.         IFOGlobal->cell_address[id_count].vobid    = bswap_16 (cell_addr->vob_id);
  123.         IFOGlobal->cell_address[id_count].cellid   = cell_addr->cell_id;
  124.         TSpan sptemp;
  125.         sptemp.start    = (__int64)bswap_32 (cell_addr->start)*2048;
  126.         sptemp.end      = (__int64)bswap_32 (cell_addr->end  )*2048 + 2047;
  127.  
  128.         IFOGlobal->cell_address[id_count].pos.AddItem( &sptemp );
  129.  
  130.         cell_addr ++;
  131.     }
  132.  
  133.     printf ("\n\n\n");
  134. }    
  135. #endif
  136.