return *s;
}
-static void lcg_seek(uint32_t *s, int64_t dt)
+static void lcg_seek(uint32_t *s, uint32_t dt)
{
uint32_t a, c, t = *s;
- if (dt >= 0) {
- a = LCG_A;
- c = LCG_C;
- } else { /* coefficients for a step backward */
- a = LCG_AI;
- c = (uint32_t)(LCG_AI * LCG_C);
- dt = -dt;
- }
+ a = LCG_A;
+ c = LCG_C;
while (dt) {
if (dt & 1)
t = a * t + c;
ws->next_inter = i;
ws->next_ts = i < ws->nb_inter ? ws->inter[i].ts_start : INF_TS;
*last = -1;
- lcg_seek(&ws->dither_state, ts - ws->cur_ts);
+ lcg_seek(&ws->dither_state, (uint32_t)ts - (uint32_t)ws->cur_ts);
if (ws->pink_need) {
int64_t pink_ts_cur = (ws->cur_ts + PINK_UNIT - 1) & ~(PINK_UNIT - 1);
int64_t pink_ts_next = ts & ~(PINK_UNIT - 1);
edata_end = edata + avc->extradata_size;
ws->nb_inter = AV_RL32(edata);
edata += 4;
- if (ws->nb_inter < 0)
+ if (ws->nb_inter < 0 || (edata_end - edata) / 24 < ws->nb_inter)
return AVERROR(EINVAL);
ws->inter = av_calloc(ws->nb_inter, sizeof(*ws->inter));
if (!ws->inter)
dt = in->ts_end - in->ts_start;
switch (in->type) {
case WS_SINE:
- if (edata_end - edata < 20)
+ if (edata_end - edata < 20 || avc->sample_rate <= 0)
return AVERROR(EINVAL);
f1 = AV_RL32(edata + 0);
f2 = AV_RL32(edata + 4);