Commit f6bb7390 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Revert "vlc_bits: Differentiate between writable bits stream and read only."

This reverts commit 4bfba26a.
This broke strict C aliasing rules.
parent 182692ca
......@@ -30,25 +30,15 @@
*/
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, const void *p_data, unsigned i_data )
static inline void bs_init( bs_t *s, void *p_data, int i_data )
{
s->p_start = p_data;
s->p = p_data;
......@@ -151,67 +141,25 @@ static inline void bs_skip( bs_t *s, int i_count )
}
}
/*
* 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 )
static inline void bs_write( bs_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 )
{
......@@ -221,7 +169,7 @@ static inline void bsw_write( bsw_t *s, int i_count, uint32_t i_bits )
}
}
static inline void bsw_align( bsw_t *s )
static inline void bs_align( bs_t *s )
{
if( s->i_left != 8 )
{
......@@ -230,16 +178,20 @@ static inline void bsw_align( bsw_t *s )
}
}
static inline void bsw_align_0( bsw_t *s )
static inline void bs_align_0( bs_t *s )
{
if( s->i_left != 8 )
bsw_write( s, s->i_left, 0 );
{
bs_write( s, s->i_left, 0 );
}
}
static inline void bsw_align_1( bsw_t *s )
static inline void bs_align_1( bs_t *s )
{
while( s->i_left != 8 )
bsw_write( s, 1, 1 );
{
bs_write( s, 1, 1 );
}
}
#endif
......@@ -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;
bsw_t bsw;
bs_t bs;
bsw_init_writable( &bsw, p_data->p_buffer + p_sys->i_image_offset,
bs_init( &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++ )
......@@ -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 = bsw_read( &bsw, 4 );
uint8_t i_val = bs_read( &bs, 4 );
if( i_val == 0 )
{
/* Fill the rest of the line with next color */
i_color = bsw_read( &bsw, 4 );
i_color = bs_read( &bs, 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,
}
}
bsw_align( &bsw );
bs_align( &bs );
}
}
}
This diff is collapsed.
......@@ -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;
bsw_t bs;
bs_t bs;
bsw_init_writable( &bs, p_data->p_buffer + p_sys->i_image_offset,
bs_init( &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 = bsw_read( &bs, 2 );
if( i_color == 0 && (i_count = bsw_read( &bs, 2 )) )
i_color = bs_read( &bs, 2 );
if( i_color == 0 && (i_count = bs_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;
}
bsw_align( &bs );
bs_align( &bs );
}
/* odd field */
bsw_init_writable( &bs, p_data->p_buffer + p_sys->i_image_offset +
bs_init( &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 );
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment