X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcodec%2Faraw.c;h=b4c9dad832bf9cd2b29620fe021933533b164f9c;hb=c0641836357466d938339b33bdac3e357ce733d9;hp=fcf091ee7ff28d68eb57bc2cbde76e6980ace633;hpb=b8813031072aa91c046f25f3937dc573066e183b;p=vlc diff --git a/modules/codec/araw.c b/modules/codec/araw.c index fcf091ee7f..b4c9dad832 100644 --- a/modules/codec/araw.c +++ b/modules/codec/araw.c @@ -336,7 +336,7 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) p_block = *pp_block; - if( p_block->i_pts != 0 && + if( p_block->i_pts > VLC_TS_INVALID && p_block->i_pts != date_Get( &p_sys->end_date ) ) { date_Set( &p_sys->end_date, p_block->i_pts ); @@ -349,7 +349,7 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) } /* Don't re-use the same pts twice */ - p_block->i_pts = 0; + p_block->i_pts = VLC_TS_INVALID; i_samples = p_block->i_buffer / p_sys->i_bytespersample / p_dec->fmt_in.audio.i_channels; @@ -370,15 +370,16 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) return NULL; } - p_out->start_date = date_Get( &p_sys->end_date ); - p_out->end_date = date_Increment( &p_sys->end_date, i_samples ); + p_out->i_pts = date_Get( &p_sys->end_date ); + p_out->i_length = date_Increment( &p_sys->end_date, i_samples ) + - p_out->i_pts; if( p_sys->p_logtos16 ) { int16_t *s = (int16_t*)p_out->p_buffer; unsigned int i; - for( i = 0; i < p_out->i_nb_bytes / 2; i++ ) + for( i = 0; i < p_out->i_buffer / 2; i++ ) { *s++ = p_sys->p_logtos16[*p_block->p_buffer++]; p_block->i_buffer--; @@ -386,9 +387,9 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) } else { - memcpy( p_out->p_buffer, p_block->p_buffer, p_out->i_nb_bytes ); - p_block->p_buffer += p_out->i_nb_bytes; - p_block->i_buffer -= p_out->i_nb_bytes; + memcpy( p_out->p_buffer, p_block->p_buffer, p_out->i_buffer ); + p_block->p_buffer += p_out->i_buffer; + p_block->i_buffer -= p_out->i_buffer; } return p_out; @@ -1375,11 +1376,11 @@ static block_t *EncoderEncode( encoder_t *p_enc, aout_buffer_t *p_aout_buf ) encoder_sys_t *p_sys = p_enc->p_sys; block_t *p_block = NULL; - if( !p_aout_buf || !p_aout_buf->i_nb_bytes ) return NULL; + if( !p_aout_buf || !p_aout_buf->i_buffer ) return NULL; if( p_sys->i_s16tolog ) { - if( ( p_block = block_New( p_enc, p_aout_buf->i_nb_bytes / 2 ) ) ) + if( ( p_block = block_New( p_enc, p_aout_buf->i_buffer / 2 ) ) ) { int8_t *s = (int8_t*)p_block->p_buffer; // sink int16_t *aout = (int16_t*)p_aout_buf->p_buffer; // source @@ -1387,7 +1388,7 @@ static block_t *EncoderEncode( encoder_t *p_enc, aout_buffer_t *p_aout_buf ) if( p_sys->i_s16tolog == ALAW ) { - for( i = 0; i < p_aout_buf->i_nb_bytes / 2; i++ ) + for( i = 0; i < p_aout_buf->i_buffer / 2; i++ ) { if( *aout >= 0) *s++ = alaw_encode[*aout / 16]; @@ -1399,7 +1400,7 @@ static block_t *EncoderEncode( encoder_t *p_enc, aout_buffer_t *p_aout_buf ) } else /* ULAW */ { - for( i = 0; i < p_aout_buf->i_nb_bytes / 2; i++ ) + for( i = 0; i < p_aout_buf->i_buffer / 2; i++ ) { if( *aout >= 0) *s++ = ulaw_encode[*aout / 4]; @@ -1411,15 +1412,15 @@ static block_t *EncoderEncode( encoder_t *p_enc, aout_buffer_t *p_aout_buf ) } } } - else if( ( p_block = block_New( p_enc, p_aout_buf->i_nb_bytes ) ) ) + else if( ( p_block = block_New( p_enc, p_aout_buf->i_buffer ) ) ) { memcpy( p_block->p_buffer, p_aout_buf->p_buffer, - p_aout_buf->i_nb_bytes ); + p_aout_buf->i_buffer ); } if( p_block ) { - p_block->i_dts = p_block->i_pts = p_aout_buf->start_date; + p_block->i_dts = p_block->i_pts = p_aout_buf->i_pts; p_block->i_length = (int64_t)p_aout_buf->i_nb_samples * (int64_t)1000000 / p_enc->fmt_in.audio.i_rate; }