aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ffmpeg/avcodec.pas
diff options
context:
space:
mode:
authork-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-05-16 21:57:58 +0000
committerk-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-05-16 21:57:58 +0000
commita0846a75fdac01df21161ff4d76371544fab4c1a (patch)
treefb5deb2cce29a304c549a93aa1d03ce33793782d /src/lib/ffmpeg/avcodec.pas
parentc227fad8311d25fc5f91b1b959e7b45f543ca0be (diff)
downloadusdx-a0846a75fdac01df21161ff4d76371544fab4c1a.tar.gz
usdx-a0846a75fdac01df21161ff4d76371544fab4c1a.tar.xz
usdx-a0846a75fdac01df21161ff4d76371544fab4c1a.zip
arithmetic solution on bit level for AVERROR_SIGN. Delphi cannot handle the solution with directives. Still needs check on powerpc.
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2377 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src/lib/ffmpeg/avcodec.pas')
-rw-r--r--src/lib/ffmpeg/avcodec.pas20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/lib/ffmpeg/avcodec.pas b/src/lib/ffmpeg/avcodec.pas
index 175ed053..2c98f8fa 100644
--- a/src/lib/ffmpeg/avcodec.pas
+++ b/src/lib/ffmpeg/avcodec.pas
@@ -4693,13 +4693,21 @@ const
{$ENDIF}
{$ENDIF}
+(**
+ * We need the sign of of the error, because some platforms have
+ * E* and errno already negated. The previous version failed
+ * with Delphi, because it needs EINVAL defined.
+ * Warning: This code is platform dependent and assumes constants
+ * to be 32 bit.
+ * This version does the following steps:
+ * 1) shr 6: shifts the sign bit to bit position 2
+ * 2) and $00000002: sets all other bits to zero
+ * positive EINVAL gives 0, negative gives 2
+ * 3) not: inverts all bits. This gives -1 and -3
+ * 4) + 2: positive EINVAL gives 1, negative -1
+ *)
const
-{$IF EINVAL > 0}
- AVERROR_SIGN = -1;
-{$ELSE}
- {* Some platforms have E* and errno already negated. *}
- AVERROR_SIGN = 1;
-{$IFEND}
+ AVERROR_SIGN = not((EINVAL shr 6) and $00000002) + 2;
(*
#if EINVAL > 0