There is a special case I missed, its simpler to just store
Unified · Split
| @@ -1268,6 +1268,7 @@ typedef struct RemapEncoderState { · 1267 unmodified lines | |||
| 1268 | int run1final; | 1268 | int run1final; |
| 1269 | int64_t run1start_i; | 1269 | int64_t run1start_i; |
| 1270 | int64_t run1start_last_val; | 1270 | int64_t run1start_last_val; |
| 1271 | int run1start_mul_index; | ||
| 1271 | } RemapEncoderState; | 1272 | } RemapEncoderState; |
| 1272 | 1273 | ||
| 1273 | static inline void copy_state(RemapEncoderState *dst, const RemapEncoderState *src) | 1274 | static inline void copy_state(RemapEncoderState *dst, const RemapEncoderState *src) |
| @@ -1287,6 +1288,7 @@ static inline void copy_state(RemapEncoderState *dst, const RemapEncoderState *s · 13 unmodified lines | |||
| 1287 | dst->run1final = src->run1final; | 1288 | dst->run1final = src->run1final; |
| 1288 | dst->run1start_i = src->run1start_i; | 1289 | dst->run1start_i = src->run1start_i; |
| 1289 | dst->run1start_last_val = src->run1start_last_val; | 1290 | dst->run1start_last_val = src->run1start_last_val; |
| 1291 | dst->run1start_mul_index = src->run1start_mul_index; | ||
| 1290 | } | 1292 | } |
| 1291 | 1293 | ||
| 1292 | static int encode_float32_remap_segment(FFV1SliceContext *sc, | 1294 | static int encode_float32_remap_segment(FFV1SliceContext *sc, |
| @@ -1337,6 +1339,7 @@ static int encode_float32_remap_segment(FFV1SliceContext *sc, · 44 unmodified lines | |||
| 1337 | if (!s.run) { | 1339 | if (!s.run) { |
| 1338 | s.run1start_i = s.i - 1; | 1340 | s.run1start_i = s.i - 1; |
| 1339 | s.run1start_last_val = s.last_val; | 1341 | s.run1start_last_val = s.last_val; |
| 1342 | s.run1start_mul_index= s.current_mul_index; | ||
| 1340 | } | 1343 | } |
| 1341 | if (step == 1) { | 1344 | if (step == 1) { |
| 1342 | if (s.run1final) { | 1345 | if (s.run1final) { |
| @@ -1355,9 +1358,7 @@ static int encode_float32_remap_segment(FFV1SliceContext *sc, · 12 unmodified lines | |||
| 1355 | put_symbol_inline(&s.rc, s.state[s.lu][0], s.run, 0, NULL, NULL); | 1358 | put_symbol_inline(&s.rc, s.state[s.lu][0], s.run, 0, NULL, NULL); |
| 1356 | s.i = s.run1start_i; | 1359 | s.i = s.run1start_i; |
| 1357 | s.last_val = s.run1start_last_val; // we could compute this instead of storing | 1360 | s.last_val = s.run1start_last_val; // we could compute this instead of storing |
| 1358 | av_assert2(s.last_val >= 0 && s.i >= 0); // first state is zero run so we cant have this in a one run and current_mul_index would be -1 | 1361 | s.current_mul_index = s.run1start_mul_index; |
| 1359 | if (s.run) | ||
| 1360 | s.current_mul_index = ((s.last_val + 1) * s.mul_count) >> 32; | ||
| 1361 | } | 1362 | } |
| 1362 | s.run1final ^= 1; | 1363 | s.run1final ^= 1; |
| 1363 | 1364 | ||