History

avcodec/ffv1enc: replace 3 double precision log2() by 1 single precision log2()

This makes the remap finding heuristic much faster

Michael Niedermayer committed 1 year ago

Commit 98c17881 parent b4d165c1 file · +11 −5Browse files

Unified · Split

libavcodec/ffv1enc.c+11−5
@@ -1390,7 +1390,7 @@ static void encode_float32_remap(FFV1Context *f, FFV1SliceContext *sc, · 1389 unmodified lines
1390 int last_mul_index = -1;1390 int last_mul_index = -1;
1391 int mul_count = 1 << log2_mul_count;1391 int mul_count = 1 << log2_mul_count;
1392 1392
1393 score_sum[log2_mul_count] += log2_mul_count;1393 score_sum[log2_mul_count] += log2_mul_count * log2_mul_count;
1394 for (int i= 0; i<pixel_num; i++) {1394 for (int i= 0; i<pixel_num; i++) {
1395 int64_t val = sc->unit[p][i].val;1395 int64_t val = sc->unit[p][i].val;
1396 int mul_index = (val + 1LL)*mul_count >> 32;1396 int mul_index = (val + 1LL)*mul_count >> 32;
@@ -1414,11 +1414,17 @@ static void encode_float32_remap(FFV1Context *f, FFV1SliceContext *sc, · 17 unmodified lines
1414 }1414 }
1415 1415
1416 cost = FFMAX((delta + mul/2) / mul, 1);1416 cost = FFMAX((delta + mul/2) / mul, 1);
1417 score_tab[si] += log2(cost);1417 float score = 1;
1418 if (mul > 1)1418 if (mul > 1) {
1419 score_tab[si] += log2(fabs(delta - cost*mul)+1) * (1 + (mul_count > 1));1419 score *= (fabs(delta - cost*mul)+1);
1420 if (mul_count > 1)
1421 score *= score;
1422 }
1423 score *= cost;
1424 score *= score;
1420 if (mul_index != last_mul_index)1425 if (mul_index != last_mul_index)
1421 score_tab[si] += 0.5*log2(mul);1426 score *= mul;
1427 score_tab[si] += log2f(score);
1422 }1428 }
1423 }1429 }
1424 last_val = val;1430 last_val = val;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t