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
13901390 int last_mul_index = -1;
13911391 int mul_count = 1 << log2_mul_count;
13921392
1393− score_sum[log2_mul_count] += log2_mul_count;
1393+ score_sum[log2_mul_count] += log2_mul_count * log2_mul_count;
13941394 for (int i= 0; i<pixel_num; i++) {
13951395 int64_t val = sc->unit[p][i].val;
13961396 int mul_index = (val + 1LL)*mul_count >> 32;
@@ -1414,11 +1414,17 @@ static void encode_float32_remap(FFV1Context *f, FFV1SliceContext *sc, · 17 unmodified lines
14141414 }
14151415
14161416 cost = FFMAX((delta + mul/2) / mul, 1);
1417− score_tab[si] += log2(cost);
1418− if (mul > 1)
1419− score_tab[si] += log2(fabs(delta - cost*mul)+1) * (1 + (mul_count > 1));
1417+ float score = 1;
1418+ if (mul > 1) {
1419+ score *= (fabs(delta - cost*mul)+1);
1420+ if (mul_count > 1)
1421+ score *= score;
1422+ }
1423+ score *= cost;
1424+ score *= score;
14201425 if (mul_index != last_mul_index)
1421− score_tab[si] += 0.5*log2(mul);
1426+ score *= mul;
1427+ score_tab[si] += log2f(score);
14221428 }
14231429 }
14241430 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