Compare commits

..

668 Commits
1.7.2 ... 1.7.3

Author SHA1 Message Date
Siana Gearz
4cd2de0fff Version 1.7.3 2013-01-20 05:57:05 +01:00
Siana Gearz
b318a0703b Use standard way on windows to find default file picker path 2013-01-20 05:55:18 +01:00
Siana Gearz
ea67aca955 This should de-clog the tubes on the map 2013-01-20 03:32:51 +01:00
Siana Gearz
0ab140a071 Potential permission fix 2013-01-20 01:49:55 +01:00
Siana Gearz
d5eb2432ef Merge branch 'master' of github.com:singularity-viewer/SingularityViewer 2013-01-20 01:49:14 +01:00
Aleric Inglewood
7a8a2757db Add comment for sake of translation. 2013-01-18 16:10:18 +01:00
Aleric Inglewood
d8d3cafc32 Merge remote-tracking branch 'singu/master' 2013-01-18 02:28:17 +01:00
Aleric Inglewood
604824335c Keep focus during Freeze Time so that pressing ESC always leaves Freeze Time. 2013-01-18 02:26:43 +01:00
Latif Khalifa
9240147874 Merge remote-tracking branch 'lirusato/master' 2013-01-17 17:26:00 +01:00
Lirusaito
05a6323d2c French antispam controls touchup 2013-01-17 09:17:43 -05:00
Lirusaito
1dd0b7713b French translation fixies~ 2013-01-17 03:38:53 -05:00
Lirusaito
795f70a0b0 d520053 - MAINT-852 / VWR-8761 : Cannot delete object description. Now you can. 2013-01-17 01:11:59 -05:00
Lirusaito
5831af0fb6 OPEN-161: Typo in the header guard of lltexturecache.h 2013-01-17 01:10:47 -05:00
Aleric Inglewood
e8e3e43711 Update llqtwebkit with recompiled version. 2013-01-17 00:43:21 +01:00
Latif Khalifa
460b05d37a Merge remote-tracking branch 'shyotl/master' 2013-01-16 16:25:51 +01:00
Latif Khalifa
f03405ca47 Merge remote-tracking branch 'lirusato/master' 2013-01-16 16:25:37 +01:00
Lirusaito
0405ed9e3d French Translation update. 2013-01-16 09:27:25 -05:00
Lirusaito
2eb8f2f84a 07e5202 MAINT-1942 Increase maximum animation length from 30 seconds to 60 seconds 2013-01-16 05:00:35 -05:00
Shyotl
6894d4c0bc Changed how the 'client' column in avatar radar is handled. Initially was not designed nor tested to be toggleable on user-demand (was one shot deal depending on detected grid). 2013-01-15 23:14:58 -06:00
Lirusaito
53c04b7299 Issue 220: Copy/paste params in the build tools like phoenix
Adds mClipboardFlexiParams, mClipboardLightParams, mClipboardSculptParams, and mClipboardLightImageParams to LLPanelObject.
Corrects the tooltip on the the copy button.
2013-01-15 22:43:22 -05:00
Latif Khalifa
3bf307abb0 Merge remote-tracking branch 'shyotl/master' 2013-01-15 18:37:09 +01:00
Latif Khalifa
4928d29a8e Merge remote-tracking branch 'aleric/master' 2013-01-15 18:36:51 +01:00
Latif Khalifa
8cec9c7b73 Merge remote-tracking branch 'lirusato/master' 2013-01-15 18:36:39 +01:00
Shyotl
a6e3352073 Setting camera toolset as current sticks us into build mode (??)... Avoid when taking snapshots. 2013-01-14 23:09:12 -06:00
Aleric Inglewood
0eeea37662 Fix 'Open floater in Freeze Time mode'
When the floater was opened in Freeze Time mode, then parent of the
widget that triggers it to open is the 'Floater View'. We do NOT
want to set that MouseOpaque :p. Using getParent here is just
nonsense.
2013-01-15 03:31:57 +01:00
Shyotl
2a8f55e99e Updated gesture floater to use more modern (and actual working) method of adding list elements via xml. 2013-01-14 18:41:48 -06:00
Aleric Inglewood
db7b0c1785 Revert last part (work in progress of last two commits, I guess). 2013-01-15 00:11:17 +01:00
Aleric Inglewood
55e64f6ab0 Fix for last commit.
Show sculpties with no (or not enough) data as spheres with default LOD
stepping.
2013-01-14 23:53:58 +01:00
Aleric Inglewood
6fce7062e5 Fix gcc 4.4 problem.
When a sculptie has too few vertices, especially when we bluntly assume
it's stitched around and don't want to get less than 4 vertices in
either direction, then instead we end up with even ZERO vertices, which
causes a division by zero in LLPath::genNGon with undefined behavior.
2013-01-14 23:14:29 +01:00
Aleric Inglewood
2df8ba19f4 Fix last compiler warning. 2013-01-14 22:59:49 +01:00
Aleric Inglewood
e4a3b3b5ba Merge remote-tracking branch 'shyotl/master' 2013-01-14 16:12:57 +01:00
Lirusaito
0494dc8d32 Fix Issue 432: Radar Keeps Popping Up and side issue I got still the window "An object owned by you ..."
Unified key message sending to function send_keys_message()
Switched a few getBOOLs to CachedControls
Added RadarChatKeysStopAsking, and RadarChatKeysRequest as a three button notification so the user can decide to permanently say no.
Corrected RadarChatKeys description to be more accurate.
If we want to know if the radar is open, we check instanceExists, not getInstance.
Also enabled using the announce button when RadarChatKeys is false to announce keys, for manual updates.
2013-01-14 06:34:27 -05:00
Latif Khalifa
3dd33518c4 Merge remote-tracking branch 'shyotl/master' 2013-01-14 10:53:27 +01:00
Shyotl
db8225a078 Fixup LLScrollListCtrl::setCommentText, and incorrect behaviors with script editor and bulk perm editor pertaining to setCommentText inherited from V3. 2013-01-14 03:36:04 -06:00
Damian Zhaoying
00fb7804da Spanish Translate for new Group/Chat/IM floaters and some general string fixed 2013-01-13 19:05:35 -03:00
Siana Gearz
cddd21d879 Merge branch 'master' of github.com:singularity-viewer/SingularityViewer 2013-01-13 20:11:15 +01:00
Aleric Inglewood
dcc2e52c61 Merge remote-tracking branch 'singu/master' 2013-01-13 18:01:48 +01:00
Latif Khalifa
11c5e1cf4c Merge branch 'master' into 1.7.3-dev 2013-01-13 12:45:43 +01:00
Latif Khalifa
cef7ea9f5e Merge remote-tracking branch 'lirusato/master' into 1.7.3-dev 2013-01-13 12:45:37 +01:00
Latif Khalifa
31d2a15957 Merge remote-tracking branch 'aleric/master' into 1.7.3-dev 2013-01-13 12:45:25 +01:00
Aleric Inglewood
3a414b21fa Temporary workaround for release. 2013-01-13 02:18:00 +01:00
Aleric Inglewood
e99a906f54 Testsuite part 1: make it compile alone. 2013-01-13 01:58:49 +01:00
Aleric Inglewood
fc4b02cee8 Moved HTTPTimeout to it's own files. 2013-01-12 23:00:21 +01:00
Aleric Inglewood
e01567553e Added default message for feed uploads.
By default show 'Type your message here...' and if the text editor
never got focus, replace that with a default message.
2013-01-12 21:31:21 +01:00
Aleric Inglewood
bf7b0bf4bf Hide floater until success/failure (or floater is re-opened) 2013-01-12 21:16:40 +01:00
Lirusaito
ece92a1b7c Optionally, have group chat and conference buttons on title line.
Adds UseConciseGroupChatButtons, and UseConciseConferenceButtons
Adds "Buttons on group chat name line (Affects new group chats)" and "Buttons on conference title line (Affects new conferences)" checkboxes to Adv. Chat's Chat UI tab.
Adds floater_instant_message_ad_hoc_concisebuttons.xml, floater_instant_message_group_concisebuttons.xml

Brings panel_speaker_controls.xml's speakers_list down by 7 pixels, which is necessary because it is awkwardly high in old places as well, such as Local Chat.
2013-01-12 14:42:55 -05:00
Aleric Inglewood
2da5c51e42 Do not freeze UI when snapshot floater is opened the first time. 2013-01-12 17:35:01 +01:00
Aleric Inglewood
57228fa208 Fix upload snapshot to inventory callback mechanism. 2013-01-12 17:27:33 +01:00
Aleric Inglewood
024c62aed4 Fix the "map/set iterators incompatible" bug.
cookies is only valid when AIHTTPReceivedHeaders::getValues return true.
2013-01-12 04:24:21 +01:00
Aleric Inglewood
e56f14502e Fill fd_sets AFTER processing command queue. 2013-01-12 02:51:44 +01:00
Lirusaito
82eb1a946e Fix group buttons in horizontal and allow the horizontal buttoned friends and groups floater to take up minimal space. 2013-01-11 19:17:06 -05:00
Siana Gearz
b6f1bb570f Merge branch 'master' of git://github.com/Lirusaito/SingularityViewer 2013-01-12 00:59:06 +01:00
Siana Gearz
896036b3c2 Removing ReSit, because it's not so very nice 2013-01-12 00:50:24 +01:00
Lirusaito
e51937cee7 Warn more clearly about LLRadioGroup::setValue being used wrong, and attempt to recover with LLUICtrl::setValue. 2013-01-11 18:21:48 -05:00
Lirusaito
a47dbf88bb Fix Issue 590: Debug Settings parameters setting is seriously bugged 2013-01-11 15:50:47 -05:00
Aleric Inglewood
f9a868a979 Compile fix for VC++ 2013-01-11 17:16:05 +01:00
Latif Khalifa
56542a02e8 Use multiple cores for compilation of the Debug build 2013-01-11 11:28:21 +01:00
Lirusaito
2dda9499fa Unhide Client column properly on non-SL Grids. 2013-01-11 03:56:55 -05:00
Aleric Inglewood
f9738cb611 Add getName() to every non-base class Responder object. 2013-01-11 04:15:55 +01:00
Aleric Inglewood
741a160913 Fine tune of private (libcwd) assertion.
It turns out that it's possible to receive data before an upload
finished when the server sends HTTP_BAD_REQUEST in the middle of the
upload (this happens to me when I try to upload a 6000x6000 image to my
profile feed, with is a 44MB file). So, in that case the finished upload
detection did not fail and we shouldn't assert.
2013-01-11 01:28:46 +01:00
Aleric Inglewood
5daf817e7e Upload larger original to profile feed. 2013-01-10 19:42:19 +01:00
Aleric Inglewood
9175bc0e16 Fixed LLUploadDialog to display it's text.
Also made the view rectangle have some minimal size (1/10th of the
screens width and height).
Increased the used font a bit.
Fixed removal of the dialog in the case of uploading to profile feed.
2013-01-10 18:48:02 +01:00
Lirusaito
b7f1fdd9cc Vertical space recovered 2013-01-09 11:25:46 -05:00
Lirusaito
07f88d21bd Applied STORM-1209 and added string AGroupMemberNamed for translation. 2013-01-09 11:05:37 -05:00
Lirusaito
a7d1a4611f Optionally, have IM buttons on the same line as the person's name.
Adds UseConciseIMButtons.
Adds floater_instant_message_concisebuttons.xml
Adds Have buttons on the same line as name for IMs (Affects new IMs) checkbox to Adv. Chat's Chat UI tab.
2013-01-09 10:19:41 -05:00
Lirusaito
c96b840c53 Split off certain preferences into new Adv. Chat subtab Chat UI
From Text Chat: Disallow communicate shortcut opening detached friends list
From Vanity: Use horizontal buttons for contacts floater (needs restart)
The rest were in Chat/IM of Vanity.
2013-01-09 07:30:49 -05:00
Lirusaito
70445ab8a3 Add option for Horizontal buttons on Contacts floater.
Adds Use horizontal buttons for contacts floater (needs restart) to Vanity Preferences.
Adds ContactsUseHorizontalButtons.
Adds FloaterContactsHorizRect for saving horizontal contacts rect.
Adds panel_friends_horiz.xml, panel_group_horiz.xml, and floater_my_friends_horiz.xml

Also corrects string value for FloaterContactsRect
2013-01-08 20:21:15 -05:00
Aleric Inglewood
136e6dd389 New debug channel dc::snapshot. 2013-01-09 00:54:53 +01:00
Siana Gearz
94edef2c3f Merge branch 'master' of git://github.com/AlericInglewood/SingularityViewer 2013-01-09 00:07:57 +01:00
Siana Gearz
1434e8d6e9 Merge branch 'master' of git://github.com/Lirusaito/SingularityViewer 2013-01-09 00:07:34 +01:00
Siana Gearz
54a53b574f Follow fix and clean-up 2013-01-09 00:07:17 +01:00
Aleric Inglewood
63ae33eca7 Fix crash in AICurlPrivate::curlthread::PollSet::next
Introduced in
6dcda3595e
(Add recovery for randomly closed socket desciptors.)

By copying CurlSocketInfo* into mCopiedFileDescriptors, it was possible
that we accessed a deleted CurlSocketInfo for it's filedescriptor,
returning a random value, which, when passed to FD_ISSET could cause a
SIGSEGV.

I reverted this change and now store the literal socket descriptors in
mCopiedFileDescriptors again. It is not a problem when libcurl deletes
the corresponding CurlSocketInfo (through a callback to
MultiHandle::socket_callback) in that case, because the fd_set we test
against isn't updated as a result of that, not until we're down with
mCopiedFileDescriptors (at the re-entry of select()).
2013-01-08 23:43:25 +01:00
Lirusaito
b485048f6b Show local chat bar in floater... (Needs restart) 2013-01-08 17:17:52 -05:00
Lirusaito
3ed2da9282 Once more change the behavior of minimizing new chats in open in separate floater mode, to be a little more truthful. 2013-01-08 14:53:08 -05:00
Aleric Inglewood
5188693469 Compile fix for last commit and Release 2013-01-08 20:33:29 +01:00
Lirusaito
68911876b9 Option to Disallow communicate shortcut opening detached friends list
Added CommunicateSpecificShortcut
Added checkbox to Text Chat preferences
2013-01-08 13:48:18 -05:00
Lirusaito
820b4ea358 Optionally, remove chatbar from local chat floater.
FloaterChatBarlessRect keeps the size of this separate, for those who want to switch by mood.
ShowLocalChatFloaterBar toggles this.
Show local chat bar in floater entry added to Adv. Chat prefs.
floater_chat_history_barless.xml added for this.
2013-01-08 12:16:51 -05:00
Aleric Inglewood
d8485350e7 Address clang warnings.
* Split off AIThreadSafeBitsPOD, because offsetof may only be used on POD types.
* Added ASSERT_ONLY and ASSERT_ONLY_COMMA
* Removed a few unused class members
* Fixed a bug in AIHTTPReceivedHeaders::equal that more or less only
  compared the length of the headers before :/
2013-01-08 17:50:09 +01:00
Lirusaito
b4b6186f54 Re: 3ea353bef3, fix minimize case to minimize and not steal focus. Also apply to group chats. 2013-01-08 08:43:55 -05:00
Lirusaito
3ea353bef3 Change default behavior of separated non-local chats mode to open minimized. 2013-01-08 06:33:07 -05:00
Lirusaito
67e4518132 Scroll to the object's texture if the user has a copy in their inventory. EXT-5403? Fixes part of Issue 501. 2013-01-07 18:32:54 -05:00
Lirusaito
0636f0049a Rectify the problem in which profile images would be below the window border when first opened. 2013-01-07 18:20:02 -05:00
Aleric Inglewood
4b592f7507 Merge remote-tracking branch 'singu/master' 2013-01-07 17:58:53 +01:00
Aleric Inglewood
a9a308e5e9 Never freeze again.
Put snapshot related floaters always on top of the full screen preview.
Make having multiple running uploads more robust.
Fix infinite recursion when clicking on the bottom 'Snapshot' button
under certain conditions.
Unfreeze time more robust; unfreeze time out of precaution when
starting an upload (if 'Keep open' not checked).
Fixed a bug that caused all callbacks for successful feed uploads to be
ignored.
2013-01-06 23:40:53 +01:00
Siana Gearz
cd27184332 Take out buggy padding removal in OJ 2013-01-06 04:01:28 +01:00
Siana Gearz
d5892bbb32 My preliminary thoughts on OpenJPEG 2013-01-06 02:38:12 +01:00
Siana Gearz
20ae72e5fa CMake needs proper quoting 2013-01-05 23:25:47 +01:00
Siana Gearz
7fc4348f64 Fix build deselect 2013-01-05 22:14:10 +01:00
Lirusaito
5ec116021a Feature request: Alt-R for Region/Estate floater 2013-01-05 01:45:55 -05:00
Lirusaito
a992333744 Zi Ree's Debug Setting Floater awesomeness (Search!!)
Made to work with Singularity, and also be a bit better..
Alphabetizes includes.
Switches settings combobox to a scrolllist, and Boolean combobox to a radiogroup.
Makes floater resizable, aligns a lot of the UI, and prepares it all for proper resize behavior.
Adds Copy button for copying the name of the debug setting.
Yay, verbosity! Also adds FloaterDebugSettingsRect to keep track of the floater's size.

Also somehow the getInstance line snuck out of last commit... tossed it in here.
2013-01-05 01:43:17 -05:00
Siana Gearz
fefe0df922 Merge branch 'master' of git://github.com/AlericInglewood/SingularityViewer 2013-01-03 23:37:00 +01:00
Siana Gearz
509bdcb891 Merge branch 'master' of git://github.com/Lirusaito/SingularityViewer 2013-01-03 23:36:55 +01:00
Aleric Inglewood
2fbd53807c Do not use LLCachedControl as global variables. 2013-01-03 23:25:18 +01:00
Lirusaito
9498375e75 Update LLFloaterSettingsDebug to match up with v-d.
Adds boost::bind and makes the floater a singleton.
2013-01-03 17:20:57 -05:00
Aleric Inglewood
639b264d2d Do not crash upon corrupted HTTP header.
This addresses the reported assertion by luis thibodeaux.
2013-01-03 21:06:20 +01:00
Lirusaito
c3829485e4 Fixed LLCompileQueue messages via update to v-d in parts. Script resets now output properly~ 2013-01-03 14:08:39 -05:00
Lirusaito
88de1b28a2 Add MoyMiniMapCustomColor swatch to Vanity Preferences.
Fixed spacing of MoyMiniMapCustomColor in settings_ascent_coa.xml and removed it from settings_per_account.xml

TODO: Make MoyMiniMapCustomColor more flexible.
-Added ColorCustomChat checkbox, pref code, and setting commented out.
2013-01-03 13:59:14 -05:00
Siana Gearz
17e0c79fe7 Build fix Linux 2013-01-03 03:03:06 +01:00
Siana Gearz
ddef80d2cf Revert "Attempt to fix frame timer on broken mainboards"
This reverts commit 5eb99b7d2f.
2013-01-03 03:02:15 +01:00
Siana Gearz
1872337f5f Merge branch 'master' of git://github.com/AlericInglewood/SingularityViewer 2013-01-03 02:17:20 +01:00
Siana Gearz
6e219f0a4e Merge branch 'master' of https://github.com/Shyotl/SingularityViewer 2013-01-03 02:15:51 +01:00
Shyotl
a408c2211b Workaround for targetomega'd objects turning jittery when zoomed in on. 2013-01-02 18:42:26 -06:00
Siana Gearz
8b2dcb6cb0 We're supposed to use HTTP bake fetch now 2013-01-03 00:10:56 +01:00
Aleric Inglewood
b0fe12f597 Snapshot Freeze Time: add Langolier tag for new (invisible) avatars.
If an avatar TP's in while you are in Freeze Time mode, they now have a
visible tag with the tag 'Langolier' in it. After exiting Freeze Time
mode they become visible. Before they would stay invisible.
2013-01-03 00:02:28 +01:00
Siana Gearz
9a1cc8b9a8 Translation cleanup script fix 2013-01-02 23:47:05 +01:00
Siana Gearz
cce4d50378 Merge branch 'master' of git://github.com/Lirusaito/SingularityViewer 2013-01-02 23:00:46 +01:00
Siana Gearz
e732e62b39 Tiny cleanup 2013-01-02 22:56:04 +01:00
Lirusaito
728056acdb Add support for Aurora's extended land layer codes to llvlmanager.cpp 2013-01-01 20:15:21 -05:00
Lirusaito
b85d282dfb WindLightRefresh added for compliance with Aurora's windlight event system. 2013-01-01 18:09:45 -05:00
Lirusaito
194902798b HippoGridManager and HippoLimits updated with Aurora bits from Voodoo.
Adds isAurora() to HippoGridManager
Adds setAuroraLimits and Aurora case to setLimits() in HippoLimits
2013-01-01 18:04:39 -05:00
Aleric Inglewood
cc276ff232 More snapshot UI tweaks. 2013-01-01 22:34:22 +01:00
Aleric Inglewood
5538fe27e5 Snapshot improvements.
* Warn when it was not possible to make a snapshot because the difference
between the aspect of the required target size and the required target
aspect itself is too large.
* Reset Feed and Postcard Aspect to Default when making a new snapshot.
* Fixed a rounding error that caused one-pixel size error.
2013-01-01 21:30:13 +01:00
Lirusaito
c0ba3e95f3 Ability to change default behavior of Chats being torn off so that all chats appear minimized upon opening, as well, regardless of conditions.
Adds debug setting OtherChatsTornOffAndMinimized
Not added to ui xml because the default behavior is likely fine.
2012-12-31 19:06:23 -05:00
Lirusaito
4ec6f853d8 In-Group feature request: Ability to have chats torn off, by default.
Best viewed without space changes... or maybe it doesn't matter any more.
Debug setting OtherChatsTornOff added.
Added Open new IMs in separate floaters checkbox to  Adv. Chat.
Moved Show group name in chat to the right column on top of Adv. Chat panel.

So how's this work?
Two ways.. 1. The user opens a chat; 2. A chat is started from another party to the user.
In 1, we open the chat in a separate floater and focus the floater.
In 2, we check if there is a floater currently in focus before opening the chat
if so, we minimize the floater, setting focus back to whatever floater the user was focused on;
if not, we leave the new chat floater open and focused.

Note that this will NOT alter the default behavior at all, we can't be having that.
2012-12-31 17:06:30 -05:00
Aleric Inglewood
6dcda3595e Add recovery for randomly closed socket desciptors.
Although it should never happen that a file descriptor is suddenly
closed, it appeared that this happens on linux 64bit when using
FMODex... Not really sure how useful this is, but at least now the
viewer just continues to work, as if -say- the socket was closed
remotely. Before the curl thread would go into a tight loop that it
wouldn't recover from until the watchdog thread terminated the viewer.
2012-12-31 19:24:37 +01:00
Aleric Inglewood
c4a9eb9e44 Work around for 'version `OPENSSL_1.0.0' not found'
When linking against the prebuilt libcrypto.so.1.0.0 and
libssl.so.1.0.0 there is a problem running the viewer in
gdb (on debian) because gdb links with libpython2.7.so
which needs a newer openssl on my system (OPENSSL_1.0.1).

The patch allows to work around this problem by defining
-DUSE_SYSTEM_OPENSSL:BOOL=ON when configuring, which then
causes the viewer to be compiled against the system libs.
(If you already installed the prebuilt, you have to manually
remove them with script/install.py --uninstall openSSL).

The prebuilt libcurl expects a function SSLv2_client_method
however, which is not present in my openssl system libs.
A stub was added which is possible because the function
in question isn't used anyway.
2012-12-31 16:15:36 +01:00
Lirusaito
ba57bb1396 In-group feature request: Allow coloring chat of special people (Friends, Estate Owner, Lindens, Muted Residents)
Added ColorFriendChat, ColorEstateOwnerChat, ColorLindenChat, and ColorMutedChat.
Did some spaces to tabs work, view without space changes.
Add checkboxes beneath corresponding color swatches and "Use colors for chat:" text to Vanity.
Fix Ascent*Color Comments strings.

Also fix the issue where clicking ones name in a group chat would result in it opening a random profile.
2012-12-31 06:24:35 -05:00
Lirusaito
f94f4a1191 Satisfy Issue 100: When timestamp it set to include seconds, the seconds do not get included with IM & chat logs.
Best viewed without space changes.
SecondsInLog debug setting added.
Seconds in Log timestamps checkbox added to Adv. Chat prefs.
2012-12-31 04:54:59 -05:00
Lirusaito
469f76e690 Added "Request New Feature..." to Help->Bug Reporting menu. 2012-12-30 16:21:01 -05:00
Lirusaito
0098466704 Fix for WordFromTheWise's missing lsl strings issue. 2012-12-30 16:09:08 -05:00
Lirusaito
48ddfd25d4 Skins request! Black Red, Black Light Blue, and Black Dark! 2012-12-30 16:07:07 -05:00
Aleric Inglewood
2f3841d7e6 Update of print_diagnostics.
CURLE_COULDNT_CONNECT only happens when we actually get
an error (ie, 'connection refused'). If we time out while the connect
attempt is still running then we get CURLE_OPERATION_TIMEDOUT.
2012-12-30 21:11:10 +01:00
Lirusaito
1cde242f06 Merge branch 'master' of https://github.com/DamianZhaoying/SingularityViewer 2012-12-30 14:05:35 -05:00
Damian Zhaoying
a0b227fdd8 fixes and UI translations tweeks to fit in spanish language 2012-12-30 15:38:11 -03:00
Aleric Inglewood
36a79d7cbe Merge remote-tracking branch 'shyotl/master' 2012-12-30 02:57:11 +01:00
Lirusaito
2c491bc905 Break out LLMakeOutfitDialog.
Added "Make Outfit..." to Edit menu and Create->"New Outfit" to inventory floater menu.
Cleaned up LLMakeOutfitDialog, using boost::bind and less waste.
Moved onMakeOutfitCommit() to LLMakeOutfitDialog as makeOutfit()
Also changes LLFloaterCustomize's callbacks to use boost::bind
Give new outfit dialog a title instead of a heading.

Small fix to mistake with AnnounceSnapshots xmlstuffs.
2012-12-29 19:24:17 -05:00
Aleric Inglewood
a25c405eae Fix assert after failed login.
reset_login(), among others, sets the state back to STATE_LOGIN_SHOW,
which then causes gViewerWindow->initWorldUI() to be called, which
is the (only) function that calls
LLMenuOptionPathfindingRebakeNavmesh::initialize.
In other words, it's perfectly normal to enter that function
a second time and the assert is erroneous.
2012-12-29 18:08:46 +01:00
Aleric Inglewood
e666c60e7d Merge remote-tracking branch 'singu/master' 2012-12-29 17:05:15 +01:00
Aleric Inglewood
6a45e68c73 Merge branch 'master' into llwebprofile 2012-12-29 17:03:46 +01:00
Aleric Inglewood
59b313352b Third time I have to fix this... weird 2012-12-29 17:03:16 +01:00
Aleric Inglewood
9e04f9ba80 Enable/disable upload/send button correctly.
Passes an 'index' magic number to the upload/save functions which
pass that back to the *Done callbacks, so we know if the *raw*
snapshot is still up to date when the upload succeeds or fails.
2012-12-29 16:51:29 +01:00
Lirusaito
cf5838505f In-world feature request: Announce in chat when someone has taken a snapshot.
AnnounceSnapshots debug setting.
"Announce when someone takes a snapshot" added to Vanity Main Preferences.
took_a_snapshot translatable string added to strings.xml

Also in this commit:
Turned PlayTypingSound check into LLCachedControl.
In preparation for the crippling of all old viewers, the Vanity Main tab shall henceforth only be called Main, not Main  (General)
This change has been made in the code comments and the UI itself.
2012-12-29 07:58:06 -05:00
Lirusaito
23469c00de Satisfy Issue 411: Song list in local chat - not a floater
AnnounceStreamMetadata debug setting.
"Announce music stream's metadata in local chat when tuned in" checkbox added to vanity main preferences.
Made the words Title and Artist translatable, as well as the "Now playing" string.
2012-12-29 07:45:05 -05:00
Siana Gearz
66083d6531 Removing leftover dead code 2012-12-28 21:07:19 +01:00
Aleric Inglewood
1c3748e923 Merge remote-tracking branch 'lirusaito/llwebprofile' into llwebprofile 2012-12-28 17:04:29 +01:00
Aleric Inglewood
88bf01fe6f Avoid crashing at exit by joining the curl thread. 2012-12-28 16:59:04 +01:00
Siana Gearz
a969a8f99c UseNewTargetOmegaCode loosely ported from Henri 2012-12-28 16:46:06 +01:00
Aleric Inglewood
ef0e34a278 Do not attach cam to avatar in Freeze Time mode.
We do, and the avatar moves then the cam jumps
away from the frozen avatar to where it really is.

Unfortunately, it's still not possible to attach
the cam to moving objects with this patch.
Also, scripted changes to objects are still visible,
like changes in local lights of texture full brightness.
2012-12-28 16:40:08 +01:00
Lirusaito
50eb45991d "attachments and wearables", not "clothing and wearables" 2012-12-28 02:13:50 -05:00
Lirusaito
ffa405dad9 Comment cleanup. 2012-12-28 01:25:11 -05:00
Lirusaito
1f966eb6c3 Merge branch 'master' of git://github.com/Shyotl/SingularityViewer 2012-12-28 01:21:28 -05:00
Lirusaito
b503540075 Always remember to save after making a change. (Location works now) 2012-12-28 00:33:08 -05:00
Lirusaito
2be305d39e Improvements!
Fix CMakeLists being out of order.
Add setting SnapshotFeedAddLocation to keep track of user's preference whether or not to include location in uploads to profile feed.
Clean up LLFloaterFeed to take only what it needs, also gave it a boost~
Remove saveFeed() from LLFloaterSnapshot, removing the dependency on LLWebProfile.
Compile fixes for LLFloaterSnapshot.
Prettied up the upload to feed floater.

TODO: Does Location even work? I can't get it to appear, never seems to get used right in v-d either.
2012-12-28 00:14:54 -05:00
Shyotl
f6ee966e17 Clean up LLAvatarListEntry creation/destruction and resolve LLAvatarPropertiesProcessor retaining deleted observers. 2012-12-27 21:59:59 -06:00
Drake Arconis
246315c723 This is the Cupcake Commit. Cupcakes. Also may fix linux fmodex64. 2012-12-27 15:15:27 -05:00
Aleric Inglewood
be8f16a8e6 Disable upload/send button immediately.
Immediately disables button and reenables it
again when upload/save was a failure.
The callback is now ignored if the snapshot
was refresh in the meantime.
2012-12-27 19:02:58 +01:00
Aleric Inglewood
32614d3539 Compile bug fix 2012-12-27 17:38:28 +01:00
Aleric Inglewood
aab978c7ea WIP: floater_snapshot_feed.xml and code.
This is just a skeleton, roughly copied from the Postcoard
code, which is very similar. Nothing in indra/newview/llfloaterfeed.cpp
has been changed yet, apart from a few deletions (to make it compile)
and the literal replacement of "Postcard" with "Feed".
indra/newview/llfloatersnapshot.cpp was updated however to
open the new floater when one tries to upload a snapshot to the feed.
It is still needed to make a callback to saveFeed(), or rather to
move that function to the saveFeed that is in llfloatersnapshot.cpp.
2012-12-27 17:13:47 +01:00
Lirusaito
d4b48fae6f Merge branch 'master' of https://github.com/singularity-viewer/SingularityViewer 2012-12-26 15:50:38 -05:00
Lirusaito
0433bd8560 Gemini young age color should look more natural for Gemini. 2012-12-26 13:09:05 -05:00
Shyotl
71eb0fedd9 Merge branch 'master' of git://github.com/lkalif/SingularityViewer.git 2012-12-25 06:17:42 -06:00
Latif Khalifa
9056ae72d3 Point library downloads to bitbucket since github is depreciating binary downloads 2012-12-25 11:57:59 +01:00
Latif Khalifa
430a5359ac Merge remote-tracking branch 'upstream/master' 2012-12-25 11:47:32 +01:00
Inusaito Sayori
5468bc8447 Fix compile warning/error in aihttptimeoutpolicy.cpp 2012-12-25 04:53:16 -05:00
Inusaito Sayori
059005a4a7 Fly after teleport, off by default. 2012-12-25 04:47:07 -05:00
Shyotl
3ca39ab3f1 Client-side maturity handling when teleporting. Adds new notification that asks if you want to change maturity settings with a single click and automatically re-fire the teleport request. 2012-12-25 02:30:51 -06:00
Shyotl
f8a6e2e19f Moved region rebake button to 'Tools' menu 2012-12-25 02:27:15 -06:00
Shyotl
1f5c2095a5 Merge branch 'master' of https://github.com/Lirusaito/SingularityViewer.git 2012-12-24 18:26:52 -06:00
Shyotl
afaaba6b3c OSX was choking on transformfeedback shaders. Make failure to load such shaders non-critical to the shader loading process. Also clean up glColorMask state properly in wlsky. 2012-12-24 17:56:32 -06:00
Aleric Inglewood
c85f976ed6 Fix outbox notifications. 2012-12-24 22:08:44 +01:00
Aleric Inglewood
b22832ba54 Fix cookie handling.
Cookies are now collected during redirects, one the last cookie
of a given name is kept. Cookies are then set by looking for
the right cookie name (instead of what viewer 3 does: just
use the last cookie that was set).

This fixes the merchant outbox.
2012-12-24 19:58:54 +01:00
Inusaito Sayori
977f17a893 Add feature to Continue flying upon standing, if the user was flying when they sat down.
A couple users said this could be handy.
Useful for birds, fairies, and otherwise flying critters.
2012-12-24 05:24:57 -05:00
Inusaito Sayori
60621a300c Satisfy in-world feature request: Avatar Count on Radar. 2012-12-24 03:09:09 -05:00
Aleric Inglewood
fac3fc67b6 Add filtering for curl debug output.
Add CURLTR debug channel for libcurl API calls,
and use CURLIO only for libcurl debug output.
Note: need to set gDebugCurlTerse to true for
filtering to take effect, then pass 'debug_on'
to the LLHttpClient methods that require debugging.
2012-12-24 02:54:36 +01:00
Inusaito Sayori
8e3da75c3c Missed a spot for 487. 2012-12-23 15:10:53 -05:00
Inusaito Sayori
c9dc2eaad4 Satisfy Issue 487: Walking Backwards, Turning Around
TurnAroundWhenWalkingBackwards added.
Turn Around When Walking Backwards added to Vanity Main Preferences.
Code borrowed, in part, from Firestorm.
2012-12-23 00:26:49 -05:00
Aleric Inglewood
8095d6c48c Large snapshot update (part 3) 2012-12-22 19:07:08 +01:00
Inusaito Sayori
6f2e192947 Complete Issue 545: OSSL Updates
Updates keywords.ini, lsl_functions_os.xml, and en-us/strings.xml
Thanks WhiteStar, ThiteStar.
2012-12-22 12:25:46 -05:00
Inusaito Sayori
0b9d8c7b47 Satisfy Issue 512: Increase RenderVolume LOD Factor Threshold to 4.000
Phoenix users are used to this.
The setting clamps to the max here, so it must be 4.
2012-12-22 05:29:21 -05:00
Inusaito Sayori
1ecea32933 An hour is not a circle. 2012-12-22 02:07:36 -05:00
Inusaito Sayori
ceae4470f5 Fix a windows compiley thing. 2012-12-21 05:49:14 -05:00
Lirusaito
237455f4b7 Use boost::date_time for displaying avatar age.
llpanelavatar change may be better viewed without space changes.
2012-12-20 23:34:05 -05:00
Lirusaito
3d25f8ee79 Merge branch 'master' of https://github.com/DamianZhaoying/SingularityViewer 2012-12-20 09:25:33 -05:00
Lirusaito
86572462e6 Merge branch 'master' of git://github.com/Shyotl/SingularityViewer 2012-12-20 09:25:21 -05:00
Lirusaito
245eaa1fd9 Satisfy radar issues: 51(Avatar Age), 382(Time duration), 245(Hide columns on command)
Overall:
Extras tab added to radar.
Activities given tool_tip strings, TODO: Get icon entries to have tool_tips.
Added tab_min_width="0" to tab container so tabs take up only as much space as necessary.

Issue 51:
RadarAlertAge, AvatarAgeAlertDays debugs added.
RadarTextYoung color added to colors_base and gemini.
UI bits added to radar.
ALERT_TYPE_AGE, LIST_AGE, and boost::lexical_cast added.
LLAvatarListEntry is now derived from LLAvatarPropertiesObserver for processProperties and all that fun stuff. Also has mAgeAlert and mAge.
processProperties is basically copied directly from LLAvatarPanel, it can probably be bettered.

Issue 382:
mTime, getTime(), LIST_TIME
Time column.

Issue 245:
Hide columns text and checkboxes added to UI.
assessColumns() now used to determine which columns to show. Also once used during postBuild()
col_helper() function added to help decide to hide or resize a column based on given params.
checkboxes all use assessColumns as callback.
RadarColumn* debug settings added.

If you read this all, that's a sign the 'pocalypse is coming.
2012-12-20 08:58:18 -05:00
Damian Zhaoying
e7b712660e update spanish translations 2012-12-19 23:29:36 -03:00
Shyotl
3750123e43 Obsessive excessive clearing of glow rendertargets, as they still occasionally act weird. 2012-12-19 19:08:10 -06:00
Shyotl
b20f39d09f Retain shader error logs across entire session. 2012-12-19 19:06:59 -06:00
Inusaito Sayori
c35f762826 Satisfy Issue 476: Option to mute gesture sounds
Enable Gesture Sounds checkbox added to Adv. Chat->Spam tab.
2012-12-19 03:35:06 -05:00
Shyotl
7eda762c28 Cheapo sun bloom contribution in deferred. 2012-12-19 02:30:44 -06:00
Shyotl
0460769eea Unified moon/star rendering to share same shader. Also now actually using deferred shader when performing deferred rendering. 2012-12-19 01:52:10 -06:00
Shyotl
d3939c785d Fixup scroll list column header resizing. 2012-12-18 18:27:59 -06:00
Inusaito Sayori
66386d6eec Fix an issue introduced in V2MultiWear in which double-clicking or hitting an enter on a worn wearable would rewear it, not detach it. 2012-12-17 19:32:40 -05:00
Inusaito Sayori
9e8dafc4ca Satisfy Issue 167: Ability to set global "add instead of wear" option in prefs
Adds debug setting LiruAddNotReplace.
Adds "Add clothing and wearables instead of replacing them" to Main (General) tab of Vanity Preferences.
2012-12-17 17:17:12 -05:00
Inusaito Sayori
36a698fee4 Satisfy Issue 271: Fly after teleport feature.
Add debug setting LiruFlyAfterTeleports
Add Always fly after Teleports to General tab of System preferences.
(Also, fixed tabs where spaces should be in settings.xml)
2012-12-16 20:50:40 -05:00
Aleric Inglewood
aab764a6e5 Don't crash when user forgets last name on non-SL grids. 2012-12-16 23:39:58 +01:00
Aleric Inglewood
11f30bc28d Removed gFullName which isn't used anywhere 2012-12-16 23:17:10 +01:00
Inusaito Sayori
46b5595c3f Don't leave Group Copy check enabled unless we have trans and copy perms.
Also some code consistency chages that won't change anything.
2012-12-16 15:32:06 -05:00
Inusaito Sayori
c380f1f399 Don't show Paste As Link when Paste As Copy is shown enabled because it'll just be disabled in these cases. 2012-12-16 15:31:53 -05:00
Shyotl
184882e916 Remove dead code from llfloaterworldmap, and a tweak to lluictrl that I could've sworn I already did. 2012-12-16 13:30:29 -06:00
Aleric Inglewood
a9963bcdb3 In FreezeTime mode, keep avatars that TP away.
If an avatar TP's away (or quits), he will not
disappear anymore from a frozen scene. Unfreezing
makes him disappear of course (and clean up).

Known bug: if during Freeze Time mode someone
TPs away and then back, then he becomes a cloud
after Freeze Time is ended, which can only be
reset by another teleport (or relog) from either
the cloud or the one seeing him as cloud.
I decided not to fix this, cause there are things
with a higher priority and this - if it happens
at all - is rare and easy to recognize and work
around.
2012-12-16 00:13:06 +01:00
Aleric Inglewood
e0c0da7dff In Freeze Time re-show fullscreen preview when clicking thumbnail. 2012-12-15 02:20:53 +01:00
Shyotl
6c9df4574c Merge branch 'master' of https://github.com/Lirusaito/SingularityViewer.git 2012-12-14 16:59:49 -06:00
Shyotl
034c83f996 Added trivial diagnostic message regarding teleport handling. 2012-12-14 16:28:18 -06:00
Shyotl
2b582b169b Mute list, now with 100% more text-appearing-ness, and 20% new shinies (mute-type icons, multi-select unmute, and displayname support). 2012-12-14 16:24:51 -06:00
Aleric Inglewood
cfa8df0575 Merge branch 'master' into llwebprofile 2012-12-14 20:43:17 +01:00
Aleric Inglewood
c34f2941aa Merge remote-tracking branch 'github/master' 2012-12-14 20:41:18 +01:00
Aleric Inglewood
555b397067 Install vivox runtime also on standalone when linux64 2012-12-14 20:40:27 +01:00
Inusaito Sayori
38f59e640c We canUndo and canRedo when we have a MoveableObject, not necessarily an EditableObject 2012-12-14 11:30:56 -05:00
Aleric Inglewood
65ce7dabe3 Merge remote-tracking branch 'github/master' 2012-12-14 16:42:27 +01:00
Aleric Inglewood
4d7d3ea937 Compile fix for non-standalone with DEBUG_CURLIO
Oops, that option doesn't exist in the prebuilt curl version.
2012-12-14 16:40:03 +01:00
Aleric Inglewood
15b6593143 Large snapshot update (part 2) 2012-12-14 02:31:08 +01:00
Inusaito Sayori
af1e7b346e Vignette is Awesome, its panel should reflect that! 2012-12-13 16:53:19 -05:00
Shyotl
7a2f572eaa Merge branch 'master' of https://github.com/AlericInglewood/SingularityViewer.git 2012-12-12 13:13:26 -06:00
Aleric Inglewood
4bb3ed0d85 Login crash bug fix.
XMLRPCResponder constructor was missing.
This fixes the following crash signature:

VIEWER      : 2012-12-12T14:25:13Z INFO("AppInit"): setStartupState: Startup state changing from STATE_LOGIN_NO_DATA_YET to STATE_LOGIN_DOWNLOADING
VIEWER      : 2012-12-12T14:25:14Z INFO("AppInit"): transferRate: Buffer size:   1308 B
VIEWER      : 2012-12-12T14:25:14Z INFO("AppInit"): transferRate: Transfer rate: 11 kb/s

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff33df7f5 in XMLRPC_RequestGetData () from /usr/lib/x86_64-linux-gnu/libxmlrpc-epi.so.0
(gdb) bt

Reason was that if the server replied with some error code then
mResponse was undefined.

I also added code to retry three times in that case;
the http status code that I get was 503, which really
mean "Service *temporarily* unavailable", so a retry
is in order.
2012-12-12 16:27:32 +01:00
Aleric Inglewood
5fe0820e13 Login crash bug fix.
XMLRPCResponder constructor was missing.
This fixes the following crash signature:

VIEWER      : 2012-12-12T14:25:13Z INFO("AppInit"): setStartupState: Startup state changing from STATE_LOGIN_NO_DATA_YET to STATE_LOGIN_DOWNLOADING
VIEWER      : 2012-12-12T14:25:14Z INFO("AppInit"): transferRate: Buffer size:   1308 B
VIEWER      : 2012-12-12T14:25:14Z INFO("AppInit"): transferRate: Transfer rate: 11 kb/s

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff33df7f5 in XMLRPC_RequestGetData () from /usr/lib/x86_64-linux-gnu/libxmlrpc-epi.so.0
(gdb) bt

Reason was that if the server replied with some error code then
mResponse was undefined.

I also added code to retry three times in that case;
the http status code that I get was 503, which really
mean "Service *temporarily* unavailable", so a retry
is in order.
2012-12-12 16:14:32 +01:00
Shyotl
28a4101d4d Merge branch 'master' of https://github.com/Lirusaito/SingularityViewer.git 2012-12-12 03:12:08 -06:00
Shyotl
cc22edcce3 Merge branch 'master' of https://github.com/singularity-viewer/SingularityViewer.git 2012-12-12 03:11:50 -06:00
Shyotl
2424d2a082 A little bit of postprocess shader tinkering. 2012-12-12 03:10:05 -06:00
Lirusaito
b1ccb70277 Added isClipboardPasteableAsCopy() to decide when not to show Paste As Copy 2012-12-11 15:15:41 -05:00
Shyotl
c641cc6394 Fix object list in About Land floater. (whoops) 2012-12-10 20:02:47 -06:00
Shyotl
9a6568f5e8 A little bit of bloom on indirect shiny reflections in deferred. 2012-12-10 20:00:57 -06:00
Shyotl
3627b33eec Reworked flexi update handling a little bit. 2012-12-10 19:55:17 -06:00
Lirusaito
702eb95b84 Add Paste As Copy to inventory menu...
The opposite of Paste As Link, this will make copies of everything in the paste buffer,
allowing the user to copy bunches of items or links and simply paste them to make new copies.

Also appears when not needed... unsure how to go about removing, maybe comment out in release?
2012-12-10 19:39:55 -05:00
Lirusaito
03f191f47d Satisfy Issue 494: Inventory: Copy links (without "find original")
http://code.google.com/p/singularity-viewer/issues/detail?id=494
Patch by Kitty Barnett, slightly modified by myself.
2012-12-10 16:42:06 -05:00
Lirusaito
813a4b0200 Fix warning: unused variable ‘len’ in release builds. 2012-12-10 13:26:48 -05:00
Lirusaito
c24950b261 Merge branch 'master' of https://github.com/singularity-viewer/SingularityViewer
Conflicts:
	indra/newview/llfloateravatarpicker.cpp - Includes to v-d style, since plain alphabetical just won't cut it. Shyotl's changes for name system, here.
	indra/newview/llpanelgroupinvite.cpp - Shyotl's changes for name system, here.

Also corrected new README to have less typos and be slightly more accurate.
2012-12-10 11:24:25 -05:00
Shyotl
806abb1985 Reduce required number of glow rendertargets by 1... 2012-12-10 01:31:57 -06:00
Shyotl
a4591a5eaa Fix for friends list not resorting upon avatar online status change. Also did some minor cleanup 2012-12-09 17:05:54 -06:00
Siana Gearz
018737eb15 Blind Windows compile fix 2012-12-09 04:53:35 +01:00
Siana Gearz
3e5bd4e13b Linux build fixes 2012-12-09 04:25:01 +01:00
Siana Gearz
98ec8b9910 Merge branch 'master' of https://github.com/Shyotl/SingularityViewer 2012-12-09 03:27:52 +01:00
Siana Gearz
d2a966f363 OpenJPEG 1.5.2 2012-12-09 02:10:16 +01:00
Shyotl
8a7cc9259c Merge branch 'master' of https://github.com/singularity-viewer/SingularityViewer.git 2012-12-08 17:13:07 -06:00
Shyotl
382fc710e5 Disable octree statistics gathering. 2012-12-08 17:07:15 -06:00
Shyotl
be4229867a Occlusion-fudge was incorrectly defaulting to zero. 2012-12-08 16:56:06 -06:00
Shyotl
6b05022530 Applied Tofu Linden's SSAO improvements. e189d55a7b 2012-12-08 16:51:38 -06:00
Shyotl
08a3828cc9 Applied Tofu Linden's water atmospherics improvements.
59f73ee6a1 &
43fdcb8d84
2012-12-08 16:50:35 -06:00
Shyotl
d5efedf51b Merge branch 'master' of https://github.com/AlericInglewood/SingularityViewer.git into CT3Merge 2012-12-08 13:39:55 -06:00
Aleric Inglewood
8394a96fa8 Fix of TEXTBOX of group owned object.
Fixes http://code.google.com/p/singularity-viewer/issues/detail?id=548
2012-12-08 20:30:00 +01:00
Shyotl
4f7e869509 Merge branch 'master' of https://github.com/AlericInglewood/SingularityViewer.git into CT3Merge 2012-12-08 01:03:29 -06:00
Shyotl
7aac61859f Avoid excess calls to gGL.flush when bound texture hasn't actually changed. 2012-12-08 01:01:47 -06:00
Shyotl
3ba967bdc1 Update to LLAvatarNameCache and consumers. 2012-12-08 00:59:37 -06:00
Shyotl
9fb4e677a6 Updates to LLScrollListCtrl and related inter-dependencies. Also added ability to set face texture to 'None' (LLUUID::null). 2012-12-08 00:56:58 -06:00
Lirusaito
1ffb5aa6fe LLFloaterAvatarList RLVa: Don't announce people are in range when the user is blind. 2012-12-06 22:17:44 -05:00
Lirusaito
0100cd2f36 More of e2b011590d
Fixing up the name system, missed two parts.
2012-12-06 21:04:06 -05:00
Aleric Inglewood
d6b486524c Fix include of reader.h 2012-12-07 00:31:10 +01:00
Shyotl
f80394fc02 llpreviewgesture.cpp changes snuck past me in an early commit. 2012-12-06 17:19:10 -06:00
Shyotl
e750c598be Updated avatar radar. Focusprev/focusnext now obey the order of the actual displayed avatar list. Cleaned up some commit callbacks. 2012-12-06 17:16:44 -06:00
Shyotl
26191dd274 Migrate to boost::bind for a bunch of CommitCallbacks. Converted several static member functions to nonstatic member functions 2012-12-06 17:13:17 -06:00
Aleric Inglewood
12171f6cd9 Merge commit '5947769812369a7988a7f1db30df79e6fc0e4787'
Adds important commits from llwebprofile branch
into master which need to go into the next release.
2012-12-05 22:27:21 +01:00
Lirusaito
457276fa5d Merge branch 'master' of https://github.com/DamianZhaoying/SingularityViewer 2012-12-05 13:59:36 -05:00
Lirusaito
7ba21ac4fd Show Highlight and Edit Axis at Root on build floater
Thanks for the help, Naudia Nadezda!
2012-12-05 12:06:10 -05:00
Lirusaito
e2b011590d Fix up the Name System just a little bit more.
Better viewed without space changes
Pretty much add support for sending LLAvatarName and std::string to become a name via the system...
Also a bit of a revert for llcallingcard.cpp in this regard, just allow it to use a callback along with the new support,
but still handle the actual name switching in LLAvatarNameCache.
Fixes a problem I was having with "[NAME] is Online" notifications appearing early on, only.
2012-12-05 01:48:09 -05:00
Shyotl
ef6f411b70 Removed LLUICtrl::setDoubleClickCallback and LLPanel::childSetDoubleClickCallback as they aren't used/needed and complicate things. Added LLPanel::childSetAction overload that accepts boost::singal2::signal (for boost::bind). Now using boost::function for various callbacks in LLScrollListCtrl (for boost::bind). 2012-12-04 21:54:01 -06:00
Lirusaito
2c48161595 Make Baker's Group code compile! Thanks Shyotl~
Note: Large groups still don't load?!
SimConsole cap is needed for Sim Console, won't work without it, keeping it in!
..But it should work with the new ASync one? Maybe needs tweaks, first?

Also switches opening IMs to the gCacheName->getFullName(id, name) system mentioned earlier, my connection has improved!
And makes the Avatar Picker show display names! Yay! (Rearranged the includes there, alphabetical~)
Also fallback to gCacheName->getFullName(id, name) if getting name fails in the new system.. hopefully this will combat occasional big failures.. but it may not work anyway.. maybe my connection is just awful again
2012-12-04 11:54:54 -05:00
Shyotl
ca3e0d2ba9 Use the correct font name. "SANSSERIF_SMALL", not "SANSSERIFSMALL" 2012-12-04 02:59:19 -06:00
Lirusaito
922e234fe9 Baker Linden's group update, added with some care, won't compile,
Note: These changesets removed the some caps in llviewerregion.cpp, I have made a note of these, but left them in.
Please take a look at the Singu Note:'s and Singu: TODO:'s when working on this.
2012-12-04 03:53:05 -05:00
Lirusaito
b9cfd2fae5 Replace the tricky copy-paste-everywhere Display Name system code with a unified function
Only does that, dun believe me? Take a look, oh... it also corrects improper interpretations of the PhoenixNameSystem value: 1 is both, 2 is displays, 0 and anything else is Legacy.
Also replaces a bit of the display name support code with new system... by definition this shouldn't change the log file, only the title of the session..
because of my bad connection during week days, I can not confirm this working 100%,
but if it does end up changing the logs under certain unseen conditions, replace the new name check with gCacheName->getFullName(id, name) but this reallllly shouldn't happen!
2012-12-04 00:36:12 -05:00
Aleric Inglewood
d8bc84adb1 Snapshot fixes and improvements.
* Allow to pass -1 to LLImageBase::reallocateData too (default parameter),
  causing it to allocate what is necessary for the size set (same
  behavior as allocateData).
* Speed up LLImageRaw::scale with factor 2 or 3 by copying the data less
  often and calling LLImageBase::reallocateData instead of destroying
  and recreating always.
* Fix gl_rect_2d to not decrement top and right with one pixel.
* Remove the vague "Constrain Proportions" checkbox and replace it with
  a new combo box and spinner to explicitly set the target aspect ratio,
  allowing to set it also to something different than either the window
  aspect ratio (ie, 1.6) or the target image dimension (1.0 for textures)
  which was totally lacking when, for example, uploading a profile image
  (which needs to be 4:3). This also allows to show snapshots on prims
  of arbitrary aspects.
2012-12-04 00:45:01 +01:00
Shyotl
ce3511f7ea Misc changes via v3 merge. Nothing big. 2012-12-03 15:03:52 -06:00
Shyotl
a8e1bd1538 'Save scripts in inventory as Mono scripts instead of LSL2' checkbox was not functioning. For whatever reason it was not implemented in the actual panel, and referenced the incorrect setting. The proper setting will be 'SaveInventoryScriptsAsMono' not 'SaveScriptsAsMono' 2012-12-03 11:33:24 -06:00
Lirusaito
0876c8c2bf Go away when idle checkbox added to General Preferences. 2012-12-02 22:14:36 -05:00
Shyotl
0554ecae5c Added explicit texture reloading. Accessable in the 'tools' submenus for the agent, avatars, and selected objects. 2012-12-02 17:06:54 -06:00
Lirusaito
cfbc8a23f7 Transaction Notifications are now optionally Notify Tips for those who don't want them to collect at the top right of the screen, but still want a notification.
Debug setting LiruNoTransactionClutter has been added, and is toggled by checkbox in General preferences
This adds support for TransactionInfo message, to localize the server's transaction notifications.
Adds a notification called Payment, which unifies all three of v-d's Payment* notifications.

This is a fairly large change to view, keep in mind what was removed as it may just be in a slightly different order or position..
2012-12-02 17:52:36 -05:00
Shyotl
8b19f82c0b Trivial changes. Resolved some sign mismatch warnings, and now using LLCachedControl for 'SGIgnoreSimulatorCameraConstraint' setting lookup. 2012-11-29 11:58:41 -06:00
Shyotl
794dbacea3 Merge branch 'master' of https://github.com/AlericInglewood/SingularityViewer.git into testpit
Conflicts:
	indra/newview/lldrawpoolavatar.cpp
	indra/newview/llviewertexturelist.cpp
	indra/newview/llworldmap.cpp
	indra/newview/pipeline.cpp
2012-11-29 11:54:41 -06:00
Shyotl
3a4b6cf6b6 Hovertext updates marked objects as 'moved' when inappropriate. http://hg.secondlife.com/viewer-development/commits/8ccf2b0fa3857a6610f6ea03166e5a4494ca6d03 2012-11-29 10:07:25 -06:00
Shyotl
c0c9c51e43 Some minor syntax grooming in LLNetMap::draw 2012-11-29 10:03:48 -06:00
Aleric Inglewood
e788ee5faf Merge branch 'master' into llwebprofile 2012-11-28 18:50:31 +01:00
Aleric Inglewood
e17405d80a Fixed snapping of rotation in the edge-on case
Patch by https://codereview.secondlife.com/users/cron.stardust/
Jira: https://jira.secondlife.com/browse/STORM-1919
2012-11-28 17:04:24 +01:00
Aleric Inglewood
de52eebe7a Allow setting a custom size when uploading a texture. 2012-11-26 23:21:34 +01:00
Aleric Inglewood
d7069a2a66 Fix cancelling "Save" while "Keep open after save" is unchecked.
This causes a failure to save local file, or when clicking
Cancel in the file chooser, to keep the image and keep the
snapshot floater open so a retry to save the image can be
attempted.
2012-11-26 20:41:25 +01:00
Aleric Inglewood
7faa19b297 Large snapshot update (part 1)
This commit concentrates on remembering what parameters
where used for the last snapshot (the actual source, not
the formatted one), thus - the parameters passed to
rawSnapshot() - and then shows this snapshot as if it
was just made whenever the UI parameter selection matches.
The result is that the user can make a snapshot, save
it (for example) to their harddisk and then change the
destination and upload the same thing as snapshot.
The code tries hard to make this possible by automatically
adjusting the UI parameters to match every time the destination
is changed PROVIDED it was already saved or uploaded before.
If a snapshot wasn't saved and one changes destination
then this currently doesn't happen (by you could manually
make the parameters match, and still upload it). Also, if
the resolution is changed for a particular destination then
it won't automatically adjust it again.

Obviously, snapshots are no longer refreshed when changing
destination etc. You have to explicitly click "Refresh
Snapshot" before the last one is deleted / replaced.

The Debug Setting variables reflect the (last) manual choices
in most cases (set in the onCommit functions). If such a choice
is not allowed for a different destination then the UI is
changed to reflect the current behavior and the checkbox is
disabled so the user can't change it anymore. Then, if they
change destination back - the Debug Setting variable is used
to remember their last preference. A new Debug Setting has
been added for this purpose: SnapshotLayerType (colors or depth).

The old mSnapshotUpToDate has been removed and replaced with
mShowFreezeFrameSnapshot. The old getSnapshotUpToDate() now
returns something else (than mShowFreezeFrameSnapshot), namely
whether or not the current raw snapshot was taken with the same
parameters as are currently set in the UI.

The unused functions getImageAspect() and getAspect() were
removed.

mCurImageIndex has been deleted. Index 0 now means "the last
snapshot" and index 1 is temporarily used for the Falling Away
animation.

mDataSize was renamed to mFormattedDataSize.

The size spinner arrows are now disabled too whenever the spinner
edit field is disabled.

A bug in Freeze Time was fixed, where avatars would still
rotate around their axis in place (and without that their
attachments moved!)

Pressing ESC would return keyboard control to "walking"
for the own avatar with the above as result for the own
avatar. We now intercept ESC and use it (in Freeze Time mode)
to return to the cammable preview when a 2D preview was
being shown.
2012-11-26 18:12:41 +01:00
Shyotl
5e6ed2dc9f Large update to the worldmap. Essentially, v3 merge, and reimplemented legacy tile drawing and opensim-specific changes. Also added a diagnostic view. 2012-11-24 11:21:29 -06:00
Shyotl
adebc36bc7 Cheap workaround for osgrid giving us an invalid pure-white single-channel opaque water texture. First it purges the texture from the cache and attempts to refetch, and if it's still invalid it falls back to the transparent water texture (which won't actually be transparent due to blending being disabled). Also fixed some annoying console spam related to null textures, and also now using the correct glTexGen* function. More details in comments. 2012-11-24 01:00:25 -06:00
Aleric Inglewood
165bebda3e Compile error and warning fixes for DEBUG_CURLIO without CWDEBUG. 2012-11-23 03:19:39 +01:00
Aleric Inglewood
0f54e5fe46 Remove erroneous assertion. 2012-11-22 03:55:10 +01:00
Aleric Inglewood
14c046108e Snapshot floater changes
* Added a radio button for "Post to my.secondlife.com feed"
* Moved the snapshot to the top of the floater.
* Increased the size of the snapshot to match the size used in V3
  (floater is only 4 pixels wider though).
* Disable the "Temporary upload" checkbox when the Destination isn't the
  inventory.
* Update the shown Upload Fee to L$ 0 if temporary is checked.
* Added a size chooser for the Feed destination, using exclusively
  preset sizes with an aspect ratio of 4:3.
* Added two new preset sizes: 1024x1024 for texture uploads, and
  1680x1050 for save to disk.
2012-11-20 22:27:48 +01:00
Aleric Inglewood
b5a8850d65 Fix deinitialization order fiasco. 2012-11-19 08:32:00 +01:00
Aleric Inglewood
3f51bb6e1d Clear the command queue after flushing statemachines
Flushing the state machines can cause remove commands to be added to the
command queue, so clearing it needs to be after.
2012-11-19 08:31:46 +01:00
Aleric Inglewood
aab195a6eb Fix deinitialization order fiasco. 2012-11-19 04:42:02 +01:00
Aleric Inglewood
2400d146ce Clear the command queue after flushing statemachines
Flushing the state machines can cause remove commands to be added to the
command queue, so clearing it needs to be after.
2012-11-19 04:01:54 +01:00
Shyotl
9a9b5ce61e LLRectBase<>::clipPointToRect could divide by zero, resulting in the resulting clampd values being invalid under some scenarios (worldmap panning could cause the mouse cursor to 'restore' to an invalid location upon mouseclick release.) 2012-11-18 02:48:55 -06:00
Shyotl
6b473c6edc Avoid clearing hud object rebuild states when teleporting. 2012-11-18 02:42:33 -06:00
Shyotl
9d8f31a0cb Some teleport reworking. Don't clear rebuild groups/resetVBO unless tp screen is up, or we've just changed sims. Also skip updateUI drawing if tp screen is up. 2012-11-18 02:41:37 -06:00
Aleric Inglewood
5947769812 Fix LLMimeDiscoveryResponder.
Extract Content-Type also from a 405 reply.
If all else fails, use a default mime-type for url's opened
in the browser (start with http: or https:) of "text/html" instead
of "none/none".
2012-11-18 03:29:01 +01:00
Aleric Inglewood
52673f5249 Slight update of README 2012-11-18 02:41:37 +01:00
Aleric Inglewood
f44de434c2 Always use followRedir() to determine if redirections should be followed.
Before every HEAD and GET request allowed redirection by default,
without setting a limit on the number of redirections. This caused
an infinite redirect loop when connecting to marketplace, in combination
with the bug that we did not allow cookies.
2012-11-18 02:07:19 +01:00
Siana Gearz
cbb27a5661 Merge branch 'master' of git://github.com/Lirusaito/SingularityViewer 2012-11-18 01:33:18 +01:00
Siana Gearz
48eaccc612 Merge branch 'master' of git://github.com/AlericInglewood/SingularityViewer 2012-11-18 01:33:11 +01:00
Aleric Inglewood
5499136677 Don't send an Accept header for HEAD requests. 2012-11-18 01:29:24 +01:00
Aleric Inglewood
57b66a9be9 Allow cookies when allowing redirects (next to when sending a Cookie ourselves). 2012-11-18 01:28:23 +01:00
Aleric Inglewood
746f419e80 Fix detection of mIsInProductionGrid and fix getMarketplaceDomain()
getMarketplaceDomain() should return aditi.lindenlab.com for aditi,
not secondlife.aditi.lindenlab.com.
mIsInProductionGrid wasn't set correctly.
2012-11-17 21:38:55 +01:00
Aleric Inglewood
5d1a138c5c Code clean up of code related to previous commit. 2012-11-17 05:16:21 +01:00
Aleric Inglewood
e781870da3 Fix Ratany Residents crash 2012-11-17 04:55:34 +01:00
Aleric Inglewood
e3f30fece9 Fix print_diagnostics for windows. 2012-11-16 16:06:30 +01:00
Lirusaito
7b2536eb0d Inventory cut support!
Also fixes a bunch of comments, implementation based off of v-d.
Added isOnClipboard and setCutMode functions to LLInventoryClipboard, in part from v-d's LLClipboard.
LLInventoryFilter has a few rearrangements of code; only real change is now it has checkAgainstClipboard and uses it to filter out cut items.
There is a massive retabbed block in llinventorymodel.cpp, view without space changes. Implements removeObject.
Note: We are not afflicted by MAINT-1197: Fix inventory deselection/reselection when cutting items
2012-11-16 02:47:05 -05:00
Damian Zhaoying
299382b907 Add Merchant Outbox text files 2012-11-15 22:13:17 -03:00
Aleric Inglewood
fce64f8f12 Add LLWebProfile and responders.
Adds finding and using libjsoncpp. Note that the old cmake file
found libjson, not the same thing.

Adds Debug Setting WebProfileNonProductionURL (next to already existing
WebProfileURL) to mimic V3's behavior and use a different URL for aditi.
These Debug Settings are using by (the new) getProfileURL() (copied
from V3 with just a minor fix).

Adds HippoGridInfo::isInProductionGrid() next to the existing
LLViewerLogin::isInProductionGrid that always returned true.
The former should only be called SL grids and then only returns
true for agni (and false for aditi et al). The latter was changed
to now always return true except on SL when the grid isn't agni.
The first is used for SL-only cases, the latter for things like
colors and for godmode decision logic.

V3's llwebprofile.cpp was fixed to compile on singu, with only real
difference that I dropped the Content-Type headers for the GET methods.
2012-11-16 02:00:06 +01:00
Aleric Inglewood
f8bf11d574 More clearly state the implications of the NoVerifySSLCert debug option 2012-11-15 14:14:25 +01:00
Aleric Inglewood
fdfe0cae87 More clearly state the implications of the NoVerifySSLCert debug option 2012-11-15 13:51:16 +01:00
Aleric Inglewood
66664660d7 Copied llwebprofile.{h,cpp} from v-d as-is. 2012-11-15 04:07:44 +01:00
Scott Meitz
760ac98ab6 missed another spot with trailing spaces in aa functions, TNX LightDrake and Shyot1 :) 2012-11-14 21:37:36 -05:00
Scott Meitz
2bd5d88dbf fix extra space in strings.xml en. Tooltip was not find them 2012-11-14 21:37:00 -05:00
Siana Gearz
5f78a36899 Merge branch 'master' of git://github.com/Lirusaito/SingularityViewer 2012-11-15 02:30:01 +01:00
Lirusaito
b897b9427f Fix unclickable explanatory link on Outbox floater
mOutboxInventoryPanel couldn't be setVisible(false) while it was NULL, thus it sat on top of the rest of the UI.
Set it to panel_outbox_inventory in postBuild, instead of setupOutbox.
2012-11-14 16:48:03 -05:00
Lirusaito
c33b1004d1 Merge branch 'master' of https://github.com/singularity-viewer/SingularityViewer 2012-11-14 13:55:48 -05:00
Siana Gearz
19e8977fff Merge branch 'master' of git://github.com/AlericInglewood/SingularityViewer 2012-11-14 19:40:45 +01:00
Aleric Inglewood
c097d650dc Don't upload partial files 2012-11-14 19:26:16 +01:00
Aleric Inglewood
b7af32bee3 Use std::istream::read instead of readsome
According to the docs
(http://www.cplusplus.com/reference/iostream/istream/readsome/)
readsome would also set state flag eofbit, but apparently I'm
misinterpreting it.  Anyway, using read() and then gcount()
to get the number of bytes does work.
2012-11-14 18:37:44 +01:00
Shyotl
d2422b03be Don't flush rebuild queue nor flush pending texture requests if merely performing a local teleport (eg: doubleclick teleporting within current sim.) 2012-11-13 23:34:48 -06:00
Shyotl
97d2085735 Nullcheck in LLTextureFetch::removeRequest was returning without unlocking LLTextureFetch::mQueueMutex if called via LLTextureFetch::deleteRequest 2012-11-13 23:25:32 -06:00
Aleric Inglewood
e307df79a1 Ignore the body in case of internal errors 2012-11-14 04:00:26 +01:00
Aleric Inglewood
324fe06a06 Improved printed info when curl times out. 2012-11-14 02:12:27 +01:00
Shyotl
fe15371047 Update to LLTombstone/LLHandle/LLRootHandle/LLHandleProvider. 2012-11-13 17:55:52 -06:00
Siana Gearz
fbb7196100 Missed a piece of a fix for the case we receive complete texture data instead of what we asked for.
The rest of the fix landed in commit c37a473287 by accident.
2012-11-13 23:54:23 +01:00
Siana Gearz
8c9a9c9d12 Introducing SGIgnoreSimulatorCameraConstraints 2012-11-13 23:46:21 +01:00
Aleric Inglewood
6f8ea87c46 Add ResponderHeadersOnly.
ResponderHeadersOnly is a base class for responders that use
HTTPClient::head or HTTPClient::getHeaderOnly. It already
has a needsHeaders() that return true and only allows for
completedHeaders to be overridden.

I removed the CURLOPT_HEADER option for these cases, because
that only causes the headers to be send to the writeCallback
as if they are part of the body, in addition to the headerCallback;
That gave raise to some confusion for the existing code (ie,
unexpected errors when trying to decode the body as LLSD and
duplicated 'low speed' information for the Timeout policy code.
2012-11-13 21:46:35 +01:00
Siana Gearz
3d84157325 Revert "Probably antivirus-friendlier SLPlugin"
This reverts commit 817085c172.
2012-11-13 18:41:58 +01:00
Siana Gearz
9abf8ddf91 Merge git://github.com/Murf/SingularityViewer 2012-11-13 18:40:20 +01:00
Lirusaito
f289d5d9e7 Make MARKET_IMPORTER_UPDATE_FREQUENCY configurable as debug setting MarketImporterUpdateFreq
Change the default to a minute... that should be good? Right?
2012-11-13 00:16:04 -05:00
Lirusaito
821c03a389 Copy folders support!
Sync with v-d/rlva for Copy folder support
Also, guard against outboxy stuff, like when we're importing, don't show the Marketplace Send menu entry.
Fixed a few comments
Please view this commit with space/tab changes off! There were a lot of retabbing cases that don't need to waste anymore of anyone's time.
2012-11-13 00:06:47 -05:00
Siana Gearz
c37a473287 Add NickyD's fast j2k metadata reader 2012-11-13 05:38:27 +01:00
Shyotl
3eebedc4c3 Revert "Avoid re-requesting object-inventory items that already have a pending request."
This code was actually regression in viewer-dev and causes some issues.
This reverts commit cd5aa8f074.
2012-11-12 20:32:40 -06:00
Siana Gearz
5eb99b7d2f Attempt to fix frame timer on broken mainboards 2012-11-13 02:50:15 +01:00
Brett Murphy
3534706a59 get OSX building again 2012-11-13 11:38:28 +11:00
Brett Murphy
717a8a5cdb Merge branch 'master' of https://github.com/AlericInglewood/SingularityViewer 2012-11-13 11:03:38 +11:00
Aleric Inglewood
586d8fdf21 Compile fixes for gcc 4.2 (Mac) 2012-11-13 01:01:19 +01:00
Siana Gearz
f4016c2e1c Stop trying to package dbghelp.dll - windows always comes with one anyway 2012-11-12 19:37:31 +01:00
Siana Gearz
2bb08d7638 Merge branch 'master' of git://github.com/LightDrake/SingularityViewer 2012-11-12 19:34:06 +01:00
Aleric Inglewood
155cc56632 Do not put AICurlEasyRequest in a container. 2012-11-12 18:42:55 +01:00
Shyotl
4a4032f3b8 Hopefully allows better behavior when loading other avatars. This is from v3, and taking a cursory glance, it's useful as onFirstTEMessageReceived is called before LLVOAvatar::idleUpdate, which means that mLoadedCallbacksPaused hasn't been updated for that particualr frame yet. Using LLVOAvatar::isVisible() is more accurate. 2012-11-12 03:41:53 -06:00
Shyotl
cd5aa8f074 Avoid re-requesting object-inventory items that already have a pending request. 2012-11-12 03:18:02 -06:00
Shyotl
c2b26f6c15 GCC Fixes:
Only use C++0x/C++11 features if compiling for windows, or if GCC is configured to support such features (v4.7 onwards: '-std=c++11'. v4.3 through v4.6: '-std=c++0x')
Removed an assertion that's no longer possible to evaluate (queue doesn't support iterators).
2012-11-12 03:04:24 -06:00
Shyotl
f25ca2ac80 Fixed small #if/#ifdef typo. Also fixed formatting error in strings.xml 2012-11-12 00:12:39 -06:00
Siana Gearz
303c74f4c9 Merge branch 'master' of git://github.com/Lirusaito/SingularityViewer
Conflicts:
	indra/llmessage/llurlrequest.cpp
	indra/newview/llvoavatar.cpp
2012-11-12 06:46:58 +01:00
Siana Gearz
59d4d833f1 Made octree check optional 2012-11-12 04:48:00 +01:00
Siana Gearz
562acd6e2c Merge branch 'master' of https://github.com/Shyotl/SingularityViewer 2012-11-12 04:12:57 +01:00
Siana Gearz
c3d76669ca Merge branch 'master' of git://github.com/AlericInglewood/SingularityViewer
Conflicts:
	indra/llmessage/llavatarnamecache.cpp
2012-11-12 04:12:28 +01:00
Siana Gearz
14d8d14832 Texture fetch cleanup 2012-11-12 03:33:17 +01:00
Aleric Inglewood
cdc04ba413 Merge branch 'fasttimelock' 2012-11-11 19:06:14 +01:00
Aleric Inglewood
ab91525e7a Add missing needHeaders
The AIBufferedCurlEasyRequestEvents are not triggered unless
the derived class return true for needsHeaders().
That means, every class that implements received_HTTP_header(),
received_header() or completed_headers(), or implement
the virtual function completedHeaders(), or use the protected
member mReceivedHeaders directly.
This commits adds missing needsHeaders() for LLAvatarNameCache
(thanks Siana) and XMLRPCResponder. The former now uses
mReceivedHeaders directly instead of making a copy.
2012-11-11 17:36:43 +01:00
Shyotl
0a4b3487ea Resolve string substitutions failing for a few 'unsuccessful' startup dialogs. 2012-11-11 01:01:04 -06:00
Aleric Inglewood
0061055e73 Attempted to dereference a past-the-end iterator. 2012-11-11 01:54:50 +01:00
Aleric Inglewood
a16c4015ba Attempted to decrement past-the-end iterator of empty container. 2012-11-11 01:54:50 +01:00
Shyotl
0173c29630 Resolve compiler warning caused by silly temporary #define. 2012-11-09 23:32:57 -06:00
Aleric Inglewood
26a734a538 Add fasttimers around obtaining a mutex or waiting on a condition. 2012-11-10 02:33:48 +01:00
Aleric Inglewood
04e7dc1270 Collect and print stats about HTTP status code 2012-11-10 02:19:20 +01:00
Shyotl
1cdc11dae2 Added LLTextureFetch::deleteAllRequests procedure. Called upon teleport. 2012-11-09 18:45:57 -06:00
Shyotl
1cb75c4471 Tiny bit of code consolidation in lltexturefetch 2012-11-09 18:42:37 -06:00
Shyotl
b6efc9f583 Fixed buggyness regarding objects moved by scripts. http://hg.secondlife.com/viewer-development/changeset/1a874cd5d0a0616b979a571e810320cd35e69baf 2012-11-09 18:41:05 -06:00
Shyotl
01868e46fe Removed pointless redundant gGL.flush() calls from llworldmapview. 2012-11-09 18:33:44 -06:00
Shyotl
313cce23db Trivial. Changed LLOcclusionQueryPool::mAvailableName to std::queue, because it's being used as a queue, and it being a list makes little sense. 2012-11-09 18:32:57 -06:00
Shyotl
9aca1f41f3 Make occlusion boundingbox 'fudge' settings adjustable via SHOcclusionFudge saved setting. 2012-11-09 18:20:45 -06:00
Shyotl
81c7445744 image->hasFetcher() check reundant in LLViewerTextureList::clearFetchingRequests(). LLViewerFetchedTexture::forceToDeleteRequest() checks for this too. 2012-11-09 18:12:57 -06:00
Shyotl
d54daa19a0 Allow trial of trasform feedback (for testing/benchmark) on hardware that declares support for GL_EXT_transform_feedback. Performance is far less than satisfactory on my hd4870(ogl3.3 gpu), however. Also messes up texcoords. Don't add RenderUseTransformFeedback to settings.xml. 2012-11-09 18:10:39 -06:00
Shyotl
0c58a42b08 Added a couple needed nullchecks of gAgentAvatarp in LLAgent. 2012-11-09 16:32:26 -06:00
Aleric Inglewood
68cbf31c8b Add a PerHostRequestQueue object.
Adds a std::map for hostname (or urls) --> PerHostRequestQueue
objects. The latter keeps track of the number of added curl easy
requests and decides if a new request should be throttled or
not, as well as provides the queue to queue throttled requests.

At the moment CurlConcurrentConnectionsPerHost is set to 16,
because things really don't work without LL supporting connection
reuse if we limit it to 2. CurlConcurrentConnectionsPerHost is
also set to non-persistent so that we can easily change it in the future
(once we decide on it's final value it can be set to persistent).
2012-11-07 15:41:50 +01:00
Lirusaito
d518222340 Disable Group Fee Invites in antispam preferences, when appropriate. 2012-11-06 21:35:35 -05:00
Lirusaito
7a35a43bd4 Merchant Outbox!
Enter: LLFloaterOutbox, floater_merchant_outbox, LLMarketplaceFunctions, LLPanelMarketplaceOutboxInventory, and panel_outbox_inventory

LLView now has childFromPoint() from v-d.
LLInventoryBridge{
Sync includes with v-d.
Let's ENABLE_MERCHANT_SEND_TO_MARKETPLACE_CONTEXT_MENU for ease of access and tweak it to work.
Uncomment related code.
Catch if we're moving objects into the outbox during pasteFromClipboard()
}
LLInventoryPanel: start_folder attribute for inventory_panels, this could be quite useful in the future
Sync LLToolDragAndDrop with Catznip/v-d
Add the outbox to the World menu, since that seems to involve most commerce. Perhaps we should add a menu entry to the outbox itself to open its floater?
Fix the inventory merchant menu entries, thanks Shyotl..
Merchant Outbox Strings!
2012-11-06 20:23:36 -05:00
Aleric Inglewood
cb52e82a60 Moved and extended AICurlInterface::Stats
Moved AICurlPrivate::Stats to AICurlInterface::Stats and added several
counters to keep track of the number of existing instances of
respectively AICurlEasyRequest, AICurlEasyRequestStateMachine,
BufferedCurlEasyRequest, ResponderBase and
ThreadSafeBufferedCurlEasyRequest.
2012-11-07 02:15:23 +01:00
Aleric Inglewood
1a43bc8abf As AIStateMachine moved outside newview, there is no longer any need to pass AIStateMachine::flush to initCurl() 2012-11-07 02:08:52 +01:00
Aleric Inglewood
e88c39b090 AIStateMachine::flush can only make statemachines idle.
As idle statemachines aren't in any list, it's not possible
(without adding that list) to delete them. I don't think
that there are any active statemachines left at the end
of flush anyway, but killing them doesn't much sense if
we can't get them all: there will always be statemachines
left: those that were idle at the moment the viewer was
quit.
2012-11-07 01:53:12 +01:00
Aleric Inglewood
a1f5e6ba43 Rename AICurlResponderBufferEvents to AIBufferedCurlEasyRequestEvents
Since we changed CurlResponderBuffer to be derived from CurlEasyRequest
and therefore changed it's name to BufferedCurlEasyRequest, we should
also rename AICurlResponderBufferEvents to
AIBufferedCurlEasyRequestEvents.
This commit also fixes C++ comment in several places to reflex the
previous name change.
2012-11-07 01:49:45 +01:00
Lirusaito
d0a0aa7a65 Fix handle_secondlifeprotocol.sh, and sync with v-d.
More translation strings~
Log inventory offers to those we're not chatting with.
"SDL deiconification state switched to " now lldebugs instead of llinfos, far too spammy..

(Pre-outbox commit, may contain pieces of outbox work.. and unmentioned harmless sync)
2012-11-06 18:50:45 -05:00
Drake Arconis
8cf956e669 Fixed a crash 2012-11-06 07:20:24 -05:00
Shyotl
3bbb23b1bc Experiments with allocating octree nodes via memory pools. 2012-11-05 16:58:03 -06:00
Shyotl
a582b5996c Whoops. Forgot settings.xml 2012-11-05 14:54:48 -06:00
Siana Gearz
4cd10c34e2 Fix manifest when extra libs are empty on Windows 2012-11-05 12:15:42 +01:00
Shyotl
3ec1dbf51c Updated spatial partition and octrees to use std::vector. Also, added diagnostic spew to octrees. 2012-11-04 21:48:17 -06:00
Shyotl
71deb8925e Added some nullchecks, removed some dead code, and cleaned up a few small things. 2012-11-04 21:16:53 -06:00
Siana Gearz
abb562d1ab For extra safety 2012-11-05 03:22:57 +01:00
Aleric Inglewood
a495a6bfbc Short circuit llsd debug check. 2012-11-05 01:04:02 +01:00
Siana Gearz
e86b17be2d Merge branch 'master' of git://github.com/AlericInglewood/SingularityViewer 2012-11-04 18:56:15 +01:00
Aleric Inglewood
e62f805bcd Fix wrong assertion mAddedEasyRequests.size() >= (size_t)mRunningHandles
Rename check_run_count to check_msg_queue, because the whole 'run count'
approach is flawed anyway (the author of libcurl told me that THE way
to check for finished curl handles is to just call curl_multi_info_read
every time: it's extremely fast. Any test that attempts to avoid that
call is nonsense anyway.

The reason the assertion failed might have been caused by the fact
that we're comparing the current number of easy handles with the
number of running handles of 'a while ago'. It is possible that a
easy handle was removed in the meantime.

In order to check if that hypothesis is right, I moved the assertion
to directly below the call to curl_multi_socket_action where it
should hold. If this new assertion doesn't trigger than the hypothesis
was right and this is fixed.
2012-11-04 17:08:05 +01:00
Siana Gearz
6f8ae718d1 Forgotten files for message logger 2012-11-04 03:30:49 +01:00
Siana Gearz
1dcfa9e0ee Merge branch 'master' of git://github.com/AlericInglewood/SingularityViewer
Conflicts:
	indra/llmessage/llregionpresenceverifier.cpp
	indra/llmessage/llregionpresenceverifier.h
2012-11-04 02:10:31 +01:00
Siana Gearz
7f0664ff82 Bringing back message logger 2012-11-03 14:13:13 +01:00
Aleric Inglewood
03b3e60e23 Merge branch 'curlthreading3' 2012-11-02 18:54:07 +01:00
Aleric Inglewood
72bde5234a Rename CurlResponderBuffer to BufferedCurlEasyRequest and derive it from CurlEasyRequest
Every curl transaction is a AICurlEasyRequestStateMachine which has a
AICurlEasyRequest as member, which is a reference counting pointer to
a ThreadSafeBufferedCurlEasyRequest. And now BufferedCurlEasyRequest is
derived from CurlEasyRequest which is derived from CurlEasyHandle, but
neither are used separatedly.
2012-11-02 18:41:23 +01:00
Aleric Inglewood
1e1f5e8193 Fix windows compile errors/warnings 2012-11-01 03:18:00 +01:00
Aleric Inglewood
6c01b6da9b Merging CurlEasyRequest and CurlResponderBuffer, Step 1 2012-11-01 02:40:08 +01:00
Aleric Inglewood
756aac1f9a Remove AICurlInterface::strerror 2012-11-01 02:04:40 +01:00
Aleric Inglewood
c0ac428179 Code cleanup
* Moved Responder stuff to LLHTTPClient.
* Renamed LLHTTPClient::Responder to LLHTTPClient::ResponderWithResult.
* Deleted LLHTTPClientAdapter and LLHTTPClientInterface.
* Renamed AICurlInterface::TransferInfo to AITransferInfo and moved it
  to llhttpclient.h
* Removed 'CURLcode code' argument from completed_headers.
2012-10-31 23:11:42 +01:00
Aleric Inglewood
7549b471c3 Moved curl stuff from indra/aistatemachine to indra/llmessage. 2012-10-31 18:51:52 +01:00
Aleric Inglewood
0b265320a9 Code clean up.
* Removed LLCurlRequest and replaced it's last usage with LLHTTPClient API calls.
* Deleted dead code.
* Renamed all the get4/post4/put4/getByteRange4 etc, back to their
  original name without the '4'.
2012-10-31 05:01:24 +01:00
Aleric Inglewood
6033a76870 Print more debug output. Remove last AIFIXME 2012-10-30 21:37:49 +01:00
Aleric Inglewood
3708d55ef9 Allow changing CurlTimeout Debug Settings on the fly.
Same for NoVerifySSLCert and CurlConcurrentConnections.
2012-10-30 21:18:15 +01:00
Aleric Inglewood
9996cf6157 Bug fix 2012-10-30 21:17:25 +01:00
Aleric Inglewood
3e78b7c262 Allow people with last name "Resident" to login using Hippogrid manager. 2012-10-30 07:16:01 +01:00
Aleric Inglewood
65e012c540 More curl fixes and changes.
* Moved LegacyPolledResponder::mCode to ResponderBase::mCode.
* Added a parameter to ResponderBase::finished (and pubError*) to set mCode.
* Renamed ResponderBase::decode_body to decode_llsd_body and added ResponderBase::decode_raw_body.
* Use LegacyPolledResponder::finished instead of LegacyPolledResponder::completed_headers
  to set remaining cached values.
* Fixed assertion in case of -DCWDEBUG and upload finish detection failure in case of HEAD
  method (mDebugIsGetMethod -> mDebugIsHeadOrGetMethod).
* Add XmlTreeInjector : support for LLXmlTree.
* Split BlockingResponder into BlockingLLSDResponder and BlockingRawResponder.
* Final blocking responders are now: BlockingLLSDPostResponder, BlockingLLSDGetResponder
  and BlockingRawGetResponder.
* Added LLHTTPClient::blockingGetRaw
* Got rid of hipporestrequest.* -- and fixed hippogridmanager.cpp to use
  LLHTTPClient::blockingGetRaw instead, and fixed llviewermessage.cpp to use
  AICurlInterface::ResponderWithCompleted and decode_raw_body instead of
  HippoRestHandlerRaw and LLHTTPClient::get4 instead of HippoRestRequest::get5.
2012-10-28 17:38:25 +01:00
Aleric Inglewood
2a88f7d7c4 ResponderAdapter stuff
Renamed AICurlInterface::Responder to AICurlInterface::ResponderBase,
but without the virtual 'event' methods.
Derived from that: Responder and ReponderWithCompleted, where the
first defines result = 0, ErrorWithContent and error, and the latter
completedRaw and completed.
Added HttpClient::IgnoreBody, derived from Responder and implementing
'result' doing nothing; HttpClient::Ignore is now derived from
IgnoreBody and defines the still pure virtual getHTTPTimeoutPolicy.

Added ResponderBase::decode_body, which is now the sole place
where the code makes the decision wether some response data might be
LLSD or not based on the http status result. Before it just tried
to decode everything as LLSD, which seems a bit nonsense.

ResponderWithCompleted::completed no longer does anything, since
classes derived from ResponderWithCompleted are expected to override it,
or never call it by overriding completedRaw.

Entry point is now ResponderBase::finished = 0, instead of
completedRaw, where ResponderWithCompleted implements finished by
called completedRaw, but Responder doesn't: that directly calls
result/errorWithContent/error. Or, for the hack ResponderAdapter,
the entry points are pubResult/pubErrorWithContent.
Those are now the ONLY public methods, so more confusion.
mFinished is now set in all cases.

As a result of all that, it is no longer possible to accidently
pass a responder to ResponderAdapter that would break because it
expects completed() and completedRaw() to be called.

Added LLBufferArray::writeChannelTo.

Fixed bug for BlockingResponder::body (returned reference to temporary).

LLSDMessage::ResponderAdapter now allows a "timeoutpolicy" name
to be passed (not doing so results in the default timings), so
that the timeout policy of the used responder is retained.

Fixed llfasttimerview.cpp to test LLSDSerialize::fromXML() to return
a positive value instead of non-zero, because it may return -1 when the
parsing fails (three places).

Removed LLHTTPClient::Responder as base class from
LLFloaterRegionDebugConsole completely: it isn't a responder!

Several other responder classes were simplified a bit in order to
compile again with the above changes.
2012-10-26 04:13:29 +02:00
Shyotl
dca9501de7 Attempt to break viewer window out of 'maximized' mode when not actually maximized. There are old jiras about the previous workaround causing issues, so let's attempt a different method. 2012-10-25 20:52:14 -05:00
Shyotl
8ed6b549ee A few resolutions in the dropdown in the prefrences panel were not being parsed correctly. Use standard 'x' instead of '×' 2012-10-25 20:50:42 -05:00
Shyotl
1a741b97d2 Fixed LLGLState::checkStates() failing upon context re-creation:
-After new context creation, immediately call LLRender::refreshState() after LLViewerWindow::initGLDefaults() in order to force states to apply.
--LLRender::initGLDefaults optimizes out gl calls by caching states, but the cached values are only applicable to the old context, not the new, so this optimization must be skipped (LLRender::mDirty).
-LLViewerWindow::mStatesDirty also triggered a redundant shader reload, since restoreGL also called setShaders().
Fixed somewhat annoying flicker of a single frame whilst recovering from screen resizing.
-Skip frame if LLViewerWindow::checkSettings() called LLViewerWindow::reshape. (reshape will set gWindowResized to true)
--True optimal fix will require some refactoring.
Reworked how window position is saved in LLViewerWindow::changeDisplaySettings. Hopefully reduces chances of odd behavior (had WindowX and WindowY get stuck at massive negative values before)
2012-10-25 20:42:58 -05:00
Aleric Inglewood
33809f56c5 Comment out unused code. 2012-10-25 02:17:40 +02:00
Shyotl
67ee544231 Clear saved raw discard level upon texfetch cleanup. (missed this in an earlier commit) 2012-10-24 03:21:51 -05:00
Shyotl
94f61ce307 A few nullchecks in the particle system. Had a null drawable pop up. 2012-10-24 03:20:32 -05:00
Shyotl
b57f7cdc79 Fixed various specular/glow effects bleeding through fullbright objects in deferred. 2012-10-24 03:19:53 -05:00
Shyotl
c901a7136f I freaking swear LL breaks hud attachment lighting in some way every few months. *Grumble* 2012-10-23 17:24:08 -05:00
Aleric Inglewood
243db9a3a8 Moved mFinished/is_finished() from LegacyPolledResponder to Responder.
Slightly more robust, adds one boolean to all responders, 99%
of which don't need that though, and an extra call redirection,
but well... We might need it this way when I add the possibility
to abort a transfer.
2012-10-22 22:52:18 +02:00
Shyotl
a5ef61ac82 Avoid std::vector::erase in particle system (erase in any sequence-independent vector is a waste as it shifts all elements to maintain element-ordering and contiguity). Replaced with swap and pop. 2012-10-22 15:46:12 -05:00
Shyotl
9e272aeef0 Still need to initialize flexis upon their very first idle update, else you get an ugly polygon soup when they first appear. 2012-10-22 15:32:33 -05:00
Shyotl
5c45979783 Resolve issue with sculpties loading with incorrect discard levels. 2012-10-22 15:26:53 -05:00
Shyotl
02f214d8a7 Clear object rebuild queues upon teleport. 2012-10-22 15:25:02 -05:00
Aleric Inglewood
daac25c343 Bug fix, introduced in commit 0bee4a92 2012-10-22 20:31:33 +02:00
Aleric Inglewood
768f1b5710 Fixes blocking_request. Adds LegacyPolledResponder and BlockingResponder.
XMLRPCResponder also uses the new LegacyPolledResponder now.
Renamed http_result() -> http_status().
2012-10-22 20:19:44 +02:00
Shyotl
5b4b9fd169 Durr, missed a line when adding attached light muting. Clobbered when diffing. Incrementing in a for loop is kinda important! Our handling in this function differes from LL in the firstplace because they are performing iteration on an iterator that can be invalid after the erase. 2012-10-22 03:17:33 -05:00
Shyotl
7dea357f4c Picked up a few small changes from viewer-beta pertaining to pathfinding. 2012-10-22 03:08:51 -05:00
Shyotl
9ef10b1663 Muting an avatar now also removes their attached lights. Also cleaned up light update code(no change in behavior) 2012-10-22 03:07:07 -05:00
Shyotl
d2004e88f9 MatrixMode sanity checks and adjustments to physics debug display (fixes a crash with that debug view, too) 2012-10-22 03:05:18 -05:00
Shyotl
ef27cc54dd Fixed unsafe erasure from vector while iterating in llinventorybackup.cpp. 2012-10-22 02:56:41 -05:00
Shyotl
19390eaec3 Remove pointless framebuffer status check. glReadBuffer doesn't work with gl_depth_attachment, thus will always complain about readbuffer being absent. (it checks GL_COLOR_ATTACHMENT0, which isn't present because this check is before we attach color attachments.) 2012-10-22 02:55:21 -05:00
Shyotl
dff6171605 More alignment crap. 2012-10-22 02:51:41 -05:00
Shyotl
4fe84efafd Unbork shadow shaders by tweaking normal unpack. 2012-10-22 02:51:28 -05:00
Shyotl
ed4997168b LLViewerObject::idleUpdate now returns void. Texture animations/flexis now have their own update queues. 2012-10-22 02:50:04 -05:00
Aleric Inglewood
b92de9beb5 Done as part of AIHTTPTimeout 2012-10-22 02:20:20 +02:00
Aleric Inglewood
7f50b2ba7b Add XMLRPC support to LLHTTPClient and that instead of LLXMLRPCTransaction 2012-10-22 01:59:17 +02:00
Aleric Inglewood
c35bc71334 Fix crash when libcurl calls read callback before calling socket callback.
In days of usage this has never happened before, but apparently
it's possible. The solution chosen is to create the AIHTTPTimeout
object on the fly when it doesn't exist and let it be picked up
later when the CurlSocketInfo for the transfer is created.
2012-10-22 00:53:54 +02:00
Shyotl
413a8111c0 PASS_INVISI_SHINY never issued. Commented out some unused code. 2012-10-21 17:16:22 -05:00
Shyotl
5be31898f1 Don't compile avatar eye shader, as it isn't used anywhere. 2012-10-21 17:14:29 -05:00
Shyotl
44faf3e169 Removed annoying attribute consumption warnings. Alpha pass was leaving shader bound, which hosed up updateCull for water reflections (updateCull only binds occlusion shader if another shader isn't currently bound) 2012-10-21 17:14:00 -05:00
Aleric Inglewood
937a60c8f9 Add AIHTTPReceivedHeaders
This fixes the problem that existed with received headers:
The server sends some headers ("set-cookie") more than once
in the same reply, which cannot be stored in std::map.
The old code just ignored the additional cookies, while
curlthreading3 (since the introduction of AIHTTPHeaders)
caused an assertion.

AIHTTPReceivedHeaders is written around a std::multimap
and allows to retrieve multiple headers with the same key.
Also, it is case insensitive so that if a server sends
"Content-Type" it will still find it (the viewer looks for
"content-type").
2012-10-21 17:45:46 +02:00
Aleric Inglewood
f7626699da Bug fix: (correctly) revoke CurlResponderBuffer events. 2012-10-21 17:28:22 +02:00
Lirusaito
ad97c72821 Use smaller horizontal chat tabs, where possible. 2012-10-21 11:19:03 -04:00
Lirusaito
b7ce7b7dab Tiny LLWorld silliness fix up 2012-10-21 11:18:49 -04:00
Shyotl
b73f4dd8e4 Catch up with viewer-beta. Primarily sim transition alterations to reduce frame hitching, and some optimization in LLViewerObjectList (std::set -> std::vector and and some allocation tweakage). 2012-10-20 17:02:43 -05:00
Aleric Inglewood
a4bf92dae4 Add CURLcode and TransferInfo to completed_headers event. 2012-10-20 23:56:19 +02:00
Aleric Inglewood
1e745ba48b Curl work in progress.
Minor changes like comment fixes and addition of accessors
that will be needed for future commits.
Also removed Responder::fatalError as it was never used.
2012-10-20 23:52:34 +02:00
Aleric Inglewood
f8273e977e Make NoVerifySSLCert work for all LLURLRequest
Moved CURLOPT_ENCODING from CurlEasyRequest::setPost_raw, and
CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST from
CurlResponderBuffer::prepRequest, to LLURLRequest::configure,
enabling the debug setting NoVerifySSLCert for the latter
two to work as follows: old behavior if "NoVerifySSLCert"
is not set, and check neither if it is set. However, if
the (new) bool mIsAuth is set the behavior of LLXMLRPCTransaction::Impl::init
is used. This is so in a next commit we can replace
LLXMLRPCTransaction with LLURLRequest: LLXMLRPCTransaction::Impl::init
will be removed. For the same reason, when the new boolean
mNoCompression is set then CURLOPT_ENCODING is set to "identity",
otherwise the old behavior (of clearing it) is used.
2012-10-20 23:28:33 +02:00
Aleric Inglewood
605843b527 HTTP status of 400 is an error too. 2012-10-20 21:47:31 +02:00
Siana Gearz
71d2bd83aa Fix inconsistent link/unlink checking 2012-10-17 13:41:30 +02:00
Siana Gearz
a12704c6a3 Don't eat my mouse when i might be debugging 2012-10-17 13:39:54 +02:00
Shyotl
43271f290e A few more alignment bits and bobs. 2012-10-16 20:07:04 -05:00
Shyotl
7533b475be TCMalloc can now be manually disabled via develop.py -DDISABLE_TCMALLOC:BOOL=ON 2012-10-16 17:15:23 -05:00
Shyotl
1b89e5c973 Dragged in a bunch of alignment fixes from LL. Should allow disabling of tcmalloc on windows/linux32 if such is ever implemented. 2012-10-16 02:33:05 -05:00
Aleric Inglewood
8ba127d4c5 HTTPTimeout work in progress
* Avoid using CurlEasyRequest::mTimeout for HTTPTime::done and
  HTTPTime::print_diagnostics when it might be NULL.
* Comment fixes.
* Indentation fix.
2012-10-15 21:07:17 +02:00
Aleric Inglewood
bb8ea493d6 Fix top check in MultiHandle::check_run_count.
This check isn't really needed at all, since curl_multi_info_read
is fast enough, but well... The old check was flawed anyway.
2012-10-15 21:03:08 +02:00
Aleric Inglewood
02cffa9a71 Replace TimeOut with Timeout everywhere. 2012-10-15 21:01:16 +02:00
Aleric Inglewood
76fc30e460 HTTPTimeout work in progress.
* Moved DoutCurlEasy and DoutCurlEasyEntering from aicurl.cpp
  to aicurl.h and renamed them to DoutCurl and DoutCurlEntering
  respectively.
* Moved the callback functions from aicurl.cpp to aicurlthread.cpp.
* In CurlEasyRequest, renamed timeout_timings to print_curl_timings
  and mTimeoutLowercaseHostname to mLowercaseHostname.
* Put all remaining CurlEasyRequest::mTimeout* variables and
  timeout_* methods in curlthread::HTTPTimeout, stripping them
  of said prefix, and moved the definition to aicurlprivate.h.
  Added a ThreadSafeCurlEasyRequest* member and a get_lockobj()
  method so to that class so we can still use DoutCurl /
  DoutCurlEntering. timeout_add_easy_request was removed completely
  and reimplemented as the constructor of HTTPTimeout.
  timeout_has_stalled was renamed to HTTPTimeout::has_stalled,
  but also reimplemented as CurlEasyRequest::has_stalled.
* CurlEasyRequest::mRequestFinalized was removed and it's
  functionality taken over by CurlEasyRequest::mTimeoutPolicy.
* Fixed the indentation of struct Stats, class CurlEasyHandle
  and class CurlEasyRequest.
* Added CurlEasyRequest::set_timeout_opts
* Added CurlSocketInfo::mTimeout (LLPointer<HTTPTimeout>).
* mUploadFinished is now reset in HTTPTimeout::data_received,
  this was needed because "HEAD /something" header-only
  messages triggered upload_finished (unlike "GET ..."),
  and in combination with redirection that caused an assert.
2012-10-15 03:34:32 +02:00
Shyotl
e8ec81bf04 Experimentation with normalpacking and component precision. 2012-10-14 04:00:02 -05:00
Aleric Inglewood
9fba54ad5d On failed transfer, print CURLINFO_OS_ERRNO when available. 2012-10-14 03:13:32 +02:00
Aleric Inglewood
ccd98c3c3d Fix comment. 2012-10-14 02:55:45 +02:00
Aleric Inglewood
2539e41e59 Avoid problems in case a host also resolves to IPv6 2012-10-14 02:53:36 +02:00
Aleric Inglewood
83312fbb74 Allow getinfo() to be called on a const CurlEasyRequest. 2012-10-14 02:45:58 +02:00
Aleric Inglewood
6134162f1c Merge remote-tracking branch 'singu/exp' 2012-10-14 00:57:07 +02:00
Lirusaito
fb713226a0 Merge branch 'master' of git://github.com/Shyotl/SingularityViewer 2012-10-12 13:50:56 -04:00
Aleric Inglewood
3ac46f5fa7 HTTP timeout work in progress. 2012-10-12 19:39:11 +02:00
Lirusaito
d5c507ca6b Merge branch 'master' of https://github.com/LightDrake/SingularityViewer 2012-10-12 12:59:42 -04:00
Drake Arconis
858bb15a6b Fixed issue 2012-10-12 12:36:31 -04:00
Aleric Inglewood
faee255730 HTTP timeout bug fix! Plus work in progress.
Use the better understandable alias CURLOPT_HTTPHEADER in debug output

Bug fix - finally!

This fixes a bug I've been looking for a week.
By accidently calling get_clock_count() for the mTimeoutLowSpeedClock
'event', the time difference 'now' - 'event' becomes negative, which
should be impossible; the result being that timeout_low_speed
stalled for 24 seconds while looping over the full 32 bit. That in
turn made SSL handshakes of libcurl fail, which seemed to be
impossible since the calls to libcurl had not changed!
2012-10-12 04:50:46 +02:00
Shyotl
eb5b1312bb Removed pointless asset fetches for expression-based gestures (opposed to animation based ones), since they don't have actual animation assets. 2012-10-11 02:40:00 -05:00
Siana Gearz
5445b4f97a Fix bandwidth estimation for texture fetch 2012-10-10 15:37:43 +02:00
Aleric Inglewood
02ead94848 HTTP timeout work in progress.
More debug output.
Avoid the new assert when exiting the viewer.
2012-10-08 19:14:22 +02:00
Aleric Inglewood
6a4f76a219 Bug fix for previous commit. 2012-10-08 05:00:11 +02:00
Aleric Inglewood
1252b0bde2 HTTP timeout work in progress.
* Remove progress meter call back, use read/write/header callbacks instead.
* Don't use timeout_lowspeed for ReplyDelay, instead use:
* Add timeout stuff to the main loop (CurlEasyRequest::mTimeoutStalled).

This patch fixes a few things compared to the previous version.
More things need to be fixed.
2012-10-08 02:19:32 +02:00
Aleric Inglewood
a40fbf0da1 Cache hostname of url in CurlEasyRequest::mTimeoutLowercaseHostname
Also add DoutCurlEasyEntering debug macro.
The caching is necessary because CURLINFO_EFFECTIVE_URL is unreliable
and can change several times during the transfer at any moment (as
a result of forwarding etc).
2012-10-06 01:21:33 +02:00
Aleric Inglewood
468f52a4f6 Merge branch 'master' into curlthreading3 2012-10-05 16:55:28 +02:00
Aleric Inglewood
3f1fb9a66e Add improved timeout handling for HTTP transactions.
Introduces AIHTTPTimeoutPolicy objects which do not just
specify a single "timeout" in seconds, but a plethora of
timings related to the life cycle of the average HTTP
transaction.

This knowledge is that moved to the Responder being
used instead of floating constants hardcoded in the
callers of http requests. This assumes that the same
timeout policy is wanted for each transaction that
uses the same Responder, which can be enforced is needed.

I added a AIHTTPTimeoutPolicy for EVERY responder,
only to make it easier later to tune timeout values
and/or to get feedback about which responder runs
into HTTP errors in debug output (especially time outs),
so that they can be tuned later. If we already understood
exactly what we were doing then most responders could
have been left alone and just return the default timeout
policy: by far most timeout policies are just a copy
of the default policy, currently.

This commit is not finished... It's a work in progress
(viewer runs fine with it though).
2012-10-05 15:53:29 +02:00
Drake Arconis
c181891549 New windlight presets 2012-10-04 18:28:51 -04:00
Drake Arconis
f84f4aa058 Updated/Fixed Cursors 2012-10-04 18:13:48 -04:00
Drake Arconis
5d5c3e2a48 LLCalcparser update 2012-10-04 17:56:43 -04:00
Drake Arconis
5b8b88e05a Nuked ancient uneeded things 2012-10-04 17:56:25 -04:00
Drake Arconis
0287e21c01 More python indentation fixing...DIE TABS DIE 2012-10-04 16:34:10 -04:00
Drake Arconis
7d2f2bd610 Fixed python indentation in newview 2012-10-04 16:25:44 -04:00
Drake Arconis
d56393b134 Merge remote-tracking branch 'singu/master'
Conflicts:
	indra/cmake/WebKitLibPlugin.cmake
	indra/llmessage/llurlrequest.cpp
	indra/plugins/webkit/media_plugin_webkit.cpp
2012-10-04 16:17:41 -04:00
Lirusaito
1f7ed035d3 Make translation more flexible
Also in this commit, unrelated updates to the building panel (so git sees the markup "just" move in my next commit)
2012-09-29 16:59:17 -04:00
Aleric Inglewood
8430328043 Add support for uploading JP2 files.
Recognizes .jp2, .j2c and .j2k extensions.
Adds image/jp2 files to file picker image filter (windows and Mac,
windows apparently already showed them).
Show preview for jpeg 2000 files.
Fixes error reporting for failed image uploads.
Enforces a power-of-two size for jpeg 2000 files (seemed to make sense to do that).
2012-09-29 17:47:15 +02:00
Lirusaito
f311852e9b Satiate Issue 474 by showing a more sensible number for ARC by default.
http://code.google.com/p/singularity-viewer/issues/detail?id=474
Adds LiruSensibleARC debug setting, defaults to true.
Code ported from Imprudence.
2012-09-28 20:13:38 -04:00
Shyotl
ac0a32e690 Add an antispam setting to block only group invites to groups that require an entry fee. 2012-09-27 19:30:54 -05:00
Shyotl
88482a2431 An extra rendertarget is needed when fxaa dof are used in conjunction. mDeferredScreens color attachment was being used for both input and output when doing DoF combine, which is undefined behavior. Using mDeferredScreen for this works as it's no longer needed after lighting has been applied. 2012-09-26 20:45:47 -05:00
Shyotl
efbd339dc8 No return value? VisualStudio don' care. 2012-09-26 19:52:17 -05:00
Shyotl
ff28ce8d65 Corrections of some stupids (harmless copy-paste shenanigans in this case). 2012-09-26 19:51:24 -05:00
Lirusaito
cb33470673 Strings fix-up~ 2012-09-25 16:02:17 -04:00
Lirusaito
e6389d62dc Add debian/ubuntu support to install-deps script.
Also make the script more portable.
2012-09-25 16:01:43 -04:00
Aleric Inglewood
2766f17cb9 Merge remote-tracking branch 'github/master' into curlthreading3 2012-09-24 17:52:46 +02:00
Aleric Inglewood
70c36716c9 Disable SSL/TLS session caching.
Fixes: VWR-28039, VWR-28629
2012-09-24 17:05:23 +02:00
Aleric Inglewood
48702b1ed9 Various stuff
Comment fixes
Added some more debug support, not used yet (linux/libcwd only),
I used it, but won't commit the code that did.
Pass time_time parameter from post2() to prepRequest; only
used by mesh uploading at the moment.
2012-09-24 16:55:34 +02:00
Shyotl
16216b2ed0 Removed lscript_compile, lscript_execute, and lscript_library dependencies from newview. 2012-09-24 04:08:57 -05:00
Aleric Inglewood
3e22553d7e Merge remote-tracking branch 'github/master' into curlthreading3 2012-09-23 17:40:07 +02:00
Aleric Inglewood
4744839a08 Bug fix for curl request queue of last commit.
In debug mode an assertion was triggered when a queued
request was being removed by the main thread; and rightfully
so: we should remove such request from the queue in that
case.
2012-09-23 17:31:41 +02:00
Lirusaito
cb0c13a1a1 Merge branch 'master' of https://github.com/LightDrake/SingularityViewer 2012-09-23 10:25:22 -04:00
Drake Arconis
f0497a2721 Merge branch 'llqtwebkit' 2012-09-23 05:58:47 -04:00
Drake Arconis
77d018dbc8 Dependency install script for linux. Currently only supports Arch. 2012-09-23 00:51:29 -04:00
Drake Arconis
4be8b50360 Merge branch 'master' into llqtwebkit 2012-09-22 22:45:56 -04:00
Lirusaito
2581935b36 Merge branch 'master' of git://github.com/Shyotl/SingularityViewer
Conflicts:
	indra/newview/skins/default/xui/en-us/floater_post_process.xml - Used Mine, because Shyotl's is the ancient one from "the before time" and because my last commit (worked on motionblur tab, then, too.)
2012-09-22 15:12:45 -04:00
Aleric Inglewood
a7cf09883e Merge branch 'master' into curlthreading3 2012-09-22 01:26:37 +02:00
Aleric Inglewood
1254a7bbe2 Merge remote-tracking branch 'github/master' into curlthreading3
Conflicts:
	indra/aistatemachine/aistatemachine.cpp
2012-09-22 01:25:54 +02:00
Aleric Inglewood
fb5ec1d1f5 Implement curl connection throttling (CurlConcurrentConnections) 2012-09-21 19:26:40 +02:00
Aleric Inglewood
5bcb350d89 Always print '(CURL*)' in front of CURL*'s in debug output. 2012-09-21 01:48:21 +02:00
Aleric Inglewood
81bc6b49f8 Debug code bug fix; removal of CurlEasyHandle::getErrorString()
CurlEasyHandle::mErrorBuffer (CURLOPT_ERRORBUFFER) can NOT be
used to retrieve information about an error returned by
curl_multi_info_read in CURLMsg::data::result. This buffer is
only initialized when a curl_easy_* call returns an error,
and those errors are already printed automagically.

Initialize the buffer with an empty string upon invokation
of an curl_easy_* call, so we are sure the error belongs to
the last call.
2012-09-21 01:28:26 +02:00
Shyotl
9019a1eb23 Merge branch 'master' of https://github.com/singularity-viewer/SingularityViewer.git 2012-09-20 15:29:28 -05:00
Aleric Inglewood
f3780998ed Always reset stream state after using std::hex 2012-09-20 16:50:03 +02:00
Aleric Inglewood
27090c541f Remove inconsistent dll linkage (missing LL_COMMON_API) 2012-09-20 05:36:11 +02:00
Aleric Inglewood
ef73469700 Merge remote-tracking branch 'singu/master'
Abandonning curlthreading2 -- which is now in master.
2012-09-20 05:17:56 +02:00
Aleric Inglewood
2d12a82a54 Always flush LLBufferStream objects. 2012-09-20 04:49:43 +02:00
Aleric Inglewood
c5d9dc4732 Bug fix 2012-09-20 04:48:03 +02:00
Drake Arconis
84ec70e707 Revert "Breakpad cmake"
This reverts commit b0415370f8.
2012-09-19 20:50:54 -04:00
Siana Gearz
b7f5d7e415 Windows build fixes 2012-09-20 01:37:40 +02:00
Siana Gearz
8df7a52cf7 Merge branch 'curlthreading2' of git://github.com/AlericInglewood/SingularityViewer
Conflicts:
	indra/llplugin/slplugin/CMakeLists.txt
2012-09-19 23:30:48 +02:00
Shyotl
9bb9292a41 Attempt to catch octree node manipulation while iterating over said nodes 2012-09-19 15:34:25 -05:00
Shyotl
438c499718 And the shader.. 2012-09-19 15:34:15 -05:00
Shyotl
ff81d9461a Added motionblur postprocess shader.
Conflicts:

	indra/newview/skins/default/xui/en-us/floater_post_process.xml
2012-09-19 15:33:58 -05:00
Shyotl
f4f85aa1fd Merge branch 'master' of https://github.com/singularity-viewer/SingularityViewer.git
Conflicts:
	indra/newview/llviewerobject.cpp
2012-09-19 15:24:33 -05:00
Aleric Inglewood
56f2f0b727 Merge branch 'curlthreading2' into curlthreading3 2012-09-19 04:14:25 +02:00
Aleric Inglewood
19f325aa09 Merge remote-tracking branch 'singu/master' into curlthreading2
Conflicts:
	indra/llcommon/CMakeLists.txt

Resolved with kdiff3 automatically.
2012-09-19 04:11:16 +02:00
Aleric Inglewood
1d5a63c180 Fixed showing TOS floater.
This creates a separate events interface structure
for CurlResponderBuffer (AICurlResponderBufferEvents)
for dealing with received HTTP headers.

The headers are passed to the Responder, but only
if the class derived from Responder implements
completedHeaders (otherwise it makes little sense
to even decode the headers).

Basically this is a reimplementation of the functionality
of the old LLHTTPClientURLAdaptor class.
2012-09-18 23:59:09 +02:00
Lirusaito
d7da5153f3 Fixed up the Post-Process floater~
Vertical tabs, as requested by Shyotl
2012-09-18 10:06:21 -04:00
Aleric Inglewood
c67f010302 Pass filename by reference when possible. 2012-09-18 05:01:34 +02:00
Drake Arconis
90a10b3508 Removed packaged dbghelp.dll 2012-09-17 22:40:30 -04:00
Drake Arconis
a09f7d274f Fixed a bit of cmake derpyness 2012-09-17 22:23:57 -04:00
Drake Arconis
daa9466b7a Spelling fixin a comment :D 2012-09-17 22:22:28 -04:00
Drake Arconis
efb252206b Cached controls in cmdline chatbar 2012-09-17 22:22:02 -04:00
Drake Arconis
ffb847bbc0 Merge branch 'master' of https://github.com/singularity-viewer/SingularityViewer 2012-09-16 16:40:49 -04:00
Siana Gearz
a7b9b0da42 Version 1.7.2 2012-09-15 21:17:16 +02:00
Siana Gearz
5f8eac9dc8 Have i beaten you now, evil extortionists? 2012-09-15 21:15:59 +02:00
Aleric Inglewood
b5b6d3f85c Fix PluginAttachDebuggerToPlugins for linux.
This fixes the problem that many terminals require command line
parameters to be passed as command line parameters to the terminal
command. The old code would pass the whole gdb command including
all it's arguments (whatever replaces %s) as a single argument,
regardless of whether there are quotes around the %s or not.
Now those arguments are passed as separate arguments if there
are no quotes around the %s.

Updated documentation with an example on how to open a gdb terminal
on a different machines X display.
2012-09-14 19:38:05 +02:00
Drake Arconis
f50d23a0d4 Fast Timers brought up to linden equiv 2012-09-14 00:30:52 -04:00
Drake Arconis
cb9f972d13 BE GONE 2012-09-14 00:30:25 -04:00
Drake Arconis
e0a7c7e935 Renamed our log files to not conflict with linden 2012-09-13 19:39:02 -04:00
Drake Arconis
b0415370f8 Breakpad cmake 2012-09-13 18:19:38 -04:00
Drake Arconis
b7ff2fe3e3 Merge branch 'master' of https://github.com/LightDrake/SingularityViewer 2012-09-13 18:09:46 -04:00
Aleric Inglewood
a032bd28ad Merge branch 'curlthreading2' into curlthreading3 2012-09-11 17:05:13 +02:00
Aleric Inglewood
834a524a67 Compile fix.
This belongs to the latest merge with singu/master.
2012-09-11 17:03:57 +02:00
Aleric Inglewood
e3460bea09 Compile fix for openssl < 1.0.1 2012-09-11 15:51:18 +02:00
Aleric Inglewood
131959e388 Merge branch 'curlthreading2' into curlthreading3 2012-09-11 15:19:28 +02:00
Aleric Inglewood
d23835a6c2 Merge remote-tracking branch 'singu/master' into curlthreading2
Conflicts:
	indra/newview/statemachine/aistatemachine.cpp

Huh - you re-INDENTED a file that you didn't merge yet?
How about merging curlthreading2 and curlthreading3
before doing THAT? :/

Obviously I did an "use ours" here.
2012-09-11 15:15:46 +02:00
Aleric Inglewood
e17632e0d5 Merge branch 'curlthreading2' into curlthreading3 2012-09-11 14:56:07 +02:00
Aleric Inglewood
d57a3b101b Hide quilt patch directory 2012-09-11 14:54:51 +02:00
Aleric Inglewood
c2289c047b Only disable TLS1.1 for openssl1.0.1 and higher, leaving SSL3 alone. 2012-09-11 02:05:54 +02:00
Drake Arconis
9b358a1b39 Initial llqtwebkit 2012-09-08 02:03:07 -04:00
Aleric Inglewood
36c097744c Merge remote-tracking branch 'github/master' 2012-09-06 15:22:31 +02:00
Aleric Inglewood
e7cd445491 Merge branch 'curlthreading2' into curlthreading3 2012-09-06 15:12:22 +02:00
Aleric Inglewood
e3752aefed Fix loading Qt plugin on linux standalone.
For standalone there is no need to link libmedia_plugin_webkit.so
against Qt's plugins, and thus also not to add "random" paths
to LD_LIBRARY_PATH. Just let Qt do it's thing and find and
load the plugins it needs itself.
2012-09-05 19:29:47 +02:00
Aleric Inglewood
d8ff809092 Make webkit work with Qt 4.8 2012-09-05 04:12:13 +02:00
Aleric Inglewood
a8f5bf8baf Bug fix.
dlerror() returns NULL when no errors have occurred since the last call
to dlerror() (or since the last call to dlopen(), dlsym() or dlclose()).
2012-09-05 02:15:41 +02:00
Aleric Inglewood
3a3605b812 Cherry pick from curlthreading2 2012-09-04 23:34:56 +02:00
Aleric Inglewood
f1c635d103 Cherry pick from curlthreading2 2012-09-04 23:34:11 +02:00
Aleric Inglewood
15cce79040 Merge remote-tracking branch 'singu/master' into curlthreading2
Conflicts:
	indra/llmessage/llcurl.cpp

Changes to unused file (I'll remove it when I'm done).
2012-09-04 17:38:11 +02:00
Aleric Inglewood
dd9f7bba5d Merge branch 'curlthreading2' of github.com:AlericInglewood/SingularityViewer into curlthreading2 2012-09-01 04:02:45 +02:00
Aleric Inglewood
8051cd4194 Install fix for latest 32bitcompatibilitylibs 2012-09-01 03:56:52 +02:00
Aleric Inglewood
21ea923520 Compile fix for OSX 2012-08-31 05:50:42 +02:00
Aleric Inglewood
484fff444f Compile fix for OSX 2012-08-31 05:23:20 +02:00
Aleric Inglewood
83b13f6a3f WIP: make everything use AICurlEasyRequestStateMachine 2012-08-20 21:18:19 +02:00
Aleric Inglewood
05c32c7a62 Merge branch 'curlthreading2' into curlthreading3 2012-08-15 05:44:17 +02:00
Aleric Inglewood
ea4d32b4ad Compile fix. 2012-08-15 05:43:12 +02:00
Aleric Inglewood
536cb6febd Merge branch 'curlthreading2' into curlthreading3
Conflicts:
	indra/CMakeLists.txt
	indra/llcommon/llstring.h
	indra/llmessage/CMakeLists.txt
	indra/llmessage/llhttpclient.cpp
	indra/llmessage/llhttpclient.h
	indra/llmessage/llurlrequest.cpp
	indra/llmessage/llurlrequest.h
	indra/newview/hipporestrequest.cpp
	indra/newview/llappviewer.cpp
2012-08-15 00:51:40 +02:00
Aleric Inglewood
19293601b3 Manual pick of stuff from 'shycurl' (68ad5411) that seemed to make sense. 2012-08-14 02:38:06 +02:00
Shyotl
f2bcfa5275 Use cachedcontrol in LLViewerObjectList::update. 2012-08-13 18:51:37 -05:00
Siana Gearz
36ff4dcd11 Don't feed empty, non-working callback to CURL
Cherry-Pick of 96a4e16a

Conflicts:
	indra/llmessage/llurlrequest.cpp
	indra/llmessage/llurlrequest.h
	indra/newview/hipporestrequest.cpp

Clear reasons for conflicts, resolved.
2012-08-13 23:33:49 +02:00
Aleric Inglewood
35a53ef1d7 Bug fix (needed for libcwd with memory allocation debugging) 2012-08-13 21:59:57 +02:00
Aleric Inglewood
169670a58b Refurbish last merge. Fix compile for standalone and libcwd. 2012-08-13 19:30:35 +02:00
Aleric Inglewood
fbb5dced97 Merge remote-tracking branch 'singu/master' into curlthreading2
Conflicts:
	indra/llcommon/CMakeLists.txt
	indra/llmessage/llcurl.cpp
	indra/llmessage/llcurl.h
	indra/llmessage/llhttpclient.cpp
	indra/llmessage/llhttpclient.h
	indra/llmessage/llpumpio.cpp
	indra/llmessage/llpumpio.h
	indra/llmessage/llurlrequest.cpp
	indra/llmessage/llurlrequest.h
	indra/newview/hipporestrequest.cpp
	indra/newview/llappviewer.cpp
	indra/newview/llspatialpartition.cpp
	indra/newview/llviewermedia.cpp
	indra/newview/llxmlrpctransaction.cpp

Conflicts resolved by choosing curlthreading2
for any llmessage file regardless (which looks
correct upon investigation); the rest also
turned out to need to use curlthreading2, except
in one line where I added a semi-colon after
an assert(), and the assert was changed in
singu/master.
2012-08-13 17:07:25 +02:00
Shyotl
aa54a386f3 Fix regression introduced in pathfinding (avelocity bugs) 2012-08-13 02:55:47 -05:00
Aleric Inglewood
263a25fb87 Compile fix for DEBUG_CURLIO 2012-08-12 17:42:30 +02:00
Aleric Inglewood
fa10ce28d2 Missing header 2012-08-12 17:10:44 +02:00
Aleric Inglewood
304fa05094 Suppress "Expect:" header for POST and PUT. No longer use CURLOPT_COPYPOSTFIELDS.
For POST and PUT, libcurl adds by default a "Expect: 100-continue"
header and wait for the server to reply with a 100 response.
However, since the server never does that (LL comment in the
code "I'm not sure what it means") it's up to libcurl to continue
anyway after a while and that part is apparently bugged, causing
people not to be able to login sometimes. But suppressing the
header, libcurl doesn't wait for it and we worked around this bug.

The commit introduces a much improved CurlEasyRequest::setPost
method that enforces the above for POST, but that also no longer
uses CURLOPT_COPYPOSTFIELDS (but CURLOPT_POSTFIELDS), no longer
making a copy of the body of what we are going to send to the server.
Instead it uses a new object, derived from AIPostField, to keep track
of this data and to dispose of it once the transaction is complete
(and no sooner).

Copied from llcorehttp, we now also always set a "Connection:
keep-alive" and "Keep-alive: 300" header for POST.
This was already done for texture downloads (HttpOpRequest),
but now we do it always :p. Might need to be changed in the
future, but currently those headers are ignored by the server
anyway.
2012-08-12 16:34:20 +02:00
Aleric Inglewood
2fbe7ab6ce Only accept pointers to valid types for getinfo(). 2012-08-12 03:38:45 +02:00
Aleric Inglewood
164799e4c4 Curl debug output improvements and minor fixes. 2012-08-12 03:33:33 +02:00
Aleric Inglewood
8e1bbfe938 Amend last commit 2012-08-11 03:29:46 +02:00
Aleric Inglewood
3469d65f95 Windows compile and linker fixes.
* Do not include aithreadid.h from debug.h, because the latter is
  included everywhere (from linden_common.h) and aithreadid.h is
  heavy (includes among others windows.h).
* On windows, thread local members cannot be exported.
2012-08-11 03:23:31 +02:00
Aleric Inglewood
70717cb6c8 Compile bug fix for windows. 2012-08-10 14:49:34 +02:00
Aleric Inglewood
94ebcdeb6b Add eight missing headers...
How did you ever get this to compile if those
headers were removed from the precompiled header?
2012-08-10 07:23:29 +02:00
Aleric Inglewood
152238e67f Merge remote-tracking branch 'shyotl/breakforce' into breakforce 2012-08-10 05:56:28 +02:00
Shyotl
eef51e0bd0 Pulled llpacketring.h and llhttpclient.h out of the precompiled header. 2012-08-09 22:50:05 -05:00
Aleric Inglewood
91df8446b0 Oops bug fix for last commit. 2012-08-10 05:37:41 +02:00
Aleric Inglewood
ffb55f482a Compile fixes for windows. 2012-08-10 05:35:11 +02:00
Aleric Inglewood
b2c5a84964 Replace CURLOPT_POSTFIELDSIZE_LARGE with CURLOPT_POSTFIELDSIZE
Also adds a more robust interface for setopt that does
type checking based on the options used. This fixes one
bug where a F32 was passed and interpreted as long.
In many cases a U32 or S32 was passed as long, which
would fail (only) on a 64bit non-windows big endian machine.
2012-08-10 04:18:04 +02:00
Aleric Inglewood
0054e6a378 Bug fix.
Fixes an exit crash when the user clicks on Login and immediately
on Quit, because termination of the LLAuth curl request statemachine
access the CurlRequestTimeOut debug setting.
2012-08-09 07:04:23 +02:00
Aleric Inglewood
76e30150b9 Removed superfluous debug output 2012-08-09 07:02:42 +02:00
Aleric Inglewood
cd197a3807 Fix LL_REF_COUNT_DEBUG debug code.
This code was broken with respect to LLAPRPool.
Fix that, and also fixed it for the new AIThreadID API.
2012-08-09 07:00:51 +02:00
Aleric Inglewood
b9673df961 Clean up of debug.h: just use LL_COMMON_API. 2012-08-09 06:57:53 +02:00
Aleric Inglewood
37c8ea54eb Add AIThreadID - Cleanup of apr_os_thread* related code.
Apart from just really cleaning things up and moving
everything into one class regarding thread IDs (ie,
is_main_thread(), comparing ID's etc), this also
fixes an obscure bug where LL was casting thread ID's
to U32 and then compared those to find out if it
the same thread. It's theoretically possible that
such fails on a 64bit OS.

By generalizing the interface, I adopted the use
of a thread-local cache for the current thread ID
as used by LLMutex et al, so now all code benefits
from that. The idea was even extended to now also
be used for is_main_thread() tests and even resetting
a thread ID to the ID of the current thread.
2012-08-09 06:30:31 +02:00
Aleric Inglewood
f94f458922 Print CURL_SOCKET_TIMEOUT for that particular value. 2012-08-08 04:10:34 +02:00
Aleric Inglewood
89ef06fd3f Compiler warning fixes. Take into account that debug_libcurl.cpp is no longer linked dynamically. 2012-08-08 01:58:49 +02:00
Aleric Inglewood
ccd135b2a6 and again 2012-08-08 01:04:27 +02:00
Aleric Inglewood
80eb0851d9 Fix stupidity 2012-08-08 01:02:08 +02:00
Aleric Inglewood
b84f470fca Bug fix: curl_off_t has a different size than void* on 32 bit. 2012-08-08 00:40:01 +02:00
Aleric Inglewood
5caeccc007 Final compile/link bug fixes for debug_libcurl code.
renamed cwdebug/debug_libcurl.cc -> llmessage/debug_libcurl.cpp
    and cwdebug/debug_libcurl.h  -> llmessage/debug_libcurl.h,
because debug_libcurl.cpp does curl calls that do ares and
openssl calls, so we need to link with those libraries.
llmessage is already linking with those libraries, and contains
the main entry point aicurl.h, so it's a suitable place to put
this.

Bug fix: must always include llpreprocessor.h before including
curl/curl.h.

Bug fix: Added #include "debug_libcurl.h" to hipporestrequest.cpp
and llurlsimstring.cpp which I missed before because they
included "curl/curl.h" instead of <curl/curl.h>. Same in
llwaterparammanager.cpp, but removed include there because it
isn't needed.

Now test DEBUG_CURLIO before including debug_curlio, that
seems better, because otherwise it would make more sense to
replace all #include <curl/curl.h> with #include "mycurl.h"
and then do it there-- but I didn't want to do that.

Bug fix: we undef-ed CURLOPT_DNS_USE_GLOBAL_CACHE, while really
that is an enum, not a macro.

Fixed DEBUG_WINDOWS_CODE_ON_LINUX again by adding a hack for
ioctlsocket(), not instantiating dumb_socketpair unless
DEBUG_WINDOWS_CODE_ON_LINUX is defined and removing again ^M's
introduced with the new windows non-blocking code.
Also changed the type of flags passed to fcntl to int (was long).
2012-08-07 20:57:39 +02:00
Aleric Inglewood
477c657f60 Merge remote-tracking branch 'singu/breakforce' into breakforce 2012-08-07 16:19:20 +02:00
Aleric Inglewood
cc50e620c0 Merge branch 'curlthreading2' into breakforce 2012-08-07 05:22:10 +02:00
Aleric Inglewood
8646abb18b Merge branch 'curlthreading2' into curlthreading3 2012-08-07 05:21:52 +02:00
Aleric Inglewood
2fbf6b732e Fix undefined symbols linker error on linux / relwithdebinfo.
See http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Interface.html
With this patch, the #pragma will also be used with icc and clang,
I didn't test this.
2012-08-07 05:18:24 +02:00
Aleric Inglewood
93416e40a4 Compile fix: CURLOPT_SSL_OPTIONS was also added since 7.25.0 2012-08-07 05:16:59 +02:00
Aleric Inglewood
e14be5c8c2 Make debug_libcurl.cc compile with libcurl 7.21 and higher 2012-08-07 01:33:29 +02:00
Aleric Inglewood
95083e846b WIP 2012-08-06 23:19:09 +02:00
Aleric Inglewood
f479ea4bcf Merge branch 'curlthreading2' into curlthreading3 2012-08-06 19:55:19 +02:00
Aleric Inglewood
65a1aae629 Bug fix
curl_easy_setopt expects a long int. Before this patch,
uninitialized memory was read, leading to extreme long
time out, instead of the intended disabled time out (so,
in practise this patch has little effect).

This bug was discovered with the previous commit.
2012-08-05 18:55:27 +02:00
Aleric Inglewood
caef97ad36 Print all libcurl calls if -DDEBUG_CURLIO. Don't create static lib for cwdebug.
Basically, cmake doesn't support linking static libs into a shared lib.
The correct way is to just specify source files in subdirectories
directly as source files of the shared library. This patch changes that.

Also, after this commit, when DEBUG_CURLIO is defined, every call to
libcurl is printed to llinfos (or to dc::curl when using libcwd).
2012-08-05 18:51:21 +02:00
Siana Gearz
761439cc8d Setting socket pair non-blocking 2012-08-05 08:20:31 +02:00
Aleric Inglewood
98c740f204 Remove debug output 2012-08-03 00:56:41 +02:00
Aleric Inglewood
255742db26 Merge branch 'curlthreading2' into breakforce 2012-08-03 00:54:12 +02:00
Aleric Inglewood
af4ceb0658 Crash on exit fix. 2012-08-03 00:53:54 +02:00
Aleric Inglewood
08d72b12ab Fix compilation on linux. Remove trailing ^M's 2012-08-02 23:03:03 +02:00
Aleric Inglewood
5fb4badb7c WIP 2012-08-02 22:34:23 +02:00
Siana Gearz
4650636e5a Use TCP socket pair instead of UDP 2012-08-02 22:33:01 +02:00
Aleric Inglewood
725cdc2d69 Linux compile fixes 2012-07-31 23:04:45 +02:00
Siana Gearz
048c57cf0c Linktime fix 2012-07-31 22:40:20 +02:00
Siana Gearz
12dcbfbc79 Merge remote-tracking branch 'aleric/breakforce' into breakforce 2012-07-31 22:39:48 +02:00
Aleric Inglewood
32be05fa6c Compile warning fixes. Type fix (SLL -> SSL) 2012-07-31 22:37:49 +02:00
Aleric Inglewood
ae62b67554 Merge branch 'curlthreading2' into breakforce 2012-07-31 22:24:57 +02:00
Aleric Inglewood
29908533cd More work in progress 2012-07-31 22:23:52 +02:00
Siana Gearz
9c4f22d85b Attempt at fixing linker errors... 2012-07-31 21:30:05 +02:00
Siana Gearz
7f64668e55 Compile warning fix 2012-07-31 21:29:22 +02:00
Siana Gearz
0208942b84 Compile warning fix 2012-07-31 21:28:37 +02:00
Siana Gearz
783e86990c Compile fixes 2012-07-31 19:42:15 +02:00
Aleric Inglewood
cdefc0e384 Merge branch 'curlthreading2' into curlthreading3
Conflicts:
	indra/llmessage/llcurlrequest.cpp

Header file include changes collided. Fixed.
2012-07-31 17:46:07 +02:00
Aleric Inglewood
c9715c5b0b Print Dout() and DoutEntering() debug output on windows.
This is a bit of a hack currently and requires a
recompile with -DDEBUG_CURLIO.
2012-07-31 04:57:13 +02:00
Aleric Inglewood
dd47123bde Add possibility to suppress function name prefix in debug output.
Adds llinfos_nf et al.
2012-07-31 04:56:03 +02:00
Aleric Inglewood
3de21156b5 Windows code improvements and debugging.
Extended the DEBUG_WINDOWS_CODE_ON_LINUX hack to include ALL code.
memset-zero sockaddr_in, and use WSASocket as per suggestion of Shyotl.
2012-07-30 02:46:48 +02:00
Aleric Inglewood
ce2c6ab49e Don't crash when libcurl wasn't compiled with support for libz 2012-07-30 02:45:39 +02:00
Aleric Inglewood
d19c5a4a4a Move apr_os_thread_current_wrapper closer to where it's used, and fix a comment. 2012-07-30 02:44:51 +02:00
Aleric Inglewood
8945fe4857 Unbreak standalone install on 64bit linux 2012-07-30 01:47:27 +02:00
Aleric Inglewood
464919072d Use LLBufferArray instead of std::stringstream for CurlResponderBuffer::mInput
Note the changed code is never used yet.  CurlResponderBuffer::curlReadCallback
is only called when Request::post is being used, which is never used.
2012-07-29 22:52:20 +02:00
Siana Gearz
f8c2087d74 Preliminary Windows support for curlthreading 2012-07-29 22:47:19 +02:00
Siana Gearz
7adc0e24ab Merge branch 'curlthreading2' of git://github.com/AlericInglewood/SingularityViewer into curlthreading 2012-07-29 21:32:24 +02:00
Aleric Inglewood
ba65f29a72 Fix draining of wake up pipe.
This is a bug fix, although not one we'd ever run into as normally
there is always just one byte to read, never an EAGAIN and certainly
never more than 256 bytes. Anyway, also those cases should work now.
2012-07-29 21:12:45 +02:00
Aleric Inglewood
76eef6fe59 Avoid crash on exit. 2012-07-29 18:38:59 +02:00
Aleric Inglewood
af4ac8fb5f WIP: work on rewriting LLURLRequest 2012-07-29 01:30:11 +02:00
Aleric Inglewood
adaf5cd69c Update of a few <edit> comments.
While comparing this function with v-d, I realized that
I editted these instances for Singularity, so I might
as well update the <edit> comments to be a bit more correct.
Not saying that there aren't other <edit> comments
still missing futher into the function.
2012-07-29 01:30:11 +02:00
Aleric Inglewood
516f5a40d0 Change mainloop to no longer use gIdleCallbacks 2012-07-29 01:30:11 +02:00
Aleric Inglewood
3b7887a041 Cleanup of some unnecessary dependencies. 2012-07-29 01:30:11 +02:00
Aleric Inglewood
fe38f59bbb Bug fix 2012-07-29 01:30:10 +02:00
Aleric Inglewood
cd93aba002 Created aistatemachine library and moved files. 2012-07-29 01:30:10 +02:00
Siana Gearz
2bcabce1d6 Merge branch 'curlthreading2' of git://github.com/AlericInglewood/SingularityViewer into curlthreading 2012-07-28 17:28:18 +02:00
Aleric Inglewood
ed4c6b7c92 Removed dead code.
This code has been in the viewer source for a long time,
and hasn't been used for a long time (furtherest back that
I checked was Snowglobe 1.4).

Most notably, this removes LLContextURLExtractor and code
that used it because that required an API where AICurlEasyHandle
is created before an url is known, which gets in the way of
reusing connections.
2012-07-23 18:15:11 +02:00
Aleric Inglewood
785729abdf Merge branch 'master' into curlthreading2 2012-07-22 04:17:34 +02:00
Aleric Inglewood
fb38f6adea Always write curl I/O debug info for the login attempt. 2012-07-21 21:51:24 +02:00
Aleric Inglewood
3a30f1dc71 This is called when LLApp::sStatus == LLApp::APP_STATUS_STOPPED too. 2012-07-21 03:57:58 +02:00
Siana Gearz
8802d5033f Merge branch 'master' into curlthreading
Conflicts:
	indra/newview/viewer_manifest.py
2012-07-20 00:37:58 +02:00
Siana Gearz
3d39564605 Merge branch 'curlthreading2' of git://github.com/AlericInglewood/SingularityViewer into curlthreading 2012-07-20 00:35:43 +02:00
Aleric Inglewood
9e5cbf330f Bug fix for windows code found with previous commit. 2012-07-19 17:28:45 +02:00
Aleric Inglewood
2fa9334090 Debug code to test the windows code path on linux 2012-07-19 17:27:37 +02:00
Aleric Inglewood
fcdf5d377e Move PollSet out of the header file 2012-07-19 17:26:02 +02:00
Aleric Inglewood
051263117d Don't force TLS v1 unless needed and then warn about it. 2012-07-19 00:13:43 +02:00
Aleric Inglewood
f772cbee51 Don't crash upon exit if we fail to cleanup. 2012-07-18 03:13:33 +02:00
Aleric Inglewood
7f78870295 Merge remote-tracking branch 'siana/master' into curlthreading2
Conflicts:
	indra/llcommon/llstring.cpp
	indra/llmessage/llcurl.cpp
	indra/newview/llviewertexturelist.cpp
	indra/newview/viewer_manifest.py
	install.xml

Resolved:
	indra/llcommon/llstring.cpp :
		two different ways to work around compile error.
	indra/llmessage/llcurl.cpp :
		this file is no longer used.. I deleted huge
		parts to mark that I implemented that. Siana
		apparently made a few changes in those parts.
	indra/newview/llviewertexturelist.cpp :
		manually copied patch. Mine also removed trailing
		spaces, keeping that.
	indra/newview/viewer_manifest.py:
		Collision with changes from Liru, which have been
		ignored (kept siana/master).
	install.xml:
		Collision with an earlier screw up. I kept the
		fix from siana/master.
2012-07-18 02:08:31 +02:00
Aleric Inglewood
706b9c55c2 Moving stuff around a bit... 2012-07-18 01:41:36 +02:00
Shyotl
48ae0d003d Made the Visual Studio compiler a bit more happy with aicurl. 2012-07-17 18:04:48 -05:00
Aleric Inglewood
0204d09a89 If curl thread is already awake, then don't write something to the pipe. 2012-07-17 23:39:44 +02:00
Aleric Inglewood
648ed00ce2 Don't call gSavedSettings.getU32() and calc_clock_frequency() so often anymore. 2012-07-17 19:58:34 +02:00
Aleric Inglewood
87c9358813 Add back erroneously removed comments. 2012-07-17 19:33:12 +02:00
Aleric Inglewood
64b968b262 process is no longer processing 2012-07-17 19:27:14 +02:00
Aleric Inglewood
900e533b4b Remove unused call to process(). 2012-07-17 08:01:06 +02:00
Aleric Inglewood
9deb3e433c LLCurlRequest time out fixes.
Also some more cleanup on exit improvements.
2012-07-16 22:35:04 +02:00
Aleric Inglewood
a34247ebf4 Bug fix.
Don't test on something that belongs in an assert.
is_main_thread() doesn't even exist unless --type=Debug.
2012-07-15 23:08:07 +02:00
Aleric Inglewood
53e96b02c0 Bug fix. Forgot to actually make it virtual. 2012-07-15 22:59:29 +02:00
Aleric Inglewood
7c022d6061 Don't crash on exit.
When a new state machine was just created, so run() had already
been called but it never did really run yet so running() would
return false; then abort() wasn't called in flush(), causing
the subsequent mainloop call to actually try and startup the
state machine, which then crashed because Debug Settings
mechanism is already destroyed at that point (and in general,
we really don't want anything to run: it does unpredictable
things).

With this fix, also state machines that were just created are
aborted, resulting actuall in a kill without delete, and subsequently
a clean delete from the mainloop.
2012-07-15 22:51:14 +02:00
Aleric Inglewood
14e5b46687 Fixed and adjusted remainders of isValid() code.
Note that in the code, and still, has_curl_request was always false.
However, instead of deleting all code paths that are only executed
when has_curl_request would be true, I fixed the code to work as
intended with my current implementation; which also results in
LLCurlRequests to never expire. This way things won't break
unexpectedly when this ever changes.

Since on this branch isValid was only called still (the rest was
removed already) to check if the curl download expired, I took
the liberty to rename isValid to hasNotExpired.
2012-07-15 22:46:38 +02:00
Aleric Inglewood
a6bb2604f6 Use our API, which makes more sense. 2012-07-15 16:58:47 +02:00
Aleric Inglewood
b2c71c099f Fixed typo in comment 2012-07-15 16:57:47 +02:00
Aleric Inglewood
7416d2aaf1 Timer, time out, and clean up improvements. 2012-07-14 04:29:37 +02:00
Aleric Inglewood
0419f8bee9 Add an AITimer to AICurlEasyRequestStateMachine.
Fixes AIStateMachine to work thread-safe with the timer.
2012-07-10 05:09:08 +02:00
Aleric Inglewood
f012f664d2 Threading voodoo: allow multiple concurrent calls to set_state().
This patch prepares AIStateMachine for the use of AITimer together
with calls to set_state() from other threads. The extra problem
in this case is that the main-thread CAN start running the state
machine again (when the timer times out), while before it was
assumed to be idle until a thread called set_state.

This also takes into account that a thread might call set_state()
and then AGAIN call set_state() before the main thread gets the
chance to call idle() inbetween.
2012-07-09 04:19:28 +02:00
Aleric Inglewood
744563a150 Use a newer libcurl version for linux. 2012-07-07 23:22:48 +02:00
Aleric Inglewood
389074d1e9 Fail at configure time when openGL is not found 2012-07-07 23:17:22 +02:00
Aleric Inglewood
93778eccbb Compile fix for g++ 4.7 2012-07-07 18:29:55 +02:00
Aleric Inglewood
f46d8e8a10 Try to be smart about not printing garbage (binary) received from the server. 2012-07-05 23:50:03 +02:00
Siana Gearz
f5bfab139c Merge branch 'curlthreading2' of git://github.com/AlericInglewood/SingularityViewer into curlthreading 2012-07-05 06:06:04 +02:00
Aleric Inglewood
df20f918ba New libcwd channel 'curlio'.
Enable printing of libcurl 'IO' debug messages when libcwd channel
'curlio' is turned on (added to .libcwdrc). Avoiding a recompile.
2012-07-05 03:10:16 +02:00
Aleric Inglewood
b8fc1f634e Print the curl library found during configure.
Prints something like:
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.25.0")
2012-07-05 01:41:01 +02:00
Aleric Inglewood
ae9dadb5d8 Improved layout of curl stats print out. 2012-07-04 16:56:33 +02:00
Siana Gearz
d31c062693 Fix building with libcwd 2012-07-04 12:44:05 +02:00
Siana Gearz
544928a039 Merge branch 'curlthreading2' of git://github.com/AlericInglewood/SingularityViewer into curlthreading 2012-07-04 10:45:48 +02:00
Aleric Inglewood
14276b3cf8 Bug fix 2012-07-04 08:44:22 +02:00
Aleric Inglewood
07e7eeedd1 Added some windows code.
Iterating directly over the elements of fd_set::fd_array in
windows is faster than using FD_ISSET.
2012-07-04 07:32:24 +02:00
Aleric Inglewood
125a10bb44 Code hardening, review, bug fixes, documentation, curl stats and cleanup.
Bug fixes:
AICurlEasyRequestStateMachine didn't delete itself.
curl_multi_socket_action calls were made for potentional removed sockets.
The curl thread wasn't terminated.
2012-07-04 00:10:43 +02:00
Aleric Inglewood
9b8e5c8719 Merge branch 'V2MultiWear' into curlthreading2
I picked a few non-curl related patches from curlthreading2
and applied them to V2MultiWear. Now merging back to avoid
collisions for others.
2012-07-03 14:27:12 +02:00
Aleric Inglewood
a803507d67 Use correct way to check if we logged in yet or not.
Without this fix, we trigger an assert, in debug mode, that was added
to Singularity exactly to find out if we called functions like
getExpandedFilename(LL_PATH_PER_SL_ACCOUNT ...) before logging in.
Checking if THAT function returns empty() is clearly not safe, but
very error prone.
2012-07-01 22:15:03 +02:00
Aleric Inglewood
cb5efad026 Turn llassert[_always] into a (single) statement and print line nr in decimal. 2012-06-30 21:14:18 +02:00
Aleric Inglewood
26922a1578 Merge remote-tracking branch 'lirusaito/curlthreading2' into curlthreading2 2012-06-29 05:28:58 +02:00
Aleric Inglewood
90493b6571 Add support for libopenSSL older than version 1.0.0. 2012-06-29 05:20:24 +02:00
Aleric Inglewood
2dee921cd5 Fix libcurl version check. 2012-06-29 01:33:38 +02:00
Lirusaito
433c7c3f99 Spelling fixes and stuff like that to AICurl* and llproxy.* documentations
Also removes a duplicate include from llares.cpp

Conflicts:
	indra/llmessage/aicurl.cpp
2012-06-28 04:08:25 -04:00
Lirusaito
fef461fd13 Grabbed openSSL-1.0.0d from upstream for linux, necessary for non-standalone compiles.
Also brought in linux64 version I had sitting around, collecting dust.
2012-06-28 03:46:22 -04:00
Aleric Inglewood
1f56645b69 Always set proxy settings for every HTTP curl connection.
Move applyProxySettings to CurlEasyRequest and call it from
applyDefaultOptions.

Use AIThreadSafe for LLProxy for a more robust threadsafeness.
(This forces correct locking, checks that the unshared vars
are indeed unshared and made it easy to use read/write locking,
which might be important in this case (we do a lot of read-only
accesses to it).
2012-06-28 05:56:21 +02:00
Aleric Inglewood
69ca6cd5b2 WIP: Make curl thread code robust and flexible.
Conflicts:

	indra/llmessage/llcurl.cpp
	indra/llmessage/llcurl.h
	indra/newview/app_settings/settings.xml
	indra/newview/llappviewer.cpp
	indra/newview/llmeshrepository.cpp

Resolved:

	indra/llmessage/llcurl.cpp:

	  Basically removed (not used anyway)

	indra/llmessage/llcurl.h:

	  Basically removed (just includes aiculr.h now)

	indra/newview/app_settings/settings.xml:

	  CurlUseMultipleThreads was remvoved.
	  CurlMaximumNumberOfHandles and CurlRequestTimeOut
	  are still in there, but unused at the moment.

	indra/newview/llappviewer.cpp:

	  CurlMaximumNumberOfHandles and CurlRequestTimeOut
	  are unused at the moment.

	indra/newview/llmeshrepository.cpp:

	  Lock mSignal always (is unlocked inside wait()).
	  Use mSignal lock to see if we are waiting; remove mWaiting.
	  Return false from the MeshFetch functions iff we have to retry
	  a HTTP fetch. Catch the error exception thrown by getByteRange
	  instead of using it's return value (always returns true
	  anyway).
2012-06-28 01:30:46 +02:00
1786 changed files with 61265 additions and 26248 deletions

2
.gitignore vendored
View File

@@ -11,6 +11,7 @@
/bin-release
/indra/viewer-*
/indra/newview/vivox-runtime/
/indra/newview/dbghelp.dll
/libraries/
/lib/
*.pyc
@@ -22,3 +23,4 @@
/LICENSES/
/edited-files.txt
qtcreator-build/
/.pc

View File

@@ -0,0 +1,114 @@
Linden Research, Inc. ("Linden Lab") Viewer FLOSS License Exception v0.5
The Linden Lab Exception for Free/Libre and Open Source Software-only
Applications Using Linden Lab Viewer Software (the "FLOSS Exception").
Exception Intent
Linden Lab is releasing the source code for certain software that
enables users to view or otherwise access the Second Life virtual
world environment (the "Viewer Software"), under version 2 of the GNU
General Public License (the "GPL"). The creation or distribution of
works based on the Program (as defined under the GPL) of the Viewer
Software may require the use of certain Free/Libre and Open Source
Software ("FLOSS") works that are subject to license agreements not
compatible with re-licensing under the GPL. Because we want to allow
the Viewer Software to be distributed with these FLOSS works, this
FLOSS Exception following exception applies subject to the terms and
conditions below.
Legal Terms and Conditions
As a special exception to the terms and conditions of version 2.0 of
the GPL:
You are free to distribute a work based on the Program that is formed
entirely from the Viewer Software (and any modifications thereof) and
one or more works that are independent and separate works not derived
from the Viewer Software, and are licensed under one or more of the
licenses listed below in section 1 (each, a "FLOSS Work") , as long
as:
A. You obey the GPL in all respects for the Viewer Software and any
work based on the Program, except for the FLOSS Works, for which
you must comply with B below,
B. all FLOSS Works,
i. are distributed subject to one of the FLOSS licenses
listed below, and
ii. the object code or executable form of the FLOSS Works are
accompanied by the complete corresponding
machine-readable source code for those FLOSS Works on the
same medium and under the same FLOSS license as the
corresponding object code or executable forms thereof,
and
C. any works that are aggregated with the Viewer Software or a work
based on the Program on a volume of a storage or distribution
medium in accordance with the GPL, and are not licensed under
the FLOSS licenses listed below, are independent and separate
works in themselves which are not derivatives of either the
Viewer Software, a work based on the Program or a FLOSS Work.
If the above conditions are not met, then the Viewer Software may only
be copied, modified, distributed or used under the terms and
conditions of the GPL or another valid licensing option from Linden
Lab.
1. FLOSS License List
License name Version(s)/Copyright Date
Academic Free License 2.0
Apache Software License 1.0/1.1/2.0
Apple Public Source License 2.0
Artistic license From Perl 5.8.0
BSD license "July 22 1999"
Common Development and
Distribution License (CDDL) 1.0
Common Public License 1.0
GNU Library or "Lesser" General
Public License (LGPL) 2.0/2.1
Jabber Open Source License 1.0
MIT License (As listed in file MIT-License.txt) -
Mozilla Public License (MPL) 1.0/1.1
Open Software License 2.0
OpenSSL license (with
original SSLeay license) "2003" ("1998")
PHP License 3.0
Python license (CNRI Python License) -
Python Software Foundation License 2.1.1
Sleepycat License "1999"
W3C License "2001"
X11 License "2001"
Zlib/libpng License -
Zope Public License 2.0
Due to the many variants of some of the above licenses, we require
that any variant of the above licenses be identical in substance to
the form approved by the Open Source Initiative and follow the 2003
version of the Free Software Foundation's Free Software Definition
(http://www.gnu.org/philosophy/free-sw.html) or version 1.9 of the
Open Source Definition by the Open Source Initiative
(http://www.opensource.org/docs/definition.php).
2. Definitions
Terms used, but not defined, herein shall have the meaning provided in
the GPL.
3. Applicability
This FLOSS Exception applies to all Viewer Software files that contain
a notice placed by Linden Lab saying that the Viewer Software may be
distributed under the terms of this FLOSS Exception. If you create or
distribute a work which is a work based on the Program for the Viewer
Software and any other work licensed under the GPL, then this FLOSS
Exception is not available for that work; thus, you must remove the
FLOSS Exception notice from that work and comply with the GPL in all
respects, including by retaining all GPL notices. You may choose to
redistribute a copy of the Viewer Software exclusively under the terms
of the GPL by removing the FLOSS Exception notice from that copy of
the Viewer Software, provided that the copy has never been modified by
you or any third party.

339
LICENSES/GPL-license.txt Normal file
View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@@ -0,0 +1,36 @@
Source code
========
The license for the source code in this distribution should be clearly
marked on each source file. Unless otherwise specified, the source
code in this distribution ("Source Code") is provided by Linden Lab to
you under the terms of the GNU General Public License, version 2.0
("GPL"), unless you have obtained a separate licensing agreement
("Other License"), formally executed by you and Linden Lab. Terms of
the GPL can be found in GPL-license.txt in this distribution, or
online at http://secondlifegrid.net/technology-programs/license-virtual-world/viewerlicensing/gplv2
There are special exceptions to the terms and conditions of the GPL as
it is applied to this Source Code. View the full text of the exception
in the file FLOSS-exception.txt in this software distribution, or
online at http://secondlifegrid.net/technology-programs/license-virtual-world/viewerlicensing/flossexception
By copying, modifying or distributing this software, you acknowledge
that you have read and understood your obligations described above,
and agree to abide by those obligations.
ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
COMPLETENESS OR PERFORMANCE.
Logos and trademarks
==============
"Second Life" and "Linden Lab" are registered trademarks of Linden
Research, Inc. Other trademarks include (but are not limited to): the
names Linden and Linden Research, as well as the Linden Lab Hexagon
Design and the Second Life Hand Design logos.
Use of logos and trademarks are subject to the Linden Lab trademark
policy, available at:
http://secondlife.com/corporate/trademark/

27
README
View File

@@ -9,15 +9,30 @@
Sin-gu-la-ri-ty (noun) - a distinctive feature, a uniqueness; a point at which
continuity breaks up; a point in history at which machine becomes smarter than
humanity and/or fuses with it indivisively; or simply a cool sounding word with
my initials in it :)
the initials S.G. in it :)
Singularity Viewer is a Second Life protocol compatible client application. It
can be used to access Second LIfe service as well as a number of other such as
those based upon OpenSim plattform. It is directly based upon source code of
Ascent Viewer by Balseraph Software Group, which is in turn based upon source
code released by Linden Lab, with contributions from various sources.
Singularity Viewer is a SecondLife(tm) protocol compatible client application.
It can be used to access SecondLife services as well as a number of others such
as those based upon the OpenSim platform.
Singulariy is maintained by a small group of volunteers who can be contacted
both, in-world (SingularityViewer group) as well on IRC (#SingularityViewer
@ FreeNode). Bug requests and features requests can be submitted through our
Issue Tracker (http://code.google.com/p/singularity-viewer/issues/list or from
the viewer menu: Help --> Bug Reporting --> Singularity Issue Tracker...)
As this Readme grows out of date, please refer to
http://www.singularityviewer.org/about
00000000011111111112222222222333333333344444444445555555555666666666677777777778
12345678901234567890123456789012345678901234567890123456789012345678901234567890
History
The Singularity viewer was started by Siana Gearz in November 2010 by forking it
from the Ascent Viewer, by Balseraph Software Group, which in turn was based upon
source code modified from the snowglobe source code released by Linden Lab.

View File

@@ -248,6 +248,7 @@ Celierra Darling
VWR-6975
Cron Stardust
VWR-10579
STORM-1919
Cypren Christenson
SNOW-129
SNOW-140

View File

@@ -378,6 +378,14 @@
<boolean>true</boolean>
</map>
<key>WindLightRefresh</key>
<map>
<key>flavor</key>
<string>llsd</string>
<key>trusted-sender</key>
<boolean>true</boolean>
</map>
<key>ParcelVoiceInfo</key>
<map>
<key>flavor</key>
@@ -386,7 +394,6 @@
<boolean>true</boolean>
</map>
<key>ParcelNavigateMedia</key>
<map>
<key>flavor</key>

View File

@@ -18,7 +18,7 @@ cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR)
cmake_policy(SET CMP0003 OLD)
set(ROOT_PROJECT_NAME "Singularity" CACHE STRING
"The root project/makefile/solution name. Defaults to SecondLife.")
"The root project/makefile/solution name. Defaults to Singularity.")
project(${ROOT_PROJECT_NAME})
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
@@ -46,7 +46,7 @@ endif(NOT STANDALONE)
add_custom_target(prepare DEPENDS ${prepare_depends})
add_subdirectory(cmake)
add_subdirectory(${LIBS_OPEN_PREFIX}cwdebug)
add_subdirectory(${LIBS_OPEN_PREFIX}aistatemachine)
add_subdirectory(${LIBS_OPEN_PREFIX}llaudio)
add_subdirectory(${LIBS_OPEN_PREFIX}llcharacter)
add_subdirectory(${LIBS_OPEN_PREFIX}llcommon)
@@ -62,11 +62,15 @@ add_subdirectory(${LIBS_OPEN_PREFIX}llvfs)
add_subdirectory(${LIBS_OPEN_PREFIX}llwindow)
add_subdirectory(${LIBS_OPEN_PREFIX}llxml)
if(STANDALONE)
add_subdirectory(${LIBS_OPEN_PREFIX}llqtwebkit)
endif(STANDALONE)
if (EXISTS ${LIBS_CLOSED_DIR}llkdu AND NOT STANDALONE)
add_subdirectory(${LIBS_CLOSED_PREFIX}llkdu)
endif (EXISTS ${LIBS_CLOSED_DIR}llkdu AND NOT STANDALONE)
add_subdirectory(${LIBS_OPEN_PREFIX}lscript)
#add_subdirectory(${LIBS_OPEN_PREFIX}lscript)
if (WINDOWS AND EXISTS ${LIBS_CLOSED_DIR}copy_win_scripts)
add_subdirectory(${LIBS_CLOSED_PREFIX}copy_win_scripts)

View File

@@ -0,0 +1,39 @@
# -*- cmake -*-
project(aistatemachine)
include(00-Common)
include(LLCommon)
include(LLMessage)
include(LLMath)
include(LLXML)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(
${LLCOMMON_INCLUDE_DIRS}
${LLMESSAGE_INCLUDE_DIRS}
${LLMATH_INCLUDE_DIRS}
${LLXML_INCLUDE_DIRS}
)
set(aistatemachine_SOURCE_FILES
aistatemachine.cpp
aitimer.cpp
)
set(aistatemachine_HEADER_FILES
CMakeLists.txt
aistatemachine.h
aitimer.h
)
set_source_files_properties(${aistatemachine_HEADER_FILES}
PROPERTIES HEADER_FILE_ONLY TRUE)
list(APPEND aistatemachine_SOURCE_FILES ${aistatemachine_HEADER_FILES})
add_library (aistatemachine ${aistatemachine_SOURCE_FILES})
add_dependencies(aistatemachine prepare)

View File

@@ -0,0 +1,628 @@
/**
* @file aistatemachine.cpp
* @brief Implementation of AIStateMachine
*
* Copyright (c) 2010, Aleric Inglewood.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution.
*
* CHANGELOG
* and additional copyright holders.
*
* 01/03/2010
* Initial version, written by Aleric Inglewood @ SL
*/
#include "linden_common.h"
#include <algorithm>
#include "llcontrol.h"
#include "llfasttimer.h"
#include "aithreadsafe.h"
#include "aistatemachine.h"
// Local variables.
namespace {
struct QueueElementComp;
class QueueElement {
private:
AIStateMachine* mStateMachine;
U64 mRuntime;
public:
QueueElement(AIStateMachine* statemachine) : mStateMachine(statemachine), mRuntime(0) { }
friend bool operator==(QueueElement const& e1, QueueElement const& e2) { return e1.mStateMachine == e2.mStateMachine; }
friend struct QueueElementComp;
AIStateMachine& statemachine(void) const { return *mStateMachine; }
void add(U64 count) { mRuntime += count; }
};
struct QueueElementComp {
bool operator()(QueueElement const& e1, QueueElement const& e2) const { return e1.mRuntime < e2.mRuntime; }
};
typedef std::vector<QueueElement> active_statemachines_type;
active_statemachines_type active_statemachines;
}
// static
U64 AIStateMachine::sMaxCount;
AIThreadSafeDC<AIStateMachine::csme_type> AIStateMachine::sContinuedStateMachinesAndMainloopEnabled;
// static
void AIStateMachine::setMaxCount(F32 StateMachineMaxTime)
{
llassert(is_main_thread());
Dout(dc::statemachine, "(Re)calculating AIStateMachine::sMaxCount");
sMaxCount = calc_clock_frequency() * StateMachineMaxTime / 1000;
}
//----------------------------------------------------------------------------
//
// Public methods
//
void AIStateMachine::run(AIStateMachine* parent, state_type new_parent_state, bool abort_parent, bool on_abort_signal_parent)
{
DoutEntering(dc::statemachine, "AIStateMachine::run(" << (void*)parent << ", " << (parent ? parent->state_str(new_parent_state) : "NA") << ", " << abort_parent << ") [" << (void*)this << "]");
// Must be the first time we're being run, or we must be called from a callback function.
llassert(!mParent || mState == bs_callback);
llassert(!mCallback || mState == bs_callback);
// Can only be run when in this state.
llassert(mState == bs_initialize || mState == bs_callback);
// Allow NULL to be passed as parent to signal that we want to reuse the old one.
if (parent)
{
mParent = parent;
// In that case remove any old callback!
if (mCallback)
{
delete mCallback;
mCallback = NULL;
}
mNewParentState = new_parent_state;
mAbortParent = abort_parent;
mOnAbortSignalParent = on_abort_signal_parent;
}
// If abort_parent is requested then a parent must be provided.
llassert(!abort_parent || mParent);
// If a parent is provided, it must be running.
llassert(!mParent || mParent->mState == bs_run);
// Mark that run() has been called, in case we're being called from a callback function.
mState = bs_initialize;
// Set mIdle to false and add statemachine to continued_statemachines.
mSetStateLock.lock();
locked_cont();
}
void AIStateMachine::run(callback_type::signal_type::slot_type const& slot)
{
DoutEntering(dc::statemachine, "AIStateMachine::run(<slot>) [" << (void*)this << "]");
// Must be the first time we're being run, or we must be called from a callback function.
llassert(!mParent || mState == bs_callback);
llassert(!mCallback || mState == bs_callback);
// Can only be run when in this state.
llassert(mState == bs_initialize || mState == bs_callback);
// Clean up any old callbacks.
mParent = NULL;
if (mCallback)
{
delete mCallback;
mCallback = NULL;
}
mCallback = new callback_type(slot);
// Mark that run() has been called, in case we're being called from a callback function.
mState = bs_initialize;
// Set mIdle to false and add statemachine to continued_statemachines.
mSetStateLock.lock();
locked_cont();
}
void AIStateMachine::idle(void)
{
DoutEntering(dc::statemachine, "AIStateMachine::idle() [" << (void*)this << "]");
llassert(is_main_thread());
llassert(!mIdle);
mIdle = true;
mSleep = 0;
#ifdef SHOW_ASSERT
mCalledThreadUnsafeIdle = true;
#endif
}
void AIStateMachine::idle(state_type current_run_state)
{
DoutEntering(dc::statemachine, "AIStateMachine::idle(" << state_str(current_run_state) << ") [" << (void*)this << "]");
llassert(is_main_thread());
llassert(!mIdle);
mSetStateLock.lock();
// Only go idle if the run state is (still) what we expect it to be.
// Otherwise assume that another thread called set_state() and continue running.
if (current_run_state == mRunState)
{
mIdle = true;
mSleep = 0;
}
mSetStateLock.unlock();
}
// About thread safeness:
//
// The main thread initializes a statemachine and calls run, so a statemachine
// runs in the main thread. However, it is allowed that a state calls idle()
// and then allows one or more other threads to call cont() upon some
// event (only once, of course, as idle() has to be called before cont()
// can be called again-- and a non-main thread is not allowed to call idle()).
// Instead of cont() one may also call set_state().
// Of course, this may give rise to a race condition; if that happens then
// the thread that calls cont() (set_state()) first is serviced, and the other
// thread(s) are ignored, as if they never called cont().
void AIStateMachine::locked_cont(void)
{
DoutEntering(dc::statemachine, "AIStateMachine::locked_cont() [" << (void*)this << "]");
llassert(mIdle);
// Atomic test mActive and change mIdle.
mIdleActive.lock();
#ifdef SHOW_ASSERT
mContThread.reset();
#endif
mIdle = false;
bool not_active = mActive == as_idle;
mIdleActive.unlock();
// mActive is only changed in AIStateMachine::mainloop, by the main-thread, and
// here, possibly by any thread. However, after setting mIdle to false above, it
// is impossible for any thread to come here, until after the main-thread called
// idle(). So, if this is the main thread then that certainly isn't going to
// happen until we left this function, while if this is another thread and the
// state machine is already running in the main thread then not_active is false
// and we're already at the end of this function.
// If not_active is true then main-thread is not running this statemachine.
// It might call cont() (or set_state()) but never locked_cont(), and will never
// start actually running until we are done here and release the lock on
// sContinuedStateMachinesAndMainloopEnabled again. It is therefore safe
// to release mSetStateLock here, with as advantage that if we're not the main-
// thread and not_active is true, then the main-thread won't block when it has
// a timer running that times out and calls set_state().
mSetStateLock.unlock();
if (not_active)
{
AIWriteAccess<csme_type> csme_w(sContinuedStateMachinesAndMainloopEnabled);
// See above: it is not possible that mActive was changed since not_active
// was set to true above.
llassert_always(mActive == as_idle);
Dout(dc::statemachine, "Adding " << (void*)this << " to continued_statemachines");
csme_w->continued_statemachines.push_back(this);
if (!csme_w->mainloop_enabled)
{
Dout(dc::statemachine, "Activating AIStateMachine::mainloop.");
csme_w->mainloop_enabled = true;
}
mActive = as_queued;
llassert_always(!mIdle); // It should never happen that the main thread calls idle(), while another thread calls cont() concurrently.
}
}
void AIStateMachine::set_state(state_type state)
{
DoutEntering(dc::statemachine, "AIStateMachine::set_state(" << state_str(state) << ") [" << (void*)this << "]");
// Stop race condition of multiple threads calling cont() or set_state() here.
mSetStateLock.lock();
// Do not call set_state() unless running.
llassert(mState == bs_run || !is_main_thread());
// If this function is called from another thread than the main thread, then we have to ignore
// it if we're not idle and the state is less than the current state. The main thread must
// be able to change the state to anything (also smaller values). Note that that only can work
// if the main thread itself at all times cancels thread callbacks that call set_state()
// before calling idle() again!
//
// Thus: main thead calls idle(), and tells one or more threads to do callbacks on events,
// which (might) call set_state(). If the main thread calls set_state first (currently only
// possible as a result of the use of a timer) it will set mIdle to false (here) then cancel
// the call backs from the other threads and only then call idle() again.
// Thus if you want other threads get here while mIdle is false to be ignored then the
// main thread should use a large value for the new run state.
//
// If a non-main thread calls set_state first, then the state is changed but the main thread
// can still override it if it calls set_state before handling the new state; in the latter
// case it would still be as if the call from the non-main thread was ignored.
//
// Concurrent calls from non-main threads however, always result in the largest state
// to prevail.
// If the state machine is already running, and we are not the main-thread and the new
// state is less than the current state, ignore it.
// Also, if abort() or finish() was called, then we should just ignore it.
if (mState != bs_run ||
(!mIdle && state <= mRunState && !AIThreadID::in_main_thread()))
{
#ifdef SHOW_ASSERT
// It's a bit weird if the same thread does two calls on a row where the second call
// has a smaller value: warn about that.
if (mState == bs_run && mContThread.equals_current_thread())
{
llwarns << "Ignoring call to set_state(" << state_str(state) <<
") by non-main thread before main-thread could react on previous call, "
"because new state is smaller than old state (" << state_str(mRunState) << ")." << llendl;
}
#endif
mSetStateLock.unlock();
return; // Ignore.
}
// Do not call idle() when set_state is called from another thread; use idle(state_type) instead.
llassert(!mCalledThreadUnsafeIdle || is_main_thread());
// Change mRunState to the requested value.
if (mRunState != state)
{
mRunState = state;
Dout(dc::statemachine, "mRunState set to " << state_str(mRunState));
}
// Continue the state machine if appropriate.
if (mIdle)
locked_cont(); // This unlocks mSetStateLock.
else
mSetStateLock.unlock();
// If we get here then mIdle is false, so only mRunState can still be changed but we won't
// call locked_cont() anymore. When the main thread finally picks up on the state change,
// it will cancel any possible callbacks from other threads and process the largest state
// that this function was called with in the meantime.
}
void AIStateMachine::abort(void)
{
DoutEntering(dc::statemachine, "AIStateMachine::abort() [" << (void*)this << "]");
// It's possible that abort() is called before calling AIStateMachine::multiplex.
// In that case the statemachine wasn't initialized yet and we should just kill() it.
if (LL_UNLIKELY(mState == bs_initialize))
{
// It's ok to use the thread-unsafe idle() here, because if the statemachine
// wasn't started yet, then other threads won't call set_state() on it.
if (!mIdle)
idle();
// run() calls locked_cont() after which the top of the mainloop adds this
// state machine to active_statemachines. Therefore, if the following fails
// then either the same statemachine called run() immediately followed by abort(),
// which is not allowed; or there were two active statemachines running,
// the first created a new statemachine and called run() on it, and then
// the other (before reaching the top of the mainloop) called abort() on
// that freshly created statemachine. Obviously, this is highly unlikely,
// but if that is the case then here we bump the statemachine into
// continued_statemachines to prevent kill() to delete this statemachine:
// the caller of abort() does not expect that.
if (LL_UNLIKELY(mActive == as_idle))
{
mSetStateLock.lock();
locked_cont();
idle();
}
kill();
}
else
{
llassert(mState == bs_run);
mSetStateLock.lock();
mState = bs_abort; // Causes additional calls to set_state to be ignored.
mSetStateLock.unlock();
abort_impl();
mAborted = true;
finish();
}
}
void AIStateMachine::finish(void)
{
DoutEntering(dc::statemachine, "AIStateMachine::finish() [" << (void*)this << "]");
mSetStateLock.lock();
llassert(mState == bs_run || mState == bs_abort);
// It is possible that mIdle is true when abort or finish was called from
// outside multiplex_impl. However, that only may be done by the main thread.
llassert(!mIdle || is_main_thread());
if (!mIdle)
idle(); // After calling this, we don't want other threads to call set_state() anymore.
mState = bs_finish; // Causes additional calls to set_state to be ignored.
mSetStateLock.unlock();
finish_impl();
// Did finish_impl call kill()? Then that is only the default. Remember it.
bool default_delete = (mState == bs_killed);
mState = bs_finish;
if (mParent)
{
// It is possible that the parent is not running when the parent is in fact aborting and called
// abort on this object from it's abort_impl function. It that case we don't want to recursively
// call abort again (or change it's state).
if (mParent->running())
{
if (mAborted && mAbortParent)
{
mParent->abort();
mParent = NULL;
}
else if (!mAborted || mOnAbortSignalParent)
{
mParent->set_state(mNewParentState);
}
}
}
// After this (bool)*this evaluates to true and we can call the callback, which then is allowed to call run().
mState = bs_callback;
if (mCallback)
{
// This can/may call kill() that sets mState to bs_kill and in which case the whole AIStateMachine
// will be deleted from the mainloop, or it may call run() that sets mState is set to bs_initialize
// and might change or reuse mCallback or mParent.
mCallback->callback(!mAborted);
if (mState != bs_initialize)
{
delete mCallback;
mCallback = NULL;
mParent = NULL;
}
}
else
{
// Not restarted by callback. Allow run() to be called later on.
mParent = NULL;
}
// Fix the final state.
if (mState == bs_callback)
mState = default_delete ? bs_killed : bs_initialize;
if (mState == bs_killed && mActive == as_idle)
{
// Bump the statemachine onto the active statemachine list, or else it won't be deleted.
mSetStateLock.lock();
locked_cont();
idle();
}
}
void AIStateMachine::kill(void)
{
DoutEntering(dc::statemachine, "AIStateMachine::kill() [" << (void*)this << "]");
// Should only be called from finish() (or when not running (bs_initialize)).
// However, also allow multiple calls to kill() on a row (bs_killed) (which effectively don't do anything).
llassert(mIdle && (mState == bs_callback || mState == bs_finish || mState == bs_initialize || mState == bs_killed));
base_state_type prev_state = mState;
mState = bs_killed;
if (prev_state == bs_initialize && mActive == as_idle)
{
// We're not running (ie being deleted by a parent statemachine), delete it immediately.
delete this;
}
}
// Return stringified 'state'.
char const* AIStateMachine::state_str(state_type state)
{
if (state >= min_state && state < max_state)
{
switch (state)
{
AI_CASE_RETURN(bs_initialize);
AI_CASE_RETURN(bs_run);
AI_CASE_RETURN(bs_abort);
AI_CASE_RETURN(bs_finish);
AI_CASE_RETURN(bs_callback);
AI_CASE_RETURN(bs_killed);
}
}
return state_str_impl(state);
}
//----------------------------------------------------------------------------
//
// Private methods
//
void AIStateMachine::multiplex(U64 current_time)
{
// Return immediately when this state machine is sleeping.
// A negative value of mSleep means we're counting frames,
// a positive value means we're waiting till a certain
// amount of time has passed.
if (mSleep != 0)
{
if (mSleep < 0)
{
if (++mSleep)
return;
}
else
{
if (current_time < (U64)mSleep)
return;
mSleep = 0;
}
}
DoutEntering(dc::statemachine, "AIStateMachine::multiplex() [" << (void*)this << "] [with state: " << state_str(mState == bs_run ? mRunState : mState) << "]");
llassert(mState == bs_initialize || mState == bs_run);
// Real state machine starts here.
if (mState == bs_initialize)
{
mAborted = false;
mState = bs_run;
initialize_impl();
if (mAborted || mState != bs_run)
return;
}
multiplex_impl();
}
//static
void AIStateMachine::add_continued_statemachines(AIReadAccess<csme_type>& csme_r)
{
bool nonempty = false;
for (continued_statemachines_type::const_iterator iter = csme_r->continued_statemachines.begin(); iter != csme_r->continued_statemachines.end(); ++iter)
{
nonempty = true;
active_statemachines.push_back(QueueElement(*iter));
Dout(dc::statemachine, "Adding " << (void*)*iter << " to active_statemachines");
(*iter)->mActive = as_active;
}
if (nonempty)
AIWriteAccess<csme_type>(csme_r)->continued_statemachines.clear();
}
// static
void AIStateMachine::dowork(void)
{
llassert(!active_statemachines.empty());
// Run one or more state machines.
U64 total_clocks = 0;
for (active_statemachines_type::iterator iter = active_statemachines.begin(); iter != active_statemachines.end(); ++iter)
{
AIStateMachine& statemachine(iter->statemachine());
if (!statemachine.mIdle)
{
U64 start = get_clock_count();
// This might call idle() and then pass the statemachine to another thread who then may call cont().
// Hence, after this isn't not sure what mIdle is, and it can change from true to false at any moment,
// if it is true after this function returns.
statemachine.multiplex(start);
U64 delta = get_clock_count() - start;
iter->add(delta);
total_clocks += delta;
if (total_clocks >= sMaxCount)
{
#ifndef LL_RELEASE_FOR_DOWNLOAD
llwarns << "AIStateMachine::mainloop did run for " << (total_clocks * 1000 / calc_clock_frequency()) << " ms." << llendl;
#endif
std::sort(active_statemachines.begin(), active_statemachines.end(), QueueElementComp());
break;
}
}
}
// Remove idle state machines from the loop.
active_statemachines_type::iterator iter = active_statemachines.begin();
while (iter != active_statemachines.end())
{
AIStateMachine& statemachine(iter->statemachine());
// Atomic test mIdle and change mActive.
bool locked = statemachine.mIdleActive.tryLock();
// If the lock failed, then another thread is in the middle of calling cont(),
// thus mIdle will end up false. So, there is no reason to block here; just
// treat mIdle as false already.
if (locked && statemachine.mIdle)
{
// Without the lock, it would be possible that another thread called cont() right here,
// changing mIdle to false again but NOT adding the statemachine to continued_statemachines,
// thinking it is in active_statemachines (and it is), while immediately below it is
// erased from active_statemachines.
statemachine.mActive = as_idle;
// Now, calling cont() is ok -- as that will cause the statemachine to be added to
// continued_statemachines, so it's fine in that case-- even necessary-- to remove it from
// active_statemachines regardless, and we can release the lock here.
statemachine.mIdleActive.unlock();
Dout(dc::statemachine, "Erasing " << (void*)&statemachine << " from active_statemachines");
iter = active_statemachines.erase(iter);
if (statemachine.mState == bs_killed)
{
Dout(dc::statemachine, "Deleting " << (void*)&statemachine);
delete &statemachine;
}
}
else
{
if (locked)
{
statemachine.mIdleActive.unlock();
}
llassert(statemachine.mActive == as_active); // It should not be possible that another thread called cont() and changed this when we are we are not idle.
llassert(statemachine.mState == bs_run || statemachine.mState == bs_initialize);
++iter;
}
}
if (active_statemachines.empty())
{
// If this was the last state machine, remove mainloop from the IdleCallbacks.
AIReadAccess<csme_type> csme_r(sContinuedStateMachinesAndMainloopEnabled, true);
if (csme_r->continued_statemachines.empty() && csme_r->mainloop_enabled)
{
Dout(dc::statemachine, "Deactivating AIStateMachine::mainloop: no active state machines left.");
AIWriteAccess<csme_type>(csme_r)->mainloop_enabled = false;
}
}
}
// static
void AIStateMachine::flush(void)
{
DoutEntering(dc::curl, "AIStateMachine::flush(void)");
{
AIReadAccess<csme_type> csme_r(sContinuedStateMachinesAndMainloopEnabled);
add_continued_statemachines(csme_r);
}
// Abort all state machines.
for (active_statemachines_type::iterator iter = active_statemachines.begin(); iter != active_statemachines.end(); ++iter)
{
AIStateMachine& statemachine(iter->statemachine());
if (statemachine.abortable())
{
// We can't safely call abort() here for non-running (run() was called, but they weren't initialized yet) statemachines,
// because that might call kill() which in some cases is undesirable (ie, when it is owned by a partent that will
// also call abort() on it when it is aborted itself).
if (statemachine.running())
statemachine.abort();
else
statemachine.idle(); // Stop the statemachine from starting, in the next loop with batch == 0.
}
}
for (int batch = 0;; ++batch)
{
// Run mainloop until all state machines are idle (batch == 0) or deleted (batch == 1).
for(;;)
{
{
AIReadAccess<csme_type> csme_r(sContinuedStateMachinesAndMainloopEnabled);
if (!csme_r->mainloop_enabled)
break;
}
mainloop();
}
if (batch == 1)
break;
{
AIReadAccess<csme_type> csme_r(sContinuedStateMachinesAndMainloopEnabled);
add_continued_statemachines(csme_r);
}
}
// At this point all statemachines should be idle.
AIReadAccess<csme_type> csme_r(sContinuedStateMachinesAndMainloopEnabled);
llinfos << "Current number of continued statemachines: " << csme_r->continued_statemachines.size() << llendl;
llinfos << "Current number of active statemachines: " << active_statemachines.size() << llendl;
llassert(csme_r->continued_statemachines.empty() && active_statemachines.empty());
}

View File

@@ -192,6 +192,15 @@ class AIStateMachine {
as_active // State machine is on active_statemachines list.
};
//! Type of continued_statemachines.
typedef std::vector<AIStateMachine*> continued_statemachines_type;
//! Type of sContinuedStateMachinesAndMainloopEnabled.
struct csme_type
{
continued_statemachines_type continued_statemachines;
bool mainloop_enabled;
};
public:
typedef U32 state_type; //!< The type of mRunState
@@ -207,12 +216,17 @@ class AIStateMachine {
active_type mActive; //!< Whether statemachine is idle, queued to be added to the active list, or already on the active list.
S64 mSleep; //!< Non-zero while the state machine is sleeping.
LLMutex mIdleActive; //!< Used for atomic operations on the pair mIdle / mActive.
#ifdef SHOW_ASSERT
AIThreadID mContThread; //!< Thread that last called locked_cont().
bool mCalledThreadUnsafeIdle; //!< Set to true when idle() is called.
#endif
// Callback facilities.
// From within an other state machine:
AIStateMachine* mParent; //!< The parent object that started this state machine, or NULL if there isn't any.
state_type mNewParentState; //!< The state at which the parent should continue upon a successful finish.
bool mAbortParent; //!< If true, abort parent on abort(). Otherwise continue as normal.
bool mOnAbortSignalParent; //!< If true and mAbortParent is false, change state of parent even on abort.
// From outside a state machine:
struct callback_type {
typedef boost::signals2::signal<void (bool)> signal_type;
@@ -225,24 +239,34 @@ class AIStateMachine {
};
callback_type* mCallback; //!< Pointer to signal/connection, or NULL when not connected.
static AIThreadSafeSimpleDC<U64> sMaxCount; //!< Number of cpu clocks below which we start a new state machine within the same frame.
static U64 sMaxCount; //!< Number of cpu clocks below which we start a new state machine within the same frame.
static AIThreadSafeDC<csme_type> sContinuedStateMachinesAndMainloopEnabled; //!< Read/write locked variable pair.
protected:
LLMutex mSetStateLock; //!< For critical areas in set_state() and locked_cont().
//! State of the derived class. Only valid if mState == bs_run. Call set_state to change.
state_type mRunState;
volatile state_type mRunState;
public:
//! Create a non-running state machine.
AIStateMachine(void) : mState(bs_initialize), mIdle(true), mAborted(true), mActive(as_idle), mSleep(0), mParent(NULL), mCallback(NULL) { updateSettings(); }
AIStateMachine(void) : mState(bs_initialize), mIdle(true), mAborted(true), mActive(as_idle), mSleep(0), mParent(NULL), mCallback(NULL)
#ifdef SHOW_ASSERT
, mContThread(AIThreadID::none), mCalledThreadUnsafeIdle(false)
#endif
{ }
protected:
//! The user should call 'kill()', not delete a AIStateMachine (derived) directly.
virtual ~AIStateMachine() { llassert(mState == bs_killed && mActive == as_idle); }
virtual ~AIStateMachine() { llassert((mState == bs_killed && mActive == as_idle) || mState == bs_initialize); }
public:
//! Halt the state machine until cont() is called.
//! Halt the state machine until cont() is called (not thread-safe).
void idle(void);
//! Halt the state machine until cont() is called, provided it is still in 'cur_run_state'.
void idle(state_type current_run_state);
//! Temporarily halt the state machine.
void yield_frame(unsigned int frames) { mSleep = -(S64)frames; }
@@ -250,15 +274,25 @@ class AIStateMachine {
void yield_ms(unsigned int ms) { mSleep = get_clock_count() + calc_clock_frequency() * ms / 1000; }
//! Continue running after calling idle.
void cont(void);
void cont(void)
{
mSetStateLock.lock();
// Ignore calls to cont() if the statemachine isn't idle. See comments in set_state().
// Calling cont() twice or after calling set_state(), without first calling idle(), is an error.
if (mState != bs_run || !mIdle) { llassert(mState != bs_run || !mContThread.equals_current_thread()); mSetStateLock.unlock(); return; }
locked_cont();
}
private:
void locked_cont(void);
public:
//---------------------------------------
// Changing the state.
//! Change state to <code>bs_run</code>. May only be called after creation or after returning from finish().
// If <code>parent</code> is non-NULL, change the parent state machine's state to <code>new_parent_state</code>
// upon finish, or in the case of an abort and when <code>abort_parent</code> is true, call parent->abort() instead.
void run(AIStateMachine* parent, state_type new_parent_state, bool abort_parent = true);
void run(AIStateMachine* parent, state_type new_parent_state, bool abort_parent = true, bool on_abort_signal_parent = true);
//! Change state to 'bs_run'. May only be called after creation or after returning from finish().
// Does not cause a callback.
@@ -315,7 +349,7 @@ class AIStateMachine {
// Other.
//! Called whenever the StateMachineMaxTime setting is changed.
static void updateSettings(void);
static void setMaxCount(F32 StateMachineMaxTime);
//---------------------------------------
// Accessors.
@@ -326,11 +360,14 @@ class AIStateMachine {
//! Return true if the derived class is running (also when we are idle).
bool running(void) const { return mState == bs_run; }
//! Return true if it's safe to call abort.
bool abortable(void) const { return mState == bs_run || mState == bs_initialize; }
//! Return true if the derived class is running but idle.
bool waiting(void) const { return mState == bs_run && mIdle; }
// Use some safebool idiom (http://www.artima.com/cppsource/safebool.html) rather than operator bool.
typedef state_type AIStateMachine::* const bool_type;
typedef volatile state_type AIStateMachine::* const bool_type;
//! Return true if state machine successfully finished.
operator bool_type() const { return ((mState == bs_initialize || mState == bs_callback) && !mAborted) ? &AIStateMachine::mRunState : 0; }
@@ -338,9 +375,27 @@ class AIStateMachine {
char const* state_str(state_type state);
private:
static void mainloop(void*);
static void add_continued_statemachines(AIReadAccess<csme_type>& csme_r);
static void dowork(void);
void multiplex(U64 current_time);
public:
//! Call this once per frame to give the statemachines CPU cycles.
static void mainloop(void)
{
{
AIReadAccess<csme_type> csme_r(sContinuedStateMachinesAndMainloopEnabled, true);
if (!csme_r->mainloop_enabled)
return;
if (!csme_r->continued_statemachines.empty())
add_continued_statemachines(csme_r);
}
dowork();
}
//! Abort all running state machines and then run mainloop until all state machines are idle (called when application is exiting).
static void flush(void);
protected:
//---------------------------------------
// Derived class implementations.

View File

@@ -70,7 +70,6 @@ class AITimer : public AIStateMachine {
* @brief Set the interval after which the timer should expire.
*
* @param interval Amount of time in seconds before the timer will expire.
* @param True if the timer should be deleted after it expires; false means it will keep firing at regular intervals.
*
* Call abort() at any time to stop the timer (and delete the AITimer object).
*/

View File

@@ -29,7 +29,7 @@ if (WINDOWS)
# Don't build DLLs.
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /Zi /MDd /arch:SSE2"
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /Zi /MDd /MP /arch:SSE2"
CACHE STRING "C++ compiler debug options" FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od /Zi /MD /MP /arch:SSE2"

View File

@@ -1,4 +1,4 @@
# -*- cmake -*-
set(AISTATEMACHINE_INCLUDE_DIRS statemachine)
set(AISTATEMACHINE_LIBRARIES statemachine)
set(AISTATEMACHINE_INCLUDE_DIRS ${LIBS_OPEN_DIR}/aistatemachine)
set(AISTATEMACHINE_LIBRARIES aistatemachine)

View File

@@ -54,13 +54,14 @@ set(cmake_SOURCE_FILES
LLMessage.cmake
LLPlugin.cmake
LLPrimitive.cmake
LLQtWebkit.cmake
LLRender.cmake
LLScene.cmake
LLUI.cmake
LLVFS.cmake
LLWindow.cmake
LLXML.cmake
LScript.cmake
# LScript.cmake
Linking.cmake
NDOF.cmake
OPENAL.cmake
@@ -70,6 +71,7 @@ set(cmake_SOURCE_FILES
PNG.cmake
Python.cmake
Prebuilt.cmake
Qt4.cmake
RunBuildTest.cmake
TemplateCheck.cmake
Tut.cmake

View File

@@ -1,7 +1,7 @@
# -*- cmake -*-
include(Prebuilt)
set(CURL_FIND_QUIETLY ON)
set(CURL_FIND_QUIETLY OFF)
set(CURL_FIND_REQUIRED ON)
if (STANDALONE)

View File

@@ -1 +1,18 @@
set(CWDEBUG_LIBRARIES cwdebug)
include_directories (${CMAKE_SOURCE_DIR}/cwdebug)
set(cwdebug_SOURCE_FILES
${CMAKE_SOURCE_DIR}/cwdebug/debug.cc
)
set(cwdebug_HEADER_FILES
${CMAKE_SOURCE_DIR}/cwdebug/cwdebug.h
${CMAKE_SOURCE_DIR}/cwdebug/sys.h
${CMAKE_SOURCE_DIR}/cwdebug/debug.h
${CMAKE_SOURCE_DIR}/cwdebug/debug_ostream_operators.h
)
set_source_files_properties(${cwdebug_HEADER_FILES}
PROPERTIES HEADER_FILE_ONLY TRUE)
list(APPEND cwdebug_SOURCE_FILES ${cwdebug_HEADER_FILES})

View File

@@ -2,54 +2,52 @@
include(Linking)
if(INSTALL_PROPRIETARY)
include(Prebuilt)
use_prebuilt_binary(fmodex)
endif(INSTALL_PROPRIETARY)
find_library(FMODEX_LIBRARY
NAMES fmodex fmodexL fmodex_vc fmodexL_vc
PATHS
optimized ${ARCH_PREBUILT_DIRS_RELEASE}
debug ${ARCH_PREBUILT_DIRS_DEBUG}
)
if (NOT FMODEX_LIBRARY)
set(FMODEX_SDK_DIR CACHE PATH "Path to the FMOD Ex SDK.")
if (FMODEX_SDK_DIR)
find_library(FMODEX_LIBRARY
fmodex_vc fmodexL_vc fmodex fmodexL fmodex64 fmodexL64
PATHS
${FMODEX_SDK_DIR}/api/lib
${FMODEX_SDK_DIR}/api
${FMODEX_SDK_DIR}/lib
${FMODEX_SDK_DIR}
)
if(WORD_SIZE EQUAL 32)
find_library(FMODEX_LIBRARY
fmodex_vc fmodexL_vc fmodex fmodexL
PATHS
"${FMODEX_SDK_DIR}/api/lib"
"${FMODEX_SDK_DIR}/api"
"${FMODEX_SDK_DIR}/lib"
"${FMODEX_SDK_DIR}"
)
elseif(WORD_SIZE EQUAL 64)
find_library(FMODEX_LIBRARY
fmodex64 fmodexL64
PATHS
"${FMODEX_SDK_DIR}/api/lib"
"${FMODEX_SDK_DIR}/api"
"${FMODEX_SDK_DIR}/lib"
"${FMODEX_SDK_DIR}"
)
endif(WORD_SIZE EQUAL 32)
endif(FMODEX_SDK_DIR)
if(WINDOWS AND NOT FMODEX_LIBRARY)
set(FMODEX_PROG_DIR "$ENV{PROGRAMFILES}/FMOD SoundSystem/FMOD Programmers API Windows")
find_library(FMODEX_LIBRARY
fmodex_vc fmodexL_vc
PATHS
${FMODEX_PROG_DIR}/api/lib
${FMODEX_PROG_DIR}/api
${FMODEX_PROG_DIR}
"${FMODEX_PROG_DIR}/api/lib"
"${FMODEX_PROG_DIR}/api"
"${FMODEX_PROG_DIR}"
)
if(FMODEX_LIBRARY)
message(STATUS "Found fmodex in ${FMODEX_PROG_DIR}")
set(FMODEX_SDK_DIR ${FMODEX_PROG_DIR})
set(FMODEX_SDK_DIR ${FMODEX_PROG_DIR} CACHE PATH "Path to the FMOD Ex SDK." FORCE)
set(FMODEX_SDK_DIR "${FMODEX_PROG_DIR}")
set(FMODEX_SDK_DIR "${FMODEX_PROG_DIR}" CACHE PATH "Path to the FMOD Ex SDK." FORCE)
endif(FMODEX_LIBRARY)
endif(WINDOWS AND NOT FMODEX_LIBRARY)
endif (NOT FMODEX_LIBRARY)
find_path(FMODEX_INCLUDE_DIR fmod.hpp
${LIBS_PREBUILT_DIR}/include/fmodex
${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/fmodex
${FMODEX_SDK_DIR}/api/inc
${FMODEX_SDK_DIR}/inc
${FMODEX_SDK_DIR}
"${LIBS_PREBUILT_DIR}/include/fmodex"
"${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/fmodex"
"${FMODEX_SDK_DIR}/api/inc"
"${FMODEX_SDK_DIR}/inc"
"${FMODEX_SDK_DIR}"
)
if(DARWIN)

View File

@@ -3,16 +3,18 @@
# - Find JSONCpp
# Find the JSONCpp includes and library
# This module defines
# JSONCPP_INCLUDE_DIR, where to find json.h, etc.
# JSONCPP_LIBRARIES, the libraries needed to use jsoncpp.
# JSONCPP_FOUND, If false, do not try to use jsoncpp.
# also defined, but not for general use are
# JSONCPP_LIBRARY, where to find the jsoncpp library.
# JSONCPP_FOUND, System has libjsoncpp.
# JSONCPP_INCLUDE_DIRS - The libjsoncpp include directories.
# JSONCPP_LIBRARIES - The libraries needed to use libjsoncpp.
# JSONCPP_DEFINITIONS - Compiler switches required for using libjsoncpp.
FIND_PATH(JSONCPP_INCLUDE_DIR json/json.h
/usr/local/include
/usr/include
)
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_JSONCPP jsoncpp)
SET(JSONCPP_DEFINITIONS ${PC_JSONCPP_CFLAGS_OTHER})
FIND_PATH(JSONCPP_INCLUDE_DIR json/reader.h
HINTS ${PC_JSONCPP_INCLUDE_DIR} ${PC_JSONCPP_INCLUDE_DIRS}
PATH_SUFFIXES jsoncpp)
# Get the GCC compiler version
EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
@@ -22,39 +24,16 @@ EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
)
# Try to find a library that was compiled with the same compiler version as we currently use.
SET(JSONCPP_NAMES ${JSONCPP_NAMES} libjson_linux-gcc-${_gcc_COMPILER_VERSION}_libmt.so)
IF (STANDALONE)
# On standalone, assume that the system installed library was compiled with the used compiler.
SET(JSONCPP_NAMES ${JSONCPP_NAMES} libjson.so)
ENDIF (STANDALONE)
FIND_LIBRARY(JSONCPP_LIBRARY
NAMES ${JSONCPP_NAMES}
PATHS /usr/lib /usr/local/lib
)
NAMES libjson_linux-gcc-${_gcc_COMPILER_VERSION}_libmt.so libjsoncpp.so
HINTS ${PC_JSONCPP_LIBDIR} ${PC_JSONCPP_LIBRARY_DIRS}
PATHS /usr/lib /usr/local/lib)
IF (JSONCPP_LIBRARY AND JSONCPP_INCLUDE_DIR)
SET(JSONCPP_LIBRARIES ${JSONCPP_LIBRARY})
SET(JSONCPP_FOUND "YES")
ELSE (JSONCPP_LIBRARY AND JSONCPP_INCLUDE_DIR)
SET(JSONCPP_FOUND "NO")
ENDIF (JSONCPP_LIBRARY AND JSONCPP_INCLUDE_DIR)
SET(JSONCPP_LIBRARIES ${JSONCPP_LIBRARY})
SET(JSONCPP_INCLUDE_DIRS ${JSONCPP_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(JSONCPP DEFAULT_MSG
JSONCPP_LIBRARY JSONCPP_INCLUDE_DIR)
IF (JSONCPP_FOUND)
IF (NOT JSONCPP_FIND_QUIETLY)
MESSAGE(STATUS "Found JSONCpp: ${JSONCPP_LIBRARIES}")
ENDIF (NOT JSONCPP_FIND_QUIETLY)
ELSE (JSONCPP_FOUND)
IF (JSONCPP_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find JSONCpp library")
ENDIF (JSONCPP_FIND_REQUIRED)
ENDIF (JSONCPP_FOUND)
# Deprecated declarations.
SET (NATIVE_JSONCPP_INCLUDE_PATH ${JSONCPP_INCLUDE_DIR} )
GET_FILENAME_COMPONENT (NATIVE_JSONCPP_LIB_PATH ${JSONCPP_LIBRARY} PATH)
MARK_AS_ADVANCED(
JSONCPP_LIBRARY
JSONCPP_INCLUDE_DIR
)
MARK_AS_ADVANCED(JSONCPP_LIBRARY JSONCPP_INCLUDE_DIR)

View File

@@ -11,10 +11,10 @@ else (STANDALONE)
if (LINUX OR WINDOWS AND NOT WORD_SIZE EQUAL 64)
use_prebuilt_binary(gperftools)
endif (LINUX OR WINDOWS AND NOT WORD_SIZE EQUAL 64)
if (WINDOWS)
if (WINDOWS AND NOT DISABLE_TCMALLOC)
set(TCMALLOC_LIBRARIES libtcmalloc_minimal.lib)
set(TCMALLOC_LINKER_FLAGS "/INCLUDE:\"__tcmalloc\"")
endif (WINDOWS)
endif (WINDOWS AND NOT DISABLE_TCMALLOC)
if (LINUX)
if(USE_GOOGLE_PERFTOOLS)
set(TCMALLOC_LIBRARIES tcmalloc)

View File

@@ -2,7 +2,7 @@
include(Prebuilt)
set(JSONCPP_FIND_QUIETLY ON)
set(JSONCPP_FIND_QUIETLY OFF)
set(JSONCPP_FIND_REQUIRED ON)
if (STANDALONE)

View File

@@ -4,12 +4,14 @@ include(CARes)
include(CURL)
include(OpenSSL)
include(XmlRpcEpi)
include(AIStateMachine)
set(LLMESSAGE_INCLUDE_DIRS
${LIBS_OPEN_DIR}/llmessage
${CARES_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIRS}
${AISTATEMACHINE_INCLUDE_DIRS}
)
set(LLMESSAGE_LIBRARIES llmessage)
set(LLMESSAGE_LIBRARIES llmessage aistatemachine)

View File

@@ -0,0 +1,11 @@
# -*- cmake -*-
if (STANDALONE)
set(LLQTWEBKIT_INCLUDE_DIR
${LIBS_OPEN_DIR}/llqtwebkit
)
set(LLQTWEBKIT_LIBRARY
llqtwebkit
)
endif (STANDALONE)

View File

@@ -4,9 +4,9 @@ include(Prebuilt)
set(OpenSSL_FIND_QUIETLY ON)
set(OpenSSL_FIND_REQUIRED ON)
if (STANDALONE)
if (STANDALONE OR USE_SYSTEM_OPENSSL)
include(FindOpenSSL)
else (STANDALONE)
else (STANDALONE OR USE_SYSTEM_OPENSSL)
use_prebuilt_binary(openSSL)
if (WINDOWS)
set(OPENSSL_LIBRARIES ssleay32 libeay32)
@@ -14,7 +14,7 @@ else (STANDALONE)
set(OPENSSL_LIBRARIES ssl)
endif (WINDOWS)
set(OPENSSL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
endif (STANDALONE)
endif (STANDALONE OR USE_SYSTEM_OPENSSL)
if (LINUX OR DARWIN)
set(CRYPTO_LIBRARIES crypto)

12
indra/cmake/Qt4.cmake Normal file
View File

@@ -0,0 +1,12 @@
# -*- cmake -*-
include(Prebuilt)
if (STANDALONE)
set(Qt4_FIND_REQUIRED ON)
include(FindQt4)
find_package(Qt4 4.7.0 COMPONENTS QtCore QtGui QtNetwork QtOpenGL QtWebKit REQUIRED)
include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
endif (STANDALONE)

View File

@@ -0,0 +1,4 @@
# -*- cmake -*-
set(STATEMACHINE_INCLUDE_DIRS statemachine)
set(STATEMACHINE_LIBRARIES statemachine)

View File

@@ -30,6 +30,7 @@ set(LIBS_SERVER_DIR ${CMAKE_SOURCE_DIR}/${LIBS_SERVER_PREFIX})
set(SCRIPTS_DIR ${CMAKE_SOURCE_DIR}/${SCRIPTS_PREFIX})
set(SERVER_DIR ${CMAKE_SOURCE_DIR}/${SERVER_PREFIX})
set(VIEWER_DIR ${CMAKE_SOURCE_DIR}/${VIEWER_PREFIX})
set(DISABLE_TCMALLOC OFF CACHE BOOL "Disable linkage of TCMalloc. (64bit builds automatically disable TCMalloc)")
set(LL_TESTS OFF CACHE BOOL "Build and run unit and integration tests (disable for build timing runs to reduce variation)")
set(VISTA_ICON OFF CACHE BOOL "Allow vista icon with pre 2008 Visual Studio IDEs. (Assumes replacement old rcdll.dll with new rcdll.dll from win sdk 7.0 or later)")

View File

@@ -19,8 +19,3 @@ else (NOT STANDALONE)
endif(LINUX AND ${ARCH} STREQUAL "x86_64")
set(STANDALONE ON)
endif(NOT STANDALONE)
if (WINDOWS)
use_prebuilt_binary(dbghelp)
endif (WINDOWS)

View File

@@ -1,31 +1,10 @@
# -*- cmake -*-
include(Linking)
include(Prebuilt)
include(LLQtWebkit)
include(Qt4)
if (STANDALONE)
# The minimal version, 4.4.3, is rather arbitrary: it's the version in Debian/Lenny.
find_package(Qt4 4.4.3 COMPONENTS QtCore QtGui QtNetwork QtOpenGL QtWebKit REQUIRED)
include(${QT_USE_FILE})
set(QTDIR $ENV{QTDIR})
if (QTDIR AND NOT "${QT_BINARY_DIR}" STREQUAL "${QTDIR}/bin")
message(FATAL_ERROR "\"${QT_BINARY_DIR}\" is unequal \"${QTDIR}/bin\"; "
"Qt is found by looking for qmake in your PATH. "
"Please set your PATH such that 'qmake' is found in \$QTDIR/bin, "
"or unset QTDIR if the found Qt is correct.")
endif (QTDIR AND NOT "${QT_BINARY_DIR}" STREQUAL "${QTDIR}/bin")
find_package(LLQtWebkit REQUIRED QUIET)
# Add the plugins.
set(QT_PLUGIN_LIBRARIES)
foreach(qlibname qgif qjpeg)
find_library(QT_PLUGIN_${qlibname} ${qlibname} PATHS ${QT_PLUGINS_DIR}/imageformats NO_DEFAULT_PATH)
if (QT_PLUGIN_${qlibname})
list(APPEND QT_PLUGIN_LIBRARIES ${QT_PLUGIN_${qlibname}})
else (QT_PLUGIN_${qtlibname})
message(FATAL_ERROR "Could not find the Qt plugin ${qlibname} in \"${QT_PLUGINS_DIR}/imageformats\"!")
endif (QT_PLUGIN_${qlibname})
endforeach(qlibname)
# qjpeg depends on libjpeg
list(APPEND QT_PLUGIN_LIBRARIES jpeg)
set(WEBKITLIBPLUGIN OFF CACHE BOOL
"WEBKITLIBPLUGIN support for the llplugin/llmedia test apps.")
else (STANDALONE)

View File

@@ -1,39 +0,0 @@
# -*- cmake -*-
project(cwdebug)
include(00-Common)
include(LLCommon)
include(LLMath)
include(LLMessage)
include(LLVFS)
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
set(cwdebug_SOURCE_FILES
debug.cc
)
set(cwdebug_HEADER_FILES
CMakeLists.txt
cwdebug.h
sys.h
debug.h
debug_ostream_operators.h
)
set_source_files_properties(${cwdebug_HEADER_FILES}
PROPERTIES HEADER_FILE_ONLY TRUE)
if(NOT WORD_SIZE EQUAL 32)
if(WINDOWS)
add_definitions(/FIXED:NO)
else(WINDOWS) # not windows therefore gcc LINUX and DARWIN
add_definitions(-fPIC)
endif(WINDOWS)
endif (NOT WORD_SIZE EQUAL 32)
list(APPEND cwdebug_SOURCE_FILES ${cwdebug_HEADER_FILES})
add_library (cwdebug ${cwdebug_SOURCE_FILES})

View File

@@ -49,6 +49,8 @@
namespace debug {
#if CWDEBUG_LOCATION
ll_thread_local size_t BackTrace::S_number;
void BackTrace::dump_backtrace(void) const
{
for (int frame = 0; frame < frames(); ++frame)
@@ -67,6 +69,67 @@ void BackTrace::dump_backtrace(void) const
Dout(dc::finish, mangled_function_name);
}
}
void BackTraces::store_trace(size_t trace)
{
mBackTraces.push_back(trace);
}
void BackTraces::remove_trace(size_t trace)
{
trace_container_type::iterator iter = mBackTraces.begin();
while (iter != mBackTraces.end())
{
if (*iter == trace)
{
*iter = mBackTraces.back();
mBackTraces.pop_back();
return;
}
++iter;
}
DoutFatal(dc::core, "Trace doesn't exist!");
}
void BackTraces::dump(void) const
{
Dout(dc::backtrace|continued_cf, "Dump for (BackTraces*)" << (void*)this << " (" << mBackTraces.size() << " backtraces): ");
for (trace_container_type::const_iterator iter = mBackTraces.begin(); iter != mBackTraces.end(); ++iter)
{
Dout(dc::continued|nonewline_cf, *iter << ' ');
}
Dout(dc::finish, "");
}
BackTraceTracker::BackTraceTracker(BackTraces* back_traces) : mBackTraces(back_traces)
{
BACKTRACE;
mTrace = BackTrace::S_number;
mBackTraces->store_trace(mTrace);
}
BackTraceTracker::~BackTraceTracker()
{
mBackTraces->remove_trace(mTrace);
}
BackTraceTracker::BackTraceTracker(BackTraceTracker const& orig) : mBackTraces(orig.mBackTraces)
{
BACKTRACE;
mTrace = BackTrace::S_number;
mBackTraces->store_trace(mTrace);
}
BackTraceTracker& BackTraceTracker::operator=(BackTraceTracker const& orig)
{
mBackTraces->remove_trace(mTrace);
mBackTraces = orig.mBackTraces;
BACKTRACE;
mTrace = BackTrace::S_number;
mBackTraces->store_trace(mTrace);
return *this;
}
#endif // CWDEBUG_LOCATION
#if CWDEBUG_ALLOC && CWDEBUG_LOCATION
@@ -173,6 +236,10 @@ void stop_recording_backtraces(void)
channel_ct backtrace DDCN("BACKTRACE"); //!< This debug channel is used for backtraces.
channel_ct statemachine DDCN("STATEMACHINE"); //!< This debug channel is used for output related to class AIStateMachine.
channel_ct caps DDCN("CAPS"); //!< This debug channel is used for output related to Capabilities.
channel_ct curl DDCN("CURL"); //!< This debug channel is used for output related to AICurl.
channel_ct curlio DDCN("CURLIO"); //!< This debug channel is used to print debug output of libcurl. This includes all HTTP network traffic.
channel_ct curltr DDCN("CURLTR"); //!< This debug channel is used to print libcurl API calls.
channel_ct snapshot DDCN("SNAPSHOT"); //!< This debug channel is used for output related to snapshots.
} // namespace dc
} // namespace DEBUGCHANNELS
@@ -411,4 +478,94 @@ void cwdebug_backtrace(int n)
}
#endif
#endif // CWDEBUG
#elif defined(DEBUG_CURLIO)
#include "debug.h"
#include "aithreadid.h"
namespace debug
{
namespace libcwd { libcwd_do_type const libcw_do; }
ll_thread_local int Indent::S_indentation;
Indent::Indent(int indent) : M_indent(indent)
{
S_indentation += M_indent;
}
Indent::~Indent()
{
S_indentation -= M_indent;
}
std::ostream& operator<<(std::ostream& os, Indent::print_nt)
{
if (Indent::S_indentation)
os << std::string(Indent::S_indentation, ' ');
return os;
}
#ifdef DEBUG_CURLIO
std::ostream& operator<<(std::ostream& os, print_thread_id_t)
{
if (!AIThreadID::in_main_thread_inline())
{
os << std::hex << (size_t)AIThreadID::getCurrentThread_inline() << std::dec << ' ';
}
return os;
}
#endif
std::ostream& operator<<(std::ostream& os, libcwd::buf2str const& b2s)
{
static char const c2s_tab[7] = { 'a', 'b', 't', 'n', 'v', 'f', 'r' };
size_t size = b2s.mSize;
for (char const* p1 = b2s.mBuf; size > 0; --size, ++p1)
{
char c =*p1;
if ((c > 31 && c != 92 && c != 127) || (unsigned char)c > 159)
os.put(c);
else
{
os.put('\\');
if (c > 6 && c < 14)
{
os.put(c2s_tab[c - 7]);
return os;
}
else if (c == 27)
{
os.put('e');
return os;
}
else if (c == '\\')
{
os.put('\\');
return os;
}
std::ostream::char_type old_fill = os.fill('0');
std::ios_base::fmtflags old_flgs = os.flags();
os.width(3);
os << std::oct << (int)((unsigned char)c);
os.setf(old_flgs);
os.fill(old_fill);
}
}
return os;
}
namespace dc
{
fake_channel const warning(1, "WARNING ");
fake_channel const curl(1, "CURL ");
fake_channel const curlio(1, "CURLIO ");
fake_channel const statemachine(1, "STATEMACHINE");
fake_channel const notice(1, "NOTICE ");
} // namespace dc
} // namespace debug
#endif

View File

@@ -27,6 +27,94 @@
#ifndef CWDEBUG
#ifdef DEBUG_CURLIO
// If CWDEBUG is not defined, but DEBUG_CURLIO is, then replace
// some of the cwd macro's with something that generates viewer
// specific debug output. Note that this generates a LOT of
// output and should not normally be defined.
#include <string>
#include "llpreprocessor.h"
namespace debug {
namespace libcwd {
struct buf2str {
buf2str(char const* buf, int size) : mBuf(buf), mSize(size) { }
char const* mBuf;
int mSize;
};
struct libcwd_do_type {
void on() const { }
};
extern LL_COMMON_API libcwd_do_type const libcw_do;
} // namespace libcwd
enum print_thread_id_t { print_thread_id };
inline void init() { }
struct Indent {
int M_indent;
static ll_thread_local int S_indentation;
enum LL_COMMON_API print_nt { print };
LL_COMMON_API Indent(int indent);
LL_COMMON_API ~Indent();
};
extern LL_COMMON_API std::ostream& operator<<(std::ostream& os, libcwd::buf2str const& b2s);
extern LL_COMMON_API std::ostream& operator<<(std::ostream& os, Indent::print_nt);
extern LL_COMMON_API std::ostream& operator<<(std::ostream& os, print_thread_id_t);
namespace dc {
struct fake_channel {
int mOn;
char const* mLabel;
fake_channel(int on, char const* label) : mOn(on), mLabel(label) { }
fake_channel(void) : mOn(0) { }
bool is_on() const { return !!mOn; }
bool is_off() const { return !mOn; }
void on() const { }
void off() const { }
};
extern LL_COMMON_API fake_channel const warning;
extern LL_COMMON_API fake_channel const curl;
extern LL_COMMON_API fake_channel const curlio;
extern LL_COMMON_API fake_channel const statemachine;
extern LL_COMMON_API fake_channel const notice;
} // namespace dc
} // namespace debug
#define LIBCWD_DEBUG_CHANNELS debug
#define LibcwDoutScopeBegin(a, b, c) do { using namespace debug; using namespace debug::libcwd; llinfos_nf << print_thread_id << (c).mLabel << ": " << Indent::print;
#define LibcwDoutStream llcont
#define LibcwDoutScopeEnd llcont << llendl; } while(0)
#define Debug(x) do { using namespace debug; using namespace debug::libcwd; x; } while(0)
#define Dout(a, b) do { using namespace debug; using namespace debug::libcwd; if ((a).mOn) { llinfos_nf << print_thread_id << (a).mLabel << ": " << Indent::print << b << llendl; } } while(0)
#define DoutEntering(a, b) \
int __slviewer_debug_indentation = 2; \
{ \
using namespace debug; \
using namespace debug::libcwd; \
if ((a).mOn) \
llinfos_nf << print_thread_id << (a).mLabel << ": " << Indent::print << "Entering " << b << llendl; \
else \
__slviewer_debug_indentation = 0; \
} \
debug::Indent __slviewer_debug_indent(__slviewer_debug_indentation);
#else // !DEBUG_CURLIO
#define Debug(x)
#define Dout(a, b)
#define DoutEntering(a, b)
#endif // !DEBUG_CURLIO
#ifndef DOXYGEN // No need to document this. See http://libcwd.sourceforge.net/ for more info.
#include <iostream>
@@ -36,9 +124,6 @@
#define AllocTag2(p, desc)
#define AllocTag_dynamic_description(p, x)
#define AllocTag(p, x)
#define Debug(x)
#define Dout(a, b)
#define DoutEntering(a, b)
#define DoutFatal(a, b) LibcwDoutFatal(::std, , a, b)
#define ForAllDebugChannels(STATEMENT)
#define ForAllDebugObjects(STATEMENT)
@@ -88,7 +173,9 @@
#include <boost/shared_array.hpp>
#if CWDEBUG_LOCATION
#include <execinfo.h> // Needed for 'backtrace'.
#include "llpreprocessor.h"
#endif
#include <set>
#define CWD_API __attribute__ ((visibility("default")))
@@ -118,6 +205,10 @@ extern CWD_API channel_ct sdl;
extern CWD_API channel_ct backtrace;
extern CWD_API channel_ct statemachine;
extern CWD_API channel_ct caps;
extern CWD_API channel_ct curl;
extern CWD_API channel_ct curlio;
extern CWD_API channel_ct curltr;
extern CWD_API channel_ct snapshot;
#endif
@@ -186,6 +277,8 @@ class BackTrace {
private:
boost::shared_array<void*> M_buffer;
int M_frames;
public:
static ll_thread_local size_t S_number;
public:
BackTrace(void** buffer, int frames) : M_buffer(new void* [frames]), M_frames(frames) { std::memcpy(M_buffer.get(), buffer, sizeof(void*) * frames); }
@@ -212,19 +305,81 @@ extern pthread_mutex_t backtrace_mutex;
using namespace debug; \
void* buffer[32]; \
int frames = backtrace(buffer, 32); \
size_t size; \
{ \
pthread_mutex_lock(&backtrace_mutex); \
backtraces.push_back(BackTrace(buffer, frames)); \
size = backtraces.size(); \
BackTrace::S_number = backtraces.size(); \
pthread_mutex_unlock(&backtrace_mutex); \
} \
Dout(dc::backtrace, "Stored backtrace #" << size); \
Dout(dc::backtrace, "Stored backtrace #" << BackTrace::S_number); \
} while(0)
class LL_COMMON_API BackTraces {
private:
typedef std::vector<size_t> trace_container_type;
trace_container_type mBackTraces;
public:
void store_trace(size_t trace);
void remove_trace(size_t trace);
void dump(void) const;
};
class LL_COMMON_API BackTraceTracker {
private:
BackTraces* mBackTraces;
size_t mTrace;
public:
BackTraceTracker(BackTraces* back_traces);
~BackTraceTracker();
BackTraceTracker(BackTraceTracker const&);
BackTraceTracker& operator=(BackTraceTracker const&);
void dump(void) const { mBackTraces->dump(); }
};
#else
#define BACKTRACE do { } while(0)
#endif // CWDEBUG_LOCATION
template<class T>
class LL_COMMON_API InstanceTracker {
private:
T const* mInstance;
static pthread_mutex_t sInstancesMutex;
static std::set<T const*> sInstances;
static void remember(T const* instance) { pthread_mutex_lock(&sInstancesMutex); sInstances.insert(instance); pthread_mutex_unlock(&sInstancesMutex); }
static void forget(T const* instance) { pthread_mutex_lock(&sInstancesMutex); sInstances.erase(instance); pthread_mutex_unlock(&sInstancesMutex); }
public:
InstanceTracker(T const* instance) : mInstance(instance) { remember(mInstance); }
~InstanceTracker() { forget(mInstance); }
InstanceTracker& operator=(InstanceTracker const& orig) { forget(mInstance); mInstance = orig.mInstance; remember(mInstance); return *this; }
static void dump(void);
private:
// Non-copyable. Instead of copying, call InstanceTracker(T const*) with the this pointer of the new instance.
InstanceTracker(InstanceTracker const& orig);
};
template<class T>
pthread_mutex_t InstanceTracker<T>::sInstancesMutex = PTHREAD_MUTEX_INITIALIZER;
template<class T>
std::set<T const*> InstanceTracker<T>::sInstances;
template<class T>
void InstanceTracker<T>::dump(void)
{
pthread_mutex_lock(&sInstancesMutex);
for (typename std::set<T const*>::iterator iter = sInstances.begin(); iter != sInstances.end(); ++iter)
{
std::cout << *iter << std::endl;
}
pthread_mutex_unlock(&sInstancesMutex);
}
} // namespace debug
//! Debugging macro.

View File

@@ -782,13 +782,14 @@ Commands:
Command-options for "configure":
We use cmake variables to change the build configuration.
-DSERVER:BOOL=OFF Don't configure simulator/dataserver/etc
-DVIEWER:BOOL=OFF Don't configure the viewer
-DPACKAGE:BOOL=ON Create "package" target to make installers
-DLOCALIZESETUP:BOOL=ON Create one win_setup target per supported language
-DLL_TESTS:BOOL=OFF Don't generate unit test projects
-DEXAMPLEPLUGIN:BOOL=OFF Don't generate example plugin project
-VISTA_ICON:BOOL=ON Allow pre-2008 VS to use vista-optimized resource file. (Requires updated rcdll.dll!)
-DSERVER:BOOL=OFF Don't configure simulator/dataserver/etc
-DVIEWER:BOOL=OFF Don't configure the viewer
-DPACKAGE:BOOL=ON Create "package" target to make installers
-DLOCALIZESETUP:BOOL=ON Create one win_setup target per supported language
-DLL_TESTS:BOOL=OFF Don't generate unit test projects
-DEXAMPLEPLUGIN:BOOL=OFF Don't generate example plugin project
-DDISABLE_TCMALLOC:BOOL=ON Disable linkage of TCMalloc. (64bit builds automatically disable TCMalloc)
-DVISTA_ICON:BOOL=ON Allow pre-2008 VS to use vista-optimized resource file. (Requires updated rcdll.dll!)
Examples:
Set up a viewer-only project for your system:

View File

@@ -7,14 +7,15 @@ include(00-Common)
# OPENJPEG version number, useful for packaging and doxygen doc:
set(OPENJPEG_VERSION_MAJOR 1)
set(OPENJPEG_VERSION_MINOR 4)
set(OPENJPEG_VERSION_BUILD 0)
set(OPENJPEG_VERSION_MINOR 5)
set(OPENJPEG_VERSION_BUILD 2)
set(OPENJPEG_VERSION
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
set(openjpeg_SOURCE_FILES
bio.c
cio.c
cidx_manager.c
dwt.c
event.c
image.c
@@ -26,20 +27,26 @@ set(openjpeg_SOURCE_FILES
mqc.c
openjpeg.c
pi.c
phix_manager.c
ppix_manager.c
raw.c
t1.c
t2.c
tcd.c
tgt.c
thix_manager.c
tpix_manager.c
)
set(openjpeg_HEADER_FILES
bio.h
cio.h
cidx_manager.h
dwt.h
event.h
event.h
fix.h
image.h
indexbox_manager.h
int.h
j2k.h
j2k_lib.h
@@ -48,6 +55,7 @@ set(openjpeg_HEADER_FILES
mct.h
mqc.h
openjpeg.h
opj_config.h
opj_includes.h
opj_malloc.h
pi.h

View File

@@ -0,0 +1,211 @@
/*
* $Id: cidx_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
*
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2011, Professor Benoit Macq
* Copyright (c) 2003-2004, Yannick Verschueren
* Copyright (c) 2010-2011, Kaori Hagihara
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "opj_includes.h"
/*
* Write CPTR Codestream finder box
*
* @param[in] coff offset of j2k codestream
* @param[in] clen length of j2k codestream
* @param[in] cio file output handle
*/
void write_cptr(int coff, int clen, opj_cio_t *cio);
/*
* Write main header index table (box)
*
* @param[in] coff offset of j2k codestream
* @param[in] cstr_info codestream information
* @param[in] cio file output handle
* @return length of mainmhix box
*/
int write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio);
/*
* Check if EPH option is used
*
* @param[in] coff offset of j2k codestream
* @param[in] markers marker information
* @param[in] marknum number of markers
* @param[in] cio file output handle
* @return true if EPH is used
*/
opj_bool check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_cio_t *cio);
int write_cidx( int offset, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t cstr_info, int j2klen)
{
int len, i, lenp;
opj_jp2_box_t *box;
int num_box = 0;
opj_bool EPHused;
(void)image; /* unused ? */
lenp = -1;
box = (opj_jp2_box_t *)opj_calloc( 32, sizeof(opj_jp2_box_t));
for (i=0;i<2;i++){
if(i)
cio_seek( cio, lenp);
lenp = cio_tell( cio);
cio_skip( cio, 4); /* L [at the end] */
cio_write( cio, JPIP_CIDX, 4); /* CIDX */
write_cptr( offset, cstr_info.codestream_size, cio);
write_manf( i, num_box, box, cio);
num_box = 0;
box[num_box].length = write_mainmhix( offset, cstr_info, cio);
box[num_box].type = JPIP_MHIX;
num_box++;
box[num_box].length = write_tpix( offset, cstr_info, j2klen, cio);
box[num_box].type = JPIP_TPIX;
num_box++;
box[num_box].length = write_thix( offset, cstr_info, cio);
box[num_box].type = JPIP_THIX;
num_box++;
EPHused = check_EPHuse( offset, cstr_info.marker, cstr_info.marknum, cio);
box[num_box].length = write_ppix( offset, cstr_info, EPHused, j2klen, cio);
box[num_box].type = JPIP_PPIX;
num_box++;
box[num_box].length = write_phix( offset, cstr_info, EPHused, j2klen, cio);
box[num_box].type = JPIP_PHIX;
num_box++;
len = cio_tell( cio)-lenp;
cio_seek( cio, lenp);
cio_write( cio, len, 4); /* L */
cio_seek( cio, lenp+len);
}
opj_free( box);
return len;
}
void write_cptr(int coff, int clen, opj_cio_t *cio)
{
int len, lenp;
lenp = cio_tell( cio);
cio_skip( cio, 4); /* L [at the end] */
cio_write( cio, JPIP_CPTR, 4); /* T */
cio_write( cio, 0, 2); /* DR A PRECISER !! */
cio_write( cio, 0, 2); /* CONT */
cio_write( cio, coff, 8); /* COFF A PRECISER !! */
cio_write( cio, clen, 8); /* CLEN */
len = cio_tell( cio) - lenp;
cio_seek( cio, lenp);
cio_write( cio, len, 4); /* L */
cio_seek( cio, lenp+len);
}
void write_manf(int second, int v, opj_jp2_box_t *box, opj_cio_t *cio)
{
int len, lenp, i;
lenp = cio_tell( cio);
cio_skip( cio, 4); /* L [at the end] */
cio_write( cio, JPIP_MANF,4); /* T */
if (second){ /* Write only during the second pass */
for( i=0; i<v; i++){
cio_write( cio, box[i].length, 4); /* Box length */
cio_write( cio, box[i].type, 4); /* Box type */
}
}
len = cio_tell( cio) - lenp;
cio_seek( cio, lenp);
cio_write( cio, len, 4); /* L */
cio_seek( cio, lenp+len);
}
int write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio)
{
int i;
int len, lenp;
lenp = cio_tell( cio);
cio_skip( cio, 4); /* L [at the end] */
cio_write( cio, JPIP_MHIX, 4); /* MHIX */
cio_write( cio, cstr_info.main_head_end-cstr_info.main_head_start+1, 8); /* TLEN */
for(i = 1; i < cstr_info.marknum; i++){ /* Marker restricted to 1 apparition, skip SOC marker */
cio_write( cio, cstr_info.marker[i].type, 2);
cio_write( cio, 0, 2);
cio_write( cio, cstr_info.marker[i].pos-coff, 8);
cio_write( cio, cstr_info.marker[i].len, 2);
}
len = cio_tell( cio) - lenp;
cio_seek( cio, lenp);
cio_write( cio, len, 4); /* L */
cio_seek( cio, lenp+len);
return len;
}
opj_bool check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_cio_t *cio)
{
opj_bool EPHused = OPJ_FALSE;
int i=0;
int org_pos;
unsigned int Scod;
for(i = 0; i < marknum; i++){
if( markers[i].type == J2K_MS_COD){
org_pos = cio_tell( cio);
cio_seek( cio, coff+markers[i].pos+2);
Scod = cio_read( cio, 1);
if( ((Scod >> 2) & 1))
EPHused = OPJ_TRUE;
cio_seek( cio, org_pos);
break;
}
}
return EPHused;
}

View File

@@ -0,0 +1,56 @@
/*
* $Id: cidx_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
*
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2011, Professor Benoit Macq
* Copyright (c) 2003-2004, Yannick Verschueren
* Copyright (c) 2010-2011, Kaori Hagihara
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*! \file
* \brief Modification of jpip.h from 2KAN indexer
*/
#ifndef CIDX_MANAGER_H_
# define CIDX_MANAGER_H_
#include "openjpeg.h"
/*
* Write Codestream index box (superbox)
*
* @param[in] offset offset of j2k codestream
* @param[in] cio file output handle
* @param[in] image image data
* @param[in] cstr_info codestream information
* @param[in] j2klen length of j2k codestream
* @return length of cidx box
*/
int write_cidx( int offset, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t cstr_info, int j2klen);
#endif /* !CIDX_MANAGER_H_ */

View File

@@ -126,13 +126,13 @@ unsigned char *cio_getbp(opj_cio_t *cio) {
/*
* Write a byte.
*/
bool cio_byteout(opj_cio_t *cio, unsigned char v) {
opj_bool cio_byteout(opj_cio_t *cio, unsigned char v) {
if (cio->bp >= cio->end) {
opj_event_msg(cio->cinfo, EVT_ERROR, "write error\n");
return false;
return OPJ_FALSE;
}
*cio->bp++ = v;
return true;
return OPJ_TRUE;
}
/*
@@ -152,7 +152,7 @@ unsigned char cio_bytein(opj_cio_t *cio) {
* v : value to write
* n : number of bytes to write
*/
unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n) {
unsigned int cio_write(opj_cio_t *cio, unsigned int64 v, int n) {
int i;
for (i = n - 1; i >= 0; i--) {
if( !cio_byteout(cio, (unsigned char) ((v >> (i << 3)) & 0xff)) )

View File

@@ -31,6 +31,13 @@
#ifndef __CIO_H
#define __CIO_H
#if defined(_MSC_VER) || defined(__BORLANDC__)
#define int64 __int64
#else
#define int64 long long
#endif
/**
@file cio.h
@brief Implementation of a byte input-output process (CIO)
@@ -63,7 +70,7 @@ Write some bytes
@param n Number of bytes to write
@return Returns the number of bytes written or 0 if an error occured
*/
unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n);
unsigned int cio_write(opj_cio_t *cio, unsigned int64 v, int n);
/**
Read some bytes
@param cio CIO handle

View File

@@ -64,12 +64,12 @@ typedef struct v4dwt_local {
int cas ;
} v4dwt_t ;
static const float dwt_alpha = 1.586134342f; // 12994
static const float dwt_beta = 0.052980118f; // 434
static const float dwt_gamma = -0.882911075f; // -7233
static const float dwt_delta = -0.443506852f; // -3633
static const float dwt_alpha = 1.586134342f; /* 12994 */
static const float dwt_beta = 0.052980118f; /* 434 */
static const float dwt_gamma = -0.882911075f; /* -7233 */
static const float dwt_delta = -0.443506852f; /* -3633 */
static const float K = 1.230174105f; // 10078
static const float K = 1.230174105f; /* 10078 */
/* FIXME: What is this constant? */
static const float c13318 = 1.625732422f;
@@ -527,7 +527,7 @@ static void dwt_decode_tile(opj_tcd_tilecomp_t* tilec, int numres, DWT1DFN dwt_1
int w = tilec->x1 - tilec->x0;
h.mem = (int *)opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int));
h.mem = (int*)opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int));
v.mem = h.mem;
while( --numres) {
@@ -570,7 +570,7 @@ static void v4dwt_interleave_h(v4dwt_t* restrict w, float* restrict a, int x, in
int count = w->sn;
int i, k;
for(k = 0; k < 2; ++k){
if (count + 3 * x < size && ((long) a & 0x0f) == 0 && ((long) bi & 0x0f) == 0 && (x & 0x0f) == 0) {
if (count + 3 * x < size && ((size_t) a & 0x0f) == 0 && ((size_t) bi & 0x0f) == 0 && (x & 0x0f) == 0) {
/* Fast code path */
for(i = 0; i < count; ++i){
int j = i;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Hervé Drolon, FreeImage Team
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,6 +26,42 @@
#include "opj_includes.h"
/* ==========================================================
Utility functions
==========================================================*/
#ifdef OPJ_CODE_NOT_USED
#ifndef _WIN32
static char*
i2a(unsigned i, char *a, unsigned r) {
if (i/r > 0) a = i2a(i/r,a,r);
*a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i%r];
return a+1;
}
/**
Transforms integer i into an ascii string and stores the result in a;
string is encoded in the base indicated by r.
@param i Number to be converted
@param a String result
@param r Base of value; must be in the range 2 - 36
@return Returns a
*/
static char *
_itoa(int i, char *a, int r) {
r = ((r < 2) || (r > 36)) ? 10 : r;
if(i < 0) {
*a = '-';
*i2a(-i, a+1, r) = 0;
}
else *i2a(i, a, r) = 0;
return a;
}
#endif /* !_WIN32 */
#endif
/* ----------------------------------------------------------------------- */
opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context) {
if(cinfo) {
opj_event_mgr_t *previous = cinfo->event_mgr;
@@ -37,7 +73,7 @@ opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_
return NULL;
}
bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
#define MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */
opj_msg_callback msg_handler = NULL;
@@ -57,30 +93,29 @@ bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
break;
}
if(msg_handler == NULL) {
return false;
return OPJ_FALSE;
}
} else {
return false;
return OPJ_FALSE;
}
if ((fmt != NULL) && (event_mgr != NULL)) {
va_list arg;
int str_length/*, i, j*/; /* UniPG */
char message[MSG_SIZE];
memset(message, 0, MSG_SIZE);
/* initialize the optional parameter list */
va_start(arg, fmt);
/* check the length of the format string */
str_length = (strlen(fmt) > MSG_SIZE) ? MSG_SIZE : strlen(fmt);
/* parse the format string and put the result in 'message' */
vsprintf(message, fmt, arg); /* UniPG */
str_length = vsnprintf(message, MSG_SIZE, fmt, arg); /* UniPG */
/* deinitialize the optional parameter list */
va_end(arg);
/* output the message to the user program */
msg_handler(message, cinfo->client_data);
if( str_length > -1 && str_length < MSG_SIZE )
msg_handler(message, cinfo->client_data);
else return OPJ_FALSE;
}
return true;
return OPJ_TRUE;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Herv<EFBFBD> Drolon, FreeImage Team
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -49,7 +49,7 @@ Write formatted data to a string and send the string to a user callback.
@param fmt Format-control string (plus optionnal arguments)
@return Returns true if successful, returns false otherwise
*/
bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...);
opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...);
/* ----------------------------------------------------------------------- */
/*@}*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Herv Drolon, FreeImage Team
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,6 @@
opj_image_t* opj_image_create0(void) {
opj_image_t *image = (opj_image_t*)opj_calloc(1, sizeof(opj_image_t));
image->comps=NULL;
return image;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Herv<EFBFBD> Drolon, FreeImage Team
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@@ -0,0 +1,118 @@
/*
* $Id: indexbox_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
*
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2011, Professor Benoit Macq
* Copyright (c) 2003-2004, Yannick Verschueren
* Copyright (c) 2010-2011, Kaori Hagihara
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*! \file
* \brief Modification of jpip.c from 2KAN indexer
*/
#ifndef INDEXBOX_MANAGER_H_
# define INDEXBOX_MANAGER_H_
#include "openjpeg.h"
#include "j2k.h" /* needed to use jp2.h */
#include "jp2.h"
#define JPIP_CIDX 0x63696478 /* Codestream index */
#define JPIP_CPTR 0x63707472 /* Codestream Finder Box */
#define JPIP_MANF 0x6d616e66 /* Manifest Box */
#define JPIP_FAIX 0x66616978 /* Fragment array Index box */
#define JPIP_MHIX 0x6d686978 /* Main Header Index Table */
#define JPIP_TPIX 0x74706978 /* Tile-part Index Table box */
#define JPIP_THIX 0x74686978 /* Tile header Index Table box */
#define JPIP_PPIX 0x70706978 /* Precinct Packet Index Table box */
#define JPIP_PHIX 0x70686978 /* Packet Header index Table */
#define JPIP_FIDX 0x66696478 /* File Index */
#define JPIP_FPTR 0x66707472 /* File Finder */
#define JPIP_PRXY 0x70727879 /* Proxy boxes */
#define JPIP_IPTR 0x69707472 /* Index finder box */
#define JPIP_PHLD 0x70686c64 /* Place holder */
/*
* Write tile-part Index table box (superbox)
*
* @param[in] coff offset of j2k codestream
* @param[in] cstr_info codestream information
* @param[in] j2klen length of j2k codestream
* @param[in] cio file output handle
* @return length of tpix box
*/
int write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio);
/*
* Write tile header index table box (superbox)
*
* @param[in] coff offset of j2k codestream
* @param[in] cstr_info codestream information pointer
* @param[in] cio file output handle
* @return length of thix box
*/
int write_thix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio);
/*
* Write precinct packet index table box (superbox)
*
* @param[in] coff offset of j2k codestream
* @param[in] cstr_info codestream information
* @param[in] EPHused true if EPH option used
* @param[in] j2klen length of j2k codestream
* @param[in] cio file output handle
* @return length of ppix box
*/
int write_ppix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
/*
* Write packet header index table box (superbox)
*
* @param[in] coff offset of j2k codestream
* @param[in] cstr_info codestream information
* @param[in] EPHused true if EPH option used
* @param[in] j2klen length of j2k codestream
* @param[in] cio file output handle
* @return length of ppix box
*/
int write_phix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
/*
* Wriet manifest box (box)
*
* @param[in] second number to be visited
* @param[in] v number of boxes
* @param[in] box box to be manifested
* @param[in] cio file output handle
*/
void write_manf(int second, int v, opj_jp2_box_t *box, opj_cio_t *cio);
#endif /* !INDEXBOX_MANAGER_H_ */

View File

@@ -6,6 +6,7 @@
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2006-2007, Parvatha Elangovan
* Copyright (c) 2010-2011, Kaori Hagihara
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -228,6 +229,23 @@ Read an unknown marker
@param j2k J2K handle
*/
static void j2k_read_unk(opj_j2k_t *j2k);
/**
Add main header marker information
@param cstr_info Codestream information structure
@param type marker type
@param pos byte offset of marker segment
@param len length of marker segment
*/
static void j2k_add_mhmarker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len);
/**
Add tile header marker information
@param tileno tile index number
@param cstr_info Codestream information structure
@param type marker type
@param pos byte offset of marker segment
@param len length of marker segment
*/
static void j2k_add_tlmarker( int tileno, opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len);
/*@}*/
@@ -258,80 +276,6 @@ char *j2k_convert_progression_order(OPJ_PROG_ORDER prg_order){
return po->str_prog;
}
void j2k_dump_image(FILE *fd, opj_image_t * img) {
int compno;
fprintf(fd, "image {\n");
fprintf(fd, " x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0, img->x1, img->y1);
fprintf(fd, " numcomps=%d\n", img->numcomps);
for (compno = 0; compno < img->numcomps; compno++) {
opj_image_comp_t *comp = &img->comps[compno];
fprintf(fd, " comp %d {\n", compno);
fprintf(fd, " dx=%d, dy=%d\n", comp->dx, comp->dy);
fprintf(fd, " prec=%d\n", comp->prec);
//fprintf(fd, " bpp=%d\n", comp->bpp);
fprintf(fd, " sgnd=%d\n", comp->sgnd);
fprintf(fd, " }\n");
}
fprintf(fd, "}\n");
}
void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp) {
int tileno, compno, layno, bandno, resno, numbands;
fprintf(fd, "coding parameters {\n");
fprintf(fd, " tx0=%d, ty0=%d\n", cp->tx0, cp->ty0);
fprintf(fd, " tdx=%d, tdy=%d\n", cp->tdx, cp->tdy);
fprintf(fd, " tw=%d, th=%d\n", cp->tw, cp->th);
for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
opj_tcp_t *tcp = &cp->tcps[tileno];
fprintf(fd, " tile %d {\n", tileno);
fprintf(fd, " csty=%x\n", tcp->csty);
fprintf(fd, " prg=%d\n", tcp->prg);
fprintf(fd, " numlayers=%d\n", tcp->numlayers);
fprintf(fd, " mct=%d\n", tcp->mct);
fprintf(fd, " rates=");
for (layno = 0; layno < tcp->numlayers; layno++) {
fprintf(fd, "%.1f ", tcp->rates[layno]);
}
fprintf(fd, "\n");
for (compno = 0; compno < img->numcomps; compno++) {
opj_tccp_t *tccp = &tcp->tccps[compno];
fprintf(fd, " comp %d {\n", compno);
fprintf(fd, " csty=%x\n", tccp->csty);
fprintf(fd, " numresolutions=%d\n", tccp->numresolutions);
fprintf(fd, " cblkw=%d\n", tccp->cblkw);
fprintf(fd, " cblkh=%d\n", tccp->cblkh);
fprintf(fd, " cblksty=%x\n", tccp->cblksty);
fprintf(fd, " qmfbid=%d\n", tccp->qmfbid);
fprintf(fd, " qntsty=%d\n", tccp->qntsty);
fprintf(fd, " numgbits=%d\n", tccp->numgbits);
fprintf(fd, " roishift=%d\n", tccp->roishift);
fprintf(fd, " stepsizes=");
numbands = tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2;
for (bandno = 0; bandno < numbands; bandno++) {
fprintf(fd, "(%d,%d) ", tccp->stepsizes[bandno].mant,
tccp->stepsizes[bandno].expn);
}
fprintf(fd, "\n");
if (tccp->csty & J2K_CCP_CSTY_PRT) {
fprintf(fd, " prcw=");
for (resno = 0; resno < tccp->numresolutions; resno++) {
fprintf(fd, "%d ", tccp->prcw[resno]);
}
fprintf(fd, "\n");
fprintf(fd, " prch=");
for (resno = 0; resno < tccp->numresolutions; resno++) {
fprintf(fd, "%d ", tccp->prch[resno]);
}
fprintf(fd, "\n");
}
fprintf(fd, " }\n");
}
fprintf(fd, " }\n");
}
fprintf(fd, "}\n");
}
/* ----------------------------------------------------------------------- */
static int j2k_get_num_tp(opj_cp_t *cp,int pino,int tileno){
char *prog;
@@ -371,6 +315,9 @@ static int j2k_get_num_tp(opj_cp_t *cp,int pino,int tileno){
/** mem allocation for TLM marker*/
int j2k_calculate_tp(opj_cp_t *cp,int img_numcomp,opj_image_t *image,opj_j2k_t *j2k ){
int pino,tileno,totnum_tp=0;
OPJ_ARG_NOT_USED(img_numcomp);
j2k->cur_totnum_tp = (int *) opj_malloc(cp->tw * cp->th * sizeof(int));
for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
int cur_totnum_tp = 0;
@@ -399,12 +346,14 @@ static void j2k_write_soc(opj_j2k_t *j2k) {
opj_cio_t *cio = j2k->cio;
cio_write(cio, J2K_MS_SOC, 2);
if(j2k->cstr_info)
j2k_add_mhmarker(j2k->cstr_info, J2K_MS_SOC, cio_tell(cio), 0);
/* UniPG>> */
#ifdef USE_JPWL
/* update markers struct */
j2k_add_marker(j2k->cstr_info, J2K_MS_SOC, cio_tell(cio) - 2, 2);
#endif /* USE_JPWL */
/* <<UniPG */
}
@@ -425,7 +374,7 @@ static void j2k_write_siz(opj_j2k_t *j2k) {
opj_cio_t *cio = j2k->cio;
opj_image_t *image = j2k->image;
opj_cp_t *cp = j2k->cp;
cio_write(cio, J2K_MS_SIZ, 2); /* SIZ */
lenp = cio_tell(cio);
cio_skip(cio, 2);
@@ -448,6 +397,9 @@ static void j2k_write_siz(opj_j2k_t *j2k) {
cio_seek(cio, lenp);
cio_write(cio, len, 2); /* Lsiz */
cio_seek(cio, lenp + len);
if(j2k->cstr_info)
j2k_add_mhmarker(j2k->cstr_info, J2K_MS_SIZ, lenp, len);
}
static void j2k_read_siz(opj_j2k_t *j2k) {
@@ -516,6 +468,12 @@ static void j2k_read_siz(opj_j2k_t *j2k) {
}
#endif /* USE_JPWL */
/* prevent division by zero */
if (!(cp->tdx * cp->tdy)) {
opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: invalid tile size (tdx: %d, tdy: %d)\n", cp->tdx, cp->tdy);
return;
}
image->comps = (opj_image_comp_t*) opj_calloc(image->numcomps, sizeof(opj_image_comp_t));
for (i = 0; i < image->numcomps; i++) {
int tmp, w, h;
@@ -554,6 +512,12 @@ static void j2k_read_siz(opj_j2k_t *j2k) {
}
#endif /* USE_JPWL */
/* prevent division by zero */
if (!(image->comps[i].dx * image->comps[i].dy)) {
opj_event_msg(j2k->cinfo, EVT_ERROR, "JPWL: invalid component size (dx: %d, dy: %d)\n", image->comps[i].dx, image->comps[i].dy);
return;
}
/* TODO: unused ? */
w = int_ceildiv(image->x1 - image->x0, image->comps[i].dx);
h = int_ceildiv(image->y1 - image->y0, image->comps[i].dy);
@@ -606,7 +570,17 @@ static void j2k_read_siz(opj_j2k_t *j2k) {
#endif /* USE_JPWL */
cp->tcps = (opj_tcp_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tcp_t));
if (cp->tcps == NULL)
{
opj_event_msg(j2k->cinfo, EVT_ERROR, "Out of memory\n");
return;
}
cp->tileno = (int*) opj_malloc(cp->tw * cp->th * sizeof(int));
if (cp->tileno == NULL)
{
opj_event_msg(j2k->cinfo, EVT_ERROR, "Out of memory\n");
return;
}
cp->tileno_size = 0;
#ifdef USE_JPWL
@@ -678,6 +652,11 @@ static void j2k_write_com(opj_j2k_t *j2k) {
cio_seek(cio, lenp);
cio_write(cio, len, 2);
cio_seek(cio, lenp + len);
if(j2k->cstr_info)
j2k_add_mhmarker(j2k->cstr_info, J2K_MS_COM, lenp, len);
}
}
@@ -721,12 +700,18 @@ static void j2k_read_cox(opj_j2k_t *j2k, int compno) {
tccp->numresolutions = cio_read(cio, 1) + 1; /* SPcox (D) */
// If user wants to remove more resolutions than the codestream contains, return error
/* If user wants to remove more resolutions than the codestream contains, return error*/
if (cp->reduce >= tccp->numresolutions) {
opj_event_msg(j2k->cinfo, EVT_ERROR, "Error decoding component %d.\nThe number of resolutions to remove is higher than the number "
"of resolutions of this component\nModify the cp_reduce parameter.\n\n", compno);
"of resolutions of this component\nModify the cp_reduce parameter.\n\n", compno);
j2k->state |= J2K_STATE_ERR;
}
if( tccp->numresolutions > J2K_MAXRLVLS ) {
opj_event_msg(j2k->cinfo, EVT_ERROR, "Error decoding component %d.\nThe number of resolutions is too big: %d vs max= %d. Truncating.\n\n",
compno, tccp->numresolutions, J2K_MAXRLVLS);
j2k->state |= J2K_STATE_ERR;
tccp->numresolutions = J2K_MAXRLVLS;
}
tccp->cblkw = cio_read(cio, 1) + 2; /* SPcox (E) */
tccp->cblkh = cio_read(cio, 1) + 2; /* SPcox (F) */
@@ -781,6 +766,10 @@ static void j2k_write_cod(opj_j2k_t *j2k) {
cio_seek(cio, lenp);
cio_write(cio, len, 2); /* Lcod */
cio_seek(cio, lenp + len);
if(j2k->cstr_info)
j2k_add_mhmarker(j2k->cstr_info, J2K_MS_COD, lenp, len);
}
static void j2k_read_cod(opj_j2k_t *j2k) {
@@ -846,6 +835,12 @@ static void j2k_read_coc(opj_j2k_t *j2k) {
len = cio_read(cio, 2); /* Lcoc */
compno = cio_read(cio, image->numcomps <= 256 ? 1 : 2); /* Ccoc */
if (compno >= image->numcomps) {
opj_event_msg(j2k->cinfo, EVT_ERROR,
"bad component number in COC (%d out of a maximum of %d)\n",
compno, image->numcomps);
return;
}
tcp->tccps[compno].csty = cio_read(cio, 1); /* Scoc */
j2k_read_cox(j2k, compno);
}
@@ -909,6 +904,15 @@ static void j2k_read_qcx(opj_j2k_t *j2k, int compno, int len) {
};
};
#else
/* We check whether there are too many subbands */
if ((numbands < 0) || (numbands >= J2K_MAXBANDS)) {
opj_event_msg(j2k->cinfo, EVT_WARNING ,
"bad number of subbands in Sqcx (%d) regarding to J2K_MAXBANDS (%d) \n"
"- limiting number of bands to J2K_MAXBANDS and try to move to the next markers\n", numbands, J2K_MAXBANDS);
}
#endif /* USE_JPWL */
for (bandno = 0; bandno < numbands; bandno++) {
@@ -921,8 +925,10 @@ static void j2k_read_qcx(opj_j2k_t *j2k, int compno, int len) {
expn = tmp >> 11;
mant = tmp & 0x7ff;
}
tccp->stepsizes[bandno].expn = expn;
tccp->stepsizes[bandno].mant = mant;
if (bandno < J2K_MAXBANDS){
tccp->stepsizes[bandno].expn = expn;
tccp->stepsizes[bandno].mant = mant;
}
}
/* Add Antonin : if scalar_derived -> compute other stepsizes */
@@ -950,6 +956,9 @@ static void j2k_write_qcd(opj_j2k_t *j2k) {
cio_seek(cio, lenp);
cio_write(cio, len, 2); /* Lqcd */
cio_seek(cio, lenp + len);
if(j2k->cstr_info)
j2k_add_mhmarker(j2k->cstr_info, J2K_MS_QCD, lenp, len);
}
static void j2k_read_qcd(opj_j2k_t *j2k) {
@@ -986,7 +995,7 @@ static void j2k_read_qcc(opj_j2k_t *j2k) {
int len, compno;
int numcomp = j2k->image->numcomps;
opj_cio_t *cio = j2k->cio;
len = cio_read(cio, 2); /* Lqcc */
compno = cio_read(cio, numcomp <= 256 ? 1 : 2); /* Cqcc */
@@ -1013,9 +1022,16 @@ static void j2k_read_qcc(opj_j2k_t *j2k) {
/* keep your private count of tiles */
backup_compno++;
};
}
#endif /* USE_JPWL */
if ((compno < 0) || (compno >= numcomp)) {
opj_event_msg(j2k->cinfo, EVT_ERROR,
"bad component number in QCC (%d out of a maximum of %d)\n",
compno, j2k->image->numcomps);
return;
}
j2k_read_qcx(j2k, compno, len - 2 - (numcomp <= 256 ? 1 : 2));
}
@@ -1271,6 +1287,10 @@ static void j2k_write_sot(opj_j2k_t *j2k) {
j2k_add_marker(j2k->cstr_info, J2K_MS_SOT, j2k->sot_start, len + 2);
#endif /* USE_JPWL */
/* <<UniPG */
if( j2k->cstr_info && j2k->cur_tp_num==0){
j2k_add_tlmarker( j2k->curtileno, j2k->cstr_info, J2K_MS_SOT, lenp, len);
}
}
static void j2k_read_sot(opj_j2k_t *j2k) {
@@ -1354,6 +1374,11 @@ static void j2k_read_sot(opj_j2k_t *j2k) {
partno = cio_read(cio, 1);
numparts = cio_read(cio, 1);
if (partno >= numparts) {
opj_event_msg(j2k->cinfo, EVT_WARNING, "SOT marker inconsistency in tile %d: tile-part index greater (%d) than number of tile-parts (%d)\n", tileno, partno, numparts);
numparts = partno+1;
}
j2k->curtileno = tileno;
j2k->cur_tp_num = partno;
@@ -1369,15 +1394,14 @@ static void j2k_read_sot(opj_j2k_t *j2k) {
j2k->cstr_info->tile[tileno].tileno = tileno;
j2k->cstr_info->tile[tileno].start_pos = cio_tell(cio) - 12;
j2k->cstr_info->tile[tileno].end_pos = j2k->cstr_info->tile[tileno].start_pos + totlen - 1;
j2k->cstr_info->tile[tileno].num_tps = numparts;
if (numparts)
j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(numparts * sizeof(opj_tp_info_t));
else
j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(10 * sizeof(opj_tp_info_t)); // Fixme (10)
}
else {
} else {
j2k->cstr_info->tile[tileno].end_pos += totlen;
}
}
j2k->cstr_info->tile[tileno].num_tps = numparts;
if (numparts)
j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_realloc(j2k->cstr_info->tile[tileno].tp, numparts * sizeof(opj_tp_info_t));
else
j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_realloc(j2k->cstr_info->tile[tileno].tp, 10 * sizeof(opj_tp_info_t)); /* Fixme (10)*/
j2k->cstr_info->tile[tileno].tp[partno].tp_start_pos = cio_tell(cio) - 12;
j2k->cstr_info->tile[tileno].tp[partno].tp_end_pos =
j2k->cstr_info->tile[tileno].tp[partno].tp_start_pos + totlen - 1;
@@ -1413,6 +1437,11 @@ static void j2k_write_sod(opj_j2k_t *j2k, void *tile_coder) {
tcd->cur_tp_num = j2k->cur_tp_num;
cio_write(cio, J2K_MS_SOD, 2);
if( j2k->cstr_info && j2k->cur_tp_num==0){
j2k_add_tlmarker( j2k->curtileno, j2k->cstr_info, J2K_MS_SOD, cio_tell(cio), 0);
}
if (j2k->curtileno == 0) {
j2k->sod_start = cio_tell(cio) + j2k->pos_correction;
}
@@ -1487,7 +1516,7 @@ static void j2k_read_sod(opj_j2k_t *j2k) {
if (len == cio_numbytesleft(cio) + 1) {
truncate = 1; /* Case of a truncate codestream */
}
}
data = j2k->tile_data[curtileno];
data = (unsigned char*) opj_realloc(data, (j2k->tile_len[curtileno] + len) * sizeof(unsigned char));
@@ -1548,6 +1577,13 @@ static void j2k_read_rgn(opj_j2k_t *j2k) {
};
#endif /* USE_JPWL */
if (compno >= numcomps) {
opj_event_msg(j2k->cinfo, EVT_ERROR,
"bad component number in RGN (%d out of a maximum of %d)\n",
compno, j2k->image->numcomps);
return;
}
tcp->tccps[compno].roishift = cio_read(cio, 1); /* SPrgn */
}
@@ -1566,7 +1602,7 @@ static void j2k_write_eoc(opj_j2k_t *j2k) {
static void j2k_read_eoc(opj_j2k_t *j2k) {
int i, tileno;
bool success;
opj_bool success = OPJ_FALSE;
/* if packets should be decoded */
if (j2k->cp->limit_decoding != DECODE_ALL_BUT_PACKETS) {
@@ -1574,12 +1610,17 @@ static void j2k_read_eoc(opj_j2k_t *j2k) {
tcd_malloc_decode(tcd, j2k->image, j2k->cp);
for (i = 0; i < j2k->cp->tileno_size; i++) {
tcd_malloc_decode_tile(tcd, j2k->image, j2k->cp, i, j2k->cstr_info);
tileno = j2k->cp->tileno[i];
success = tcd_decode_tile(tcd, j2k->tile_data[tileno], j2k->tile_len[tileno], tileno, j2k->cstr_info);
opj_free(j2k->tile_data[tileno]);
j2k->tile_data[tileno] = NULL;
tcd_free_decode_tile(tcd, i);
if (success == false) {
if (j2k->cp->tileno[i] != -1)
{
tileno = j2k->cp->tileno[i];
success = tcd_decode_tile(tcd, j2k->tile_data[tileno], j2k->tile_len[tileno], tileno, j2k->cstr_info);
opj_free(j2k->tile_data[tileno]);
j2k->tile_data[tileno] = NULL;
tcd_free_decode_tile(tcd, i);
}
else
success = OPJ_FALSE;
if (success == OPJ_FALSE) {
j2k->state |= J2K_STATE_ERR;
break;
}
@@ -1749,6 +1790,14 @@ void j2k_destroy_decompress(opj_j2k_t *j2k) {
opj_free(j2k->tile_len);
}
if(j2k->tile_data != NULL) {
if(j2k->cp != NULL) {
for (i = 0; i < j2k->cp->tileno_size; i++) {
int tileno = j2k->cp->tileno[i];
opj_free(j2k->tile_data[tileno]);
j2k->tile_data[tileno] = NULL;
}
}
opj_free(j2k->tile_data);
}
if(j2k->default_tcp != NULL) {
@@ -1834,7 +1883,7 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c
if (j2k->cp->correct) {
int orig_pos = cio_tell(cio);
bool status;
opj_bool status;
/* call the corrector */
status = jpwl_correct(j2k);
@@ -1873,13 +1922,13 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c
return 0;
}
e = j2k_dec_mstab_lookup(id);
// Check if the marker is known
/* Check if the marker is known*/
if (!(j2k->state & e->states)) {
opj_image_destroy(image);
opj_event_msg(cinfo, EVT_ERROR, "%.8x: unexpected marker %x\n", cio_tell(cio) - 2, id);
return 0;
}
// Check if the decoding is limited to the main header
/* Check if the decoding is limited to the main header*/
if (e->id == J2K_MS_SOT && j2k->cp->limit_decoding == LIMIT_TO_MAIN_HEADER) {
opj_event_msg(cinfo, EVT_INFO, "Main Header decoded.\n");
return image;
@@ -1889,7 +1938,10 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c
(*e->handler)(j2k);
}
if (j2k->state & J2K_STATE_ERR)
{
opj_image_destroy(image);
return NULL;
}
if (j2k->state == J2K_STATE_MT) {
break;
@@ -1905,7 +1957,6 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c
if (j2k->state != J2K_STATE_MT) {
opj_event_msg(cinfo, EVT_WARNING, "Incomplete bitstream\n");
}
return image;
}
@@ -1917,9 +1968,10 @@ opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestre
opj_image_t *image = NULL;
opj_jpt_msg_header_t header;
int position;
opj_common_ptr cinfo = j2k->cinfo;
OPJ_ARG_NOT_USED(cstr_info);
j2k->cio = cio;
/* create an empty image */
@@ -2110,12 +2162,12 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_
int i;
/* set JPWL on */
cp->epc_on = true;
cp->info_on = false; /* no informative technique */
cp->epc_on = OPJ_TRUE;
cp->info_on = OPJ_FALSE; /* no informative technique */
/* set EPB on */
if ((parameters->jpwl_hprot_MH > 0) || (parameters->jpwl_hprot_TPH[0] > 0)) {
cp->epb_on = true;
cp->epb_on = OPJ_TRUE;
cp->hprot_MH = parameters->jpwl_hprot_MH;
for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) {
@@ -2136,7 +2188,7 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_
/* set ESD writing */
if ((parameters->jpwl_sens_size == 1) || (parameters->jpwl_sens_size == 2)) {
cp->esd_on = true;
cp->esd_on = OPJ_TRUE;
cp->sens_size = parameters->jpwl_sens_size;
cp->sens_addr = parameters->jpwl_sens_addr;
@@ -2150,10 +2202,10 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_
}
/* always set RED writing to false: we are at the encoder */
cp->red_on = false;
cp->red_on = OPJ_FALSE;
} else {
cp->epc_on = false;
cp->epc_on = OPJ_FALSE;
}
#endif /* USE_JPWL */
@@ -2226,10 +2278,10 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_
if(parameters->cp_cinema)
{
//Precinct size for lowest frequency subband=128
/*Precinct size for lowest frequency subband=128*/
tccp->prcw[0] = 7;
tccp->prch[0] = 7;
//Precinct size at all other resolutions = 256
/*Precinct size at all other resolutions = 256*/
for (j = 1; j < tccp->numresolutions; j++) {
tccp->prcw[j] = 8;
tccp->prch[j] = 8;
@@ -2271,7 +2323,7 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_
}
p++;
/*printf("\nsize precinct for level %d : %d,%d\n", j,tccp->prcw[j], tccp->prch[j]); */
} //end for
} /*end for*/
} else {
for (j = 0; j < tccp->numresolutions; j++) {
tccp->prcw[j] = 15;
@@ -2285,7 +2337,7 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_
}
}
bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
opj_bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
int tileno, compno;
opj_cp_t *cp = NULL;
@@ -2296,8 +2348,6 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre
cp = j2k->cp;
/* j2k_dump_cp(stdout, image, cp); */
/* INDEX >> */
j2k->cstr_info = cstr_info;
if (cstr_info) {
@@ -2394,6 +2444,9 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre
/* INDEX >> */
if(cstr_info) {
cstr_info->tile[j2k->curtileno].start_pos = cio_tell(cio) + j2k->pos_correction;
cstr_info->tile[j2k->curtileno].maxmarknum = 10;
cstr_info->tile[j2k->curtileno].marker = (opj_marker_info_t *) opj_malloc(cstr_info->tile[j2k->curtileno].maxmarknum * sizeof(opj_marker_info_t));
cstr_info->tile[j2k->curtileno].marknum = 0;
}
/* << INDEX */
@@ -2500,11 +2553,46 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre
}
#endif /* USE_JPWL */
return true;
return OPJ_TRUE;
}
static void j2k_add_mhmarker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len) {
if (!cstr_info)
return;
/* expand the list? */
if ((cstr_info->marknum + 1) > cstr_info->maxmarknum) {
cstr_info->maxmarknum = 100 + (int) ((float) cstr_info->maxmarknum * 1.0F);
cstr_info->marker = (opj_marker_info_t*)opj_realloc(cstr_info->marker, cstr_info->maxmarknum);
}
/* add the marker */
cstr_info->marker[cstr_info->marknum].type = type;
cstr_info->marker[cstr_info->marknum].pos = pos;
cstr_info->marker[cstr_info->marknum].len = len;
cstr_info->marknum++;
}
static void j2k_add_tlmarker( int tileno, opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len) {
opj_marker_info_t *marker;
if (!cstr_info)
return;
/* expand the list? */
if ((cstr_info->tile[tileno].marknum + 1) > cstr_info->tile[tileno].maxmarknum) {
cstr_info->tile[tileno].maxmarknum = 100 + (int) ((float) cstr_info->tile[tileno].maxmarknum * 1.0F);
cstr_info->tile[tileno].marker = (opj_marker_info_t*)opj_realloc(cstr_info->tile[tileno].marker, cstr_info->maxmarknum);
}
marker = &(cstr_info->tile[tileno].marker[cstr_info->tile[tileno].marknum]);
/* add the marker */
marker->type = type;
marker->pos = pos;
marker->len = len;
cstr_info->tile[tileno].marknum++;
}

View File

@@ -265,15 +265,15 @@ typedef struct opj_cp {
/* UniPG>> */
#ifdef USE_JPWL
/** enables writing of EPC in MH, thus activating JPWL */
bool epc_on;
opj_bool epc_on;
/** enables writing of EPB, in case of activated JPWL */
bool epb_on;
opj_bool epb_on;
/** enables writing of ESD, in case of activated JPWL */
bool esd_on;
opj_bool esd_on;
/** enables writing of informative techniques of ESD, in case of activated JPWL */
bool info_on;
opj_bool info_on;
/** enables writing of RED, in case of activated JPWL */
bool red_on;
opj_bool red_on;
/** error protection method for MH (0,1,16,32,37-128) */
int hprot_MH;
/** tile number of header protection specification (>=0) */
@@ -299,7 +299,7 @@ typedef struct opj_cp {
/** sensitivity methods for TPHs (-1,0-7) */
int sens_TPH[JPWL_MAX_NO_TILESPECS];
/** enables JPWL correction at the decoder */
bool correct;
opj_bool correct;
/** expected number of components at the decoder */
int exp_comps;
/** maximum number of tiles at the decoder */
@@ -436,10 +436,8 @@ Encode an image into a JPEG-2000 codestream
@param cstr_info Codestream information structure if required, NULL otherwise
@return Returns true if successful, returns false otherwise
*/
bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
opj_bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
void j2k_dump_image(FILE *fd, opj_image_t * img);
void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp);
/* ----------------------------------------------------------------------- */
/*@}*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Herv<EFBFBD> Drolon, FreeImage Team
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,18 +24,18 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#else
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/times.h>
#endif /* WIN32 */
#endif /* _WIN32 */
#include "opj_includes.h"
double opj_clock(void) {
#ifdef WIN32
/* WIN32: use QueryPerformance (very accurate) */
#ifdef _WIN32
/* _WIN32: use QueryPerformance (very accurate) */
LARGE_INTEGER freq , t ;
/* freq is the clock speed of the CPU */
QueryPerformanceFrequency(&freq) ;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Herv<EFBFBD> Drolon, FreeImage Team
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

File diff suppressed because it is too large Load Diff

View File

@@ -46,11 +46,64 @@
#define JP2_COLR 0x636f6c72 /**< Colour specification box */
#define JP2_JP2C 0x6a703263 /**< Contiguous codestream box */
#define JP2_URL 0x75726c20 /**< URL box */
#define JP2_DBTL 0x6474626c /**< ??? */
#define JP2_DTBL 0x6474626c /**< Data Reference box */
#define JP2_BPCC 0x62706363 /**< Bits per component box */
#define JP2_JP2 0x6a703220 /**< File type fields */
#define JP2_PCLR 0x70636c72 /**< Palette box */
#define JP2_CMAP 0x636d6170 /**< Component Mapping box */
#define JP2_CDEF 0x63646566 /**< Channel Definition box */
/* ----------------------------------------------------------------------- */
/**
Channel description: channel index, type, assocation
*/
typedef struct opj_jp2_cdef_info
{
unsigned short cn, typ, asoc;
} opj_jp2_cdef_info_t;
/**
Channel descriptions and number of descriptions
*/
typedef struct opj_jp2_cdef
{
opj_jp2_cdef_info_t *info;
unsigned short n;
} opj_jp2_cdef_t;
/**
Component mappings: channel index, mapping type, palette index
*/
typedef struct opj_jp2_cmap_comp
{
unsigned short cmp;
unsigned char mtyp, pcol;
} opj_jp2_cmap_comp_t;
/**
Palette data: table entries, palette columns
*/
typedef struct opj_jp2_pclr
{
unsigned int *entries;
unsigned char *channel_sign;
unsigned char *channel_size;
opj_jp2_cmap_comp_t *cmap;
unsigned short nr_entries, nr_channels;
} opj_jp2_pclr_t;
/**
Collector for ICC profile, palette, component mapping, channel description
*/
typedef struct opj_jp2_color
{
unsigned char *icc_profile_buf;
int icc_profile_len;
opj_jp2_cdef_t *jp2_cdef;
opj_jp2_pclr_t *jp2_pclr;
unsigned char jp2_has_colr;
} opj_jp2_color_t;
/**
JP2 component
@@ -87,6 +140,8 @@ typedef struct opj_jp2 {
opj_jp2_comps_t *comps;
unsigned int j2k_codestream_offset;
unsigned int j2k_codestream_length;
opj_bool jpip_on;
opj_bool ignore_pclr_cmap_cdef;
} opj_jp2_t;
/**
@@ -111,9 +166,10 @@ void jp2_write_jp2h(opj_jp2_t *jp2, opj_cio_t *cio);
Read the JP2H box - JP2 Header box (used in MJ2)
@param jp2 JP2 handle
@param cio Input buffer stream
@param ext Collector for profile, cdef and pclr data
@return Returns true if successful, returns false otherwise
*/
bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio);
opj_bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio, opj_jp2_color_t *color);
/**
Creates a JP2 decompression structure
@param cinfo Codec context info
@@ -139,7 +195,7 @@ Decode an image from a JPEG-2000 file stream
@param cstr_info Codestream information structure if required, NULL otherwise
@return Returns a decoded image if successful, returns NULL otherwise
*/
opj_image_t* jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, opj_codestream_info_t *cstr_info);
opj_image_t* opj_jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, opj_codestream_info_t *cstr_info);
/**
Creates a JP2 compression structure
@param cinfo Codec context info
@@ -167,7 +223,8 @@ Encode an image into a JPEG-2000 file stream
@param cstr_info Codestream information structure if required, NULL otherwise
@return Returns true if successful, returns false otherwise
*/
bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
opj_bool opj_jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
/* ----------------------------------------------------------------------- */
/*@}*/

View File

@@ -521,22 +521,21 @@ void mqc_init_dec(opj_mqc_t *mqc, unsigned char *bp, int len) {
unsigned int c;
unsigned int *ip;
unsigned char *end = mqc->end - 1;
mqc->buffer = opj_realloc(mqc->buffer, (2 * len + 1) * sizeof(unsigned int));
mqc->buffer = opj_realloc(mqc->buffer, (len + 1) * sizeof(unsigned int));
ip = (unsigned int *) mqc->buffer;
while (bp != end) {
while (bp < end) {
c = *(bp + 1);
if (*bp == 0xff) {
if (c > 0x8f) {
*ip = 0x0000ff18;
break;
} else {
bp++;
*ip = 0x00000017 | (c << 9);
}
} else {
bp++;
*ip = 0x00000018 | (c << 8);
}
bp++;
ip++;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Herv<EFBFBD> Drolon, FreeImage Team
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,17 +24,22 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#endif /* WIN32 */
#endif /* _WIN32 */
#include "opj_config.h"
#include "opj_includes.h"
/* ---------------------------------------------------------------------- */
#ifdef WIN32
#ifdef _WIN32
#ifndef OPJ_STATIC
BOOL APIENTRY
DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
OPJ_ARG_NOT_USED(lpReserved);
OPJ_ARG_NOT_USED(hModule);
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH :
break;
@@ -48,19 +53,19 @@ DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
return TRUE;
}
#endif /* OPJ_STATIC */
#endif /* WIN32 */
#endif /* _WIN32 */
/* ---------------------------------------------------------------------- */
const char* OPJ_CALLCONV opj_version(void) {
return OPENJPEG_VERSION;
return PACKAGE_VERSION;
}
opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) {
opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_calloc(1, sizeof(opj_dinfo_t));
if(!dinfo) return NULL;
dinfo->is_decompressor = true;
dinfo->is_decompressor = OPJ_TRUE;
switch(format) {
case CODEC_J2K:
case CODEC_JPT:
@@ -120,9 +125,10 @@ void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *paramete
parameters->decod_format = -1;
parameters->cod_format = -1;
parameters->flags = 0;
/* UniPG>> */
#ifdef USE_JPWL
parameters->jpwl_correct = false;
parameters->jpwl_correct = OPJ_FALSE;
parameters->jpwl_exp_comps = JPWL_EXPECTED_COMPONENTS;
parameters->jpwl_max_tiles = JPWL_MAXIMUM_TILES;
#endif /* USE_JPWL */
@@ -159,7 +165,7 @@ opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *ci
case CODEC_JPT:
return j2k_decode_jpt_stream((opj_j2k_t*)dinfo->j2k_handle, cio, cstr_info);
case CODEC_JP2:
return jp2_decode((opj_jp2_t*)dinfo->jp2_handle, cio, cstr_info);
return opj_jp2_decode((opj_jp2_t*)dinfo->jp2_handle, cio, cstr_info);
case CODEC_UNKNOWN:
default:
break;
@@ -171,7 +177,7 @@ opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *ci
opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) {
opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_calloc(1, sizeof(opj_cinfo_t));
if(!cinfo) return NULL;
cinfo->is_decompressor = false;
cinfo->is_decompressor = OPJ_FALSE;
switch(format) {
case CODEC_J2K:
/* get a J2K coder handle */
@@ -243,10 +249,10 @@ void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *paramete
parameters->cp_disto_alloc = 0;
parameters->cp_fixed_alloc = 0;
parameters->cp_fixed_quality = 0;
parameters->jpip_on = OPJ_FALSE;
/* UniPG>> */
#ifdef USE_JPWL
parameters->jpwl_epc_on = false;
parameters->jpwl_epc_on = OPJ_FALSE;
parameters->jpwl_hprot_MH = -1; /* -1 means unassigned */
{
int i;
@@ -296,7 +302,7 @@ void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *param
}
}
bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index) {
opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index) {
if (index != NULL)
opj_event_msg((opj_common_ptr)cinfo, EVT_WARNING, "Set index to NULL when calling the opj_encode function.\n"
"To extract the index, use the opj_encode_with_info() function.\n"
@@ -304,20 +310,20 @@ bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *im
return opj_encode_with_info(cinfo, cio, image, NULL);
}
bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
opj_bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
if(cinfo && cio && image) {
switch(cinfo->codec_format) {
case CODEC_J2K:
return j2k_encode((opj_j2k_t*)cinfo->j2k_handle, cio, image, cstr_info);
case CODEC_JP2:
return jp2_encode((opj_jp2_t*)cinfo->jp2_handle, cio, image, cstr_info);
return opj_jp2_encode((opj_jp2_t*)cinfo->jp2_handle, cio, image, cstr_info);
case CODEC_JPT:
case CODEC_UNKNOWN:
default:
break;
}
}
return false;
return OPJ_FALSE;
}
void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) {
@@ -328,6 +334,7 @@ void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) {
opj_free(tile_info->thresh);
opj_free(tile_info->packet);
opj_free(tile_info->tp);
opj_free(tile_info->marker);
}
opj_free(cstr_info->tile);
opj_free(cstr_info->marker);

View File

@@ -6,6 +6,7 @@
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2006-2007, Parvatha Elangovan
* Copyright (c) 2010-2011, Kaori Hagihara
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -32,7 +33,6 @@
#ifndef OPENJPEG_H
#define OPENJPEG_H
#define OPENJPEG_VERSION "1.4.0.635"
/*
==========================================================
@@ -40,7 +40,7 @@
==========================================================
*/
#if defined(OPJ_STATIC) || !(defined(WIN32) || defined(__WIN32__))
#if defined(OPJ_STATIC) || !defined(_WIN32)
#define OPJ_API
#define OPJ_CALLCONV
#else
@@ -53,38 +53,19 @@ that uses this DLL. This way any other project whose source files include this f
OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols
defined with this macro as being exported.
*/
#ifdef OPJ_EXPORTS
#if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
#define OPJ_API __declspec(dllexport)
#else
#define OPJ_API __declspec(dllimport)
#endif /* OPJ_EXPORTS */
#endif /* !OPJ_STATIC || !WIN32 */
#endif /* !OPJ_STATIC || !_WIN32 */
#ifndef __cplusplus
#if defined(HAVE_STDBOOL_H)
/*
The C language implementation does correctly provide the standard header
file "stdbool.h".
*/
#include <stdbool.h>
#else
/*
The C language implementation does not provide the standard header file
"stdbool.h" as required by ISO/IEC 9899:1999. Try to compensate for this
braindamage below.
*/
#if !defined(bool)
#define bool int
#endif
#if !defined(true)
#define true 1
#endif
#if !defined(false)
#define false 0
#endif
#endif
#endif /* __cplusplus */
typedef int opj_bool;
#define OPJ_TRUE 1
#define OPJ_FALSE 0
/* Avoid compile-time warning because parameter is not used */
#define OPJ_ARG_NOT_USED(x) (void)(x)
/*
==========================================================
Useful constant definitions
@@ -154,14 +135,18 @@ typedef enum COLOR_SPACE {
CLRSPC_SYCC = 3 /**< YUV */
} OPJ_COLOR_SPACE;
#define ENUMCS_SRGB 16
#define ENUMCS_GRAY 17
#define ENUMCS_SYCC 18
/**
Supported codec
*/
typedef enum CODEC_FORMAT {
CODEC_UNKNOWN = -1, /**< place-holder */
CODEC_J2K = 0, /**< JPEG-2000 codestream : read/write */
CODEC_JPT = 1, /**< JPT-stream (JPEG 2000, JPIP) : read only */
CODEC_JP2 = 2 /**< JPEG-2000 file format : read/write */
CODEC_J2K = 0, /**< JPEG-2000 codestream : read/write */
CODEC_JPT = 1, /**< JPT-stream (JPEG 2000, JPIP) : read only */
CODEC_JP2 = 2 /**< JPEG-2000 file format : read/write */
} OPJ_CODEC_FORMAT;
/**
@@ -244,7 +229,7 @@ Compression parameters
*/
typedef struct opj_cparameters {
/** size of tile: tile_size_on = false (not in argument) or = true (in argument) */
bool tile_size_on;
opj_bool tile_size_on;
/** XTOsiz */
int cp_tx0;
/** YTOsiz */
@@ -326,7 +311,7 @@ typedef struct opj_cparameters {
/**@name JPWL encoding parameters */
/*@{*/
/** enables writing of EPC in MH, thus activating JPWL */
bool jpwl_epc_on;
opj_bool jpwl_epc_on;
/** error protection method for MH (0,1,16,32,37-128) */
int jpwl_hprot_MH;
/** tile number of header protection specification (>=0) */
@@ -366,8 +351,12 @@ typedef struct opj_cparameters {
char tp_flag;
/** MCT (multiple component transform) */
char tcp_mct;
/** Enable JPIP indexing*/
opj_bool jpip_on;
} opj_cparameters_t;
#define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001
/**
Decompression parameters
*/
@@ -404,7 +393,7 @@ typedef struct opj_dparameters {
/**@name JPWL decoding parameters */
/*@{*/
/** activates the JPWL correction capabilities */
bool jpwl_correct;
opj_bool jpwl_correct;
/** expected number of components */
int jpwl_exp_comps;
/** maximum number of tiles */
@@ -420,6 +409,7 @@ typedef struct opj_dparameters {
*/
OPJ_LIMIT_DECODING cp_limit_decoding;
unsigned int flags;
} opj_dparameters_t;
/** Common fields between JPEG-2000 compression and decompression master structs. */
@@ -427,7 +417,7 @@ typedef struct opj_dparameters {
#define opj_common_fields \
opj_event_mgr_t *event_mgr; /**< pointer to the event manager */\
void * client_data; /**< Available for use by application */\
bool is_decompressor; /**< So common code can tell which is which */\
opj_bool is_decompressor; /**< So common code can tell which is which */\
OPJ_CODEC_FORMAT codec_format; /**< selected codec */\
void *j2k_handle; /**< pointer to the J2K codec */\
void *jp2_handle; /**< pointer to the JP2 codec */\
@@ -555,6 +545,10 @@ typedef struct opj_image {
OPJ_COLOR_SPACE color_space;
/** image components */
opj_image_comp_t *comps;
/** 'restricted' ICC profile */
unsigned char *icc_profile_buf;
/** size of ICC profile */
int icc_profile_len;
} opj_image_t;
/**
@@ -601,6 +595,21 @@ typedef struct opj_packet_info {
double disto;
} opj_packet_info_t;
/* UniPG>> */
/**
Marker structure
*/
typedef struct opj_marker_info_t {
/** marker type */
unsigned short int type;
/** position in codestream */
int pos;
/** length, marker val included */
int len;
} opj_marker_info_t;
/* <<UniPG */
/**
Index structure : Information concerning tile-parts
*/
@@ -645,26 +654,18 @@ typedef struct opj_tile_info {
int numpix;
/** add fixed_quality */
double distotile;
/** number of markers */
int marknum;
/** list of markers */
opj_marker_info_t *marker;
/** actual size of markers array */
int maxmarknum;
/** number of tile parts */
int num_tps;
/** information concerning tile parts */
opj_tp_info_t *tp;
} opj_tile_info_t;
/* UniPG>> */
/**
Marker structure
*/
typedef struct opj_marker_info_t {
/** marker type */
unsigned short int type;
/** position in codestream */
int pos;
/** length, marker val included */
int len;
} opj_marker_info_t;
/* <<UniPG */
/**
Index structure of the codestream
*/
@@ -883,13 +884,13 @@ Setup the encoder parameters using the current image and using user parameters.
OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image);
/**
Encode an image into a JPEG-2000 codestream
@param cinfo compressor handle
3@param cinfo compressor handle
@param cio Output buffer stream
@param image Image to encode
@param index Depreacted -> Set to NULL. To extract index, used opj_encode_wci()
@return Returns true if successful, returns false otherwise
*/
OPJ_API bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
OPJ_API opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
/**
Encode an image into a JPEG-2000 codestream and extract the codestream information
@param cinfo compressor handle
@@ -898,13 +899,14 @@ Encode an image into a JPEG-2000 codestream and extract the codestream informati
@param cstr_info Codestream information structure if needed afterwards, NULL otherwise
@return Returns true if successful, returns false otherwise
*/
OPJ_API bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
OPJ_API opj_bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
/**
Destroy Codestream information after compression or decompression
@param cstr_info Codestream information structure
*/
OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,36 @@
/* create config.h for CMake */
#define PACKAGE_VERSION "1.5.2"
#define HAVE_INTTYPES_H
#define HAVE_MEMORY_H
#define HAVE_STDINT_H
#define HAVE_STDLIB_H
#define HAVE_STRINGS_H
#define HAVE_STRING_H
#define HAVE_SYS_STAT_H
#define HAVE_SYS_TYPES_H
#define HAVE_UNISTD_H
/* #define HAVE_LIBPNG */
/* #define HAVE_PNG_H */
/* #define HAVE_LIBTIFF */
/* #define HAVE_TIFF_H */
/* #undef HAVE_LIBLCMS1 */
/* #undef HAVE_LIBLCMS2 */
/* #undef HAVE_LCMS1_H */
/* #undef HAVE_LCMS2_H */
/* Byte order. */
/* All compilers that support Mac OS X define either __BIG_ENDIAN__ or
* __LITTLE_ENDIAN__ to match the endianness of the architecture being
* compiled for. This is not necessarily the same as the architecture of the
* machine doing the building. In order to support Universal Binaries on
* Mac OS X, we prefer those defines to decide the endianness.
* On other platforms we use the result of the TRY_RUN. */
#if !defined(__APPLE__)
/* #undef OPJ_BIG_ENDIAN */
#elif defined(__BIG_ENDIAN__)
# define OPJ_BIG_ENDIAN
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Herv<EFBFBD> Drolon, FreeImage Team
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -89,20 +89,25 @@ Most compilers implement their own version of this keyword ...
/* MSVC and Borland C do not have lrintf */
#if defined(_MSC_VER) || defined(__BORLANDC__)
static INLINE long lrintf(float f){
int i;
_asm{
fld f
fistp i
};
return i;
#ifdef _M_X64
return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f));
#else
int i;
_asm{
fld f
fistp i
};
return i;
#endif
}
#endif
#include "j2k_lib.h"
#include "opj_malloc.h"
#include "event.h"
#include "bio.h"
#include "cio.h"
#include "image.h"
@@ -123,9 +128,12 @@ static INLINE long lrintf(float f){
#include "int.h"
#include "fix.h"
#include "cidx_manager.h"
#include "indexbox_manager.h"
/* JPWL>> */
#ifdef USE_JPWL
#include "../jpwl/jpwl.h"
#include "./jpwl/jpwl.h"
#endif /* USE_JPWL */
/* <<JPWL */

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Herv<EFBFBD> Drolon, FreeImage Team
* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
* All rights reserved.
*
@@ -69,7 +69,7 @@ Allocate memory aligned to a 16 byte boundry
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
*/
/* FIXME: These should be set with cmake tests, but we're currently not requiring use of cmake */
#ifdef WIN32
#ifdef _WIN32
/* Someone should tell the mingw people that their malloc.h ought to provide _mm_malloc() */
#ifdef __GNUC__
#include <mm_malloc.h>
@@ -80,11 +80,13 @@ Allocate memory aligned to a 16 byte boundry
#define HAVE_MM_MALLOC
#endif
#endif
#else /* Not WIN32 */
#else /* Not _WIN32 */
#if defined(__sun)
#define HAVE_MEMALIGN
#elif defined(__FreeBSD__)
#define HAVE_POSIX_MEMALIGN
/* Linux x86_64 and OSX always align allocations to 16 bytes */
#elif !defined(__amd64__) && !defined(__APPLE__)
#elif !defined(__amd64__) && !defined(__APPLE__) && !defined(_AIX)
#define HAVE_MEMALIGN
#include <malloc.h>
#endif
@@ -130,22 +132,22 @@ Allocate memory aligned to a 16 byte boundry
/**
Reallocate memory blocks.
@param memblock Pointer to previously allocated memory block
@param size New size in bytes
@param m Pointer to previously allocated memory block
@param s New size in bytes
@return Returns a void pointer to the reallocated (and possibly moved) memory block
*/
#ifdef ALLOC_PERF_OPT
void * OPJ_CALLCONV opj_realloc(void * _Memory, size_t NewSize);
void * OPJ_CALLCONV opj_realloc(void * m, size_t s);
#else
#define opj_realloc(m, s) realloc(m, s)
#endif
/**
Deallocates or frees a memory block.
@param memblock Previously allocated memory block to be freed
@param m Previously allocated memory block to be freed
*/
#ifdef ALLOC_PERF_OPT
void OPJ_CALLCONV opj_free(void * _Memory);
void OPJ_CALLCONV opj_free(void * m);
#else
#define opj_free(m) free(m)
#endif

View File

@@ -0,0 +1,170 @@
/*
* $Id: phix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
*
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2011, Professor Benoit Macq
* Copyright (c) 2003-2004, Yannick Verschueren
* Copyright (c) 2010-2011, Kaori Hagihara
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*! \file
* \brief Modification of jpip.c from 2KAN indexer
*/
#include <stdlib.h>
#include <math.h>
#include "opj_includes.h"
/*
* Write faix box of phix
*
* @param[in] coff offset of j2k codestream
* @param[in] compno component number
* @param[in] cstr_info codestream information
* @param[in] EPHused true if if EPH option used
* @param[in] j2klen length of j2k codestream
* @param[in] cio file output handle
* @return length of faix box
*/
int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
int write_phix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
{
int len, lenp=0, compno, i;
opj_jp2_box_t *box;
box = (opj_jp2_box_t *)opj_calloc( cstr_info.numcomps, sizeof(opj_jp2_box_t));
for( i=0;i<2;i++){
if (i) cio_seek( cio, lenp);
lenp = cio_tell( cio);
cio_skip( cio, 4); /* L [at the end] */
cio_write( cio, JPIP_PHIX, 4); /* PHIX */
write_manf( i, cstr_info.numcomps, box, cio);
for( compno=0; compno<cstr_info.numcomps; compno++){
box[compno].length = write_phixfaix( coff, compno, cstr_info, EPHused, j2klen, cio);
box[compno].type = JPIP_FAIX;
}
len = cio_tell( cio)-lenp;
cio_seek( cio, lenp);
cio_write( cio, len, 4); /* L */
cio_seek( cio, lenp+len);
}
opj_free(box);
return len;
}
int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
{
int len, lenp, tileno, version, i, nmax, size_of_coding; /* 4 or 8 */
opj_tile_info_t *tile_Idx;
opj_packet_info_t packet;
int resno, precno, layno, num_packet;
int numOfres, numOfprec, numOflayers;
packet.end_ph_pos = packet.start_pos = -1;
(void)EPHused; /* unused ? */
if( j2klen > pow( 2.0, 32)){
size_of_coding = 8;
version = 1;
}
else{
size_of_coding = 4;
version = 0;
}
lenp = cio_tell( cio);
cio_skip( cio, 4); /* L [at the end] */
cio_write( cio, JPIP_FAIX, 4); /* FAIX */
cio_write( cio, version,1); /* Version 0 = 4 bytes */
nmax = 0;
for( i=0; i<=cstr_info.numdecompos[compno]; i++)
nmax += cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers;
cio_write( cio, nmax, size_of_coding); /* NMAX */
cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */
for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){
tile_Idx = &cstr_info.tile[ tileno];
num_packet = 0;
numOfres = cstr_info.numdecompos[compno] + 1;
for( resno=0; resno<numOfres ; resno++){
numOfprec = tile_Idx->pw[resno]*tile_Idx->ph[resno];
for( precno=0; precno<numOfprec; precno++){
numOflayers = cstr_info.numlayers;
for( layno=0; layno<numOflayers; layno++){
switch ( cstr_info.prog){
case LRCP:
packet = tile_Idx->packet[ ((layno*numOfres+resno)*cstr_info.numcomps+compno)*numOfprec+precno];
break;
case RLCP:
packet = tile_Idx->packet[ ((resno*numOflayers+layno)*cstr_info.numcomps+compno)*numOfprec+precno];
break;
case RPCL:
packet = tile_Idx->packet[ ((resno*numOfprec+precno)*cstr_info.numcomps+compno)*numOflayers+layno];
break;
case PCRL:
packet = tile_Idx->packet[ ((precno*cstr_info.numcomps+compno)*numOfres+resno)*numOflayers + layno];
break;
case CPRL:
packet = tile_Idx->packet[ ((compno*numOfprec+precno)*numOfres+resno)*numOflayers + layno];
break;
default:
fprintf( stderr, "failed to ppix indexing\n");
}
cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */
cio_write( cio, packet.end_ph_pos-packet.start_pos+1, size_of_coding); /* length */
num_packet++;
}
}
}
/* PADDING */
while( num_packet < nmax){
cio_write( cio, 0, size_of_coding); /* start position */
cio_write( cio, 0, size_of_coding); /* length */
num_packet++;
}
}
len = cio_tell( cio)-lenp;
cio_seek( cio, lenp);
cio_write( cio, len, 4); /* L */
cio_seek( cio, lenp+len);
return len;
}

View File

@@ -43,31 +43,31 @@ Get next packet in layer-resolution-component-precinct order.
@param pi packet iterator to modify
@return returns false if pi pointed to the last packet or else returns true
*/
static bool pi_next_lrcp(opj_pi_iterator_t * pi);
static opj_bool pi_next_lrcp(opj_pi_iterator_t * pi);
/**
Get next packet in resolution-layer-component-precinct order.
@param pi packet iterator to modify
@return returns false if pi pointed to the last packet or else returns true
*/
static bool pi_next_rlcp(opj_pi_iterator_t * pi);
static opj_bool pi_next_rlcp(opj_pi_iterator_t * pi);
/**
Get next packet in resolution-precinct-component-layer order.
@param pi packet iterator to modify
@return returns false if pi pointed to the last packet or else returns true
*/
static bool pi_next_rpcl(opj_pi_iterator_t * pi);
static opj_bool pi_next_rpcl(opj_pi_iterator_t * pi);
/**
Get next packet in precinct-component-resolution-layer order.
@param pi packet iterator to modify
@return returns false if pi pointed to the last packet or else returns true
*/
static bool pi_next_pcrl(opj_pi_iterator_t * pi);
static opj_bool pi_next_pcrl(opj_pi_iterator_t * pi);
/**
Get next packet in component-precinct-resolution-layer order.
@param pi packet iterator to modify
@return returns false if pi pointed to the last packet or else returns true
*/
static bool pi_next_cprl(opj_pi_iterator_t * pi);
static opj_bool pi_next_cprl(opj_pi_iterator_t * pi);
/*@}*/
@@ -79,7 +79,7 @@ static bool pi_next_cprl(opj_pi_iterator_t * pi);
==========================================================
*/
static bool pi_next_lrcp(opj_pi_iterator_t * pi) {
static opj_bool pi_next_lrcp(opj_pi_iterator_t * pi) {
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
long index = 0;
@@ -108,7 +108,7 @@ static bool pi_next_lrcp(opj_pi_iterator_t * pi) {
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
if (!pi->include[index]) {
pi->include[index] = 1;
return true;
return OPJ_TRUE;
}
LABEL_SKIP:;
}
@@ -116,10 +116,10 @@ LABEL_SKIP:;
}
}
return false;
return OPJ_FALSE;
}
static bool pi_next_rlcp(opj_pi_iterator_t * pi) {
static opj_bool pi_next_rlcp(opj_pi_iterator_t * pi) {
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
long index = 0;
@@ -147,7 +147,7 @@ static bool pi_next_rlcp(opj_pi_iterator_t * pi) {
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
if (!pi->include[index]) {
pi->include[index] = 1;
return true;
return OPJ_TRUE;
}
LABEL_SKIP:;
}
@@ -155,10 +155,10 @@ LABEL_SKIP:;
}
}
return false;
return OPJ_FALSE;
}
static bool pi_next_rpcl(opj_pi_iterator_t * pi) {
static opj_bool pi_next_rpcl(opj_pi_iterator_t * pi) {
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
long index = 0;
@@ -229,7 +229,7 @@ if (!pi->tp_on){
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
if (!pi->include[index]) {
pi->include[index] = 1;
return true;
return OPJ_TRUE;
}
LABEL_SKIP:;
}
@@ -238,10 +238,10 @@ LABEL_SKIP:;
}
}
return false;
return OPJ_FALSE;
}
static bool pi_next_pcrl(opj_pi_iterator_t * pi) {
static opj_bool pi_next_pcrl(opj_pi_iterator_t * pi) {
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
long index = 0;
@@ -310,7 +310,7 @@ static bool pi_next_pcrl(opj_pi_iterator_t * pi) {
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
if (!pi->include[index]) {
pi->include[index] = 1;
return true;
return OPJ_TRUE;
}
LABEL_SKIP:;
}
@@ -319,10 +319,10 @@ LABEL_SKIP:;
}
}
return false;
return OPJ_FALSE;
}
static bool pi_next_cprl(opj_pi_iterator_t * pi) {
static opj_bool pi_next_cprl(opj_pi_iterator_t * pi) {
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
long index = 0;
@@ -389,7 +389,7 @@ static bool pi_next_cprl(opj_pi_iterator_t * pi) {
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
if (!pi->include[index]) {
pi->include[index] = 1;
return true;
return OPJ_TRUE;
}
LABEL_SKIP:;
}
@@ -398,7 +398,7 @@ LABEL_SKIP:;
}
}
return false;
return OPJ_FALSE;
}
/*
@@ -707,7 +707,7 @@ void pi_destroy(opj_pi_iterator_t *pi, opj_cp_t *cp, int tileno) {
}
}
bool pi_next(opj_pi_iterator_t * pi) {
opj_bool pi_next(opj_pi_iterator_t * pi) {
switch (pi->poc.prg) {
case LRCP:
return pi_next_lrcp(pi);
@@ -720,13 +720,13 @@ bool pi_next(opj_pi_iterator_t * pi) {
case CPRL:
return pi_next_cprl(pi);
case PROG_UNKNOWN:
return false;
return OPJ_FALSE;
}
return false;
return OPJ_FALSE;
}
bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp){
opj_bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp){
char prog[4];
int i;
int incr_top=1,resetX=0;
@@ -748,7 +748,7 @@ bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,
case RPCL: strncpy(prog, "RPCL",4);
break;
case PROG_UNKNOWN:
return true;
return OPJ_TRUE;
}
if(!(cp->tp_on && ((!cp->cinema && (t2_mode == FINAL_PASS)) || cp->cinema))){
@@ -958,6 +958,6 @@ bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,
}
}
}
return false;
return OPJ_FALSE;
}

View File

@@ -115,12 +115,14 @@ Modify the packet iterator for enabling tile part generation
@param pi Handle to the packet iterator generated in pi_initialise_encode
@param cp Coding parameters
@param tileno Number that identifies the tile for which to list the packets
@param pino Iterator index for pi
@param tpnum Tile part number of the current tile
@param tppos The position of the tile part flag in the progression order
@param t2_mode If == 0 In Threshold calculation ,If == 1 Final pass
@param cur_totnum_tp The total number of tile parts in the current tile
@return Returns true if an error is detected
*/
bool pi_create_encode(opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp);
opj_bool pi_create_encode(opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp);
/**
Create a packet iterator for Decoder
@param image Raw image for which the packets will be listed
@@ -145,7 +147,7 @@ Modify the packet iterator to point to the next packet
@param pi Packet iterator to modify
@return Returns false if pi pointed to the last packet or else returns true
*/
bool pi_next(opj_pi_iterator_t * pi);
opj_bool pi_next(opj_pi_iterator_t * pi);
/* ----------------------------------------------------------------------- */
/*@}*/

View File

@@ -0,0 +1,173 @@
/*
* $Id: ppix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
*
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2011, Professor Benoit Macq
* Copyright (c) 2003-2004, Yannick Verschueren
* Copyright (c) 2010-2011, Kaori Hagihara
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*! \file
* \brief Modification of jpip.c from 2KAN indexer
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "opj_includes.h"
/*
* Write faix box of ppix
*
* @param[in] coff offset of j2k codestream
* @param[in] compno component number
* @param[in] cstr_info codestream information
* @param[in] EPHused true if if EPH option used
* @param[in] j2klen length of j2k codestream
* @param[in] cio file output handle
* @return length of faix box
*/
int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
int write_ppix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
{
int len, lenp, compno, i;
opj_jp2_box_t *box;
/* printf("cstr_info.packno %d\n", cstr_info.packno); //NMAX? */
lenp = -1;
box = (opj_jp2_box_t *)opj_calloc( cstr_info.numcomps, sizeof(opj_jp2_box_t));
for (i=0;i<2;i++){
if (i) cio_seek( cio, lenp);
lenp = cio_tell( cio);
cio_skip( cio, 4); /* L [at the end] */
cio_write( cio, JPIP_PPIX, 4); /* PPIX */
write_manf( i, cstr_info.numcomps, box, cio);
for (compno=0; compno<cstr_info.numcomps; compno++){
box[compno].length = write_ppixfaix( coff, compno, cstr_info, EPHused, j2klen, cio);
box[compno].type = JPIP_FAIX;
}
len = cio_tell( cio)-lenp;
cio_seek( cio, lenp);
cio_write( cio, len, 4); /* L */
cio_seek( cio, lenp+len);
}
opj_free(box);
return len;
}
int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
{
int len, lenp, tileno, version, i, nmax, size_of_coding; /* 4 or 8*/
opj_tile_info_t *tile_Idx;
opj_packet_info_t packet;
int resno, precno, layno, num_packet;
int numOfres, numOfprec, numOflayers;
packet.end_pos = packet.end_ph_pos = packet.start_pos = -1;
(void)EPHused; /* unused ? */
if( j2klen > pow( 2.0, 32)){
size_of_coding = 8;
version = 1;
}
else{
size_of_coding = 4;
version = 0;
}
lenp = cio_tell( cio);
cio_skip( cio, 4); /* L [at the end] */
cio_write( cio, JPIP_FAIX, 4); /* FAIX */
cio_write( cio, version, 1); /* Version 0 = 4 bytes */
nmax = 0;
for( i=0; i<=cstr_info.numdecompos[compno]; i++)
nmax += cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers;
cio_write( cio, nmax, size_of_coding); /* NMAX */
cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */
for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){
tile_Idx = &cstr_info.tile[ tileno];
num_packet=0;
numOfres = cstr_info.numdecompos[compno] + 1;
for( resno=0; resno<numOfres ; resno++){
numOfprec = tile_Idx->pw[resno]*tile_Idx->ph[resno];
for( precno=0; precno<numOfprec; precno++){
numOflayers = cstr_info.numlayers;
for( layno=0; layno<numOflayers; layno++){
switch ( cstr_info.prog){
case LRCP:
packet = tile_Idx->packet[ ((layno*numOfres+resno)*cstr_info.numcomps+compno)*numOfprec+precno];
break;
case RLCP:
packet = tile_Idx->packet[ ((resno*numOflayers+layno)*cstr_info.numcomps+compno)*numOfprec+precno];
break;
case RPCL:
packet = tile_Idx->packet[ ((resno*numOfprec+precno)*cstr_info.numcomps+compno)*numOflayers+layno];
break;
case PCRL:
packet = tile_Idx->packet[ ((precno*cstr_info.numcomps+compno)*numOfres+resno)*numOflayers + layno];
break;
case CPRL:
packet = tile_Idx->packet[ ((compno*numOfprec+precno)*numOfres+resno)*numOflayers + layno];
break;
default:
fprintf( stderr, "failed to ppix indexing\n");
}
cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */
cio_write( cio, packet.end_pos-packet.start_pos+1, size_of_coding); /* length */
num_packet++;
}
}
}
while( num_packet < nmax){ /* PADDING */
cio_write( cio, 0, size_of_coding); /* start position */
cio_write( cio, 0, size_of_coding); /* length */
num_packet++;
}
}
len = cio_tell( cio)-lenp;
cio_seek( cio, lenp);
cio_write( cio, len, 4); /* L */
cio_seek( cio, lenp+len);
return len;
}

View File

@@ -123,20 +123,20 @@ static void t1_enc_refpass_step(
/**
Decode refinement pass
*/
static void INLINE t1_dec_refpass_step_raw(
static INLINE void t1_dec_refpass_step_raw(
opj_t1_t *t1,
flag_t *flagsp,
int *datap,
int poshalf,
int neghalf,
int vsc);
static void INLINE t1_dec_refpass_step_mqc(
static INLINE void t1_dec_refpass_step_mqc(
opj_t1_t *t1,
flag_t *flagsp,
int *datap,
int poshalf,
int neghalf);
static void INLINE t1_dec_refpass_step_mqc_vsc(
static INLINE void t1_dec_refpass_step_mqc_vsc(
opj_t1_t *t1,
flag_t *flagsp,
int *datap,
@@ -240,6 +240,7 @@ Encode 1 code-block
@param stepsize
@param cblksty Code-block style
@param numcomps
@param mct
@param tile
*/
static void t1_encode_cblk(
@@ -381,9 +382,10 @@ static INLINE void t1_dec_sigpass_step_raw(
int vsc)
{
int v, flag;
opj_raw_t *raw = t1->raw; /* RAW component */
OPJ_ARG_NOT_USED(orient);
flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp);
if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) {
if (raw_decode(raw)) {
@@ -822,9 +824,10 @@ static void t1_dec_clnpass_step_partial(
int oneplushalf)
{
int v, flag;
opj_mqc_t *mqc = t1->mqc; /* MQC component */
OPJ_ARG_NOT_USED(orient);
flag = *flagsp;
mqc_setcurctx(mqc, t1_getctxno_sc(flag));
v = mqc_decode(mqc) ^ t1_getspb(flag);
@@ -1115,7 +1118,7 @@ static double t1_getwmsedec(
return wmsedec;
}
static bool allocate_buffers(
static opj_bool allocate_buffers(
opj_t1_t *t1,
int w,
int h)
@@ -1127,7 +1130,7 @@ static bool allocate_buffers(
opj_aligned_free(t1->data);
t1->data = (int*) opj_aligned_malloc(datasize * sizeof(int));
if(!t1->data){
return false;
return OPJ_FALSE;
}
t1->datasize=datasize;
}
@@ -1140,7 +1143,7 @@ static bool allocate_buffers(
opj_aligned_free(t1->flags);
t1->flags = (flag_t*) opj_aligned_malloc(flagssize * sizeof(flag_t));
if(!t1->flags){
return false;
return OPJ_FALSE;
}
t1->flagssize=flagssize;
}
@@ -1149,7 +1152,7 @@ static bool allocate_buffers(
t1->w=w;
t1->h=h;
return true;
return OPJ_TRUE;
}
/** mod fixed_quality */
@@ -1425,6 +1428,7 @@ void t1_encode_cblks(
for (bandno = 0; bandno < res->numbands; ++bandno) {
opj_tcd_band_t* restrict band = &res->bands[bandno];
int bandconst = 8192 * 8192 / ((int) floor(band->stepsize * 8192));
for (precno = 0; precno < res->pw * res->ph; ++precno) {
opj_tcd_precinct_t *prc = &band->precincts[precno];
@@ -1475,7 +1479,7 @@ void t1_encode_cblks(
datap[(j * cblk_w) + i] =
fix_mul(
tmp,
8192 * 8192 / ((int) floor(band->stepsize * 8192))) >> (11 - T1_NMSEDEC_FRACBITS);
bandconst) >> (11 - T1_NMSEDEC_FRACBITS);
}
}
}
@@ -1586,6 +1590,7 @@ void t1_decode_cblks(
opj_free(cblk->segs);
} /* cblkno */
opj_free(precinct->cblks.dec);
precinct->cblks.dec = NULL;
} /* precno */
} /* bandno */
} /* resno */

View File

@@ -135,8 +135,8 @@ void t1_encode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp);
/**
Decode the code-blocks of a tile
@param t1 T1 handle
@param tile The tile to decode
@param tcp Tile coding parameters
@param tilec The tile to decode
@param tccp Tile coding parameters
*/
void t1_decode_cblks(opj_t1_t* t1, opj_tcd_tilecomp_t* tilec, opj_tccp_t* tccp);
/* ----------------------------------------------------------------------- */

View File

@@ -59,11 +59,12 @@ Encode a packet of a tile to a destination buffer
*/
static int t2_encode_packet(opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterator_t *pi, unsigned char *dest, int len, opj_codestream_info_t *cstr_info, int tileno);
/**
@param seg
@param cblk
@param index
@param cblksty
@param first
*/
static void t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int first);
static opj_bool t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int first);
/**
Decode a packet of a tile from a source buffer
@param t2 T2 handle
@@ -72,6 +73,7 @@ Decode a packet of a tile from a source buffer
@param tile Tile for which to write the packets
@param tcp Tile coding parameters
@param pi Packet identity
@param pack_info Packet information
@return
*/
static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile,
@@ -147,8 +149,8 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera
c[1] = 145;
c[2] = 0;
c[3] = 4;
c[4] = (tile->packno % 65536) / 256;
c[5] = (tile->packno % 65536) % 256;
c[4] = (unsigned char)((tile->packno % 65536) / 256);
c[5] = (unsigned char)((tile->packno % 65536) % 256);
c += 6;
}
/* </SOP> */
@@ -253,8 +255,8 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera
/* </EPH> */
/* << INDEX */
// End of packet header position. Currently only represents the distance to start of packet
// Will be updated later by incrementing with packet start value
/* End of packet header position. Currently only represents the distance to start of packet
// Will be updated later by incrementing with packet start value */
if(cstr_info && cstr_info->index_write) {
opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->packno];
info_PK->end_ph_pos = (int)(c - dest);
@@ -294,9 +296,17 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera
return (c - dest);
}
static void t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int first) {
static opj_bool t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int first) {
opj_tcd_seg_t* seg;
cblk->segs = (opj_tcd_seg_t*) opj_realloc(cblk->segs, (index + 1) * sizeof(opj_tcd_seg_t));
opj_tcd_seg_t* segs;
segs = (opj_tcd_seg_t*) opj_realloc(cblk->segs, (index + 1) * sizeof(opj_tcd_seg_t));
if (segs == NULL)
{
return OPJ_FALSE;
}
cblk->segs = segs;
seg = &cblk->segs[index];
seg->data = NULL;
seg->dataindex = 0;
@@ -314,6 +324,8 @@ static void t2_init_seg(opj_tcd_cblk_dec_t* cblk, int index, int cblksty, int fi
} else {
seg->maxpasses = 109;
}
return OPJ_TRUE;
}
static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile,
@@ -401,8 +413,8 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
}
/* << INDEX */
// End of packet header position. Currently only represents the distance to start of packet
// Will be updated later by incrementing with packet start value
/* End of packet header position. Currently only represents the distance to start of packet
// Will be updated later by incrementing with packet start value*/
if(pack_info) {
pack_info->end_ph_pos = (int)(c - src);
}
@@ -460,12 +472,22 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
cblk->numlenbits += increment;
segno = 0;
if (!cblk->numsegs) {
t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 1);
if (!t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 1))
{
opj_event_msg(t2->cinfo, EVT_ERROR, "Out of memory\n");
bio_destroy(bio);
return -999;
}
} else {
segno = cblk->numsegs - 1;
if (cblk->segs[segno].numpasses == cblk->segs[segno].maxpasses) {
++segno;
t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0);
if (!t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0))
{
opj_event_msg(t2->cinfo, EVT_ERROR, "Out of memory\n");
bio_destroy(bio);
return -999;
}
}
}
n = cblk->numnewpasses;
@@ -476,7 +498,12 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
n -= cblk->segs[segno].numnewpasses;
if (n > 0) {
++segno;
t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0);
if (!t2_init_seg(cblk, segno, tcp->tccps[compno].cblksty, 0))
{
opj_event_msg(t2->cinfo, EVT_ERROR, "Out of memory\n");
bio_destroy(bio);
return -999;
}
}
} while (n > 0);
}
@@ -494,14 +521,15 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
if (tcp->csty & J2K_CP_CSTY_EPH) {
if ((*hd) != 0xff || (*(hd + 1) != 0x92)) {
opj_event_msg(t2->cinfo, EVT_ERROR, "Expected EPH marker\n");
return -999;
} else {
hd += 2;
}
}
/* << INDEX */
// End of packet header position. Currently only represents the distance to start of packet
// Will be updated later by incrementing with packet start value
/* End of packet header position. Currently only represents the distance to start of packet
// Will be updated later by incrementing with packet start value*/
if(pack_info) {
pack_info->end_ph_pos = (int)(hd - src);
}
@@ -565,7 +593,7 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
#endif /* USE_JPWL */
cblk->data = (unsigned char*) opj_realloc(cblk->data, (cblk->len + seg->newlen) * sizeof(unsigned char*));
cblk->data = (unsigned char*) opj_realloc(cblk->data, (cblk->len + seg->newlen) * sizeof(unsigned char));
memcpy(cblk->data + cblk->len, c, seg->newlen);
if (seg->numpasses == 0) {
seg->data = &cblk->data;
@@ -659,8 +687,8 @@ int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlaye
info_PK->start_pos = ((cp->tp_on | tcp->POC)&& info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->packno - 1].end_pos + 1;
}
info_PK->end_pos = info_PK->start_pos + e - 1;
info_PK->end_ph_pos += info_PK->start_pos - 1; // End of packet header which now only represents the distance
// to start of packet is incremented by value of start of packet
info_PK->end_ph_pos += info_PK->start_pos - 1; /* End of packet header which now only represents the distance
// to start of packet is incremented by value of start of packet*/
}
cstr_info->packno++;
@@ -711,7 +739,11 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj
} else {
e = 0;
}
if(e == -999)
{
pi_destroy(pi, cp, tileno);
return -999;
}
/* progression in resolution */
image->comps[pi[pino].compno].resno_decoded =
(e > 0) ?
@@ -725,8 +757,9 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj
opj_packet_info_t *info_PK = &info_TL->packet[cstr_info->packno];
if (!cstr_info->packno) {
info_PK->start_pos = info_TL->end_header + 1;
} else if (info_TL->packet[cstr_info->packno-1].end_pos >= (int)cstr_info->tile[tileno].tp[curtp].tp_end_pos){ // New tile part
info_TL->tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; // Number of packets in previous tile-part
} else if (info_TL->packet[cstr_info->packno-1].end_pos >= (int)cstr_info->tile[tileno].tp[curtp].tp_end_pos){ /* New tile part*/
info_TL->tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; /* Number of packets in previous tile-part*/
info_TL->tp[curtp].tp_start_pack = tp_start_packno;
tp_start_packno = cstr_info->packno;
curtp++;
info_PK->start_pos = cstr_info->tile[tileno].tp[curtp].tp_end_header+1;
@@ -734,8 +767,8 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj
info_PK->start_pos = (cp->tp_on && info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->packno - 1].end_pos + 1;
}
info_PK->end_pos = info_PK->start_pos + e - 1;
info_PK->end_ph_pos += info_PK->start_pos - 1; // End of packet header which now only represents the distance
// to start of packet is incremented by value of start of packet
info_PK->end_ph_pos += info_PK->start_pos - 1; /* End of packet header which now only represents the distance
// to start of packet is incremented by value of start of packet*/
cstr_info->packno++;
}
/* << INDEX */
@@ -749,7 +782,8 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj
}
/* INDEX >> */
if(cstr_info) {
cstr_info->tile[tileno].tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; // Number of packets in last tile-part
cstr_info->tile[tileno].tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; /* Number of packets in last tile-part*/
cstr_info->tile[tileno].tp[curtp].tp_start_pack = tp_start_packno;
}
/* << INDEX */

View File

@@ -67,6 +67,7 @@ Encode the packets of a tile to a destination buffer
@param cstr_info Codestream information structure
@param tpnum Tile part number of the current tile
@param tppos The position of the tile part flag in the progression order
@param pino
@param t2_mode If == 0 In Threshold calculation ,If == 1 Final pass
@param cur_totnum_tp The total number of tile parts in the current tile
*/
@@ -78,6 +79,7 @@ Decode the packets of a tile from a source buffer
@param len length of the source buffer
@param tileno number that identifies the tile for which to decode the packets
@param tile tile for which to decode the packets
@param cstr_info Codestream information structure
*/
int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj_tcd_tile_t *tile, opj_codestream_info_t *cstr_info);

View File

@@ -30,10 +30,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#define _ISOC99_SOURCE /* lrintf is C99 */
#include "opj_includes.h"
void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t * img) {
int tileno, compno, resno, bandno, precno;//, cblkno;
int tileno, compno, resno, bandno, precno;/*, cblkno;*/
fprintf(fd, "image {\n");
fprintf(fd, " tw=%d, th=%d x0=%d x1=%d y0=%d y1=%d\n",
@@ -290,6 +291,7 @@ void tcd_malloc_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int c
for (i = 0; i < res->pw * res->ph * 3; i++) {
band->precincts[i].imsbtree = NULL;
band->precincts[i].incltree = NULL;
band->precincts[i].cblks.enc = NULL;
}
for (precno = 0; precno < res->pw * res->ph; precno++) {
@@ -332,8 +334,10 @@ void tcd_malloc_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int c
cblk->y0 = int_max(cblkystart, prc->y0);
cblk->x1 = int_min(cblkxend, prc->x1);
cblk->y1 = int_min(cblkyend, prc->y1);
cblk->data = (unsigned char*) opj_calloc(8192+2, sizeof(unsigned char));
cblk->data = (unsigned char*) opj_calloc(9728+2, sizeof(unsigned char));
/* FIXME: mqc_init_enc and mqc_byteout underrun the buffer if we don't do this. Why? */
cblk->data[0] = 0;
cblk->data[1] = 0;
cblk->data += 2;
cblk->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof(opj_tcd_layer_t));
cblk->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(opj_tcd_pass_t));
@@ -593,6 +597,8 @@ void tcd_init_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int cur
cblk->y1 = int_min(cblkyend, prc->y1);
cblk->data = (unsigned char*) opj_calloc(8192+2, sizeof(unsigned char));
/* FIXME: mqc_init_enc and mqc_byteout underrun the buffer if we don't do this. Why? */
cblk->data[0] = 0;
cblk->data[1] = 0;
cblk->data += 2;
cblk->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof(opj_tcd_layer_t));
cblk->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(opj_tcd_pass_t));
@@ -613,7 +619,7 @@ void tcd_malloc_decode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp) {
tcd->image = image;
tcd->tcd_image->tw = cp->tw;
tcd->tcd_image->th = cp->th;
tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_malloc(cp->tw * cp->th * sizeof(opj_tcd_tile_t));
tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_calloc(cp->tw * cp->th, sizeof(opj_tcd_tile_t));
/*
Allocate place to store the decoded data = final image
@@ -656,7 +662,7 @@ void tcd_malloc_decode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp) {
tilec->y1 = int_ceildiv(tile->y1, image->comps[i].dy);
x0 = j == 0 ? tilec->x0 : int_min(x0, (unsigned int) tilec->x0);
y0 = j == 0 ? tilec->y0 : int_min(y0, (unsigned int) tilec->x0);
y0 = j == 0 ? tilec->y0 : int_min(y0, (unsigned int) tilec->y0);
x1 = j == 0 ? tilec->x1 : int_max(x1, (unsigned int) tilec->x1);
y1 = j == 0 ? tilec->y1 : int_max(y1, (unsigned int) tilec->y1);
}
@@ -676,6 +682,8 @@ void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp,
opj_tcp_t *tcp;
opj_tcd_tile_t *tile;
OPJ_ARG_NOT_USED(cstr_info);
tcd->cp = cp;
tcp = &(cp->tcps[cp->tileno[tileno]]);
@@ -687,6 +695,12 @@ void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp,
opj_tccp_t *tccp = &tcp->tccps[compno];
opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
if (tccp->numresolutions <= 0)
{
cp->tileno[tileno] = -1;
return;
}
/* border of each tile component (global) */
tilec->x0 = int_ceildiv(tile->x0, image->comps[compno].dx);
tilec->y0 = int_ceildiv(tile->y0, image->comps[compno].dy);
@@ -997,7 +1011,7 @@ void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final) {
}
}
bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) {
opj_bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) {
int compno, resno, bandno, precno, cblkno, passno, layno;
double min, max;
double cumdisto[100]; /* fixed_quality */
@@ -1149,7 +1163,7 @@ bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestre
}
if (!success) {
return false;
return OPJ_FALSE;
}
if(cstr_info) { /* Threshold for Marcela Index */
@@ -1161,7 +1175,7 @@ bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestre
cumdisto[layno] = (layno == 0) ? tcd_tile->distolayer[0] : (cumdisto[layno - 1] + tcd_tile->distolayer[layno]);
}
return true;
return OPJ_TRUE;
}
int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) {
@@ -1313,7 +1327,7 @@ int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, op
return l;
}
bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info) {
opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info) {
int l;
int compno;
int eof = 0;
@@ -1349,7 +1363,7 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op
}
else {
cstr_info->tile[tileno].pdx[resno] = 15;
cstr_info->tile[tileno].pdx[resno] = 15;
cstr_info->tile[tileno].pdy[resno] = 15;
}
}
}
@@ -1373,14 +1387,24 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op
t1_time = opj_clock(); /* time needed to decode a tile */
t1 = t1_create(tcd->cinfo);
if (t1 == NULL)
{
opj_event_msg(tcd->cinfo, EVT_ERROR, "Out of memory\n");
t1_destroy(t1);
return OPJ_FALSE;
}
for (compno = 0; compno < tile->numcomps; ++compno) {
opj_tcd_tilecomp_t* tilec = &tile->comps[compno];
/* The +3 is headroom required by the vectorized DWT */
tilec->data = (int*) opj_aligned_malloc((((tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0))+3) * sizeof(int));
if(tilec->data)
t1_decode_cblks(t1, tilec, &tcd->tcp->tccps[compno]);
else
opj_event_msg(tcd->cinfo, EVT_ERROR, "tcd_decode: tile size invalid\n");
if (tilec->data == NULL)
{
opj_event_msg(tcd->cinfo, EVT_ERROR, "Out of memory\n");
return OPJ_FALSE;
}
t1_decode_cblks(t1, tilec, &tcd->tcp->tccps[compno]);
}
t1_destroy(t1);
t1_time = opj_clock() - t1_time;
@@ -1394,18 +1418,20 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op
int numres2decode;
if (tcd->cp->reduce != 0) {
tcd->image->comps[compno].resno_decoded =
tile->comps[compno].numresolutions - tcd->cp->reduce - 1;
if (tcd->image->comps[compno].resno_decoded < 0) {
if ( tile->comps[compno].numresolutions < ( tcd->cp->reduce - 1 ) ) {
opj_event_msg(tcd->cinfo, EVT_ERROR, "Error decoding tile. The number of resolutions to remove [%d+1] is higher than the number "
" of resolutions in the original codestream [%d]\nModify the cp_reduce parameter.\n", tcd->cp->reduce, tile->comps[compno].numresolutions);
return false;
" of resolutions in the original codestream [%d]\nModify the cp_reduce parameter.\n", tcd->cp->reduce, tile->comps[compno].numresolutions);
return OPJ_FALSE;
}
else {
tcd->image->comps[compno].resno_decoded =
tile->comps[compno].numresolutions - tcd->cp->reduce - 1;
}
}
if(!tilec->data) {
opj_event_msg(tcd->cinfo, EVT_ERROR, "Error decoding tile. null data\n");
return false;
opj_event_msg(tcd->cinfo, EVT_ERROR, "Error decoding tile. null data\n");
return OPJ_FALSE;
}
numres2decode = tcd->image->comps[compno].resno_decoded + 1;
@@ -1424,18 +1450,23 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op
if (tcd->tcp->mct) {
int n = (tile->comps[0].x1 - tile->comps[0].x0) * (tile->comps[0].y1 - tile->comps[0].y0);
if (tcd->tcp->tccps[0].qmfbid == 1) {
mct_decode(
tile->comps[0].data,
tile->comps[1].data,
tile->comps[2].data,
n);
} else {
mct_decode_real(
(float*)tile->comps[0].data,
(float*)tile->comps[1].data,
(float*)tile->comps[2].data,
n);
if (tile->numcomps >= 3 ){
if (tcd->tcp->tccps[0].qmfbid == 1) {
mct_decode(
tile->comps[0].data,
tile->comps[1].data,
tile->comps[2].data,
n);
} else {
mct_decode_real(
(float*)tile->comps[0].data,
(float*)tile->comps[1].data,
(float*)tile->comps[2].data,
n);
}
} else{
opj_event_msg(tcd->cinfo, EVT_WARNING,"Number of components (%d) is inconsistent with a MCT. Skip the MCT step.\n",tile->numcomps);
}
}
@@ -1459,6 +1490,11 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op
if(!imagec->data){
imagec->data = (int*) opj_malloc(imagec->w * imagec->h * sizeof(int));
}
if (!imagec->data)
{
opj_event_msg(tcd->cinfo, EVT_ERROR, "Out of memory\n");
return OPJ_FALSE;
}
if(tcd->tcp->tccps[compno].qmfbid == 1) {
for(j = res->y0; j < res->y1; ++j) {
for(i = res->x0; i < res->x1; ++i) {
@@ -1484,40 +1520,59 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op
opj_event_msg(tcd->cinfo, EVT_INFO, "- tile decoded in %f s\n", tile_time);
if (eof) {
return false;
return OPJ_FALSE;
}
return true;
return OPJ_TRUE;
}
void tcd_free_decode(opj_tcd_t *tcd) {
opj_tcd_image_t *tcd_image = tcd->tcd_image;
int i = 0;
for (i = 0; i < tcd_image->tw * tcd_image->th; i++)
{
tcd_free_decode_tile(tcd, i);
}
opj_free(tcd_image->tiles);
}
void tcd_free_decode_tile(opj_tcd_t *tcd, int tileno) {
int compno,resno,bandno,precno;
int compno,resno,bandno,precno,cblkno;
opj_tcd_image_t *tcd_image = tcd->tcd_image;
opj_tcd_tile_t *tile = &tcd_image->tiles[tileno];
for (compno = 0; compno < tile->numcomps; compno++) {
opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
for (resno = 0; resno < tilec->numresolutions; resno++) {
opj_tcd_resolution_t *res = &tilec->resolutions[resno];
for (bandno = 0; bandno < res->numbands; bandno++) {
opj_tcd_band_t *band = &res->bands[bandno];
for (precno = 0; precno < res->ph * res->pw; precno++) {
opj_tcd_precinct_t *prec = &band->precincts[precno];
if (prec->imsbtree != NULL) tgt_destroy(prec->imsbtree);
if (prec->incltree != NULL) tgt_destroy(prec->incltree);
if (tile->comps != NULL) {
for (compno = 0; compno < tile->numcomps; compno++) {
opj_tcd_tilecomp_t *tilec = &tile->comps[compno];
for (resno = 0; resno < tilec->numresolutions; resno++) {
opj_tcd_resolution_t *res = &tilec->resolutions[resno];
for (bandno = 0; bandno < res->numbands; bandno++) {
opj_tcd_band_t *band = &res->bands[bandno];
for (precno = 0; precno < res->ph * res->pw; precno++) {
opj_tcd_precinct_t *prec = &band->precincts[precno];
if (prec->cblks.dec != NULL) {
for (cblkno = 0; cblkno < prec->cw * prec->ch; ++cblkno) {
opj_tcd_cblk_dec_t* cblk = &prec->cblks.dec[cblkno];
opj_free(cblk->data);
opj_free(cblk->segs);
}
opj_free(prec->cblks.dec);
}
if (prec->imsbtree != NULL) tgt_destroy(prec->imsbtree);
if (prec->incltree != NULL) tgt_destroy(prec->incltree);
}
opj_free(band->precincts);
}
opj_free(band->precincts);
}
opj_free(tilec->resolutions);
}
opj_free(tilec->resolutions);
opj_free(tile->comps);
tile->comps = NULL;
}
opj_free(tile->comps);
}

View File

@@ -251,7 +251,7 @@ void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp,
void tcd_makelayer_fixed(opj_tcd_t *tcd, int layno, int final);
void tcd_rateallocate_fixed(opj_tcd_t *tcd);
void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final);
bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info);
opj_bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info);
/**
Encode a tile from the raw image into a buffer
@param tcd TCD handle
@@ -268,8 +268,9 @@ Decode a tile from a buffer into a raw image
@param src Source buffer
@param len Length of source buffer
@param tileno Number that identifies one of the tiles to be decoded
@param cstr_info Codestream information structure
*/
bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info);
opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info);
/**
Free the memory allocated for decoding
@param tcd TCD handle

View File

@@ -0,0 +1,120 @@
/*
* $Id: thix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
*
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2011, Professor Benoit Macq
* Copyright (c) 2003-2004, Yannick Verschueren
* Copyright (c) 2010-2011, Kaori Hagihara
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*! \file
* \brief Modification of jpip.c from 2KAN indexer
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "opj_includes.h"
/*
* Write tile-part headers mhix box
*
* @param[in] coff offset of j2k codestream
* @param[in] cstr_info codestream information
* @param[in] tileno tile number
* @param[in] cio file output handle
* @return length of mhix box
*/
int write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_cio_t *cio);
int write_thix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio)
{
int len, lenp, i;
int tileno;
opj_jp2_box_t *box;
lenp = 0;
box = (opj_jp2_box_t *)opj_calloc( cstr_info.tw*cstr_info.th, sizeof(opj_jp2_box_t));
for ( i = 0; i < 2 ; i++ ){
if (i)
cio_seek( cio, lenp);
lenp = cio_tell( cio);
cio_skip( cio, 4); /* L [at the end] */
cio_write( cio, JPIP_THIX, 4); /* THIX */
write_manf( i, cstr_info.tw*cstr_info.th, box, cio);
for (tileno = 0; tileno < cstr_info.tw*cstr_info.th; tileno++){
box[tileno].length = write_tilemhix( coff, cstr_info, tileno, cio);
box[tileno].type = JPIP_MHIX;
}
len = cio_tell( cio)-lenp;
cio_seek( cio, lenp);
cio_write( cio, len, 4); /* L */
cio_seek( cio, lenp+len);
}
opj_free(box);
return len;
}
int write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_cio_t *cio)
{
int i;
opj_tile_info_t tile;
opj_tp_info_t tp;
int len, lenp;
opj_marker_info_t *marker;
lenp = cio_tell( cio);
cio_skip( cio, 4); /* L [at the end] */
cio_write( cio, JPIP_MHIX, 4); /* MHIX */
tile = cstr_info.tile[tileno];
tp = tile.tp[0];
cio_write( cio, tp.tp_end_header-tp.tp_start_pos+1, 8); /* TLEN */
marker = cstr_info.tile[tileno].marker;
for( i=0; i<cstr_info.tile[tileno].marknum; i++){ /* Marker restricted to 1 apparition */
cio_write( cio, marker[i].type, 2);
cio_write( cio, 0, 2);
cio_write( cio, marker[i].pos-coff, 8);
cio_write( cio, marker[i].len, 2);
}
/* free( marker);*/
len = cio_tell( cio) - lenp;
cio_seek( cio, lenp);
cio_write( cio, len, 4); /* L */
cio_seek( cio, lenp+len);
return len;
}

View File

@@ -0,0 +1,153 @@
/*
* $Id: tpix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
*
* Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
* Copyright (c) 2002-2011, Professor Benoit Macq
* Copyright (c) 2003-2004, Yannick Verschueren
* Copyright (c) 2010-2011, Kaori Hagihara
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*! \file
* \brief Modification of jpip.c from 2KAN indexer
*/
#include <math.h>
#include "opj_includes.h"
#define MAX(a,b) ((a)>(b)?(a):(b))
/*
* Write faix box of tpix
*
* @param[in] coff offset of j2k codestream
* @param[in] compno component number
* @param[in] cstr_info codestream information
* @param[in] j2klen length of j2k codestream
* @param[in] cio file output handle
* @return length of faix box
*/
int write_tpixfaix( int coff, int compno, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio);
int write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio)
{
int len, lenp;
lenp = cio_tell( cio);
cio_skip( cio, 4); /* L [at the end] */
cio_write( cio, JPIP_TPIX, 4); /* TPIX */
write_tpixfaix( coff, 0, cstr_info, j2klen, cio);
len = cio_tell( cio)-lenp;
cio_seek( cio, lenp);
cio_write( cio, len, 4); /* L */
cio_seek( cio, lenp+len);
return len;
}
/*
* Get number of maximum tile parts per tile
*
* @param[in] cstr_info codestream information
* @return number of maximum tile parts per tile
*/
int get_num_max_tile_parts( opj_codestream_info_t cstr_info);
int write_tpixfaix( int coff, int compno, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio)
{
int len, lenp;
int i, j;
int Aux;
int num_max_tile_parts;
int size_of_coding; /* 4 or 8 */
opj_tp_info_t tp;
int version;
num_max_tile_parts = get_num_max_tile_parts( cstr_info);
if( j2klen > pow( 2.0, 32)){
size_of_coding = 8;
version = num_max_tile_parts == 1 ? 1:3;
}
else{
size_of_coding = 4;
version = num_max_tile_parts == 1 ? 0:2;
}
lenp = cio_tell( cio);
cio_skip( cio, 4); /* L [at the end] */
cio_write( cio, JPIP_FAIX, 4); /* FAIX */
cio_write( cio, version, 1); /* Version 0 = 4 bytes */
cio_write( cio, num_max_tile_parts, size_of_coding); /* NMAX */
cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */
for (i = 0; i < cstr_info.tw*cstr_info.th; i++){
for (j = 0; j < cstr_info.tile[i].num_tps; j++){
tp = cstr_info.tile[i].tp[j];
cio_write( cio, tp.tp_start_pos-coff, size_of_coding); /* start position */
cio_write( cio, tp.tp_end_pos-tp.tp_start_pos+1, size_of_coding); /* length */
if (version & 0x02){
if( cstr_info.tile[i].num_tps == 1 && cstr_info.numdecompos[compno] > 1)
Aux = cstr_info.numdecompos[compno] + 1;
else
Aux = j + 1;
cio_write( cio, Aux,4);
/*cio_write(img.tile[i].tile_parts[j].num_reso_AUX,4);*/ /* Aux_i,j : Auxiliary value */
/* fprintf(stderr,"AUX value %d\n",Aux);*/
}
/*cio_write(0,4);*/
}
/* PADDING */
while (j < num_max_tile_parts){
cio_write( cio, 0, size_of_coding); /* start position */
cio_write( cio, 0, size_of_coding); /* length */
if (version & 0x02)
cio_write( cio, 0,4); /* Aux_i,j : Auxiliary value */
j++;
}
}
len = cio_tell( cio)-lenp;
cio_seek( cio, lenp);
cio_write( cio, len, 4); /* L */
cio_seek( cio, lenp+len);
return len;
}
int get_num_max_tile_parts( opj_codestream_info_t cstr_info)
{
int num_max_tp = 0, i;
for( i=0; i<cstr_info.tw*cstr_info.th; i++)
num_max_tp = MAX( cstr_info.tile[i].num_tps, num_max_tp);
return num_max_tp;
}

View File

@@ -41,6 +41,7 @@
#include "lldir.h"
#include "llendianswizzle.h"
#include "llassetstorage.h"
#include "llrefcount.h"
#include "vorbis/codec.h"
#include "vorbis/vorbisfile.h"

View File

@@ -33,7 +33,7 @@
#ifndef LL_LLBVHCONSTS_H
#define LL_LLBVHCONSTS_H
const F32 MAX_ANIM_DURATION = 30.f;
const F32 MAX_ANIM_DURATION = 60.f;
typedef enum e_constraint_type
{

View File

@@ -193,21 +193,30 @@ void LLCharacter::requestStopMotion( LLMotion* motion)
//-----------------------------------------------------------------------------
// updateMotions()
//-----------------------------------------------------------------------------
static LLFastTimer::DeclareTimer FTM_UPDATE_ANIMATION("Update Animation");
static LLFastTimer::DeclareTimer FTM_UPDATE_HIDDEN_ANIMATION("Update Hidden Anim");
static LLFastTimer::DeclareTimer FTM_UPDATE_MOTIONS("Update Motions");
void LLCharacter::updateMotions(e_update_t update_type)
{
if (update_type == HIDDEN_UPDATE)
{
LLFastTimer t(FTM_UPDATE_HIDDEN_ANIMATION);
mMotionController.updateMotionsMinimal();
}
else
{
LLFastTimer t(FTM_UPDATE_ANIMATION);
// unpause if the number of outstanding pause requests has dropped to the initial one
if (mMotionController.isPaused() && mPauseRequest->getNumRefs() == 1)
{
mMotionController.unpauseAllMotions();
}
bool force_update = (update_type == FORCE_UPDATE);
mMotionController.updateMotions(force_update);
{
LLFastTimer t(FTM_UPDATE_MOTIONS);
mMotionController.updateMotions(force_update);
}
}
}

View File

@@ -547,6 +547,8 @@ void LLMotionController::updateIdleActiveMotions()
//-----------------------------------------------------------------------------
// updateMotionsByType()
//-----------------------------------------------------------------------------
static LLFastTimer::DeclareTimer FTM_MOTION_ON_UPDATE("Motion onUpdate");
void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_type)
{
BOOL update_result = TRUE;
@@ -704,7 +706,10 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty
}
// perform motion update
update_result = motionp->onUpdate(mAnimTime - motionp->mActivationTimestamp, last_joint_signature);
{
LLFastTimer t(FTM_MOTION_ON_UPDATE);
update_result = motionp->onUpdate(mAnimTime - motionp->mActivationTimestamp, last_joint_signature);
}
}
//**********************

View File

@@ -50,8 +50,7 @@ LLMultiGesture::LLMultiGesture()
mSteps(),
mPlaying(FALSE),
mCurrentStep(0),
mDoneCallback(NULL),
mCallbackData(NULL)
mDoneCallback(NULL)
{
reset();
}

View File

@@ -100,8 +100,7 @@ public:
// Timer for waiting
LLFrameTimer mWaitTimer;
void (*mDoneCallback)(LLMultiGesture* gesture, void* data);
void* mCallbackData;
boost::function<void (LLMultiGesture*)> mDoneCallback;
// Animations that we requested to start
std::set<LLUUID> mRequestedAnimIDs;

View File

@@ -16,6 +16,7 @@ include_directories(
set(llcommon_SOURCE_FILES
aiframetimer.cpp
aithreadid.cpp
imageids.cpp
indra_constants.cpp
llallocator.cpp
@@ -104,6 +105,8 @@ set(llcommon_HEADER_FILES
CMakeLists.txt
aiframetimer.h
airecursive.h
aithreadid.h
aithreadsafe.h
bitpack.h
ctype_workaround.h
@@ -254,6 +257,7 @@ set(llcommon_HEADER_FILES
set_source_files_properties(${llcommon_HEADER_FILES}
PROPERTIES HEADER_FILE_ONLY TRUE)
list(APPEND llcommon_SOURCE_FILES ${cwdebug_SOURCE_FILES})
list(APPEND llcommon_SOURCE_FILES ${llcommon_HEADER_FILES})
add_library (llcommon SHARED ${llcommon_SOURCE_FILES})
@@ -266,15 +270,9 @@ target_link_libraries(
${ZLIB_LIBRARIES}
${WINDOWS_LIBRARIES}
${Boost_REGEX_LIBRARY}
${CWDEBUG_LIBRARIES}
${CORESERVICES_LIBRARY}
)
if (LINUX)
# When linking with llcommon later, we do not want to link with cwdebug.a again.
set_property(TARGET llcommon PROPERTY LINK_INTERFACE_LIBRARIES "-lapr-1 -laprutil-1 -lz")
endif (LINUX)
if (DARWIN)
# Don't embed a full path in the library's install name
set_target_properties(

View File

@@ -0,0 +1,58 @@
/**
* @file airecursive.h
* @brief Declaration of AIRecursive.
*
* Copyright (c) 2013, Aleric Inglewood.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution.
*
* CHANGELOG
* and additional copyright holders.
*
* 05/01/2013
* Initial version, written by Aleric Inglewood @ SL
*/
#ifndef AI_RECURSIVE
#define AI_RECURSIVE
// Exception safe class to detect recursive calls.
//
// A unique, static bool must be passed (thread local if the function is
// called by more than one thread).
//
// Example usage:
//
// void f()
// {
// static bool recursive;
// if (recursive) return;
// AIRecursive dummy(flag);
// ...
// }
class AIRecursive {
private:
bool& mFlag;
public:
AIRecursive(bool& flag) : mFlag(flag) { mFlag = true; }
~AIRecursive() { mFlag = false; }
};
#endif // AI_RECURSIVE

View File

@@ -0,0 +1,78 @@
/**
* @file aithreadid.cpp
*
* Copyright (c) 2012, Aleric Inglewood.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution.
*
* CHANGELOG
* and additional copyright holders.
*
* 08/08/2012
* - Initial version, written by Aleric Inglewood @ SL
*/
#include <iostream>
#include <iomanip>
#include "aithreadid.h"
AIThreadID const AIThreadID::sNone(AIThreadID::none);
apr_os_thread_t AIThreadID::sMainThreadID;
apr_os_thread_t const AIThreadID::undefinedID = (apr_os_thread_t)-1;
#ifndef LL_DARWIN
apr_os_thread_t ll_thread_local AIThreadID::lCurrentThread;
#endif
void AIThreadID::set_main_thread_id(void)
{
sMainThreadID = apr_os_thread_current();
}
void AIThreadID::set_current_thread_id(void)
{
#ifndef LL_DARWIN
lCurrentThread = apr_os_thread_current();
#endif
}
#ifndef LL_DARWIN
void AIThreadID::reset(void)
{
mID = lCurrentThread;
}
bool AIThreadID::equals_current_thread(void) const
{
return apr_os_thread_equal(mID, lCurrentThread);
}
bool AIThreadID::in_main_thread(void)
{
return apr_os_thread_equal(lCurrentThread, sMainThreadID);
}
apr_os_thread_t AIThreadID::getCurrentThread(void)
{
return lCurrentThread;
}
#endif
std::ostream& operator<<(std::ostream& os, AIThreadID const& id)
{
return os << id.mID;
}

View File

@@ -0,0 +1,94 @@
/**
* @file aithreadid.h
* @brief Declaration of AIThreadID.
*
* Copyright (c) 2012, Aleric Inglewood.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution.
*
* CHANGELOG
* and additional copyright holders.
*
* 08/08/2012
* Initial version, written by Aleric Inglewood @ SL
*/
#ifndef AI_THREAD_ID
#define AI_THREAD_ID
#include <apr_portable.h> // apr_os_thread_t, apr_os_thread_current(), apr_os_thread_equal().
#include <iosfwd> // std::ostream.
#include "llpreprocessor.h" // LL_COMMON_API, LL_COMMON_API_TLS
// Lightweight wrapper around apr_os_thread_t.
// This class introduces no extra assembly code after optimization; it's only intend is to provide type-safety.
class AIThreadID
{
private:
apr_os_thread_t mID;
static LL_COMMON_API apr_os_thread_t sMainThreadID;
static LL_COMMON_API apr_os_thread_t const undefinedID;
#ifndef LL_DARWIN
static ll_thread_local apr_os_thread_t lCurrentThread;
#endif
public:
static LL_COMMON_API AIThreadID const sNone;
enum undefined_thread_t { none };
public:
AIThreadID(void) : mID(apr_os_thread_current()) { }
explicit AIThreadID(undefined_thread_t) : mID(undefinedID) { } // Used for sNone.
AIThreadID(AIThreadID const& id) : mID(id.mID) { }
AIThreadID& operator=(AIThreadID const& id) { mID = id.mID; return *this; }
bool is_main_thread(void) const { return apr_os_thread_equal(mID, sMainThreadID); }
bool is_no_thread(void) const { return apr_os_thread_equal(mID, sNone.mID); }
friend LL_COMMON_API bool operator==(AIThreadID const& id1, AIThreadID const& id2) { return apr_os_thread_equal(id1.mID, id2.mID); }
friend LL_COMMON_API bool operator!=(AIThreadID const& id1, AIThreadID const& id2) { return !apr_os_thread_equal(id1.mID, id2.mID); }
friend LL_COMMON_API std::ostream& operator<<(std::ostream& os, AIThreadID const& id);
static void set_main_thread_id(void); // Called once to set sMainThreadID.
static void set_current_thread_id(void); // Called once for every thread to set lCurrentThread.
#ifndef LL_DARWIN
LL_COMMON_API void reset(void);
LL_COMMON_API bool equals_current_thread(void) const;
LL_COMMON_API static bool in_main_thread(void);
LL_COMMON_API static apr_os_thread_t getCurrentThread(void);
// The *_inline variants cannot be exported because they access a thread-local member.
void reset_inline(void) { mID = lCurrentThread; }
bool equals_current_thread_inline(void) const { return apr_os_thread_equal(mID, lCurrentThread); }
static bool in_main_thread_inline(void) { return apr_os_thread_equal(lCurrentThread, sMainThreadID); }
static apr_os_thread_t getCurrentThread_inline(void) { return lCurrentThread; }
#else
// Both variants are inline on OS X.
void reset(void) { mID = apr_os_thread_current(); }
void reset_inline(void) { mID = apr_os_thread_current(); }
bool equals_current_thread(void) const { return apr_os_thread_equal(mID, apr_os_thread_current()); }
bool equals_current_thread_inline(void) const { return apr_os_thread_equal(mID, apr_os_thread_current()); }
static bool in_main_thread(void) { return apr_os_thread_equal(apr_os_thread_current(), sMainThreadID); }
static bool in_main_thread_inline(void) { return apr_os_thread_equal(apr_os_thread_current(), sMainThreadID); }
static apr_os_thread_t getCurrentThread(void) { return apr_os_thread_current(); }
static apr_os_thread_t getCurrentThread_inline(void) { return apr_os_thread_current(); }
#endif
};
// Legacy function.
inline bool is_main_thread(void)
{
return AIThreadID::in_main_thread();
}
#endif // AI_THREAD_ID

View File

@@ -111,10 +111,10 @@ template<typename T> struct AIAccess;
template<typename T> struct AISTAccessConst;
template<typename T> struct AISTAccess;
// This helper class is needed because offsetof is only allowed on POD types.
template<typename T>
class AIThreadSafeBits
struct AIThreadSafeBitsPOD
{
private:
// AIThreadSafe is a wrapper around an instance of T.
// Because T might not have a default constructor, it is constructed
// 'in place', with placement new, in the memory reserved here.
@@ -122,7 +122,11 @@ private:
// Make sure that the memory that T will be placed in is properly
// aligned by using an array of long's.
long mMemory[(sizeof(T) + sizeof(long) - 1) / sizeof(long)];
};
template<typename T>
class AIThreadSafeBits : private AIThreadSafeBitsPOD<T>
{
public:
// The wrapped objects are constructed in-place with placement new *outside*
// of this object (by AITHREADSAFE macro(s) or derived classes).
@@ -130,20 +134,20 @@ public:
~AIThreadSafeBits() { ptr()->~T(); }
// Only for use by AITHREADSAFE, see below.
void* memory() const { return const_cast<long*>(&mMemory[0]); }
void* memory() const { return const_cast<long*>(&AIThreadSafeBitsPOD<T>::mMemory[0]); }
// Cast a T* back to AIThreadSafeBits<T>. This is the inverse of memory().
template<typename T2>
static AIThreadSafeBits<T2>* wrapper_cast(T2* ptr)
{ return reinterpret_cast<AIThreadSafeBits<T2>*>(reinterpret_cast<char*>(ptr) - offsetof(AIThreadSafeBits<T2>, mMemory[0])); }
{ return static_cast<AIThreadSafeBits<T2>*>(reinterpret_cast<AIThreadSafeBitsPOD<T2>*>(reinterpret_cast<char*>(ptr) - offsetof(AIThreadSafeBitsPOD<T2>, mMemory[0]))); }
template<typename T2>
static AIThreadSafeBits<T2> const* wrapper_cast(T2 const* ptr)
{ return reinterpret_cast<AIThreadSafeBits<T2> const*>(reinterpret_cast<char const*>(ptr) - offsetof(AIThreadSafeBits<T2>, mMemory[0])); }
{ return static_cast<AIThreadSafeBits<T2> const*>(reinterpret_cast<AIThreadSafeBitsPOD<T2> const*>(reinterpret_cast<char const*>(ptr) - offsetof(AIThreadSafeBitsPOD<T2>, mMemory[0]))); }
protected:
// Accessors.
T const* ptr() const { return reinterpret_cast<T const*>(mMemory); }
T* ptr() { return reinterpret_cast<T*>(mMemory); }
T const* ptr() const { return reinterpret_cast<T const*>(AIThreadSafeBitsPOD<T>::mMemory); }
T* ptr() { return reinterpret_cast<T*>(AIThreadSafeBitsPOD<T>::mMemory); }
};
/**
@@ -329,14 +333,14 @@ struct AIReadAccessConst
};
//! Construct a AIReadAccessConst from a constant AIThreadSafe.
AIReadAccessConst(AIThreadSafe<T> const& wrapper)
AIReadAccessConst(AIThreadSafe<T> const& wrapper, bool high_priority = false)
: mWrapper(const_cast<AIThreadSafe<T>&>(wrapper)),
mState(readlocked)
#if AI_NEED_ACCESS_CC
, mIsCopyConstructed(false)
#endif
{
mWrapper.mRWLock.rdlock();
mWrapper.mRWLock.rdlock(high_priority);
}
//! Destruct the AI*Access object.
@@ -393,7 +397,7 @@ struct AIReadAccess : public AIReadAccessConst<T>
using AIReadAccessConst<T>::readlocked;
//! Construct a AIReadAccess from a non-constant AIThreadSafe.
AIReadAccess(AIThreadSafe<T>& wrapper) : AIReadAccessConst<T>(wrapper, readlocked) { this->mWrapper.mRWLock.rdlock(); }
AIReadAccess(AIThreadSafe<T>& wrapper, bool high_priority = false) : AIReadAccessConst<T>(wrapper, readlocked) { this->mWrapper.mRWLock.rdlock(high_priority); }
protected:
//! Constructor used by AIWriteAccess.
@@ -673,18 +677,18 @@ protected:
#ifdef LL_DEBUG
mutable bool mAccessed;
mutable apr_os_thread_t mTheadID;
mutable AIThreadID mTheadID;
void accessed(void) const
{
if (!mAccessed)
{
mAccessed = true;
mTheadID = apr_os_thread_current();
mTheadID.reset();
}
else
{
llassert_always(apr_os_thread_equal(mTheadID, apr_os_thread_current()));
llassert_always(mTheadID.equals_current_thread());
}
}
#endif

View File

@@ -27,7 +27,7 @@
#include "linden_common.h"
#include "llallocator.h"
#if LL_USE_TCMALLOC
#if (LL_USE_TCMALLOC && LL_USE_HEAP_PROFILER)
#include "google/heap-profiler.h"
#include "google/commandlineflags_public.h"

View File

@@ -297,6 +297,20 @@ void LLApp::startErrorThread()
}
}
void LLApp::stopErrorThread()
{
LLApp::setStopped(); // Signal error thread that we stopped.
int count = 0;
while (mThreadErrorp && !mThreadErrorp->isStopped() && ++count < 100)
{
ms_sleep(10);
}
if (mThreadErrorp && !mThreadErrorp->isStopped())
{
llwarns << "Failed to stop Error Thread." << llendl;
}
}
void LLApp::setErrorHandler(LLAppErrorHandler handler)
{
LLApp::sErrorHandler = handler;

View File

@@ -264,6 +264,10 @@ protected:
* @ brief This method is called once as soon as logging is initialized.
*/
void startErrorThread();
/**
* @brief This method is called at the end, just prior to deinitializing curl.
*/
void stopErrorThread();
private:
void setupErrorHandling(); // Do platform-specific error-handling setup (signals, structured exceptions)

View File

@@ -36,26 +36,39 @@
#include "llapr.h"
#include "llscopedvolatileaprpool.h"
LLFastTimer::DeclareTimer FT_WAIT_FOR_SCOPEDLOCK("LLScopedLock");
//---------------------------------------------------------------------
//
// LLScopedLock
//
LLScopedLock::LLScopedLock(apr_thread_mutex_t* mutex) : mMutex(mutex)
{
if(mutex)
mLocked = !!mutex;
if (LL_LIKELY(mutex))
{
if(ll_apr_warn_status(apr_thread_mutex_lock(mMutex)))
apr_status_t status = apr_thread_mutex_trylock(mMutex);
while (LL_UNLIKELY(status != APR_SUCCESS))
{
mLocked = false;
if (APR_STATUS_IS_EBUSY(status))
{
if (AIThreadID::in_main_thread_inline())
{
LLFastTimer ft1(FT_WAIT_FOR_SCOPEDLOCK);
status = apr_thread_mutex_lock(mMutex);
}
else
{
status = apr_thread_mutex_lock(mMutex);
}
}
else
{
ll_apr_warn_status(status);
mLocked = false;
return;
}
}
else
{
mLocked = true;
}
}
else
{
mLocked = false;
}
}

View File

@@ -60,10 +60,10 @@ void LLAPRPool::create(LLAPRPool& parent)
//
// In other words, it's safe for any thread to create a (sub)pool, independent of who
// owns the parent pool.
mOwner = apr_os_thread_current();
mOwner.reset_inline();
#else
mOwner = mParent->mOwner;
llassert(apr_os_thread_equal(mOwner, apr_os_thread_current()));
llassert(mOwner.equals_current_thread_inline());
#endif
apr_status_t const apr_pool_create_status = apr_pool_create(&mPool, mParent->mPool);
llassert_always(apr_pool_create_status == APR_SUCCESS);
@@ -83,7 +83,7 @@ void LLAPRPool::destroy(void)
// of course. Otherwise, if we are a subpool, only the thread that owns
// the parent may destruct us, since that is the pool that is still alive,
// possibly being used by others and being altered here.
llassert(!mParent || apr_os_thread_equal(mParent->mOwner, apr_os_thread_current()));
llassert(!mParent || mParent->mOwner.equals_current_thread_inline());
#endif
apr_pool_t* pool = mPool;
mPool = NULL; // Mark that we are BEING destructed.

View File

@@ -48,6 +48,7 @@
#include "apr_portable.h"
#include "apr_pools.h"
#include "llerror.h"
#include "aithreadid.h"
extern void ll_init_apr();
@@ -62,22 +63,22 @@ class LL_COMMON_API LLAPRPool
protected:
apr_pool_t* mPool; //!< Pointer to the underlaying pool. NULL if not initialized.
LLAPRPool* mParent; //!< Pointer to the parent pool, if any. Only valid when mPool is non-zero.
apr_os_thread_t mOwner; //!< The thread that owns this memory pool. Only valid when mPool is non-zero.
AIThreadID mOwner; //!< The thread that owns this memory pool. Only valid when mPool is non-zero.
public:
//! Construct an uninitialized (destructed) pool.
LLAPRPool(void) : mPool(NULL) { }
LLAPRPool(void) : mPool(NULL), mOwner(AIThreadID::none) { }
//! Construct a subpool from an existing pool.
// This is not a copy-constructor, this class doesn't have one!
LLAPRPool(LLAPRPool& parent) : mPool(NULL) { create(parent); }
LLAPRPool(LLAPRPool& parent) : mPool(NULL), mOwner(AIThreadID::none) { create(parent); }
//! Destruct the memory pool (free all of it's subpools and allocated memory).
~LLAPRPool() { destroy(); }
protected:
// Create a pool that is allocated from the Operating System. Only used by LLAPRRootPool.
LLAPRPool(int) : mPool(NULL), mParent(NULL), mOwner(apr_os_thread_current())
LLAPRPool(int) : mPool(NULL), mParent(NULL)
{
apr_status_t const apr_pool_create_status = apr_pool_create(&mPool, NULL);
llassert_always(apr_pool_create_status == APR_SUCCESS);
@@ -104,7 +105,7 @@ public:
apr_pool_t* operator()(void) const
{
llassert(mPool);
llassert(apr_os_thread_equal(mOwner, apr_os_thread_current()));
llassert(mOwner.equals_current_thread());
return mPool;
}
@@ -112,7 +113,7 @@ public:
void clear(void)
{
llassert(mPool);
llassert(apr_os_thread_equal(mOwner, apr_os_thread_current()));
llassert(mOwner.equals_current_thread());
apr_pool_clear(mPool);
}
@@ -124,13 +125,13 @@ public:
void* palloc(size_t size)
{
llassert(mPool);
llassert(apr_os_thread_equal(mOwner, apr_os_thread_current()));
llassert(mOwner.equals_current_thread());
return apr_palloc(mPool, size);
}
void* pcalloc(size_t size)
{
llassert(mPool);
llassert(apr_os_thread_equal(mOwner, apr_os_thread_current()));
llassert(mOwner.equals_current_thread());
return apr_pcalloc(mPool, size);
}
#endif

View File

@@ -56,6 +56,7 @@ public:
};
LLDynamicArray(S32 size=0) : std::vector<Type>(size) { if (size < BlockSize) std::vector<Type>::reserve(BlockSize); }
LLDynamicArray(const std::vector<Type>& copy) : std::vector<Type>(copy) {}
void reset() { std::vector<Type>::clear(); }

View File

@@ -963,10 +963,14 @@ namespace LLError
settings_w->shouldLogCallCounter += 1;
std::string class_name = className(site.mClassInfo);
std::string function_name = functionName(site.mFunction);
if (site.mClassInfo != typeid(NoClassInfo))
std::string function_name;
if (site.mFunction)
{
function_name = class_name + "::" + function_name;
function_name = functionName(site.mFunction);
if (site.mClassInfo != typeid(NoClassInfo))
{
function_name = class_name + "::" + function_name;
}
}
ELevel compareLevel = settings_w->defaultLevel;
@@ -976,7 +980,7 @@ namespace LLError
// So, in increasing order of importance:
// Default < Broad Tag < File < Class < Function < Narrow Tag
((site.mNarrowTag != NULL) ? checkLevelMap(settings_w->tagLevelMap, site.mNarrowTag, compareLevel) : false)
|| checkLevelMap(settings_w->functionLevelMap, function_name, compareLevel)
|| (site.mFunction && checkLevelMap(settings_w->functionLevelMap, function_name, compareLevel))
|| checkLevelMap(settings_w->classLevelMap, class_name, compareLevel)
|| checkLevelMap(settings_w->fileLevelMap, abbreviateFile(site.mFile), compareLevel)
|| ((site.mBroadTag != NULL) ? checkLevelMap(settings_w->tagLevelMap, site.mBroadTag, compareLevel) : false);
@@ -1083,8 +1087,8 @@ namespace LLError
default: prefix << "XXX"; break;
};
bool need_function = true;
if (site.mBroadTag && *site.mBroadTag != '\0')
bool need_function = site.mFunction;
if (need_function && site.mBroadTag && *site.mBroadTag != '\0')
{
prefix << "(\"" << site.mBroadTag << "\")";
#if LL_DEBUG
@@ -1112,7 +1116,7 @@ namespace LLError
#if LL_WINDOWS
// DevStudio: __FUNCTION__ already includes the full class name
#else
if (need_function && site.mClassInfo != typeid(NoClassInfo))
if (site.mClassInfo != typeid(NoClassInfo))
{
prefix << className(site.mClassInfo) << "::";
}

View File

@@ -238,10 +238,10 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG;
See top of file for common usage.
*/
#define lllog(level, broadTag, narrowTag, once) \
#define lllog(level, broadTag, narrowTag, once, nofunction) \
do { \
static LLError::CallSite _site( \
level, __FILE__, __LINE__, typeid(_LL_CLASS_TO_LOG), __FUNCTION__, broadTag, narrowTag, once);\
level, __FILE__, __LINE__, typeid(_LL_CLASS_TO_LOG), nofunction ? NULL : __FUNCTION__, broadTag, narrowTag, once);\
if (LL_UNLIKELY(_site.shouldLog())) \
{ \
std::ostringstream* _out = LLError::Log::out(); \
@@ -255,33 +255,39 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG;
} while(0)
// DEPRECATED: Use the new macros that allow tags and *look* like macros.
#define lldebugs lllog(LLError::LEVEL_DEBUG, NULL, NULL, false)
#define llinfos lllog(LLError::LEVEL_INFO, NULL, NULL, false)
#define llwarns lllog(LLError::LEVEL_WARN, NULL, NULL, false)
#define llerrs lllog(LLError::LEVEL_ERROR, NULL, NULL, false)
#define lldebugs lllog(LLError::LEVEL_DEBUG, NULL, NULL, false, false)
#define llinfos lllog(LLError::LEVEL_INFO, NULL, NULL, false, false)
#define llwarns lllog(LLError::LEVEL_WARN, NULL, NULL, false, false)
#define llerrs lllog(LLError::LEVEL_ERROR, NULL, NULL, false, false)
#define llcont (*_out)
// No function name
#define lldebugs_nf lllog(LLError::LEVEL_DEBUG, NULL, NULL, false, true)
#define llinfos_nf lllog(LLError::LEVEL_INFO, NULL, NULL, false, true)
#define llwarns_nf lllog(LLError::LEVEL_WARN, NULL, NULL, false, true)
#define llerrs_nf lllog(LLError::LEVEL_ERROR, NULL, NULL, false, true)
// NEW Macros for debugging, allow the passing of a string tag
// One Tag
#define LL_DEBUGS(broadTag) lllog(LLError::LEVEL_DEBUG, broadTag, NULL, false)
#define LL_INFOS(broadTag) lllog(LLError::LEVEL_INFO, broadTag, NULL, false)
#define LL_WARNS(broadTag) lllog(LLError::LEVEL_WARN, broadTag, NULL, false)
#define LL_ERRS(broadTag) lllog(LLError::LEVEL_ERROR, broadTag, NULL, false)
#define LL_DEBUGS(broadTag) lllog(LLError::LEVEL_DEBUG, broadTag, NULL, false, false)
#define LL_INFOS(broadTag) lllog(LLError::LEVEL_INFO, broadTag, NULL, false, false)
#define LL_WARNS(broadTag) lllog(LLError::LEVEL_WARN, broadTag, NULL, false, false)
#define LL_ERRS(broadTag) lllog(LLError::LEVEL_ERROR, broadTag, NULL, false, false)
// Two Tags
#define LL_DEBUGS2(broadTag, narrowTag) lllog(LLError::LEVEL_DEBUG, broadTag, narrowTag, false)
#define LL_INFOS2(broadTag, narrowTag) lllog(LLError::LEVEL_INFO, broadTag, narrowTag, false)
#define LL_WARNS2(broadTag, narrowTag) lllog(LLError::LEVEL_WARN, broadTag, narrowTag, false)
#define LL_ERRS2(broadTag, narrowTag) lllog(LLError::LEVEL_ERROR, broadTag, narrowTag, false)
#define LL_DEBUGS2(broadTag, narrowTag) lllog(LLError::LEVEL_DEBUG, broadTag, narrowTag, false, false)
#define LL_INFOS2(broadTag, narrowTag) lllog(LLError::LEVEL_INFO, broadTag, narrowTag, false, false)
#define LL_WARNS2(broadTag, narrowTag) lllog(LLError::LEVEL_WARN, broadTag, narrowTag, false, false)
#define LL_ERRS2(broadTag, narrowTag) lllog(LLError::LEVEL_ERROR, broadTag, narrowTag, false, false)
// Only print the log message once (good for warnings or infos that would otherwise
// spam the log file over and over, such as tighter loops).
#define LL_DEBUGS_ONCE(broadTag) lllog(LLError::LEVEL_DEBUG, broadTag, NULL, true)
#define LL_INFOS_ONCE(broadTag) lllog(LLError::LEVEL_INFO, broadTag, NULL, true)
#define LL_WARNS_ONCE(broadTag) lllog(LLError::LEVEL_WARN, broadTag, NULL, true)
#define LL_DEBUGS2_ONCE(broadTag, narrowTag) lllog(LLError::LEVEL_DEBUG, broadTag, narrowTag, true)
#define LL_INFOS2_ONCE(broadTag, narrowTag) lllog(LLError::LEVEL_INFO, broadTag, narrowTag, true)
#define LL_WARNS2_ONCE(broadTag, narrowTag) lllog(LLError::LEVEL_WARN, broadTag, narrowTag, true)
#define LL_DEBUGS_ONCE(broadTag) lllog(LLError::LEVEL_DEBUG, broadTag, NULL, true, false)
#define LL_INFOS_ONCE(broadTag) lllog(LLError::LEVEL_INFO, broadTag, NULL, true, false)
#define LL_WARNS_ONCE(broadTag) lllog(LLError::LEVEL_WARN, broadTag, NULL, true, false)
#define LL_DEBUGS2_ONCE(broadTag, narrowTag) lllog(LLError::LEVEL_DEBUG, broadTag, narrowTag, true, false)
#define LL_INFOS2_ONCE(broadTag, narrowTag) lllog(LLError::LEVEL_INFO, broadTag, narrowTag, true, false)
#define LL_WARNS2_ONCE(broadTag, narrowTag) lllog(LLError::LEVEL_WARN, broadTag, narrowTag, true, false)
#define LL_ENDL llendl
#define LL_CONT (*_out)
@@ -302,8 +308,4 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG;
Such computation is done iff the message will be logged.
*/
#ifdef SHOW_ASSERT
extern LL_COMMON_API bool is_main_thread();
#endif
#endif // LL_LLERROR_H

View File

@@ -114,7 +114,7 @@ const int LL_ERR_PRICE_MISMATCH = -23018;
: liru_slashpos2 == std::string::npos ? std::string(__FILE__)/*Apparently, we're in / or perhaps the top of the drive, print as is*/\
: std::string(__FILE__).substr(1+liru_slashpos2))/*print foo/bar.cpp or perhaps foo\bar.cpp*/
#define llassert_always(func) if (LL_UNLIKELY(!(func))) llerrs <<"\nASSERT(" #func ")\nfile:"<<liru_assert_strip<<" line:"<<__LINE__ << llendl;
#define llassert_always(func) do { if (LL_UNLIKELY(!(func))) llerrs << "\nASSERT(" #func ")\nfile:" << liru_assert_strip << " line:" << std::dec << __LINE__ << llendl; } while(0)
#ifdef SHOW_ASSERT
#define llassert(func) llassert_always(func)
@@ -124,6 +124,25 @@ const int LL_ERR_PRICE_MISMATCH = -23018;
#define llverify(func) do {if (func) {}} while(0)
#endif
// This can be used for function parameters that are only used by llassert.
// The ellipsis is needed in case the parameter contains comma's (ie, as part of the type,
// or trailing comma). The first version can be used as first (or only) parameter of a function,
// or as parameter in the middle when adding a trailing comma, while the second version can be
// used as last parameter.
//
// Example usage:
//
// void foo(ASSERT_ONLY(int x));
// void foo(x, ASSERT_ONLY(int y,) int z);
// void foo(x/*,*/ ASSERT_ONLY_COMMA(int y)); // The optional /*,*/ makes it just a bit better readable.
#ifdef SHOW_ASSERT
#define ASSERT_ONLY(...) __VA_ARGS__
#define ASSERT_ONLY_COMMA(...) , __VA_ARGS__
#else
#define ASSERT_ONLY(...)
#define ASSERT_ONLY_COMMA(...)
#endif
// handy compile-time assert - enforce those template parameters!
#define cassert(expn) typedef char __C_ASSERT__[(expn)?1:-1] /* Flawfinder: ignore */
//XXX: used in two places in llcommon/llskipmap.h

View File

@@ -194,17 +194,17 @@ void LLErrorThread::run()
if (LLApp::isError())
{
// The app is in an error state, run the application's error handler.
//llinfos << "thread_error - An error has occurred, running error callback!" << llendl;
Dout(dc::notice, "thread_error - An error has occurred, running error callback!");
// Run the error handling callback
LLApp::runErrorHandler();
}
else
{
// Everything is okay, a clean exit.
//llinfos << "thread_error - Application exited cleanly" << llendl;
Dout(dc::notice, "thread_error - Application exited cleanly");
}
//llinfos << "thread_error - Exiting" << llendl;
Dout(dc::notice, "thread_error - Exiting");
LLApp::sErrorThreadRunning = FALSE;
}

View File

@@ -444,13 +444,13 @@ LLBoundListener LLEventPump::listen_impl(const std::string& name, const LLEventL
{
// The new node isn't last. Place it between the previous node and
// the successor.
newNode = (myprev + mydmi->second)/2.0;
newNode = (myprev + mydmi->second)/2.f;
}
else
{
// The new node is last. Bump myprev up to the next integer, add
// 1.0 and use that.
newNode = std::ceil(myprev) + 1.0;
newNode = std::ceil(myprev) + 1.f;
}
// Now that newNode has a value that places it appropriately in mSignal,
// connect it.

View File

@@ -227,7 +227,7 @@ public:
#endif
/**
* @breif filesize helpers.
* @brief filesize helpers.
*
* The file size helpers are not considered particularly efficient,
* and should only be used for config files and the like -- not in a

View File

@@ -44,6 +44,9 @@
#include "lltimer.h"
#include "timing.h"
#include <apr_thread_mutex.h>
#ifdef SHOW_ASSERT
#include "aithreadid.h" // is_main_thread()
#endif
class LL_COMMON_API LLFrameTimer
{

View File

@@ -67,6 +67,17 @@ BOOL LLMemory::sEnableMemoryFailurePrevention = FALSE;
LLPrivateMemoryPoolManager::mem_allocation_info_t LLPrivateMemoryPoolManager::sMemAllocationTracker;
#endif
void ll_assert_aligned_func(uintptr_t ptr,U32 alignment)
{
#ifdef SHOW_ASSERT
// Redundant, place to set breakpoints.
if (ptr%alignment!=0)
{
llwarns << "alignment check failed" << llendl;
}
llassert(ptr%alignment==0);
#endif
}
//static
void LLMemory::initClass()
{
@@ -246,21 +257,6 @@ U32 LLMemory::getAllocatedMemKB()
return sAllocatedMemInKB ;
}
void* ll_allocate (size_t size)
{
if (size == 0)
{
llwarns << "Null allocation" << llendl;
}
void *p = malloc(size);
if (p == NULL)
{
LLMemory::freeReserve();
llerrs << "Out of memory Error" << llendl;
}
return p;
}
//----------------------------------------------------------------------------
#if defined(LL_WINDOWS)
@@ -1358,7 +1354,7 @@ char* LLPrivateMemoryPool::allocate(U32 size)
//if the asked size larger than MAX_BLOCK_SIZE, fetch from heap directly, the pool does not manage it
if(size >= CHUNK_SIZE)
{
return (char*)malloc(size) ;
return (char*)ll_aligned_malloc_16(size) ;
}
char* p = NULL ;
@@ -1415,7 +1411,7 @@ char* LLPrivateMemoryPool::allocate(U32 size)
to_log = false ;
}
return (char*)malloc(size) ;
return (char*)ll_aligned_malloc_16(size) ;
}
return p ;
@@ -1434,7 +1430,7 @@ void LLPrivateMemoryPool::freeMem(void* addr)
if(!chunk)
{
free(addr) ; //release from heap
ll_aligned_free_16(addr) ; //release from heap
}
else
{
@@ -1558,7 +1554,7 @@ LLPrivateMemoryPool::LLMemoryChunk* LLPrivateMemoryPool::addChunk(S32 chunk_inde
mReservedPoolSize += preferred_size + overhead ;
char* buffer = (char*)malloc(preferred_size + overhead) ;
char* buffer = (char*)ll_aligned_malloc_16(preferred_size + overhead) ;
if(!buffer)
{
return NULL ;
@@ -1626,7 +1622,7 @@ void LLPrivateMemoryPool::removeChunk(LLMemoryChunk* chunk)
mReservedPoolSize -= chunk->getBufferSize() ;
//release memory
free(chunk->getBuffer()) ;
ll_aligned_free_16(chunk->getBuffer()) ;
}
U16 LLPrivateMemoryPool::findHashKey(const char* addr)
@@ -1970,7 +1966,7 @@ char* LLPrivateMemoryPoolManager::allocate(LLPrivateMemoryPool* poolp, U32 size,
if(!poolp)
{
p = (char*)malloc(size) ;
p = (char*)ll_aligned_malloc_16(size) ;
}
else
{
@@ -1999,7 +1995,7 @@ char* LLPrivateMemoryPoolManager::allocate(LLPrivateMemoryPool* poolp, U32 size)
}
else
{
return (char*)malloc(size) ;
return (char*)ll_aligned_malloc_16(size) ;
}
}
#endif
@@ -2024,7 +2020,7 @@ void LLPrivateMemoryPoolManager::freeMem(LLPrivateMemoryPool* poolp, void* addr
{
if(!sPrivatePoolEnabled)
{
free(addr) ; //private pool is disabled.
ll_aligned_free_16(addr) ; //private pool is disabled.
}
else if(!sInstance) //the private memory manager is destroyed, try the dangling list
{

View File

@@ -39,9 +39,14 @@
#include <stdint.h> // uintptr_t
#endif
#include "llerror.h"
#include "llmemtype.h"
#if LL_DEBUG
#if LL_WINDOWS && LL_DEBUG
#define LL_CHECK_MEMORY llassert(_CrtCheckMemory());
#else
#define LL_CHECK_MEMORY
#endif
inline void* ll_aligned_malloc( size_t size, int align )
{
void* mem = malloc( size + (align - 1) + sizeof(void*) );
@@ -57,10 +62,11 @@ inline void ll_aligned_free( void* ptr )
free( ((void**)ptr)[-1] );
}
#if !LL_USE_TCMALLOC
inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed with ll_aligned_free_16().
{
#if defined(LL_WINDOWS)
return _mm_malloc(size, 16);
return _aligned_malloc(size, 16);
#elif defined(LL_DARWIN)
return malloc(size); // default osx malloc is 16 byte aligned.
#else
@@ -75,7 +81,7 @@ inline void* ll_aligned_malloc_16(size_t size) // returned hunk MUST be freed wi
inline void ll_aligned_free_16(void *p)
{
#if defined(LL_WINDOWS)
_mm_free(p);
_aligned_free(p);
#elif defined(LL_DARWIN)
return free(p);
#else
@@ -83,10 +89,39 @@ inline void ll_aligned_free_16(void *p)
#endif
}
inline void* ll_aligned_realloc_16(void* ptr, size_t size, size_t old_size) // returned hunk MUST be freed with ll_aligned_free_16().
{
#if defined(LL_WINDOWS)
return _aligned_realloc(ptr, size, 16);
#elif defined(LL_DARWIN)
return realloc(ptr,size); // default osx malloc is 16 byte aligned.
#else
//FIXME: memcpy is SLOW
void* ret = ll_aligned_malloc_16(size);
if (ptr)
{
if (ret)
{
// Only copy the size of the smallest memory block to avoid memory corruption.
memcpy(ret, ptr, llmin(old_size, size));
}
ll_aligned_free_16(ptr);
}
return ret;
#endif
}
#else // USE_TCMALLOC
// ll_aligned_foo_16 are not needed with tcmalloc
#define ll_aligned_malloc_16 malloc
#define ll_aligned_realloc_16(a,b,c) realloc(a,b)
#define ll_aligned_free_16 free
#endif // USE_TCMALLOC
inline void* ll_aligned_malloc_32(size_t size) // returned hunk MUST be freed with ll_aligned_free_32().
{
#if defined(LL_WINDOWS)
return _mm_malloc(size, 32);
return _aligned_malloc(size, 32);
#elif defined(LL_DARWIN)
return ll_aligned_malloc( size, 32 );
#else
@@ -101,22 +136,13 @@ inline void* ll_aligned_malloc_32(size_t size) // returned hunk MUST be freed wi
inline void ll_aligned_free_32(void *p)
{
#if defined(LL_WINDOWS)
_mm_free(p);
_aligned_free(p);
#elif defined(LL_DARWIN)
ll_aligned_free( p );
#else
free(p); // posix_memalign() is compatible with heap deallocator
#endif
}
#else // LL_DEBUG
// ll_aligned_foo are noops now that we use tcmalloc everywhere (tcmalloc aligns automatically at appropriate intervals)
#define ll_aligned_malloc( size, align ) malloc(size)
#define ll_aligned_free( ptr ) free(ptr)
#define ll_aligned_malloc_16 malloc
#define ll_aligned_free_16 free
#define ll_aligned_malloc_32 malloc
#define ll_aligned_free_32 free
#endif // LL_DEBUG
#ifndef __DEBUG_PRIVATE_MEM__
#define __DEBUG_PRIVATE_MEM__ 0
@@ -521,9 +547,16 @@ void LLPrivateMemoryPoolTester::operator delete[](void* addr)
#endif
#endif
LL_COMMON_API void ll_assert_aligned_func(uintptr_t ptr,U32 alignment);
#ifdef SHOW_ASSERT
#define ll_assert_aligned(ptr,alignment) ll_assert_aligned_func(reinterpret_cast<uintptr_t>(ptr),((U32)alignment))
#else
#define ll_assert_aligned(ptr,alignment)
#endif
//EVENTUALLY REMOVE THESE:
#include "llpointer.h"
#include "llrefcount.h"
#include "llsingleton.h"
#include "llsafehandle.h"

View File

@@ -179,7 +179,6 @@ LLMemType::DeclareMemType LLMemType::MTYPE_IO_BUFFER("IoBuffer");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_HTTP_SERVER("IoHttpServer");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_SD_SERVER("IoSDServer");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_SD_CLIENT("IoSDClient");
LLMemType::DeclareMemType LLMemType::MTYPE_IO_URL_REQUEST("IOUrlRequest");
LLMemType::DeclareMemType LLMemType::MTYPE_DIRECTX_INIT("DirectXInit");

View File

@@ -223,7 +223,6 @@ public:
static DeclareMemType MTYPE_IO_HTTP_SERVER;
static DeclareMemType MTYPE_IO_SD_SERVER;
static DeclareMemType MTYPE_IO_SD_CLIENT;
static DeclareMemType MTYPE_IO_URL_REQUEST;
static DeclareMemType MTYPE_DIRECTX_INIT;

View File

@@ -195,4 +195,13 @@
# define LL_COMMON_API
#endif // LL_COMMON_LINK_SHARED
// Darwin does not support thread-local data.
#ifndef LL_DARWIN
#if LL_WINDOWS
#define ll_thread_local __declspec(thread)
#else // Linux
#define ll_thread_local __thread
#endif
#endif
#endif // not LL_LINDEN_PREPROCESSOR_H

View File

@@ -251,7 +251,7 @@ bool LLQueuedThread::addRequest(QueuedRequest* req)
// MAIN thread
bool LLQueuedThread::waitForResult(LLQueuedThread::handle_t handle, bool auto_complete)
{
llassert (handle != nullHandle())
llassert (handle != nullHandle());
bool res = false;
bool waspaused = isPaused();
bool done = false;

Some files were not shown because too many files have changed in this diff Show More