ws_snd: use memcpy() and memset() instead of loops
This commit is contained in:
parent
6896aa7a38
commit
618b067d21
@ -60,7 +60,6 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
|
|||||||
|
|
||||||
int in_size, out_size;
|
int in_size, out_size;
|
||||||
int sample = 128;
|
int sample = 128;
|
||||||
int i;
|
|
||||||
uint8_t *samples = data;
|
uint8_t *samples = data;
|
||||||
uint8_t *samples_end;
|
uint8_t *samples_end;
|
||||||
|
|
||||||
@ -87,8 +86,7 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
|
|||||||
samples_end = samples + out_size;
|
samples_end = samples + out_size;
|
||||||
|
|
||||||
if (in_size == out_size) {
|
if (in_size == out_size) {
|
||||||
for (i = 0; i < out_size; i++)
|
memcpy(samples, buf, out_size);
|
||||||
*samples++ = *buf++;
|
|
||||||
*data_size = out_size;
|
*data_size = out_size;
|
||||||
return buf_size;
|
return buf_size;
|
||||||
}
|
}
|
||||||
@ -153,16 +151,15 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
|
|||||||
sample = av_clip_uint8(sample);
|
sample = av_clip_uint8(sample);
|
||||||
*samples++ = sample;
|
*samples++ = sample;
|
||||||
} else { /* copy */
|
} else { /* copy */
|
||||||
for (count++; count > 0; count--) {
|
memcpy(samples, buf, smp);
|
||||||
*samples++ = *buf++;
|
samples += smp;
|
||||||
}
|
buf += smp;
|
||||||
sample = buf[-1];
|
sample = buf[-1];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: /* run */
|
default: /* run */
|
||||||
for(count++; count > 0; count--) {
|
memset(samples, sample, smp);
|
||||||
*samples++ = sample;
|
samples += smp;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user