History

avcodec/evc_parse: remove pow() and log2()

The use of float based functions is both unneeded and wrong due to unpredictable rounding

Michael Niedermayer committed 3 years ago

Commit d35eecd1 parent f2687a31 file · +6 −4Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/evc_parse.c+6−4
@@ -172,7 +172,8 @@ int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh, · 171 unmodified lines
172172 poc->PicOrderCntVal = 0;
173173 poc->DocOffset = -1;
174174 } else {
175− int SubGopLength = (int)pow(2.0, sps->log2_sub_gop_length);
175+ int SubGopLength = 1 << sps->log2_sub_gop_length;
176+
176177 if (tid == 0) {
177178 poc->PicOrderCntVal = poc->prevPicOrderCntVal + SubGopLength;
178179 poc->DocOffset = 0;
@@ -187,15 +188,16 @@ int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh, · 8 unmodified lines
187188 poc->prevPicOrderCntVal += SubGopLength;
188189 ExpectedTemporalId = 0;
189190 } else
190− ExpectedTemporalId = 1 + (int)log2(poc->DocOffset);
191+ ExpectedTemporalId = 1 + av_log2(poc->DocOffset);
192+
191193 while (tid != ExpectedTemporalId) {
192194 poc->DocOffset = (poc->DocOffset + 1) % SubGopLength;
193195 if (poc->DocOffset == 0)
194196 ExpectedTemporalId = 0;
195197 else
196− ExpectedTemporalId = 1 + (int)log2(poc->DocOffset);
198+ ExpectedTemporalId = 1 + av_log2(poc->DocOffset);
197199 }
198− PocOffset = (int)(SubGopLength * ((2.0 * poc->DocOffset + 1) / (int)pow(2.0, tid) - 2));
200+ PocOffset = (int)(SubGopLength * ((2.0 * poc->DocOffset + 1) / (1 << tid) - 2));
199201 poc->PicOrderCntVal = poc->prevPicOrderCntVal + PocOffset;
200202 }
201203 }

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