Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
3475fc64
Commit
3475fc64
authored
Dec 19, 2001
by
Sam Hocevar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* Heavy butchery in the VCD plugin. It should no longer segfault when reaching end of title.
parent
7756c6e8
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
186 additions
and
276 deletions
+186
-276
plugins/dvd/input_dvd.c
plugins/dvd/input_dvd.c
+2
-1
plugins/vcd/Makefile
plugins/vcd/Makefile
+1
-1
plugins/vcd/input_vcd.c
plugins/vcd/input_vcd.c
+112
-157
plugins/vcd/input_vcd.h
plugins/vcd/input_vcd.h
+8
-16
plugins/vcd/linux_cdrom_tools.c
plugins/vcd/linux_cdrom_tools.c
+61
-98
plugins/vcd/linux_cdrom_tools.h
plugins/vcd/linux_cdrom_tools.h
+2
-3
No files found.
plugins/dvd/input_dvd.c
View file @
3475fc64
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* -dvd_udf to find files
* -dvd_udf to find files
*****************************************************************************
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_dvd.c,v 1.10
8 2001/12/19 18:14:23
sam Exp $
* $Id: input_dvd.c,v 1.10
9 2001/12/19 23:19:20
sam Exp $
*
*
* Author: Stphane Borel <stef@via.ecp.fr>
* Author: Stphane Borel <stef@via.ecp.fr>
*
*
...
@@ -955,6 +955,7 @@ intf_WarnMsg( 2, "Sector: 0x%x Read: %d Chapter: %d", p_dvd->i_sector, i_block_o
...
@@ -955,6 +955,7 @@ intf_WarnMsg( 2, "Sector: 0x%x Read: %d Chapter: %d", p_dvd->i_sector, i_block_o
/* MPEG-2 Pack header. */
/* MPEG-2 Pack header. */
i_packet_size
=
8
;
i_packet_size
=
8
;
}
}
if
(
i_pos
!=
0
)
if
(
i_pos
!=
0
)
{
{
pp_packets
[
i_packet
]
=
input_ShareBuffer
(
pp_packets
[
i_packet
]
=
input_ShareBuffer
(
...
...
plugins/vcd/Makefile
View file @
3475fc64
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
# Objects
# Objects
#
#
PLUGIN_VCD
=
vcd.o input_vcd.o linux_cdrom_tools.o
$(OBJ_VCD)
PLUGIN_VCD
=
vcd.o input_vcd.o linux_cdrom_tools.o
BUILTIN_VCD
=
$(PLUGIN_VCD:%.o=BUILTIN_%.o)
BUILTIN_VCD
=
$(PLUGIN_VCD:%.o=BUILTIN_%.o)
ALL_OBJ
=
$(PLUGIN_VCD)
$(BUILTIN_VCD)
ALL_OBJ
=
$(PLUGIN_VCD)
$(BUILTIN_VCD)
...
...
plugins/vcd/input_vcd.c
View file @
3475fc64
...
@@ -70,17 +70,14 @@
...
@@ -70,17 +70,14 @@
#include "modules.h"
#include "modules.h"
#include "modules_export.h"
#include "modules_export.h"
#include "../mpeg_system/input_ps.h"
#include "input_vcd.h"
#include "input_vcd.h"
#include "linux_cdrom_tools.h"
#include "linux_cdrom_tools.h"
/* how many blocks VCDRead will read in each loop */
/* how many blocks VCDRead will read in each loop */
#define VCD_BLOCKS_ONCE
6
4
#define VCD_BLOCKS_ONCE 4
#define VCD_DATA_ONCE (2 * VCD_BLOCKS_ONCE)
#define VCD_DATA_ONCE (2 * VCD_BLOCKS_ONCE)
#define BUFFER_SIZE VCD_DATA_SIZE
#define BUFFER_SIZE VCD_DATA_SIZE
/*****************************************************************************
/*****************************************************************************
* Local prototypes
* Local prototypes
*****************************************************************************/
*****************************************************************************/
...
@@ -145,7 +142,6 @@ void _M( input_getfunctions )( function_list_t * p_function_list )
...
@@ -145,7 +142,6 @@ void _M( input_getfunctions )( function_list_t * p_function_list )
*****************************************************************************/
*****************************************************************************/
static
int
VCDProbe
(
probedata_t
*
p_data
)
static
int
VCDProbe
(
probedata_t
*
p_data
)
{
{
input_thread_t
*
p_input
=
(
input_thread_t
*
)
p_data
;
input_thread_t
*
p_input
=
(
input_thread_t
*
)
p_data
;
char
*
psz_name
=
p_input
->
p_source
;
char
*
psz_name
=
p_input
->
p_source
;
...
@@ -162,6 +158,7 @@ static int VCDProbe( probedata_t *p_data )
...
@@ -162,6 +158,7 @@ static int VCDProbe( probedata_t *p_data )
i_score
=
100
;
i_score
=
100
;
psz_name
+=
4
;
psz_name
+=
4
;
}
}
return
(
i_score
);
return
(
i_score
);
}
}
...
@@ -170,8 +167,6 @@ static int VCDProbe( probedata_t *p_data )
...
@@ -170,8 +167,6 @@ static int VCDProbe( probedata_t *p_data )
*****************************************************************************/
*****************************************************************************/
static
void
VCDOpen
(
struct
input_thread_s
*
p_input
)
static
void
VCDOpen
(
struct
input_thread_s
*
p_input
)
{
{
int
vcdhandle
;
vlc_mutex_lock
(
&
p_input
->
stream
.
stream_lock
);
vlc_mutex_lock
(
&
p_input
->
stream
.
stream_lock
);
/* If we are here we can control the pace... */
/* If we are here we can control the pace... */
...
@@ -179,30 +174,27 @@ static void VCDOpen( struct input_thread_s *p_input )
...
@@ -179,30 +174,27 @@ static void VCDOpen( struct input_thread_s *p_input )
p_input
->
stream
.
b_seekable
=
1
;
p_input
->
stream
.
b_seekable
=
1
;
p_input
->
stream
.
p_selected_area
->
i_size
=
0
;
p_input
->
stream
.
p_selected_area
->
i_size
=
0
;
p_input
->
stream
.
p_selected_area
->
i_tell
=
0
;
p_input
->
stream
.
p_selected_area
->
i_tell
=
0
;
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
/* XXX: put this shit in an access plugin */
/* XXX: put this shit in an access plugin */
if
(
strlen
(
p_input
->
p_source
)
>
4
if
(
strlen
(
p_input
->
p_source
)
>
4
&&
!
strncasecmp
(
p_input
->
p_source
,
"vcd:"
,
4
)
)
&&
!
strncasecmp
(
p_input
->
p_source
,
"vcd:"
,
4
)
)
{
{
vcdhandle
=
open
(
p_input
->
p_source
+
4
,
O_RDONLY
|
O_NONBLOCK
);
p_input
->
i_handle
=
open
(
p_input
->
p_source
+
4
,
O_RDONLY
|
O_NONBLOCK
);
}
}
else
else
{
{
vcdhandle
=
open
(
p_input
->
p_source
+
4
,
O_RDONLY
|
O_NONBLOCK
);
p_input
->
i_handle
=
open
(
p_input
->
p_source
+
4
,
O_RDONLY
|
O_NONBLOCK
);
}
}
if
(
vcd
handle
==
-
1
)
if
(
p_input
->
i_
handle
==
-
1
)
{
{
p_input
->
b_error
=
1
;
p_input
->
b_error
=
1
;
return
;
}
}
p_input
->
i_handle
=
(
int
)
vcdhandle
;
}
}
/*****************************************************************************
/*****************************************************************************
...
@@ -242,13 +234,13 @@ static void VCDInit( input_thread_t * p_input )
...
@@ -242,13 +234,13 @@ static void VCDInit( input_thread_t * p_input )
return
;
return
;
}
}
p_vcd
->
vcd
handle
=
p_input
->
i_handle
;
p_vcd
->
i_
handle
=
p_input
->
i_handle
;
p_vcd
->
b_end_of_track
=
0
;
p_vcd
->
b_end_of_track
=
0
;
/* we read the Table Of Content information */
/* we read the Table Of Content information */
if
(
read_toc
(
p_vcd
)
==
-
1
)
if
(
VCDReadToc
(
p_vcd
)
==
-
1
)
{
{
intf_ErrMsg
(
"An error occured when reading vcd's TOC"
);
intf_ErrMsg
(
"vcd error: could not read TOC"
);
}
}
p_input
->
i_read_once
=
VCD_DATA_ONCE
;
p_input
->
i_read_once
=
VCD_DATA_ONCE
;
...
@@ -272,8 +264,8 @@ static void VCDInit( input_thread_t * p_input )
...
@@ -272,8 +264,8 @@ static void VCDInit( input_thread_t * p_input )
area
[
i
]
->
i_id
=
i
;
area
[
i
]
->
i_id
=
i
;
/* Absolute start offset and size */
/* Absolute start offset and size */
area
[
i
]
->
i_start
=
p_vcd
->
tracks_sector
[
i
];
area
[
i
]
->
i_start
=
p_vcd
->
p_sectors
[
i
];
area
[
i
]
->
i_size
=
p_vcd
->
tracks_sector
[
i
+
1
]
-
p_vcd
->
tracks_sector
[
i
];
area
[
i
]
->
i_size
=
p_vcd
->
p_sectors
[
i
+
1
]
-
p_vcd
->
p_sectors
[
i
];
/* Number of chapters */
/* Number of chapters */
area
[
i
]
->
i_part_nb
=
0
;
// will be the entry points
area
[
i
]
->
i_part_nb
=
0
;
// will be the entry points
...
@@ -283,18 +275,18 @@ static void VCDInit( input_thread_t * p_input )
...
@@ -283,18 +275,18 @@ static void VCDInit( input_thread_t * p_input )
area
[
i
]
->
i_angle_nb
=
1
;
// no angle support in VCDs
area
[
i
]
->
i_angle_nb
=
1
;
// no angle support in VCDs
area
[
i
]
->
i_angle
=
1
;
area
[
i
]
->
i_angle
=
1
;
area
[
i
]
->
i_plugin_data
=
p_vcd
->
tracks_sector
[
i
];
area
[
i
]
->
i_plugin_data
=
p_vcd
->
p_sectors
[
i
];
}
}
#undef area
#undef area
/* Get requested title - if none try the first title */
/* Get requested title - if none try the first title */
i_title
=
main_GetIntVariable
(
INPUT_TITLE_VAR
,
1
);
i_title
=
main_GetIntVariable
(
INPUT_TITLE_VAR
,
1
);
if
(
i_title
<=
0
)
if
(
i_title
<=
0
)
{
{
i_title
=
1
;
i_title
=
1
;
}
}
// p_vcd->
current_track = i_title-1
;
// p_vcd->
i_track = i_title-1
;
/* Get requested chapter - if none defaults to first one */
/* Get requested chapter - if none defaults to first one */
i_chapter
=
main_GetIntVariable
(
INPUT_CHAPTER_VAR
,
1
);
i_chapter
=
main_GetIntVariable
(
INPUT_CHAPTER_VAR
,
1
);
...
@@ -303,7 +295,6 @@ static void VCDInit( input_thread_t * p_input )
...
@@ -303,7 +295,6 @@ static void VCDInit( input_thread_t * p_input )
i_chapter
=
1
;
i_chapter
=
1
;
}
}
p_input
->
stream
.
pp_areas
[
i_title
]
->
i_part
=
i_chapter
;
p_input
->
stream
.
pp_areas
[
i_title
]
->
i_part
=
i_chapter
;
p_area
=
p_input
->
stream
.
pp_areas
[
i_title
];
p_area
=
p_input
->
stream
.
pp_areas
[
i_title
];
...
@@ -341,12 +332,8 @@ static void VCDInit( input_thread_t * p_input )
...
@@ -341,12 +332,8 @@ static void VCDInit( input_thread_t * p_input )
}
}
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
return
;
}
}
/*****************************************************************************
/*****************************************************************************
* VCDEnd: frees unused data
* VCDEnd: frees unused data
*****************************************************************************/
*****************************************************************************/
...
@@ -384,10 +371,10 @@ static int VCDSetArea( input_thread_t * p_input, input_area_t * p_area )
...
@@ -384,10 +371,10 @@ static int VCDSetArea( input_thread_t * p_input, input_area_t * p_area )
/* we can't use the interface slider until initilization is complete */
/* we can't use the interface slider until initilization is complete */
p_input
->
stream
.
b_seekable
=
0
;
p_input
->
stream
.
b_seekable
=
0
;
if
(
p_area
!=
p_input
->
stream
.
p_selected_area
)
if
(
p_area
!=
p_input
->
stream
.
p_selected_area
)
{
{
/* Reset the Chapter position of the
old
title */
/* Reset the Chapter position of the
current
title */
p_input
->
stream
.
p_selected_area
->
i_part
=
0
;
p_input
->
stream
.
p_selected_area
->
i_part
=
1
;
p_input
->
stream
.
p_selected_area
->
i_tell
=
0
;
p_input
->
stream
.
p_selected_area
->
i_tell
=
0
;
/* Change the default area */
/* Change the default area */
...
@@ -395,114 +382,89 @@ static int VCDSetArea( input_thread_t * p_input, input_area_t * p_area )
...
@@ -395,114 +382,89 @@ static int VCDSetArea( input_thread_t * p_input, input_area_t * p_area )
/* Change the current track */
/* Change the current track */
/* The first track is not a valid one */
/* The first track is not a valid one */
p_vcd
->
current_track
=
p_area
->
i_id
;
p_vcd
->
i_track
=
p_area
->
i_id
;
p_vcd
->
current_sector
=
p_vcd
->
tracks_sector
[
p_vcd
->
current_track
]
;
p_vcd
->
i_sector
=
p_vcd
->
p_sectors
[
p_vcd
->
i_track
]
;
}
}
/* warn interface that something has changed */
/* warn interface that something has changed */
p_input
->
stream
.
b_seekable
=
1
;
p_input
->
stream
.
b_seekable
=
1
;
p_input
->
stream
.
b_changed
=
1
;
p_input
->
stream
.
b_changed
=
1
;
return
0
;
return
0
;
}
}
/*****************************************************************************
/*****************************************************************************
* VCDRead: reads from the VCD into PES packets.
* VCDRead: reads from the VCD into PES packets.
*****************************************************************************
*****************************************************************************
* Returns -1 in case of error, 0 if everything went well, and 1 in case of
* Returns -1 in case of error, 0 if everything went well, and 1 in case of
* EOF.
* EOF.
*****************************************************************************/
*****************************************************************************/
static
int
VCDRead
(
input_thread_t
*
p_input
,
static
int
VCDRead
(
input_thread_t
*
p_input
,
data_packet_t
**
pp_packets
)
data_packet_t
**
pp_packets
)
{
{
thread_vcd_data_t
*
p_vcd
;
thread_vcd_data_t
*
p_vcd
;
data_packet_t
*
p_data
;
data_packet_t
*
p_data
;
int
i_packet_size
;
int
i_packet_size
;
int
i_index
;
int
i_index
;
int
i_packet
;
int
i_packet
;
byte_t
*
p_buff
er
;
u32
i_head
er
;
b
oolean_t
b_no_packet
;
b
yte_t
p_buffer
[
VCD_DATA_SIZE
]
;
/* boolean_t b_eoc; No chapters yet */
/* boolean_t b_eoc; No chapters yet */
p_vcd
=
(
thread_vcd_data_t
*
)
p_input
->
p_plugin_data
;
p_vcd
=
(
thread_vcd_data_t
*
)
p_input
->
p_plugin_data
;
p_buffer
=
malloc
(
VCD_DATA_SIZE
);
if
(
p_buffer
==
NULL
)
{
intf_ErrMsg
(
"Could not malloc the read buffer"
);
return
-
1
;
}
i_packet
=
0
;
i_packet
=
0
;
b_no_packet
=
0
;
while
(
i_packet
<
VCD_DATA_ONCE
)
while
(
i_packet
<
VCD_DATA_ONCE
&&
!
p_vcd
->
b_end_of_track
)
{
{
i_index
=
0
;
if
(
VCDReadSector
(
p_vcd
,
p_buffer
)
==
-
1
)
if
(
VCD_sector_read
(
p_vcd
,
p_buffer
)
==
-
1
)
{
{
return
-
1
;
return
-
1
;
}
}
while
(
i_index
<
BUFFER_SIZE
-
6
)
i_index
=
0
;
{
if
(
(
U32_AT
(
p_buffer
+
i_index
)
&
0xFFFFFF00
)
!=
0x100L
)
while
(
i_index
<
BUFFER_SIZE
-
6
&&
!
p_vcd
->
b_end_of_track
&&
i_packet
<
VCD_DATA_ONCE
)
{
{
i_header
=
U32_AT
(
p_buffer
+
i_index
);
/* This is not the startcode of a packet. Read the stream
/* This is not the startcode of a packet. Read the stream
* until we find one. */
* until we find one. */
if
(
!
i_header
)
if
(
!
U32_AT
(
p_buffer
+
i_index
)
)
{
{
/* It is common for MPEG-1 streams to pad with zeros
/* It is common for MPEG-1 streams to pad with zeros
* (although it is forbidden by the recommendation), so
* (although it is forbidden by the recommendation), so
* don't bother everybody in this case. */
* don't bother everybody in this case. */
intf_WarnMsg
(
3
,
"G
arbage at input"
);
intf_WarnMsg
(
3
,
"vcd warning: g
arbage at input"
);
}
}
while
(
(
(
U32_AT
(
p_buffer
+
i_index
)
&
0xFFFFFF00
)
!=
0x100L
)
while
(
(
i_header
&
0xFFFFFF00
)
!=
0x100L
&&
(
i_index
<
BUFFER_SIZE
-
4
)
)
&&
(
++
i_index
<
BUFFER_SIZE
-
4
)
)
{
{
i_index
++
;
i_header
=
U32_AT
(
p_buffer
+
i_index
)
;
}
}
if
(
i_index
==
BUFFER_SIZE
-
4
)
if
(
(
i_header
&
0xFFFFFF00
)
!=
0x100L
)
{
{
b_no_packet
=
1
;
intf_WarnMsg
(
3
,
"vcd warning: no packet at sector %d
\n
"
,
}
p_vcd
->
i_sector
-
1
);
/* Packet found. */
}
if
(
b_no_packet
)
{
b_no_packet
=
0
;
intf_WarnMsg
(
3
,
"No packet found on sector %d
\n
"
,
p_vcd
->
current_sector
-
1
);
break
;
/* go to the next sector */
break
;
/* go to the next sector */
}
}
#ifdef DEBUG
#ifdef DEBUG
intf_DbgMsg
(
"packet start code : %X
\n
"
,
intf_DbgMsg
(
"packet start code : %X
\n
"
,
i_header
);
U32_AT
(
p_buffer
+
i_index
));
#endif
#endif
/* 0x1B9 == SYSTEM_END_CODE, it is only 4 bytes long. */
if
(
U32_AT
(
p_buffer
+
i_index
)
!=
0x1B9
)
{
/* The packet is at least 6 bytes long. */
if
(
U32_AT
(
p_buffer
+
i_index
)
!=
0x1BA
)
switch
(
i_header
)
{
/* That's the case for all packets, except pack header. */
i_packet_size
=
U16_AT
((
p_buffer
+
(
i_index
+
4
)));
}
else
{
{
/* Pack header. */
/* 0x1b9 == SYSTEM_END_CODE, it is only 4 bytes long. */
case
0x1b9
:
i_packet_size
=
-
2
;
break
;
/* Pack header */
case
0x1ba
:
if
(
(
*
(
p_buffer
+
(
i_index
+
4
)
)
&
0xC0
)
==
0x40
)
if
(
(
*
(
p_buffer
+
(
i_index
+
4
)
)
&
0xC0
)
==
0x40
)
{
{
/* MPEG-2 */
/* MPEG-2 */
...
@@ -518,32 +480,34 @@ static int VCDRead( input_thread_t * p_input,
...
@@ -518,32 +480,34 @@ static int VCDRead( input_thread_t * p_input,
intf_ErrMsg
(
"Unable to determine stream type"
);
intf_ErrMsg
(
"Unable to determine stream type"
);
return
(
-
1
);
return
(
-
1
);
}
}
break
;
/* The packet is at least 6 bytes long. */
default:
/* That's the case for all packets, except pack header. */
i_packet_size
=
U16_AT
((
p_buffer
+
(
i_index
+
4
)));
break
;
}
}
}
else
{
/* System End Code */
i_packet_size
=
-
2
;
}
#ifdef DEBUG
#ifdef DEBUG
intf_DbgMsg
(
"i_index : %d
\n
"
,
i_index
);
intf_DbgMsg
(
"i_index : %d
\n
"
,
i_index
);
intf_DbgMsg
(
"i_packet_size : %d
\n
"
,
i_packet_size
);
intf_DbgMsg
(
"i_packet_size : %d
\n
"
,
i_packet_size
);
#endif
#endif
if
(
i_index
+
i_packet_size
>
BUFFER_SIZE
)
if
(
i_index
+
i_packet_size
>
BUFFER_SIZE
)
{
{
intf_ErrMsg
(
"
input
error: packet too long (%i)"
,
intf_ErrMsg
(
"
vcd
error: packet too long (%i)"
,
i_index
+
i_packet_size
);
i_index
+
i_packet_size
);
continue
;
continue
;
}
}
/* Fetch a packet of the appropriate size. */
/* Fetch a packet of the appropriate size. */
p_data
=
p_input
->
pf_new_packet
(
p_input
->
p_method_data
,
p_data
=
p_input
->
pf_new_packet
(
p_input
->
p_method_data
,
i_packet_size
+
6
);
i_packet_size
+
6
);
if
(
p_data
==
NULL
)
if
(
p_data
==
NULL
)
{
{
intf_ErrMsg
(
"
O
ut of memory"
);
intf_ErrMsg
(
"
vcd error: o
ut of memory"
);
return
(
-
1
);
return
(
-
1
);
}
}
...
@@ -552,7 +516,6 @@ static int VCDRead( input_thread_t * p_input,
...
@@ -552,7 +516,6 @@ static int VCDRead( input_thread_t * p_input,
p_main
->
fast_memcpy
(
p_data
->
p_demux_start
,
p_buffer
+
i_index
,
p_main
->
fast_memcpy
(
p_data
->
p_demux_start
,
p_buffer
+
i_index
,
6
+
i_packet_size
);
6
+
i_packet_size
);
i_index
+=
(
6
+
i_packet_size
);
i_index
+=
(
6
+
i_packet_size
);
}
}
else
else
{
{
...
@@ -563,20 +526,16 @@ static int VCDRead( input_thread_t * p_input,
...
@@ -563,20 +526,16 @@ static int VCDRead( input_thread_t * p_input,
/* Give the packet to the other input stages. */
/* Give the packet to the other input stages. */
pp_packets
[
i_packet
]
=
p_data
;
pp_packets
[
i_packet
]
=
p_data
;
i_packet
++
;
i_packet
++
;
}
}
if
(
p_vcd
->
b_end_of_track
)
break
;
}
}
pp_packets
[
i_packet
]
=
NULL
;
vlc_mutex_lock
(
&
p_input
->
stream
.
stream_lock
);
vlc_mutex_lock
(
&
p_input
->
stream
.
stream_lock
);
p_input
->
stream
.
p_selected_area
->
i_tell
=
p_input
->
stream
.
p_selected_area
->
i_tell
=
p_vcd
->
current_sector
-
p_vcd
->
i_sector
-
p_input
->
stream
.
p_selected_area
->
i_start
;
p_input
->
stream
.
p_selected_area
->
i_start
;
/* no chapter for the moment*/
/* no chapter for the moment*/
/*if( b_eoc )
/*if( b_eoc )
...
@@ -591,7 +550,7 @@ static int VCDRead( input_thread_t * p_input,
...
@@ -591,7 +550,7 @@ static int VCDRead( input_thread_t * p_input,
input_area_t
*
p_area
;
input_area_t
*
p_area
;
/* EOF ? */
/* EOF ? */
if
(
p_vcd
->
current
_track
>=
p_vcd
->
nb_tracks
-
1
)
if
(
p_vcd
->
i
_track
>=
p_vcd
->
nb_tracks
-
1
)
{
{
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
vlc_mutex_unlock
(
&
p_input
->
stream
.
stream_lock
);
return
1
;
return
1
;
...
@@ -621,7 +580,6 @@ static int VCDRewind( input_thread_t * p_input )
...
@@ -621,7 +580,6 @@ static int VCDRewind( input_thread_t * p_input )
return
(
-
1
);
return
(
-
1
);
}
}
/****************************************************************************
/****************************************************************************
* VCDSeek
* VCDSeek
****************************************************************************/
****************************************************************************/
...
@@ -631,12 +589,9 @@ static void VCDSeek( input_thread_t * p_input, off_t i_off )
...
@@ -631,12 +589,9 @@ static void VCDSeek( input_thread_t * p_input, off_t i_off )
p_vcd
=
(
thread_vcd_data_t
*
)
p_input
->
p_plugin_data
;
p_vcd
=
(
thread_vcd_data_t
*
)
p_input
->
p_plugin_data
;
p_vcd
->
current_sector
=
p_vcd
->
tracks_sector
[
p_vcd
->
current_track
]
p_vcd
->
i_sector
=
p_vcd
->
p_sectors
[
p_vcd
->
i_track
]
+
i_off
;
+
i_off
;
p_input
->
stream
.
p_selected_area
->
i_tell
=
p_vcd
->
current
_sector
p_input
->
stream
.
p_selected_area
->
i_tell
=
p_vcd
->
i
_sector
-
p_input
->
stream
.
p_selected_area
->
i_start
;
-
p_input
->
stream
.
p_selected_area
->
i_start
;
return
;
}
}
plugins/vcd/input_vcd.h
View file @
3475fc64
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* input_vcd.h: thread structure of the VCD plugin
* input_vcd.h: thread structure of the VCD plugin
*****************************************************************************
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* Copyright (C) 1999-2001 VideoLAN
* $Id: input_vcd.h,v 1.
1 2001/10/23 03:17:49 jobi
Exp $
* $Id: input_vcd.h,v 1.
2 2001/12/19 23:19:20 sam
Exp $
*
*
* Author: Johan Bilien <jobi@via.ecp.fr>
* Author: Johan Bilien <jobi@via.ecp.fr>
*
*
...
@@ -21,25 +21,17 @@
...
@@ -21,25 +21,17 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
/*****************************************************************************
/*****************************************************************************
* thread_vcd_data_t: VCD information
* thread_vcd_data_t: VCD information
*****************************************************************************/
*****************************************************************************/
typedef
struct
thread_vcd_data_s
typedef
struct
thread_vcd_data_s
{
{
int
vcdhandle
;
// File descriptor
int
i_handle
;
/* File descriptor */
int
nb_tracks
;
// Nb of tracks (titles)
int
nb_tracks
;
/* Nb of tracks (titles) */
int
current_track
;
// Current track
int
i_track
;
/* Current track */
int
current_sector
;
// Current Sector
int
i_sector
;
/* Current Sector */
int
*
tracks_sector
;
// index of tracks
int
*
p_sectors
;
/* Track sectors */
boolean_t
b_end_of_track
;
// if the end of track is
boolean_t
b_end_of_track
;
/* If the end of track was reached */
// reached
}
thread_vcd_data_t
;
}
thread_vcd_data_t
;
plugins/vcd/linux_cdrom_tools.c
View file @
3475fc64
...
@@ -20,11 +20,12 @@
...
@@ -20,11 +20,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
*****************************************************************************/
/*****************************************************************************
#define MODULE_NAME vcd
* Functions declared in this file use lots of ioctl calls, thus they are
#include "modules_inner.h"
* Linux-specific.
****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include "defs.h"
#include "defs.h"
#include <stdio.h>
#include <stdio.h>
...
@@ -74,105 +75,84 @@
...
@@ -74,105 +75,84 @@
#include "input_vcd.h"
#include "input_vcd.h"
#include "linux_cdrom_tools.h"
#include "linux_cdrom_tools.h"
static
void
lba2msf
(
struct
cdrom_msf0
*
p_msf
,
int
lba
);
/*****************************************************************************
/*****************************************************************************
* read_toc : Reads the Table of Content of a CD-ROM and fills p_vcd with *
* VCDReadToc: Read the Table of Contents and fill p_vcd.
* the read information *
*****************************************************************************/
*****************************************************************************/
int
VCDReadToc
(
thread_vcd_data_t
*
p_vcd
)
int
read_toc
(
thread_vcd_data_t
*
p_vcd
)
{
{
int
i
;
int
i
;
struct
cdrom_tochdr
tochdr
;
struct
cdrom_tochdr
tochdr
;
struct
cdrom_tocentry
tocent
;
struct
cdrom_tocentry
tocent
;
int
fd
=
p_vcd
->
vcdhandle
;
/*
f
irst we read the TOC header */
/*
F
irst we read the TOC header */
if
(
ioctl
(
fd
,
CDROMREADTOCHDR
,
&
tochdr
)
==
-
1
)
if
(
ioctl
(
p_vcd
->
i_handle
,
CDROMREADTOCHDR
,
&
tochdr
)
==
-
1
)
{
{
intf_ErrMsg
(
"problem occured when reading CD's TOCHDR
\n
"
)
;
intf_ErrMsg
(
"vcd error: could not read TOCHDR"
)
;
return
-
1
;
return
-
1
;
}
}
p_vcd
->
nb_tracks
=
tochdr
.
cdth_trk1
;
p_vcd
->
nb_tracks
=
tochdr
.
cdth_trk1
-
tochdr
.
cdth_trk0
+
1
;
/* nb_tracks + 1 because we put the lead_out tracks for computing last
/* nb_tracks + 1 because we put the lead_out tracks for computing last
track's size */
* track's size */
p_vcd
->
tracks_sector
=
malloc
(
(
p_vcd
->
nb_tracks
+
1
)
p_vcd
->
p_sectors
=
malloc
(
(
p_vcd
->
nb_tracks
+
1
)
*
sizeof
(
int
)
);
*
sizeof
(
int
)
);
if
(
p_vcd
->
p_sectors
==
NULL
)
if
(
p_vcd
->
tracks_sector
==
NULL
)
{
{
intf_ErrMsg
(
"could not malloc tracks_sector"
);
intf_ErrMsg
(
"vcd error: could not allocate p_sectors"
);
return
-
1
;
return
-
1
;
}
}
/* then for each track we read its TOC entry */
/* Fill the p_sectors structure with the track/sector matches */
for
(
i
=
0
;
i
<=
p_vcd
->
nb_tracks
;
i
++
)
for
(
i
=
tochdr
.
cdth_trk0
;
i
<=
tochdr
.
cdth_trk1
;
i
++
)
{
{
tocent
.
cdte_track
=
i
;
tocent
.
cdte_format
=
CDROM_LBA
;
tocent
.
cdte_format
=
CDROM_LBA
;
if
(
ioctl
(
fd
,
CDROMREADTOCENTRY
,
&
tocent
)
==
-
1
)
tocent
.
cdte_track
=
(
i
==
p_vcd
->
nb_tracks
)
?
CDROM_LEADOUT
:
tochdr
.
cdth_trk0
+
i
;
if
(
ioctl
(
p_vcd
->
i_handle
,
CDROMREADTOCENTRY
,
&
tocent
)
==
-
1
)
{
{
intf_ErrMsg
(
"problem occured when reading CD's TOCENTRY
\n
"
);
intf_ErrMsg
(
"vcd error: could not read TOCENTRY
"
);
free
(
p_vcd
->
tracks_sector
);
free
(
p_vcd
->
p_sectors
);
return
-
1
;
return
-
1
;
}
}
p_vcd
->
tracks_sector
[
i
-
1
]
=
tocent
.
cdte_addr
.
lba
;
p_vcd
->
p_sectors
[
i
]
=
tocent
.
cdte_addr
.
lba
;
}
/* finally we read the lead-out track toc entry */
tocent
.
cdte_track
=
CDROM_LEADOUT
;
tocent
.
cdte_format
=
CDROM_LBA
;
if
(
ioctl
(
fd
,
CDROMREADTOCENTRY
,
&
tocent
)
==
-
1
)
{
intf_ErrMsg
(
"problem occured when readind CD's
lead-out track TOC entry"
)
;
free
(
p_vcd
->
tracks_sector
)
;
return
-
1
;
}
}
p_vcd
->
tracks_sector
[
p_vcd
->
nb_tracks
]
=
tocent
.
cdte_addr
.
lba
;
return
1
;
return
1
;
}
}
/****************************************************************************
/****************************************************************************
* VCD
_sector_read : Function that reads a sector (2324 bytes) from VCD
* VCD
ReadSector: Read a sector (2324 bytes)
****************************************************************************/
****************************************************************************/
int
VCD
_sector_read
(
struct
thread_vcd_data_s
*
p_vcd
,
byte_t
*
p_buffer
)
int
VCD
ReadSector
(
struct
thread_vcd_data_s
*
p_vcd
,
byte_t
*
p_buffer
)
{
{
byte_t
p_read_block
[
VCD_SECTOR_SIZE
]
;
byte_t
p_block
[
VCD_SECTOR_SIZE
]
;
struct
cdrom_msf0
msf_cursor
;
int
i_dummy
=
p_vcd
->
i_sector
+
2
*
CD_FRAMES
;
lba2msf
(
&
msf_cursor
,
p_vcd
->
current_sector
)
;
#define p_msf ((struct cdrom_msf0 *)p_block)
p_msf
->
minute
=
i_dummy
/
(
CD_FRAMES
*
CD_SECS
);
p_msf
->
second
=
(
i_dummy
%
(
CD_FRAMES
*
CD_SECS
)
)
/
CD_FRAMES
;
p_msf
->
frame
=
(
i_dummy
%
(
CD_FRAMES
*
CD_SECS
)
)
%
CD_FRAMES
;
#undef p_msf
#ifdef DEBUG
#ifdef DEBUG
intf_DbgMsg
(
"Playing frame %d:%d-%d
\n
"
,
msf_cursor
.
minute
,
intf_DbgMsg
(
"vcd debug: playing frame %d:%d-%d"
,
msf_cursor
.
second
,
msf_cursor
.
frame
)
;
p_msf
->
minute
,
p_msf
->
second
,
p_msf
->
frame
)
;
#endif
#endif
memcpy
(
p_read_block
,
&
msf_cursor
,
sizeof
(
struct
cdrom_msf0
))
;
if
(
ioctl
(
p_vcd
->
i_handle
,
CDROMREADRAW
,
p_block
)
==
-
1
)
if
(
ioctl
(
p_vcd
->
vcdhandle
,
CDROMREADRAW
,
p_read_block
)
==
-
1
)
{
{
intf_ErrMsg
(
"problem occured when reading CD"
)
;
intf_ErrMsg
(
"vcd error: could not read block from disc"
);
free
(
p_read_block
)
;
return
-
1
;
return
-
1
;
}
}
/* we don't want to keep the header of the read sector */
/* We don't want to keep the header of the read sector */
memcpy
(
p_buffer
,
&
p_read_block
[
VCD_DATA_START
],
p_main
->
fast_memcpy
(
p_buffer
,
p_block
+
VCD_DATA_START
,
VCD_DATA_SIZE
);
VCD_DATA_SIZE
);
p_vcd
->
current_sector
++
;
p_vcd
->
i_sector
++
;
if
(
p_vcd
->
current_sector
==
if
(
p_vcd
->
i_sector
>=
p_vcd
->
p_sectors
[
p_vcd
->
i_track
+
1
]
)
p_vcd
->
tracks_sector
[
p_vcd
->
current_track
+
1
]
)
{
{
p_vcd
->
b_end_of_track
=
1
;
p_vcd
->
b_end_of_track
=
1
;
}
}
...
@@ -180,20 +160,3 @@ int VCD_sector_read ( struct thread_vcd_data_s * p_vcd, byte_t * p_buffer )
...
@@ -180,20 +160,3 @@ int VCD_sector_read ( struct thread_vcd_data_s * p_vcd, byte_t * p_buffer )
return
1
;
return
1
;
}
}
/*****************************************************************************
* lba2msf : converts a logical block address into a minute/second/frame
* address.
*****************************************************************************/
static
void
lba2msf
(
struct
cdrom_msf0
*
p_msf
,
int
lba
)
{
/* we add 2*CD_FRAMES since the 2 first seconds are not played */
p_msf
->
minute
=
(
lba
+
2
*
CD_FRAMES
)
/
(
CD_FRAMES
*
CD_SECS
)
;
p_msf
->
second
=
(
(
lba
+
2
*
CD_FRAMES
)
%
(
CD_FRAMES
*
CD_SECS
)
)
/
CD_FRAMES
;
p_msf
->
frame
=
(
(
lba
+
2
*
CD_FRAMES
)
%
(
CD_FRAMES
*
CD_SECS
)
)
%
CD_FRAMES
;
}
plugins/vcd/linux_cdrom_tools.h
View file @
3475fc64
...
@@ -36,7 +36,6 @@
...
@@ -36,7 +36,6 @@
/******************************************************************************
/******************************************************************************
* Prototypes *
* Prototypes *
******************************************************************************/
******************************************************************************/
int
VCDReadToc
(
struct
thread_vcd_data_s
*
);
int
read_toc
(
struct
thread_vcd_data_s
*
);
int
VCDReadSector
(
struct
thread_vcd_data_s
*
,
byte_t
*
);
int
VCD_sector_read
(
struct
thread_vcd_data_s
*
,
byte_t
*
)
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment