Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
4bfba26a
Commit
4bfba26a
authored
Aug 20, 2009
by
Pierre d'Herbemont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vlc_bits: Differentiate between writable bits stream and read only.
This fixes some const qualifier violation in modules.
parent
7ca02b97
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
505 additions
and
457 deletions
+505
-457
include/vlc_bits.h
include/vlc_bits.h
+67
-19
modules/codec/cvdsub.c
modules/codec/cvdsub.c
+5
-5
modules/codec/dvbsub.c
modules/codec/dvbsub.c
+338
-338
modules/codec/svcdsub.c
modules/codec/svcdsub.c
+6
-6
modules/packetizer/mpeg4audio.c
modules/packetizer/mpeg4audio.c
+89
-89
No files found.
include/vlc_bits.h
View file @
4bfba26a
...
...
@@ -30,15 +30,25 @@
*/
typedef
struct
bs_s
{
const
uint8_t
*
p_start
;
const
uint8_t
*
p
;
const
uint8_t
*
p_end
;
unsigned
i_left
;
/* i_count number of available bits */
}
bs_t
;
typedef
struct
bs_writable_s
{
uint8_t
*
p_start
;
uint8_t
*
p
;
uint8_t
*
p_end
;
unsigned
i_left
;
/* i_count number of available bits */
}
bsw_t
;
int
i_left
;
/* i_count number of available bits */
}
bs_t
;
static
inline
void
bs_init
(
bs_t
*
s
,
void
*
p_data
,
int
i_data
)
static
inline
void
bs_init
(
bs_t
*
s
,
const
void
*
p_data
,
unsigned
i_data
)
{
s
->
p_start
=
p_data
;
s
->
p
=
p_data
;
...
...
@@ -141,25 +151,67 @@ static inline void bs_skip( bs_t *s, int i_count )
}
}
static
inline
void
bs_write
(
bs_t
*
s
,
int
i_count
,
uint32_t
i_bits
)
/*
* Writable bits stream
*/
static
inline
void
bsw_init_writable
(
bsw_t
*
s
,
void
*
p_data
,
unsigned
i_data
)
{
s
->
p_start
=
p_data
;
s
->
p
=
p_data
;
s
->
p_end
=
s
->
p
+
i_data
;
s
->
i_left
=
8
;
}
static
inline
bs_t
*
bs_from_writable
(
bsw_t
*
s
)
{
return
(
bs_t
*
)
s
;
}
static
inline
void
bsw_skip
(
bsw_t
*
s
,
int
count
)
{
return
bs_skip
(
bs_from_writable
(
s
),
count
);
}
static
inline
uint32_t
bsw_show
(
bsw_t
*
s
,
int
count
)
{
return
bs_show
(
bs_from_writable
(
s
),
count
);
}
static
inline
uint32_t
bsw_read1
(
bsw_t
*
s
)
{
return
bs_read1
(
bs_from_writable
(
s
));
}
static
inline
uint32_t
bsw_read
(
bsw_t
*
s
,
int
count
)
{
return
bs_read
(
bs_from_writable
(
s
),
count
);
}
static
inline
int
bsw_pos
(
bsw_t
*
s
)
{
return
bs_pos
(
bs_from_writable
(
s
));
}
static
inline
int
bsw_eof
(
bsw_t
*
s
)
{
return
bs_eof
(
bs_from_writable
(
s
));
}
static
inline
void
bsw_write
(
bsw_t
*
s
,
int
i_count
,
uint32_t
i_bits
)
{
while
(
i_count
>
0
)
{
if
(
s
->
p
>=
s
->
p_end
)
{
break
;
}
i_count
--
;
if
(
(
i_bits
>>
i_count
)
&
0x01
)
{
*
s
->
p
|=
1
<<
(
s
->
i_left
-
1
);
}
else
{
*
s
->
p
&=
~
(
1
<<
(
s
->
i_left
-
1
)
);
}
s
->
i_left
--
;
if
(
s
->
i_left
==
0
)
{
...
...
@@ -169,7 +221,7 @@ static inline void bs_write( bs_t *s, int i_count, uint32_t i_bits )
}
}
static
inline
void
bs
_align
(
bs
_t
*
s
)
static
inline
void
bs
w_align
(
bsw
_t
*
s
)
{
if
(
s
->
i_left
!=
8
)
{
...
...
@@ -178,20 +230,16 @@ static inline void bs_align( bs_t *s )
}
}
static
inline
void
bs
_align_0
(
bs
_t
*
s
)
static
inline
void
bs
w_align_0
(
bsw
_t
*
s
)
{
if
(
s
->
i_left
!=
8
)
{
bs_write
(
s
,
s
->
i_left
,
0
);
}
bsw_write
(
s
,
s
->
i_left
,
0
);
}
static
inline
void
bs
_align_1
(
bs
_t
*
s
)
static
inline
void
bs
w_align_1
(
bsw
_t
*
s
)
{
while
(
s
->
i_left
!=
8
)
{
bs_write
(
s
,
1
,
1
);
}
bsw_write
(
s
,
1
,
1
);
}
#endif
modules/codec/cvdsub.c
View file @
4bfba26a
...
...
@@ -573,9 +573,9 @@ static void RenderImage( decoder_t *p_dec, block_t *p_data,
int
i_field
;
/* The subtitles are interlaced */
int
i_row
,
i_column
;
/* scanline row/column number */
uint8_t
i_color
,
i_count
;
bs
_t
bs
;
bs
w_t
bsw
;
bs
_init
(
&
bs
,
p_data
->
p_buffer
+
p_sys
->
i_image_offset
,
bs
w_init_writable
(
&
bsw
,
p_data
->
p_buffer
+
p_sys
->
i_image_offset
,
p_data
->
i_buffer
-
p_sys
->
i_image_offset
);
for
(
i_field
=
0
;
i_field
<
2
;
i_field
++
)
...
...
@@ -584,12 +584,12 @@ static void RenderImage( decoder_t *p_dec, block_t *p_data,
{
for
(
i_column
=
0
;
i_column
<
p_sys
->
i_width
;
i_column
++
)
{
uint8_t
i_val
=
bs
_read
(
&
bs
,
4
);
uint8_t
i_val
=
bs
w_read
(
&
bsw
,
4
);
if
(
i_val
==
0
)
{
/* Fill the rest of the line with next color */
i_color
=
bs
_read
(
&
bs
,
4
);
i_color
=
bs
w_read
(
&
bsw
,
4
);
memset
(
&
p_dest
[
i_row
*
p_region
->
p_picture
->
Y_PITCH
+
i_column
],
i_color
,
...
...
@@ -612,7 +612,7 @@ static void RenderImage( decoder_t *p_dec, block_t *p_data,
}
}
bs
_align
(
&
bs
);
bs
w_align
(
&
bsw
);
}
}
}
modules/codec/dvbsub.c
View file @
4bfba26a
...
...
@@ -218,7 +218,7 @@ typedef struct
struct
decoder_sys_t
{
bs_t
bs
;
bs
w
_t
bs
;
/* Decoder internal data */
int
i_id
;
...
...
@@ -270,12 +270,12 @@ struct decoder_sys_t
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static
void
decode_segment
(
decoder_t
*
,
bs_t
*
);
static
void
decode_page_composition
(
decoder_t
*
,
bs_t
*
);
static
void
decode_region_composition
(
decoder_t
*
,
bs_t
*
);
static
void
decode_object
(
decoder_t
*
,
bs_t
*
);
static
void
decode_display_definition
(
decoder_t
*
,
bs_t
*
);
static
void
decode_clut
(
decoder_t
*
,
bs_t
*
);
static
void
decode_segment
(
decoder_t
*
,
bs
w
_t
*
);
static
void
decode_page_composition
(
decoder_t
*
,
bs
w
_t
*
);
static
void
decode_region_composition
(
decoder_t
*
,
bs
w
_t
*
);
static
void
decode_object
(
decoder_t
*
,
bs
w
_t
*
);
static
void
decode_display_definition
(
decoder_t
*
,
bs
w
_t
*
);
static
void
decode_clut
(
decoder_t
*
,
bs
w
_t
*
);
static
void
free_all
(
decoder_t
*
);
static
void
default_clut_init
(
decoder_t
*
);
...
...
@@ -388,16 +388,16 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
return
NULL
;
}
bs
_init
(
&
p_sys
->
bs
,
p_block
->
p_buffer
,
p_block
->
i_buffer
);
bs
w_init_writable
(
&
p_sys
->
bs
,
p_block
->
p_buffer
,
p_block
->
i_buffer
);
if
(
bs_read
(
&
p_sys
->
bs
,
8
)
!=
0x20
)
/* Data identifier */
if
(
bs
w
_read
(
&
p_sys
->
bs
,
8
)
!=
0x20
)
/* Data identifier */
{
msg_Dbg
(
p_dec
,
"invalid data identifier"
);
block_Release
(
p_block
);
return
NULL
;
}
if
(
bs_read
(
&
p_sys
->
bs
,
8
)
)
/* Subtitle stream id */
if
(
bs
w
_read
(
&
p_sys
->
bs
,
8
)
)
/* Subtitle stream id */
{
msg_Dbg
(
p_dec
,
"invalid subtitle stream id"
);
block_Release
(
p_block
);
...
...
@@ -409,12 +409,12 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
#endif
p_sys
->
b_page
=
false
;
while
(
bs_show
(
&
p_sys
->
bs
,
8
)
==
0x0f
)
/* Sync byte */
while
(
bs
w
_show
(
&
p_sys
->
bs
,
8
)
==
0x0f
)
/* Sync byte */
{
decode_segment
(
p_dec
,
&
p_sys
->
bs
);
}
if
(
bs_read
(
&
p_sys
->
bs
,
8
)
!=
0xff
)
/* End marker */
if
(
bs
w
_read
(
&
p_sys
->
bs
,
8
)
!=
0xff
)
/* End marker */
{
msg_Warn
(
p_dec
,
"end marker not found (corrupted subtitle ?)"
);
block_Release
(
p_block
);
...
...
@@ -495,7 +495,7 @@ static void default_clut_init( decoder_t *p_dec )
memset
(
p_sys
->
default_clut
.
c_8b
,
0xFF
,
256
*
sizeof
(
dvbsub_color_t
)
);
}
static
void
decode_segment
(
decoder_t
*
p_dec
,
bs_t
*
s
)
static
void
decode_segment
(
decoder_t
*
p_dec
,
bs
w
_t
*
s
)
{
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
int
i_type
;
...
...
@@ -503,16 +503,16 @@ static void decode_segment( decoder_t *p_dec, bs_t *s )
int
i_size
;
/* sync_byte (already checked) */
bs_skip
(
s
,
8
);
bs
w
_skip
(
s
,
8
);
/* segment type */
i_type
=
bs_read
(
s
,
8
);
i_type
=
bs
w
_read
(
s
,
8
);
/* page id */
i_page_id
=
bs_read
(
s
,
16
);
i_page_id
=
bs
w
_read
(
s
,
16
);
/* segment size */
i_size
=
bs_show
(
s
,
16
);
i_size
=
bs
w
_show
(
s
,
16
);
if
(
(
i_page_id
!=
p_sys
->
i_id
)
&&
(
i_page_id
!=
p_sys
->
i_ancillary_id
)
)
...
...
@@ -521,7 +521,7 @@ static void decode_segment( decoder_t *p_dec, bs_t *s )
msg_Dbg
(
p_dec
,
"subtitle skipped (page id: %i, %i)"
,
i_page_id
,
p_sys
->
i_id
);
#endif
bs_skip
(
s
,
8
*
(
2
+
i_size
)
);
bs
w
_skip
(
s
,
8
*
(
2
+
i_size
)
);
return
;
}
...
...
@@ -532,7 +532,7 @@ static void decode_segment( decoder_t *p_dec, bs_t *s )
#ifdef DEBUG_DVBSUB
msg_Dbg
(
p_dec
,
"skipped invalid ancillary subtitle packet"
);
#endif
bs_skip
(
s
,
8
*
(
2
+
i_size
)
);
bs
w
_skip
(
s
,
8
*
(
2
+
i_size
)
);
return
;
}
...
...
@@ -584,24 +584,24 @@ static void decode_segment( decoder_t *p_dec, bs_t *s )
#ifdef DEBUG_DVBSUB
msg_Dbg
(
p_dec
,
"end of display"
);
#endif
bs_skip
(
s
,
8
*
(
2
+
i_size
)
);
bs
w
_skip
(
s
,
8
*
(
2
+
i_size
)
);
break
;
case
DVBSUB_ST_STUFFING
:
#ifdef DEBUG_DVBSUB
msg_Dbg
(
p_dec
,
"skip stuffing"
);
#endif
bs_skip
(
s
,
8
*
(
2
+
i_size
)
);
bs
w
_skip
(
s
,
8
*
(
2
+
i_size
)
);
break
;
default:
msg_Warn
(
p_dec
,
"unsupported segment type: (%04x)"
,
i_type
);
bs_skip
(
s
,
8
*
(
2
+
i_size
)
);
bs
w
_skip
(
s
,
8
*
(
2
+
i_size
)
);
break
;
}
}
static
void
decode_clut
(
decoder_t
*
p_dec
,
bs_t
*
s
)
static
void
decode_clut
(
decoder_t
*
p_dec
,
bs
w
_t
*
s
)
{
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
uint16_t
i_segment_length
;
...
...
@@ -609,9 +609,9 @@ static void decode_clut( decoder_t *p_dec, bs_t *s )
dvbsub_clut_t
*
p_clut
,
*
p_next
;
int
i_id
,
i_version
;
i_segment_length
=
bs_read
(
s
,
16
);
i_id
=
bs_read
(
s
,
8
);
i_version
=
bs_read
(
s
,
4
);
i_segment_length
=
bs
w
_read
(
s
,
16
);
i_id
=
bs
w
_read
(
s
,
8
);
i_version
=
bs
w
_read
(
s
,
4
);
/* Check if we already have this clut */
for
(
p_clut
=
p_sys
->
p_cluts
;
p_clut
!=
NULL
;
p_clut
=
p_clut
->
p_next
)
...
...
@@ -623,7 +623,7 @@ static void decode_clut( decoder_t *p_dec, bs_t *s )
if
(
p_clut
&&
(
p_clut
->
i_version
==
i_version
)
)
{
/* Nothing to do */
bs_skip
(
s
,
8
*
i_segment_length
-
12
);
bs
w
_skip
(
s
,
8
*
i_segment_length
-
12
);
return
;
}
...
...
@@ -647,7 +647,7 @@ static void decode_clut( decoder_t *p_dec, bs_t *s )
/* We don't have this version of the CLUT: Parse it */
p_clut
->
i_version
=
i_version
;
p_clut
->
i_id
=
i_id
;
bs_skip
(
s
,
4
);
/* Reserved bits */
bs
w
_skip
(
s
,
4
);
/* Reserved bits */
i_processed_length
=
2
;
while
(
i_processed_length
<
i_segment_length
)
{
...
...
@@ -655,25 +655,25 @@ static void decode_clut( decoder_t *p_dec, bs_t *s )
uint8_t
i_id
;
uint8_t
i_type
;
i_id
=
bs_read
(
s
,
8
);
i_type
=
bs_read
(
s
,
3
);
i_id
=
bs
w
_read
(
s
,
8
);
i_type
=
bs
w
_read
(
s
,
3
);
bs_skip
(
s
,
4
);
bs
w
_skip
(
s
,
4
);
if
(
bs_read
(
s
,
1
)
)
if
(
bs
w
_read
(
s
,
1
)
)
{
y
=
bs_read
(
s
,
8
);
cr
=
bs_read
(
s
,
8
);
cb
=
bs_read
(
s
,
8
);
t
=
bs_read
(
s
,
8
);
y
=
bs
w
_read
(
s
,
8
);
cr
=
bs
w
_read
(
s
,
8
);
cb
=
bs
w
_read
(
s
,
8
);
t
=
bs
w
_read
(
s
,
8
);
i_processed_length
+=
6
;
}
else
{
y
=
bs_read
(
s
,
6
)
<<
2
;
cr
=
bs_read
(
s
,
4
)
<<
4
;
cb
=
bs_read
(
s
,
4
)
<<
4
;
t
=
bs_read
(
s
,
2
)
<<
6
;
y
=
bs
w
_read
(
s
,
6
)
<<
2
;
cr
=
bs
w
_read
(
s
,
4
)
<<
4
;
cb
=
bs
w
_read
(
s
,
4
)
<<
4
;
t
=
bs
w
_read
(
s
,
2
)
<<
6
;
i_processed_length
+=
4
;
}
...
...
@@ -713,17 +713,17 @@ static void decode_clut( decoder_t *p_dec, bs_t *s )
}
}
static
void
decode_page_composition
(
decoder_t
*
p_dec
,
bs_t
*
s
)
static
void
decode_page_composition
(
decoder_t
*
p_dec
,
bs
w
_t
*
s
)
{
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
int
i_version
,
i_state
,
i_segment_length
,
i_timeout
,
i
;
/* A page is composed by 0 or more region */
i_segment_length
=
bs_read
(
s
,
16
);
i_timeout
=
bs_read
(
s
,
8
);
i_version
=
bs_read
(
s
,
4
);
i_state
=
bs_read
(
s
,
2
);
bs_skip
(
s
,
2
);
/* Reserved */
i_segment_length
=
bs
w
_read
(
s
,
16
);
i_timeout
=
bs
w
_read
(
s
,
8
);
i_version
=
bs
w
_read
(
s
,
4
);
i_state
=
bs
w
_read
(
s
,
2
);
bs
w
_skip
(
s
,
2
);
/* Reserved */
if
(
i_state
==
DVBSUB_PCS_STATE_CHANGE
)
{
...
...
@@ -741,7 +741,7 @@ static void decode_page_composition( decoder_t *p_dec, bs_t *s )
#if 0
/* Try to start decoding even without an acquisition page */
bs_skip( s, 8 * (i_segment_length - 2) );
bs
w
_skip( s, 8 * (i_segment_length - 2) );
return;
#endif
}
...
...
@@ -754,7 +754,7 @@ static void decode_page_composition( decoder_t *p_dec, bs_t *s )
/* Check version number */
if
(
p_sys
->
p_page
&&
(
p_sys
->
p_page
->
i_version
==
i_version
)
)
{
bs_skip
(
s
,
8
*
(
i_segment_length
-
2
)
);
bs
w
_skip
(
s
,
8
*
(
i_segment_length
-
2
)
);
return
;
}
else
if
(
p_sys
->
p_page
)
...
...
@@ -791,10 +791,10 @@ static void decode_page_composition( decoder_t *p_dec, bs_t *s )
{
for
(
i
=
0
;
i
<
p_sys
->
p_page
->
i_region_defs
;
i
++
)
{
p_sys
->
p_page
->
p_region_defs
[
i
].
i_id
=
bs_read
(
s
,
8
);
bs_skip
(
s
,
8
);
/* Reserved */
p_sys
->
p_page
->
p_region_defs
[
i
].
i_x
=
bs_read
(
s
,
16
);
p_sys
->
p_page
->
p_region_defs
[
i
].
i_y
=
bs_read
(
s
,
16
);
p_sys
->
p_page
->
p_region_defs
[
i
].
i_id
=
bs
w
_read
(
s
,
8
);
bs
w
_skip
(
s
,
8
);
/* Reserved */
p_sys
->
p_page
->
p_region_defs
[
i
].
i_x
=
bs
w
_read
(
s
,
16
);
p_sys
->
p_page
->
p_region_defs
[
i
].
i_y
=
bs
w
_read
(
s
,
16
);
#ifdef DEBUG_DVBSUB
msg_Dbg
(
p_dec
,
"page_composition, region %i (%i,%i)"
,
...
...
@@ -805,7 +805,7 @@ static void decode_page_composition( decoder_t *p_dec, bs_t *s )
}
}
static
void
decode_region_composition
(
decoder_t
*
p_dec
,
bs_t
*
s
)
static
void
decode_region_composition
(
decoder_t
*
p_dec
,
bs
w
_t
*
s
)
{
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
dvbsub_region_t
*
p_region
,
**
pp_region
=
&
p_sys
->
p_regions
;
...
...
@@ -814,9 +814,9 @@ static void decode_region_composition( decoder_t *p_dec, bs_t *s )
int
i_8_bg
,
i_4_bg
,
i_2_bg
;
bool
b_fill
;
i_segment_length
=
bs_read
(
s
,
16
);
i_id
=
bs_read
(
s
,
8
);
i_version
=
bs_read
(
s
,
4
);
i_segment_length
=
bs
w
_read
(
s
,
16
);
i_id
=
bs
w
_read
(
s
,
8
);
i_version
=
bs
w
_read
(
s
,
4
);
/* Check if we already have this region */
for
(
p_region
=
p_sys
->
p_regions
;
p_region
!=
NULL
;
...
...
@@ -829,7 +829,7 @@ static void decode_region_composition( decoder_t *p_dec, bs_t *s )
/* Check version number */
if
(
p_region
&&
(
p_region
->
i_version
==
i_version
)
)
{
bs_skip
(
s
,
8
*
(
i_segment_length
-
1
)
-
4
);
bs
w
_skip
(
s
,
8
*
(
i_segment_length
-
1
)
-
4
);
return
;
}
...
...
@@ -850,23 +850,23 @@ static void decode_region_composition( decoder_t *p_dec, bs_t *s )
/* Region attributes */
p_region
->
i_id
=
i_id
;
p_region
->
i_version
=
i_version
;
b_fill
=
bs_read
(
s
,
1
);
bs_skip
(
s
,
3
);
/* Reserved */
b_fill
=
bs
w
_read
(
s
,
1
);
bs
w
_skip
(
s
,
3
);
/* Reserved */
i_width
=
bs_read
(
s
,
16
);
i_height
=
bs_read
(
s
,
16
);
i_width
=
bs
w
_read
(
s
,
16
);
i_height
=
bs
w
_read
(
s
,
16
);
#ifdef DEBUG_DVBSUB
msg_Dbg
(
p_dec
,
" width=%d height=%d"
,
i_width
,
i_height
);
#endif
i_level_comp
=
bs_read
(
s
,
3
);
i_depth
=
bs_read
(
s
,
3
);
bs_skip
(
s
,
2
);
/* Reserved */
i_clut
=
bs_read
(
s
,
8
);
i_level_comp
=
bs
w
_read
(
s
,
3
);
i_depth
=
bs
w
_read
(
s
,
3
);
bs
w
_skip
(
s
,
2
);
/* Reserved */
i_clut
=
bs
w
_read
(
s
,
8
);
i_8_bg
=
bs_read
(
s
,
8
);
i_4_bg
=
bs_read
(
s
,
4
);
i_2_bg
=
bs_read
(
s
,
2
);
bs_skip
(
s
,
2
);
/* Reserved */
i_8_bg
=
bs
w
_read
(
s
,
8
);
i_4_bg
=
bs
w
_read
(
s
,
4
);
i_2_bg
=
bs
w
_read
(
s
,
2
);
bs
w
_skip
(
s
,
2
);
/* Reserved */
/* Free old object defs */
while
(
p_region
->
i_object_defs
)
...
...
@@ -926,12 +926,12 @@ static void decode_region_composition( decoder_t *p_dec, bs_t *s )
/* We parse object properties */
p_obj
=
&
p_region
->
p_object_defs
[
p_region
->
i_object_defs
-
1
];
p_obj
->
i_id
=
bs_read
(
s
,
16
);
p_obj
->
i_type
=
bs_read
(
s
,
2
);
bs_skip
(
s
,
2
);
/* Provider */
p_obj
->
i_x
=
bs_read
(
s
,
12
);
bs_skip
(
s
,
4
);
/* Reserved */
p_obj
->
i_y
=
bs_read
(
s
,
12
);
p_obj
->
i_id
=
bs
w
_read
(
s
,
16
);
p_obj
->
i_type
=
bs
w
_read
(
s
,
2
);
bs
w
_skip
(
s
,
2
);
/* Provider */
p_obj
->
i_x
=
bs
w
_read
(
s
,
12
);
bs
w
_skip
(
s
,
4
);
/* Reserved */
p_obj
->
i_y
=
bs
w
_read
(
s
,
12
);
p_obj
->
psz_text
=
NULL
;
i_processed_length
+=
6
;
...
...
@@ -939,15 +939,15 @@ static void decode_region_composition( decoder_t *p_dec, bs_t *s )
if
(
(
p_obj
->
i_type
==
DVBSUB_OT_BASIC_CHAR
)
||
(
p_obj
->
i_type
==
DVBSUB_OT_COMPOSITE_STRING
)
)
{
p_obj
->
i_fg_pc
=
bs_read
(
s
,
8
);
p_obj
->
i_bg_pc
=
bs_read
(
s
,
8
);
p_obj
->
i_fg_pc
=
bs
w
_read
(
s
,
8
);
p_obj
->
i_bg_pc
=
bs
w
_read
(
s
,
8
);
i_processed_length
+=
2
;
}
}
}
/* ETSI 300 743 [7.2.1] */
static
void
decode_display_definition
(
decoder_t
*
p_dec
,
bs_t
*
s
)
static
void
decode_display_definition
(
decoder_t
*
p_dec
,
bs
w
_t
*
s
)
{
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
uint16_t
i_segment_length
;
...
...
@@ -956,14 +956,14 @@ static void decode_display_definition( decoder_t *p_dec, bs_t *s )
dvbsub_display_t
*
p_old
=
p_sys
->
p_display
;
int
i_version
;
i_segment_length
=
bs_read
(
s
,
16
);
i_version
=
bs_read
(
s
,
4
);
i_segment_length
=
bs
w
_read
(
s
,
16
);
i_version
=
bs
w
_read
(
s
,
4
);
/* Check version number */
if
(
p_old
&&
(
p_old
->
i_version
==
i_version
)
)
{
/* The definition did not change */
bs_skip
(
s
,
8
*
i_segment_length
-
4
);
bs
w
_skip
(
s
,
8
*
i_segment_length
-
4
);
return
;
}
...
...
@@ -975,10 +975,10 @@ static void decode_display_definition( decoder_t *p_dec, bs_t *s )
{
/* We don't have this version of the display definition: Parse it */
p_display
->
i_version
=
i_version
;
p_display
->
b_windowed
=
bs_read
(
s
,
1
);
bs_skip
(
s
,
3
);
/* Reserved bits */
p_display
->
i_width
=
bs_read
(
s
,
16
)
+
1
;
p_display
->
i_height
=
bs_read
(
s
,
16
)
+
1
;
p_display
->
b_windowed
=
bs
w
_read
(
s
,
1
);
bs
w
_skip
(
s
,
3
);
/* Reserved bits */
p_display
->
i_width
=
bs
w
_read
(
s
,
16
)
+
1
;
p_display
->
i_height
=
bs
w
_read
(
s
,
16
)
+
1
;
if
(
p_display
->
b_windowed
)
{
...
...
@@ -986,10 +986,10 @@ static void decode_display_definition( decoder_t *p_dec, bs_t *s )
msg_Dbg
(
p_dec
,
"display definition with offsets (windowed)"
);
#endif
/* Coordinates are measured from the top left corner */
p_display
->
i_x
=
bs_read
(
s
,
16
);
p_display
->
i_max_x
=
bs_read
(
s
,
16
);
p_display
->
i_y
=
bs_read
(
s
,
16
);
p_display
->
i_max_y
=
bs_read
(
s
,
16
);
p_display
->
i_x
=
bs
w
_read
(
s
,
16
);
p_display
->
i_max_x
=
bs
w
_read
(
s
,
16
);
p_display
->
i_y
=
bs
w
_read
(
s
,
16
);
p_display
->
i_max_y
=
bs
w
_read
(
s
,
16
);
i_processed_length
+=
64
;
}
}
...
...
@@ -1014,11 +1014,11 @@ static void decode_display_definition( decoder_t *p_dec, bs_t *s )
static
void
dvbsub_render_pdata
(
decoder_t
*
,
dvbsub_region_t
*
,
int
,
int
,
uint8_t
*
,
int
);
static
void
dvbsub_pdata2bpp
(
bs_t
*
,
uint8_t
*
,
int
,
int
*
);
static
void
dvbsub_pdata4bpp
(
bs_t
*
,
uint8_t
*
,
int
,
int
*
);
static
void
dvbsub_pdata8bpp
(
bs_t
*
,
uint8_t
*
,
int
,
int
*
);
static
void
dvbsub_pdata2bpp
(
bs
w
_t
*
,
uint8_t
*
,
int
,
int
*
);
static
void
dvbsub_pdata4bpp
(
bs
w
_t
*
,
uint8_t
*
,
int
,
int
*
);
static
void
dvbsub_pdata8bpp
(
bs
w
_t
*
,
uint8_t
*
,
int
,
int
*
);
static
void
decode_object
(
decoder_t
*
p_dec
,
bs_t
*
s
)
static
void
decode_object
(
decoder_t
*
p_dec
,
bs
w
_t
*
s
)
{
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
dvbsub_region_t
*
p_region
;
...
...
@@ -1028,15 +1028,15 @@ static void decode_object( decoder_t *p_dec, bs_t *s )
/* ETSI 300-743 paragraph 7.2.4
* sync_byte, segment_type and page_id have already been processed.
*/
i_segment_length
=
bs_read
(
s
,
16
);
i_id
=
bs_read
(
s
,
16
);
i_version
=
bs_read
(
s
,
4
);
i_coding_method
=
bs_read
(
s
,
2
);
i_segment_length
=
bs
w
_read
(
s
,
16
);
i_id
=
bs
w
_read
(
s
,
16
);
i_version
=
bs
w
_read
(
s
,
4
);
i_coding_method
=
bs
w
_read
(
s
,
2
);
if
(
i_coding_method
>
1
)
{
msg_Dbg
(
p_dec
,
"unknown DVB subtitling coding %d is not handled!"
,
i_coding_method
);
bs_skip
(
s
,
8
*
(
i_segment_length
-
2
)
-
6
);
bs
w
_skip
(
s
,
8
*
(
i_segment_length
-
2
)
-
6
);
return
;
}
...
...
@@ -1052,7 +1052,7 @@ static void decode_object( decoder_t *p_dec, bs_t *s )
}
if
(
!
p_region
)
{
bs_skip
(
s
,
8
*
(
i_segment_length
-
2
)
-
6
);
bs
w
_skip
(
s
,
8
*
(
i_segment_length
-
2
)
-
6
);
return
;
}
...
...
@@ -1060,20 +1060,20 @@ static void decode_object( decoder_t *p_dec, bs_t *s )
msg_Dbg
(
p_dec
,
"new object: %i"
,
i_id
);
#endif
b_non_modify_color
=
bs_read
(
s
,
1
);
bs_skip
(
s
,
1
);
/* Reserved */
b_non_modify_color
=
bs
w
_read
(
s
,
1
);
bs
w
_skip
(
s
,
1
);
/* Reserved */
if
(
i_coding_method
==
0x00
)
{
int
i_topfield
,
i_bottomfield
;
uint8_t
*
p_topfield
,
*
p_bottomfield
;
i_topfield
=
bs_read
(
s
,
16
);
i_bottomfield
=
bs_read
(
s
,
16
);
p_topfield
=
s
->
p_start
+
bs_pos
(
s
)
/
8
;
i_topfield
=
bs
w
_read
(
s
,
16
);
i_bottomfield
=
bs
w
_read
(
s
,
16
);
p_topfield
=
s
->
p_start
+
bs
w
_pos
(
s
)
/
8
;
p_bottomfield
=
p_topfield
+
i_topfield
;
bs_skip
(
s
,
8
*
(
i_segment_length
-
7
)
);
bs
w
_skip
(
s
,
8
*
(
i_segment_length
-
7
)
);
/* Sanity check */
if
(
(
i_segment_length
<
(
i_topfield
+
i_bottomfield
+
7
)
)
||
...
...
@@ -1116,8 +1116,8 @@ static void decode_object( decoder_t *p_dec, bs_t *s )
else
{
/* DVB subtitling as characters */
int
i_number_of_codes
=
bs_read
(
s
,
8
);
uint8_t
*
p_start
=
s
->
p_start
+
bs_pos
(
s
)
/
8
;
int
i_number_of_codes
=
bs
w
_read
(
s
,
8
);
uint8_t
*
p_start
=
s
->
p_start
+
bs
w
_pos
(
s
)
/
8
;
/* Sanity check */
if
(
(
i_segment_length
<
(
i_number_of_codes
*
2
+
4
)
)
||
...
...
@@ -1143,7 +1143,7 @@ static void decode_object( decoder_t *p_dec, bs_t *s )
/* FIXME 16bits -> char ??? See Preamble */
for
(
j
=
0
;
j
<
i_number_of_codes
;
j
++
)
{
p_region
->
p_object_defs
[
i
].
psz_text
[
j
]
=
(
char
)(
bs_read
(
s
,
16
)
&
0xFF
);
p_region
->
p_object_defs
[
i
].
psz_text
[
j
]
=
(
char
)(
bs
w
_read
(
s
,
16
)
&
0xFF
);
}
/* Null terminate the string */
p_region
->
p_object_defs
[
i
].
psz_text
[
j
]
=
0
;
...
...
@@ -1162,7 +1162,7 @@ static void dvbsub_render_pdata( decoder_t *p_dec, dvbsub_region_t *p_region,
{
uint8_t
*
p_pixbuf
;
int
i_offset
=
0
;
bs_t
bs
;
bs
w
_t
bs
;
/* Sanity check */
if
(
!
p_region
->
p_pixbuf
)
...
...
@@ -1178,14 +1178,14 @@ static void dvbsub_render_pdata( decoder_t *p_dec, dvbsub_region_t *p_region,
}
p_pixbuf
=
p_region
->
p_pixbuf
+
i_y
*
p_region
->
i_width
;
bs
_init
(
&
bs
,
p_field
,
i_field
);
bs
w_init_writable
(
&
bs
,
p_field
,
i_field
);
while
(
!
bs_eof
(
&
bs
)
)
while
(
!
bs
w
_eof
(
&
bs
)
)
{
/* Sanity check */
if
(
i_y
>=
p_region
->
i_height
)
return
;
switch
(
bs_read
(
&
bs
,
8
)
)
switch
(
bs
w
_read
(
&
bs
,
8
)
)
{
case
0x10
:
dvbsub_pdata2bpp
(
&
bs
,
p_pixbuf
+
i_x
,
p_region
->
i_width
-
i_x
,
...
...
@@ -1216,31 +1216,31 @@ static void dvbsub_render_pdata( decoder_t *p_dec, dvbsub_region_t *p_region,
}
}
static
void
dvbsub_pdata2bpp
(
bs_t
*
s
,
uint8_t
*
p
,
int
i_width
,
int
*
pi_off
)
static
void
dvbsub_pdata2bpp
(
bs
w
_t
*
s
,
uint8_t
*
p
,
int
i_width
,
int
*
pi_off
)
{
bool
b_stop
=
false
;
while
(
!
b_stop
&&
!
bs_eof
(
s
)
)
while
(
!
b_stop
&&
!
bs
w
_eof
(
s
)
)
{
int
i_count
=
0
,
i_color
=
0
;
i_color
=
bs_read
(
s
,
2
);
i_color
=
bs
w
_read
(
s
,
2
);
if
(
i_color
!=
0x00
)
{
i_count
=
1
;
}
else
{
if
(
bs_read
(
s
,
1
)
==
0x01
)
// Switch1
if
(
bs
w
_read
(
s
,
1
)
==
0x01
)
// Switch1
{
i_count
=
3
+
bs_read
(
s
,
3
);
i_color
=
bs_read
(
s
,
2
);
i_count
=
3
+
bs
w
_read
(
s
,
3
);
i_color
=
bs
w
_read
(
s
,
2
);
}
else
{
if
(
bs_read
(
s
,
1
)
==
0x00
)
//Switch2
if
(
bs
w
_read
(
s
,
1
)
==
0x00
)
//Switch2
{
switch
(
bs_read
(
s
,
2
)
)
//Switch3
switch
(
bs
w
_read
(
s
,
2
)
)
//Switch3
{
case
0x00
:
b_stop
=
true
;
...
...
@@ -1249,12 +1249,12 @@ static void dvbsub_pdata2bpp( bs_t *s, uint8_t *p, int i_width, int *pi_off )
i_count
=
2
;
break
;
case
0x02
:
i_count
=
12
+
bs_read
(
s
,
4
);
i_color
=
bs_read
(
s
,
2
);
i_count
=
12
+
bs
w
_read
(
s
,
4
);
i_color
=
bs
w
_read
(
s
,
2
);
break
;
case
0x03
:
i_count
=
29
+
bs_read
(
s
,
8
);
i_color
=
bs_read
(
s
,
2
);
i_count
=
29
+
bs
w
_read
(
s
,
8
);
i_color
=
bs
w
_read
(
s
,
2
);
break
;
default:
break
;
...
...
@@ -1279,18 +1279,18 @@ static void dvbsub_pdata2bpp( bs_t *s, uint8_t *p, int i_width, int *pi_off )
(
*
pi_off
)
+=
i_count
;
}
bs_align
(
s
);
bs
w
_align
(
s
);
}
static
void
dvbsub_pdata4bpp
(
bs_t
*
s
,
uint8_t
*
p
,
int
i_width
,
int
*
pi_off
)
static
void
dvbsub_pdata4bpp
(
bs
w
_t
*
s
,
uint8_t
*
p
,
int
i_width
,
int
*
pi_off
)
{
bool
b_stop
=
false
;
while
(
!
b_stop
&&
!
bs_eof
(
s
)
)
while
(
!
b_stop
&&
!
bs
w
_eof
(
s
)
)
{
int
i_count
=
0
,
i_color
=
0
;
i_color
=
bs_read
(
s
,
4
);
i_color
=
bs
w
_read
(
s
,
4
);
if
(
i_color
!=
0x00
)
{
/* Add 1 pixel */
...
...
@@ -1298,28 +1298,28 @@ static void dvbsub_pdata4bpp( bs_t *s, uint8_t *p, int i_width, int *pi_off )
}
else
{
if
(
bs_read
(
s
,
1
)
==
0x00
)
// Switch1
if
(
bs
w
_read
(
s
,
1
)
==
0x00
)
// Switch1
{
if
(
bs_show
(
s
,
3
)
!=
0x00
)
if
(
bs
w
_show
(
s
,
3
)
!=
0x00
)
{
i_count
=
2
+
bs_read
(
s
,
3
);
i_count
=
2
+
bs
w
_read
(
s
,
3
);
}
else
{
bs_skip
(
s
,
3
);
bs
w
_skip
(
s
,
3
);
b_stop
=
true
;
}
}
else
{
if
(
bs_read
(
s
,
1
)
==
0x00
)
//Switch2
if
(
bs
w
_read
(
s
,
1
)
==
0x00
)
//Switch2
{
i_count
=
4
+
bs_read
(
s
,
2
);
i_color
=
bs_read
(
s
,
4
);
i_count
=
4
+
bs
w
_read
(
s
,
2
);
i_color
=
bs
w
_read
(
s
,
4
);
}
else
{
switch
(
bs_read
(
s
,
2
)
)
//Switch3
switch
(
bs
w
_read
(
s
,
2
)
)
//Switch3
{
case
0x0
:
i_count
=
1
;
...
...
@@ -1328,12 +1328,12 @@ static void dvbsub_pdata4bpp( bs_t *s, uint8_t *p, int i_width, int *pi_off )
i_count
=
2
;
break
;
case
0x2
:
i_count
=
9
+
bs_read
(
s
,
4
);
i_color
=
bs_read
(
s
,
4
);
i_count
=
9
+
bs
w
_read
(
s
,
4
);
i_color
=
bs
w
_read
(
s
,
4
);
break
;
case
0x3
:
i_count
=
25
+
bs_read
(
s
,
8
);
i_color
=
bs_read
(
s
,
4
);
i_count
=
25
+
bs
w
_read
(
s
,
8
);
i_color
=
bs
w
_read
(
s
,
4
);
break
;
}
}
...
...
@@ -1351,18 +1351,18 @@ static void dvbsub_pdata4bpp( bs_t *s, uint8_t *p, int i_width, int *pi_off )
(
*
pi_off
)
+=
i_count
;
}
bs_align
(
s
);
bs
w
_align
(
s
);
}
static
void
dvbsub_pdata8bpp
(
bs_t
*
s
,
uint8_t
*
p
,
int
i_width
,
int
*
pi_off
)
static
void
dvbsub_pdata8bpp
(
bs
w
_t
*
s
,
uint8_t
*
p
,
int
i_width
,
int
*
pi_off
)
{
bool
b_stop
=
false
;
while
(
!
b_stop
&&
!
bs_eof
(
s
)
)
while
(
!
b_stop
&&
!
bs
w
_eof
(
s
)
)
{
int
i_count
=
0
,
i_color
=
0
;
i_color
=
bs_read
(
s
,
8
);
i_color
=
bs
w
_read
(
s
,
8
);
if
(
i_color
!=
0x00
)
{
/* Add 1 pixel */
...
...
@@ -1370,22 +1370,22 @@ static void dvbsub_pdata8bpp( bs_t *s, uint8_t *p, int i_width, int *pi_off )
}
else
{
if
(
bs_read
(
s
,
1
)
==
0x00
)
// Switch1
if
(
bs
w
_read
(
s
,
1
)
==
0x00
)
// Switch1
{
if
(
bs_show
(
s
,
7
)
!=
0x00
)
if
(
bs
w
_show
(
s
,
7
)
!=
0x00
)
{
i_count
=
bs_read
(
s
,
7
);
i_count
=
bs
w
_read
(
s
,
7
);
}
else
{
bs_skip
(
s
,
7
);
bs
w
_skip
(
s
,
7
);
b_stop
=
true
;
}
}
else
{
i_count
=
bs_read
(
s
,
7
);
i_color
=
bs_read
(
s
,
8
);
i_count
=
bs
w
_read
(
s
,
7
);
i_color
=
bs
w
_read
(
s
,
8
);
}
}
...
...
@@ -1400,7 +1400,7 @@ static void dvbsub_pdata8bpp( bs_t *s, uint8_t *p, int i_width, int *pi_off )
(
*
pi_off
)
+=
i_count
;
}
bs_align
(
s
);
bs
w
_align
(
s
);
}
static
void
free_all
(
decoder_t
*
p_dec
)
...
...
@@ -1644,10 +1644,10 @@ struct encoder_sys_t
int
i_offset_y
;
};
static
void
encode_page_composition
(
encoder_t
*
,
bs_t
*
,
subpicture_t
*
);
static
void
encode_clut
(
encoder_t
*
,
bs_t
*
,
subpicture_t
*
);
static
void
encode_region_composition
(
encoder_t
*
,
bs_t
*
,
subpicture_t
*
);
static
void
encode_object
(
encoder_t
*
,
bs_t
*
,
subpicture_t
*
);
static
void
encode_page_composition
(
encoder_t
*
,
bs
w
_t
*
,
subpicture_t
*
);
static
void
encode_clut
(
encoder_t
*
,
bs
w
_t
*
,
subpicture_t
*
);
static
void
encode_region_composition
(
encoder_t
*
,
bs
w
_t
*
,
subpicture_t
*
);
static
void
encode_object
(
encoder_t
*
,
bs
w
_t
*
,
subpicture_t
*
);
/*****************************************************************************
* OpenEncoder: probe the encoder and return score
...
...
@@ -1903,7 +1903,7 @@ static block_t *Encode( encoder_t *p_enc, subpicture_t *p_subpic )
{
subpicture_t
*
p_temp
=
NULL
;
subpicture_region_t
*
p_region
=
NULL
;
bs_t
bits
,
*
s
=
&
bits
;
bs
w
_t
bits
,
*
s
=
&
bits
;
block_t
*
p_block
;
if
(
!
p_subpic
||
!
p_subpic
->
p_region
)
return
NULL
;
...
...
@@ -1957,10 +1957,10 @@ static block_t *Encode( encoder_t *p_enc, subpicture_t *p_subpic )
msg_Dbg
(
p_enc
,
"encoding subpicture"
);
#endif
p_block
=
block_New
(
p_enc
,
64000
);
bs
_init
(
s
,
p_block
->
p_buffer
,
p_block
->
i_buffer
);
bs
w_init_writable
(
s
,
p_block
->
p_buffer
,
p_block
->
i_buffer
);
bs_write
(
s
,
8
,
0x20
);
/* Data identifier */
bs_write
(
s
,
8
,
0x0
);
/* Subtitle stream id */
bs
w
_write
(
s
,
8
,
0x20
);
/* Data identifier */
bs
w
_write
(
s
,
8
,
0x0
);
/* Subtitle stream id */
encode_page_composition
(
p_enc
,
s
,
p_subpic
);
encode_region_composition
(
p_enc
,
s
,
p_subpic
);
...
...
@@ -1968,13 +1968,13 @@ static block_t *Encode( encoder_t *p_enc, subpicture_t *p_subpic )
encode_object
(
p_enc
,
s
,
p_subpic
);
/* End of display */
bs_write
(
s
,
8
,
0x0f
);
/* Sync byte */
bs_write
(
s
,
8
,
DVBSUB_ST_ENDOFDISPLAY
);
/* Segment type */
bs_write
(
s
,
16
,
1
);
/* Page id */
bs_write
(
s
,
16
,
0
);
/* Segment length */
bs
w
_write
(
s
,
8
,
0x0f
);
/* Sync byte */
bs
w
_write
(
s
,
8
,
DVBSUB_ST_ENDOFDISPLAY
);
/* Segment type */
bs
w
_write
(
s
,
16
,
1
);
/* Page id */
bs
w
_write
(
s
,
16
,
0
);
/* Segment length */
bs_write
(
s
,
8
,
0xff
);
/* End marker */
p_block
->
i_buffer
=
bs_pos
(
s
)
/
8
;
bs
w
_write
(
s
,
8
,
0xff
);
/* End marker */
p_block
->
i_buffer
=
bs
w
_pos
(
s
)
/
8
;
p_block
->
i_pts
=
p_block
->
i_dts
=
p_subpic
->
i_start
;
if
(
!
p_subpic
->
b_ephemer
&&
(
p_subpic
->
i_stop
>
p_subpic
->
i_start
)
)
{
...
...
@@ -1984,16 +1984,16 @@ static block_t *Encode( encoder_t *p_enc, subpicture_t *p_subpic )
/* Send another (empty) subtitle to signal the end of display */
p_block_stop
=
block_New
(
p_enc
,
64000
);
bs
_init
(
s
,
p_block_stop
->
p_buffer
,
p_block_stop
->
i_buffer
);
bs_write
(
s
,
8
,
0x20
);
/* Data identifier */
bs_write
(
s
,
8
,
0x0
);
/* Subtitle stream id */
bs
w_init_writable
(
s
,
p_block_stop
->
p_buffer
,
p_block_stop
->
i_buffer
);
bs
w
_write
(
s
,
8
,
0x20
);
/* Data identifier */
bs
w
_write
(
s
,
8
,
0x0
);
/* Subtitle stream id */
encode_page_composition
(
p_enc
,
s
,
0
);
bs_write
(
s
,
8
,
0x0f
);
/* Sync byte */
bs_write
(
s
,
8
,
DVBSUB_ST_ENDOFDISPLAY
);
/* Segment type */
bs_write
(
s
,
16
,
1
);
/* Page id */
bs_write
(
s
,
16
,
0
);
/* Segment length */
bs_write
(
s
,
8
,
0xff
);
/* End marker */
p_block_stop
->
i_buffer
=
bs_pos
(
s
)
/
8
;
bs
w
_write
(
s
,
8
,
0x0f
);
/* Sync byte */
bs
w
_write
(
s
,
8
,
DVBSUB_ST_ENDOFDISPLAY
);
/* Segment type */
bs
w
_write
(
s
,
16
,
1
);
/* Page id */
bs
w
_write
(
s
,
16
,
0
);
/* Segment length */
bs
w
_write
(
s
,
8
,
0xff
);
/* End marker */
p_block_stop
->
i_buffer
=
bs
w
_pos
(
s
)
/
8
;
p_block_stop
->
i_pts
=
p_block_stop
->
i_dts
=
p_subpic
->
i_stop
;
block_ChainAppend
(
&
p_block
,
p_block_stop
);
p_block_stop
->
i_length
=
100000
;
/* p_subpic->i_stop - p_subpic->i_start; */
...
...
@@ -2020,7 +2020,7 @@ static void CloseEncoder( vlc_object_t *p_this )
free
(
p_sys
);
}
static
void
encode_page_composition
(
encoder_t
*
p_enc
,
bs_t
*
s
,
static
void
encode_page_composition
(
encoder_t
*
p_enc
,
bs
w
_t
*
s
,
subpicture_t
*
p_subpic
)
{
encoder_sys_t
*
p_sys
=
p_enc
->
p_sys
;
...
...
@@ -2028,9 +2028,9 @@ static void encode_page_composition( encoder_t *p_enc, bs_t *s,
bool
b_mode_change
=
false
;
int
i_regions
,
i_timeout
;
bs_write
(
s
,
8
,
0x0f
);
/* Sync byte */
bs_write
(
s
,
8
,
DVBSUB_ST_PAGE_COMPOSITION
);
/* Segment type */
bs_write
(
s
,
16
,
1
);
/* Page id */
bs
w
_write
(
s
,
8
,
0x0f
);
/* Sync byte */
bs
w
_write
(
s
,
8
,
DVBSUB_ST_PAGE_COMPOSITION
);
/* Segment type */
bs
w
_write
(
s
,
16
,
1
);
/* Page id */
for
(
i_regions
=
0
,
p_region
=
p_subpic
?
p_subpic
->
p_region
:
0
;
p_region
;
p_region
=
p_region
->
p_next
,
i_regions
++
)
...
...
@@ -2069,7 +2069,7 @@ static void encode_page_composition( encoder_t *p_enc, bs_t *s,
}
}
bs_write
(
s
,
16
,
i_regions
*
6
+
2
);
/* Segment length */
bs
w
_write
(
s
,
16
,
i_regions
*
6
+
2
);
/* Segment length */
i_timeout
=
0
;
if
(
p_subpic
&&
!
p_subpic
->
b_ephemer
&&
...
...
@@ -2078,31 +2078,31 @@ static void encode_page_composition( encoder_t *p_enc, bs_t *s,
i_timeout
=
(
p_subpic
->
i_stop
-
p_subpic
->
i_start
)
/
1000000
;
}
bs_write
(
s
,
8
,
i_timeout
);
/* Timeout */
bs_write
(
s
,
4
,
p_sys
->
i_page_ver
++
);
bs_write
(
s
,
2
,
b_mode_change
?
bs
w
_write
(
s
,
8
,
i_timeout
);
/* Timeout */
bs
w
_write
(
s
,
4
,
p_sys
->
i_page_ver
++
);
bs
w
_write
(
s
,
2
,
b_mode_change
?
DVBSUB_PCS_STATE_CHANGE
:
DVBSUB_PCS_STATE_ACQUISITION
);
bs_write
(
s
,
2
,
0
);
/* Reserved */
bs
w
_write
(
s
,
2
,
0
);
/* Reserved */
for
(
i_regions
=
0
,
p_region
=
p_subpic
?
p_subpic
->
p_region
:
0
;
p_region
;
p_region
=
p_region
->
p_next
,
i_regions
++
)
{
bs_write
(
s
,
8
,
i_regions
);
bs_write
(
s
,
8
,
0
);
/* Reserved */
bs
w
_write
(
s
,
8
,
i_regions
);
bs
w
_write
(
s
,
8
,
0
);
/* Reserved */
if
(
(
p_sys
->
i_offset_x
>
0
)
&&
(
p_sys
->
i_offset_y
>
0
)
)
{
bs_write
(
s
,
16
,
p_sys
->
i_offset_x
);
/* override x position */
bs_write
(
s
,
16
,
p_sys
->
i_offset_y
);
/* override y position */
bs
w
_write
(
s
,
16
,
p_sys
->
i_offset_x
);
/* override x position */
bs
w
_write
(
s
,
16
,
p_sys
->
i_offset_y
);
/* override y position */
}
else
{
bs_write
(
s
,
16
,
p_region
->
i_x
);
bs_write
(
s
,
16
,
p_region
->
i_y
);
bs
w
_write
(
s
,
16
,
p_region
->
i_x
);
bs
w
_write
(
s
,
16
,
p_region
->
i_y
);
}
}
}
static
void
encode_clut
(
encoder_t
*
p_enc
,
bs_t
*
s
,
subpicture_t
*
p_subpic
)
static
void
encode_clut
(
encoder_t
*
p_enc
,
bs
w
_t
*
s
,
subpicture_t
*
p_subpic
)
{
encoder_sys_t
*
p_sys
=
p_enc
->
p_sys
;
subpicture_region_t
*
p_region
=
p_subpic
->
p_region
;
...
...
@@ -2129,32 +2129,32 @@ static void encode_clut( encoder_t *p_enc, bs_t *s, subpicture_t *p_subpic )
p_pal
=
&
pal
;
}
bs_write
(
s
,
8
,
0x0f
);
/* Sync byte */
bs_write
(
s
,
8
,
DVBSUB_ST_CLUT_DEFINITION
);
/* Segment type */
bs_write
(
s
,
16
,
1
);
/* Page id */
bs
w
_write
(
s
,
8
,
0x0f
);
/* Sync byte */
bs
w
_write
(
s
,
8
,
DVBSUB_ST_CLUT_DEFINITION
);
/* Segment type */
bs
w
_write
(
s
,
16
,
1
);
/* Page id */
bs_write
(
s
,
16
,
p_pal
->
i_entries
*
6
+
2
);
/* Segment length */
bs_write
(
s
,
8
,
1
);
/* Clut id */
bs_write
(
s
,
4
,
p_sys
->
i_clut_ver
++
);
bs_write
(
s
,
4
,
0
);
/* Reserved */
bs
w
_write
(
s
,
16
,
p_pal
->
i_entries
*
6
+
2
);
/* Segment length */
bs
w
_write
(
s
,
8
,
1
);
/* Clut id */
bs
w
_write
(
s
,
4
,
p_sys
->
i_clut_ver
++
);
bs
w
_write
(
s
,
4
,
0
);
/* Reserved */
for
(
i
=
0
;
i
<
p_pal
->
i_entries
;
i
++
)
{
bs_write
(
s
,
8
,
i
);
/* Clut entry id */
bs_write
(
s
,
1
,
p_pal
->
i_entries
==
4
);
/* 2bit/entry flag */
bs_write
(
s
,
1
,
p_pal
->
i_entries
==
16
);
/* 4bit/entry flag */
bs_write
(
s
,
1
,
p_pal
->
i_entries
==
256
);
/* 8bit/entry flag */
bs_write
(
s
,
4
,
0
);
/* Reserved */
bs_write
(
s
,
1
,
1
);
/* Full range flag */
bs_write
(
s
,
8
,
p_pal
->
palette
[
i
][
3
]
?
/* Y value */
bs
w
_write
(
s
,
8
,
i
);
/* Clut entry id */
bs
w
_write
(
s
,
1
,
p_pal
->
i_entries
==
4
);
/* 2bit/entry flag */
bs
w
_write
(
s
,
1
,
p_pal
->
i_entries
==
16
);
/* 4bit/entry flag */
bs
w
_write
(
s
,
1
,
p_pal
->
i_entries
==
256
);
/* 8bit/entry flag */
bs
w
_write
(
s
,
4
,
0
);
/* Reserved */
bs
w
_write
(
s
,
1
,
1
);
/* Full range flag */
bs
w
_write
(
s
,
8
,
p_pal
->
palette
[
i
][
3
]
?
/* Y value */
(
p_pal
->
palette
[
i
][
0
]
?
p_pal
->
palette
[
i
][
0
]
:
16
)
:
0
);
bs_write
(
s
,
8
,
p_pal
->
palette
[
i
][
1
]
);
/* Cr value */
bs_write
(
s
,
8
,
p_pal
->
palette
[
i
][
2
]
);
/* Cb value */
bs_write
(
s
,
8
,
0xff
-
p_pal
->
palette
[
i
][
3
]
);
/* T value */
bs
w
_write
(
s
,
8
,
p_pal
->
palette
[
i
][
1
]
);
/* Cr value */
bs
w
_write
(
s
,
8
,
p_pal
->
palette
[
i
][
2
]
);
/* Cb value */
bs
w
_write
(
s
,
8
,
0xff
-
p_pal
->
palette
[
i
][
3
]
);
/* T value */
}
}
static
void
encode_region_composition
(
encoder_t
*
p_enc
,
bs_t
*
s
,
static
void
encode_region_composition
(
encoder_t
*
p_enc
,
bs
w
_t
*
s
,
subpicture_t
*
p_subpic
)
{
encoder_sys_t
*
p_sys
=
p_enc
->
p_sys
;
...
...
@@ -2187,49 +2187,49 @@ static void encode_region_composition( encoder_t *p_enc, bs_t *s,
}
}
bs_write
(
s
,
8
,
0x0f
);
/* Sync byte */
bs_write
(
s
,
8
,
DVBSUB_ST_REGION_COMPOSITION
);
/* Segment type */
bs_write
(
s
,
16
,
1
);
/* Page id */
bs
w
_write
(
s
,
8
,
0x0f
);
/* Sync byte */
bs
w
_write
(
s
,
8
,
DVBSUB_ST_REGION_COMPOSITION
);
/* Segment type */
bs
w
_write
(
s
,
16
,
1
);
/* Page id */
bs_write
(
s
,
16
,
10
+
6
+
(
b_text
?
2
:
0
)
);
/* Segment length */
bs_write
(
s
,
8
,
i_region
);
bs_write
(
s
,
4
,
p_sys
->
i_region_ver
++
);
bs
w
_write
(
s
,
16
,
10
+
6
+
(
b_text
?
2
:
0
)
);
/* Segment length */
bs
w
_write
(
s
,
8
,
i_region
);
bs
w
_write
(
s
,
4
,
p_sys
->
i_region_ver
++
);
/* Region attributes */
bs_write
(
s
,
1
,
i_bg
<
i_entries
);
/* Fill */
bs_write
(
s
,
3
,
0
);
/* Reserved */
bs_write
(
s
,
16
,
p_sys
->
p_regions
[
i_region
].
i_width
);
bs_write
(
s
,
16
,
p_sys
->
p_regions
[
i_region
].
i_height
);
bs_write
(
s
,
3
,
i_depth
);
/* Region level of compatibility */
bs_write
(
s
,
3
,
i_depth
);
/* Region depth */
bs_write
(
s
,
2
,
0
);
/* Reserved */
bs_write
(
s
,
8
,
1
);
/* Clut id */
bs_write
(
s
,
8
,
i_bg
);
/* region 8bit pixel code */
bs_write
(
s
,
4
,
i_bg
);
/* region 4bit pixel code */
bs_write
(
s
,
2
,
i_bg
);
/* region 2bit pixel code */
bs_write
(
s
,
2
,
0
);
/* Reserved */
bs
w
_write
(
s
,
1
,
i_bg
<
i_entries
);
/* Fill */
bs
w
_write
(
s
,
3
,
0
);
/* Reserved */
bs
w
_write
(
s
,
16
,
p_sys
->
p_regions
[
i_region
].
i_width
);
bs
w
_write
(
s
,
16
,
p_sys
->
p_regions
[
i_region
].
i_height
);
bs
w
_write
(
s
,
3
,
i_depth
);
/* Region level of compatibility */
bs
w
_write
(
s
,
3
,
i_depth
);
/* Region depth */
bs
w
_write
(
s
,
2
,
0
);
/* Reserved */
bs
w
_write
(
s
,
8
,
1
);
/* Clut id */
bs
w
_write
(
s
,
8
,
i_bg
);
/* region 8bit pixel code */
bs
w
_write
(
s
,
4
,
i_bg
);
/* region 4bit pixel code */
bs
w
_write
(
s
,
2
,
i_bg
);
/* region 2bit pixel code */
bs
w
_write
(
s
,
2
,
0
);
/* Reserved */
/* In our implementation we only have 1 object per region */
bs_write
(
s
,
16
,
i_region
);
bs_write
(
s
,
2
,
b_text
?
DVBSUB_OT_BASIC_CHAR
:
DVBSUB_OT_BASIC_BITMAP
);
bs_write
(
s
,
2
,
0
);
/* object provider flag */
bs_write
(
s
,
12
,
0
);
/* object horizontal position */
bs_write
(
s
,
4
,
0
);
/* Reserved */
bs_write
(
s
,
12
,
0
);
/* object vertical position */
bs
w
_write
(
s
,
16
,
i_region
);
bs
w
_write
(
s
,
2
,
b_text
?
DVBSUB_OT_BASIC_CHAR
:
DVBSUB_OT_BASIC_BITMAP
);
bs
w
_write
(
s
,
2
,
0
);
/* object provider flag */
bs
w
_write
(
s
,
12
,
0
);
/* object horizontal position */
bs
w
_write
(
s
,
4
,
0
);
/* Reserved */
bs
w
_write
(
s
,
12
,
0
);
/* object vertical position */
if
(
b_text
)
{
bs_write
(
s
,
8
,
1
);
/* foreground pixel code */
bs_write
(
s
,
8
,
0
);
/* background pixel code */
bs
w
_write
(
s
,
8
,
1
);
/* foreground pixel code */
bs
w
_write
(
s
,
8
,
0
);
/* background pixel code */
}
}
}
static
void
encode_pixel_data
(
encoder_t
*
p_enc
,
bs_t
*
s
,
static
void
encode_pixel_data
(
encoder_t
*
p_enc
,
bs
w
_t
*
s
,
subpicture_region_t
*
p_region
,
bool
b_top
);
static
void
encode_object
(
encoder_t
*
p_enc
,
bs_t
*
s
,
subpicture_t
*
p_subpic
)
static
void
encode_object
(
encoder_t
*
p_enc
,
bs
w
_t
*
s
,
subpicture_t
*
p_subpic
)
{
encoder_sys_t
*
p_sys
=
p_enc
->
p_sys
;
subpicture_region_t
*
p_region
;
...
...
@@ -2240,31 +2240,31 @@ static void encode_object( encoder_t *p_enc, bs_t *s, subpicture_t *p_subpic )
for
(
i_region
=
0
,
p_region
=
p_subpic
->
p_region
;
p_region
;
p_region
=
p_region
->
p_next
,
i_region
++
)
{
bs_write
(
s
,
8
,
0x0f
);
/* Sync byte */
bs_write
(
s
,
8
,
DVBSUB_ST_OBJECT_DATA
);
/* Segment type */
bs_write
(
s
,
16
,
1
);
/* Page id */
bs
w
_write
(
s
,
8
,
0x0f
);
/* Sync byte */
bs
w
_write
(
s
,
8
,
DVBSUB_ST_OBJECT_DATA
);
/* Segment type */
bs
w
_write
(
s
,
16
,
1
);
/* Page id */
i_length_pos
=
bs_pos
(
s
);
bs_write
(
s
,
16
,
0
);
/* Segment length */
bs_write
(
s
,
16
,
i_region
);
/* Object id */
bs_write
(
s
,
4
,
p_sys
->
i_region_ver
++
);
i_length_pos
=
bs
w
_pos
(
s
);
bs
w
_write
(
s
,
16
,
0
);
/* Segment length */
bs
w
_write
(
s
,
16
,
i_region
);
/* Object id */
bs
w
_write
(
s
,
4
,
p_sys
->
i_region_ver
++
);
/* object coding method */
switch
(
p_region
->
fmt
.
i_chroma
)
{
case
VLC_CODEC_YUVP
:
bs_write
(
s
,
2
,
0
);
bs
w
_write
(
s
,
2
,
0
);
break
;
case
VLC_CODEC_TEXT
:
bs_write
(
s
,
2
,
1
);
bs
w
_write
(
s
,
2
,
1
);
break
;
default:
msg_Err
(
p_enc
,
"FOURCC %d not supported by encoder."
,
p_region
->
fmt
.
i_chroma
);
continue
;
}
bs_write
(
s
,
1
,
0
);
/* non modifying color flag */
bs_write
(
s
,
1
,
0
);
/* Reserved */
bs
w
_write
(
s
,
1
,
0
);
/* non modifying color flag */
bs
w
_write
(
s
,
1
,
0
);
/* Reserved */
if
(
p_region
->
fmt
.
i_chroma
==
VLC_CODEC_TEXT
)
{
...
...
@@ -2274,51 +2274,51 @@ static void encode_object( encoder_t *p_enc, bs_t *s, subpicture_t *p_subpic )
i_size
=
__MIN
(
strlen
(
p_region
->
psz_text
),
256
);
bs_write
(
s
,
8
,
i_size
);
/* number of characters in string */
bs
w
_write
(
s
,
8
,
i_size
);
/* number of characters in string */
for
(
i
=
0
;
i
<
i_size
;
i
++
)
{
bs_write
(
s
,
16
,
p_region
->
psz_text
[
i
]
);
bs
w
_write
(
s
,
16
,
p_region
->
psz_text
[
i
]
);
}
/* Update segment length */
SetWBE
(
&
s
->
p_start
[
i_length_pos
/
8
],
(
bs_pos
(
s
)
-
i_length_pos
)
/
8
-
2
);
(
bs
w
_pos
(
s
)
-
i_length_pos
)
/
8
-
2
);
continue
;
}
/* Coding of a bitmap object */
i_update_pos
=
bs_pos
(
s
);
bs_write
(
s
,
16
,
0
);
/* topfield data block length */
bs_write
(
s
,
16
,
0
);
/* bottomfield data block length */
i_update_pos
=
bs
w
_pos
(
s
);
bs
w
_write
(
s
,
16
,
0
);
/* topfield data block length */
bs
w
_write
(
s
,
16
,
0
);
/* bottomfield data block length */
/* Top field */
i_pixel_data_pos
=
bs_pos
(
s
);
i_pixel_data_pos
=
bs
w
_pos
(
s
);
encode_pixel_data
(
p_enc
,
s
,
p_region
,
true
);
i_pixel_data_pos
=
(
bs_pos
(
s
)
-
i_pixel_data_pos
)
/
8
;
i_pixel_data_pos
=
(
bs
w
_pos
(
s
)
-
i_pixel_data_pos
)
/
8
;
SetWBE
(
&
s
->
p_start
[
i_update_pos
/
8
],
i_pixel_data_pos
);
/* Bottom field */
i_pixel_data_pos
=
bs_pos
(
s
);
i_pixel_data_pos
=
bs
w
_pos
(
s
);
encode_pixel_data
(
p_enc
,
s
,
p_region
,
false
);
i_pixel_data_pos
=
(
bs_pos
(
s
)
-
i_pixel_data_pos
)
/
8
;
i_pixel_data_pos
=
(
bs
w
_pos
(
s
)
-
i_pixel_data_pos
)
/
8
;
SetWBE
(
&
s
->
p_start
[
i_update_pos
/
8
+
2
],
i_pixel_data_pos
);
/* Stuffing for word alignment */
bs_align_0
(
s
);
if
(
bs
_pos
(
s
)
%
16
)
bs
_write
(
s
,
8
,
0
);
bs
w
_align_0
(
s
);
if
(
bs
w_pos
(
s
)
%
16
)
bsw
_write
(
s
,
8
,
0
);
/* Update segment length */
SetWBE
(
&
s
->
p_start
[
i_length_pos
/
8
],
(
bs_pos
(
s
)
-
i_length_pos
)
/
8
-
2
);
SetWBE
(
&
s
->
p_start
[
i_length_pos
/
8
],
(
bs
w
_pos
(
s
)
-
i_length_pos
)
/
8
-
2
);
}
}
static
void
encode_pixel_line_2bp
(
bs_t
*
s
,
subpicture_region_t
*
p_region
,
static
void
encode_pixel_line_2bp
(
bs
w
_t
*
s
,
subpicture_region_t
*
p_region
,
int
i_line
);
static
void
encode_pixel_line_4bp
(
bs_t
*
s
,
subpicture_region_t
*
p_region
,
static
void
encode_pixel_line_4bp
(
bs
w
_t
*
s
,
subpicture_region_t
*
p_region
,
int
i_line
);
static
void
encode_pixel_line_8bp
(
bs_t
*
s
,
subpicture_region_t
*
p_region
,
static
void
encode_pixel_line_8bp
(
bs
w
_t
*
s
,
subpicture_region_t
*
p_region
,
int
i_line
);
static
void
encode_pixel_data
(
encoder_t
*
p_enc
,
bs_t
*
s
,
static
void
encode_pixel_data
(
encoder_t
*
p_enc
,
bs
w
_t
*
s
,
subpicture_region_t
*
p_region
,
bool
b_top
)
{
...
...
@@ -2337,17 +2337,17 @@ static void encode_pixel_data( encoder_t *p_enc, bs_t *s,
break
;
case
4
:
bs_write
(
s
,
8
,
0x10
);
/* 2 bit/pixel code string */
bs
w
_write
(
s
,
8
,
0x10
);
/* 2 bit/pixel code string */
encode_pixel_line_2bp
(
s
,
p_region
,
i_line
);
break
;
case
16
:
bs_write
(
s
,
8
,
0x11
);
/* 4 bit/pixel code string */
bs
w
_write
(
s
,
8
,
0x11
);
/* 4 bit/pixel code string */
encode_pixel_line_4bp
(
s
,
p_region
,
i_line
);
break
;
case
256
:
bs_write
(
s
,
8
,
0x12
);
/* 8 bit/pixel code string */
bs
w
_write
(
s
,
8
,
0x12
);
/* 8 bit/pixel code string */
encode_pixel_line_8bp
(
s
,
p_region
,
i_line
);
break
;
...
...
@@ -2357,11 +2357,11 @@ static void encode_pixel_data( encoder_t *p_enc, bs_t *s,
break
;
}
bs_write
(
s
,
8
,
0xf0
);
/* End of object line code */
bs
w
_write
(
s
,
8
,
0xf0
);
/* End of object line code */
}
}
static
void
encode_pixel_line_2bp
(
bs_t
*
s
,
subpicture_region_t
*
p_region
,
static
void
encode_pixel_line_2bp
(
bs
w
_t
*
s
,
subpicture_region_t
*
p_region
,
int
i_line
)
{
unsigned
int
i
,
i_length
=
0
;
...
...
@@ -2382,12 +2382,12 @@ static void encode_pixel_line_2bp( bs_t *s, subpicture_region_t *p_region,
{
/* 2bit/pixel code */
if
(
i_last_pixel
)
bs_write
(
s
,
2
,
i_last_pixel
);
bs
w
_write
(
s
,
2
,
i_last_pixel
);
else
{
bs_write
(
s
,
2
,
0
);
bs_write
(
s
,
1
,
0
);
bs_write
(
s
,
1
,
1
);
/* pseudo color 0 */
bs
w
_write
(
s
,
2
,
0
);
bs
w
_write
(
s
,
1
,
0
);
bs
w
_write
(
s
,
1
,
1
);
/* pseudo color 0 */
}
i_length
--
;
}
...
...
@@ -2396,42 +2396,42 @@ static void encode_pixel_line_2bp( bs_t *s, subpicture_region_t *p_region,
{
if
(
i_last_pixel
)
{
bs_write
(
s
,
2
,
i_last_pixel
);
bs_write
(
s
,
2
,
i_last_pixel
);
bs
w
_write
(
s
,
2
,
i_last_pixel
);
bs
w
_write
(
s
,
2
,
i_last_pixel
);
}
else
{
bs_write
(
s
,
2
,
0
);
bs_write
(
s
,
1
,
0
);
bs_write
(
s
,
1
,
0
);
bs_write
(
s
,
2
,
1
);
/* 2 * pseudo color 0 */
bs
w
_write
(
s
,
2
,
0
);
bs
w
_write
(
s
,
1
,
0
);
bs
w
_write
(
s
,
1
,
0
);
bs
w
_write
(
s
,
2
,
1
);
/* 2 * pseudo color 0 */
}
}
else
if
(
i_length
>
2
)
{
bs_write
(
s
,
2
,
0
);
bs
w
_write
(
s
,
2
,
0
);
if
(
i_length
<=
10
)
{
bs_write
(
s
,
1
,
1
);
bs_write
(
s
,
3
,
i_length
-
3
);
bs_write
(
s
,
2
,
i_last_pixel
);
bs
w
_write
(
s
,
1
,
1
);
bs
w
_write
(
s
,
3
,
i_length
-
3
);
bs
w
_write
(
s
,
2
,
i_last_pixel
);
}
else
{
bs_write
(
s
,
1
,
0
);
bs_write
(
s
,
1
,
0
);
bs
w
_write
(
s
,
1
,
0
);
bs
w
_write
(
s
,
1
,
0
);
if
(
i_length
<=
27
)
{
bs_write
(
s
,
2
,
2
);
bs_write
(
s
,
4
,
i_length
-
12
);
bs_write
(
s
,
2
,
i_last_pixel
);
bs
w
_write
(
s
,
2
,
2
);
bs
w
_write
(
s
,
4
,
i_length
-
12
);
bs
w
_write
(
s
,
2
,
i_last_pixel
);
}
else
{
bs_write
(
s
,
2
,
3
);
bs_write
(
s
,
8
,
i_length
-
29
);
bs_write
(
s
,
2
,
i_last_pixel
);
bs
w
_write
(
s
,
2
,
3
);
bs
w
_write
(
s
,
8
,
i_length
-
29
);
bs
w
_write
(
s
,
2
,
i_last_pixel
);
}
}
}
...
...
@@ -2443,16 +2443,16 @@ static void encode_pixel_line_2bp( bs_t *s, subpicture_region_t *p_region,
}
/* Stop */
bs_write
(
s
,
2
,
0
);
bs_write
(
s
,
1
,
0
);
bs_write
(
s
,
1
,
0
);
bs_write
(
s
,
2
,
0
);
bs
w
_write
(
s
,
2
,
0
);
bs
w
_write
(
s
,
1
,
0
);
bs
w
_write
(
s
,
1
,
0
);
bs
w
_write
(
s
,
2
,
0
);
/* Stuffing */
bs_align_0
(
s
);
bs
w
_align_0
(
s
);
}
static
void
encode_pixel_line_4bp
(
bs_t
*
s
,
subpicture_region_t
*
p_region
,
static
void
encode_pixel_line_4bp
(
bs
w
_t
*
s
,
subpicture_region_t
*
p_region
,
int
i_line
)
{
unsigned
int
i
,
i_length
=
0
;
...
...
@@ -2475,13 +2475,13 @@ static void encode_pixel_line_4bp( bs_t *s, subpicture_region_t *p_region,
{
/* 4bit/pixel code */
if
(
i_last_pixel
)
bs_write
(
s
,
4
,
i_last_pixel
);
bs
w
_write
(
s
,
4
,
i_last_pixel
);
else
{
bs_write
(
s
,
4
,
0
);
bs_write
(
s
,
1
,
1
);
bs_write
(
s
,
1
,
1
);
bs_write
(
s
,
2
,
0
);
/* pseudo color 0 */
bs
w
_write
(
s
,
4
,
0
);
bs
w
_write
(
s
,
1
,
1
);
bs
w
_write
(
s
,
1
,
1
);
bs
w
_write
(
s
,
2
,
0
);
/* pseudo color 0 */
}
i_length
--
;
}
...
...
@@ -2490,49 +2490,49 @@ static void encode_pixel_line_4bp( bs_t *s, subpicture_region_t *p_region,
{
if
(
i_last_pixel
)
{
bs_write
(
s
,
4
,
i_last_pixel
);
bs_write
(
s
,
4
,
i_last_pixel
);
bs
w
_write
(
s
,
4
,
i_last_pixel
);
bs
w
_write
(
s
,
4
,
i_last_pixel
);
}
else
{
bs_write
(
s
,
4
,
0
);
bs_write
(
s
,
1
,
1
);
bs_write
(
s
,
1
,
1
);
bs_write
(
s
,
2
,
1
);
/* 2 * pseudo color 0 */
bs
w
_write
(
s
,
4
,
0
);
bs
w
_write
(
s
,
1
,
1
);
bs
w
_write
(
s
,
1
,
1
);
bs
w
_write
(
s
,
2
,
1
);
/* 2 * pseudo color 0 */
}
}
else
if
(
!
i_last_pixel
&&
(
i_length
>=
3
)
&&
(
i_length
<=
9
)
)
{
bs_write
(
s
,
4
,
0
);
bs_write
(
s
,
1
,
0
);
bs_write
(
s
,
3
,
i_length
-
2
);
/* (i_length - 2) * color 0 */
bs
w
_write
(
s
,
4
,
0
);
bs
w
_write
(
s
,
1
,
0
);
bs
w
_write
(
s
,
3
,
i_length
-
2
);
/* (i_length - 2) * color 0 */
}
else
if
(
i_length
>
2
)
{
bs_write
(
s
,
4
,
0
);
bs_write
(
s
,
1
,
1
);
bs
w
_write
(
s
,
4
,
0
);
bs
w
_write
(
s
,
1
,
1
);
if
(
i_length
<=
7
)
{
bs_write
(
s
,
1
,
0
);
bs_write
(
s
,
2
,
i_length
-
4
);
bs_write
(
s
,
4
,
i_last_pixel
);
bs
w
_write
(
s
,
1
,
0
);
bs
w
_write
(
s
,
2
,
i_length
-
4
);
bs
w
_write
(
s
,
4
,
i_last_pixel
);
}
else
{
bs_write
(
s
,
1
,
1
);
bs
w
_write
(
s
,
1
,
1
);
if
(
i_length
<=
24
)
{
bs_write
(
s
,
2
,
2
);
bs_write
(
s
,
4
,
i_length
-
9
);
bs_write
(
s
,
4
,
i_last_pixel
);
bs
w
_write
(
s
,
2
,
2
);
bs
w
_write
(
s
,
4
,
i_length
-
9
);
bs
w
_write
(
s
,
4
,
i_last_pixel
);
}
else
{
bs_write
(
s
,
2
,
3
);
bs_write
(
s
,
8
,
i_length
-
25
);
bs_write
(
s
,
4
,
i_last_pixel
);
bs
w
_write
(
s
,
2
,
3
);
bs
w
_write
(
s
,
8
,
i_length
-
25
);
bs
w
_write
(
s
,
4
,
i_last_pixel
);
}
}
}
...
...
@@ -2544,13 +2544,13 @@ static void encode_pixel_line_4bp( bs_t *s, subpicture_region_t *p_region,
}
/* Stop */
bs_write
(
s
,
8
,
0
);
bs
w
_write
(
s
,
8
,
0
);
/* Stuffing */
bs_align_0
(
s
);
bs
w
_align_0
(
s
);
}
static
void
encode_pixel_line_8bp
(
bs_t
*
s
,
subpicture_region_t
*
p_region
,
static
void
encode_pixel_line_8bp
(
bs
w
_t
*
s
,
subpicture_region_t
*
p_region
,
int
i_line
)
{
unsigned
int
i
,
i_length
=
0
;
...
...
@@ -2570,28 +2570,28 @@ static void encode_pixel_line_8bp( bs_t *s, subpicture_region_t *p_region,
if
(
(
i_length
==
1
)
&&
i_last_pixel
)
{
/* 8bit/pixel code */
bs_write
(
s
,
8
,
i_last_pixel
);
bs
w
_write
(
s
,
8
,
i_last_pixel
);
}
else
if
(
(
i_length
==
2
)
&&
i_last_pixel
)
{
/* 8bit/pixel code */
bs_write
(
s
,
8
,
i_last_pixel
);
bs_write
(
s
,
8
,
i_last_pixel
);
bs
w
_write
(
s
,
8
,
i_last_pixel
);
bs
w
_write
(
s
,
8
,
i_last_pixel
);
}
else
if
(
i_length
<=
127
)
{
bs_write
(
s
,
8
,
0
);
bs
w
_write
(
s
,
8
,
0
);
if
(
!
i_last_pixel
)
{
bs_write
(
s
,
1
,
0
);
bs_write
(
s
,
7
,
i_length
);
/* pseudo color 0 */
bs
w
_write
(
s
,
1
,
0
);
bs
w
_write
(
s
,
7
,
i_length
);
/* pseudo color 0 */
}
else
{
bs_write
(
s
,
1
,
1
);
bs_write
(
s
,
7
,
i_length
);
bs_write
(
s
,
8
,
i_last_pixel
);
bs
w
_write
(
s
,
1
,
1
);
bs
w
_write
(
s
,
7
,
i_length
);
bs
w
_write
(
s
,
8
,
i_last_pixel
);
}
}
...
...
@@ -2602,9 +2602,9 @@ static void encode_pixel_line_8bp( bs_t *s, subpicture_region_t *p_region,
}
/* Stop */
bs_write
(
s
,
8
,
0
);
bs_write
(
s
,
8
,
0
);
bs
w
_write
(
s
,
8
,
0
);
bs
w
_write
(
s
,
8
,
0
);
/* Stuffing */
bs_align_0
(
s
);
bs
w
_align_0
(
s
);
}
modules/codec/svcdsub.c
View file @
4bfba26a
...
...
@@ -546,9 +546,9 @@ static void SVCDSubRenderImage( decoder_t *p_dec, block_t *p_data,
int
i_field
;
/* The subtitles are interlaced */
int
i_row
,
i_column
;
/* scanline row/column number */
uint8_t
i_color
,
i_count
;
bs_t
bs
;
bs
w
_t
bs
;
bs
_init
(
&
bs
,
p_data
->
p_buffer
+
p_sys
->
i_image_offset
,
bs
w_init_writable
(
&
bs
,
p_data
->
p_buffer
+
p_sys
->
i_image_offset
,
p_data
->
i_buffer
-
p_sys
->
i_image_offset
);
for
(
i_field
=
0
;
i_field
<
2
;
i_field
++
)
...
...
@@ -557,8 +557,8 @@ static void SVCDSubRenderImage( decoder_t *p_dec, block_t *p_data,
{
for
(
i_column
=
0
;
i_column
<
p_sys
->
i_width
;
i_column
++
)
{
i_color
=
bs_read
(
&
bs
,
2
);
if
(
i_color
==
0
&&
(
i_count
=
bs_read
(
&
bs
,
2
))
)
i_color
=
bs
w
_read
(
&
bs
,
2
);
if
(
i_color
==
0
&&
(
i_count
=
bs
w
_read
(
&
bs
,
2
))
)
{
i_count
=
__MIN
(
i_count
,
p_sys
->
i_width
-
i_column
);
memset
(
&
p_dest
[
i_row
*
p_region
->
p_picture
->
Y_PITCH
+
...
...
@@ -570,11 +570,11 @@ static void SVCDSubRenderImage( decoder_t *p_dec, block_t *p_data,
p_dest
[
i_row
*
p_region
->
p_picture
->
Y_PITCH
+
i_column
]
=
i_color
;
}
bs_align
(
&
bs
);
bs
w
_align
(
&
bs
);
}
/* odd field */
bs
_init
(
&
bs
,
p_data
->
p_buffer
+
p_sys
->
i_image_offset
+
bs
w_init_writable
(
&
bs
,
p_data
->
p_buffer
+
p_sys
->
i_image_offset
+
p_sys
->
second_field_offset
,
p_data
->
i_buffer
-
p_sys
->
i_image_offset
-
p_sys
->
second_field_offset
);
...
...
modules/packetizer/mpeg4audio.c
View file @
4bfba26a
...
...
@@ -430,88 +430,88 @@ static int LOASSyncInfo( uint8_t p_header[LOAS_HEADER_SIZE], unsigned int *pi_he
return
(
(
p_header
[
1
]
&
0x1f
)
<<
8
)
+
p_header
[
2
];
}
static
int
Mpeg4GAProgramConfigElement
(
bs_t
*
s
)
static
int
Mpeg4GAProgramConfigElement
(
bs
w
_t
*
s
)
{
/* TODO compute channels count ? */
int
i_tag
=
bs_read
(
s
,
4
);
int
i_tag
=
bs
w
_read
(
s
,
4
);
if
(
i_tag
!=
0x05
)
return
-
1
;
bs_skip
(
s
,
2
+
4
);
// object type + sampling index
int
i_num_front
=
bs_read
(
s
,
4
);
int
i_num_side
=
bs_read
(
s
,
4
);
int
i_num_back
=
bs_read
(
s
,
4
);
int
i_num_lfe
=
bs_read
(
s
,
2
);
int
i_num_assoc_data
=
bs_read
(
s
,
3
);
int
i_num_valid_cc
=
bs_read
(
s
,
4
);
if
(
bs_read1
(
s
)
)
bs_skip
(
s
,
4
);
// mono downmix
if
(
bs_read1
(
s
)
)
bs_skip
(
s
,
4
);
// stereo downmix
if
(
bs_read1
(
s
)
)
bs_skip
(
s
,
2
+
1
);
// matrix downmix + pseudo_surround
bs_skip
(
s
,
i_num_front
*
(
1
+
4
)
);
bs_skip
(
s
,
i_num_side
*
(
1
+
4
)
);
bs_skip
(
s
,
i_num_back
*
(
1
+
4
)
);
bs_skip
(
s
,
i_num_lfe
*
(
4
)
);
bs_skip
(
s
,
i_num_assoc_data
*
(
4
)
);
bs_skip
(
s
,
i_num_valid_cc
*
(
5
)
);
bs_align
(
s
);
int
i_comment
=
bs_read
(
s
,
8
);
bs_skip
(
s
,
i_comment
*
8
);
bs
w
_skip
(
s
,
2
+
4
);
// object type + sampling index
int
i_num_front
=
bs
w
_read
(
s
,
4
);
int
i_num_side
=
bs
w
_read
(
s
,
4
);
int
i_num_back
=
bs
w
_read
(
s
,
4
);
int
i_num_lfe
=
bs
w
_read
(
s
,
2
);
int
i_num_assoc_data
=
bs
w
_read
(
s
,
3
);
int
i_num_valid_cc
=
bs
w
_read
(
s
,
4
);
if
(
bs
w
_read1
(
s
)
)
bs
w
_skip
(
s
,
4
);
// mono downmix
if
(
bs
w
_read1
(
s
)
)
bs
w
_skip
(
s
,
4
);
// stereo downmix
if
(
bs
w
_read1
(
s
)
)
bs
w
_skip
(
s
,
2
+
1
);
// matrix downmix + pseudo_surround
bs
w
_skip
(
s
,
i_num_front
*
(
1
+
4
)
);
bs
w
_skip
(
s
,
i_num_side
*
(
1
+
4
)
);
bs
w
_skip
(
s
,
i_num_back
*
(
1
+
4
)
);
bs
w
_skip
(
s
,
i_num_lfe
*
(
4
)
);
bs
w
_skip
(
s
,
i_num_assoc_data
*
(
4
)
);
bs
w
_skip
(
s
,
i_num_valid_cc
*
(
5
)
);
bs
w
_align
(
s
);
int
i_comment
=
bs
w
_read
(
s
,
8
);
bs
w
_skip
(
s
,
i_comment
*
8
);
return
0
;
}
static
int
Mpeg4GASpecificConfig
(
mpeg4_cfg_t
*
p_cfg
,
bs_t
*
s
)
static
int
Mpeg4GASpecificConfig
(
mpeg4_cfg_t
*
p_cfg
,
bs
w
_t
*
s
)
{
p_cfg
->
i_frame_length
=
bs_read1
(
s
)
?
960
:
1024
;
p_cfg
->
i_frame_length
=
bs
w
_read1
(
s
)
?
960
:
1024
;
if
(
bs_read1
(
s
)
)
// depend on core coder
bs_skip
(
s
,
14
);
// core coder delay
if
(
bs
w
_read1
(
s
)
)
// depend on core coder
bs
w
_skip
(
s
,
14
);
// core coder delay
int
i_extension_flag
=
bs_read1
(
s
);
int
i_extension_flag
=
bs
w
_read1
(
s
);
if
(
p_cfg
->
i_channel
==
0
)
{
Mpeg4GAProgramConfigElement
(
s
);
}
if
(
p_cfg
->
i_object_type
==
6
||
p_cfg
->
i_object_type
==
20
)
bs_skip
(
s
,
3
);
// layer
bs
w
_skip
(
s
,
3
);
// layer
if
(
i_extension_flag
)
{
if
(
p_cfg
->
i_object_type
==
22
)
{
bs_skip
(
s
,
5
+
11
);
// numOfSubFrame + layer length
bs
w
_skip
(
s
,
5
+
11
);
// numOfSubFrame + layer length
}
if
(
p_cfg
->
i_object_type
==
17
||
p_cfg
->
i_object_type
==
19
||
p_cfg
->
i_object_type
==
20
||
p_cfg
->
i_object_type
==
23
)
{
bs_skip
(
s
,
1
+
1
+
1
);
// ER data : section scale spectral */
bs
w
_skip
(
s
,
1
+
1
+
1
);
// ER data : section scale spectral */
}
if
(
bs_read1
(
s
)
)
// extension 3
if
(
bs
w
_read1
(
s
)
)
// extension 3
fprintf
(
stderr
,
"Mpeg4GASpecificConfig: error 1
\n
"
);
}
return
0
;
}
static
int
Mpeg4ReadAudioObjectType
(
bs_t
*
s
)
static
int
Mpeg4ReadAudioObjectType
(
bs
w
_t
*
s
)
{
int
i_type
=
bs_read
(
s
,
5
);
int
i_type
=
bs
w
_read
(
s
,
5
);
if
(
i_type
==
31
)
i_type
=
32
+
bs_read
(
s
,
6
);
i_type
=
32
+
bs
w
_read
(
s
,
6
);
return
i_type
;
}
static
int
Mpeg4ReadAudioSamplerate
(
bs_t
*
s
)
static
int
Mpeg4ReadAudioSamplerate
(
bs
w
_t
*
s
)
{
int
i_index
=
bs_read
(
s
,
4
);
int
i_index
=
bs
w
_read
(
s
,
4
);
if
(
i_index
!=
0x0f
)
return
pi_sample_rates
[
i_index
];
return
bs_read
(
s
,
24
);
return
bs
w
_read
(
s
,
24
);
}
static
int
Mpeg4ReadAudioSpecificInfo
(
mpeg4_cfg_t
*
p_cfg
,
int
*
pi_extra
,
uint8_t
*
p_extra
,
bs_t
*
s
,
int
i_max_size
)
static
int
Mpeg4ReadAudioSpecificInfo
(
mpeg4_cfg_t
*
p_cfg
,
int
*
pi_extra
,
uint8_t
*
p_extra
,
bs
w
_t
*
s
,
int
i_max_size
)
{
#if 0
static const char *ppsz_otype[] = {
...
...
@@ -533,8 +533,8 @@ static int Mpeg4ReadAudioSpecificInfo( mpeg4_cfg_t *p_cfg, int *pi_extra, uint8_
"DST",
};
#endif
const
int
i_pos_start
=
bs_pos
(
s
);
bs_t
s_sav
=
*
s
;
const
int
i_pos_start
=
bs
w
_pos
(
s
);
bs
w
_t
s_sav
=
*
s
;
int
i_bits
;
int
i
;
...
...
@@ -544,7 +544,7 @@ static int Mpeg4ReadAudioSpecificInfo( mpeg4_cfg_t *p_cfg, int *pi_extra, uint8_
p_cfg
->
i_object_type
=
Mpeg4ReadAudioObjectType
(
s
);
p_cfg
->
i_samplerate
=
Mpeg4ReadAudioSamplerate
(
s
);
p_cfg
->
i_channel
=
bs_read
(
s
,
4
);
p_cfg
->
i_channel
=
bs
w
_read
(
s
,
4
);
if
(
p_cfg
->
i_channel
==
7
)
p_cfg
->
i_channel
=
8
;
// 7.1
else
if
(
p_cfg
->
i_channel
>=
8
)
...
...
@@ -614,14 +614,14 @@ static int Mpeg4ReadAudioSpecificInfo( mpeg4_cfg_t *p_cfg, int *pi_extra, uint8_
case
17
:
case
19
:
case
20
:
case
21
:
case
22
:
case
23
:
case
24
:
case
25
:
case
26
:
case
27
:
{
int
epConfig
=
bs_read
(
s
,
2
);
int
epConfig
=
bs
w
_read
(
s
,
2
);
if
(
epConfig
==
2
||
epConfig
==
3
)
{
//ErrorProtectionSpecificConfig();
}
if
(
epConfig
==
3
)
{
int
directMapping
=
bs_read1
(
s
);
int
directMapping
=
bs
w
_read1
(
s
);
if
(
directMapping
)
{
// tbd ...
...
...
@@ -633,19 +633,19 @@ static int Mpeg4ReadAudioSpecificInfo( mpeg4_cfg_t *p_cfg, int *pi_extra, uint8_
break
;
}
if
(
p_cfg
->
extension
.
i_object_type
!=
5
&&
i_max_size
>
0
&&
i_max_size
-
(
bs_pos
(
s
)
-
i_pos_start
)
>=
16
&&
bs_read
(
s
,
11
)
==
0x2b7
)
if
(
p_cfg
->
extension
.
i_object_type
!=
5
&&
i_max_size
>
0
&&
i_max_size
-
(
bs
w
_pos
(
s
)
-
i_pos_start
)
>=
16
&&
bs
w
_read
(
s
,
11
)
==
0x2b7
)
{
p_cfg
->
extension
.
i_object_type
=
Mpeg4ReadAudioObjectType
(
s
);
if
(
p_cfg
->
extension
.
i_object_type
==
5
)
{
p_cfg
->
i_sbr
=
bs_read1
(
s
);
p_cfg
->
i_sbr
=
bs
w
_read1
(
s
);
if
(
p_cfg
->
i_sbr
==
1
)
{
p_cfg
->
extension
.
i_samplerate
=
Mpeg4ReadAudioSamplerate
(
s
);
if
(
i_max_size
>
0
&&
i_max_size
-
(
bs
_pos
(
s
)
-
i_pos_start
)
>=
12
&&
bs
_read
(
s
,
11
)
==
0x548
)
if
(
i_max_size
>
0
&&
i_max_size
-
(
bs
w_pos
(
s
)
-
i_pos_start
)
>=
12
&&
bsw
_read
(
s
,
11
)
==
0x548
)
{
p_cfg
->
i_ps
=
bs_read1
(
s
);
p_cfg
->
i_ps
=
bs
w
_read1
(
s
);
}
}
}
...
...
@@ -654,38 +654,38 @@ static int Mpeg4ReadAudioSpecificInfo( mpeg4_cfg_t *p_cfg, int *pi_extra, uint8_
//fprintf( stderr, "Mpeg4ReadAudioSpecificInfo: t=%s(%d)f=%d c=%d sbr=%d\n",
// ppsz_otype[p_cfg->i_object_type], p_cfg->i_object_type, p_cfg->i_samplerate, p_cfg->i_channel, p_cfg->i_sbr );
i_bits
=
bs_pos
(
s
)
-
i_pos_start
;
i_bits
=
bs
w
_pos
(
s
)
-
i_pos_start
;
*
pi_extra
=
__MIN
(
(
i_bits
+
7
)
/
8
,
LATM_MAX_EXTRA_SIZE
);
for
(
i
=
0
;
i
<
*
pi_extra
;
i
++
)
{
const
int
i_read
=
__MIN
(
8
,
i_bits
-
8
*
i
);
p_extra
[
i
]
=
bs_read
(
&
s_sav
,
i_read
)
<<
(
8
-
i_read
);
p_extra
[
i
]
=
bs
w
_read
(
&
s_sav
,
i_read
)
<<
(
8
-
i_read
);
}
return
i_bits
;
}
static
int
LatmGetValue
(
bs_t
*
s
)
static
int
LatmGetValue
(
bs
w
_t
*
s
)
{
int
i_bytes
=
bs_read
(
s
,
2
);
int
i_bytes
=
bs
w
_read
(
s
,
2
);
int
v
=
0
;
int
i
;
for
(
i
=
0
;
i
<
i_bytes
;
i
++
)
v
=
(
v
<<
8
)
+
bs_read
(
s
,
8
);
v
=
(
v
<<
8
)
+
bs
w
_read
(
s
,
8
);
return
v
;
}
static
int
LatmReadStreamMuxConfiguration
(
latm_mux_t
*
m
,
bs_t
*
s
)
static
int
LatmReadStreamMuxConfiguration
(
latm_mux_t
*
m
,
bs
w
_t
*
s
)
{
int
i_mux_version
;
int
i_mux_versionA
;
int
i_program
;
i_mux_version
=
bs_read
(
s
,
1
);
i_mux_version
=
bs
w
_read
(
s
,
1
);
i_mux_versionA
=
0
;
if
(
i_mux_version
)
i_mux_versionA
=
bs_read
(
s
,
1
);
i_mux_versionA
=
bs
w
_read
(
s
,
1
);
if
(
i_mux_versionA
!=
0
)
/* support only A=0 */
return
-
1
;
...
...
@@ -700,15 +700,15 @@ static int LatmReadStreamMuxConfiguration( latm_mux_t *m, bs_t *s )
}
}
m
->
b_same_time_framing
=
bs_read1
(
s
);
m
->
i_sub_frames
=
1
+
bs_read
(
s
,
6
);
m
->
i_programs
=
1
+
bs_read
(
s
,
4
);
m
->
b_same_time_framing
=
bs
w
_read1
(
s
);
m
->
i_sub_frames
=
1
+
bs
w
_read
(
s
,
6
);
m
->
i_programs
=
1
+
bs
w
_read
(
s
,
4
);
for
(
i_program
=
0
;
i_program
<
m
->
i_programs
;
i_program
++
)
{
int
i_layer
;
m
->
pi_layers
[
i_program
]
=
1
+
bs_read
(
s
,
3
);
m
->
pi_layers
[
i_program
]
=
1
+
bs
w
_read
(
s
,
3
);
for
(
i_layer
=
0
;
i_layer
<
m
->
pi_layers
[
i_program
];
i_layer
++
)
{
...
...
@@ -721,7 +721,7 @@ static int LatmReadStreamMuxConfiguration( latm_mux_t *m, bs_t *s )
b_previous_cfg
=
false
;
if
(
i_program
!=
0
||
i_layer
!=
0
)
b_previous_cfg
=
bs_read1
(
s
);
b_previous_cfg
=
bs
w
_read1
(
s
);
if
(
b_previous_cfg
)
{
...
...
@@ -735,33 +735,33 @@ static int LatmReadStreamMuxConfiguration( latm_mux_t *m, bs_t *s )
i_cfg_size
=
LatmGetValue
(
s
);
i_cfg_size
-=
Mpeg4ReadAudioSpecificInfo
(
&
st
->
cfg
,
&
st
->
i_extra
,
st
->
extra
,
s
,
i_cfg_size
);
if
(
i_cfg_size
>
0
)
bs_skip
(
s
,
i_cfg_size
);
bs
w
_skip
(
s
,
i_cfg_size
);
}
st
->
i_frame_length_type
=
bs_read
(
s
,
3
);
st
->
i_frame_length_type
=
bs
w
_read
(
s
,
3
);
switch
(
st
->
i_frame_length_type
)
{
case
0
:
{
bs_skip
(
s
,
8
);
/* latmBufferFullnes */
bs
w
_skip
(
s
,
8
);
/* latmBufferFullnes */
if
(
!
m
->
b_same_time_framing
)
{
if
(
st
->
cfg
.
i_object_type
==
6
||
st
->
cfg
.
i_object_type
==
20
||
st
->
cfg
.
i_object_type
==
8
||
st
->
cfg
.
i_object_type
==
24
)
{
bs_skip
(
s
,
6
);
/* eFrameOffset */
bs
w
_skip
(
s
,
6
);
/* eFrameOffset */
}
}
break
;
}
case
1
:
st
->
i_frame_length
=
bs_read
(
s
,
9
);
st
->
i_frame_length
=
bs
w
_read
(
s
,
9
);
break
;
case
3
:
case
4
:
case
5
:
st
->
i_frame_length_index
=
bs_read
(
s
,
6
);
// celp
st
->
i_frame_length_index
=
bs
w
_read
(
s
,
6
);
// celp
break
;
case
6
:
case
7
:
st
->
i_frame_length_index
=
bs_read
(
s
,
1
);
// hvxc
st
->
i_frame_length_index
=
bs
w
_read
(
s
,
1
);
// hvxc
default:
break
;
}
...
...
@@ -771,7 +771,7 @@ static int LatmReadStreamMuxConfiguration( latm_mux_t *m, bs_t *s )
}
/* other data */
if
(
bs_read1
(
s
)
)
if
(
bs
w
_read1
(
s
)
)
{
if
(
i_mux_version
==
1
)
{
...
...
@@ -781,16 +781,16 @@ static int LatmReadStreamMuxConfiguration( latm_mux_t *m, bs_t *s )
{
int
b_continue
;
do
{
b_continue
=
bs_read1
(
s
);
m
->
i_other_data
=
(
m
->
i_other_data
<<
8
)
+
bs_read
(
s
,
8
);
b_continue
=
bs
w
_read1
(
s
);
m
->
i_other_data
=
(
m
->
i_other_data
<<
8
)
+
bs
w
_read
(
s
,
8
);
}
while
(
b_continue
);
}
}
/* crc */
m
->
i_crc
=
-
1
;
if
(
bs_read1
(
s
)
)
m
->
i_crc
=
bs_read
(
s
,
8
);
if
(
bs
w
_read1
(
s
)
)
m
->
i_crc
=
bs
w
_read
(
s
,
8
);
return
0
;
}
...
...
@@ -798,14 +798,14 @@ static int LatmReadStreamMuxConfiguration( latm_mux_t *m, bs_t *s )
static
int
LOASParse
(
decoder_t
*
p_dec
,
uint8_t
*
p_buffer
,
int
i_buffer
)
{
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
bs_t
s
;
bs
w
_t
s
;
int
i_sub
;
int
i_accumulated
=
0
;
bs
_init
(
&
s
,
p_buffer
,
i_buffer
);
bs
w_init_writable
(
&
s
,
p_buffer
,
i_buffer
);
/* Read the stream mux configuration if present */
if
(
!
bs_read1
(
&
s
)
)
if
(
!
bs
w
_read1
(
&
s
)
)
{
if
(
!
LatmReadStreamMuxConfiguration
(
&
p_sys
->
latm
,
&
s
)
&&
p_sys
->
latm
.
i_streams
>
0
)
...
...
@@ -858,7 +858,7 @@ static int LOASParse( decoder_t *p_dec, uint8_t *p_buffer, int i_buffer )
int
i_payload
=
0
;
for
(
;;
)
{
int
i_tmp
=
bs_read
(
&
s
,
8
);
int
i_tmp
=
bs
w
_read
(
&
s
,
8
);
i_payload
+=
i_tmp
;
if
(
i_tmp
!=
255
)
break
;
...
...
@@ -873,7 +873,7 @@ static int LOASParse( decoder_t *p_dec, uint8_t *p_buffer, int i_buffer )
(
st
->
i_frame_length_type
==
5
)
||
(
st
->
i_frame_length_type
==
7
)
)
{
bs_skip
(
&
s
,
2
);
// muxSlotLengthCoded
bs
w
_skip
(
&
s
,
2
);
// muxSlotLengthCoded
pi_payload
[
i_program
][
i_layer
]
=
0
;
/* TODO */
}
else
...
...
@@ -898,13 +898,13 @@ static int LOASParse( decoder_t *p_dec, uint8_t *p_buffer, int i_buffer )
/* FIXME that's slow (and a bit ugly to write in place) */
for
(
i
=
0
;
i
<
pi_payload
[
i_program
][
i_layer
];
i
++
)
p_buffer
[
i_accumulated
++
]
=
bs_read
(
&
s
,
8
);
p_buffer
[
i_accumulated
++
]
=
bs
w
_read
(
&
s
,
8
);
}
}
}
else
{
const
int
i_chunks
=
bs_read
(
&
s
,
4
);
const
int
i_chunks
=
bs
w
_read
(
&
s
,
4
);
int
pi_program
[
16
];
int
pi_layer
[
16
];
int
i_chunk
;
...
...
@@ -913,7 +913,7 @@ static int LOASParse( decoder_t *p_dec, uint8_t *p_buffer, int i_buffer )
for
(
i_chunk
=
0
;
i_chunk
<
i_chunks
;
i_chunk
++
)
{
const
int
streamIndex
=
bs_read
(
&
s
,
4
);
const
int
streamIndex
=
bs
w
_read
(
&
s
,
4
);
latm_stream_t
*
st
=
&
p_sys
->
latm
.
stream
[
streamIndex
];
const
int
i_program
=
st
->
i_program
;
const
int
i_layer
=
st
->
i_layer
;
...
...
@@ -926,13 +926,13 @@ static int LOASParse( decoder_t *p_dec, uint8_t *p_buffer, int i_buffer )
int
i_payload
=
0
;
for
(
;;
)
{
int
i_tmp
=
bs_read
(
&
s
,
8
);
int
i_tmp
=
bs
w
_read
(
&
s
,
8
);
i_payload
+=
i_tmp
;
if
(
i_tmp
!=
255
)
break
;
}
pi_payload
[
i_program
][
i_layer
]
=
i_payload
;
bs_skip
(
&
s
,
1
);
// auEndFlag
bs
w
_skip
(
&
s
,
1
);
// auEndFlag
}
else
if
(
st
->
i_frame_length_type
==
1
)
{
...
...
@@ -942,7 +942,7 @@ static int LOASParse( decoder_t *p_dec, uint8_t *p_buffer, int i_buffer )
(
st
->
i_frame_length_type
==
5
)
||
(
st
->
i_frame_length_type
==
7
)
)
{
bs_read
(
&
s
,
2
);
// muxSlotLengthCoded
bs
w
_read
(
&
s
,
2
);
// muxSlotLengthCoded
}
else
{
...
...
@@ -962,7 +962,7 @@ static int LOASParse( decoder_t *p_dec, uint8_t *p_buffer, int i_buffer )
{
/* Other data XXX we just ignore them */
}
bs_align
(
&
s
);
bs
w
_align
(
&
s
);
return
i_accumulated
;
}
...
...
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