MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / encode_float32_remap_segment

Function encode_float32_remap_segment

libavcodec/ffv1enc.c:1289–1402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1287}
1288
1289static int encode_float32_remap_segment(FFV1SliceContext *sc,
1290 int p, int mul_count, int *mul_tab, int update, int final)
1291{
1292 const int pixel_num = sc->slice_width * sc->slice_height;
1293 uint8_t state[2][3][32];
1294 int mul[4096+1];
1295 RangeCoder rc = sc->c;
1296 int lu = 0;
1297 int run = 0;
1298 int64_t last_val = -1;
1299 int compact_index = -1;
1300 int i = 0;
1301 int current_mul_index = -1;
1302 int run1final = 0;
1303 int run1start_i;
1304 int run1start_last_val;
1305 int run1start_mul_index;
1306
1307 memcpy(mul, mul_tab, sizeof(*mul_tab)*(mul_count+1));
1308 memset(state, 128, sizeof(state));
1309 put_symbol(&rc, state[0][0], mul_count, 0);
1310 memset(state, 128, sizeof(state));
1311
1312 for (; i < pixel_num+1; i++) {
1313 int current_mul = current_mul_index < 0 ? 1 : FFABS(mul[current_mul_index]);
1314 int64_t val;
1315 if (i == pixel_num) {
1316 if (last_val == 0xFFFFFFFF && (!run || run1final)) {
1317 break;
1318 } else {
1319 val = last_val + ((1LL<<32) - last_val + current_mul - 1) / current_mul * current_mul;
1320 av_assert2(val >= (1LL<<32));
1321 val += lu * current_mul; //ensure a run1 ends
1322 }
1323 } else
1324 val = sc->unit[p][i].val;
1325
1326 if (last_val != val) {
1327 int64_t delta = val - last_val;
1328 int64_t step = FFMAX(1, (delta + current_mul/2) / current_mul);
1329 av_assert2(last_val < val);
1330 av_assert2(current_mul > 0);
1331
1332 delta -= step*current_mul;
1333 av_assert2(delta <= current_mul/2);
1334 av_assert2(delta > -current_mul);
1335
1336 av_assert2(step > 0);
1337 if (lu) {
1338 if (!run) {
1339 run1start_i = i - 1;
1340 run1start_last_val = last_val;
1341 run1start_mul_index= current_mul_index;
1342 }
1343 if (step == 1) {
1344 if (run1final) {
1345 if (current_mul>1)
1346 put_symbol_inline(&rc, state[lu][1], delta, 1, NULL, NULL);

Callers 1

encode_float32_remapFunction · 0.85

Calls 3

put_symbol_inlineFunction · 0.85
get_rac_countFunction · 0.85
put_symbolFunction · 0.70

Tested by

no test coverage detected