6060#endif
6161
6262#define ROS 5
63-
63+ #define RSI_USED ( state ) ((size_t)(state->rsip - state->rsi_buffer))
6464#define BUFFERSPACE (strm ) (strm->avail_in >= strm->state->in_blklen \
6565 && strm->avail_out >= strm->state->out_blklen)
6666
@@ -203,7 +203,7 @@ static inline void check_rsi_end(struct aec_stream *strm)
203203 */
204204 struct internal_state * state = strm -> state ;
205205
206- if (state -> rsi_size == ( size_t )( state -> rsip - state -> rsi_buffer )) {
206+ if (state -> rsi_size == RSI_USED ( state )) {
207207 state -> flush_output (strm );
208208 state -> flush_start = state -> rsi_buffer ;
209209 state -> rsip = state -> rsi_buffer ;
@@ -523,7 +523,7 @@ static int m_zero_block(struct aec_stream *strm)
523523 fs_drop (strm );
524524
525525 if (zero_blocks == ROS ) {
526- b = (int )(state -> rsip - state -> rsi_buffer ) / strm -> block_size ;
526+ b = (int )RSI_USED (state ) / strm -> block_size ;
527527 zero_blocks = MIN (strm -> rsi - b , 64 - (b % 64 ));
528528 } else if (zero_blocks > ROS ) {
529529 zero_blocks -- ;
@@ -537,7 +537,7 @@ static int m_zero_block(struct aec_stream *strm)
537537 zero_bytes = i * state -> bytes_per_sample ;
538538
539539 if (strm -> avail_out >= zero_bytes ) {
540- if (state -> rsi_size - (state -> rsip - state -> rsi_buffer ) < i )
540+ if (state -> rsi_size - RSI_USED (state ) < i )
541541 return M_ERROR ;
542542
543543 memset (state -> rsip , 0 , i * sizeof (uint32_t ));
0 commit comments