diff options
author | k-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2012-05-03 21:02:31 +0000 |
---|---|---|
committer | k-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2012-05-03 21:02:31 +0000 |
commit | 8d7de6a0515b5e2eca3179df4d76f48b1e0d2965 (patch) | |
tree | 77e3c05f76990a23a6bb2b2ebd8286df0fd2ba48 /src | |
parent | af2ef1052277f25d86d8b0f014312fbcdef113f2 (diff) | |
download | usdx-8d7de6a0515b5e2eca3179df4d76f48b1e0d2965.tar.gz usdx-8d7de6a0515b5e2eca3179df4d76f48b1e0d2965.tar.xz usdx-8d7de6a0515b5e2eca3179df4d76f48b1e0d2965.zip |
update the implementation of av_cmp_q
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2870 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/ffmpeg-0.10/rational.pas | 22 | ||||
-rw-r--r-- | src/lib/ffmpeg-0.7/rational.pas | 22 | ||||
-rw-r--r-- | src/lib/ffmpeg-0.8/rational.pas | 22 | ||||
-rw-r--r-- | src/lib/ffmpeg/rational.pas | 19 |
4 files changed, 75 insertions, 10 deletions
diff --git a/src/lib/ffmpeg-0.10/rational.pas b/src/lib/ffmpeg-0.10/rational.pas index 19c1026a..c0d76168 100644 --- a/src/lib/ffmpeg-0.10/rational.pas +++ b/src/lib/ffmpeg-0.10/rational.pas @@ -155,19 +155,37 @@ function av_find_nearest_q_idx(q: TAVRational; q_list: {const} PAVRationalArray) implementation -function av_cmp_q (a: TAVRational; b: TAVRational): cint; +function av_cmp_q (a: TAVRational; b: TAVRational): cint; {$IFDEF HasInline}inline;{$ENDIF} var tmp: cint64; begin tmp := a.num * cint64(b.den) - b.num * cint64(a.den); +{ old version if (tmp <> 0) then Result := (tmp shr 63) or 1 else + Result := 0; +} +{ C original: + if(tmp) return ((tmp ^ a.den ^ b.den)>>63)|1; + else if(b.den && a.den) return 0; + else if(a.num && b.num) return (a.num>>31) - (b.num>>31); + else return INT_MIN; +} + + if tmp <> 0 then + Result := ((tmp xor a.den xor b.den) >> 63) or 1 + else if (b.den and a.den) <> 0 then Result := 0 + else if (a.num and b.num) <> 0 then + Result := (a.num >> 31) - (b.num >> 31) + else + Result := low(cint); + end; -function av_q2d(a: TAVRational): cdouble; +function av_q2d(a: TAVRational): cdouble; {$IFDEF HasInline}inline;{$ENDIF} begin Result := a.num / a.den; end; diff --git a/src/lib/ffmpeg-0.7/rational.pas b/src/lib/ffmpeg-0.7/rational.pas index a6792100..371a6fd7 100644 --- a/src/lib/ffmpeg-0.7/rational.pas +++ b/src/lib/ffmpeg-0.7/rational.pas @@ -152,19 +152,37 @@ implementation // This corresponds to the old c version and should be updated to // the new c version. -function av_cmp_q (a: TAVRational; b: TAVRational): cint; +function av_cmp_q (a: TAVRational; b: TAVRational): cint; {$IFDEF HasInline}inline;{$ENDIF} var tmp: cint64; begin tmp := a.num * cint64(b.den) - b.num * cint64(a.den); +{ old version if (tmp <> 0) then Result := (tmp shr 63) or 1 else + Result := 0; +} +{ C original: + if(tmp) return ((tmp ^ a.den ^ b.den)>>63)|1; + else if(b.den && a.den) return 0; + else if(a.num && b.num) return (a.num>>31) - (b.num>>31); + else return INT_MIN; +} + + if tmp <> 0 then + Result := ((tmp xor a.den xor b.den) >> 63) or 1 + else if (b.den and a.den) <> 0 then Result := 0 + else if (a.num and b.num) <> 0 then + Result := (a.num >> 31) - (b.num >> 31) + else + Result := low(cint); + end; -function av_q2d(a: TAVRational): cdouble; +function av_q2d(a: TAVRational): cdouble; {$IFDEF HasInline}inline;{$ENDIF} begin Result := a.num / a.den; end; diff --git a/src/lib/ffmpeg-0.8/rational.pas b/src/lib/ffmpeg-0.8/rational.pas index f20fc68f..d3601ec5 100644 --- a/src/lib/ffmpeg-0.8/rational.pas +++ b/src/lib/ffmpeg-0.8/rational.pas @@ -152,19 +152,37 @@ implementation // This corresponds to the old c version and should be updated to // the new c version. -function av_cmp_q (a: TAVRational; b: TAVRational): cint; +function av_cmp_q (a: TAVRational; b: TAVRational): cint; {$IFDEF HasInline}inline;{$ENDIF} var tmp: cint64; begin tmp := a.num * cint64(b.den) - b.num * cint64(a.den); +{ old version if (tmp <> 0) then Result := (tmp shr 63) or 1 else + Result := 0; +} +{ C original: + if(tmp) return ((tmp ^ a.den ^ b.den)>>63)|1; + else if(b.den && a.den) return 0; + else if(a.num && b.num) return (a.num>>31) - (b.num>>31); + else return INT_MIN; +} + + if tmp <> 0 then + Result := ((tmp xor a.den xor b.den) >> 63) or 1 + else if (b.den and a.den) <> 0 then Result := 0 + else if (a.num and b.num) <> 0 then + Result := (a.num >> 31) - (b.num >> 31) + else + Result := low(cint); + end; -function av_q2d(a: TAVRational): cdouble; +function av_q2d(a: TAVRational): cdouble; {$IFDEF HasInline}inline;{$ENDIF} begin Result := a.num / a.den; end; diff --git a/src/lib/ffmpeg/rational.pas b/src/lib/ffmpeg/rational.pas index 892f2273..24bbfa8d 100644 --- a/src/lib/ffmpeg/rational.pas +++ b/src/lib/ffmpeg/rational.pas @@ -151,7 +151,7 @@ function av_find_nearest_q_idx(q: TAVRational; q_list: {const} PAVRationalArray) implementation -function av_cmp_q (a: TAVRational; b: TAVRational): cint; +function av_cmp_q (a: TAVRational; b: TAVRational): cint; {$IFDEF HasInline}inline;{$ENDIF} var tmp: cint64; begin @@ -160,16 +160,27 @@ begin if (tmp <> 0) then Result := (tmp shr 63) or 1 else - Result := 0 -{ new version: + Result := 0; + +{ C original: if(tmp) return ((tmp ^ a.den ^ b.den)>>63)|1; else if(b.den && a.den) return 0; else if(a.num && b.num) return (a.num>>31) - (b.num>>31); else return INT_MIN; } +{ + if tmp <> 0 then + Result := ((tmp xor a.den xor b.den) >> 63) or 1 + else if (b.den and a.den) <> 0 then + Result := 0 + else if (a.num and b.num) <> 0 then + Result := (a.num >> 31) - (b.num >> 31) + else + Result := low(cint); +} end; -function av_q2d(a: TAVRational): cdouble; +function av_q2d(a: TAVRational): cdouble; {$IFDEF HasInline}inline;{$ENDIF} begin Result := a.num / a.den; end; |