
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, May 24, 2001 at 07:18:42PM +0200, Samuel Hocevar wrote:
> On Sun, May 20, 2001, German Tischler wrote:
>=20
> > !       unsigned char * tmem1 =3D malloc(2*DVD_LB_SIZE);
>=20
>    Be careful, this is a very uneffective call.

I know that it is. But the corresponding routine is not called often,
so performance should not be a problem here.
=20
>    You should try to malloc() this buffer at the beginning and always
> use the same memory area. For instance, add a new "u8 *p_buffer;" entry
> to the p_dvd structure, allocate it in DVDInit and free it in DVDEnd.

Ok. I added a section to the ifo_t structure, the p_dvd structure
is not available within the patched routine.

--gt


-- Attached file included as plaintext by Listar --

*** plugins/dvd/dvd_ifo.c.orig	Thu May 24 19:34:43 2001
--- plugins/dvd/dvd_ifo.c	Thu May 24 19:53:51 2001
***************
*** 67,74 ****
  static __inline__ u8* FillBuffer( ifo_t* p_ifo, u8* pi_buffer, off_t i_pos )
  {
      memset( pi_buffer, 0, DVD_LB_SIZE );
!     p_ifo->i_pos = lseek( p_ifo->i_fd, i_pos, SEEK_SET );
!     read( p_ifo->i_fd, pi_buffer, DVD_LB_SIZE );
  
      return pi_buffer;
  }
--- 67,122 ----
  static __inline__ u8* FillBuffer( ifo_t* p_ifo, u8* pi_buffer, off_t i_pos )
  {
      memset( pi_buffer, 0, DVD_LB_SIZE );
!     
!     #if defined(__FreeBSD__)
!     if ( i_pos % 2048 )
!     {
!       off_t newpos1 = i_pos - (i_pos % DVD_LB_SIZE);
!       off_t newpos2 = newpos1 + DVD_LB_SIZE;
!       off_t relpos1 = i_pos % DVD_LB_SIZE;
!       off_t relpos2 = DVD_LB_SIZE - (DVD_LB_SIZE-relpos1);
! 
!       intf_WarnMsg( 1, "Warning: position is not a multiple of 2048!");
!       
!       if ( lseek(p_ifo->i_fd, newpos1, SEEK_SET) == -1 )
!       {
!         intf_WarnMsg( 1, "Warning: seek failure!");
!         p_ifo->i_pos = -1;
!         return pi_buffer;
!       }
!       if ( read(p_ifo->i_fd, p_ifo->remap_buf, DVD_LB_SIZE) == -1 )
!       {
!         intf_WarnMsg( 1, "Warning: read failure!");
!         p_ifo->i_pos = -1;
!         return pi_buffer;
!       }
!       
!       if ( lseek(p_ifo->i_fd, newpos2, SEEK_SET) == -1 )
!       {
!         intf_WarnMsg( 1, "Warning: seek failure!");
!         p_ifo->i_pos = -1;
!         return pi_buffer;
!       }
!       if ( read(p_ifo->i_fd, (p_ifo->remap_buf+DVD_LB_SIZE),
!                 DVD_LB_SIZE) == -1 )
!       {
!         intf_WarnMsg( 1, "Warning: read failure!");
!         p_ifo->i_pos = -1;
!         return pi_buffer;
!       }
!       
!       memcpy(pi_buffer, p_ifo->remap_buf+relpos1, (DVD_LB_SIZE-relpos1));
!       memcpy(pi_buffer+(DVD_LB_SIZE-relpos1), (p_ifo->remap_buf+DVD_LB_SIZE),
!              relpos2);
!       
!       p_ifo->i_pos = i_pos;
!     }
!     else
!     #endif
!     {
!       p_ifo->i_pos = lseek( p_ifo->i_fd, i_pos, SEEK_SET );
!       read( p_ifo->i_fd, pi_buffer, DVD_LB_SIZE );
!     }
  
      return pi_buffer;
  }

-- Attached file included as plaintext by Listar --

*** plugins/dvd/dvd_ifo.h.orig	Thu May 24 19:35:26 2001
--- plugins/dvd/dvd_ifo.h	Thu May 24 19:47:10 2001
***************
*** 545,550 ****
--- 545,555 ----
      vmg_t           vmg;            /* Structure described in video_ts */
      int             i_title;        /* Current title number */
      vts_t           vts;            /* Vts ifo for current title set */
+     
+     #if defined(__FreeBSD__)
+     uint8_t         remap_buf[2*2048]; 
+                                     /* Remap buffer for unaligned reads */
+     #endif
  } ifo_t;
  
  


-- Attached file included as plaintext by Listar --

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
MessageID: S3GNpwSfVwhvfbvR6YyyElgoJhjOm6AW

[payload removed: 376 characters in 6 lines]
=4G5F
-----END PGP SIGNATURE-----



