# HG changeset patch
# User unc0rr
# Date 1351888475 -14400
# Node ID 88fde28bbda6c1234cd6e3236cda9978dd51ddd7
# Parent 3331b30e4ef1588179e3b039deffc7d2589af958# Parent 550083f61a0ea826cd847ba25bd9d47c3c1c8f1f
Merge with default
diff -r 3331b30e4ef1 -r 88fde28bbda6 .hgignore
--- a/.hgignore Sun Oct 21 01:28:33 2012 +0400
+++ b/.hgignore Sat Nov 03 00:34:35 2012 +0400
@@ -3,6 +3,7 @@
glob:moc_*.cxx
glob:qrc_*.cxx
glob:*.o
+glob:*.qm
glob:Makefile
glob:bin
glob:*.hi
@@ -50,3 +51,8 @@
glob:project_files/Android-build/SDL-android-project/.*
glob:project_files/Android-build/out
glob:project_files/Android-build/Makefile.android
+glob:hedgewars-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug
+glob:hedgewars-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Release
+glob:*.depends
+glob:tools/build_windows_koda.bat
+
diff -r 3331b30e4ef1 -r 88fde28bbda6 .hgtags
--- a/.hgtags Sun Oct 21 01:28:33 2012 +0400
+++ b/.hgtags Sat Nov 03 00:34:35 2012 +0400
@@ -50,3 +50,4 @@
0000000000000000000000000000000000000000 0-9.17-release
4670f003f91b3246665ca0de95fa056d2d2f3f54 0.9.17-release
ce2b24995ab2efc088accecd7f7b116bb946fff7 hedgeroid-alpha
+2f203395bacab0d5594d3d303b5d87b2f152df50 0.9.18-release
diff -r 3331b30e4ef1 -r 88fde28bbda6 CMakeLists.txt
--- a/CMakeLists.txt Sun Oct 21 01:28:33 2012 +0400
+++ b/CMakeLists.txt Sat Nov 03 00:34:35 2012 +0400
@@ -43,8 +43,8 @@
#versioning
set(CPACK_PACKAGE_VERSION_MAJOR 0)
set(CPACK_PACKAGE_VERSION_MINOR 9)
-set(CPACK_PACKAGE_VERSION_PATCH 18${version_suffix})
-set(HEDGEWARS_PROTO_VER 42)
+set(CPACK_PACKAGE_VERSION_PATCH 19${version_suffix})
+set(HEDGEWARS_PROTO_VER 44)
set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
@@ -176,13 +176,13 @@
endif()
endif()
-set(pascal_flags ${fpflags_parsed} "-vq" "-vm4079,4080,4081" "-B" "-FE../bin" "-Cs2000000" "-vewn" "-dDEBUGFILE" ${pascal_flags})
+set(pascal_flags ${fpflags_parsed} "-vm4079,4080,4081" "-B" "-FE../bin" "-Cs2000000" "-vewnq" "-dDEBUGFILE" ${pascal_flags})
set(haskell_flags "-O2" ${ghflags_parsed} ${haskell_flags})
#get BUILD_TYPE and enable/disable optimisation
if(CMAKE_BUILD_TYPE MATCHES "DEBUG")
message(STATUS "Building Debug flavour")
- set(pascal_flags "-O-" "-g" "-gl" "-gv" "-Ct" ${pascal_flags})
+ set(pascal_flags "-O-" "-g" "-gl" "-gv" ${pascal_flags})
set(haskell_flags "-Wall" "-debug" "-dcore-lint" "-fno-warn-unused-do-bind" ${haskell_flags})
else()
message(STATUS "Building Release flavour")
@@ -227,9 +227,9 @@
#lua discovery
find_package(Lua)
if(LUA_FOUND)
- message(STATUS "LUA found: ${LUA_DEFAULT}")
+ message(STATUS "Found LUA: ${LUA_DEFAULT}")
else()
- message(STATUS "Cound NOT find LUA, building bundled dependency")
+ message(STATUS "LUA will be provided by the bundled sources")
add_subdirectory(misc/liblua)
#linking with liblua.a requires system readline -- this works everywhere, right?
set(pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline" ${pascal_flags})
diff -r 3331b30e4ef1 -r 88fde28bbda6 CREDITS
--- a/CREDITS Sun Oct 21 01:28:33 2012 +0400
+++ b/CREDITS Sat Nov 03 00:34:35 2012 +0400
@@ -18,12 +18,12 @@
- hillis -> AkuAku (2010)
- Lortinak -> OldMan (2010), ShortHair (2010)
- chujoii -> BrainSlug (2010), Dragon (2010), Ladle (2010), Laminaria (2010), Pantsu (2010), Pig (2010), Plunger (2010), SauceBoat (2010), ShaggyYeti (2010), SleepWalker (2010), SunWukong (2010), Teapot (2010), Teacup (2010), Zombi (2010)
-- Randy -> Cyclops (2011), Soldier (2011)
+- Randy Broda -> Cyclops (2011), Soldier (2011)
==========
= GRAVESTONES
==========
-- Randy -> Dragonball (2012)
+- Randy Broda -> Dragonball (2012)
==========
= MAPS
diff -r 3331b30e4ef1 -r 88fde28bbda6 ChangeLog.txt
--- a/ChangeLog.txt Sun Oct 21 01:28:33 2012 +0400
+++ b/ChangeLog.txt Sat Nov 03 00:34:35 2012 +0400
@@ -1,6 +1,34 @@
+ features
* bugfixes
+0.9.17 -> 0.9.18:
+
+ + 'A Classic Fairytale' Campaign
+ + Video recorder (requires ffmpeg)
+ + Cleaver weapon
+ + AI is now aware of drowning and fall damage
+ + AI learned how to use Sniper Rifle and Cake
+ + Variable pen width and eraser for drawn maps
+ + Several trainings and missions
+ + Allow setting custom local palette of teams colors
+ + Hide eliminated teams from teams healths widget
+ + Server doesn't delete room till last player quits it
+ + PNG screenshots
+ + Show bot level on CPU flag
+ + Objects now have density value assigned which impacts their behavior on explosions, throwing from rope and drowning
+ + Improve AI skills at Desert Eagel, Whip, Firepunch, Baseball Bat, Hammer, Cluster Bomb, Watermelon and walking
+ + Individual hedgehogs healths in team health bar
+ + Drill rocket wouldn't explode in your face if you stand close to wall
+ + Ability to rope into a portal, allow RC plane to go through portals
+ + Many small frontend improvements: get rid of "save" buttons, descriptions, allow to use network proxy, etc
+ + Reduce amount of memory needed for engine to store land data
+ + Countless other small fixes and improvements
+ + Detect desyncs early
+ * Fix cake getting stuck in barrels, crates and hedgehogs
+ * Fix all knowns bugs which caused network game hang when players close engine or quit
+ * Fix drill strike bug when drill's timer gets ridiculously high value instead of explosion
+ * Fix some crashes, freezes and memory leaks in frontend and engine
+
0.9.16 -> 0.9.17:
+ New theme, Cave
+ New voicepack, Hillbilly
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/CMakeLists.txt
--- a/QTfrontend/CMakeLists.txt Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/CMakeLists.txt Sat Nov 03 00:34:35 2012 +0400
@@ -28,7 +28,9 @@
# Configure for SDL
find_package(SDL REQUIRED)
find_package(SDL_mixer REQUIRED)
-find_package(FFMPEG)
+if(NOT NOVIDEOREC)
+ find_package(FFMPEG)
+endif()
include_directories(.)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/model)
@@ -74,8 +76,8 @@
file(GLOB_RECURSE UIcpp ui/*.cpp)
file(GLOB UtilCpp util/*.cpp)
-if((NOT NOVIDEOREC) AND "${FFMPEG_FOUND}")
- add_definitions(-DVIDEOREC)
+if(${FFMPEG_FOUND})
+ add_definitions(-DVIDEOREC -D__STDC_CONSTANT_MACROS)
endif()
set(hwfr_src
@@ -130,7 +132,7 @@
hwform.h
team.h
util/DataManager.h
- util/libav_iteraction.h
+ util/LibavInteraction.h
)
set(hwfr_hdrs
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/binds.cpp
--- a/QTfrontend/binds.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/binds.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -20,51 +20,51 @@
const BindAction cbinds[BINDS_NUMBER] =
{
- {"+up", "up", QT_TRANSLATE_NOOP("binds", "up"), QT_TRANSLATE_NOOP("binds (categories)", "Basic controls"), QT_TRANSLATE_NOOP("binds (descriptions)", "Move your hogs and aim:")},
- {"+left", "left", QT_TRANSLATE_NOOP("binds", "left"), NULL, NULL},
- {"+right", "right", QT_TRANSLATE_NOOP("binds", "right"), NULL, NULL},
- {"+down", "down", QT_TRANSLATE_NOOP("binds", "down"), NULL, NULL},
- {"+precise", "left_shift", QT_TRANSLATE_NOOP("binds", "precise aim"), NULL, NULL},
- {"ljump", "return", QT_TRANSLATE_NOOP("binds", "long jump"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Traverse gaps and obstacles by jumping:")},
- {"hjump", "backspace", QT_TRANSLATE_NOOP("binds", "high jump"), NULL, NULL},
- {"+attack", "space", QT_TRANSLATE_NOOP("binds", "attack"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Fire your selected weapon or trigger an utility item:")},
- {"put", "mousel", QT_TRANSLATE_NOOP("binds", "put"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Pick a weapon or a target location under the cursor:")},
- {"switch", "tab", QT_TRANSLATE_NOOP("binds", "switch"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Switch your currently active hog (if possible):")},
- {"ammomenu", "mouser", QT_TRANSLATE_NOOP("binds", "ammo menu"), QT_TRANSLATE_NOOP("binds (categories)", "Weapon controls"), QT_TRANSLATE_NOOP("binds (descriptions)", "Pick a weapon or utility item:")},
- {"slot 1", "f1", QT_TRANSLATE_NOOP("binds", "slot 1"), NULL, NULL},
- {"slot 2", "f2", QT_TRANSLATE_NOOP("binds", "slot 2"), NULL, NULL},
- {"slot 3", "f3", QT_TRANSLATE_NOOP("binds", "slot 3"), NULL, NULL},
- {"slot 4", "f4", QT_TRANSLATE_NOOP("binds", "slot 4"), NULL, NULL},
- {"slot 5", "f5", QT_TRANSLATE_NOOP("binds", "slot 5"), NULL, NULL},
- {"slot 6", "f6", QT_TRANSLATE_NOOP("binds", "slot 6"), NULL, NULL},
- {"slot 7", "f7", QT_TRANSLATE_NOOP("binds", "slot 7"), NULL, NULL},
- {"slot 8", "f8", QT_TRANSLATE_NOOP("binds", "slot 8"), NULL, NULL},
- {"slot 9", "f9", QT_TRANSLATE_NOOP("binds", "slot 9"), NULL, NULL},
- {"slot :", "f10", QT_TRANSLATE_NOOP("binds", "slot 10"), NULL, NULL},
- {"timer 1", "1", QT_TRANSLATE_NOOP("binds", "timer 1 sec"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Set the timer on bombs and timed weapons:")},
- {"timer 2", "2", QT_TRANSLATE_NOOP("binds", "timer 2 sec"), NULL, NULL},
- {"timer 3", "3", QT_TRANSLATE_NOOP("binds", "timer 3 sec"), NULL, NULL},
- {"timer 4", "4", QT_TRANSLATE_NOOP("binds", "timer 4 sec"), NULL, NULL},
- {"timer 5", "5", QT_TRANSLATE_NOOP("binds", "timer 5 sec"), NULL, NULL},
- {"findhh", "h", QT_TRANSLATE_NOOP("binds", "find hedgehog"), QT_TRANSLATE_NOOP("binds (categories)", "Camera and cursor controls"), QT_TRANSLATE_NOOP("binds (descriptions)", "Move the camera to the active hog:")},
- {"+cur_u", "[8]", QT_TRANSLATE_NOOP("binds", "up"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Move the cursor or camera without using the mouse:")},
- {"+cur_l", "[4]", QT_TRANSLATE_NOOP("binds", "left"), NULL, NULL},
- {"+cur_r", "[6]", QT_TRANSLATE_NOOP("binds", "right"), NULL, NULL},
- {"+cur_d", "[2]", QT_TRANSLATE_NOOP("binds", "down"), NULL, NULL},
-// {"+cur_m", "", QT_TRANSLATE_NOOP("binds", "movement key modifier"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Specify a modifier key to move camera and cursor using your default hog movement keys:")},
- {"zoomin", "wheelup", QT_TRANSLATE_NOOP("binds", "zoom in"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Modify the camera's zoom level:")},
- {"zoomout", "wheeldown", QT_TRANSLATE_NOOP("binds", "zoom out"), NULL, NULL},
- {"zoomreset", "mousem", QT_TRANSLATE_NOOP("binds", "reset zoom"), NULL, NULL},
- {"chat", "t", QT_TRANSLATE_NOOP("binds", "chat"), QT_TRANSLATE_NOOP("binds (categories)", "Other"), QT_TRANSLATE_NOOP("binds (descriptions)", "Talk to your team or all participants:")},
- {"history", "`", QT_TRANSLATE_NOOP("binds", "chat history"), NULL, NULL},
- {"pause", "p", QT_TRANSLATE_NOOP("binds", "pause"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Pause, continue or leave your game:")},
- {"quit", "escape", QT_TRANSLATE_NOOP("binds", "quit"), NULL, NULL},
- {"confirm", "y", QT_TRANSLATE_NOOP("binds", "confirmation"), NULL, NULL},
- {"+voldown", "9", QT_TRANSLATE_NOOP("binds", "volume down"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Modify the game's volume while playing:")},
- {"+volup", "0", QT_TRANSLATE_NOOP("binds", "volume up"), NULL, NULL},
- {"mute", "8", QT_TRANSLATE_NOOP("binds", "mute audio"), NULL, NULL},
- {"fullscr", "f12", QT_TRANSLATE_NOOP("binds", "change mode"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Toggle fullscreen mode:")},
- {"capture", "c", QT_TRANSLATE_NOOP("binds", "capture"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Take a screenshot:")},
- {"rotmask", "delete", QT_TRANSLATE_NOOP("binds", "hedgehogs\ninfo"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Toggle labels above hedgehogs:")},
- {"record", "r", QT_TRANSLATE_NOOP("binds", "record"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Record video:")}
+ {"+up", "up", QT_TRANSLATE_NOOP("binds", "up"), QT_TRANSLATE_NOOP("binds (categories)", "Basic controls"), QT_TRANSLATE_NOOP("binds (descriptions)", "Move your hogs and aim:")},
+ {"+left", "left", QT_TRANSLATE_NOOP("binds", "left"), NULL, NULL},
+ {"+right", "right", QT_TRANSLATE_NOOP("binds", "right"), NULL, NULL},
+ {"+down", "down", QT_TRANSLATE_NOOP("binds", "down"), NULL, NULL},
+ {"+precise", "left_shift", QT_TRANSLATE_NOOP("binds", "precise aim"), NULL, NULL},
+ {"ljump", "return", QT_TRANSLATE_NOOP("binds", "long jump"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Traverse gaps and obstacles by jumping:")},
+ {"hjump", "backspace", QT_TRANSLATE_NOOP("binds", "high jump"), NULL, NULL},
+ {"+attack", "space", QT_TRANSLATE_NOOP("binds", "attack"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Fire your selected weapon or trigger an utility item:")},
+ {"put", "mousel", QT_TRANSLATE_NOOP("binds", "put"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Pick a weapon or a target location under the cursor:")},
+ {"switch", "tab", QT_TRANSLATE_NOOP("binds", "switch"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Switch your currently active hog (if possible):")},
+ {"ammomenu", "mouser", QT_TRANSLATE_NOOP("binds", "ammo menu"), QT_TRANSLATE_NOOP("binds (categories)", "Weapon controls"), QT_TRANSLATE_NOOP("binds (descriptions)", "Pick a weapon or utility item:")},
+ {"slot 1", "f1", QT_TRANSLATE_NOOP("binds", "slot 1"), NULL, NULL},
+ {"slot 2", "f2", QT_TRANSLATE_NOOP("binds", "slot 2"), NULL, NULL},
+ {"slot 3", "f3", QT_TRANSLATE_NOOP("binds", "slot 3"), NULL, NULL},
+ {"slot 4", "f4", QT_TRANSLATE_NOOP("binds", "slot 4"), NULL, NULL},
+ {"slot 5", "f5", QT_TRANSLATE_NOOP("binds", "slot 5"), NULL, NULL},
+ {"slot 6", "f6", QT_TRANSLATE_NOOP("binds", "slot 6"), NULL, NULL},
+ {"slot 7", "f7", QT_TRANSLATE_NOOP("binds", "slot 7"), NULL, NULL},
+ {"slot 8", "f8", QT_TRANSLATE_NOOP("binds", "slot 8"), NULL, NULL},
+ {"slot 9", "f9", QT_TRANSLATE_NOOP("binds", "slot 9"), NULL, NULL},
+ {"slot :", "f10", QT_TRANSLATE_NOOP("binds", "slot 10"), NULL, NULL},
+ {"timer 1", "1", QT_TRANSLATE_NOOP("binds", "timer 1 sec"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Set the timer on bombs and timed weapons:")},
+ {"timer 2", "2", QT_TRANSLATE_NOOP("binds", "timer 2 sec"), NULL, NULL},
+ {"timer 3", "3", QT_TRANSLATE_NOOP("binds", "timer 3 sec"), NULL, NULL},
+ {"timer 4", "4", QT_TRANSLATE_NOOP("binds", "timer 4 sec"), NULL, NULL},
+ {"timer 5", "5", QT_TRANSLATE_NOOP("binds", "timer 5 sec"), NULL, NULL},
+ {"findhh", "h", QT_TRANSLATE_NOOP("binds", "find hedgehog"), QT_TRANSLATE_NOOP("binds (categories)", "Camera and cursor controls"), QT_TRANSLATE_NOOP("binds (descriptions)", "Move the camera to the active hog:")},
+ {"+cur_u", "[8]", QT_TRANSLATE_NOOP("binds", "up"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Move the cursor or camera without using the mouse:")},
+ {"+cur_l", "[4]", QT_TRANSLATE_NOOP("binds", "left"), NULL, NULL},
+ {"+cur_r", "[6]", QT_TRANSLATE_NOOP("binds", "right"), NULL, NULL},
+ {"+cur_d", "[2]", QT_TRANSLATE_NOOP("binds", "down"), NULL, NULL},
+// {"+cur_m", "", QT_TRANSLATE_NOOP("binds", "movement key modifier"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Specify a modifier key to move camera and cursor using your default hog movement keys:")},
+ {"zoomin", "wheelup", QT_TRANSLATE_NOOP("binds", "zoom in"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Modify the camera's zoom level:")},
+ {"zoomout", "wheeldown", QT_TRANSLATE_NOOP("binds", "zoom out"), NULL, NULL},
+ {"zoomreset", "mousem", QT_TRANSLATE_NOOP("binds", "reset zoom"), NULL, NULL},
+ {"chat", "t", QT_TRANSLATE_NOOP("binds", "chat"), QT_TRANSLATE_NOOP("binds (categories)", "Other"), QT_TRANSLATE_NOOP("binds (descriptions)", "Talk to your team or all participants:")},
+ {"history", "`", QT_TRANSLATE_NOOP("binds", "chat history"), NULL, NULL},
+ {"pause", "p", QT_TRANSLATE_NOOP("binds", "pause"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Pause, continue or leave your game:")},
+ {"quit", "escape", QT_TRANSLATE_NOOP("binds", "quit"), NULL, NULL},
+ {"confirm", "y", QT_TRANSLATE_NOOP("binds", "confirmation"), NULL, NULL},
+ {"+voldown", "9", QT_TRANSLATE_NOOP("binds", "volume down"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Modify the game's volume while playing:")},
+ {"+volup", "0", QT_TRANSLATE_NOOP("binds", "volume up"), NULL, NULL},
+ {"mute", "8", QT_TRANSLATE_NOOP("binds", "mute audio"), NULL, NULL},
+ {"fullscr", "f12", QT_TRANSLATE_NOOP("binds", "change mode"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Toggle fullscreen mode:")},
+ {"capture", "c", QT_TRANSLATE_NOOP("binds", "capture"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Take a screenshot:")},
+ {"rotmask", "delete", QT_TRANSLATE_NOOP("binds", "hedgehogs\ninfo"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Toggle labels above hedgehogs:")},
+ {"record", "r", QT_TRANSLATE_NOOP("binds", "record"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Record video:")}
};
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/campaign.cpp
--- a/QTfrontend/campaign.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/campaign.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -19,7 +19,6 @@
#include
#include
#include
-#include
#include
#include
#include
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/game.cpp
--- a/QTfrontend/game.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/game.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -21,7 +21,6 @@
#include
#include
#include
-#include
#include
#include "game.h"
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/gameuiconfig.cpp
--- a/QTfrontend/gameuiconfig.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/gameuiconfig.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -16,7 +16,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-#include
#include
#include
#include
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/hwconsts.h
--- a/QTfrontend/hwconsts.h Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/hwconsts.h Sat Nov 03 00:34:35 2012 +0400
@@ -73,13 +73,13 @@
#define AMMOLINE_CRAZY_DELAY "00000000000000000000000000000000000000000000000000000000"
#define AMMOLINE_CRAZY_CRATE "13111103121111111231141111111111111112111101011111110101"
-#define AMMOLINE_PROMODE_QT "90900090000000000000090000000000000000000000000000000001"
+#define AMMOLINE_PROMODE_QT "90900090000000000000090000000000000000000000000000000000"
#define AMMOLINE_PROMODE_PROB "00000000000000000000000000000000000000000000000000000000"
-#define AMMOLINE_PROMODE_DELAY "00000000000002055000000400070040000000002000000000000009"
+#define AMMOLINE_PROMODE_DELAY "00000000000002055000000400070040000000002000000000000002"
#define AMMOLINE_PROMODE_CRATE "11111111111111111111111111111111111111111001011111110101"
#define AMMOLINE_SHOPPA_QT "00000099000000000000000000000000000000000000000000000000"
-#define AMMOLINE_SHOPPA_PROB "44444100442444022101121212224220000000020004000100110000"
+#define AMMOLINE_SHOPPA_PROB "44444100442444022101121212224220000000020004000100110001"
#define AMMOLINE_SHOPPA_DELAY "00000000000000000000000000000000000000000000000000000000"
#define AMMOLINE_SHOPPA_CRATE "11111111111111111111111111111111111111111011011111110001"
@@ -94,7 +94,7 @@
#define AMMOLINE_MINES_CRATE "11111111111111111111111111111111111111111111011111110101"
#define AMMOLINE_PORTALS_QT "90000090020000000021000000000000001100000900000000000000"
-#define AMMOLINE_PORTALS_PROB "04050405416006555465544647765766666661555101011154110100"
+#define AMMOLINE_PORTALS_PROB "04050405416006555465544647765766666661555101011154110101"
#define AMMOLINE_PORTALS_DELAY "00000000000002055000000400070040000000002000000006000000"
#define AMMOLINE_PORTALS_CRATE "13111103121111111231141111111111111112111111011111110101"
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/hwform.cpp
--- a/QTfrontend/hwform.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/hwform.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -163,8 +163,8 @@
// ctrl+q closes frontend for consistency
QShortcut * closeFrontend = new QShortcut(QKeySequence("Ctrl+Q"), this);
connect (closeFrontend, SIGNAL(activated()), this, SLOT(close()));
- QShortcut * updateData = new QShortcut(QKeySequence("F5"), this);
- connect (updateData, SIGNAL(activated()), &DataManager::instance(), SLOT(reload()));
+ //QShortcut * updateData = new QShortcut(QKeySequence("F5"), this);
+ //connect (updateData, SIGNAL(activated()), &DataManager::instance(), SLOT(reload()));
#endif
UpdateTeamsLists();
@@ -202,8 +202,6 @@
connect(ui.pageMain->BtnDataDownload, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
pageSwitchMapper->setMapping(ui.pageMain->BtnDataDownload, ID_PAGE_DATADOWNLOAD);
- connect(ui.pageNetGame, SIGNAL(DLCClicked()), pageSwitchMapper, SLOT(map()));
- pageSwitchMapper->setMapping(ui.pageNetGame, ID_PAGE_DATADOWNLOAD);
#ifdef VIDEOREC
connect(ui.pageMain->BtnVideos, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
@@ -693,16 +691,13 @@
animationOldOpacity->setEasingCurve(QEasingCurve::OutExpo);
#endif
- QParallelAnimationGroup *group = new QParallelAnimationGroup;
- group->addAnimation(animationOldSlide);
- group->addAnimation(animationNewSlide);
-#ifdef false
- group->addAnimation(animationOldOpacity);
- group->addAnimation(animationNewOpacity);
-#endif
- group->start();
+ // let's hide the old slide after its animation has finished
+ connect(animationOldSlide, SIGNAL(finished()), ui.Pages->widget(lastid), SLOT(hide()));
- connect(animationOldSlide, SIGNAL(finished()), ui.Pages->widget(lastid), SLOT(hide()));
+ // start animations
+ animationOldSlide->start(QAbstractAnimation::DeleteWhenStopped);
+ animationNewSlide->start(QAbstractAnimation::DeleteWhenStopped);
+
/* this is for the situation when the animation below is interrupted by a new animation. For some reason, finished is not being fired */
for(int i=0;iwidget(i)->hide();
}
@@ -806,18 +801,21 @@
animationNewOpacity->setEasingCurve(QEasingCurve::OutExpo);
#endif
- QParallelAnimationGroup *group = new QParallelAnimationGroup;
- group->addAnimation(animationOldSlide);
- group->addAnimation(animationNewSlide);
-#ifdef false
- group->addAnimation(animationOldOpacity);
- group->addAnimation(animationNewOpacity);
-#endif
- group->start();
+ // let's hide the old slide after its animation has finished
+ connect(animationNewSlide, SIGNAL(finished()), ui.Pages->widget(curid), SLOT(hide()));
- connect(animationNewSlide, SIGNAL(finished()), ui.Pages->widget(curid), SLOT(hide()));
+ // start animations
+ animationOldSlide->start(QAbstractAnimation::DeleteWhenStopped);
+ animationNewSlide->start(QAbstractAnimation::DeleteWhenStopped);
}
#endif
+
+ if (stopAnim)
+ ui.Pages->widget(curid)->hide();
+
+// TODO the whole pages shown and effects stuff should be moved
+// out of hwform.cpp and into a subclass of QStackedLayout
+
}
void HWForm::OpenSnapshotFolder()
@@ -897,10 +895,18 @@
void HWForm::DeleteTeam(const QString & teamName)
{
- ui.pageEditTeam->deleteTeam(teamName);
- QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Teams"), QMessageBox::tr("Really delete this team?"), QMessageBox::Ok | QMessageBox::Cancel);
+ QMessageBox reallyDeleteMsg(this);
+ reallyDeleteMsg.setIcon(QMessageBox::Question);
+ reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Teams - Are you sure?"));
+ reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the team '%1'?").arg(teamName));
+ reallyDeleteMsg.setWindowModality(Qt::WindowModal);
+ reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
- UpdateTeamsLists();
+ if (reallyDeleteMsg.exec() == QMessageBox::Ok)
+ {
+ ui.pageEditTeam->deleteTeam(teamName);
+ UpdateTeamsLists();
+ }
}
void HWForm::DeleteScheme()
@@ -908,7 +914,7 @@
ui.pageScheme->selectScheme->setCurrentIndex(ui.pageOptions->SchemesName->currentIndex());
if (ui.pageOptions->SchemesName->currentIndex() < ammoSchemeModel->numberOfDefaultSchemes)
{
- QMessageBox::warning(0, QMessageBox::tr("Schemes"), QMessageBox::tr("Can not delete default scheme '%1'!").arg(ui.pageOptions->SchemesName->currentText()));
+ ShowErrorMessage(QMessageBox::tr("Cannot delete default scheme '%1'!").arg(ui.pageOptions->SchemesName->currentText()));
}
else
{
@@ -934,10 +940,7 @@
QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem();
if (!curritem)
{
- QMessageBox::critical(this,
- tr("Error"),
- tr("Please select record from the list above"),
- tr("OK"));
+ ShowErrorMessage(QMessageBox::tr("Please select a record from the list"));
return;
}
CreateGame(0, 0, 0);
@@ -1001,7 +1004,7 @@
void HWForm::NetNickTaken(const QString & nick)
{
bool ok = false;
- QString newNick = QInputDialog::getText(this, tr("Nickname"), tr("Some one already uses\n your nickname %1\non the server.\nPlease pick another nickname:").arg(nick), QLineEdit::Normal, nick, &ok);
+ QString newNick = QInputDialog::getText(this, tr("Nickname"), tr("Someone already uses your nickname %1 on the server.\nPlease pick another nickname:").arg(nick), QLineEdit::Normal, nick, &ok);
if (!ok || newNick.isEmpty())
{
@@ -1229,10 +1232,10 @@
config->SaveOptions();
pnetserver = new HWNetServer;
- if(!pnetserver->StartServer(ui.pageNetServer->sbPort->value()))
+ if (!pnetserver->StartServer(ui.pageNetServer->sbPort->value()))
{
- QMessageBox::critical(0, tr("Error"),
- tr("Unable to start the server"));
+ ShowErrorMessage(QMessageBox::tr("Unable to start server"));
+
delete pnetserver;
pnetserver = 0;
return;
@@ -1271,14 +1274,20 @@
void HWForm::ForcedDisconnect(const QString & reason)
{
- if(pnetserver) return; // we have server - let it care of all things
+ if (pnetserver)
+ return; // we have server - let it care of all things
if (hwnet)
{
- QMessageBox::warning(this, QMessageBox::tr("Network"),
- QMessageBox::tr("Connection to server is lost") + (reason.isEmpty()?"":("\n\n" + HWNewNet::tr("Quit reason: ") + '"' + reason +'"')));
+ QString errorStr = QMessageBox::tr("Connection to server is lost") + (reason.isEmpty()?"":("\n\n" + HWNewNet::tr("Quit reason: ") + '"' + reason +'"'));
+ ShowErrorMessage(errorStr);
+ }
+ while (ui.Pages->currentIndex() != ID_PAGE_NET
+ && ui.Pages->currentIndex() != ID_PAGE_NETTYPE
+ && ui.Pages->currentIndex() != ID_PAGE_MAIN)
+ {
+ GoBack();
}
- if (ui.Pages->currentIndex() != ID_PAGE_NET) GoBack();
}
void HWForm::NetConnected()
@@ -1379,9 +1388,12 @@
void HWForm::ShowErrorMessage(const QString & msg)
{
- QMessageBox::warning(this,
- "Hedgewars",
- msg);
+ QMessageBox msgMsg(this);
+ msgMsg.setIcon(QMessageBox::Warning);
+ msgMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Error"));
+ msgMsg.setText(msg);
+ msgMsg.setWindowModality(Qt::WindowModal);
+ msgMsg.exec();
}
void HWForm::GetRecord(RecordType type, const QByteArray & record)
@@ -1674,8 +1686,17 @@
// hack to add user's settings to hwengine. might be better at this point to read in the file, append it, and write it out to its new home. This assumes no spaces in the data dir path
if (success) success = system(("sed -i 's/^\\(Exec=.*\\) \\([^ ]* %f\\)/\\1 "+cfgdir->absolutePath().replace(" ","\\\\ ").replace("/","\\/")+" \\2 --set-everything "+arguments+"/' "+QDir::home().absolutePath()+"/.local/share/applications/hwengine.desktop").toLocal8Bit().constData())==0;
#endif
- if (success) QMessageBox::information(0, "", QMessageBox::tr("All file associations have been set."));
- else QMessageBox::information(0, "", QMessageBox::tr("File association failed."));
+ if (success)
+ {
+ QMessageBox infoMsg(this);
+ infoMsg.setIcon(QMessageBox::Information);
+ infoMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Success"));
+ infoMsg.setText(QMessageBox::tr("All file associations have been set"));
+ infoMsg.setWindowModality(Qt::WindowModal);
+ infoMsg.exec();
+ }
+ else
+ ShowErrorMessage(QMessageBox::tr("File association failed."));
}
void HWForm::saveDemoWithCustomName()
@@ -1711,8 +1732,7 @@
//Create Xml representation of google code issue first
if (!CreateIssueXml())
{
- QMessageBox::warning(this, QMessageBox::tr("Fields required"),
- QMessageBox::tr("Please fill out all fields"));
+ ShowErrorMessage(QMessageBox::tr("Please fill out all fields"));
return;
}
@@ -1758,18 +1778,23 @@
if (authToken.length() != 0)
{
- QMessageBox::information(this, QMessageBox::tr("Success"),
- QMessageBox::tr("Successfully posted the issue on code.google.com!"));
+
+ QMessageBox infoMsg(this);
+ infoMsg.setIcon(QMessageBox::Information);
+ infoMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Success"));
+ infoMsg.setText(QMessageBox::tr("Successfully posted the issue on hedgewars.googlecode.com"));
+ infoMsg.setWindowModality(Qt::WindowModal);
+ infoMsg.exec();
+
ui.pageFeedback->summary->clear();
ui.pageFeedback->description->clear();
authToken = "";
return;
}
- if(!getAuthToken(str))
+ if (!getAuthToken(str))
{
- QMessageBox::warning(this, QMessageBox::tr("Network"),
- QMessageBox::tr("Error during authentication with www.google.com"));
+ ShowErrorMessage(QMessageBox::tr("Error during authentication at google.com"));
return;
}
@@ -1782,12 +1807,10 @@
}
else if (authToken.length() == 0)
- QMessageBox::warning(this, QMessageBox::tr("Network"),
- QMessageBox::tr("Error during authentication with www.google.com"));
+ ShowErrorMessage(QMessageBox::tr("Error during authentication at google.com"));
else
{
- QMessageBox::warning(this, QMessageBox::tr("Network"),
- QMessageBox::tr("Error creating the issue"));
+ ShowErrorMessage(QMessageBox::tr("Error reporting the issue, please try again later (or visit hedgewars.googlecode.com directly)"));
authToken = "";
}
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/main.cpp
--- a/QTfrontend/main.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/main.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -92,10 +92,12 @@
if (!tmpdir.exists(dir))
if (!tmpdir.mkdir(dir))
{
- QMessageBox::critical(0,
- QObject::tr("Error"),
- QObject::tr("Cannot create directory %1").arg(dir),
- QObject::tr("OK"));
+ QMessageBox directoryMsg(QApplication::activeWindow());
+ directoryMsg.setIcon(QMessageBox::Warning);
+ directoryMsg.setWindowTitle(QMessageBox::tr("Main - Error"));
+ directoryMsg.setText(QMessageBox::tr("Cannot create directory %1").arg(dir));
+ directoryMsg.setWindowModality(Qt::WindowModal);
+ directoryMsg.exec();
return false;
}
return true;
@@ -208,10 +210,14 @@
datadir->cd(*cDataDir);
if(!datadir->cd("hedgewars/Data"))
{
- QMessageBox::critical(0, QMessageBox::tr("Error"),
- QMessageBox::tr("Failed to open data directory:\n%1\n"
- "Please check your installation").
- arg(datadir->absolutePath()+"/hedgewars/Data"));
+ QMessageBox missingMsg(QApplication::activeWindow());
+ missingMsg.setIcon(QMessageBox::Critical);
+ missingMsg.setWindowTitle(QMessageBox::tr("Main - Error"));
+ missingMsg.setText(QMessageBox::tr("Failed to open data directory:\n%1\n\n"
+ "Please check your installation!").
+ arg(datadir->absolutePath()+"/hedgewars/Data"));
+ missingMsg.setWindowModality(Qt::WindowModal);
+ missingMsg.exec();
return 1;
}
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/model/playerslistmodel.cpp
--- a/QTfrontend/model/playerslistmodel.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/model/playerslistmodel.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -110,8 +110,9 @@
if(mil.size())
{
- setData(mil[0], "1", RoomFilterRole);
+ setData(mil[0], true, RoomFilterRole);
updateIcon(mil[0]);
+ updateSortData(mil[0]);
}
}
@@ -122,7 +123,10 @@
if(mil.size())
{
- setData(mil[0], "0", RoomFilterRole);
+ setData(mil[0], false, RoomFilterRole);
+ setData(mil[0], false, RoomAdmin);
+ setData(mil[0], false, Ready);
+ setData(mil[0], false, InGame);
updateIcon(mil[0]);
}
}
@@ -181,9 +185,9 @@
{
QModelIndex mi = index(i);
- if(mi.data(RoomFilterRole).toString() == "1")
+ if(mi.data(RoomFilterRole).toBool())
{
- setData(mi, "0", RoomFilterRole);
+ setData(mi, false, RoomFilterRole);
setData(mi, false, RoomAdmin);
setData(mi, false, Ready);
setData(mi, false, InGame);
@@ -207,7 +211,7 @@
<< index.data(Friend).toBool()
<< index.data(Ignore).toBool()
<< index.data(InGame).toBool()
- << (index.data(RoomFilterRole).toString() == "1")
+ << index.data(RoomFilterRole).toBool()
;
for(int i = flags.size() - 1; i >= 0; --i)
@@ -225,14 +229,20 @@
QPainter painter(&result);
- if(index.data(RoomFilterRole).toString() == "1")
+ if(index.data(RoomFilterRole).toBool())
+ {
if(index.data(InGame).toBool())
+ {
painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/ingame.png"));
+ }
else
+ {
if(index.data(Ready).toBool())
painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp.png"));
else
painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp_off.png"));
+ }
+ }
QString mainIconName(":/res/chat/");
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/net/netserver.cpp
--- a/QTfrontend/net/netserver.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/net/netserver.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -17,8 +17,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-#include
-
#include "hwconsts.h"
#include "netserver.h"
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/net/newnetclient.cpp
--- a/QTfrontend/net/newnetclient.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/net/newnetclient.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -53,7 +53,7 @@
m_roomPlayersModel->setDynamicSortFilter(true);
m_roomPlayersModel->sort(0);
m_roomPlayersModel->setFilterRole(PlayersListModel::RoomFilterRole);
- m_roomPlayersModel->setFilterFixedString("1");
+ m_roomPlayersModel->setFilterFixedString("true");
// socket stuff
connect(&NetSocket, SIGNAL(readyRead()), this, SLOT(ClientRead()));
@@ -102,9 +102,6 @@
RawSendNet(QString("CREATE_ROOM%1%2").arg(delimeter).arg(room));
isChief = true;
-
- //set our ready status to be true
- RawSendNet(QString("TOGGLE_READY"));
}
void HWNewNet::JoinRoom(const QString & room)
@@ -395,14 +392,12 @@
if (isChief && !setFlag) ToggleReady();
else emit setMyReadyStatus(setFlag);
}
- emit setReadyStatus(nick, setFlag);
m_playersModel->setFlag(nick, PlayersListModel::Ready, setFlag);
}
break;
// flag indicating if a player is a registered user
case 'u':
- emit setRegisteredStatus(nicks, setFlag);
foreach(const QString & nick, nicks)
m_playersModel->setFlag(nick, PlayersListModel::Registered, setFlag);
break;
@@ -422,7 +417,6 @@
emit roomMaster(isChief);
}
- emit setRoomMasterStatus(nick, setFlag);
m_playersModel->setFlag(nick, PlayersListModel::RoomAdmin, setFlag);
}
break;
@@ -434,7 +428,6 @@
if (nick == mynick)
emit adminAccess(setFlag);
- emit setAdminStatus(nick, setFlag);
m_playersModel->setFlag(nick, PlayersListModel::ServerAdmin, setFlag);
}
break;
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/net/newnetclient.h
--- a/QTfrontend/net/newnetclient.h Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/net/newnetclient.h Sat Nov 03 00:34:35 2012 +0400
@@ -145,11 +145,7 @@
void serverMessageOld(const QString &);
void latestProtocolVar(int);
- void setReadyStatus(const QString & nick, bool isReady);
void setMyReadyStatus(bool isReady);
- void setAdminStatus(const QString & nick, bool isAdmin);
- void setRoomMasterStatus(const QString & nick, bool isAdmin);
- void setRegisteredStatus(const QStringList & nicks, bool isRegistered);
public slots:
void ToggleReady();
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/net/recorder.cpp
--- a/QTfrontend/net/recorder.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/net/recorder.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -18,13 +18,12 @@
#include
#include
-//#include
#include "recorder.h"
#include "gameuiconfig.h"
#include "hwconsts.h"
#include "game.h"
-#include "libav_iteraction.h"
+#include "LibavInteraction.h"
// Encoding is memory expensive process, so we need to limit maximum number
// of simultaneous encoders.
@@ -39,7 +38,7 @@
this->config = config;
this->prefix = prefix;
finished = false;
- name = prefix + "." + LibavIteraction::instance().getExtension(config->AVFormat());
+ name = prefix + "." + LibavInteraction::instance().getExtension(config->AVFormat());
}
HWRecorder::~HWRecorder()
@@ -111,7 +110,7 @@
arguments << "0"; // sound volume
arguments << QString::number(config->timerInterval());
arguments << datadir->absolutePath();
- arguments << (config->isShowFPSEnabled() ? "1" : "0");
+ arguments << "0"; // fps
arguments << (config->isAltDamageEnabled() ? "1" : "0");
arguments << config->netNick().toUtf8().toBase64();
arguments << QString::number(config->translateQuality());
@@ -125,7 +124,7 @@
// Could use a field to use quality instead. maybe quality could override bitrate - or just pass (and set) both.
// The library does support using both at once after all.
arguments << QString::number(config->rec_Bitrate()*1024);
- arguments << (config->recordAudio()? config->audioCodec() : "no");
+ arguments << (config->recordAudio() ? config->audioCodec() : "no");
return arguments;
}
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/net/tcpBase.cpp
--- a/QTfrontend/net/tcpBase.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/net/tcpBase.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -21,7 +21,7 @@
#include
#include
-
+#include
#include
#include "hwconsts.h"
@@ -45,10 +45,14 @@
IPCServer->setMaxPendingConnections(1);
if (!IPCServer->listen(QHostAddress::LocalHost))
{
- QMessageBox::critical(0, tr("Error"),
- tr("Unable to start the server: %1.")
- .arg(IPCServer->errorString()));
- exit(0); // FIXME - should be graceful exit here
+ QMessageBox deniedMsg(QApplication::activeWindow());
+ deniedMsg.setIcon(QMessageBox::Critical);
+ deniedMsg.setWindowTitle(QMessageBox::tr("TCP - Error"));
+ deniedMsg.setText(QMessageBox::tr("Unable to start the server: %1.").arg(IPCServer->errorString()));
+ deniedMsg.setWindowModality(Qt::WindowModal);
+ deniedMsg.exec();
+
+ exit(0); // FIXME - should be graceful exit here (lower Critical -> Warning above when implemented)
}
}
ipc_port=IPCServer->serverPort();
@@ -113,9 +117,13 @@
void TCPBase::StartProcessError(QProcess::ProcessError error)
{
- QMessageBox::critical(0, tr("Error"),
- tr("Unable to run engine: %1 (")
- .arg(error) + bindir->absolutePath() + "/hwengine)");
+ QMessageBox deniedMsg(QApplication::activeWindow());
+ deniedMsg.setIcon(QMessageBox::Critical);
+ deniedMsg.setWindowTitle(QMessageBox::tr("TCP - Error"));
+ deniedMsg.setText(QMessageBox::tr("Unable to run engine at ") + bindir->absolutePath() + "/hwengine\n" +
+ QMessageBox::tr("Error code: %1").arg(error));
+ deniedMsg.setWindowModality(Qt::WindowModal);
+ deniedMsg.exec();
ClientDisconnect();
}
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/res/BackgroundBirthday.png
Binary file QTfrontend/res/BackgroundBirthday.png has changed
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/res/chat/hedgehog_gray.png
Binary file QTfrontend/res/chat/hedgehog_gray.png has changed
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/res/chat/roomadmin_gray.png
Binary file QTfrontend/res/chat/roomadmin_gray.png has changed
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/res/chat/serveradmin_gray.png
Binary file QTfrontend/res/chat/serveradmin_gray.png has changed
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/res/css/birthday.css
--- a/QTfrontend/res/css/birthday.css Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/res/css/birthday.css Sat Nov 03 00:34:35 2012 +0400
@@ -21,7 +21,7 @@
background-image: url(":/res/BackgroundBirthday.png");
background-position: bottom center;
background-repeat: repeat-x;
-background-color: #141250;
+background-color: #100308;
}
* {
@@ -32,16 +32,16 @@
a { color:#c8c8ff; }
-QLineEdit, QListWidget, QTableView, QTextBrowser, QSpinBox, QComboBox,
+QLineEdit, QListWidget, QListView, QTableView, QTextBrowser, QSpinBox, QComboBox,
QComboBox QAbstractItemView, QPlainTextEdit, QMenu::item {
-background-color: rgba(13, 5, 68, 70%);
+background-color: rgba(20, 20, 20, 70%);
}
QComboBox::separator {
border: solid; border-width: 3px; border-color: #ffcc00;
}
-QPushButton, QListWidget, QTableView, QLineEdit, QHeaderView,
+QPushButton, QListWidget, QListView, QTableView, QLineEdit, QHeaderView,
QTextBrowser, QSpinBox, QToolBox, QComboBox, QPlainTextEdit,
QComboBox QAbstractItemView, IconedGroupBox,
.QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget,
@@ -51,17 +51,17 @@
border-color: #ffcc00;
}
-QPushButton:hover, QLineEdit:hover, QListWidget:hover,
+QPushButton:hover, QLineEdit:hover, QListWidget:hover, QListView:hover,
QSpinBox:hover, QToolBox:hover, QComboBox:hover {
border-color: yellow;
}
-QLineEdit, QListWidget,QTableView, QTextBrowser,
+QLineEdit, QListWidget, QListView,QTableView, QTextBrowser,
QSpinBox, QToolBox, QPlainTextEdit {
border-radius: 10px;
}
-QLineEdit, QLabel, QHeaderView, QListWidget, QTableView,
+QLineEdit, QLabel, QHeaderView, QListWidget, QListView, QTableView,
QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView,
IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget,
SelWeaponWidget, QCheckBox, QRadioButton, QPushButton, QPlainTextEdit {
@@ -76,7 +76,7 @@
background-position: bottom center;
background-repeat: repeat-x;
border-radius: 16px;
-background-color: rgba(13, 5, 68, 70%);
+background-color: rgba(20, 20, 20, 70%);
padding: 6px;
}
/* Experimenting with PaintOnScreen and border-radius on IconedGroupBox children didn't work out well
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/res/css/christmas.css
--- a/QTfrontend/res/css/christmas.css Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/res/css/christmas.css Sat Nov 03 00:34:35 2012 +0400
@@ -32,7 +32,7 @@
a { color:#c8c8ff; }
-QLineEdit, QListWidget, QTableView, QTextBrowser, QSpinBox, QComboBox,
+QLineEdit, QListWidget, QListView, QTableView, QTextBrowser, QSpinBox, QComboBox,
QComboBox QAbstractItemView, QPlainTextEdit, QMenu::item {
background-color: rgba(13, 5, 68, 70%);
}
@@ -41,7 +41,7 @@
border: solid; border-width: 3px; border-color: #ffcc00;
}
-QPushButton, QListWidget, QTableView, QLineEdit, QHeaderView,
+QPushButton, QListWidget, QListView, QTableView, QLineEdit, QHeaderView,
QTextBrowser, QSpinBox, QToolBox, QComboBox, QPlainTextEdit,
QComboBox QAbstractItemView, IconedGroupBox,
.QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget,
@@ -51,17 +51,17 @@
border-color: #ffcc00;
}
-QPushButton:hover, QLineEdit:hover, QListWidget:hover,
+QPushButton:hover, QLineEdit:hover, QListWidget:hover, QListView:hover,
QSpinBox:hover, QToolBox:hover, QComboBox:hover {
border-color: yellow;
}
-QLineEdit, QListWidget,QTableView, QTextBrowser,
+QLineEdit, QListWidget, QListView,QTableView, QTextBrowser,
QSpinBox, QToolBox, QPlainTextEdit {
border-radius: 10px;
}
-QLineEdit, QLabel, QHeaderView, QListWidget, QTableView,
+QLineEdit, QLabel, QHeaderView, QListWidget, QListView, QTableView,
QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView,
IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget,
SelWeaponWidget, QCheckBox, QRadioButton, QPushButton, QPlainTextEdit {
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/res/css/easter.css
--- a/QTfrontend/res/css/easter.css Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/res/css/easter.css Sat Nov 03 00:34:35 2012 +0400
@@ -32,7 +32,7 @@
a { color:#c8c8ff; }
-QLineEdit, QListWidget, QTableView, QTextBrowser, QSpinBox, QComboBox,
+QLineEdit, QListWidget, QListView, QTableView, QTextBrowser, QSpinBox, QComboBox,
QComboBox QAbstractItemView, QPlainTextEdit, QMenu::item {
background-color: rgba(13, 5, 68, 70%);
}
@@ -41,7 +41,7 @@
border: solid; border-width: 3px; border-color: #ffcc00;
}
-QPushButton, QListWidget, QTableView, QLineEdit, QHeaderView,
+QPushButton, QListWidget, QListView, QTableView, QLineEdit, QHeaderView,
QTextBrowser, QSpinBox, QToolBox, QComboBox, QPlainTextEdit,
QComboBox QAbstractItemView, IconedGroupBox,
.QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget,
@@ -51,17 +51,17 @@
border-color: #ffcc00;
}
-QPushButton:hover, QLineEdit:hover, QListWidget:hover,
+QPushButton:hover, QLineEdit:hover, QListWidget:hover, QListView:hover,
QSpinBox:hover, QToolBox:hover, QComboBox:hover {
border-color: yellow;
}
-QLineEdit, QListWidget,QTableView, QTextBrowser,
+QLineEdit, QListWidget, QListView,QTableView, QTextBrowser,
QSpinBox, QToolBox, QPlainTextEdit {
border-radius: 10px;
}
-QLineEdit, QLabel, QHeaderView, QListWidget, QTableView,
+QLineEdit, QLabel, QHeaderView, QListWidget, QListView, QTableView,
QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView,
IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget,
SelWeaponWidget, QCheckBox, QRadioButton, QPushButton, QPlainTextEdit {
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/res/css/qt.css
--- a/QTfrontend/res/css/qt.css Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/res/css/qt.css Sat Nov 03 00:34:35 2012 +0400
@@ -116,17 +116,18 @@
alternate-background-color: #2f213a;
gridline-color: transparent;
}
-
+QTabWidget::pane { top: -2px; }
QTabBar::tab {
-border-bottom-width: 0;
border-radius: 0;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
padding: 3px;
+background-color: #00351d;
+color: #ffcc00;
}
-QTabBar::tab:!selected {
-color: #0d0544;
-background-color: #ffcc00;
+QTabBar::tab:selected {
+border-bottom-color: #0d0544;
+border-bottom-width: 0;
}
QSpinBox::up-button{
background: transparent;
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/dialog/ask_quit.cpp
--- a/QTfrontend/ui/dialog/ask_quit.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/dialog/ask_quit.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -30,14 +30,14 @@
{
this->form = form;
- setWindowTitle(tr("Do yot really want to quit?"));
+ setWindowTitle(tr("Do you really want to quit?"));
QVBoxLayout * layout = new QVBoxLayout(this);
QLabel * lbLabel = new QLabel(this);
lbLabel->setText(QLabel::tr("There are videos that are currently being processed.\n"
"Exiting now will abort them.\n"
- "Do yot really want to quit?"));
+ "Do you really want to quit?"));
layout->addWidget(lbLabel);
lbList = new QLabel(this);
@@ -58,6 +58,8 @@
QTimer * timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateList()));
timer->start(200);
+
+ this->setWindowModality(Qt::WindowModal);
}
void HWAskQuitDialog::goToPageVideos()
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/dialog/input_ip.cpp
--- a/QTfrontend/ui/dialog/input_ip.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/dialog/input_ip.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -60,6 +60,8 @@
connect(pbOK, SIGNAL(clicked()), this, SLOT(accept()));
connect(pbCancel, SIGNAL(clicked()), this, SLOT(reject()));
connect(pbDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort()));
+
+ this->setWindowModality(Qt::WindowModal);
}
void HWHostPortDialog::setDefaultPort()
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/dialog/input_password.cpp
--- a/QTfrontend/ui/dialog/input_password.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/dialog/input_password.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -50,4 +50,6 @@
connect(pbOK, SIGNAL(clicked()), this, SLOT(accept()));
connect(pbCancel, SIGNAL(clicked()), this, SLOT(reject()));
+
+ this->setWindowModality(Qt::WindowModal);
}
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/dialog/upload_video.cpp
--- a/QTfrontend/ui/dialog/upload_video.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/dialog/upload_video.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -32,7 +32,6 @@
#include
#include
#include
-#include
#include "upload_video.h"
#include "hwconsts.h"
@@ -159,6 +158,8 @@
connect(btnUpload, SIGNAL(clicked()), this, SLOT(upload()));
connect(pbCancel, SIGNAL(clicked()), this, SLOT(reject()));
+
+ this->setWindowModality(Qt::WindowModal);
}
void HWUploadVideoDialog::showEvent(QShowEvent * event)
@@ -233,7 +234,14 @@
errorStr += QMessageBox::tr("Login or password is incorrect");
else
errorStr += reply->errorString();
- QMessageBox::warning(this, QMessageBox::tr("Error"), errorStr);
+
+ QMessageBox deniedMsg(this);
+ deniedMsg.setIcon(QMessageBox::Warning);
+ deniedMsg.setWindowTitle(QMessageBox::tr("Video upload - Error"));
+ deniedMsg.setText(errorStr);
+ deniedMsg.setWindowModality(Qt::WindowModal);
+ deniedMsg.exec();
+
setEditable(true);
return;
}
@@ -288,7 +296,14 @@
{
QString errorStr = QMessageBox::tr("Error while sending metadata to youtube.com:\n");
errorStr += reply->errorString();
- QMessageBox::warning(this, QMessageBox::tr("Error"), errorStr);
+
+ QMessageBox deniedMsg(this);
+ deniedMsg.setIcon(QMessageBox::Warning);
+ deniedMsg.setWindowTitle(QMessageBox::tr("Video upload - Error"));
+ deniedMsg.setText(errorStr);
+ deniedMsg.setWindowModality(Qt::WindowModal);
+ deniedMsg.exec();
+
setEditable(true);
return;
}
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/page/AbstractPage.cpp
--- a/QTfrontend/ui/page/AbstractPage.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/page/AbstractPage.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -25,8 +25,8 @@
#include
#include
#include
-#include
-#include
+
+#include "qpushbuttonwithsound.h"
AbstractPage::AbstractPage(QWidget* parent)
{
@@ -93,6 +93,27 @@
}
return btn;
}
+QPushButton* AbstractPage::formattedSoundlessButton(const QString & name, bool hasIcon)
+{
+ QPushButton* btn = new QPushButton(this);
+
+ if (hasIcon)
+ {
+ const QIcon& lp=QIcon(name);
+ QSize sz = lp.actualSize(QSize(65535, 65535));
+ btn->setIcon(lp);
+ btn->setFixedSize(sz);
+ btn->setIconSize(sz);
+ btn->setFlat(true);
+ btn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ }
+ else
+ {
+ btn->setFont(*font14);
+ btn->setText(name);
+ }
+ return btn;
+}
QPushButtonWithSound * AbstractPage::addButton(const QString & name, QGridLayout * grid, int row, int column, int rowSpan, int columnSpan, bool hasIcon)
{
@@ -108,6 +129,13 @@
return btn;
}
+QPushButton* AbstractPage::addSoundlessButton(const QString & name, QBoxLayout * box, int where, bool hasIcon)
+{
+ QPushButton* btn = formattedSoundlessButton(name, hasIcon);
+ box->addWidget(btn, where);
+ return btn;
+}
+
void AbstractPage::setBackButtonVisible(bool visible)
{
btnBack->setVisible(visible);
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/page/AbstractPage.h
--- a/QTfrontend/ui/page/AbstractPage.h Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/page/AbstractPage.h Sat Nov 03 00:34:35 2012 +0400
@@ -138,6 +138,7 @@
* @return the button.
*/
QPushButtonWithSound * formattedButton(const QString & name, bool hasIcon = false);
+ QPushButton * formattedSoundlessButton(const QString & name, bool hasIcon = false);
/**
* @brief Creates a default formatted button and adds it to a
@@ -167,6 +168,7 @@
* @return the button.
*/
QPushButtonWithSound * addButton(const QString & name, QBoxLayout * box, int where, bool hasIcon = false);
+ QPushButton* addSoundlessButton(const QString & name, QBoxLayout * box, int where, bool hasIcon = false);
/**
* @brief Changes visibility of the back-button.
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/page/pagedata.cpp
--- a/QTfrontend/ui/page/pagedata.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/page/pagedata.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -222,10 +222,7 @@
return false;
}
- if (this->isVisible())
- m_contentDownloaded = true;
- else
- DataManager::instance().reload();
+ m_contentDownloaded = true;
}
file.close();
@@ -248,6 +245,6 @@
if (m_contentDownloaded)
{
m_contentDownloaded = false;
- DataManager::instance().reload();
+ //DataManager::instance().reload();
}
}
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/page/pageeditteam.cpp
--- a/QTfrontend/ui/page/pageeditteam.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/page/pageeditteam.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -134,7 +134,7 @@
CBVoicepack = new QComboBox(GBoxTeam);
hbox->addWidget(CBVoicepack, 100);
- btnTestSound = addButton(":/res/PlaySound.png", hbox, 1, true);
+ btnTestSound = addSoundlessButton(":/res/PlaySound.png", hbox, 1, true);
hbox->setStretchFactor(btnTestSound, 1);
GBTLayout->addLayout(hbox, 4, 1);
@@ -383,9 +383,14 @@
void PageEditTeam::deleteTeam(const QString & name)
{
- QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Teams"), QMessageBox::tr("Really delete this team?"), QMessageBox::Ok | QMessageBox::Cancel, this);
+ QMessageBox reallyDeleteMsg(this);
+ reallyDeleteMsg.setIcon(QMessageBox::Question);
+ reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Teams - Are you sure?"));
+ reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the team '%1'?").arg(name));
+ reallyDeleteMsg.setWindowModality(Qt::WindowModal);
+ reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
- if (reallyDelete.exec() == QMessageBox::Ok)
+ if (reallyDeleteMsg.exec() == QMessageBox::Ok)
HWTeam(name).deleteFile();
}
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/page/pagegamestats.cpp
--- a/QTfrontend/ui/page/pagegamestats.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/page/pagegamestats.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -140,7 +140,7 @@
while (i != healthPoints.constEnd())
{
quint32 c = i.key();
- QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255));
+ //QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255));
QVector hps = i.value();
QPainterPath path;
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/page/pagemain.cpp
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/page/pagenet.cpp
--- a/QTfrontend/ui/page/pagenet.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/page/pagenet.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -108,7 +108,12 @@
QModelIndex mi = tvServersList->currentIndex();
if(!mi.isValid())
{
- QMessageBox::information(this, tr("Error"), tr("Please select server from the list above"));
+ QMessageBox serverMsg(this);
+ serverMsg.setIcon(QMessageBox::Warning);
+ serverMsg.setWindowTitle(QMessageBox::tr("Netgame - Error"));
+ serverMsg.setText(QMessageBox::tr("Please select a server from the list"));
+ serverMsg.setWindowModality(Qt::WindowModal);
+ serverMsg.exec();
return;
}
QString host = model->index(mi.row(), 1).data().toString();
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/page/pagenetgame.cpp
--- a/QTfrontend/ui/page/pagenetgame.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/page/pagenetgame.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -62,9 +62,6 @@
{
QHBoxLayout * bottomLayout = new QHBoxLayout;
- btnDLC = addButton(tr("DLC"), bottomLayout, 0);
- btnDLC->setWhatsThis(tr("Downloadable Content"));
-
leRoomName = new HistoryLineEdit(this,10);
leRoomName->setMaxLength(60);
leRoomName->setMinimumWidth(200);
@@ -79,23 +76,21 @@
BtnGo->setMinimumHeight(50);
bottomLayout->addWidget(leRoomName);
- BtnUpdate = addButton(QAction::tr("Update"), bottomLayout, 2);
+ BtnUpdate = addButton(QAction::tr("Update"), bottomLayout, 1);
bottomLayout->addStretch();
bottomLayout->addWidget(BtnGo);
- BtnMaster = addButton(tr("Control"), bottomLayout, 4);
+ BtnMaster = addButton(tr("Control"), bottomLayout, 3);
bottomLayout->insertStretch(3, 100);
- BtnStart = addButton(QAction::tr("Start"), bottomLayout, 4);
+ BtnStart = addButton(QAction::tr("Start"), bottomLayout, 3);
return bottomLayout;
}
void PageNetGame::connectSignals()
{
- connect(btnDLC, SIGNAL(clicked()), this, SIGNAL(DLCClicked()));
-
connect(btnSetup, SIGNAL(clicked()), this, SIGNAL(SetupClicked()));
connect(BtnUpdate, SIGNAL(clicked()), this, SLOT(onUpdateClick()));
@@ -157,10 +152,12 @@
else
{
leRoomName->clear();
- QMessageBox::critical(this,
- tr("Error"),
- tr("Please enter room name"),
- tr("OK"));
+ QMessageBox roomMsg(this);
+ roomMsg.setIcon(QMessageBox::Warning);
+ roomMsg.setWindowTitle(QMessageBox::tr("Netgame - Error"));
+ roomMsg.setText(QMessageBox::tr("Please enter room name"));
+ roomMsg.setWindowModality(Qt::WindowModal);
+ roomMsg.exec();
}
}
@@ -177,10 +174,6 @@
BtnStart->setVisible(isMaster);
BtnUpdate->setVisible(isMaster);
leRoomName->setVisible(isMaster);
-
- //disable the `toggle ready` button, because the start button does the same
- //job when the user is chief
- BtnGo->setVisible(!isMaster);
}
void PageNetGame::setUser(const QString & nickname)
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/page/pagenetgame.h
--- a/QTfrontend/ui/page/pagenetgame.h Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/page/pagenetgame.h Sat Nov 03 00:34:35 2012 +0400
@@ -65,7 +65,6 @@
signals:
void SetupClicked();
- void DLCClicked();
void askForUpdateRoomName(const QString &);
private:
@@ -77,7 +76,6 @@
HistoryLineEdit * leRoomName;
QPushButton * btnSetup;
- QPushButton * btnDLC;
};
#endif
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/page/pageplayrecord.cpp
--- a/QTfrontend/ui/page/pageplayrecord.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/page/pageplayrecord.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -120,10 +120,12 @@
QListWidgetItem * curritem = DemosList->currentItem();
if (!curritem)
{
- QMessageBox::critical(this,
- tr("Error"),
- tr("Please select record from the list"),
- tr("OK"));
+ QMessageBox recordMsg(this);
+ recordMsg.setIcon(QMessageBox::Warning);
+ recordMsg.setWindowTitle(QMessageBox::tr("Record Play - Error"));
+ recordMsg.setText(QMessageBox::tr("Please select record from the list"));
+ recordMsg.setWindowModality(Qt::WindowModal);
+ recordMsg.exec();
return ;
}
QFile rfile(curritem->data(Qt::UserRole).toString());
@@ -144,7 +146,14 @@
ok = rfile.rename(newfullname);
if(!ok)
- QMessageBox::critical(this, tr("Error"), tr("Cannot rename to") + newfullname);
+ {
+ QMessageBox renameMsg(this);
+ renameMsg.setIcon(QMessageBox::Warning);
+ renameMsg.setWindowTitle(QMessageBox::tr("Record Play - Error"));
+ renameMsg.setText(QMessageBox::tr("Cannot rename to ") + newfullname);
+ renameMsg.setWindowModality(Qt::WindowModal);
+ renameMsg.exec();
+ }
else
FillFromDir(recType);
}
@@ -155,10 +164,12 @@
QListWidgetItem * curritem = DemosList->currentItem();
if (!curritem)
{
- QMessageBox::critical(this,
- tr("Error"),
- tr("Please select record from the list"),
- tr("OK"));
+ QMessageBox recordMsg(this);
+ recordMsg.setIcon(QMessageBox::Warning);
+ recordMsg.setWindowTitle(QMessageBox::tr("Record Play - Error"));
+ recordMsg.setText(QMessageBox::tr("Please select record from the list"));
+ recordMsg.setWindowModality(Qt::WindowModal);
+ recordMsg.exec();
return ;
}
QFile rfile(curritem->data(Qt::UserRole).toString());
@@ -167,7 +178,14 @@
ok = rfile.remove();
if(!ok)
- QMessageBox::critical(this, tr("Error"), tr("Cannot delete file"));
+ {
+ QMessageBox removeMsg(this);
+ removeMsg.setIcon(QMessageBox::Warning);
+ removeMsg.setWindowTitle(QMessageBox::tr("Record Play - Error"));
+ removeMsg.setText(QMessageBox::tr("Cannot delete file ") + rfile.fileName());
+ removeMsg.setWindowModality(Qt::WindowModal);
+ removeMsg.exec();
+ }
else
{
int i = DemosList->row(curritem);
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/page/pageroomslist.cpp
--- a/QTfrontend/ui/page/pageroomslist.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/page/pageroomslist.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -101,7 +101,6 @@
BtnCreate = addButton(tr("Create"), pageLayout, 0, 2);
BtnJoin = addButton(tr("Join"), pageLayout, 1, 2);
- BtnRefresh = addButton(tr("Refresh"), pageLayout, 3, 2);
BtnClear = addButton(tr("Clear"), pageLayout, 4, 2);
// strech all but the buttons column
@@ -143,7 +142,6 @@
connect(BtnCreate, SIGNAL(clicked()), this, SLOT(onCreateClick()));
connect(BtnJoin, SIGNAL(clicked()), this, SLOT(onJoinClick()));
- connect(BtnRefresh, SIGNAL(clicked()), this, SLOT(onRefreshClick()));
connect(BtnClear, SIGNAL(clicked()), this, SLOT(onClearClick()));
connect(roomsList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(onJoinClick()));
connect(CBState, SIGNAL(currentIndexChanged (int)), this, SLOT(onFilterChanged()));
@@ -426,10 +424,14 @@
if (roomName->text().size())
emit askForCreateRoom(roomName->text());
else
- QMessageBox::critical(this,
- tr("Error"),
- tr("Please enter room name"),
- tr("OK"));
+ {
+ QMessageBox roomNameMsg(this);
+ roomNameMsg.setIcon(QMessageBox::Warning);
+ roomNameMsg.setWindowTitle(QMessageBox::tr("Room Name - Error"));
+ roomNameMsg.setText(QMessageBox::tr("Please enter room name"));
+ roomNameMsg.setWindowModality(Qt::WindowModal);
+ roomNameMsg.exec();
+ }
}
void PageRoomsList::onJoinClick()
@@ -438,10 +440,12 @@
if(mdl.size() != 1)
{
- QMessageBox::critical(this,
- tr("Error"),
- tr("Please select room from the list"),
- tr("OK"));
+ QMessageBox roomNameMsg(this);
+ roomNameMsg.setIcon(QMessageBox::Warning);
+ roomNameMsg.setWindowTitle(QMessageBox::tr("Room Name - Error"));
+ roomNameMsg.setText(QMessageBox::tr("Please select room from the list"));
+ roomNameMsg.setWindowModality(Qt::WindowModal);
+ roomNameMsg.exec();
return;
}
@@ -469,10 +473,15 @@
void PageRoomsList::onJoinConfirmation(const QString & room)
{
- if (QMessageBox::warning(this,
- tr("Warning"),
- tr("The game you are trying to join has started.\nDo you still want to join the room?"),
- QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
+
+ QMessageBox reallyJoinMsg(this);
+ reallyJoinMsg.setIcon(QMessageBox::Question);
+ reallyJoinMsg.setWindowTitle(QMessageBox::tr("Room Name - Are you sure?"));
+ reallyJoinMsg.setText(QMessageBox::tr("The game you are trying to join has started.\nDo you still want to join the room?"));
+ reallyJoinMsg.setWindowModality(Qt::WindowModal);
+ reallyJoinMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
+
+ if (reallyJoinMsg.exec() == QMessageBox::Ok)
{
emit askForJoinRoom(room);
}
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/page/pageroomslist.h
--- a/QTfrontend/ui/page/pageroomslist.h Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/page/pageroomslist.h Sat Nov 03 00:34:35 2012 +0400
@@ -42,7 +42,6 @@
QTableView * roomsList;
QPushButton * BtnCreate;
QPushButton * BtnJoin;
- QPushButton * BtnRefresh;
QPushButton * BtnAdmin;
QPushButton * BtnClear;
QComboBox * CBState;
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/page/pagescheme.cpp
--- a/QTfrontend/ui/page/pagescheme.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/page/pagescheme.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -516,12 +516,30 @@
void PageScheme::deleteRow()
{
- QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Schemes"), QMessageBox::tr("Really delete this game scheme?"), QMessageBox::Ok | QMessageBox::Cancel);
+ int numberOfDefaultSchemes = ((AmmoSchemeModel*)mapper->model())->numberOfDefaultSchemes;
+ if (selectScheme->currentIndex() < numberOfDefaultSchemes)
+ {
+ QMessageBox deniedMsg(this);
+ deniedMsg.setIcon(QMessageBox::Warning);
+ deniedMsg.setWindowTitle(QMessageBox::tr("Schemes - Warning"));
+ deniedMsg.setText(QMessageBox::tr("Cannot delete default scheme '%1'!").arg(selectScheme->currentText()));
+ deniedMsg.setWindowModality(Qt::WindowModal);
+ deniedMsg.exec();
+ }
+ else
+ {
+ QMessageBox reallyDeleteMsg(this);
+ reallyDeleteMsg.setIcon(QMessageBox::Question);
+ reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Schemes - Are you sure?"));
+ reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the game scheme '%1'?").arg(selectScheme->currentText()));
+ reallyDeleteMsg.setWindowModality(Qt::WindowModal);
+ reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
- if (reallyDelete.exec() == QMessageBox::Ok)
- {
- QAbstractItemModel * model = mapper->model();
- model->removeRow(selectScheme->currentIndex());
+ if (reallyDeleteMsg.exec() == QMessageBox::Ok)
+ {
+ QAbstractItemModel * model = mapper->model();
+ model->removeRow(selectScheme->currentIndex());
+ }
}
}
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/page/pagevideos.cpp
--- a/QTfrontend/ui/page/pagevideos.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/page/pagevideos.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -47,7 +47,7 @@
#include "hwconsts.h"
#include "pagevideos.h"
#include "igbox.h"
-#include "libav_iteraction.h"
+#include "LibavInteraction.h"
#include "gameuiconfig.h"
#include "recorder.h"
#include "ask_quit.h"
@@ -92,7 +92,7 @@
};
VideoItem::VideoItem(const QString& name)
- : QTableWidgetItem(name, UserType)
+: QTableWidgetItem(name, UserType)
{
this->name = name;
pRecorder = NULL;
@@ -128,7 +128,7 @@
// list of supported formats
comboAVFormats = new QComboBox(pOptionsGroup);
pOptLayout->addWidget(comboAVFormats, 0, 1, 1, 4);
- LibavIteraction::instance().fillFormats(comboAVFormats);
+ LibavInteraction::instance().fillFormats(comboAVFormats);
// separator
QFrame * hr = new QFrame(pOptionsGroup);
@@ -217,6 +217,7 @@
// button 'set default options'
btnDefaults = new QPushButton(pOptionsGroup);
btnDefaults->setText(QPushButton::tr("Set default options"));
+ btnDefaults->setWhatsThis(QPushButton::tr("Restore default coding parameters"));
pOptLayout->addWidget(btnDefaults, 7, 0, 1, 5);
pPageLayout->addWidget(pOptionsGroup, 1, 0);
@@ -250,6 +251,7 @@
header->setStretchLastSection(true);
btnOpenDir = new QPushButton(QPushButton::tr("Open videos directory"), pTableGroup);
+ btnOpenDir->setWhatsThis(QPushButton::tr("Open the video directory in your system"));
QVBoxLayout *box = new QVBoxLayout(pTableGroup);
box->addWidget(filesTable);
@@ -296,12 +298,15 @@
// buttons: play and delete
btnPlay = new QPushButton(QPushButton::tr("Play"), pDescGroup);
btnPlay->setEnabled(false);
+ btnPlay->setWhatsThis(QPushButton::tr("Play this video"));
pBottomDescLayout->addWidget(btnPlay);
btnDelete = new QPushButton(QPushButton::tr("Delete"), pDescGroup);
btnDelete->setEnabled(false);
+ btnDelete->setWhatsThis(QPushButton::tr("Delete this video"));
pBottomDescLayout->addWidget(btnDelete);
btnToYouTube = new QPushButton(QPushButton::tr("Upload to YouTube"), pDescGroup);
btnToYouTube->setEnabled(false);
+ btnToYouTube->setWhatsThis(QPushButton::tr("Upload this video to your Youtube account"));
pBottomDescLayout->addWidget(btnToYouTube);
pDescLayout->addStretch(1);
@@ -369,7 +374,7 @@
comboAudioCodecs->clear();
// get list of codecs for specified format
- LibavIteraction::instance().fillCodecs(comboAVFormats->itemData(index).toString(), comboVideoCodecs, comboAudioCodecs);
+ LibavInteraction::instance().fillCodecs(comboAVFormats->itemData(index).toString(), comboVideoCodecs, comboAudioCodecs);
// disable audio if there is no audio codec
if (comboAudioCodecs->count() == 0)
@@ -411,13 +416,14 @@
void PageVideos::setDefaultCodecs()
{
- if (tryCodecs("mp4", "libx264", "libmp3lame"))
+ // VLC should be able to handle any of these configurations
+ // Quicktime X only opens the first one
+ // Windows Media Player TODO
+ if (tryCodecs("mp4", "libx264", "aac"))
return;
if (tryCodecs("mp4", "libx264", "libfaac"))
return;
- if (tryCodecs("mp4", "libx264", "libvo_aacenc"))
- return;
- if (tryCodecs("mp4", "libx264", "aac"))
+ if (tryCodecs("mp4", "libx264", "libmp3lame"))
return;
if (tryCodecs("mp4", "libx264", "mp2"))
return;
@@ -442,8 +448,8 @@
void PageVideos::setDefaultOptions()
{
- framerateBox->setValue(25);
- bitrateBox->setValue(400);
+ framerateBox->setValue(30);
+ bitrateBox->setValue(1000);
checkRecordAudio->setChecked(true);
checkUseGameRes->setChecked(true);
setDefaultCodecs();
@@ -645,7 +651,7 @@
}
#ifdef Q_WS_WIN
// there is a bug in qt, QDir::rename() doesn't fail on such names but damages files
- if (newName.contains(QRegExp("[\"*:<>?\/|]")))
+ if (newName.contains(QRegExp("[\"*:<>?\\/|]")))
{
setName(item, oldName);
return;
@@ -743,7 +749,7 @@
{
// Extract description from file;
// It will contain duration, resolution, etc and also comment added by hwengine.
- item->desc = LibavIteraction::instance().getFileInfo(path);
+ item->desc = LibavInteraction::instance().getFileInfo(path);
// extract prefix (original name) from description (it is enclosed in prefix[???]prefix)
int prefixBegin = item->desc.indexOf("prefix[");
@@ -839,18 +845,26 @@
return;
// ask user if (s)he is serious
- if (QMessageBox::question(this,
- tr("Are you sure?"),
- tr("Do you really want do remove %1?").arg(item->name),
- QMessageBox::Yes | QMessageBox::No)
- != QMessageBox::Yes)
+ QMessageBox reallyDeleteMsg(this);
+ reallyDeleteMsg.setIcon(QMessageBox::Question);
+ reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Videos - Are you sure?"));
+ reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the video '%1'?").arg(item->name));
+ reallyDeleteMsg.setWindowModality(Qt::WindowModal);
+ reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
+
+ if (reallyDeleteMsg.exec() != QMessageBox::Ok)
return;
// remove
if (!item->ready())
item->pRecorder->deleteLater();
else
+ {
cfgdir->remove("Videos/" + item->name);
+ // we have no idea whether screenshot is going to be bmp or png so let's delete both
+ cfgdir->remove("VideoTemp/" + item->prefix + ".png");
+ cfgdir->remove("VideoTemp/" + item->prefix + ".bmp");
+ }
// this code is for removing several files when multiple selection is enabled
#if 0
@@ -860,11 +874,14 @@
return;
// ask user if (s)he is serious
- if (QMessageBox::question(this,
- tr("Are you sure?"),
- tr("Do you really want do remove %1 file(s)?", "", num).arg(num),
- QMessageBox::Yes | QMessageBox::No)
- != QMessageBox::Yes)
+ QMessageBox reallyDeleteMsg(this);
+ reallyDeleteMsg.setIcon(QMessageBox::Question);
+ reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Videos - Are you sure?"));
+ reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to remove %1 file(s)?", "", num).arg(num));
+ reallyDeleteMsg.setWindowModality(Qt::WindowModal);
+ reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
+
+ if (reallyDeleteMsg.exec() != QMessageBox::Ok)
return;
// remove
@@ -1081,11 +1098,15 @@
if (item->pUploading)
{
- if (QMessageBox::question(this,
- tr("Are you sure?"),
- tr("Do you really want do cancel uploading %1?").arg(item->name),
- QMessageBox::Yes | QMessageBox::No)
- != QMessageBox::Yes)
+ // ask user if (s)he is serious
+ QMessageBox reallyStopMsg(this);
+ reallyStopMsg.setIcon(QMessageBox::Question);
+ reallyStopMsg.setWindowTitle(QMessageBox::tr("Videos - Are you sure?"));
+ reallyStopMsg.setText(QMessageBox::tr("Do you really want to cancel uploading %1?").arg(item->name));
+ reallyStopMsg.setWindowModality(Qt::WindowModal);
+ reallyStopMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
+
+ if (reallyStopMsg.exec() != QMessageBox::Ok)
return;
item->pUploading->deleteLater();
filesTable->setCellWidget(row, vcProgress, NULL); // remove progress bar
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/widget/about.cpp
--- a/QTfrontend/ui/widget/about.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/widget/about.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -85,6 +85,10 @@
"Lua game modes and missions: John Lambert <redgrinner@gmail.com>
"
"Frontend improvements: Mayur Pawashe <zorgiepoo@gmail.com>
"
"Android port: Richard Deurwaarder <xeli@xelification.com>
"
+ "Android netplay, portability abstraction: Simeon Maxein <smaxein@googlemail.com>
"
+ "WebGL port, some pas2c and GLES2 work: Meng Xiangyun <xymengxy@gmail.com>
"
+ "Video recording: Stepan Podoskin <stepik-777@mail.ru>
"
+ "Campaign support, first campaign: Szabolcs Orbà n <szabibibi@gmail.com>
"
"
" +
QLabel::tr("Art:") + "
"
@@ -123,7 +127,7 @@
"Chinese: Jie Luo <lililjlj@gmail.com>
"
"English: Andrey Korotaev <unC0Rr@gmail.com>
"
"Finnish: Nina Kuisma <ninnnu@gmail.com>
"
- "French: Antoine Turmel <geekshadow@gmail.com>
"
+ "French: Antoine Turmel <geekshadow@gmail.com>, Clement Woitrain <sphrixclement@gmail.com>
"
"German: Peter Hüwe <PeterHuewe@gmx.de>, Mario Liebisch <mario.liebisch@gmail.com>, Richard Karolyi <sheepluva@" "ercatec.net>
"
"Greek: <talos_kriti@yahoo.gr>
"
"Italian: Luca Bonora <bonora.luca@gmail.com>, Marco Bresciani
"
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/widget/chatwidget.cpp
--- a/QTfrontend/ui/widget/chatwidget.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/widget/chatwidget.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -532,9 +532,9 @@
QString hlRegExp("^(.* )?%1[^-a-z0-9_]*( .*)?$");
QRegExp whitespace("\\s");
- m_highlights.append(QRegExp(hlRegExp.arg(m_userNick)));
+ m_highlights.append(QRegExp(hlRegExp.arg(m_userNick.toLower())));
- QFile file(cfgdir->absolutePath() + "/" + m_userNick + "_highlight.txt");
+ QFile file(cfgdir->absolutePath() + "/" + m_userNick.toLower() + "_highlight.txt");
if (file.exists() && (file.open(QIODevice::ReadOnly | QIODevice::Text)))
{
@@ -554,7 +554,7 @@
file.close();
}
- QFile file2(cfgdir->absolutePath() + "/" + m_userNick + "_hlregexp.txt");
+ QFile file2(cfgdir->absolutePath() + "/" + m_userNick.toLower() + "_hlregexp.txt");
if (file2.exists() && (file2.open(QIODevice::ReadOnly | QIODevice::Text)))
{
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/widget/drawmapwidget.cpp
--- a/QTfrontend/ui/widget/drawmapwidget.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/widget/drawmapwidget.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -95,7 +95,14 @@
QFile file(fileName);
if(!file.open(QIODevice::WriteOnly))
- QMessageBox::warning(this, tr("File error"), tr("Cannot open file '%1' for writing").arg(fileName));
+ {
+ QMessageBox errorMsg(this);
+ errorMsg.setIcon(QMessageBox::Warning);
+ errorMsg.setWindowTitle(QMessageBox::tr("File error"));
+ errorMsg.setText(QMessageBox::tr("Cannot open '%1' for writing").arg(fileName));
+ errorMsg.setWindowModality(Qt::WindowModal);
+ errorMsg.exec();
+ }
else
file.write(qCompress(m_scene->encode()).toBase64());
}
@@ -108,7 +115,14 @@
QFile f(fileName);
if(!f.open(QIODevice::ReadOnly))
- QMessageBox::warning(this, tr("File error"), tr("Cannot read file '%1'").arg(fileName));
+ {
+ QMessageBox errorMsg(this);
+ errorMsg.setIcon(QMessageBox::Warning);
+ errorMsg.setWindowTitle(QMessageBox::tr("File error"));
+ errorMsg.setText(QMessageBox::tr("Cannot open '%1' for reading").arg(fileName));
+ errorMsg.setWindowModality(Qt::WindowModal);
+ errorMsg.exec();
+ }
else
m_scene->decode(qUncompress(QByteArray::fromBase64(f.readAll())));
}
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/widget/gamecfgwidget.cpp
--- a/QTfrontend/ui/widget/gamecfgwidget.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/widget/gamecfgwidget.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -200,6 +200,10 @@
{
QList bcfg;
int mapgen = pMapContainer->get_mapgen();
+ if (Scripts->currentIndex() > 0)
+ {
+ bcfg << QString("escript Scripts/Multiplayer/%1.lua").arg(Scripts->itemData(Scripts->currentIndex(), GameStyleModel::ScriptRole).toString()).toUtf8();
+ }
QString currentMap = pMapContainer->getCurrentMap();
if (currentMap.size() > 0)
@@ -212,11 +216,6 @@
}
bcfg << QString("etheme " + pMapContainer->getCurrentTheme()).toUtf8();
- if (Scripts->currentIndex() > 0)
- {
- bcfg << QString("escript Scripts/Multiplayer/%1.lua").arg(Scripts->itemData(Scripts->currentIndex(), GameStyleModel::ScriptRole).toString()).toUtf8();
- }
-
bcfg << QString("eseed " + pMapContainer->getCurrentSeed()).toUtf8();
bcfg << QString("e$gmflags %1").arg(getGameFlags()).toUtf8();
bcfg << QString("e$damagepct %1").arg(schemeData(26).toInt()).toUtf8();
@@ -271,7 +270,14 @@
{
bool illegal = ammo.size() != cDefaultAmmoStore->size();
if (illegal)
- QMessageBox::critical(this, tr("Error"), tr("Illegal ammo scheme"));
+ {
+ QMessageBox illegalMsg(this);
+ illegalMsg.setIcon(QMessageBox::Warning);
+ illegalMsg.setWindowTitle(QMessageBox::tr("Error"));
+ illegalMsg.setText(QMessageBox::tr("Cannot use the ammo '%1'!").arg(name));
+ illegalMsg.setWindowModality(Qt::WindowModal);
+ illegalMsg.exec();
+ }
int pos = WeaponsName->findText(name);
if ((pos == -1) || illegal) // prevent from overriding schemes with bad ones
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/widget/mapContainer.cpp
--- a/QTfrontend/ui/widget/mapContainer.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/widget/mapContainer.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -29,7 +29,6 @@
#include
#include
#include
-#include
#include
#include "hwconsts.h"
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/widget/qpushbuttonwithsound.cpp
--- a/QTfrontend/ui/widget/qpushbuttonwithsound.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/widget/qpushbuttonwithsound.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -1,4 +1,21 @@
-#include
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2004-2012 Andrey Korotaev
+ *
+ * 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; version 2 of the License
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
#include
#include "qpushbuttonwithsound.h"
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/widget/qpushbuttonwithsound.h
--- a/QTfrontend/ui/widget/qpushbuttonwithsound.h Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/widget/qpushbuttonwithsound.h Sat Nov 03 00:34:35 2012 +0400
@@ -1,3 +1,21 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2004-2012 Andrey Korotaev
+ *
+ * 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; version 2 of the License
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
#ifndef QPUSHBUTTONWITHSOUND_H
#define QPUSHBUTTONWITHSOUND_H
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/widget/selectWeapon.cpp
--- a/QTfrontend/ui/widget/selectWeapon.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/widget/selectWeapon.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -191,19 +191,15 @@
void SelWeaponWidget::save()
{
- for(int i = 0; i < cDefaultAmmos.size(); i++)
- if (!cDefaultAmmos[i].first.compare(m_name->text()))
- {
- QMessageBox::warning(0, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not overwrite default weapon set '%1'!").arg(cDefaultAmmos[i].first));
- return;
- }
-
+ // TODO make this return if success or not, so that the page can react
+ // properly and not goBack if saving failed
if (m_name->text() == "") return;
QString state1;
QString state2;
QString state3;
QString state4;
+ QString stateFull;
for(int i = 0; i < m_numItems; ++i)
{
@@ -217,12 +213,33 @@
int am = it == weaponItems.end() ? 0 : it.value()[3]->getItemsNum();
state4.append(QString::number(am));
}
+
+ stateFull = state1 + state2 + state3 + state4;
+
+ for(int i = 0; i < cDefaultAmmos.size(); i++)
+ {
+ if (cDefaultAmmos[i].first.compare(m_name->text()) == 0)
+ {
+ // don't show warning if no change
+ if (cDefaultAmmos[i].second.compare(stateFull) == 0)
+ return;
+
+ QMessageBox deniedMsg(this);
+ deniedMsg.setIcon(QMessageBox::Warning);
+ deniedMsg.setWindowTitle(QMessageBox::tr("Weapons - Warning"));
+ deniedMsg.setText(QMessageBox::tr("Cannot overwrite default weapon set '%1'!").arg(cDefaultAmmos[i].first));
+ deniedMsg.setWindowModality(Qt::WindowModal);
+ deniedMsg.exec();
+ return;
+ }
+ }
+
if (curWeaponsName != "")
{
// remove old entry
wconf->remove(curWeaponsName);
}
- wconf->setValue(m_name->text(), state1 + state2 + state3 + state4);
+ wconf->setValue(m_name->text(), stateFull);
emit weaponsChanged();
}
@@ -244,13 +261,23 @@
for(int i = 0; i < cDefaultAmmos.size(); i++)
if (!cDefaultAmmos[i].first.compare(m_name->text()))
{
- QMessageBox::warning(0, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not delete default weapon set '%1'!").arg(cDefaultAmmos[i].first));
+ QMessageBox deniedMsg(this);
+ deniedMsg.setIcon(QMessageBox::Warning);
+ deniedMsg.setWindowTitle(QMessageBox::tr("Weapons - Warning"));
+ deniedMsg.setText(QMessageBox::tr("Cannot delete default weapon set '%1'!").arg(cDefaultAmmos[i].first));
+ deniedMsg.setWindowModality(Qt::WindowModal);
+ deniedMsg.exec();
return;
}
- QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Weapons"), QMessageBox::tr("Really delete this weapon set?"), QMessageBox::Ok | QMessageBox::Cancel);
+ QMessageBox reallyDeleteMsg(this);
+ reallyDeleteMsg.setIcon(QMessageBox::Question);
+ reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Weapons - Are you sure?"));
+ reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the weapon set '%1'?").arg(curWeaponsName));
+ reallyDeleteMsg.setWindowModality(Qt::WindowModal);
+ reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
- if (reallyDelete.exec() == QMessageBox::Ok)
+ if (reallyDeleteMsg.exec() == QMessageBox::Ok)
{
wconf->remove(curWeaponsName);
emit weaponsDeleted();
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/widget/teamselect.cpp
--- a/QTfrontend/ui/widget/teamselect.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/widget/teamselect.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -283,9 +283,9 @@
addTeam(team);
}
-bool TeamSelWidget::isPlaying(HWTeam team) const
+bool TeamSelWidget::isPlaying(const HWTeam &team) const
{
- return std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team)!=curPlayingTeams.end();
+ return curPlayingTeams.contains(team);
}
QList TeamSelWidget::getPlayingTeams() const
@@ -298,7 +298,7 @@
return m_curNotPlayingTeams;
}
-void TeamSelWidget::pre_changeTeamStatus(HWTeam team)
+void TeamSelWidget::pre_changeTeamStatus(const HWTeam & team)
{
//team.setColor(framePlaying->getNextColor());
emit acceptRequested(team);
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/ui/widget/teamselect.h
--- a/QTfrontend/ui/widget/teamselect.h Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/ui/widget/teamselect.h Sat Nov 03 00:34:35 2012 +0400
@@ -43,7 +43,7 @@
void setAcceptOuter(bool acceptOuter);
void removeNetTeam(const HWTeam& team);
void resetPlayingTeams(const QList& teamslist);
- bool isPlaying(HWTeam team) const;
+ bool isPlaying(const HWTeam &team) const;
QList getPlayingTeams() const;
QList getNotPlayingTeams() const;
void setInteractivity(bool interactive);
@@ -57,14 +57,14 @@
signals:
void setEnabledGameStart(bool);
- void teamWillPlay(HWTeam team);
+ void teamWillPlay(const HWTeam& team);
void teamNotPlaying(const HWTeam& team);
void hhogsNumChanged(const HWTeam&);
void teamColorChanged(const HWTeam&);
- void acceptRequested(HWTeam team);
+ void acceptRequested(const HWTeam& team);
private slots:
- void pre_changeTeamStatus(HWTeam);
+ void pre_changeTeamStatus(const HWTeam&);
void hhNumChanged(const HWTeam& team);
void proxyTeamColorChanged(const HWTeam& team);
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/util/DataManager.cpp
--- a/QTfrontend/util/DataManager.cpp Sun Oct 21 01:28:33 2012 +0400
+++ b/QTfrontend/util/DataManager.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -171,11 +171,9 @@
void DataManager::reload()
{
- m_gameStyleModel->loadGameStyles();
- m_hatModel->loadHats();
- m_mapModel->loadMaps();
- m_themeModel->loadThemes();
- emit updated();
+ // removed for now (also code was a bit unclean, could lead to segfault if
+ // reload() is called before all members are initialized - because currently
+ // they are initialized in the getter methods rather than the constructor)
}
void DataManager::resetColors()
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/util/LibavInteraction.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/util/LibavInteraction.cpp Sat Nov 03 00:34:35 2012 +0400
@@ -0,0 +1,356 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2004-2012 Andrey Korotaev
+ *
+ * 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; version 2 of the License
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "LibavInteraction.h"
+
+#if VIDEOREC
+extern "C"
+{
+#include "libavformat/avformat.h"
+}
+
+#include
+#include
+#include
+
+#include "HWApplication.h"
+
+struct Codec
+{
+ CodecID id;
+ bool isAudio;
+ QString shortName; // used for identification
+ QString longName; // used for displaying to user
+ bool isRecomended;
+};
+
+struct Format
+{
+ QString shortName;
+ QString longName;
+ bool isRecomended;
+ QString extension;
+ QVector codecs;
+};
+
+QList codecs;
+QMap formats;
+
+// test if given format supports given codec
+bool FormatQueryCodec(AVOutputFormat *ofmt, enum CodecID codec_id)
+{
+#if LIBAVFORMAT_VERSION_MAJOR >= 54
+ return avformat_query_codec(ofmt, codec_id, FF_COMPLIANCE_NORMAL) == 1;
+#else
+ if (ofmt->codec_tag)
+ return !!av_codec_get_tag(ofmt->codec_tag, codec_id);
+ return codec_id == ofmt->video_codec || codec_id == ofmt->audio_codec;
+#endif
+}
+
+LibavInteraction::LibavInteraction() : QObject()
+{
+ // initialize libav and register all codecs and formats
+ av_register_all();
+
+ // get list of all codecs
+ AVCodec* pCodec = NULL;
+ while (pCodec = av_codec_next(pCodec))
+ {
+#if LIBAVCODEC_VERSION_MAJOR >= 54
+ if (!av_codec_is_encoder(pCodec))
+#else
+ if (!pCodec->encode)
+#endif
+ continue;
+
+ if (pCodec->type != AVMEDIA_TYPE_VIDEO && pCodec->type != AVMEDIA_TYPE_AUDIO)
+ continue;
+
+ // this encoders seems to be buggy
+ if (strcmp(pCodec->name, "rv10") == 0 || strcmp(pCodec->name, "rv20") == 0)
+ continue;
+
+ // doesn't support stereo sound
+ if (strcmp(pCodec->name, "real_144") == 0)
+ continue;
+
+ if (!pCodec->long_name || strlen(pCodec->long_name) == 0)
+ continue;
+
+ if (pCodec->type == AVMEDIA_TYPE_VIDEO)
+ {
+ if (pCodec->supported_framerates != NULL)
+ continue;
+
+ // check if codec supports yuv 4:2:0 format
+ if (!pCodec->pix_fmts)
+ continue;
+ bool yuv420Supported = false;
+ for (const PixelFormat* pfmt = pCodec->pix_fmts; *pfmt != -1; pfmt++)
+ if (*pfmt == PIX_FMT_YUV420P)
+ {
+ yuv420Supported = true;
+ break;
+ }
+ if (!yuv420Supported)
+ continue;
+ }
+ if (pCodec->type == AVMEDIA_TYPE_AUDIO)
+ {
+ // check if codec supports signed 16-bit format
+ if (!pCodec->sample_fmts)
+ continue;
+ bool s16Supported = false;
+ for (const AVSampleFormat* pfmt = pCodec->sample_fmts; *pfmt != -1; pfmt++)
+ if (*pfmt == AV_SAMPLE_FMT_S16)
+ {
+ s16Supported = true;
+ break;
+ }
+ if (!s16Supported)
+ continue;
+ }
+ // add codec to list of codecs
+ codecs.push_back(Codec());
+ Codec & codec = codecs.back();
+ codec.id = pCodec->id;
+ codec.isAudio = pCodec->type == AVMEDIA_TYPE_AUDIO;
+ codec.shortName = pCodec->name;
+ codec.longName = pCodec->long_name;
+
+ codec.isRecomended = false;
+ if (strcmp(pCodec->name, "libx264") == 0)
+ {
+ codec.longName = "H.264/MPEG-4 Part 10 AVC (x264)";
+ codec.isRecomended = true;
+ }
+ else if (strcmp(pCodec->name, "libxvid") == 0)
+ {
+ codec.longName = "MPEG-4 Part 2 (Xvid)";
+ codec.isRecomended = true;
+ }
+ else if (strcmp(pCodec->name, "libmp3lame") == 0)
+ {
+ codec.longName = "MP3 (MPEG audio layer 3) (LAME)";
+ codec.isRecomended = true;
+ }
+ else
+ codec.longName = pCodec->long_name;
+
+ if (strcmp(pCodec->name, "mpeg4") == 0 || strcmp(pCodec->name, "ac3_fixed") == 0)
+ codec.isRecomended = true;
+
+ // FIXME: remove next line
+ //codec.longName += QString(" (%1)").arg(codec.shortName);
+ }
+
+ // get list of all formats
+ AVOutputFormat* pFormat = NULL;
+ while (pFormat = av_oformat_next(pFormat))
+ {
+ if (!pFormat->extensions)
+ continue;
+
+ // skip some strange formats to not confuse users
+ if (strstr(pFormat->long_name, "raw"))
+ continue;
+
+ Format format;
+ bool hasVideoCodec = false;
+ for (QList::iterator codec = codecs.begin(); codec != codecs.end(); ++codec)
+ {
+ if (!FormatQueryCodec(pFormat, codec->id))
+ continue;
+ format.codecs.push_back(&*codec);
+ if (!codec->isAudio)
+ hasVideoCodec = true;
+ }
+ if (!hasVideoCodec)
+ continue;
+
+ QString ext(pFormat->extensions);
+ ext.truncate(strcspn(pFormat->extensions, ","));
+ format.extension = ext;
+ format.shortName = pFormat->name;
+ format.longName = QString("%1 (*.%2)").arg(pFormat->long_name).arg(ext);
+
+ // FIXME: remove next line
+ //format.longName += QString(" (%1)").arg(format.shortName);
+
+ format.isRecomended = strcmp(pFormat->name, "mp4") == 0 || strcmp(pFormat->name, "avi") == 0;
+
+ formats[pFormat->name] = format;
+ }
+}
+
+void LibavInteraction::fillFormats(QComboBox * pFormats)
+{
+ // first insert recomended formats
+ foreach(const Format & format, formats)
+ if (format.isRecomended)
+ pFormats->addItem(format.longName, format.shortName);
+
+ // remember where to place separator between recomended and other formats
+ int sep = pFormats->count();
+
+ // insert remaining formats
+ foreach(const Format & format, formats)
+ if (!format.isRecomended)
+ pFormats->addItem(format.longName, format.shortName);
+
+ // insert separator if necessary
+ if (sep != 0 && sep != pFormats->count())
+ pFormats->insertSeparator(sep);
+}
+
+void LibavInteraction::fillCodecs(const QString & fmt, QComboBox * pVCodecs, QComboBox * pACodecs)
+{
+ Format & format = formats[fmt];
+
+ // first insert recomended codecs
+ foreach(Codec * codec, format.codecs)
+ {
+ if (codec->isRecomended)
+ {
+ if (codec->isAudio)
+ pACodecs->addItem(codec->longName, codec->shortName);
+ else
+ pVCodecs->addItem(codec->longName, codec->shortName);
+ }
+ }
+
+ // remember where to place separators between recomended and other codecs
+ int vsep = pVCodecs->count();
+ int asep = pACodecs->count();
+
+ // insert remaining codecs
+ foreach(Codec * codec, format.codecs)
+ {
+ if (!codec->isRecomended)
+ {
+ if (codec->isAudio)
+ pACodecs->addItem(codec->longName, codec->shortName);
+ else
+ pVCodecs->addItem(codec->longName, codec->shortName);
+ }
+ }
+
+ // insert separators if necessary
+ if (vsep != 0 && vsep != pVCodecs->count())
+ pVCodecs->insertSeparator(vsep);
+ if (asep != 0 && asep != pACodecs->count())
+ pACodecs->insertSeparator(asep);
+}
+
+QString LibavInteraction::getExtension(const QString & format)
+{
+ return formats[format].extension;
+}
+
+// get information abaout file (duration, resolution etc) in multiline string
+QString LibavInteraction::getFileInfo(const QString & filepath)
+{
+ AVFormatContext* pContext = NULL;
+ QByteArray utf8path = filepath.toUtf8();
+ if (avformat_open_input(&pContext, utf8path.data(), NULL, NULL) < 0)
+ return "";
+#if LIBAVFORMAT_VERSION_MAJOR < 54
+ if (av_find_stream_info(pContext) < 0)
+#else
+ if (avformat_find_stream_info(pContext, NULL) < 0)
+#endif
+ return "";
+
+ int s = float(pContext->duration)/AV_TIME_BASE;
+ QString desc = QString(tr("Duration: %1m %2s\n")).arg(s/60).arg(s%60);
+ for (int i = 0; i < (int)pContext->nb_streams; i++)
+ {
+ AVStream* pStream = pContext->streams[i];
+ if (!pStream)
+ continue;
+ AVCodecContext* pCodec = pContext->streams[i]->codec;
+ if (!pCodec)
+ continue;
+
+ if (pCodec->codec_type == AVMEDIA_TYPE_VIDEO)
+ {
+ desc += QString(tr("Video: %1x%2, ")).arg(pCodec->width).arg(pCodec->height);
+ if (pStream->avg_frame_rate.den)
+ {
+ float fps = float(pStream->avg_frame_rate.num)/pStream->avg_frame_rate.den;
+ desc += QString(tr("%1 fps, ")).arg(fps, 0, 'f', 2);
+ }
+ }
+ else if (pCodec->codec_type == AVMEDIA_TYPE_AUDIO)
+ desc += tr("Audio: ");
+ else
+ continue;
+ AVCodec* pDecoder = avcodec_find_decoder(pCodec->codec_id);
+ desc += pDecoder? pDecoder->name : "unknown";
+ desc += "\n";
+ }
+ AVDictionaryEntry* pComment = av_dict_get(pContext->metadata, "comment", NULL, 0);
+ if (pComment)
+ desc += QString("\n") + pComment->value;
+#if LIBAVFORMAT_VERSION_MAJOR < 54
+ av_close_input_file(pContext);
+#else
+ avformat_close_input(&pContext);
+#endif
+ return desc;
+}
+
+#else
+LibavInteraction::LibavInteraction() : QObject()
+{
+
+}
+
+void LibavInteraction::fillFormats(QComboBox * pFormats)
+{
+ Q_UNUSED(pFormats);
+}
+
+void LibavInteraction::fillCodecs(const QString & format, QComboBox * pVCodecs, QComboBox * pACodecs)
+{
+ Q_UNUSED(format);
+ Q_UNUSED(pVCodecs);
+ Q_UNUSED(pACodecs);
+}
+
+QString LibavInteraction::getExtension(const QString & format)
+{
+ Q_UNUSED(format);
+
+ return QString();
+}
+
+QString LibavInteraction::getFileInfo(const QString & filepath)
+{
+ Q_UNUSED(filepath);
+
+ return QString();
+}
+#endif
+
+LibavInteraction & LibavInteraction::instance()
+{
+ static LibavInteraction instance;
+ return instance;
+}
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/util/LibavInteraction.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/util/LibavInteraction.h Sat Nov 03 00:34:35 2012 +0400
@@ -0,0 +1,51 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2004-2012 Andrey Korotaev
+ *
+ * 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; version 2 of the License
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef LIBAV_ITERACTION
+#define LIBAV_ITERACTION
+
+#include
+
+/**
+ * @brief Class for interacting with ffmpeg/libav libraries
+ *
+ * @see singleton pattern
+ */
+class LibavInteraction : public QObject
+{
+ Q_OBJECT;
+
+ LibavInteraction();
+
+public:
+
+ static LibavInteraction & instance();
+
+ // fill combo box with known file formats
+ void fillFormats(QComboBox * pFormats);
+
+ // fill combo boxes with known codecs for given formats
+ void fillCodecs(const QString & format, QComboBox * pVCodecs, QComboBox * pACodecs);
+
+ QString getExtension(const QString & format);
+
+ // get information about file (duration, resolution etc) in multiline string
+ QString getFileInfo(const QString & filepath);
+};
+
+#endif // LIBAV_ITERACTION
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/util/libav_iteraction.cpp
--- a/QTfrontend/util/libav_iteraction.cpp Sun Oct 21 01:28:33 2012 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,358 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2012 Andrey Korotaev
- *
- * 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; version 2 of the License
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "libav_iteraction.h"
-
-#if VIDEOREC
-#define __STDC_CONSTANT_MACROS
-extern "C"
-{
-#include "libavformat/avformat.h"
-}
-
-#include
-#include
-#include
-#include
-
-#include "HWApplication.h"
-
-struct Codec
-{
- CodecID id;
- bool isAudio;
- QString shortName; // used for identification
- QString longName; // used for displaying to user
- bool isRecomended;
-};
-
-struct Format
-{
- QString shortName;
- QString longName;
- bool isRecomended;
- QString extension;
- QVector codecs;
-};
-
-QList codecs;
-QMap formats;
-
-// test if given format supports given codec
-bool FormatQueryCodec(AVOutputFormat *ofmt, enum CodecID codec_id)
-{
-#if LIBAVFORMAT_VERSION_MAJOR >= 54
- return avformat_query_codec(ofmt, codec_id, FF_COMPLIANCE_NORMAL) == 1;
-#else
- if (ofmt->codec_tag)
- return !!av_codec_get_tag(ofmt->codec_tag, codec_id);
- return codec_id == ofmt->video_codec || codec_id == ofmt->audio_codec;
-#endif
-}
-
-LibavIteraction::LibavIteraction() : QObject()
-{
- // initialize libav and register all codecs and formats
- av_register_all();
-
- // get list of all codecs
- AVCodec* pCodec = NULL;
- while (pCodec = av_codec_next(pCodec))
- {
-#if LIBAVCODEC_VERSION_MAJOR >= 54
- if (!av_codec_is_encoder(pCodec))
-#else
- if (!pCodec->encode)
-#endif
- continue;
-
- if (pCodec->type != AVMEDIA_TYPE_VIDEO && pCodec->type != AVMEDIA_TYPE_AUDIO)
- continue;
-
- // this encoders seems to be buggy
- if (strcmp(pCodec->name, "rv10") == 0 || strcmp(pCodec->name, "rv20") == 0)
- continue;
-
- // doesn't support stereo sound
- if (strcmp(pCodec->name, "real_144") == 0)
- continue;
-
- if (!pCodec->long_name || strlen(pCodec->long_name) == 0)
- continue;
-
- if (pCodec->type == AVMEDIA_TYPE_VIDEO)
- {
- if (pCodec->supported_framerates != NULL)
- continue;
-
- // check if codec supports yuv 4:2:0 format
- if (!pCodec->pix_fmts)
- continue;
- bool yuv420Supported = false;
- for (const PixelFormat* pfmt = pCodec->pix_fmts; *pfmt != -1; pfmt++)
- if (*pfmt == PIX_FMT_YUV420P)
- {
- yuv420Supported = true;
- break;
- }
- if (!yuv420Supported)
- continue;
- }
- if (pCodec->type == AVMEDIA_TYPE_AUDIO)
- {
- // check if codec supports signed 16-bit format
- if (!pCodec->sample_fmts)
- continue;
- bool s16Supported = false;
- for (const AVSampleFormat* pfmt = pCodec->sample_fmts; *pfmt != -1; pfmt++)
- if (*pfmt == AV_SAMPLE_FMT_S16)
- {
- s16Supported = true;
- break;
- }
- if (!s16Supported)
- continue;
- }
- // add codec to list of codecs
- codecs.push_back(Codec());
- Codec & codec = codecs.back();
- codec.id = pCodec->id;
- codec.isAudio = pCodec->type == AVMEDIA_TYPE_AUDIO;
- codec.shortName = pCodec->name;
- codec.longName = pCodec->long_name;
-
- codec.isRecomended = false;
- if (strcmp(pCodec->name, "libx264") == 0)
- {
- codec.longName = "H.264/MPEG-4 Part 10 AVC (x264)";
- codec.isRecomended = true;
- }
- else if (strcmp(pCodec->name, "libxvid") == 0)
- {
- codec.longName = "MPEG-4 Part 2 (Xvid)";
- codec.isRecomended = true;
- }
- else if (strcmp(pCodec->name, "libmp3lame") == 0)
- {
- codec.longName = "MP3 (MPEG audio layer 3) (LAME)";
- codec.isRecomended = true;
- }
- else
- codec.longName = pCodec->long_name;
-
- if (strcmp(pCodec->name, "mpeg4") == 0 || strcmp(pCodec->name, "ac3_fixed") == 0)
- codec.isRecomended = true;
-
- // FIXME: remove next line
- //codec.longName += QString(" (%1)").arg(codec.shortName);
- }
-
- // get list of all formats
- AVOutputFormat* pFormat = NULL;
- while (pFormat = av_oformat_next(pFormat))
- {
- if (!pFormat->extensions)
- continue;
-
- // skip some strange formats to not confuse users
- if (strstr(pFormat->long_name, "raw"))
- continue;
-
- Format format;
- bool hasVideoCodec = false;
- for (QList::iterator codec = codecs.begin(); codec != codecs.end(); ++codec)
- {
- if (!FormatQueryCodec(pFormat, codec->id))
- continue;
- format.codecs.push_back(&*codec);
- if (!codec->isAudio)
- hasVideoCodec = true;
- }
- if (!hasVideoCodec)
- continue;
-
- QString ext(pFormat->extensions);
- ext.truncate(strcspn(pFormat->extensions, ","));
- format.extension = ext;
- format.shortName = pFormat->name;
- format.longName = QString("%1 (*.%2)").arg(pFormat->long_name).arg(ext);
-
- // FIXME: remove next line
- //format.longName += QString(" (%1)").arg(format.shortName);
-
- format.isRecomended = strcmp(pFormat->name, "mp4") == 0 || strcmp(pFormat->name, "avi") == 0;
-
- formats[pFormat->name] = format;
- }
-}
-
-void LibavIteraction::fillFormats(QComboBox * pFormats)
-{
- // first insert recomended formats
- foreach(const Format & format, formats)
- if (format.isRecomended)
- pFormats->addItem(format.longName, format.shortName);
-
- // remember where to place separator between recomended and other formats
- int sep = pFormats->count();
-
- // insert remaining formats
- foreach(const Format & format, formats)
- if (!format.isRecomended)
- pFormats->addItem(format.longName, format.shortName);
-
- // insert separator if necessary
- if (sep != 0 && sep != pFormats->count())
- pFormats->insertSeparator(sep);
-}
-
-void LibavIteraction::fillCodecs(const QString & fmt, QComboBox * pVCodecs, QComboBox * pACodecs)
-{
- Format & format = formats[fmt];
-
- // first insert recomended codecs
- foreach(Codec * codec, format.codecs)
- {
- if (codec->isRecomended)
- {
- if (codec->isAudio)
- pACodecs->addItem(codec->longName, codec->shortName);
- else
- pVCodecs->addItem(codec->longName, codec->shortName);
- }
- }
-
- // remember where to place separators between recomended and other codecs
- int vsep = pVCodecs->count();
- int asep = pACodecs->count();
-
- // insert remaining codecs
- foreach(Codec * codec, format.codecs)
- {
- if (!codec->isRecomended)
- {
- if (codec->isAudio)
- pACodecs->addItem(codec->longName, codec->shortName);
- else
- pVCodecs->addItem(codec->longName, codec->shortName);
- }
- }
-
- // insert separators if necessary
- if (vsep != 0 && vsep != pVCodecs->count())
- pVCodecs->insertSeparator(vsep);
- if (asep != 0 && asep != pACodecs->count())
- pACodecs->insertSeparator(asep);
-}
-
-QString LibavIteraction::getExtension(const QString & format)
-{
- return formats[format].extension;
-}
-
-// get information abaout file (duration, resolution etc) in multiline string
-QString LibavIteraction::getFileInfo(const QString & filepath)
-{
- AVFormatContext* pContext = NULL;
- QByteArray utf8path = filepath.toUtf8();
- if (avformat_open_input(&pContext, utf8path.data(), NULL, NULL) < 0)
- return "";
-#if LIBAFORMAT_VERSION_MAJOR < 54
- if (av_find_stream_info(pContext) < 0)
-#else
- if (avformat_find_stream_info(pContext, NULL) < 0)
-#endif
- return "";
-
- int s = float(pContext->duration)/AV_TIME_BASE;
- QString desc = QString(tr("Duration: %1m %2s\n")).arg(s/60).arg(s%60);
- for (int i = 0; i < (int)pContext->nb_streams; i++)
- {
- AVStream* pStream = pContext->streams[i];
- if (!pStream)
- continue;
- AVCodecContext* pCodec = pContext->streams[i]->codec;
- if (!pCodec)
- continue;
-
- if (pCodec->codec_type == AVMEDIA_TYPE_VIDEO)
- {
- desc += QString(tr("Video: %1x%2, ")).arg(pCodec->width).arg(pCodec->height);
- if (pStream->avg_frame_rate.den)
- {
- float fps = float(pStream->avg_frame_rate.num)/pStream->avg_frame_rate.den;
- desc += QString(tr("%1 fps, ")).arg(fps, 0, 'f', 2);
- }
- }
- else if (pCodec->codec_type == AVMEDIA_TYPE_AUDIO)
- desc += tr("Audio: ");
- else
- continue;
- AVCodec* pDecoder = avcodec_find_decoder(pCodec->codec_id);
- desc += pDecoder? pDecoder->name : "unknown";
- desc += "\n";
- }
- AVDictionaryEntry* pComment = av_dict_get(pContext->metadata, "comment", NULL, 0);
- if (pComment)
- desc += QString("\n") + pComment->value;
-#if LIBAFORMAT_VERSION_MAJOR < 54
- av_close_input_file(pContext);
-#else
- avformat_close_input(&pContext);
-#endif
- return desc;
-}
-
-#else
-LibavIteraction::LibavIteraction() : QObject()
-{
-
-}
-
-void LibavIteraction::fillFormats(QComboBox * pFormats)
-{
- Q_UNUSED(pFormats);
-}
-
-void LibavIteraction::fillCodecs(const QString & format, QComboBox * pVCodecs, QComboBox * pACodecs)
-{
- Q_UNUSED(format);
- Q_UNUSED(pVCodecs);
- Q_UNUSED(pACodecs);
-}
-
-QString LibavIteraction::getExtension(const QString & format)
-{
- Q_UNUSED(format);
-
- return QString();
-}
-
-QString LibavIteraction::getFileInfo(const QString & filepath)
-{
- Q_UNUSED(filepath);
-
- return QString();
-}
-#endif
-
-LibavIteraction & LibavIteraction::instance()
-{
- static LibavIteraction instance;
- return instance;
-}
diff -r 3331b30e4ef1 -r 88fde28bbda6 QTfrontend/util/libav_iteraction.h
--- a/QTfrontend/util/libav_iteraction.h Sun Oct 21 01:28:33 2012 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2012 Andrey Korotaev
- *
- * 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; version 2 of the License
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#ifndef LIBAV_ITERACTION
-#define LIBAV_ITERACTION
-
-#include
-
-/**
- * @brief Class for interacting with ffmpeg/libav libraries
- *
- * @see singleton pattern
- */
-class LibavIteraction : public QObject
-{
- Q_OBJECT;
-
- LibavIteraction();
-
-public:
-
- static LibavIteraction & instance();
-
- // fill combo box with known file formats
- void fillFormats(QComboBox * pFormats);
-
- // fill combo boxes with known codecs for given formats
- void fillCodecs(const QString & format, QComboBox * pVCodecs, QComboBox * pACodecs);
-
- QString getExtension(const QString & format);
-
- // get information about file (duration, resolution etc) in multiline string
- QString getFileInfo(const QString & filepath);
-};
-
-#endif // LIBAV_ITERACTION
diff -r 3331b30e4ef1 -r 88fde28bbda6 bin/CMakeLists.txt
diff -r 3331b30e4ef1 -r 88fde28bbda6 cmake_modules/FindFFMPEG.cmake
--- a/cmake_modules/FindFFMPEG.cmake Sun Oct 21 01:28:33 2012 +0400
+++ b/cmake_modules/FindFFMPEG.cmake Sat Nov 03 00:34:35 2012 +0400
@@ -31,23 +31,35 @@
find_path(FFMPEG_AVCODEC_INCLUDE_DIR
NAMES libavcodec/avcodec.h
- PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include
+ PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS}
+ /usr/include /usr/local/include #system level
+ /opt/local/include #macports
+ /sw/include #fink
PATH_SUFFIXES ffmpeg libav
)
find_library(FFMPEG_LIBAVCODEC
NAMES avcodec
- PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
+ PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS}
+ /usr/lib /usr/local/lib #system level
+ /opt/local/lib #macports
+ /sw/lib #fink
)
find_library(FFMPEG_LIBAVFORMAT
NAMES avformat
- PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
+ PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS}
+ /usr/lib /usr/local/lib #system level
+ /opt/local/lib #macports
+ /sw/lib #fink
)
find_library(FFMPEG_LIBAVUTIL
NAMES avutil
- PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
+ PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS}
+ /usr/lib /usr/local/lib #system level
+ /opt/local/lib #macports
+ /sw/lib #fink
)
if (FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVFORMAT)
@@ -62,16 +74,19 @@
${FFMPEG_LIBAVFORMAT}
${FFMPEG_LIBAVUTIL}
)
+ if (APPLE)
+ set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} "bz2" "-framework CoreVideo" "-framework VideoDecodeAcceleration")
+ endif(APPLE)
endif (FFMPEG_FOUND)
if (FFMPEG_FOUND)
if (NOT FFMPEG_FIND_QUIETLY)
- message(STATUS "Found FFMPEG or Libav: ${FFMPEG_LIBRARIES}, ${FFMPEG_INCLUDE_DIR}")
+ message(STATUS "Found FFMPEG/LibAV: ${FFMPEG_LIBRARIES}, ${FFMPEG_INCLUDE_DIR}")
endif (NOT FFMPEG_FIND_QUIETLY)
else (FFMPEG_FOUND)
if (FFMPEG_FIND_REQUIRED)
- message(FATAL_ERROR "Could not find libavcodec or libavformat or libavutil")
+ message(FATAL_ERROR "Could NOT find libavcodec or libavformat or libavutil")
endif (FFMPEG_FIND_REQUIRED)
endif (FFMPEG_FOUND)
diff -r 3331b30e4ef1 -r 88fde28bbda6 cmake_modules/FindSDL_Extras.cmake
--- a/cmake_modules/FindSDL_Extras.cmake Sun Oct 21 01:28:33 2012 +0400
+++ b/cmake_modules/FindSDL_Extras.cmake Sat Nov 03 00:34:35 2012 +0400
@@ -12,7 +12,7 @@
math(EXPR sdlmixer_version "${sdlmixer_majorversion}*10000 + ${sdlmixer_minorversion}*100 + ${sdlmixer_patchversion}")
if(sdlmixer_version GREATER "10209")
- message(STATUS "SDL_mixer - Mix_Init() found")
+ message(STATUS "Mix_Init() is present")
set(pascal_flags "-dSDL_MIXER_NEWER" ${pascal_flags})
endif()
endif()
@@ -29,7 +29,7 @@
math(EXPR sdlimage_version "${sdlimage_majorversion}*10000 + ${sdlimage_minorversion}*100 + ${sdlimage_patchversion}")
if(sdlimage_version GREATER "010207")
- message(STATUS "SDL_image - IMG_Init() found")
+ message(STATUS "IMG_Init() is present")
set(pascal_flags "-dSDL_IMAGE_NEWER" ${pascal_flags})
endif()
endif()
diff -r 3331b30e4ef1 -r 88fde28bbda6 gameServer/Actions.hs
--- a/gameServer/Actions.hs Sun Oct 21 01:28:33 2012 +0400
+++ b/gameServer/Actions.hs Sat Nov 03 00:34:35 2012 +0400
@@ -62,6 +62,7 @@
| ModifyRoom (RoomInfo -> RoomInfo)
| ModifyServerInfo (ServerInfo -> ServerInfo)
| AddRoom B.ByteString B.ByteString
+ | SendUpdateOnThisRoom
| CheckRegistered
| ClearAccountsCache
| ProcessAccountInfo AccountInfo
@@ -211,7 +212,7 @@
rnc <- gets roomsClients
io $ do
- modifyClient rnc (\cl -> cl{teamsInGame = 0, isReady = False, isMaster = False}) ci
+ modifyClient rnc (\cl -> cl{teamsInGame = 0, isReady = False, isMaster = False, isInGame = False}) ci
modifyRoom rnc (\r -> r{playersIn = playersIn r + 1}) ri
moveClientToRoom rnc ri ci
@@ -254,19 +255,23 @@
proto <- client's clientProto
ri <- clientRoomA
rnc <- gets roomsClients
- newMasterId <- liftM (head . filter (/= ci)) . io $ roomClientsIndicesM rnc ri
+ newMasterId <- liftM (last . filter (/= ci)) . io $ roomClientsIndicesM rnc ri
newMaster <- io $ client'sM rnc id newMasterId
oldRoomName <- io $ room'sM rnc name ri
oldMaster <- client's nick
thisRoomChans <- liftM (map sendChan) $ roomClientsS ri
let newRoomName = if proto < 42 then nick newMaster else oldRoomName
mapM_ processAction [
- ModifyRoom (\r -> r{masterID = newMasterId, name = newRoomName, isRestrictedJoins = False, isRestrictedTeams = False})
- , ModifyClient2 newMasterId (\c -> c{isMaster = True})
+ ModifyRoom (\r -> r{masterID = newMasterId
+ , name = newRoomName
+ , isRestrictedJoins = False
+ , isRestrictedTeams = False
+ , readyPlayers = if isReady newMaster then readyPlayers r else readyPlayers r + 1})
+ , ModifyClient2 newMasterId (\c -> c{isMaster = True, isReady = True})
, AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"]
, AnswerClients thisRoomChans ["WARNING", "New room admin is " `B.append` nick newMaster]
, AnswerClients thisRoomChans ["CLIENT_FLAGS", "-h", oldMaster]
- , AnswerClients thisRoomChans ["CLIENT_FLAGS", "+h", nick newMaster]
+ , AnswerClients thisRoomChans ["CLIENT_FLAGS", "+hr", nick newMaster]
]
newRoom' <- io $ room'sM rnc id ri
@@ -279,7 +284,6 @@
rnc <- gets roomsClients
proto <- client's clientProto
n <- client's nick
- chan <- client's sendChan
let rm = newRoom{
masterID = clId,
@@ -296,8 +300,6 @@
mapM_ processAction [
AnswerClients chans ("ROOM" : "ADD" : roomInfo n rm)
- , AnswerClients [chan] ["CLIENT_FLAGS", "+h", n]
- , ModifyClient (\cl -> cl{isMaster = True})
]
@@ -318,14 +320,25 @@
io $ removeRoom rnc ri
+processAction SendUpdateOnThisRoom = do
+ Just clId <- gets clientIndex
+ proto <- client's clientProto
+ rnc <- gets roomsClients
+ ri <- io $ clientRoomM rnc clId
+ rm <- io $ room'sM rnc id ri
+ n <- io $ client'sM rnc nick (masterID rm)
+ chans <- liftM (map sendChan) $! sameProtoClientsS proto
+ processAction $ AnswerClients chans ("ROOM" : "UPD" : name rm : roomInfo n rm)
+
+
processAction UnreadyRoomClients = do
ri <- clientRoomA
roomPlayers <- roomClientsS ri
pr <- client's clientProto
mapM_ processAction [
- AnswerClients (map sendChan roomPlayers) $ notReadyMessage pr (map nick roomPlayers)
- , ModifyRoomClients (\cl -> cl{isReady = False})
- , ModifyRoom (\r -> r{readyPlayers = 0})
+ AnswerClients (map sendChan roomPlayers) $ notReadyMessage pr . map nick . filter (not . isMaster) $ roomPlayers
+ , ModifyRoomClients (\cl -> cl{isReady = isMaster cl})
+ , ModifyRoom (\r -> r{readyPlayers = 1})
]
where
notReadyMessage p nicks = if p < 38 then "NOT_READY" : nicks else "CLIENT_FLAGS" : "-r" : nicks
@@ -347,6 +360,7 @@
}
)
: UnreadyRoomClients
+ : SendUpdateOnThisRoom
: answerRemovedTeams
diff -r 3331b30e4ef1 -r 88fde28bbda6 gameServer/CoreTypes.hs
--- a/gameServer/CoreTypes.hs Sun Oct 21 01:28:33 2012 +0400
+++ b/gameServer/CoreTypes.hs Sat Nov 03 00:34:35 2012 +0400
@@ -142,7 +142,6 @@
latestReleaseVersion :: Word16,
earliestCompatibleVersion :: Word16,
listenPort :: PortNumber,
- --nextRoomID :: Int,
dbHost :: B.ByteString,
dbName :: B.ByteString,
dbLogin :: B.ByteString,
@@ -162,11 +161,10 @@
ServerInfo
True
"http://www.hedgewars.org/
"
- "Hedgewars 0.9.17 is out! Please update.
Download page here
"
- 41
- 43 -- 0.9.18
+ "Hedgewars 0.9.18 is out! Please update.
Download page here
"
+ 43 -- latestReleaseVersion
+ 41 -- earliestCompatibleVersion
46631
- --0
""
""
""
diff -r 3331b30e4ef1 -r 88fde28bbda6 gameServer/HWProtoInRoomState.hs
--- a/gameServer/HWProtoInRoomState.hs Sun Oct 21 01:28:33 2012 +0400
+++ b/gameServer/HWProtoInRoomState.hs Sat Nov 03 00:34:35 2012 +0400
@@ -3,7 +3,7 @@
import qualified Data.Map as Map
import Data.Sequence((|>))
-import Data.List
+import Data.List as L
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import Control.Monad
@@ -52,6 +52,13 @@
clNick <- clientNick
clChan <- thisClientChans
othChans <- roomOthersChans
+ roomChans <- roomClientsChans
+ cl <- thisClient
+ teamColor <-
+ if clientProto cl < 42 then
+ return color
+ else
+ liftM (head . (L.\\) (map B.singleton ['0'..]) . map teamcolor . teams) thisRoom
return $
if not . null . drop (maxTeams rm - 1) $ teams rm then
[Warning "too many teams"]
@@ -64,16 +71,17 @@
else if isRestrictedTeams rm then
[Warning "restricted"]
else
- [ModifyRoom (\r -> r{teams = teams r ++ [newTeam ci clNick r]}),
- ModifyClient (\c -> c{teamsInGame = teamsInGame c + 1, clientClan = Just color}),
+ [ModifyRoom (\r -> r{teams = teams r ++ [newTeam ci clNick r teamColor]}),
+ SendUpdateOnThisRoom,
+ ModifyClient (\c -> c{teamsInGame = teamsInGame c + 1, clientClan = Just teamColor}),
AnswerClients clChan ["TEAM_ACCEPTED", tName],
- AnswerClients othChans $ teamToNet $ newTeam ci clNick rm,
- AnswerClients othChans ["TEAM_COLOR", tName, color]
+ AnswerClients othChans $ teamToNet $ newTeam ci clNick rm teamColor,
+ AnswerClients roomChans ["TEAM_COLOR", tName, teamColor]
]
where
canAddNumber r = 48 - (sum . map hhnum $ teams r)
findTeam = find (\t -> tName == teamname t) . teams
- newTeam ci clNick r = TeamInfo ci clNick tName color grave fort voicepack flag dif (newTeamHHNum r) (hhsList hhsInfo)
+ newTeam ci clNick r tColor = TeamInfo ci clNick tName tColor grave fort voicepack flag dif (newTeamHHNum r) (hhsList hhsInfo)
dif = readInt_ difStr
hhsList [] = []
hhsList [_] = error "Hedgehogs list with odd elements number"
@@ -99,6 +107,7 @@
[ProtocolError "Not team owner!"]
else
[RemoveTeam tName,
+ SendUpdateOnThisRoom,
ModifyClient
(\c -> c{
teamsInGame = teamsInGame c - 1,
@@ -157,14 +166,17 @@
handleCmd_inRoom ["TOGGLE_READY"] = do
cl <- thisClient
chans <- roomClientsChans
- return [
- ModifyRoom (\r -> r{readyPlayers = readyPlayers r + (if isReady cl then -1 else 1)}),
- ModifyClient (\c -> c{isReady = not $ isReady cl}),
- AnswerClients chans $ if clientProto cl < 38 then
- [if isReady cl then "NOT_READY" else "READY", nick cl]
- else
- ["CLIENT_FLAGS", if isReady cl then "-r" else "+r", nick cl]
- ]
+ if isMaster cl then
+ return []
+ else
+ return [
+ ModifyRoom (\r -> r{readyPlayers = readyPlayers r + (if isReady cl then -1 else 1)}),
+ ModifyClient (\c -> c{isReady = not $ isReady cl}),
+ AnswerClients chans $ if clientProto cl < 38 then
+ [if isReady cl then "NOT_READY" else "READY", nick cl]
+ else
+ ["CLIENT_FLAGS", if isReady cl then "-r" else "+r", nick cl]
+ ]
handleCmd_inRoom ["START_GAME"] = do
(ci, rnc) <- ask
@@ -184,6 +196,7 @@
}
)
, AnswerClients chans ["RUN_GAME"]
+ , SendUpdateOnThisRoom
, AnswerClients chans $ "CLIENT_FLAGS" : "+g" : nicks
, ModifyRoomClients (\c -> c{isInGame = True})
]
diff -r 3331b30e4ef1 -r 88fde28bbda6 gameServer/HWProtoLobbyState.hs
--- a/gameServer/HWProtoLobbyState.hs Sun Oct 21 01:28:33 2012 +0400
+++ b/gameServer/HWProtoLobbyState.hs Sat Nov 03 00:34:35 2012 +0400
@@ -51,8 +51,10 @@
[Warning "Room exists"]
else
[
- AddRoom rName roomPassword,
- AnswerClients [sendChan cl] ["CLIENT_FLAGS", "-r", nick cl]
+ AddRoom rName roomPassword
+ , AnswerClients [sendChan cl] ["CLIENT_FLAGS", "+hr", nick cl]
+ , ModifyClient (\c -> c{isMaster = True, isReady = True})
+ , ModifyRoom (\r -> r{readyPlayers = 1})
]
diff -r 3331b30e4ef1 -r 88fde28bbda6 gameServer/Utils.hs
--- a/gameServer/Utils.hs Sun Oct 21 01:28:33 2012 +0400
+++ b/gameServer/Utils.hs Sat Nov 03 00:34:35 2012 +0400
@@ -88,6 +88,8 @@
, (40, "0.9.17-dev")
, (41, "0.9.17")
, (42, "0.9.18-dev")
+ , (43, "0.9.18")
+ , (44, "0.9.19-dev")
]
askFromConsole :: B.ByteString -> IO B.ByteString
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/ArgParsers.inc
--- a/hedgewars/ArgParsers.inc Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/ArgParsers.inc Sat Nov 03 00:34:35 2012 +0400
@@ -16,20 +16,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*)
-procedure playReplayFileWithParameters(); forward;
-
-procedure internalSetGameTypeLandPreviewFromParameters();
-begin
- if ParamStr(3) = '--stats-only' then
- playReplayFileWithParameters()
- else
- begin
- ipcPort:= StrToInt(ParamStr(2));
- GameType:= gmtLandPreview;
- if ParamStr(3) <> 'landpreview' then
- GameType:= gmtSyntax
- end
-end;
procedure internalStartGameWithParameters();
var tmp: LongInt;
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/CMakeLists.txt
--- a/hedgewars/CMakeLists.txt Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/CMakeLists.txt Sat Nov 03 00:34:35 2012 +0400
@@ -3,7 +3,6 @@
find_package(SDL_net)
find_package(SDL_ttf)
find_package(SDL_mixer)
-find_package(FFMPEG)
include(${CMAKE_MODULE_PATH}/FindSDL_Extras.cmake)
@@ -162,7 +161,7 @@
string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}")
string(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}")
string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}")
- message(STATUS "Freepascal version installed: ${fpc_vers_major}.${fpc_vers_minor}")
+ message(STATUS "Found Freepascal: ${fpc_executable} (version ${fpc_vers_major}.${fpc_vers_minor})")
math(EXPR fpc_version "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
if(fpc_version LESS "020200")
@@ -179,11 +178,9 @@
if(NOT NOPNG)
find_package(PNG)
if(${PNG_FOUND})
- message(STATUS "Found libpng: ${PNG_LIBRARY}")
set(pascal_flags "-dPNG_SCREENSHOTS" ${pascal_flags})
- if(APPLE) # need to explictly link with the static lib -- maybe windows too?
- string(REGEX REPLACE "(.*)libpng.*" "\\1" PNG_LIBDIR "${PNG_LIBRARY}")
- set(pascal_flags "-k${PNG_LIBDIR}/libpng.a" ${pascal_flags})
+ if(APPLE) # fpc png unit doesn't pull the library (see bug 21833)
+ set(pascal_flags "-k${PNG_LIBRARY}" ${pascal_flags})
endif()
else()
message(STATUS "Screenshots will be in BMP format because libpng was not found")
@@ -201,8 +198,9 @@
if(NOT NOVIDEOREC)
+ set(FFMPEG_FIND_QUIETLY true)
+ find_package(FFMPEG)
if(${FFMPEG_FOUND})
- message(STATUS "Found FFMPEG: ${FFMPEG_LIBRARIES}")
include_directories(${FFMPEG_INCLUDE_DIR})
set(pascal_flags "-dUSE_VIDEO_RECORDING" ${pascal_flags})
IF (WIN32)
@@ -213,13 +211,12 @@
ELSE()
add_library(avwrapper STATIC avwrapper.c)
set(pascal_flags "-k${FFMPEG_LIBAVCODEC}" "-k${FFMPEG_LIBAVFORMAT}" "-k${FFMPEG_LIBAVUTIL}" ${pascal_flags})
- # set(pascal_flags "-k${LIBRARY_OUTPUT_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}avwrapper${CMAKE_STATIC_LIBRARY_SUFFIX}" ${pascal_flags})
ENDIF()
if(fpc_version LESS "020600")
add_dependencies(avwrapper ENGINECLEAN)
endif()
else()
- message(STATUS "Could NOT find FFMPEG, video recording will be disabled")
+ message(STATUS "Could NOT find FFMPEG/LibAV, video recording will be disabled")
endif()
else()
message(STATUS "Video recording disabled by user")
@@ -264,10 +261,8 @@
endif()
#this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
-if(fpc_version LESS "020600")
- if(NO_VIDEOREC OR NOT ${FFMPEG_FOUND})
- add_dependencies(${engine_output_name} ENGINECLEAN)
- endif()
+if((fpc_version LESS "020600") AND (NOVIDEOREC OR NOT ${FFMPEG_FOUND}))
+ add_dependencies(${engine_output_name} ENGINECLEAN)
endif()
install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir})
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/GSHandlers.inc
--- a/hedgewars/GSHandlers.inc Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/GSHandlers.inc Sat Nov 03 00:34:35 2012 +0400
@@ -93,7 +93,10 @@
else
begin
if (gi^.State and gstMoving) = 0 then
+ begin
+ gi^.dX.isNegative:= X r div 2 then
PlaySoundV(sndNooo, gi^.Hedgehog^.Team^.voicepack)
@@ -195,8 +198,8 @@
// might need some testing/adjustments - just to avoid projectiles to fly forever (accelerated by wind/skips)
- if (hwRound(Gear^.X) < LAND_WIDTH div -2)
- or (hwRound(Gear^.X) > LAND_WIDTH * 3 div 2) then
+ if (hwRound(Gear^.X) < min(LAND_WIDTH div -2, -2048))
+ or (hwRound(Gear^.X) > max(LAND_WIDTH * 3 div 2, 6144)) then
Gear^.State := Gear^.State or gstCollision;
if Gear^.dY.isNegative then
@@ -282,10 +285,12 @@
else
Gear^.State := Gear^.State or gstMoving;
- if (Gear^.nImpactSounds > 0) and (((Gear^.Kind <> gtMine) and (Gear^.Damage <> 0))
- or ((Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving))) and(((Gear^.Radius < 3) and (Gear^.dY < -_0_1))
- or ((Gear^.Radius >= 3) and ((Gear^.dX.QWordValue > _0_1.QWordValue)
- or (Gear^.dY.QWordValue > _0_1.QWordValue)))) then
+ if (Gear^.nImpactSounds > 0) and
+ (Gear^.State and gstCollision <> 0) and
+ (((Gear^.Kind <> gtMine) and (Gear^.Damage <> 0)) or (Gear^.State and gstMoving <> 0)) and
+ (((Gear^.Radius < 3) and (Gear^.dY < -_0_1)) or
+ ((Gear^.Radius >= 3) and
+ ((Gear^.dX.QWordValue > _0_1.QWordValue) or (Gear^.dY.QWordValue > _0_1.QWordValue)))) then
PlaySound(TSound(ord(Gear^.ImpactSound) + LongInt(GetRandom(Gear^.nImpactSounds))), true);
end;
@@ -984,8 +989,8 @@
// only extend if not under water
if hwRound(Bullet^.Y) < cWaterLine then
begin
- VGear^.dX := VGear^.dX + LAND_WIDTH * (VGear^.dX - VGear^.X);
- VGear^.dY := VGear^.dY + LAND_WIDTH * (VGear^.dY - VGear^.Y);
+ VGear^.dX := VGear^.dX + max(LAND_WIDTH,4096) * (VGear^.dX - VGear^.X);
+ VGear^.dY := VGear^.dY + max(LAND_WIDTH,4096) * (VGear^.dY - VGear^.Y);
end;
VGear^.Timer := 200;
@@ -2168,7 +2173,7 @@
if (GameTicks and $3F) = 0 then
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
- if (hwRound(Gear^.X) > (LAND_WIDTH+2048)) or (hwRound(Gear^.X) < -2048) then
+ if (hwRound(Gear^.X) > (max(LAND_WIDTH,4096)+2048)) or (hwRound(Gear^.X) < -2048) then
begin
// avoid to play forever (is this necessary?)
StopSoundChan(Gear^.SoundChannel);
@@ -2188,7 +2193,7 @@
else
begin
Gear^.Tag := -1;
- Gear^.X := int2hwFloat(LAND_WIDTH + 2048);
+ Gear^.X := int2hwFloat(max(LAND_WIDTH,4096) + 2048);
end;
Gear^.Y := int2hwFloat(topY-300);
@@ -3967,9 +3972,9 @@
end
else if (y > cWaterLine)
- or (y < -LAND_WIDTH)
- or (x > 2*LAND_WIDTH)
- or (x < -LAND_WIDTH) then
+ or (y < -max(LAND_WIDTH,4096))
+ or (x > 2*max(LAND_WIDTH,4096))
+ or (x < -max(LAND_WIDTH,4096)) then
loadNewPortalBall(Gear, true);
end;
@@ -4042,7 +4047,7 @@
iterator:= GearsList;
while iterator <> nil do
begin
- if not (iterator^.Kind in [gtPortal, gtAirAttack]) and ((iterator^.Hedgehog <> CurrentHedgehog)
+ if not (iterator^.Kind in [gtPortal, gtAirAttack, gtKnife]) and ((iterator^.Hedgehog <> CurrentHedgehog)
or ((iterator^.Message and gmAllStoppable) = 0)) then
begin
iterator^.Active:= true;
@@ -5109,10 +5114,10 @@
X:= HHGear^.X;
Y:= HHGear^.Y
end;
- if (gX > LAND_WIDTH*2) or
- (gX < -LAND_WIDTH) or
- (gY < -LAND_HEIGHT) or
- (gY > LAND_HEIGHT+512) then
+ if (gX > max(LAND_WIDTH,4096)*2) or
+ (gX < -max(LAND_WIDTH,4096)) or
+ (gY < -max(LAND_HEIGHT,4096)) or
+ (gY > max(LAND_HEIGHT,4096)+512) then
begin
X:= HHGear^.X;
Y:= HHGear^.Y
@@ -5244,9 +5249,14 @@
procedure doStepKnife(Gear: PGear);
var ox, oy: LongInt;
la: hwFloat;
+ a: real;
begin
// Gear is shrunk so it can actually escape the hog without carving into the terrain
if (Gear^.Radius = 6) and (Gear^.CollisionMask = $FFFF) then Gear^.Radius:= 16;
+ if Gear^.Damage > 100 then Gear^.CollisionMask:= 0
+ else if Gear^.Damage > 30 then
+ if GetRandom(max(4,18-Gear^.Damage div 10)) < 3 then Gear^.CollisionMask:= 0;
+ Gear^.Damage:= 0;
if Gear^.Timer > 0 then dec(Gear^.Timer);
if (Gear^.State and gstMoving <> 0) and (Gear^.State and gstCollision = 0) then
begin
@@ -5255,7 +5265,9 @@
Gear^.Health:= hwRound(hwSqr((hwAbs(Gear^.dY)+hwAbs(Gear^.dX))*_4));
doStepFallingGear(Gear);
AllInactive := false;
- CalcRotationDirAngle(Gear)
+ a:= Gear^.DirAngle;
+ CalcRotationDirAngle(Gear);
+ Gear^.DirAngle:= a+(Gear^.DirAngle-a)*2*hwSign(Gear^.dX) // double rotation
end
else if (Gear^.CollisionIndex = -1) and (Gear^.Timer = 0) then
begin
@@ -5275,7 +5287,7 @@
// debug for when we couldn't get an angle
//AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeWhite);
*)
- Gear^.DirAngle:= DxDy2Angle(Gear^.dX, Gear^.dY) + (random(20)-10);
+ Gear^.DirAngle:= DxDy2Angle(Gear^.dX, Gear^.dY) + (random(30)-15);
if (Gear^.dX.isNegative and Gear^.dY.isNegative) or
((not Gear^.dX.isNegative) and (not Gear^.dY.isNegative)) then Gear^.DirAngle:= Gear^.DirAngle-90;
// end
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/VGSHandlers.inc
--- a/hedgewars/VGSHandlers.inc Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/VGSHandlers.inc Sat Nov 03 00:34:35 2012 +0400
@@ -157,10 +157,12 @@
////////////////////////////////////////////////////////////////////////////////
procedure doStepExpl(Gear: PVisualGear; Steps: Longword);
+var s: LongInt;
begin
-Gear^.X:= Gear^.X + Gear^.dX * Steps;
+s:= min(Steps, cExplFrameTicks);
-Gear^.Y:= Gear^.Y + Gear^.dY * Steps;
+Gear^.X:= Gear^.X + Gear^.dX * s;
+Gear^.Y:= Gear^.Y + Gear^.dY * s;
//Gear^.dY:= Gear^.dY + cGravityf;
if Gear^.FrameTicks <= Steps then
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/hwengine.pas
--- a/hedgewars/hwengine.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/hwengine.pas Sat Nov 03 00:34:35 2012 +0400
@@ -29,14 +29,17 @@
program hwengine;
{$ENDIF}
-uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uInputHandler, uSound,
- uScript, uTeams, uStats, uIO, uLocale, uChat, uAI, uAIMisc, uLandTexture, uCollisions,
+uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uInputHandler,
+ uSound, uScript, uTeams, uStats, uIO, uLocale, uChat, uAI, uAIMisc, uAILandMarks, uLandTexture, uCollisions,
SysUtils, uTypes, uVariables, uCommands, uUtils, uCaptions, uDebug, uCommandHandlers, uLandPainted
{$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF}
- {$IFDEF SDL13}, uTouch{$ENDIF}{$IFDEF ANDROID}, GLUnit{$ENDIF}, uAILandMarks;
+ {$IFDEF USE_TOUCH_INTERFACE}, uTouch {$ENDIF}
+ {$IFDEF ANDROID}, GLUnit{$ENDIF}
+ ;
{$IFDEF HWLIBRARY}
+procedure preInitEverything();
procedure initEverything(complete:boolean);
procedure freeEverything(complete:boolean);
procedure Game(gameArgs: PPChar); cdecl; export;
@@ -44,11 +47,12 @@
implementation
{$ELSE}
+procedure preInitEverything(); forward;
procedure initEverything(complete:boolean); forward;
procedure freeEverything(complete:boolean); forward;
{$ENDIF}
-////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
function DoTimer(Lag: LongInt): boolean;
var s: shortstring;
begin
@@ -59,9 +63,9 @@
gsLandGen:
begin
GenMap;
- uLandTexture.initModule;
- UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT, false);
- uAILandMarks.initModule;
+ SetLandTexture;
+ UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT, false);
+ setAILandMarks;
ParseCommand('sendlanddigest', true);
GameState:= gsStart;
end;
@@ -136,7 +140,7 @@
end;
end;
-///////////////////
+///////////////////////////////////////////////////////////////////////////////
procedure MainLoop;
var event: TSDL_Event;
PrevTime, CurrTime: Longword;
@@ -308,29 +312,20 @@
end;
{$ENDIF}
-///////////////
+///////////////////////////////////////////////////////////////////////////////
procedure Game{$IFDEF HWLIBRARY}(gameArgs: PPChar); cdecl; export{$ENDIF};
var p: TPathType;
s: shortstring;
i: LongInt;
begin
{$IFDEF HWLIBRARY}
- cBits:= 32;
- cTimerInterval:= 8;
+ preInitEverything();
cShowFPS:= {$IFDEF DEBUGFILE}true{$ELSE}false{$ENDIF};
ipcPort:= StrToInt(gameArgs[0]);
cScreenWidth:= StrToInt(gameArgs[1]);
cScreenHeight:= StrToInt(gameArgs[2]);
cReducedQuality:= StrToInt(gameArgs[3]);
cLocaleFName:= gameArgs[4];
- // cFullScreen functionality is platform dependent, ifdef it if you need to modify it
- cFullScreen:= false;
-
- if (Length(cLocaleFName) > 6) then
- cLocale := Copy(cLocaleFName,1,5)
- else
- cLocale := Copy(cLocaleFName,1,2);
-
UserNick:= gameArgs[5];
SetSound(gameArgs[6] = '1');
SetMusic(gameArgs[7] = '1');
@@ -338,14 +333,9 @@
PathPrefix:= gameArgs[9];
UserPathPrefix:= '../Documents';
recordFileName:= gameArgs[10];
- cStereoMode:= smNone;
{$ENDIF}
- cMinScreenWidth:= min(cScreenWidth, cMinScreenWidth);
- cMinScreenHeight:= min(cScreenHeight, cMinScreenHeight);
- cOrigScreenWidth:= cScreenWidth;
- cOrigScreenHeight:= cScreenHeight;
+ initEverything(true);
- initEverything(true);
WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')');
AddFileLog('Prefix: "' + PathPrefix +'"');
AddFileLog('UserPrefix: "' + UserPathPrefix +'"');
@@ -443,40 +433,47 @@
freeEverything(true);
end;
-procedure initEverything (complete:boolean);
+///////////////////////////////////////////////////////////////////////////////
+// preInitEverything - init variables that are going to be ovewritten by arguments
+// initEverything - init variables only. Should be coupled by below
+// freeEverything - free above. Pay attention to the init/free order!
+procedure preInitEverything;
begin
Randomize();
- uUtils.initModule(complete); // this opens the debug file, must be the first
- uMisc.initModule;
- uVariables.initModule;
- uConsole.initModule;
- uCommands.initModule;
- uCommandHandlers.initModule;
+ uVariables.preInitModule;
+ uSound.preInitModule;
+end;
- uLand.initModule;
- uLandPainted.initModule;
- uIO.initModule;
+procedure initEverything (complete:boolean);
+begin
+ uUtils.initModule(complete); // opens the debug file, must be the first
+ uVariables.initModule; // inits all global variables
+ uConsole.initModule; // opens stdout
+ uCommands.initModule; // helps below
+ uCommandHandlers.initModule; // registers all messages from frontend
+
+ uLand.initModule; // computes land
+ uLandPainted.initModule; // computes drawn land
+ uIO.initModule; // sets up sockets
if complete then
begin
-{$IFDEF ANDROID}GLUnit.init;{$ENDIF}
-{$IFDEF SDL13}uTouch.initModule;{$ENDIF}
+{$IFDEF ANDROID}GLUnit.initModule;{$ENDIF}
+{$IFDEF USE_TOUCH_INTERFACE}uTouch.initModule;{$ENDIF}
+{$IFDEF USE_VIDEO_RECORDING}uVideoRec.initModule;{$ENDIF} //stub
uAI.initModule;
- //uAIActions does not need initialization
- //uAIAmmoTests does not need initialization
uAIMisc.initModule;
+ uAILandMarks.initModule; //stub
uAmmos.initModule;
+ uCaptions.initModule;
+
uChat.initModule;
uCollisions.initModule;
- //uFloat does not need initialization
- //uGame does not need initialization
uGears.initModule;
- uInputHandler.initModule;
- //uLandGraphics does not need initialization
- //uLandObjects does not need initialization
- //uLandTemplates does not need initialization
- //uLocale does not need initialization
+ uInputHandler.initModule; //stub
+ uMisc.initModule;
+ uLandTexture.initModule; //stub
uScript.initModule;
uSound.initModule;
uStats.initModule;
@@ -484,7 +481,6 @@
uTeams.initModule;
uVisualGears.initModule;
uWorld.initModule;
- uCaptions.initModule;
end;
end;
@@ -493,9 +489,9 @@
if complete then
begin
WriteLnToConsole('Freeing resources...');
- uAI.freeModule;
+ uAI.freeModule; // AI things need to be freed first
+ uAIMisc.freeModule; //stub
uAILandMarks.freeModule;
- uAIMisc.freeModule; //stub
uCaptions.freeModule;
uWorld.freeModule;
uVisualGears.freeModule;
@@ -504,22 +500,16 @@
uStats.freeModule; //stub
uSound.freeModule;
uScript.freeModule;
- //uRandom does not need to be freed
- //uLocale does not need to be freed
- //uLandTemplates does not need to be freed
+ uMisc.freeModule;
uLandTexture.freeModule;
- //uLandObjects does not need to be freed
- //uLandGraphics does not need to be freed
uGears.freeModule;
- //uGame does not need to be freed
- //uFloat does not need to be freed
uCollisions.freeModule; //stub
uChat.freeModule;
uAmmos.freeModule;
- //uAIAmmoTests does not need to be freed
- //uAIActions does not need to be freed
- uStore.freeModule;
+ uStore.freeModule; // closes SDL
{$IFDEF USE_VIDEO_RECORDING}uVideoRec.freeModule;{$ENDIF}
+{$IFDEF USE_TOUCH_INTERFACE}uTouch.freeModule;{$ENDIF} //stub
+{$IFDEF ANDROID}GLUnit.freeModule;{$ENDIF}
end;
uIO.freeModule;
@@ -528,13 +518,12 @@
uCommandHandlers.freeModule;
uCommands.freeModule;
- uConsole.freeModule;
+ uConsole.freeModule; // closes stdout
uVariables.freeModule;
- uUtils.freeModule;
- uMisc.freeModule; // uMisc closes the debug log.
+ uUtils.freeModule; // closes debug file
end;
-/////////////////////////
+///////////////////////////////////////////////////////////////////////////////
procedure GenLandPreview{$IFDEF HWLIBRARY}(port: LongInt); cdecl; export{$ENDIF};
var Preview: TPreview;
begin
@@ -557,7 +546,7 @@
end;
{$IFNDEF HWLIBRARY}
-/////////////////////
+///////////////////////////////////////////////////////////////////////////////
procedure DisplayUsage;
var i: LongInt;
begin
@@ -583,7 +572,7 @@
WriteLn(stdout, '');
end;
-////////////////////
+///////////////////////////////////////////////////////////////////////////////
{$INCLUDE "ArgParsers.inc"}
procedure GetParams;
@@ -591,27 +580,33 @@
if (ParamCount < 3) then
GameType:= gmtSyntax
else
- if (ParamCount = 3) and ((ParamStr(3) = '--stats-only') or (ParamStr(3) = 'landpreview')) then
- internalSetGameTypeLandPreviewFromParameters()
- else if ParamCount = cDefaultParamNum then
- internalStartGameWithParameters()
+ if (ParamCount = 3) and (ParamStr(3) = 'landpreview') then
+ begin
+ ipcPort:= StrToInt(ParamStr(2));
+ GameType:= gmtLandPreview;
+ end
+ else
+ begin
+ if (ParamCount = 3) and (ParamStr(3) = '--stats-only') then
+ playReplayFileWithParameters()
+ else
+ if ParamCount = cDefaultParamNum then
+ internalStartGameWithParameters()
{$IFDEF USE_VIDEO_RECORDING}
- else if ParamCount = cVideorecParamNum then
- internalStartVideoRecordingWithParameters()
+ else if ParamCount = cVideorecParamNum then
+ internalStartVideoRecordingWithParameters()
{$ENDIF}
- else
- playReplayFileWithParameters();
+ else
+ playReplayFileWithParameters();
+ end
end;
-////////////////////////////////////////////////////////////////////////////////
-/////////////////////////////// m a i n ////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////// m a i n ///////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
begin
+ preInitEverything();
GetParams();
- if (Length(cLocaleFName) > 6) then
- cLocale := Copy(cLocaleFName,1,5)
- else
- cLocale := Copy(cLocaleFName,1,2);
if GameType = gmtLandPreview then
GenLandPreview()
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/options.inc
--- a/hedgewars/options.inc Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/options.inc Sat Nov 03 00:34:35 2012 +0400
@@ -42,7 +42,6 @@
{$ENDIF}
{$IFDEF MOBILE}
- {$DEFINE SDL13}
{$DEFINE HWLIBRARY}
{$DEFINE S3D_DISABLED}
{$DEFINE GLunit:=gles11}
@@ -63,6 +62,9 @@
{$ENDIF}
{$ENDIF}
+{$IFDEF USE_TOUCH_INTERFACE}
+ {$DEFINE SDL13}
+{$ENDIF}
{$IFDEF PAS2C}
{$DEFINE NOCONSOLE}
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uAI.pas
--- a/hedgewars/uAI.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uAI.pas Sat Nov 03 00:34:35 2012 +0400
@@ -108,7 +108,7 @@
-procedure TestAmmos(var Actions: TActions; Me: PGear; isMoved: boolean);
+procedure TestAmmos(var Actions: TActions; Me: PGear; rareChecks: boolean);
var BotLevel: Byte;
ap: TAttackParams;
Score, i, dAngle: LongInt;
@@ -130,7 +130,7 @@
{$ENDIF}
repeat
if (CanUseAmmo[a])
- and ((not isMoved) or ((AmmoTests[a].flags and amtest_OnTurn) = 0))
+ and ((not rareChecks) or ((AmmoTests[a].flags and amtest_Rare) = 0))
and ((i = 0) or ((AmmoTests[a].flags and amtest_NoTarget) = 0))
then
begin
@@ -151,7 +151,7 @@
else if (ap.Angle < 0) then
AddAction(BestActions, aia_LookLeft, 0, 200, 0, 0);
- if (ap.Time <> 0) then
+ if (Ammoz[a].Ammo.Propz and ammoprop_Timerable) <> 0 then
AddAction(BestActions, aia_Timer, ap.Time div 1000, 400, 0, 0);
if (Ammoz[a].Ammo.Propz and ammoprop_NoCrosshair) = 0 then
@@ -217,7 +217,7 @@
procedure Walk(Me: PGear; var Actions: TActions);
const FallPixForBranching = cHHRadius;
var
- ticks, maxticks, steps, tmp: Longword;
+ ticks, maxticks, oldticks, steps, tmp: Longword;
BaseRate, BestRate, Rate: integer;
GoInfo: TGoInfo;
CanGo: boolean;
@@ -225,9 +225,12 @@
BotLevel: Byte;
a: TAmmoType;
begin
-ticks:= 0; // avoid compiler hint
+ticks:= 0;
+oldticks:= 0; // avoid compiler hint
Stack.Count:= 0;
+clearAllMarks;
+
for a:= Low(TAmmoType) to High(TAmmoType) do
CanUseAmmo[a]:= Assigned(AmmoTests[a].proc) and (HHHasAmmo(Me^.Hedgehog^, a) > 0);
@@ -272,12 +275,18 @@
{$HINTS OFF}
CanGo:= HHGo(Me, @AltMe, GoInfo);
{$HINTS ON}
+ oldticks:= ticks;
inc(ticks, GoInfo.Ticks);
if ticks > maxticks then
break;
- if (BotLevel < 5) and (GoInfo.JumpType = jmpHJump) then // hjump support
+ if (BotLevel < 5)
+ and (GoInfo.JumpType = jmpHJump)
+ and (not checkMark(hwRound(Me^.X), hwRound(Me^.Y), markHJumped))
+ then // hjump support
+ begin
// check if we could go backwards and maybe ljump over a gap after this hjump
+ addMark(hwRound(Me^.X), hwRound(Me^.Y), markHJumped);
if Push(ticks, Actions, AltMe, Me^.Message xor 3) then
begin
with Stack.States[Pred(Stack.Count)] do
@@ -298,8 +307,13 @@
// but first check walking forward
Push(ticks, Stack.States[Pred(Stack.Count)].MadeActions, AltMe, Me^.Message)
end;
- if (BotLevel < 3) and (GoInfo.JumpType = jmpLJump) then // ljump support
+ end;
+ if (BotLevel < 3)
+ and (GoInfo.JumpType = jmpLJump)
+ and (not checkMark(hwRound(Me^.X), hwRound(Me^.Y), markLJumped))
+ then // ljump support
begin
+ addMark(hwRound(Me^.X), hwRound(Me^.Y), markLJumped);
// at final check where we go after jump walking backward
if Push(ticks, Actions, AltMe, Me^.Message xor 3) then
with Stack.States[Pred(Stack.Count)] do
@@ -334,11 +348,11 @@
if ((Me^.State and gstAttacked) = 0) and ((steps mod 4) = 0) then
begin
- if (steps > 4) and checkMark(hwRound(Me^.X), hwRound(Me^.Y), markWasHere) then
+ if (steps > 4) and checkMark(hwRound(Me^.X), hwRound(Me^.Y), markWalkedHere) then
break;
- addMark(hwRound(Me^.X), hwRound(Me^.Y), markWasHere);
-
- TestAmmos(Actions, Me, true);
+ addMark(hwRound(Me^.X), hwRound(Me^.Y), markWalkedHere);
+
+ TestAmmos(Actions, Me, ticks shr 12 = oldticks shr 12);
end;
if GoInfo.FallPix >= FallPixForBranching then
@@ -449,7 +463,6 @@
exit;
//DeleteCI(Me); // this will break demo/netplay
-clearAllMarks;
Me^.State:= Me^.State or gstHHThinking;
Me^.Message:= 0;
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uAIActions.pas
--- a/hedgewars/uAIActions.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uAIActions.pas Sat Nov 03 00:34:35 2012 +0400
@@ -72,7 +72,7 @@
var PrevX: LongInt = 0;
timedelta: Longword = 0;
-const ActionIdToStr: array[0..8] of string[16] = (
+const ActionIdToStr: array[0..7] of string[16] = (
{aia_none} '',
{aia_Left} 'left',
{aia_Right} 'right',
@@ -80,12 +80,11 @@
{aia_attack} 'attack',
{aia_Up} 'up',
{aia_Down} 'down',
-{aia_Switch} 'switch',
-{aia_waitAngle} 'waitAngle'
+{aia_Switch} 'switch'
);
{$IFDEF TRACEAIACTIONS}
-const SpecActionIdToStr: array[$8000..$8009] of string[16] = (
+const SpecActionIdToStr: array[$8000..$800C] of string[16] = (
{aia_Weapon} 'aia_Weapon',
{aia_WaitX} 'aia_WaitX',
{aia_WaitY} 'aia_WaitY',
@@ -95,7 +94,10 @@
{aia_HJump} 'aia_HJump',
{aia_LJump} 'aia_LJump',
{aia_Skip} 'aia_Skip',
-{aia_Wait} 'aia_Wait'
+{aia_Wait} 'aia_Wait',
+{aia_Put} 'aia_Put',
+{aia_waitAngle} 'aia_waitAngle',
+{aia_waitAmmoXY} 'aia_waitAmmoXY'
);
procedure DumpAction(Action: TAction; Me: PGear);
@@ -237,8 +239,8 @@
if LongInt(Me^.Angle) <> Abs(Param) then exit;
aia_waitAmmoXY:
- if (CurAmmoGear <> nil) and ((hwRound(CurAmmoGear^.X) <> X) or (hwRound(CurAmmoGear^.Y) <> Y)) then exit;
-
+ if (CurAmmoGear <> nil) and ((hwRound(CurAmmoGear^.X) <> X) or (hwRound(CurAmmoGear^.Y) <> Y)) then
+ exit;
end
else
begin
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uAIAmmoTests.pas
--- a/hedgewars/uAIAmmoTests.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uAIAmmoTests.pas Sat Nov 03 00:34:35 2012 +0400
@@ -22,7 +22,7 @@
interface
uses SDLh, uConsts, uFloat, uTypes;
const
- amtest_OnTurn = $00000001; // from one position
+ amtest_Rare = $00000001; // check only several positions
amtest_NoTarget = $00000002; // each pos, but no targetting
var windSpeed: real;
@@ -77,7 +77,7 @@
(proc: @TestWhip; flags: amtest_NoTarget), // amWhip
(proc: @TestBaseballBat; flags: amtest_NoTarget), // amBaseballBat
(proc: nil; flags: 0), // amParachute
- (proc: @TestAirAttack; flags: amtest_OnTurn), // amAirAttack
+ (proc: @TestAirAttack; flags: amtest_Rare), // amAirAttack
(proc: nil; flags: 0), // amMineStrike
(proc: nil; flags: 0), // amBlowTorch
(proc: nil; flags: 0), // amGirder
@@ -86,7 +86,7 @@
(proc: nil; flags: 0), // amSwitch
(proc: @TestMortar; flags: 0), // amMortar
(proc: @TestKamikaze; flags: 0), // amKamikaze
- (proc: @TestCake; flags: amtest_OnTurn or amtest_NoTarget), // amCake
+ (proc: @TestCake; flags: amtest_Rare or amtest_NoTarget), // amCake
(proc: nil; flags: 0), // amSeduction
(proc: @TestWatermelon; flags: 0), // amWatermelon
(proc: nil; flags: 0), // amHellishBomb
@@ -287,7 +287,6 @@
begin
ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level));
ap.Power:= trunc(sqrt(r) * cMaxPower) + AIrndSign(random(Level) * 15);
- ap.Time:= TestTime;
ap.ExplR:= 100;
ap.ExplX:= EX;
ap.ExplY:= EY;
@@ -496,6 +495,7 @@
begin
TestMortar:= BadTurn;
ap.ExplR:= 0;
+
meX:= hwFloat2Float(Me^.X);
meY:= hwFloat2Float(Me^.Y);
@@ -682,7 +682,7 @@
or (y < 0)
or (trunc(x) > LAND_WIDTH)
or (trunc(y) > LAND_HEIGHT)
- or (d > 23);
+ or (d > 22);
if Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 4 then
begin
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uAILandMarks.pas
--- a/hedgewars/uAILandMarks.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uAILandMarks.pas Sat Nov 03 00:34:35 2012 +0400
@@ -1,12 +1,16 @@
unit uAILandMarks;
interface
-const markWasHere = $01;
+const
+ markWalkedHere = $01;
+ markHJumped = $02;
+ markLJumped = $04;
procedure addMark(X, Y: LongInt; mark: byte);
function checkMark(X, Y: LongInt; mark: byte) : boolean;
procedure clearAllMarks;
procedure clearMarks(mark: byte);
+procedure setAILandMarks;
procedure initModule;
procedure freeModule;
@@ -54,8 +58,7 @@
marks[Y, X]:= marks[Y, X] and (not mark)
end;
-
-procedure initModule;
+procedure setAILandMarks;
begin
WIDTH:= LAND_WIDTH shr gr;
HEIGHT:= LAND_HEIGHT shr gr;
@@ -63,6 +66,10 @@
SetLength(marks, HEIGHT, WIDTH);
end;
+procedure initModule;
+begin
+end;
+
procedure freeModule;
begin
SetLength(marks, 0, 0);
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uAIMisc.pas
--- a/hedgewars/uAIMisc.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uAIMisc.pas Sat Nov 03 00:34:35 2012 +0400
@@ -110,7 +110,9 @@
begin
for i:= 0 to cMaxHHIndex do
if (Hedgehogs[i].Gear <> nil)
- and (Hedgehogs[i].Gear <> ThinkingHH) then
+ and (Hedgehogs[i].Gear <> ThinkingHH)
+ and (Hedgehogs[i].Gear^.Health > Hedgehogs[i].Gear^.Damage)
+ then
begin
with Targets.ar[Targets.Count], Hedgehogs[i] do
begin
@@ -119,11 +121,11 @@
Point.Y:= hwRound(Gear^.Y);
if Clan <> CurrentTeam^.Clan then
begin
- Score:= Gear^.Health;
+ Score:= Gear^.Health - Gear^.Damage;
inc(e)
end else
begin
- Score:= -Gear^.Health;
+ Score:= Gear^.Damage - Gear^.Health;
inc(f)
end
end;
@@ -770,7 +772,6 @@
procedure freeModule;
begin
-
end;
end.
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uCommandHandlers.pas
--- a/hedgewars/uCommandHandlers.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uCommandHandlers.pas Sat Nov 03 00:34:35 2012 +0400
@@ -37,7 +37,7 @@
'R': if ReadyTimeLeft > 1 then
begin
ReadyTimeLeft:= 1;
- if not CurrentTeam^.ExtDriven then
+ if not isExternalSource then
SendIPC('c'+s);
end
end
@@ -218,7 +218,7 @@
s:= s; // avoid compiler hint
if CheckNoTeamOrHH or isPaused then
exit;
-if not CurrentTeam^.ExtDriven then
+if not isExternalSource then
SendIPC(_S'L');
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
@@ -231,7 +231,7 @@
s:= s; // avoid compiler hint
if CheckNoTeamOrHH then
exit;
-if not CurrentTeam^.ExtDriven then
+if not isExternalSource then
SendIPC(_S'l');
with CurrentHedgehog^.Gear^ do
Message:= Message and (not (gmLeft and InputMask));
@@ -243,7 +243,7 @@
s:= s; // avoid compiler hint
if CheckNoTeamOrHH or isPaused then
exit;
-if not CurrentTeam^.ExtDriven then
+if not isExternalSource then
SendIPC(_S'R');
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
@@ -256,7 +256,7 @@
s:= s; // avoid compiler hint
if CheckNoTeamOrHH then
exit;
-if not CurrentTeam^.ExtDriven then
+if not isExternalSource then
SendIPC(_S'r');
with CurrentHedgehog^.Gear^ do
Message:= Message and (not (gmRight and InputMask));
@@ -268,7 +268,7 @@
s:= s; // avoid compiler hint
if CheckNoTeamOrHH or isPaused then
exit;
-if not CurrentTeam^.ExtDriven then
+if not isExternalSource then
SendIPC(_S'U');
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
@@ -281,7 +281,7 @@
s:= s; // avoid compiler hint
if CheckNoTeamOrHH then
exit;
-if not CurrentTeam^.ExtDriven then
+if not isExternalSource then
SendIPC(_S'u');
with CurrentHedgehog^.Gear^ do
Message:= Message and (not (gmUp and InputMask));
@@ -293,7 +293,7 @@
s:= s; // avoid compiler hint
if CheckNoTeamOrHH or isPaused then
exit;
-if not CurrentTeam^.ExtDriven then
+if not isExternalSource then
SendIPC(_S'D');
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
@@ -306,7 +306,7 @@
s:= s; // avoid compiler hint
if CheckNoTeamOrHH then
exit;
-if not CurrentTeam^.ExtDriven then
+if not isExternalSource then
SendIPC(_S'd');
with CurrentHedgehog^.Gear^ do
Message:= Message and (not (gmDown and InputMask));
@@ -318,7 +318,7 @@
s:= s; // avoid compiler hint
if CheckNoTeamOrHH or isPaused then
exit;
-if not CurrentTeam^.ExtDriven then
+if not isExternalSource then
SendIPC(_S'Z');
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
@@ -331,7 +331,7 @@
s:= s; // avoid compiler hint
if CheckNoTeamOrHH then
exit;
-if not CurrentTeam^.ExtDriven then
+if not isExternalSource then
SendIPC(_S'z');
with CurrentHedgehog^.Gear^ do
Message:= Message and (not (gmPrecise and InputMask));
@@ -343,7 +343,7 @@
s:= s; // avoid compiler hint
if CheckNoTeamOrHH or isPaused then
exit;
-if not CurrentTeam^.ExtDriven then
+if not isExternalSource then
SendIPC(_S'j');
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
@@ -356,7 +356,7 @@
s:= s; // avoid compiler hint
if CheckNoTeamOrHH or isPaused then
exit;
-if not CurrentTeam^.ExtDriven then
+if not isExternalSource then
SendIPC(_S'J');
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
@@ -376,7 +376,7 @@
if ((State and gstHHDriven) <> 0) then
begin
FollowGear:= CurrentHedgehog^.Gear;
- if not CurrentTeam^.ExtDriven then
+ if not isExternalSource then
SendIPC(_S'A');
Message:= Message or (gmAttack and InputMask);
ScriptCall('onAttack');
@@ -391,7 +391,7 @@
exit;
with CurrentHedgehog^.Gear^ do
begin
- if not CurrentTeam^.ExtDriven and
+ if not isExternalSource and
((Message and gmAttack) <> 0) then
SendIPC(_S'a');
Message:= Message and (not (gmAttack and InputMask));
@@ -404,7 +404,7 @@
s:= s; // avoid compiler hint
if CheckNoTeamOrHH or isPaused then
exit;
-if not CurrentTeam^.ExtDriven then
+if not isExternalSource then
SendIPC(_S'S');
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
@@ -428,7 +428,7 @@
gi := gi^.NextGear
end;
- if not CurrentTeam^.ExtDriven then
+ if not isExternalSource then
begin
s[0]:= #5;
s[1]:= 'N';
@@ -436,16 +436,19 @@
SendIPC(s)
end
else
- TryDo(CheckSum = lastTurnChecksum, 'Desync detected', true);
+ TryDo(CurrentTeam^.hasGone or (CheckSum = lastTurnChecksum), 'Desync detected', true);
+
AddFileLog('Next turn: time '+inttostr(GameTicks));
end;
procedure chTimer(var s: shortstring);
begin
-if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or CheckNoTeamOrHH then
+if CheckNoTeamOrHH then
exit;
-if not CurrentTeam^.ExtDriven then
+TryDo((s[0] = #1) and (s[1] >= '1') and (s[1] <= '5'), 'Malformed /timer', true);
+
+if not isExternalSource then
SendIPC(s);
bShowFinger:= false;
with CurrentHedgehog^.Gear^ do
@@ -465,7 +468,7 @@
slot:= byte(s[1]) - 49;
if slot > cMaxSlotIndex then
exit;
-if not CurrentTeam^.ExtDriven then
+if not isExternalSource then
begin
ss[0]:= #1;
ss[1]:= char(byte(s[1]) + 79);
@@ -482,13 +485,12 @@
procedure chSetWeapon(var s: shortstring);
begin
- if (s[0] <> #1) or CheckNoTeamOrHH then
+ if CheckNoTeamOrHH then
exit;
- if TAmmoType(s[1]) > High(TAmmoType) then
- exit;
+ TryDo((s[0] = #1) and (s[1] <= char(High(TAmmoType))), 'Malformed /setweap', true);
- if not CurrentTeam^.ExtDriven then
+ if not isExternalSource then
SendIPC('w' + s);
with CurrentHedgehog^.Gear^ do
@@ -507,7 +509,7 @@
if TWave(s[1]) > High(TWave) then
exit;
-if not CurrentTeam^.ExtDriven then
+if not isExternalSource then
SendIPC('t' + s);
with CurrentHedgehog^.Gear^ do
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uCommands.pas
--- a/hedgewars/uCommands.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uCommands.pas Sat Nov 03 00:34:35 2012 +0400
@@ -23,13 +23,15 @@
interface
var isDeveloperMode: boolean;
+var isExternalSource: boolean;
type TCommandHandler = procedure (var params: shortstring);
procedure initModule;
procedure freeModule;
procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean; Rand: boolean);
procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean);
-procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean);
+procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean); inline;
+procedure ParseCommand(CmdStr: shortstring; TrustedSource, ExternalSource: boolean);
procedure ParseTeamCommand(s: shortstring);
procedure StopMessages(Message: Longword);
@@ -44,8 +46,7 @@
Trusted, Rand: boolean;
end;
-var
- Variables: PVariable;
+var Variables: PVariable;
procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean);
begin
@@ -73,11 +74,17 @@
end;
-procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean);
+procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean); inline;
+begin
+ ParseCommand(CmdStr, TrustedSource, false)
+end;
+
+procedure ParseCommand(CmdStr: shortstring; TrustedSource, ExternalSource: boolean);
var s: shortstring;
t: PVariable;
c: char;
begin
+isExternalSource:= ExternalSource or ((CurrentTeam <> nil) and CurrentTeam^.ExtDriven);
//WriteLnToConsole(CmdStr);
if CmdStr[0]=#0 then
exit;
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uGame.pas
--- a/hedgewars/uGame.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uGame.pas Sat Nov 03 00:34:35 2012 +0400
@@ -28,7 +28,7 @@
////////////////////
uses uInputHandler, uTeams, uIO, uAI, uGears, uSound, uMobile,
uVisualGears, uTypes, uVariables, uCommands, uConsts
- {$IFDEF SDL13}, uTouch{$ENDIF};
+ {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF};
procedure DoGameTick(Lag: LongInt);
var i: LongInt;
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uGears.pas
--- a/hedgewars/uGears.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uGears.pas Sat Nov 03 00:34:35 2012 +0400
@@ -33,7 +33,7 @@
* effects are called "Visual Gears" and defined in the respective unit!
*)
interface
-uses SDLh, uConsts, uFloat, uTypes, uLandObjects;
+uses SDLh, uConsts, uFloat, uTypes;
procedure initModule;
procedure freeModule;
@@ -111,10 +111,12 @@
end
else
dec(Gear^.Health, dmg);
-
+(*
+This doesn't fit well w/ the new loser sprite which is cringing from an attack.
if (Gear^.Hedgehog^.Team = CurrentTeam) and (Gear^.Damage <> Gear^.Karma)
and (not Gear^.Hedgehog^.King) and (Gear^.Hedgehog^.Effects[hePoisoned] = 0) and (not SuddenDeathDmg) then
Gear^.State:= Gear^.State or gstLoser;
+*)
spawnHealthTagForHH(Gear, dmg);
@@ -1223,7 +1225,7 @@
procedure chSkip(var s: shortstring);
begin
s:= s; // avoid compiler hint
-if not CurrentTeam^.ExtDriven then
+if not isExternalSource then
SendIPC(_S',');
uStats.Skipped;
skipFlag:= true
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uGearsHedgehog.pas
--- a/hedgewars/uGearsHedgehog.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uGearsHedgehog.pas Sat Nov 03 00:34:35 2012 +0400
@@ -323,7 +323,7 @@
newGear^.SoundChannel:= LoopSound(sndRCPlane)
end;
amKamikaze: newGear:= AddGear(hwRound(lx), hwRound(ly), gtKamikaze, 0, xx * _0_5, yy * _0_5, 0);
- amCake: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 3, hwRound(ly), gtCake, 0, xx, _0, 0);
+ amCake: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 3, hwRound(ly), gtCake, 0, SignAs(cLittle, xx), _0, 0);
amSeduction: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSeduction, 0, _0, _0, 0);
amWatermelon: newGear:= AddGear(hwRound(lx), hwRound(ly), gtWatermelon, 0, newDx, newDy, CurWeapon^.Timer);
amHellishBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtHellishBomb, 0, newDx, newDy, 0);
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uGearsRender.pas
--- a/hedgewars/uGearsRender.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uGearsRender.pas Sat Nov 03 00:34:35 2012 +0400
@@ -316,16 +316,23 @@
lx:= lx + ax;
ly:= ly + ay;
tx:= round(lx);
- ty:= round(ly)
+ ty:= round(ly);
+ if (abs(tx-hx) > 1000) or (abs(hy-ty) > 1000) then
+ begin
+ DrawLine(hx, hy, tx, ty, 1.0, $FF, $00, $00, $C0);
+ hx:= tx;
+ hy:= ty
+ end
end;
// reached edge of land. assume infinite beam. Extend it way out past camera
if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then
begin
- tx:= round(lx + ax * (LAND_WIDTH div 2));
- ty:= round(ly + ay * (LAND_WIDTH div 2));
+ tx:= round(lx + ax * (max(LAND_WIDTH,4096) div 2));
+ ty:= round(ly + ay * (max(LAND_WIDTH,4096) div 2));
end;
//if (abs(lx-tx)>8) or (abs(ly-ty)>8) then
+ if (tx <> hx) or (ty <> hy) then
begin
DrawLine(hx, hy, tx, ty, 1.0, $FF, $00, $00, $C0);
end;
@@ -1086,9 +1093,9 @@
endX:= x - WorldDx;
endY:= y - WorldDy;
if Gear^.Tag < 0 then
- startX:= max(LAND_WIDTH + 1024, endX + 2048)
+ startX:= max(max(LAND_WIDTH,4096) + 1024, endX + 2048)
else
- startX:= max(-LAND_WIDTH - 1024, endX - 2048);
+ startX:= max(-max(LAND_WIDTH,4096) - 1024, endX - 2048);
startY:= endY - 256;
DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + LongInt(round((endX - startX) * (-power(2, -10 * LongInt(Gear^.Timer)/2000) + 1))), startY + WorldDy + LongInt(round((endY - startY) * sqrt(1 - power((LongInt(Gear^.Timer)/2000)-1, 2)))), ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
end
@@ -1097,9 +1104,9 @@
startX:= x - WorldDx;
startY:= y - WorldDy;
if Gear^.Tag > 0 then
- endX:= max(LAND_WIDTH + 1024, startX + 2048)
+ endX:= max(max(LAND_WIDTH,4096) + 1024, startX + 2048)
else
- endX:= max(-LAND_WIDTH - 1024, startX - 2048);
+ endX:= max(-max(LAND_WIDTH,4096) - 1024, startX - 2048);
endY:= startY + 256;
DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + LongInt(round((endX - startX) * power(2, 10 * (LongInt(Gear^.Timer)/2000 - 1)))) + hwRound(Gear^.dX * Gear^.Timer), startY + WorldDy + LongInt(round((endY - startY) * cos(LongInt(Gear^.Timer)/2000 * (Pi/2)) - (endY - startY))) + hwRound(Gear^.dY * Gear^.Timer), ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
end;
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uGearsUtils.pas
--- a/hedgewars/uGearsUtils.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uGearsUtils.pas Sat Nov 03 00:34:35 2012 +0400
@@ -323,8 +323,9 @@
var
dAngle: real;
begin
-// Frac/Round to be kind to JS as of 2012-08-27 where there is yet no int64/uint64
- dAngle := (Gear^.dX.Round + Gear^.dY.Round) / 2 + (Gear^.dX.Frac+Gear^.dY.Frac) / $80000000;
+ // Frac/Round to be kind to JS as of 2012-08-27 where there is yet no int64/uint64
+ //dAngle := (Gear^.dX.QWordValue + Gear^.dY.QWordValue) / $80000000;
+ dAngle := (Gear^.dX.Round + Gear^.dY.Round) / 2 + (Gear^.dX.Frac/$100000000+Gear^.dY.Frac/$100000000);
if not Gear^.dX.isNegative then
Gear^.DirAngle := Gear^.DirAngle + dAngle
else
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uInputHandler.pas
--- a/hedgewars/uInputHandler.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uInputHandler.pas Sat Nov 03 00:34:35 2012 +0400
@@ -57,7 +57,7 @@
RCTRL = $4000;
var tkbd: array[0..cKbdMaxIndex] of boolean;
- quitKeyCode: Byte;
+ quitKeyCode, closeKeyCode: Byte;
KeyNames: array [0..cKeyMaxIndex] of string[15];
CurrentBinds: TBinds;
@@ -134,7 +134,23 @@
{$ELSE}
if tkbd[KeyNameToCode('left_ctrl')] or tkbd[KeyNameToCode('right_ctrl')] then
{$ENDIF}
- ParseCommand('halt', true);
+ ParseCommand('halt', true);
+ end;
+
+// ctrl/cmd + w to close engine
+if(KeyDown and (code = closeKeyCode)) then
+ begin
+{$IFDEF DARWIN}
+ // on OS X it this is expected behaviour
+ if tkbd[KeyNameToCode('left_meta')] or tkbd[KeyNameToCode('right_meta')] then
+{$ELSE}
+ // on other systems use this shortcut only if the keys are not bound to any command
+ if tkbd[KeyNameToCode('left_ctrl')] or tkbd[KeyNameToCode('right_ctrl')] then
+ if ((CurrentBinds[KeyNameToCode('left_ctrl')] = '') or
+ (CurrentBinds[KeyNameToCode('right_ctrl')] = '')) and
+ (CurrentBinds[closeKeyCode] = '') then
+{$ENDIF}
+ ParseCommand('forcequit', true);
end;
if CurrentBinds[code][0] <> #0 then
@@ -204,7 +220,7 @@
for i:= 6 to cKeyMaxIndex do
begin
s:= shortstring(sdl_getkeyname(i));
- //WriteLnToConsole(IntToStr(i) + ': ' + s + ' ' + IntToStr(cKeyMaxIndex));
+ //WriteLnToConsole('uInputHandler - ' + IntToStr(i) + ': ' + s + ' ' + IntToStr(cKeyMaxIndex));
if s = 'unknown key' then KeyNames[i]:= ''
else
begin
@@ -216,6 +232,7 @@
end;
quitKeyCode:= KeyNameToCode(_S'q');
+closeKeyCode:= KeyNameToCode(_S'w');
// get the size of keyboard array
SDL_GetKeyState(@k);
@@ -245,7 +262,7 @@
end;
DefaultBinds[KeyNameToCode('escape')]:= 'quit';
-DefaultBinds[KeyNameToCode('grave')]:= 'history';
+DefaultBinds[KeyNameToCode(_S'`')]:= 'history';
DefaultBinds[KeyNameToCode('delete')]:= 'rotmask';
//numpad
@@ -426,8 +443,6 @@
procedure initModule;
begin
- wheelUp:= false;
- wheelDown:= false;
end;
procedure freeModule;
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uLandTemplates.pas
--- a/hedgewars/uLandTemplates.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uLandTemplates.pas Sat Nov 03 00:34:35 2012 +0400
@@ -1758,18 +1758,18 @@
const Template44Points: array[0..14] of TSDL_Rect =
(
(x: 0; y: 100; w: 1; h: 50),
- (x: 4096; y: 100; w: 1; h: 50),
- (x: 4096; y: 400; w: 1; h: 50),
+ (x: 4095; y: 100; w: 1; h: 50),
+ (x: 4095; y: 400; w: 1; h: 50),
(x: 0; y: 360; w: 1; h: 50),
(x: NTPX; y: 0; w: 1; h: 1),
(x: 0; y: 750; w: 1; h: 50),
- (x: 4096; y: 750; w: 1; h: 50),
- (x: 4096; y:1100; w: 1; h: 50),
+ (x: 4095; y: 750; w: 1; h: 50),
+ (x: 4095; y:1100; w: 1; h: 50),
(x: 0; y:1100; w: 1; h: 50),
(x: NTPX; y: 0; w: 1; h: 1),
(x: 0; y:1300; w: 1; h: 250),
- (x: 4096; y:1300; w: 1; h: 250),
- (x: 4096; y:1800; w: 1; h: 200),
+ (x: 4095; y:1300; w: 1; h: 250),
+ (x: 4095; y:1800; w: 1; h: 200),
(x: 0; y:1800; w: 1; h: 200),
(x: NTPX; y: 0; w: 1; h: 1)
);
@@ -1777,9 +1777,9 @@
(
(X: 1; Y: 90; w: 0; h: 0),
(X: 1; Y: 500; w: 0; h: 0),
- (X:4096; Y: 500; w: 0; h: 0),
+ (X:4095; Y: 500; w: 0; h: 0),
(X: 1; Y:1200; w: 0; h: 0),
- (X:4096; Y:1200; w: 0; h: 0),
+ (X:4095; Y:1200; w: 0; h: 0),
(X: 1; Y:2010; w: 0; h: 0)
);
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uLandTexture.pas
--- a/hedgewars/uLandTexture.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uLandTexture.pas Sat Nov 03 00:34:35 2012 +0400
@@ -27,6 +27,7 @@
procedure UpdateLandTexture(X, Width, Y, Height: LongInt; landAdded: boolean);
procedure DrawLand(dX, dY: LongInt);
procedure ResetLand;
+procedure SetLandTexture;
implementation
uses uConsts, GLunit, uTypes, uVariables, uTextures, uDebug, uRender;
@@ -183,7 +184,7 @@
end;
-procedure initModule;
+procedure SetLandTexture;
begin
if (cReducedQuality and rqBlurryLand) = 0 then
begin
@@ -199,6 +200,10 @@
SetLength(LandTextures, LANDTEXARW, LANDTEXARH);
end;
+procedure initModule;
+begin
+end;
+
procedure ResetLand;
var x, y: LongInt;
begin
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uMisc.pas
--- a/hedgewars/uMisc.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uMisc.pas Sat Nov 03 00:34:35 2012 +0400
@@ -206,9 +206,9 @@
for i0:= 0 to k-1 do
for j0:= 0 to k-1 do
begin
- r+= img[4*(width*(i*k+i0) + j*k+j0)+0];
- g+= img[4*(width*(i*k+i0) + j*k+j0)+1];
- b+= img[4*(width*(i*k+i0) + j*k+j0)+2];
+ inc(r, img[4*(width*(i*k+i0) + j*k+j0)+0]);
+ inc(g, img[4*(width*(i*k+i0) + j*k+j0)+1]);
+ inc(b, img[4*(width*(i*k+i0) + j*k+j0)+2]);
end;
img[4*(w*i + j)+0]:= r div (k*k);
img[4*(w*i + j)+1]:= g div (k*k);
@@ -311,7 +311,6 @@
procedure freeModule;
begin
- recordFileName:= '';
SDL_FreeFormat(conversionFormat);
end;
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uScript.pas
--- a/hedgewars/uScript.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uScript.pas Sat Nov 03 00:34:35 2012 +0400
@@ -46,7 +46,7 @@
function ScriptExists(fname : shortstring) : boolean;
-function ParseCommandOverride(key, value : shortstring) : shortstring;
+//function ParseCommandOverride(key, value : shortstring) : shortstring; This did not work out well
procedure initModule;
procedure freeModule;
@@ -196,7 +196,7 @@
for i:= 1 to c do s[i]:= t[i-1];
s[0]:= char(c);
- ParseCommand(s, true);
+ ParseCommand(s, true, true);
end
else
@@ -1306,11 +1306,11 @@
end
else
begin
- ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true);
- ParseCommand('grave ' + lua_tostring(L, 3), true);
- ParseCommand('fort ' + lua_tostring(L, 4), true);
- ParseCommand('voicepack ' + lua_tostring(L, 5), true);
- if (np = 6) then ParseCommand('flag ' + lua_tostring(L, 6), true);
+ ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true, true);
+ ParseCommand('grave ' + lua_tostring(L, 3), true, true);
+ ParseCommand('fort ' + lua_tostring(L, 4), true, true);
+ ParseCommand('voicepack ' + lua_tostring(L, 5), true, true);
+ if (np = 6) then ParseCommand('flag ' + lua_tostring(L, 6), true, true);
CurrentTeam^.Binds:= DefaultBinds
// fails on x64
//lua_pushinteger(L, LongInt(CurrentTeam));
@@ -1329,8 +1329,8 @@
else
begin
temp:= lua_tostring(L, 4);
- ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true);
- ParseCommand('hat ' + temp, true);
+ ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true, true);
+ ParseCommand('hat ' + temp, true, true);
lua_pushinteger(L, CurrentHedgehog^.Gear^.uid);
end;
lc_addhog:= 1;
@@ -1669,7 +1669,11 @@
if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then
hat:= lua_tostring(L, 2);
gear^.Hedgehog^.Hat:= hat;
- LoadHedgehogHat(gear^.Hedgehog^, hat);
+AddFileLog('Changed hat to: '+hat);
+ if (Length(hat) > 39) and (Copy(hat,1,8) = 'Reserved') and (Copy(hat,9,32) = gear^.Hedgehog^.Team^.PlayerHash) then
+ LoadHedgehogHat(gear^.Hedgehog^, 'Reserved/' + Copy(hat,9,Length(hat)-8))
+ else
+ LoadHedgehogHat(gear^.Hedgehog^, hat);
end;
lc_sethoghat:= 0;
end;
@@ -1871,7 +1875,7 @@
ScriptCall('onGameInit');
// pop game variables
-ParseCommand('seed ' + ScriptGetString('Seed'), true);
+ParseCommand('seed ' + ScriptGetString('Seed'), true, true);
cTemplateFilter := ScriptGetInteger('TemplateFilter');
LuaTemplateNumber:= ScriptGetInteger('TemplateNumber');
cMapGen := ScriptGetInteger('MapGen');
@@ -1892,9 +1896,10 @@
cWaterRise := ScriptGetInteger('WaterRise');
cHealthDecrease := ScriptGetInteger('HealthDecrease');
-ParseCommand('map ' + ScriptGetString('Map'), true);
+if cMapName <> ScriptGetString('Map') then
+ ParseCommand('map ' + ScriptGetString('Map'), true, true);
if ScriptGetString('Theme') <> '' then
- ParseCommand('theme ' + ScriptGetString('Theme'), true);
+ ParseCommand('theme ' + ScriptGetString('Theme'), true, true);
LuaGoals:= ScriptGetString('Goals');
// Support lua changing the ammo layout - assume all hogs have same ammo, note this might leave a few ammo stores lying around.
@@ -2016,6 +2021,7 @@
GetGlobals;
end;
+(*
function ParseCommandOverride(key, value : shortstring) : shortstring;
begin
ParseCommandOverride:= value;
@@ -2035,6 +2041,7 @@
lua_pop(luaState, 1)
end;
end;
+*)
function ScriptCall(fname : shortstring; par1: LongInt) : LongInt;
begin
@@ -2449,7 +2456,7 @@
fname:= fname; // avoid hint
ScriptExists:= false
end;
-
+(*
function ParseCommandOverride(key, value : shortstring) : shortstring;
begin
// avoid hints
@@ -2457,6 +2464,7 @@
value:= value;
ParseCommandOverride:= ''
end;
+*)
procedure ScriptOnScreenResize;
begin
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uSound.pas
--- a/hedgewars/uSound.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uSound.pas Sat Nov 03 00:34:35 2012 +0400
@@ -35,6 +35,7 @@
interface
uses SDLh, uConsts, uTypes, SysUtils;
+procedure preInitModule;
procedure initModule;
procedure freeModule;
@@ -47,7 +48,7 @@
// Obvious music commands for music track
procedure SetMusic(enabled: boolean); // Enable/disable music.
-procedure SetMusicName(musicname: shortstring); // Enable/disable music and set name of the file to play.
+procedure SetMusicName(musicname: shortstring); // Set name of the file to play.
procedure PlayMusic; // Play music from the start.
procedure PauseMusic; // Pause music.
procedure ResumeMusic; // Resume music from pause point.
@@ -95,7 +96,7 @@
// MISC
// Set the initial volume
-procedure SetVolume(volume: LongInt);
+procedure SetVolume(vol: LongInt);
// Modifies the sound volume of the game by voldelta and returns the new volume level.
function ChangeVolume(voldelta: LongInt): LongInt;
@@ -114,7 +115,7 @@
lastChan: array [TSound] of LongInt;
voicepacks: array[0..cMaxTeams] of TVoicepack;
defVoicepack: PVoicepack;
- Mus: PMixMusic = nil; // music pointer
+ Mus: PMixMusic; // music pointer
MusicFN: shortstring; // music file name
isMusicEnabled: boolean;
isSoundEnabled: boolean;
@@ -445,15 +446,15 @@
SDLTry(Mix_FadeInMusic(Mus, -1, 3000) <> -1, false)
end;
-procedure SetVolume(volume: LongInt);
+procedure SetVolume(vol: LongInt);
begin
- cInitVolume:= volume;
+ cInitVolume:= vol;
end;
function ChangeVolume(voldelta: LongInt): LongInt;
begin
ChangeVolume:= 0;
- if (not isSoundEnabled) or (voldelta = 0) then
+ if (not isSoundEnabled) or ((voldelta = 0) and not (cInitVolume = 0)) then
exit;
inc(Volume, voldelta);
@@ -494,7 +495,7 @@
procedure MuteAudio;
begin
if (not isSoundEnabled) then
- exit;
+ exit;
if (isAudioMuted) then
begin
@@ -514,12 +515,10 @@
procedure SetMusic(enabled: boolean);
begin
isMusicEnabled:= enabled;
- MusicFN:= '';
end;
procedure SetMusicName(musicname: shortstring);
begin
- isMusicEnabled:= not (musicname = '');
MusicFN:= musicname;
end;
@@ -579,6 +578,13 @@
MuteAudio;
end;
+procedure preInitModule;
+begin
+ isMusicEnabled:= true;
+ isSoundEnabled:= true;
+ cInitVolume:= 100;
+end;
+
procedure initModule;
var t: LongInt;
i: TSound;
@@ -587,6 +593,7 @@
RegisterVariable('mute' , @chMute , true );
MusicFN:='';
+ Mus:= nil;
isAudioMuted:= false;
isSEBackup:= isSoundEnabled;
Volume:= 0;
@@ -602,7 +609,7 @@
voicepacks[t].chunks[i]:= nil;
(* on MOBILE SDL_mixer has to be compiled against Tremor (USE_OGG_TREMOR)
- or sound files bigger than 32k will lockup the game*)
+ or sound files bigger than 32k will lockup the game *)
for i:= Low(TSound) to High(TSound) do
defVoicepack^.chunks[i]:= nil;
@@ -612,11 +619,6 @@
begin
if isSoundEnabled then
ReleaseSound(true);
- // koda still needs to fix this properly. when he rearranged things, he made these variables get
- // reset after argparsers picks them up
- isMusicEnabled:= true;
- isSoundEnabled:= true;
- cInitVolume:= 100;
end;
end.
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uStats.pas
--- a/hedgewars/uStats.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uStats.pas Sat Nov 03 00:34:35 2012 +0400
@@ -311,7 +311,6 @@
procedure freeModule;
begin
-
end;
end.
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uStore.pas
--- a/hedgewars/uStore.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uStore.pas Sat Nov 03 00:34:35 2012 +0400
@@ -53,7 +53,7 @@
{$ENDIF}
procedure WarpMouse(x, y: Word); inline;
-procedure SwapBuffers; inline;
+procedure SwapBuffers; {$IFDEF USE_VIDEO_RECORDING}cdecl{$ELSE}inline{$ENDIF};
implementation
uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands,
@@ -1115,6 +1115,7 @@
glutInitWindowSize(cScreenWidth, cScreenHeight);
glutCreateWindow('hedgewars (you don''t see this)'); // we don't need a window, but if this function is not called then OpenGL will not be initialized
glutHideWindow();
+ glutDisplayFunc(@SwapBuffers); // we don't need a callback, but it's required for GLUT3
SetupOpenGL();
end;
{$ENDIF} // SDL13
@@ -1296,7 +1297,7 @@
{$ENDIF}
end;
-procedure SwapBuffers; inline;
+procedure SwapBuffers; {$IFDEF USE_VIDEO_RECORDING}cdecl{$ELSE}inline{$ENDIF};
begin
if GameType = gmtRecord then
exit;
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uTeams.pas
--- a/hedgewars/uTeams.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uTeams.pas Sat Nov 03 00:34:35 2012 +0400
@@ -20,8 +20,10 @@
unit uTeams;
interface
-uses uConsts, uInputHandler, uGears, uRandom, uFloat, uStats, uVisualGears, uCollisions, GLunit, uSound, uStore,
- uTypes{$IFDEF USE_TOUCH_INTERFACE}, uWorld{$ENDIF};
+uses uConsts, uInputHandler, uGears, uRandom, uFloat, uStats, uVisualGears, uCollisions, GLunit,
+ uSound, uStore, uTypes
+ {$IFDEF USE_TOUCH_INTERFACE}, uWorld{$ENDIF};
+
procedure initModule;
procedure freeModule;
@@ -39,7 +41,8 @@
implementation
uses uLocale, uAmmos, uChat, uVariables, uUtils, uIO, uCaptions, uCommands, uDebug, uScript,
- uGearsUtils, uGearsList{$IFDEF SDL13}, uTouch{$ENDIF};
+ uGearsUtils, uGearsList
+ {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF};
var MaxTeamHealth: LongInt;
GameOver: boolean;
@@ -247,6 +250,7 @@
Z:= cCurrHHZ;
State:= gstHHDriven;
Active:= true;
+ Power:= 0;
LastDamage:= nil
end;
RemoveGearFromList(Gear);
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uTouch.pas
--- a/hedgewars/uTouch.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uTouch.pas Sat Nov 03 00:34:35 2012 +0400
@@ -22,10 +22,11 @@
interface
-uses SysUtils, uConsole, uVariables, SDLh, uFloat, uConsts, uCommands, uIO, GLUnit, uTypes, uCaptions, uAmmos, uWorld, uMobile;
+uses SysUtils, uConsole, uVariables, SDLh, uFloat, uConsts, uCommands, GLUnit, uTypes, uCaptions, uAmmos, uWorld, uMobile;
procedure initModule;
+procedure freeModule;
procedure ProcessTouch;
procedure NewTurnBeginning;
@@ -643,5 +644,9 @@
halfRectSize:= rectSize shl 1;
end;
+procedure freeModule;
+begin
+end;
+
begin
end.
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uUtils.pas
--- a/hedgewars/uUtils.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uUtils.pas Sat Nov 03 00:34:35 2012 +0400
@@ -73,7 +73,7 @@
procedure WriteLn(var f: textfile; s: shortstring);
{$ENDIF}
-procedure initModule(isGame: boolean);
+procedure initModule(isNotPreview: boolean);
procedure freeModule;
@@ -401,14 +401,14 @@
end;
{$ENDIF}
-procedure initModule(isGame: boolean);
+procedure initModule(isNotPreview: boolean);
{$IFDEF DEBUGFILE}
var logfileBase: shortstring;
{$IFNDEF MOBILE}var i: LongInt;{$ENDIF}
{$ENDIF}
begin
{$IFDEF DEBUGFILE}
- if isGame then
+ if isNotPreview then
begin
if GameType = gmtRecord then
logfileBase:= 'rec'
@@ -422,7 +422,7 @@
{$ENDIF}
{$I-}
{$IFDEF MOBILE}
- {$IFDEF IPHONEOS} Assign(f,'../Documents/hw-' + logfileBase + '.log'); {$ENDIF}
+ {$IFDEF IPHONEOS} Assign(f, UserPathPrefix + '/hw-' + logfileBase + '.log'); {$ENDIF}
{$IFDEF ANDROID} Assign(f,pathPrefix + '/' + logfileBase + '.log'); {$ENDIF}
Rewrite(f);
{$ELSE}
@@ -450,8 +450,6 @@
procedure freeModule;
begin
-recordFileName:= '';
-
{$IFDEF DEBUGFILE}
writeln(f, 'halt at ' + inttostr(GameTicks) + ' ticks. TurnTimeLeft = ' + inttostr(TurnTimeLeft));
flush(f);
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uVariables.pas
--- a/hedgewars/uVariables.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uVariables.pas Sat Nov 03 00:34:35 2012 +0400
@@ -25,45 +25,44 @@
var
/////// init flags ///////
- cMinScreenWidth : LongInt = 640;
- cMinScreenHeight : LongInt = 480;
- cScreenWidth : LongInt = 1024;
- cScreenHeight : LongInt = 768;
- cOrigScreenWidth : LongInt = 1024;
- cOrigScreenHeight : LongInt = 768;
- cNewScreenWidth : LongInt = 1024;
- cNewScreenHeight : LongInt = 768;
- cScreenResizeDelay : LongWord = 0;
- cBits : LongInt = 32;
- ipcPort : Word = 0;
- cFullScreen : boolean = false;
- cLocaleFName : shortstring = 'en.txt';
- cLocale : shortstring = 'en';
- cTimerInterval : LongInt = 8;
- PathPrefix : shortstring = './';
- UserPathPrefix : shortstring = './';
- cShowFPS : boolean = false;
- cFlattenFlakes : boolean = false;
- cFlattenClouds : boolean = false;
- cAltDamage : boolean = true;
- cReducedQuality : LongWord = rqNone;
- UserNick : shortstring = '';
- recordFileName : shortstring = '';
- cReadyDelay : Longword = 5000;
- cStereoMode : TStereoMode = smNone;
- cOnlyStats : boolean = False;
+ cMinScreenWidth : LongInt;
+ cMinScreenHeight : LongInt;
+ cScreenWidth : LongInt;
+ cScreenHeight : LongInt;
+ cOrigScreenWidth : LongInt;
+ cOrigScreenHeight : LongInt;
+ cNewScreenWidth : LongInt;
+ cNewScreenHeight : LongInt;
+ cScreenResizeDelay : LongWord;
+ cBits : LongInt;
+ ipcPort : Word;
+ cFullScreen : boolean;
+ cLocaleFName : shortstring;
+ cLocale : shortstring;
+ cTimerInterval : LongInt;
+ PathPrefix : shortstring;
+ UserPathPrefix : shortstring;
+ cShowFPS : boolean;
+ cFlattenFlakes : boolean;
+ cFlattenClouds : boolean;
+ cAltDamage : boolean;
+ cReducedQuality : LongWord;
+ UserNick : shortstring;
+ recordFileName : shortstring;
+ cReadyDelay : Longword;
+ cStereoMode : TStereoMode;
+ cOnlyStats : boolean;
{$IFDEF USE_VIDEO_RECORDING}
- RecPrefix : shortstring;
- cAVFormat : shortstring;
- cVideoCodec : shortstring;
+ RecPrefix : shortstring;
+ cAVFormat : shortstring;
+ cVideoCodec : shortstring;
cVideoFramerateNum : LongInt;
cVideoFramerateDen : LongInt;
cVideoQuality : LongInt;
- cAudioCodec : shortstring;
+ cAudioCodec : shortstring;
{$ENDIF}
//////////////////////////
- cMapName : shortstring = '';
-
+ cMapName : shortstring;
isCursorVisible : boolean;
isInLag : boolean;
isPaused : boolean;
@@ -111,7 +110,7 @@
cWaterLine : Word;
cGearScrEdgesDist: LongInt;
- isAudioMuted : boolean;
+ isAudioMuted : boolean;
// originally typed consts
ExplosionBorderColor: LongWord;
@@ -2105,7 +2104,8 @@
Probability: 100;
NumberInCase: 1;
Ammo: (Propz: ammoprop_Power or
- ammoprop_NeedUpDown; //FIXME: enable multishoot at altuse, until then removed ammoprop_AltUse
+ ammoprop_AltUse or
+ ammoprop_NeedUpDown;
Count: 1;
NumPerTurn: 1;
Timer: 0;
@@ -2338,7 +2338,8 @@
Probability: 100;
NumberInCase: 1;
Ammo: (Propz: ammoprop_Power or
- ammoprop_NeedUpDown; //FIXME: enable multishoot at altuse, until then removed ammoprop_AltUse
+ ammoprop_AltUse or
+ ammoprop_NeedUpDown;
Count: 1;
NumPerTurn: 1;
Timer: 0;
@@ -2509,8 +2510,6 @@
vobSDVelocity, vobSDFallSpeed: LongInt;
hideAmmoMenu: boolean;
- wheelUp: boolean;
- wheelDown: boolean;
ControllerNumControllers: Integer;
ControllerEnabled: Integer;
@@ -2533,18 +2532,63 @@
trmsg: array[TMsgStrId] of ansistring; // message of the event
trgoal: array[TGoalStrId] of ansistring; // message of the goal
+procedure preInitModule;
procedure initModule;
procedure freeModule;
implementation
+procedure preInitModule;
+begin
+ // initialisation flags - they are going to be overwritten by program args
+
+ cScreenWidth := 1024;
+ cScreenHeight := 768;
+ cBits := 32;
+ cShowFPS := false;
+ cAltDamage := true;
+ cTimerInterval := 8;
+ cReducedQuality := rqNone;
+ cLocaleFName := 'en.txt';
+ cFullScreen := false;
+
+ UserPathPrefix := '';
+ ipcPort := 0;
+ UserNick := '';
+ cStereoMode := smNone;
+ GrayScale := false;
+ PathPrefix := './';
+ GameType := gmtLocal;
+
+{$IFDEF USE_VIDEO_RECORDING}
+ RecPrefix := '';
+ cAVFormat := '';
+ cVideoCodec := '';
+ cVideoFramerateNum := 0;
+ cVideoFramerateDen := 0;
+ cVideoQuality := 0;
+ cAudioCodec := '';
+{$ENDIF}
+end;
+
procedure initModule;
begin
- lastVisualGearByUID:= nil;
- lastGearByUID:= nil;
-
- Pathz:= cPathz;
+
+ if (Length(cLocaleFName) > 6) then
+ cLocale := Copy(cLocaleFName,1,5)
+ else
+ cLocale := Copy(cLocaleFName,1,2);
+
+ cFlattenFlakes := false;
+ cFlattenClouds := false;
+ cOnlyStats := False;
+ lastVisualGearByUID := nil;
+ lastGearByUID := nil;
+ recordFileName := '';
+ cReadyDelay := 5000;
+ Pathz := cPathz;
+
{* REFERENCE
4096 -> $FFFFF000
2048 -> $FFFFF800
@@ -2575,8 +2619,10 @@
SDWaterColorArray[2].a := 255;
SDWaterColorArray[1]:= SDWaterColorArray[0];
SDWaterColorArray[3]:= SDWaterColorArray[2];
-
+ SDWaterOpacity:= $80;
SDTint:= $80;
+ ExplosionBorderColor:= $FF808080;
+ WaterOpacity:= $80;
cDrownSpeed.QWordValue := 257698038; // 0.06
cDrownSpeedf := 0.06;
@@ -2626,7 +2672,6 @@
cExplosives := 2;
GameState := Low(TGameState);
-// GameType := gmtLocal;
zoom := cDefaultZoomLevel;
ZoomValue := cDefaultZoomLevel;
WeaponTooltipTex:= nil;
@@ -2653,7 +2698,6 @@
ReadyTimeLeft := 0;
disableLandBack := false;
-
ScreenFade := sfNone;
// those values still are not perfect
@@ -2673,11 +2717,17 @@
vobSDVelocity:= 15;
vobSDFallSpeed:= 250;
- ExplosionBorderColor:= $FF808080;
- WaterOpacity:= $80;
- SDWaterOpacity:= $80;
+ cMinScreenWidth:= min(cScreenWidth, 640);
+ cMinScreenHeight:= min(cScreenHeight, 480);
+ cOrigScreenWidth:= cScreenWidth;
+ cOrigScreenHeight:= cScreenHeight;
+
+ cNewScreenWidth := cScreenWidth;
+ cNewScreenHeight := cScreenHeight;
+ cScreenResizeDelay := 0;
LuaGoals:= '';
+ cMapName:= '';
LuaTemplateNumber:= 0;
hiddenHedgehogsNumber:=0;
@@ -2685,27 +2735,6 @@
procedure freeModule;
begin
- // re-init flags so they will always contain safe values
- cScreenWidth := 1024;
- cScreenHeight := 768;
- cBits := 32;
- ipcPort := 0;
- cFullScreen := false;
- cLocaleFName := 'en.txt';
- cTimerInterval := 8;
- PathPrefix := './';
- UserPathPrefix := './';
- cShowFPS := false;
- cFlattenFlakes := false;
- cFlattenClouds := false;
- cAltDamage := true;
- cReducedQuality := rqNone;
- UserNick := '';
- recordFileName := '';
- cScriptName := '';
- cReadyDelay := 5000;
- cStereoMode := smNone;
- GrayScale := false;
end;
end.
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uVideoRec.pas
--- a/hedgewars/uVideoRec.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uVideoRec.pas Sat Nov 03 00:34:35 2012 +0400
@@ -30,6 +30,11 @@
{$IFNDEF WIN32}
{$LINKLIB ../bin/libavwrapper.a}
{$ENDIF}
+{$IFDEF DARWIN}
+ {$LINKLIB bz2}
+ {$LINKFRAMEWORK CoreVideo}
+ {$LINKFRAMEWORK VideoDecodeAcceleration}
+{$ENDIF}
interface
@@ -44,6 +49,7 @@
procedure StopPreRecording;
procedure SaveCameraPosition;
+procedure initModule;
procedure freeModule;
implementation
@@ -96,23 +102,26 @@
// store some description in output file
desc:= '';
if UserNick <> '' then
- desc+= 'Player: ' + UserNick + #10;
+ desc:= desc + 'Player: ' + UserNick + #10;
if recordFileName <> '' then
- desc+= 'Record: ' + recordFileName + #10;
+ desc:= desc + 'Record: ' + recordFileName + #10;
if cMapName <> '' then
- desc+= 'Map: ' + cMapName + #10;
+ desc:= desc + 'Map: ' + cMapName + #10;
if Theme <> '' then
- desc+= 'Theme: ' + Theme + #10;
- desc+= 'prefix[' + RecPrefix + ']prefix';
- desc+= #0;
+ desc:= desc + 'Theme: ' + Theme + #10;
+ desc:= desc + 'prefix[' + RecPrefix + ']prefix';
+
+ filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix;
+ soundFilePath:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.sw';
- filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix + #0;
- soundFilePath:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.sw' + #0;
- cAVFormat+= #0;
- cAudioCodec+= #0;
- cVideoCodec+= #0;
- AVWrapper_Init(@AddFileLogRaw, @filename[1], @desc[1], @soundFilePath[1], @cAVFormat[1], @cVideoCodec[1], @cAudioCodec[1],
- cScreenWidth, cScreenHeight, cVideoFramerateNum, cVideoFramerateDen, cVideoQuality);
+ AVWrapper_Init(@AddFileLogRaw
+ , PChar(ansistring(filename))
+ , PChar(ansistring(desc))
+ , PChar(ansistring(soundFilePath))
+ , PChar(ansistring(cAVFormat))
+ , PChar(ansistring(cVideoCodec))
+ , PChar(ansistring(cAudioCodec))
+ , cScreenWidth, cScreenHeight, cVideoFramerateNum, cVideoFramerateDen, cVideoQuality);
numPixels:= cScreenWidth*cScreenHeight;
YCbCr_Planes[0]:= GetMem(numPixels);
@@ -358,6 +367,10 @@
BlockWrite(cameraFile, frame, 1);
end;
+procedure initModule;
+begin
+end;
+
procedure freeModule;
begin
if flagPrerecording then
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uVisualGears.pas
--- a/hedgewars/uVisualGears.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uVisualGears.pas Sat Nov 03 00:34:35 2012 +0400
@@ -987,10 +987,10 @@
else vg:= vg^.NextGear;
end;
if ((GameFlags and gfBorder) <> 0) or ((Theme <> 'Snow') and (Theme <> 'Christmas')) then
- for i:= 0 to Pred(vobSDCount * cScreenSpace div LAND_WIDTH) do
+ for i:= 0 to Pred(vobSDCount * cScreenSpace div 4096) do
AddVisualGear(cLeftScreenBorder + random(cScreenSpace), random(1024+200) - 100 + LAND_HEIGHT, vgtFlake)
else
- for i:= 0 to Pred((vobSDCount * cScreenSpace div LAND_WIDTH) div 3) do
+ for i:= 0 to Pred((vobSDCount * cScreenSpace div 4096) div 3) do
AddVisualGear(cLeftScreenBorder + random(cScreenSpace), random(1024+200) - 100 + LAND_HEIGHT, vgtFlake);
end;
diff -r 3331b30e4ef1 -r 88fde28bbda6 hedgewars/uWorld.pas
--- a/hedgewars/uWorld.pas Sun Oct 21 01:28:33 2012 +0400
+++ b/hedgewars/uWorld.pas Sat Nov 03 00:34:35 2012 +0400
@@ -629,11 +629,7 @@
Pos:= -1;
Slot:= -1;
{$IFDEF USE_LANDSCAPE_AMMOMENU}
- {$IFDEF USE_AM_NUMCOLUMN}
-c:= 0;
- {$ELSE}
c:= -1;
- {$ENDIF}
for i:= 0 to cMaxSlotIndex do
if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
begin
@@ -647,8 +643,8 @@
if (Ammo^[i, t].Count > 0) and (Ammo^[i, t].AmmoType <> amNothing) then
begin
if (CursorPoint.Y <= (cScreenHeight - AmmoRect.y) - ( g * (AMSlotSize+1))) and
- (CursorPoint.Y >= (cScreenHeight - AmmoRect.y) - ((g+1) * (AMSlotSize+1))) and
- (CursorPoint.X >= AmmoRect.x + ( c * (AMSlotSize+1))) and
+ (CursorPoint.Y > (cScreenHeight - AmmoRect.y) - ((g+1) * (AMSlotSize+1))) and
+ (CursorPoint.X > AmmoRect.x + ( c * (AMSlotSize+1))) and
(CursorPoint.X <= AmmoRect.x + ((c+1) * (AMSlotSize+1))) then
begin
Slot:= i;
@@ -663,11 +659,7 @@
end;
end;
{$ELSE}
- {$IFDEF USE_AM_NUMCOLUMN}
c:= -1;
- {$ELSE}
-c:= 0;
- {$ENDIF}
for i:= 0 to cMaxSlotIndex do
if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
begin
@@ -681,8 +673,8 @@
if (Ammo^[i, t].Count > 0) and (Ammo^[i, t].AmmoType <> amNothing) then
begin
if (CursorPoint.Y <= (cScreenHeight - AmmoRect.y) - ( c * (AMSlotSize+1))) and
- (CursorPoint.Y >= (cScreenHeight - AmmoRect.y) - ((c+1) * (AMSlotSize+1))) and
- (CursorPoint.X >= AmmoRect.x + ( g * (AMSlotSize+1))) and
+ (CursorPoint.Y > (cScreenHeight - AmmoRect.y) - ((c+1) * (AMSlotSize+1))) and
+ (CursorPoint.X > AmmoRect.x + ( g * (AMSlotSize+1))) and
(CursorPoint.X <= AmmoRect.x + ((g+1) * (AMSlotSize+1))) then
begin
Slot:= i;
@@ -1168,28 +1160,6 @@
DrawWater(255, 0);
-// Attack bar
- if CurrentTeam <> nil then
- case AttackBar of
-(* 1: begin
- r:= StuffPoz[sPowerBar];
- {$WARNINGS OFF}
- r.w:= (CurrentHedgehog^.Gear^.Power * 256) div cPowerDivisor;
- {$WARNINGS ON}
- DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface);
- end;*)
- 2: with CurrentHedgehog^ do
- begin
- tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle);
- tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle);
- for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do
- DrawSprite(sprPower,
- hwRound(Gear^.X) + GetLaunchX(CurAmmoType, hwSign(Gear^.dX), Gear^.Angle) + LongInt(round(WorldDx + tdx * (24 + i * 2))) - 16,
- hwRound(Gear^.Y) + GetLaunchY(CurAmmoType, Gear^.Angle) + LongInt(round(WorldDy + tdy * (24 + i * 2))) - 16,
- i)
- end
- end;
-
DrawVisualGears(1);
DrawGears;
DrawVisualGears(6);
@@ -1616,6 +1586,29 @@
SetScale(zoom);
+// Attack bar
+ if CurrentTeam <> nil then
+ case AttackBar of
+(* 1: begin
+ r:= StuffPoz[sPowerBar];
+ {$WARNINGS OFF}
+ r.w:= (CurrentHedgehog^.Gear^.Power * 256) div cPowerDivisor;
+ {$WARNINGS ON}
+ DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface);
+ end;*)
+ 2: with CurrentHedgehog^ do
+ begin
+ tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle);
+ tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle);
+ for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do
+ DrawSprite(sprPower,
+ hwRound(Gear^.X) + GetLaunchX(CurAmmoType, hwSign(Gear^.dX), Gear^.Angle) + LongInt(round(WorldDx + tdx * (24 + i * 2))) - 16,
+ hwRound(Gear^.Y) + GetLaunchY(CurAmmoType, Gear^.Angle) + LongInt(round(WorldDy + tdy * (24 + i * 2))) - 16,
+ i)
+ end
+ end;
+
+
// Cursor
if isCursorVisible then
begin
@@ -1640,7 +1633,7 @@
var PrevSentPointTime: LongWord = 0;
procedure MoveCamera;
-var EdgesDist, wdy, shs,z: LongInt;
+var EdgesDist, wdy, shs,z, amNumOffsetX, amNumOffsetY: LongInt;
begin
{$IFNDEF MOBILE}
if (not (CurrentTeam^.ExtDriven and isCursorVisible and (not bShowAmmoMenu))) and cHasFocus and (GameState <> gsConfirm) then
@@ -1672,14 +1665,30 @@
if (AMState = AMShowingUp) or (AMState = AMShowing) then
begin
- if CursorPoint.X < AmmoRect.x then//check left
- CursorPoint.X:= AmmoRect.x;
- if CursorPoint.X > AmmoRect.x + AmmoRect.w then//check right
- CursorPoint.X:= AmmoRect.x + AmmoRect.w;
- if CursorPoint.Y > cScreenHeight - AmmoRect.y then//check top
- CursorPoint.Y:= cScreenHeight - AmmoRect.y;
- if CursorPoint.Y < cScreenHeight - (AmmoRect.y + AmmoRect.h - AMSlotSize - 2) then//check bottom
- CursorPoint.Y:= cScreenHeight - (AmmoRect.y + AmmoRect.h - AMSlotSize - 2);
+{$IFDEF USE_LANDSCAPE_AMMOMENU}
+ amNumOffsetX:= 0;
+ {$IFDEF USE_AM_NUMCOLUMN}
+ amNumOffsetY:= AMSlotSize;
+ {$ELSE}
+ amNumOffsetY:= 0;
+ {$ENDIF}
+{$ELSE}
+ amNumOffsetY:= 0;
+ {$IFDEF USE_AM_NUMCOLUMN}
+ amNumOffsetX:= AMSlotSize;
+ {$ELSE}
+ amNumOffsetX:= 0;
+ {$ENDIF}
+
+{$ENDIF}
+ if CursorPoint.X < AmmoRect.x + amNumOffsetX + 3 then//check left
+ CursorPoint.X:= AmmoRect.x + amNumOffsetX + 3;
+ if CursorPoint.X > AmmoRect.x + AmmoRect.w - 3 then//check right
+ CursorPoint.X:= AmmoRect.x + AmmoRect.w - 3;
+ if CursorPoint.Y > cScreenHeight - AmmoRect.y -amNumOffsetY - 1 then//check top
+ CursorPoint.Y:= cScreenHeight - AmmoRect.y - amNumOffsetY - 1;
+ if CursorPoint.Y < cScreenHeight - (AmmoRect.y + AmmoRect.h - AMSlotSize - 5) then//check bottom
+ CursorPoint.Y:= cScreenHeight - (AmmoRect.y + AmmoRect.h - AMSlotSize - 5);
prevPoint:= CursorPoint;
//if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y);
exit
@@ -1793,6 +1802,10 @@
begin
if (not cHasFocus) and (GameState <> gsConfirm) then
ParseCommand('quit', true);
+{$IFDEF MOBILE}
+// when created SDL receives an exposure event that calls UndampenAudio at full power, muting audio
+exit;
+{$ENDIF}
{$IFDEF USE_VIDEO_RECORDING}
// do not change volume during prerecording as it will affect sound in video file
@@ -1880,19 +1893,12 @@
stereoDepth:= 0;
AMState:= AMHidden;
isFirstFrame:= true;
+ stereoDepth:= stereoDepth; // avoid hint
end;
procedure freeModule;
begin
- stereoDepth:= stereoDepth; // avoid hint
- FreeTexture(fpsTexture);
- fpsTexture:= nil;
- FreeTexture(timeTexture);
- timeTexture:= nil;
- FreeTexture(missionTex);
- missionTex:= nil;
- FreeTexture(recTexture);
- recTexture:= nil;
+ ResetWorldTex();
end;
end.
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/Android.mk
--- a/misc/libtremor/Android.mk Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/Android.mk Sat Nov 03 00:34:35 2012 +0400
@@ -7,12 +7,21 @@
LOCAL_CFLAGS := -I$(LOCAL_PATH) -DHAVE_ALLOCA_H
LOCAL_SRC_FILES = \
- tremor/bitwise.c tremor/info.c tremor/codebook.c \
- tremor/dsp.c tremor/mapping0.c \
- tremor/floor0.c tremor/mdct.c \
- tremor/floor1.c tremor/misc.c \
- tremor/floor_lookup.c tremor/res012.c \
- tremor/framing.c tremor/vorbisfile.c
+ tremor/bitwise.c \
+ tremor/block.c \
+ tremor/codebook.c \
+ tremor/floor0.c \
+ tremor/floor1.c \
+ tremor/framing.c \
+ tremor/info.c \
+ tremor/mapping0.c \
+ tremor/mdct.c \
+ tremor/registry.c \
+ tremor/res012.c \
+ tremor/sharedbook.c \
+ tremor/synthesis.c \
+ tremor/vorbisfile.c \
+ tremor/window.c
include $(BUILD_STATIC_LIBRARY)
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/README
--- a/misc/libtremor/README Sun Oct 21 01:28:33 2012 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-Tremor README
-
-[0] http://svn.xiph.org/trunk/Tremor/
-Original Tremor implementation, used in Hedgewars until the Tremor devteam branched the internal Ogg implementation.
-More details: http://lists.xiph.org/pipermail/tremor/2010-August/001650.html
-
-[1] http://svn.xiph.org/branches/lowmem-no-byte/Tremor/
-A Tremor variant, suited for low memory devices, still contains an Ogg implementation, used in Hedgewars.
-
-[2] http://svn.xiph.org/branches/lowmem-branch/Tremolo/
-An interesting Tremor variant with a lot of ARM optimisations.
-
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/Xcode/Tremor.xcodeproj/project.pbxproj
--- a/misc/libtremor/Xcode/Tremor.xcodeproj/project.pbxproj Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/Xcode/Tremor.xcodeproj/project.pbxproj Sat Nov 03 00:34:35 2012 +0400
@@ -8,7 +8,10 @@
/* Begin PBXBuildFile section */
61DB1809148BA9A9004A67B8 /* asm_arm.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17E7148BA9A9004A67B8 /* asm_arm.h */; };
+ 61DB180A148BA9A9004A67B8 /* backends.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17E8148BA9A9004A67B8 /* backends.h */; };
61DB180B148BA9A9004A67B8 /* bitwise.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB17E9148BA9A9004A67B8 /* bitwise.c */; };
+ 61DB180C148BA9A9004A67B8 /* block.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB17EA148BA9A9004A67B8 /* block.c */; };
+ 61DB180D148BA9A9004A67B8 /* block.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17EB148BA9A9004A67B8 /* block.h */; };
61DB180E148BA9A9004A67B8 /* codebook.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB17EC148BA9A9004A67B8 /* codebook.c */; };
61DB180F148BA9A9004A67B8 /* codebook.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17ED148BA9A9004A67B8 /* codebook.h */; };
61DB1810148BA9A9004A67B8 /* codec_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17EE148BA9A9004A67B8 /* codec_internal.h */; };
@@ -28,19 +31,25 @@
61DB181F148BA9A9004A67B8 /* ogg.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17FD148BA9A9004A67B8 /* ogg.h */; };
61DB1820148BA9A9004A67B8 /* os_types.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17FE148BA9A9004A67B8 /* os_types.h */; };
61DB1821148BA9A9004A67B8 /* os.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17FF148BA9A9004A67B8 /* os.h */; };
+ 61DB1822148BA9A9004A67B8 /* registry.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB1800148BA9A9004A67B8 /* registry.c */; };
+ 61DB1823148BA9A9004A67B8 /* registry.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB1801148BA9A9004A67B8 /* registry.h */; };
61DB1824148BA9A9004A67B8 /* res012.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB1802148BA9A9004A67B8 /* res012.c */; };
+ 61DB1825148BA9A9004A67B8 /* sharedbook.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB1803148BA9A9004A67B8 /* sharedbook.c */; };
+ 61DB1826148BA9A9004A67B8 /* synthesis.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB1804148BA9A9004A67B8 /* synthesis.c */; };
61DB1827148BA9A9004A67B8 /* vorbisfile.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB1805148BA9A9004A67B8 /* vorbisfile.c */; };
61DB1828148BA9A9004A67B8 /* window_lookup.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB1806148BA9A9004A67B8 /* window_lookup.h */; };
- 61E1A173160BCA4F002370D0 /* dsp.c in Sources */ = {isa = PBXBuildFile; fileRef = 61E1A170160BCA4F002370D0 /* dsp.c */; };
- 61E1A174160BCA4F002370D0 /* floor_lookup.c in Sources */ = {isa = PBXBuildFile; fileRef = 61E1A171160BCA4F002370D0 /* floor_lookup.c */; };
- 61E1A175160BCA4F002370D0 /* misc.c in Sources */ = {isa = PBXBuildFile; fileRef = 61E1A172160BCA4F002370D0 /* misc.c */; };
+ 61DB1829148BA9A9004A67B8 /* window.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB1807148BA9A9004A67B8 /* window.c */; };
+ 61DB182A148BA9A9004A67B8 /* window.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB1808148BA9A9004A67B8 /* window.h */; };
AA747D9F0F9514B9006C5449 /* Tremor_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* Tremor_Prefix.pch */; };
AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
61DB17E7148BA9A9004A67B8 /* asm_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = asm_arm.h; path = ../tremor/asm_arm.h; sourceTree = SOURCE_ROOT; };
+ 61DB17E8148BA9A9004A67B8 /* backends.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = backends.h; path = ../tremor/backends.h; sourceTree = SOURCE_ROOT; };
61DB17E9148BA9A9004A67B8 /* bitwise.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = bitwise.c; path = ../tremor/bitwise.c; sourceTree = SOURCE_ROOT; };
+ 61DB17EA148BA9A9004A67B8 /* block.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = block.c; path = ../tremor/block.c; sourceTree = SOURCE_ROOT; };
+ 61DB17EB148BA9A9004A67B8 /* block.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = block.h; path = ../tremor/block.h; sourceTree = SOURCE_ROOT; };
61DB17EC148BA9A9004A67B8 /* codebook.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = codebook.c; path = ../tremor/codebook.c; sourceTree = SOURCE_ROOT; };
61DB17ED148BA9A9004A67B8 /* codebook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = codebook.h; path = ../tremor/codebook.h; sourceTree = SOURCE_ROOT; };
61DB17EE148BA9A9004A67B8 /* codec_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = codec_internal.h; path = ../tremor/codec_internal.h; sourceTree = SOURCE_ROOT; };
@@ -60,12 +69,15 @@
61DB17FD148BA9A9004A67B8 /* ogg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ogg.h; path = ../tremor/ogg.h; sourceTree = SOURCE_ROOT; };
61DB17FE148BA9A9004A67B8 /* os_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = os_types.h; path = ../tremor/os_types.h; sourceTree = SOURCE_ROOT; };
61DB17FF148BA9A9004A67B8 /* os.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = os.h; path = ../tremor/os.h; sourceTree = SOURCE_ROOT; };
+ 61DB1800148BA9A9004A67B8 /* registry.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = registry.c; path = ../tremor/registry.c; sourceTree = SOURCE_ROOT; };
+ 61DB1801148BA9A9004A67B8 /* registry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = registry.h; path = ../tremor/registry.h; sourceTree = SOURCE_ROOT; };
61DB1802148BA9A9004A67B8 /* res012.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = res012.c; path = ../tremor/res012.c; sourceTree = SOURCE_ROOT; };
+ 61DB1803148BA9A9004A67B8 /* sharedbook.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sharedbook.c; path = ../tremor/sharedbook.c; sourceTree = SOURCE_ROOT; };
+ 61DB1804148BA9A9004A67B8 /* synthesis.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = synthesis.c; path = ../tremor/synthesis.c; sourceTree = SOURCE_ROOT; };
61DB1805148BA9A9004A67B8 /* vorbisfile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = vorbisfile.c; path = ../tremor/vorbisfile.c; sourceTree = SOURCE_ROOT; };
61DB1806148BA9A9004A67B8 /* window_lookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = window_lookup.h; path = ../tremor/window_lookup.h; sourceTree = SOURCE_ROOT; };
- 61E1A170160BCA4F002370D0 /* dsp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = dsp.c; path = ../tremor/dsp.c; sourceTree = SOURCE_ROOT; };
- 61E1A171160BCA4F002370D0 /* floor_lookup.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = floor_lookup.c; path = ../tremor/floor_lookup.c; sourceTree = SOURCE_ROOT; };
- 61E1A172160BCA4F002370D0 /* misc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = misc.c; path = ../tremor/misc.c; sourceTree = SOURCE_ROOT; };
+ 61DB1807148BA9A9004A67B8 /* window.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = window.c; path = ../tremor/window.c; sourceTree = SOURCE_ROOT; };
+ 61DB1808148BA9A9004A67B8 /* window.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = window.h; path = ../tremor/window.h; sourceTree = SOURCE_ROOT; };
AA747D9E0F9514B9006C5449 /* Tremor_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Tremor_Prefix.pch; sourceTree = SOURCE_ROOT; };
AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
D2AAC07E0554694100DB518D /* libTremor.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libTremor.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -113,11 +125,11 @@
08FB77AEFE84172EC02AAC07 /* Sources */ = {
isa = PBXGroup;
children = (
- 61E1A170160BCA4F002370D0 /* dsp.c */,
- 61E1A171160BCA4F002370D0 /* floor_lookup.c */,
- 61E1A172160BCA4F002370D0 /* misc.c */,
61DB17E7148BA9A9004A67B8 /* asm_arm.h */,
+ 61DB17E8148BA9A9004A67B8 /* backends.h */,
61DB17E9148BA9A9004A67B8 /* bitwise.c */,
+ 61DB17EA148BA9A9004A67B8 /* block.c */,
+ 61DB17EB148BA9A9004A67B8 /* block.h */,
61DB17EC148BA9A9004A67B8 /* codebook.c */,
61DB17ED148BA9A9004A67B8 /* codebook.h */,
61DB17EE148BA9A9004A67B8 /* codec_internal.h */,
@@ -137,9 +149,15 @@
61DB17FD148BA9A9004A67B8 /* ogg.h */,
61DB17FE148BA9A9004A67B8 /* os_types.h */,
61DB17FF148BA9A9004A67B8 /* os.h */,
+ 61DB1800148BA9A9004A67B8 /* registry.c */,
+ 61DB1801148BA9A9004A67B8 /* registry.h */,
61DB1802148BA9A9004A67B8 /* res012.c */,
+ 61DB1803148BA9A9004A67B8 /* sharedbook.c */,
+ 61DB1804148BA9A9004A67B8 /* synthesis.c */,
61DB1805148BA9A9004A67B8 /* vorbisfile.c */,
61DB1806148BA9A9004A67B8 /* window_lookup.h */,
+ 61DB1807148BA9A9004A67B8 /* window.c */,
+ 61DB1808148BA9A9004A67B8 /* window.h */,
);
name = Sources;
sourceTree = "";
@@ -161,6 +179,8 @@
files = (
AA747D9F0F9514B9006C5449 /* Tremor_Prefix.pch in Headers */,
61DB1809148BA9A9004A67B8 /* asm_arm.h in Headers */,
+ 61DB180A148BA9A9004A67B8 /* backends.h in Headers */,
+ 61DB180D148BA9A9004A67B8 /* block.h in Headers */,
61DB180F148BA9A9004A67B8 /* codebook.h in Headers */,
61DB1810148BA9A9004A67B8 /* codec_internal.h in Headers */,
61DB1811148BA9A9004A67B8 /* config_types.h in Headers */,
@@ -173,7 +193,9 @@
61DB181F148BA9A9004A67B8 /* ogg.h in Headers */,
61DB1820148BA9A9004A67B8 /* os_types.h in Headers */,
61DB1821148BA9A9004A67B8 /* os.h in Headers */,
+ 61DB1823148BA9A9004A67B8 /* registry.h in Headers */,
61DB1828148BA9A9004A67B8 /* window_lookup.h in Headers */,
+ 61DB182A148BA9A9004A67B8 /* window.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -228,6 +250,7 @@
buildActionMask = 2147483647;
files = (
61DB180B148BA9A9004A67B8 /* bitwise.c in Sources */,
+ 61DB180C148BA9A9004A67B8 /* block.c in Sources */,
61DB180E148BA9A9004A67B8 /* codebook.c in Sources */,
61DB1812148BA9A9004A67B8 /* floor0.c in Sources */,
61DB1813148BA9A9004A67B8 /* floor1.c in Sources */,
@@ -235,11 +258,12 @@
61DB1815148BA9A9004A67B8 /* info.c in Sources */,
61DB181A148BA9A9004A67B8 /* mapping0.c in Sources */,
61DB181C148BA9A9004A67B8 /* mdct.c in Sources */,
+ 61DB1822148BA9A9004A67B8 /* registry.c in Sources */,
61DB1824148BA9A9004A67B8 /* res012.c in Sources */,
+ 61DB1825148BA9A9004A67B8 /* sharedbook.c in Sources */,
+ 61DB1826148BA9A9004A67B8 /* synthesis.c in Sources */,
61DB1827148BA9A9004A67B8 /* vorbisfile.c in Sources */,
- 61E1A173160BCA4F002370D0 /* dsp.c in Sources */,
- 61E1A174160BCA4F002370D0 /* floor_lookup.c in Sources */,
- 61E1A175160BCA4F002370D0 /* misc.c in Sources */,
+ 61DB1829148BA9A9004A67B8 /* window.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/Makefile.am
--- a/misc/libtremor/tremor/Makefile.am Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/Makefile.am Sat Nov 03 00:34:35 2012 +0400
@@ -2,19 +2,17 @@
INCLUDES = -I./
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = vorbisidec.pc
-
lib_LTLIBRARIES = libvorbisidec.la
-libvorbisidec_la_SOURCES = mdct.c dsp.c info.c misc.c \
+libvorbisidec_la_SOURCES = mdct.c block.c window.c \
+ synthesis.c info.c \
floor1.c floor0.c vorbisfile.c \
- res012.c mapping0.c codebook.c \
- framing.c bitwise.c \
+ res012.c mapping0.c registry.c codebook.c \
+ sharedbook.c framing.c bitwise.c \
codebook.h misc.h mdct_lookup.h\
- os.h mdct.h ivorbisfile.h lsp_lookup.h\
- window_lookup.h floor_lookup.c \
- codec_internal.h ogg.h \
+ os.h mdct.h block.h ivorbisfile.h lsp_lookup.h\
+ registry.h window.h window_lookup.h\
+ codec_internal.h backends.h ogg.h \
asm_arm.h ivorbiscodec.h
libvorbisidec_la_LDFLAGS = -version-info @V_LIB_CURRENT@:@V_LIB_REVISION@:@V_LIB_AGE@
@@ -29,8 +27,6 @@
include_HEADERS = ivorbiscodec.h ivorbisfile.h ogg.h os_types.h config_types.h
-EXTRA_DIST = vorbisidec.pc.in
-
example:
-ln -fs . vorbis
$(MAKE) ivorbisfile_example
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/autogen.sh
--- a/misc/libtremor/tremor/autogen.sh Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/autogen.sh Sat Nov 03 00:34:35 2012 +0400
@@ -2,14 +2,16 @@
# Run this to set up the build system: configure, makefiles, etc.
# (based on the version in enlightenment's cvs)
-package="vorbisidec"
+package="vorbisdec"
+olddir=`pwd`
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
cd "$srcdir"
DIE=0
+echo "checking for autoconf... "
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have autoconf installed to compile $package."
@@ -18,16 +20,72 @@
DIE=1
}
-(automake --version) < /dev/null > /dev/null 2>&1 || {
+VERSIONGREP="sed -e s/.*[^0-9\.]\([0-9]\.[0-9]\).*/\1/"
+VERSIONMKINT="sed -e s/[^0-9]//"
+
+# do we need automake?
+if test -r Makefile.am; then
+ AM_OPTIONS=`fgrep AUTOMAKE_OPTIONS Makefile.am`
+ AM_NEEDED=`echo $AM_OPTIONS | $VERSIONGREP`
+ if test x"$AM_NEEDED" = "x$AM_OPTIONS"; then
+ AM_NEEDED=""
+ fi
+ if test -z $AM_NEEDED; then
+ echo -n "checking for automake... "
+ AUTOMAKE=automake
+ ACLOCAL=aclocal
+ if ($AUTOMAKE --version < /dev/null > /dev/null 2>&1); then
+ echo "yes"
+ else
+ echo "no"
+ AUTOMAKE=
+ fi
+ else
+ echo -n "checking for automake $AM_NEEDED or later... "
+ for am in automake-$AM_NEEDED automake$AM_NEEDED automake; do
+ ($am --version < /dev/null > /dev/null 2>&1) || continue
+ ver=`$am --version < /dev/null | head -n 1 | $VERSIONGREP | $VERSIONMKINT`
+ verneeded=`echo $AM_NEEDED | $VERSIONMKINT`
+ if test $ver -ge $verneeded; then
+ AUTOMAKE=$am
+ echo $AUTOMAKE
+ break
+ fi
+ done
+ test -z $AUTOMAKE && echo "no"
+ echo -n "checking for aclocal $AM_NEEDED or later... "
+ for ac in aclocal-$AM_NEEDED aclocal$AM_NEEDED aclocal; do
+ ($ac --version < /dev/null > /dev/null 2>&1) || continue
+ ver=`$ac --version < /dev/null | head -n 1 | $VERSIONGREP | $VERSIONMKINT`
+ verneeded=`echo $AM_NEEDED | $VERSIONMKINT`
+ if test $ver -ge $verneeded; then
+ ACLOCAL=$ac
+ echo $ACLOCAL
+ break
+ fi
+ done
+ test -z $ACLOCAL && echo "no"
+ fi
+ test -z $AUTOMAKE || test -z $ACLOCAL && {
echo
echo "You must have automake installed to compile $package."
- echo "Download the appropriate package for your system,"
- echo "or get the source from one of the GNU ftp sites"
- echo "listed in http://www.gnu.org/order/ftp.html"
- DIE=1
-}
+ echo "Download the appropriate package for your distribution,"
+ echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
+ exit 1
+ }
+fi
-(libtool --version) < /dev/null > /dev/null 2>&1 || {
+echo -n "checking for libtool... "
+for LIBTOOLIZE in libtoolize glibtoolize nope; do
+ ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 && break
+done
+if test x$LIBTOOLIZE = xnope; then
+ echo "nope."
+ LIBTOOLIZE=libtoolize
+else
+ echo $LIBTOOLIZE
+fi
+($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have libtool installed to compile $package."
echo "Download the appropriate package for your system,"
@@ -47,15 +105,16 @@
echo "Generating configuration files for $package, please wait...."
-echo " aclocal $ACLOCAL_FLAGS"
-aclocal $ACLOCAL_FLAGS || exit 1
+echo " $ACLOCAL $ACLOCAL_FLAGS"
+$ACLOCAL $ACLOCAL_FLAGS || exit 1
+echo " $LIBTOOLIZE --automake"
+$LIBTOOLIZE --automake || exit 1
echo " autoheader"
autoheader || exit 1
-echo " libtoolize --automake"
-libtoolize --automake || exit 1
-echo " automake --add-missing $AUTOMAKE_FLAGS"
-automake --add-missing $AUTOMAKE_FLAGS || exit 1
+echo " $AUTOMAKE --add-missing $AUTOMAKE_FLAGS"
+$AUTOMAKE --add-missing $AUTOMAKE_FLAGS || exit 1
echo " autoconf"
autoconf || exit 1
-$srcdir/configure "$@" && echo
+cd $olddir
+$srcdir/configure --enable-maintainer-mode "$@" && echo
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/bitwise.c
--- a/misc/libtremor/tremor/bitwise.c Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/bitwise.c Sat Nov 03 00:34:35 2012 +0400
@@ -20,7 +20,6 @@
#include
#include
-#include "misc.h"
#include "ogg.h"
static unsigned long mask[]=
@@ -48,8 +47,8 @@
if(b->head->next){
b->count+=b->head->length;
b->head=b->head->next;
- b->headptr=b->head->buffer->data+b->head->begin-b->headend;
- b->headend+=b->head->length;
+ b->headptr=b->head->buffer->data+b->head->begin-b->headend;
+ b->headend+=b->head->length;
}else{
/* we've either met the end of decode, or gone past it. halt
only if we're past */
@@ -82,7 +81,7 @@
/* Read in bits without advancing the bitptr; bits <= 32 */
long oggpack_look(oggpack_buffer *b,int bits){
unsigned long m=mask[bits];
- unsigned long ret;
+ unsigned long ret=-1;
bits+=b->headbit;
@@ -92,22 +91,22 @@
ogg_reference *head=b->head;
if(end<0)return -1;
-
+
if(bits){
_lookspan();
ret=*ptr++>>b->headbit;
if(bits>8){
--end;
_lookspan();
- ret|=*ptr++<<(8-b->headbit);
+ ret|=*ptr++<<(8-b->headbit);
if(bits>16){
--end;
_lookspan();
- ret|=*ptr++<<(16-b->headbit);
+ ret|=*ptr++<<(16-b->headbit);
if(bits>24){
--end;
_lookspan();
- ret|=*ptr++<<(24-b->headbit);
+ ret|=*ptr++<<(24-b->headbit);
if(bits>32 && b->headbit){
--end;
_lookspan();
@@ -147,6 +146,27 @@
if((b->headend-=bits/8)<1)_span(b);
}
+/* spans forward and finds next byte. Never halts */
+static void _span_one(oggpack_buffer *b){
+ while(b->headend<1){
+ if(b->head->next){
+ b->count+=b->head->length;
+ b->head=b->head->next;
+ b->headptr=b->head->buffer->data+b->head->begin;
+ b->headend=b->head->length;
+ }else
+ break;
+ }
+}
+
+static int _halt_one(oggpack_buffer *b){
+ if(b->headend<1){
+ _adv_halt(b);
+ return -1;
+ }
+ return 0;
+}
+
int oggpack_eop(oggpack_buffer *b){
if(b->headend<0)return -1;
return 0;
@@ -154,9 +174,83 @@
/* bits <= 32 */
long oggpack_read(oggpack_buffer *b,int bits){
- long ret=oggpack_look(b,bits);
- oggpack_adv(b,bits);
- return(ret);
+ unsigned long m=mask[bits];
+ ogg_uint32_t ret=-1;
+
+ bits+=b->headbit;
+
+ if(bits >= b->headend<<3){
+
+ if(b->headend<0)return -1;
+
+ if(bits){
+ if (_halt_one(b)) return -1;
+ ret=*b->headptr>>b->headbit;
+
+ if(bits>=8){
+ ++b->headptr;
+ --b->headend;
+ _span_one(b);
+ if(bits>8){
+ if (_halt_one(b)) return -1;
+ ret|=*b->headptr<<(8-b->headbit);
+
+ if(bits>=16){
+ ++b->headptr;
+ --b->headend;
+ _span_one(b);
+ if(bits>16){
+ if (_halt_one(b)) return -1;
+ ret|=*b->headptr<<(16-b->headbit);
+
+ if(bits>=24){
+ ++b->headptr;
+ --b->headend;
+ _span_one(b);
+ if(bits>24){
+ if (_halt_one(b)) return -1;
+ ret|=*b->headptr<<(24-b->headbit);
+
+ if(bits>=32){
+ ++b->headptr;
+ --b->headend;
+ _span_one(b);
+ if(bits>32){
+ if (_halt_one(b)) return -1;
+ if(b->headbit)ret|=*b->headptr<<(32-b->headbit);
+
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }else{
+
+ ret=b->headptr[0]>>b->headbit;
+ if(bits>8){
+ ret|=b->headptr[1]<<(8-b->headbit);
+ if(bits>16){
+ ret|=b->headptr[2]<<(16-b->headbit);
+ if(bits>24){
+ ret|=b->headptr[3]<<(24-b->headbit);
+ if(bits>32 && b->headbit){
+ ret|=b->headptr[4]<<(32-b->headbit);
+ }
+ }
+ }
+ }
+
+ b->headptr+=bits/8;
+ b->headend-=bits/8;
+ }
+
+ ret&=m;
+ b->headbit=bits&7;
+ return ret;
}
long oggpack_bytes(oggpack_buffer *b){
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/codebook.c
--- a/misc/libtremor/tremor/codebook.c Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/codebook.c Sat Nov 03 00:34:35 2012 +0400
@@ -22,324 +22,11 @@
#include "ivorbiscodec.h"
#include "codebook.h"
#include "misc.h"
-#include "os.h"
-
-/**** pack/unpack helpers ******************************************/
-int _ilog(unsigned int v){
- int ret=0;
- while(v){
- ret++;
- v>>=1;
- }
- return(ret);
-}
-
-static ogg_uint32_t decpack(long entry,long used_entry,long quantvals,
- codebook *b,oggpack_buffer *opb,int maptype){
- ogg_uint32_t ret=0;
- int j;
-
- switch(b->dec_type){
-
- case 0:
- return (ogg_uint32_t)entry;
-
- case 1:
- if(maptype==1){
- /* vals are already read into temporary colum vector here */
- for(j=0;jdim;j++){
- ogg_uint32_t off=entry%quantvals;
- entry/=quantvals;
- ret|=((ogg_uint16_t *)(b->q_val))[off]<<(b->q_bits*j);
- }
- }else{
- for(j=0;jdim;j++)
- ret|=oggpack_read(opb,b->q_bits)<<(b->q_bits*j);
- }
- return ret;
-
- case 2:
- for(j=0;jdim;j++){
- ogg_uint32_t off=entry%quantvals;
- entry/=quantvals;
- ret|=off<<(b->q_pack*j);
- }
- return ret;
-
- case 3:
- return (ogg_uint32_t)used_entry;
-
- }
-}
-
-/* 32 bit float (not IEEE; nonnormalized mantissa +
- biased exponent) : neeeeeee eeemmmmm mmmmmmmm mmmmmmmm
- Why not IEEE? It's just not that important here. */
-
-static ogg_int32_t _float32_unpack(long val,int *point){
- long mant=val&0x1fffff;
- int sign=val&0x80000000;
-
- *point=((val&0x7fe00000L)>>21)-788;
-
- if(mant){
- while(!(mant&0x40000000)){
- mant<<=1;
- *point-=1;
- }
- if(sign)mant= -mant;
- }else{
- *point=-9999;
- }
- return mant;
-}
-
-/* choose the smallest supported node size that fits our decode table.
- Legal bytewidths are 1/1 1/2 2/2 2/4 4/4 */
-static int _determine_node_bytes(long used, int leafwidth){
-
- /* special case small books to size 4 to avoid multiple special
- cases in repack */
- if(used<2)
- return 4;
-
- if(leafwidth==3)leafwidth=4;
- if(_ilog(3*used-6)+1 <= leafwidth*4)
- return leafwidth/2?leafwidth/2:1;
- return leafwidth;
-}
-
-/* convenience/clarity; leaves are specified as multiple of node word
- size (1 or 2) */
-static int _determine_leaf_words(int nodeb, int leafwidth){
- if(leafwidth>nodeb)return 2;
- return 1;
-}
-
-/* given a list of word lengths, number of used entries, and byte
- width of a leaf, generate the decode table */
-static int _make_words(char *l,long n,ogg_uint32_t *r,long quantvals,
- codebook *b, oggpack_buffer *opb,int maptype){
- long i,j,count=0;
- long top=0;
- ogg_uint32_t marker[33];
-
- if(n<2){
- r[0]=0x80000000;
- }else{
- memset(marker,0,sizeof(marker));
-
- for(i=0;i>(length-j-1))&1;
- if(chase>=top){
- top++;
- r[chase*2]=top;
- r[chase*2+1]=0;
- }else
- if(!r[chase*2+bit])
- r[chase*2+bit]=top;
- chase=r[chase*2+bit];
- }
- {
- int bit=(entry>>(length-j-1))&1;
- if(chase>=top){
- top++;
- r[chase*2+1]=0;
- }
- r[chase*2+bit]= decpack(i,count++,quantvals,b,opb,maptype) |
- 0x80000000;
- }
-
- /* Look to see if the next shorter marker points to the node
- above. if so, update it and repeat. */
- for(j=length;j>0;j--){
- if(marker[j]&1){
- marker[j]=marker[j-1]<<1;
- break;
- }
- marker[j]++;
- }
-
- /* prune the tree; the implicit invariant says all the longer
- markers were dangling from our just-taken node. Dangle them
- from our *new* node. */
- for(j=length+1;j<33;j++)
- if((marker[j]>>1) == entry){
- entry=marker[j];
- marker[j]=marker[j-1]<<1;
- }else
- break;
- }
- }
- }
-
- return 0;
-}
-
-static int _make_decode_table(codebook *s,char *lengthlist,long quantvals,
- oggpack_buffer *opb,int maptype){
- int i;
- ogg_uint32_t *work;
-
- if(s->dec_nodeb==4){
- s->dec_table=_ogg_malloc((s->used_entries*2+1)*sizeof(*work));
- /* +1 (rather than -2) is to accommodate 0 and 1 sized books,
- which are specialcased to nodeb==4 */
- if(_make_words(lengthlist,s->entries,
- s->dec_table,quantvals,s,opb,maptype))return 1;
-
- return 0;
- }
-
- work=alloca((s->used_entries*2-2)*sizeof(*work));
- if(_make_words(lengthlist,s->entries,work,quantvals,s,opb,maptype))return 1;
- s->dec_table=_ogg_malloc((s->used_entries*(s->dec_leafw+1)-2)*
- s->dec_nodeb);
-
- if(s->dec_leafw==1){
- switch(s->dec_nodeb){
- case 1:
- for(i=0;iused_entries*2-2;i++)
- ((unsigned char *)s->dec_table)[i]=
- ((work[i] & 0x80000000UL) >> 24) | work[i];
- break;
- case 2:
- for(i=0;iused_entries*2-2;i++)
- ((ogg_uint16_t *)s->dec_table)[i]=
- ((work[i] & 0x80000000UL) >> 16) | work[i];
- break;
- }
-
- }else{
- /* more complex; we have to do a two-pass repack that updates the
- node indexing. */
- long top=s->used_entries*3-2;
- if(s->dec_nodeb==1){
- unsigned char *out=(unsigned char *)s->dec_table;
-
- for(i=s->used_entries*2-4;i>=0;i-=2){
- if(work[i]&0x80000000UL){
- if(work[i+1]&0x80000000UL){
- top-=4;
- out[top]=(work[i]>>8 & 0x7f)|0x80;
- out[top+1]=(work[i+1]>>8 & 0x7f)|0x80;
- out[top+2]=work[i] & 0xff;
- out[top+3]=work[i+1] & 0xff;
- }else{
- top-=3;
- out[top]=(work[i]>>8 & 0x7f)|0x80;
- out[top+1]=work[work[i+1]*2];
- out[top+2]=work[i] & 0xff;
- }
- }else{
- if(work[i+1]&0x80000000UL){
- top-=3;
- out[top]=work[work[i]*2];
- out[top+1]=(work[i+1]>>8 & 0x7f)|0x80;
- out[top+2]=work[i+1] & 0xff;
- }else{
- top-=2;
- out[top]=work[work[i]*2];
- out[top+1]=work[work[i+1]*2];
- }
- }
- work[i]=top;
- }
- }else{
- ogg_uint16_t *out=(ogg_uint16_t *)s->dec_table;
- for(i=s->used_entries*2-4;i>=0;i-=2){
- if(work[i]&0x80000000UL){
- if(work[i+1]&0x80000000UL){
- top-=4;
- out[top]=(work[i]>>16 & 0x7fff)|0x8000;
- out[top+1]=(work[i+1]>>16 & 0x7fff)|0x8000;
- out[top+2]=work[i] & 0xffff;
- out[top+3]=work[i+1] & 0xffff;
- }else{
- top-=3;
- out[top]=(work[i]>>16 & 0x7fff)|0x8000;
- out[top+1]=work[work[i+1]*2];
- out[top+2]=work[i] & 0xffff;
- }
- }else{
- if(work[i+1]&0x80000000UL){
- top-=3;
- out[top]=work[work[i]*2];
- out[top+1]=(work[i+1]>>16 & 0x7fff)|0x8000;
- out[top+2]=work[i+1] & 0xffff;
- }else{
- top-=2;
- out[top]=work[work[i]*2];
- out[top+1]=work[work[i+1]*2];
- }
- }
- work[i]=top;
- }
- }
- }
-
- return 0;
-}
-
-/* most of the time, entries%dimensions == 0, but we need to be
- well defined. We define that the possible vales at each
- scalar is values == entries/dim. If entries%dim != 0, we'll
- have 'too few' values (values*dimentries);
- int vals=b->entries>>((bits-1)*(b->dim-1)/b->dim);
-
- while(1){
- long acc=1;
- long acc1=1;
- int i;
- for(i=0;idim;i++){
- acc*=vals;
- acc1*=vals+1;
- }
- if(acc<=b->entries && acc1>b->entries){
- return(vals);
- }else{
- if(acc>b->entries){
- vals--;
- }else{
- vals++;
- }
- }
- }
-}
-
-void vorbis_book_clear(codebook *b){
- /* static book is not cleared; we're likely called on the lookup and
- the static codebook belongs to the info struct */
- if(b->q_val)_ogg_free(b->q_val);
- if(b->dec_table)_ogg_free(b->dec_table);
-
- memset(b,0,sizeof(*b));
-}
-
-int vorbis_book_unpack(oggpack_buffer *opb,codebook *s){
- char *lengthlist=NULL;
- int quantvals=0;
- long i,j,k;
- int maptype;
-
+/* unpacks a codebook from the packet buffer into the codebook struct,
+ readies the codebook auxiliary structures for decode *************/
+int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
+ long i,j;
memset(s,0,sizeof(*s));
/* make sure alignment is correct */
@@ -354,7 +41,7 @@
switch((int)oggpack_read(opb,1)){
case 0:
/* unordered */
- lengthlist=(char *)alloca(sizeof(*lengthlist)*s->entries);
+ s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
/* allocated but unused entries? */
if(oggpack_read(opb,1)){
@@ -364,20 +51,16 @@
if(oggpack_read(opb,1)){
long num=oggpack_read(opb,5);
if(num==-1)goto _eofout;
- lengthlist[i]=num+1;
- s->used_entries++;
- if(num+1>s->dec_maxlength)s->dec_maxlength=num+1;
+ s->lengthlist[i]=num+1;
}else
- lengthlist[i]=0;
+ s->lengthlist[i]=0;
}
}else{
/* all entries used; no tagging */
- s->used_entries=s->entries;
for(i=0;ientries;i++){
long num=oggpack_read(opb,5);
if(num==-1)goto _eofout;
- lengthlist[i]=num+1;
- if(num+1>s->dec_maxlength)s->dec_maxlength=num+1;
+ s->lengthlist[i]=num+1;
}
}
@@ -386,16 +69,13 @@
/* ordered */
{
long length=oggpack_read(opb,5)+1;
+ s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
- s->used_entries=s->entries;
- lengthlist=(char *)alloca(sizeof(*lengthlist)*s->entries);
-
for(i=0;ientries;){
long num=oggpack_read(opb,_ilog(s->entries-i));
if(num==-1)goto _eofout;
for(j=0;jentries;j++,i++)
- lengthlist[i]=length;
- s->dec_maxlength=length;
+ s->lengthlist[i]=length;
length++;
}
}
@@ -404,155 +84,91 @@
/* EOF */
return(-1);
}
-
-
+
/* Do we have a mapping to unpack? */
-
- if((maptype=oggpack_read(opb,4))>0){
- s->q_min=_float32_unpack(oggpack_read(opb,32),&s->q_minp);
- s->q_del=_float32_unpack(oggpack_read(opb,32),&s->q_delp);
- s->q_bits=oggpack_read(opb,4)+1;
- s->q_seq=oggpack_read(opb,1);
-
- s->q_del>>=s->q_bits;
- s->q_delp+=s->q_bits;
- }
-
- switch(maptype){
+ switch((s->maptype=oggpack_read(opb,4))){
case 0:
-
- /* no mapping; decode type 0 */
-
- /* how many bytes for the indexing? */
- /* this is the correct boundary here; we lose one bit to
- node/leaf mark */
- s->dec_nodeb=_determine_node_bytes(s->used_entries,_ilog(s->entries)/8+1);
- s->dec_leafw=_determine_leaf_words(s->dec_nodeb,_ilog(s->entries)/8+1);
- s->dec_type=0;
+ /* no mapping */
+ break;
+ case 1: case 2:
+ /* implicitly populated value mapping */
+ /* explicitly populated value mapping */
- if(_make_decode_table(s,lengthlist,quantvals,opb,maptype)) goto _errout;
- break;
-
- case 1:
-
- /* mapping type 1; implicit values by lattice position */
- quantvals=_book_maptype1_quantvals(s);
-
- /* dec_type choices here are 1,2; 3 doesn't make sense */
- {
- /* packed values */
- long total1=(s->q_bits*s->dim+8)/8; /* remember flag bit */
- /* vector of column offsets; remember flag bit */
- long total2=(_ilog(quantvals-1)*s->dim+8)/8+(s->q_bits+7)/8;
-
-
- if(total1<=4 && total1<=total2){
- /* use dec_type 1: vector of packed values */
-
- /* need quantized values before */
- s->q_val=alloca(sizeof(ogg_uint16_t)*quantvals);
- for(i=0;iq_val)[i]=oggpack_read(opb,s->q_bits);
-
- if(oggpack_eop(opb)){
- s->q_val=0; /* cleanup must not free alloca memory */
- goto _eofout;
- }
+ s->q_min=oggpack_read(opb,32);
+ s->q_delta=oggpack_read(opb,32);
+ s->q_quant=oggpack_read(opb,4)+1;
+ s->q_sequencep=oggpack_read(opb,1);
- s->dec_type=1;
- s->dec_nodeb=_determine_node_bytes(s->used_entries,
- (s->q_bits*s->dim+8)/8);
- s->dec_leafw=_determine_leaf_words(s->dec_nodeb,
- (s->q_bits*s->dim+8)/8);
- if(_make_decode_table(s,lengthlist,quantvals,opb,maptype)){
- s->q_val=0; /* cleanup must not free alloca memory */
- goto _errout;
- }
-
- s->q_val=0; /* about to go out of scope; _make_decode_table
- was using it */
-
- }else{
- /* use dec_type 2: packed vector of column offsets */
-
- /* need quantized values before */
- if(s->q_bits<=8){
- s->q_val=_ogg_malloc(quantvals);
- for(i=0;iq_val)[i]=oggpack_read(opb,s->q_bits);
- }else{
- s->q_val=_ogg_malloc(quantvals*2);
- for(i=0;iq_val)[i]=oggpack_read(opb,s->q_bits);
- }
-
- if(oggpack_eop(opb))goto _eofout;
-
- s->q_pack=_ilog(quantvals-1);
- s->dec_type=2;
- s->dec_nodeb=_determine_node_bytes(s->used_entries,
- (_ilog(quantvals-1)*s->dim+8)/8);
- s->dec_leafw=_determine_leaf_words(s->dec_nodeb,
- (_ilog(quantvals-1)*s->dim+8)/8);
- if(_make_decode_table(s,lengthlist,quantvals,opb,maptype))goto _errout;
-
+ {
+ int quantvals=0;
+ switch(s->maptype){
+ case 1:
+ quantvals=_book_maptype1_quantvals(s);
+ break;
+ case 2:
+ quantvals=s->entries*s->dim;
+ break;
}
- }
- break;
- case 2:
-
- /* mapping type 2; explicit array of values */
- quantvals=s->entries*s->dim;
- /* dec_type choices here are 1,3; 2 is not possible */
-
- if( (s->q_bits*s->dim+8)/8 <=4){ /* remember flag bit */
- /* use dec_type 1: vector of packed values */
-
- s->dec_type=1;
- s->dec_nodeb=_determine_node_bytes(s->used_entries,(s->q_bits*s->dim+8)/8);
- s->dec_leafw=_determine_leaf_words(s->dec_nodeb,(s->q_bits*s->dim+8)/8);
- if(_make_decode_table(s,lengthlist,quantvals,opb,maptype))goto _errout;
- }else{
- /* use dec_type 3: scalar offset into packed value array */
-
- s->dec_type=3;
- s->dec_nodeb=_determine_node_bytes(s->used_entries,_ilog(s->used_entries-1)/8+1);
- s->dec_leafw=_determine_leaf_words(s->dec_nodeb,_ilog(s->used_entries-1)/8+1);
- if(_make_decode_table(s,lengthlist,quantvals,opb,maptype))goto _errout;
-
- /* get the vals & pack them */
- s->q_pack=(s->q_bits+7)/8*s->dim;
- s->q_val=_ogg_malloc(s->q_pack*s->used_entries);
-
- if(s->q_bits<=8){
- for(i=0;iused_entries*s->dim;i++)
- ((unsigned char *)(s->q_val))[i]=oggpack_read(opb,s->q_bits);
- }else{
- for(i=0;iused_entries*s->dim;i++)
- ((ogg_uint16_t *)(s->q_val))[i]=oggpack_read(opb,s->q_bits);
- }
+ /* quantized values */
+ s->quantlist=(long *)_ogg_malloc(sizeof(*s->quantlist)*quantvals);
+ for(i=0;iquantlist[i]=oggpack_read(opb,s->q_quant);
+
+ if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout;
}
break;
default:
goto _errout;
}
- if(oggpack_eop(opb))goto _eofout;
-
- return 0;
+ /* all set */
+ return(0);
+
_errout:
_eofout:
- vorbis_book_clear(s);
- return -1;
+ vorbis_staticbook_clear(s);
+ return(-1);
+}
+
+/* the 'eliminate the decode tree' optimization actually requires the
+ codewords to be MSb first, not LSb. This is an annoying inelegancy
+ (and one of the first places where carefully thought out design
+ turned out to be wrong; Vorbis II and future Ogg codecs should go
+ to an MSb bitpacker), but not actually the huge hit it appears to
+ be. The first-stage decode table catches most words so that
+ bitreverse is not in the main execution path. */
+
+static ogg_uint32_t bitreverse(ogg_uint32_t x){
+ x= ((x>>16)&0x0000ffff) | ((x<<16)&0xffff0000);
+ x= ((x>> 8)&0x00ff00ff) | ((x<< 8)&0xff00ff00);
+ x= ((x>> 4)&0x0f0f0f0f) | ((x<< 4)&0xf0f0f0f0);
+ x= ((x>> 2)&0x33333333) | ((x<< 2)&0xcccccccc);
+ return((x>> 1)&0x55555555) | ((x<< 1)&0xaaaaaaaa);
}
-static inline ogg_uint32_t decode_packed_entry_number(codebook *book,
- oggpack_buffer *b){
- ogg_uint32_t chase=0;
+STIN long decode_packed_entry_number(codebook *book,
+ oggpack_buffer *b){
int read=book->dec_maxlength;
- long lok = oggpack_look(b,read),i;
-
+ long lo,hi;
+ long lok = oggpack_look(b,book->dec_firsttablen);
+
+ if (lok >= 0) {
+ long entry = book->dec_firsttable[lok];
+ if(entry&0x80000000UL){
+ lo=(entry>>15)&0x7fff;
+ hi=book->used_entries-(entry&0x7fff);
+ }else{
+ oggpack_adv(b, book->dec_codelengths[entry-1]);
+ return(entry-1);
+ }
+ }else{
+ lo=0;
+ hi=book->used_entries;
+ }
+
+ lok = oggpack_look(b, read);
+
while(lok<0 && read>1)
lok = oggpack_look(b, --read);
@@ -561,229 +177,195 @@
return -1;
}
- /* chase the tree with the bits we got */
- if(book->dec_nodeb==1){
- if(book->dec_leafw==1){
-
- /* 8/8 */
- unsigned char *t=(unsigned char *)book->dec_table;
- for(i=0;i>i)&1)];
- if(chase&0x80UL)break;
- }
- chase&=0x7fUL;
+ /* bisect search for the codeword in the ordered list */
+ {
+ ogg_uint32_t testword=bitreverse((ogg_uint32_t)lok);
- }else{
-
- /* 8/16 */
- unsigned char *t=(unsigned char *)book->dec_table;
- for(i=0;i>i)&1;
- int next=t[chase+bit];
- if(next&0x80){
- chase= (next<<8) | t[chase+bit+1+(!bit || t[chase]&0x80)];
- break;
- }
- chase=next;
- }
- chase&=0x7fffUL;
+ while(hi-lo>1){
+ long p=(hi-lo)>>1;
+ long test=book->codelist[lo+p]>testword;
+ lo+=p&(test-1);
+ hi-=p&(-test);
}
- }else{
- if(book->dec_nodeb==2){
- if(book->dec_leafw==1){
-
- /* 16/16 */
- for(i=0;idec_table))[chase*2+((lok>>i)&1)];
- if(chase&0x8000UL)break;
- }
- chase&=0x7fffUL;
-
- }else{
-
- /* 16/32 */
- ogg_uint16_t *t=(ogg_uint16_t *)book->dec_table;
- for(i=0;i>i)&1;
- int next=t[chase+bit];
- if(next&0x8000){
- chase= (next<<16) | t[chase+bit+1+(!bit || t[chase]&0x8000)];
- break;
- }
- chase=next;
- }
- chase&=0x7fffffffUL;
- }
-
- }else{
-
- for(i=0;idec_table))[chase*2+((lok>>i)&1)];
- if(chase&0x80000000UL)break;
- }
- chase&=0x7fffffffUL;
-
+ if(book->dec_codelengths[lo]<=read){
+ oggpack_adv(b, book->dec_codelengths[lo]);
+ return(lo);
}
}
- if(i declarative (set the value)
+ addmul==1 -> additive
+ addmul==2 -> multiplicitive */
+
/* returns the [original, not compacted] entry number or -1 on eof *********/
long vorbis_book_decode(codebook *book, oggpack_buffer *b){
- if(book->dec_type)return -1;
- return decode_packed_entry_number(book,b);
-}
-
-int decode_map(codebook *s, oggpack_buffer *b, ogg_int32_t *v, int point){
- ogg_uint32_t entry = decode_packed_entry_number(s,b);
- int i;
- if(oggpack_eop(b))return(-1);
-
- /* according to decode type */
- switch(s->dec_type){
- case 1:{
- /* packed vector of values */
- int mask=(1<q_bits)-1;
- for(i=0;idim;i++){
- v[i]=entry&mask;
- entry>>=s->q_bits;
- }
- break;
- }
- case 2:{
- /* packed vector of column offsets */
- int mask=(1<q_pack)-1;
- for(i=0;idim;i++){
- if(s->q_bits<=8)
- v[i]=((unsigned char *)(s->q_val))[entry&mask];
- else
- v[i]=((ogg_uint16_t *)(s->q_val))[entry&mask];
- entry>>=s->q_pack;
- }
- break;
- }
- case 3:{
- /* offset into array */
- void *ptr=s->q_val+entry*s->q_pack;
-
- if(s->q_bits<=8){
- for(i=0;idim;i++)
- v[i]=((unsigned char *)ptr)[i];
- }else{
- for(i=0;idim;i++)
- v[i]=((ogg_uint16_t *)ptr)[i];
- }
- break;
- }
- default:
- return -1;
+ if(book->used_entries>0){
+ long packed_entry=decode_packed_entry_number(book,b);
+ if(packed_entry>=0)
+ return(book->dec_index[packed_entry]);
}
- /* we have the unpacked multiplicands; compute final vals */
- {
- int shiftM=point-s->q_delp;
- ogg_int32_t add=point-s->q_minp;
- if(add>0)
- add= s->q_min >> add;
- else
- add= s->q_min << -add;
-
- if(shiftM>0)
- for(i=0;idim;i++)
- v[i]= add + ((v[i] * s->q_del) >> shiftM);
- else
- for(i=0;idim;i++)
- v[i]= add + ((v[i] * s->q_del) << -shiftM);
-
- if(s->q_seq)
- for(i=1;idim;i++)
- v[i]+=v[i-1];
- }
-
- return 0;
+ /* if there's no dec_index, the codebook unpacking isn't collapsed */
+ return(-1);
}
/* returns 0 on OK or -1 on eof *************************************/
long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a,
oggpack_buffer *b,int n,int point){
- if(book->used_entries>0){
+ if(book->used_entries>0){
int step=n/book->dim;
- ogg_int32_t *v = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
+ long *entry = (long *)alloca(sizeof(*entry)*step);
+ ogg_int32_t **t = (ogg_int32_t **)alloca(sizeof(*t)*step);
int i,j,o;
+ int shift=point-book->binarypoint;
- for (j=0;jdim;i++,o+=step)
- a[o]+=v[i];
+ if(shift>=0){
+ for (i = 0; i < step; i++) {
+ entry[i]=decode_packed_entry_number(book,b);
+ if(entry[i]==-1)return(-1);
+ t[i] = book->valuelist+entry[i]*book->dim;
+ }
+ for(i=0,o=0;idim;i++,o+=step)
+ for (j=0;j>shift;
+ }else{
+ for (i = 0; i < step; i++) {
+ entry[i]=decode_packed_entry_number(book,b);
+ if(entry[i]==-1)return(-1);
+ t[i] = book->valuelist+entry[i]*book->dim;
+ }
+ for(i=0,o=0;idim;i++,o+=step)
+ for (j=0;jused_entries>0){
- ogg_int32_t *v = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
- int i,j;
+ int i,j,entry;
+ ogg_int32_t *t;
+ int shift=point-book->binarypoint;
- for(i=0;idim;j++)
- a[i++]+=v[j];
+ if(shift>=0){
+ for(i=0;ivaluelist+entry*book->dim;
+ for (j=0;jdim;)
+ a[i++]+=t[j++]>>shift;
+ }
+ }else{
+ for(i=0;ivaluelist+entry*book->dim;
+ for (j=0;jdim;)
+ a[i++]+=t[j++]<<-shift;
+ }
}
}
- return 0;
+ return(0);
}
long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
oggpack_buffer *b,int n,int point){
if(book->used_entries>0){
- ogg_int32_t *v = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
- int i,j;
+ int i,j,entry;
+ ogg_int32_t *t;
+ int shift=point-book->binarypoint;
- for(i=0;idim;j++)
- a[i++]=v[j];
+ if(shift>=0){
+
+ for(i=0;ivaluelist+entry*book->dim;
+ for (j=0;jdim;){
+ a[i++]=t[j++]>>shift;
+ }
+ }
+ }else{
+
+ for(i=0;ivaluelist+entry*book->dim;
+ for (j=0;jdim;){
+ a[i++]=t[j++]<<-shift;
+ }
+ }
}
}else{
+
int i,j;
-
for(i=0;idim;j++)
+ for (j=0;jdim;){
a[i++]=0;
+ }
}
}
-
- return 0;
+ return(0);
}
-long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
+long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,\
long offset,int ch,
oggpack_buffer *b,int n,int point){
-
if(book->used_entries>0){
- ogg_int32_t *v = (ogg_int32_t *)alloca(sizeof(*v)*book->dim);
- long i,j;
+ long i,j,entry;
int chptr=0;
+ int shift=point-book->binarypoint;
- for(i=offset;idim;j++){
- a[chptr++][i]+=v[j];
- if(chptr==ch){
- chptr=0;
- i++;
+ if(shift>=0){
+
+ for(i=offset;ivaluelist+entry*book->dim;
+ for (j=0;jdim;j++){
+ a[chptr++][i]+=t[j]>>shift;
+ if(chptr==ch){
+ chptr=0;
+ i++;
+ }
+ }
+ }
+ }
+ }else{
+
+ for(i=offset;ivaluelist+entry*book->dim;
+ for (j=0;jdim;j++){
+ a[chptr++][i]+=t[j]<<-shift;
+ if(chptr==ch){
+ chptr=0;
+ i++;
+ }
+ }
}
}
}
}
- return 0;
+ return(0);
}
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/codebook.h
--- a/misc/libtremor/tremor/codebook.h Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/codebook.h Sat Nov 03 00:34:35 2012 +0400
@@ -20,33 +20,70 @@
#include "ogg.h"
-typedef struct codebook{
- long dim; /* codebook dimensions (elements per vector) */
- long entries; /* codebook entries */
- long used_entries; /* populated codebook entries */
+/* This structure encapsulates huffman and VQ style encoding books; it
+ doesn't do anything specific to either.
+
+ valuelist/quantlist are nonNULL (and q_* significant) only if
+ there's entry->value mapping to be done.
+
+ If encode-side mapping must be done (and thus the entry needs to be
+ hunted), the auxiliary encode pointer will point to a decision
+ tree. This is true of both VQ and huffman, but is mostly useful
+ with VQ.
+
+*/
+
+typedef struct static_codebook{
+ long dim; /* codebook dimensions (elements per vector) */
+ long entries; /* codebook entries */
+ long *lengthlist; /* codeword lengths in bits */
+
+ /* mapping ***************************************************************/
+ int maptype; /* 0=none
+ 1=implicitly populated values from map column
+ 2=listed arbitrary values */
- int dec_maxlength;
- void *dec_table;
- int dec_nodeb;
- int dec_leafw;
- int dec_type; /* 0 = entry number
- 1 = packed vector of values
- 2 = packed vector of column offsets, maptype 1
- 3 = scalar offset into value array, maptype 2 */
+ /* The below does a linear, single monotonic sequence mapping. */
+ long q_min; /* packed 32 bit float; quant value 0 maps to minval */
+ long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */
+ int q_quant; /* bits: 0 < quant <= 16 */
+ int q_sequencep; /* bitflag */
+
+ long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map
+ map == 2: list of dim*entries quantized entry vals
+ */
+} static_codebook;
- ogg_int32_t q_min;
- int q_minp;
- ogg_int32_t q_del;
- int q_delp;
- int q_seq;
- int q_bits;
- int q_pack;
- void *q_val;
+typedef struct codebook{
+ long dim; /* codebook dimensions (elements per vector) */
+ long entries; /* codebook entries */
+ long used_entries; /* populated codebook entries */
+
+ /* the below are ordered by bitreversed codeword and only used
+ entries are populated */
+ int binarypoint;
+ ogg_int32_t *valuelist; /* list of dim*entries actual entry values */
+ ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */
+
+ int *dec_index;
+ char *dec_codelengths;
+ ogg_uint32_t *dec_firsttable;
+ int dec_firsttablen;
+ int dec_maxlength;
+
+ long q_min; /* packed 32 bit float; quant value 0 maps to minval */
+ long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */
} codebook;
+extern void vorbis_staticbook_clear(static_codebook *b);
+extern void vorbis_staticbook_destroy(static_codebook *b);
+extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source);
+
extern void vorbis_book_clear(codebook *b);
-extern int vorbis_book_unpack(oggpack_buffer *b,codebook *c);
+extern long _book_maptype1_quantvals(const static_codebook *b);
+
+extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c);
extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a,
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/codec_internal.h
--- a/misc/libtremor/tremor/codec_internal.h Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/codec_internal.h Sat Nov 03 00:34:35 2012 +0400
@@ -6,7 +6,7 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
- * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
+ * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
@@ -18,149 +18,36 @@
#ifndef _V_CODECI_H_
#define _V_CODECI_H_
-#define CHUNKSIZE 1024
-
#include "codebook.h"
-#include "ivorbiscodec.h"
-
-#define VI_TRANSFORMB 1
-#define VI_WINDOWB 1
-#define VI_TIMEB 1
-#define VI_FLOORB 2
-#define VI_RESB 3
-#define VI_MAPB 1
-
-typedef void vorbis_info_floor;
-
-/* vorbis_dsp_state buffers the current vorbis audio
- analysis/synthesis state. The DSP state belongs to a specific
- logical bitstream ****************************************************/
-struct vorbis_dsp_state{
- vorbis_info *vi;
- oggpack_buffer opb;
-
- ogg_int32_t **work;
- ogg_int32_t **mdctright;
- int out_begin;
- int out_end;
-
- long lW;
- long W;
-
- ogg_int64_t granulepos;
- ogg_int64_t sequence;
- ogg_int64_t sample_count;
-
-};
-
-
-/* Floor backend generic *****************************************/
-
-extern vorbis_info_floor *floor0_info_unpack(vorbis_info *,oggpack_buffer *);
-extern void floor0_free_info(vorbis_info_floor *);
-extern int floor0_memosize(vorbis_info_floor *);
-extern ogg_int32_t *floor0_inverse1(struct vorbis_dsp_state *,
- vorbis_info_floor *,ogg_int32_t *);
-extern int floor0_inverse2 (struct vorbis_dsp_state *,vorbis_info_floor *,
- ogg_int32_t *buffer,ogg_int32_t *);
-
-extern vorbis_info_floor *floor1_info_unpack(vorbis_info *,oggpack_buffer *);
-extern void floor1_free_info(vorbis_info_floor *);
-extern int floor1_memosize(vorbis_info_floor *);
-extern ogg_int32_t *floor1_inverse1(struct vorbis_dsp_state *,
- vorbis_info_floor *,ogg_int32_t *);
-extern int floor1_inverse2 (struct vorbis_dsp_state *,vorbis_info_floor *,
- ogg_int32_t *buffer,ogg_int32_t *);
-typedef struct{
- int order;
- long rate;
- long barkmap;
-
- int ampbits;
- int ampdB;
-
- int numbooks; /* <= 16 */
- char books[16];
-
-} vorbis_info_floor0;
-
-typedef struct{
- char class_dim; /* 1 to 8 */
- char class_subs; /* 0,1,2,3 (bits: 1< Wed, 09 Oct 2002 22:00:00 -0500
-
-Local variables:
-mode: debian-changelog
-End:
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/debian/control
--- a/misc/libtremor/tremor/debian/control Sun Oct 21 01:28:33 2012 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-Source: libvorbisidec
-Section: libs
-Priority: optional
-Maintainer: Christopher L Cheney
-Build-Depends: autotools-dev, debhelper (>> 4.0.18), devscripts, gawk
-Standards-Version: 3.5.7.0
-
-Package: libvorbisidec1
-Architecture: any
-Section: libs
-Depends: ${shlibs:Depends}
-Description: Ogg Bitstream Library
- Libogg is a library for manipulating ogg bitstreams. It handles
- both making ogg bitstreams and getting packets from ogg bitstreams.
-
-Package: libvorbisidec-dev
-Architecture: any
-Section: devel
-Depends: libvorbisidec1 (= ${Source-Version}), libc6-dev
-Description: Ogg Bitstream Library Development
- The libogg-dev package contains the header files and documentation
- needed to develop applications with libogg.
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/debian/copyright
--- a/misc/libtremor/tremor/debian/copyright Sun Oct 21 01:28:33 2012 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-This package was debianized by Christopher L Cheney on
-Wed, 09 Oct 2002 22:00:00 -0500.
-
-It was downloaded from cvs.
-
-Upstream Author(s): Monty
-
-Copyright:
-Copyright (c) 2002, Xiph.org Foundation
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-- Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-
-- 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.
-
-- Neither the name of the Xiph.Org Foundation nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-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 REGENTS 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.
-
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/debian/libvorbisidec-dev.install
--- a/misc/libtremor/tremor/debian/libvorbisidec-dev.install Sun Oct 21 01:28:33 2012 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-debian/tmp/usr/include/tremor/config_types.h
-debian/tmp/usr/include/tremor/ivorbiscodec.h
-debian/tmp/usr/include/tremor/ivorbisfile.h
-debian/tmp/usr/include/tremor/ogg.h
-debian/tmp/usr/include/tremor/os_types.h
-debian/tmp/usr/lib/libvorbisidec.a
-debian/tmp/usr/lib/libvorbisidec.la
-debian/tmp/usr/lib/libvorbisidec.so
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/debian/libvorbisidec1.install
--- a/misc/libtremor/tremor/debian/libvorbisidec1.install Sun Oct 21 01:28:33 2012 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-debian/tmp/usr/lib/libvorbisidec.so.*
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/debian/rules
--- a/misc/libtremor/tremor/debian/rules Sun Oct 21 01:28:33 2012 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,151 +0,0 @@
-#!/usr/bin/make -f
-# Sample debian/rules that uses debhelper.
-# GNU copyright 1997 to 1999 by Joey Hess.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-# This is the debhelper compatibility version to use.
-export DH_COMPAT=4
-
-# This has to be exported to make some magic below work.
-export DH_OPTIONS
-
-# These are used for cross-compiling and for saving the configure script
-# from having to guess our platform (since we know it already)
-DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
-DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
-
-objdir = $(CURDIR)/obj-$(DEB_BUILD_GNU_TYPE)
-
-ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -g
-endif
-ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
- INSTALL_PROGRAM += -s
-endif
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
-
- # make build directory
- mkdir $(objdir)
-
- # run configure with build tree $(objdir)
- # change ../configure to ../autogen.sh for CVS build
- cd $(objdir) && \
- ../configure --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) \
- --prefix=/usr
-
- touch configure-stamp
-
-build: build-stamp
-build-stamp: configure-stamp
- dh_testdir
-
- cd $(objdir) && \
- $(MAKE)
-
- touch build-stamp
-
-autotools:
- OLDDATESUB=`./config.sub -t | tr -d -` ;\
- OLDDATEGUESS=`./config.guess -t | tr -d -` ;\
- NEWDATESUB=`/usr/share/misc/config.sub -t | tr -d -` ;\
- NEWDATEGUESS=`/usr/share/misc/config.guess -t | tr -d -` ;\
- if [ $$OLDDATESUB -lt $$NEWDATESUB -o \
- $$OLDDATEGUESS -lt $$NEWDATEGUESS ]; then \
- dch -a -p "GNU config automated update: config.sub\
- ($$OLDDATESUB to $$NEWDATESUB), config.guess\
- ($$OLDDATEGUESS to $$NEWDATEGUESS)" ;\
- cp -f /usr/share/misc/config.sub config.sub ;\
- cp -f /usr/share/misc/config.guess config.guess ;\
- echo WARNING: GNU config scripts updated from master copies 1>&2 ;\
- fi
-
-debian-clean:
- dh_testdir
- dh_testroot
-
- dh_clean
-
-clean: autotools
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
-
- # Remove build tree
- rm -rf $(objdir)
-
- # if Makefile exists run distclean
- if test -f Makefile; then \
- $(MAKE) distclean; \
- fi
-
- #if test -d CVS; then \
- $(MAKE) cvs-clean ;\
- fi
-
- dh_clean
-
-install: DH_OPTIONS=
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- cd $(objdir) && \
- $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
-
- dh_install --list-missing
-
-# This single target is used to build all the packages, all at once, or
-# one at a time. So keep in mind: any options passed to commands here will
-# affect _all_ packages. Anything you want to only affect one package
-# should be put in another target, such as the install target.
-binary-common:
- dh_testdir
- dh_testroot
-# dh_installxfonts
- dh_installchangelogs
- dh_installdocs
- dh_installexamples
-# dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installpam
-# dh_installmime
-# dh_installinit
-# dh_installcron
-# dh_installinfo
-# dh_undocumented
- dh_installman
- dh_strip
- dh_link
- dh_compress
- dh_fixperms
- dh_makeshlibs -V
- dh_installdeb
-# dh_perl
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-# Build architecture independant packages using the common target.
-binary-indep: build install
-# $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
-
-# Build architecture dependant packages using the common target.
-binary-arch: build install
- $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common
-
-# Any other binary targets build just one binary package at a time.
-binary-%: build install
- $(MAKE) -f debian/rules binary-common DH_OPTIONS=-p$*
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/dsp.c
--- a/misc/libtremor/tremor/dsp.c Sun Oct 21 01:28:33 2012 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,298 +0,0 @@
-/********************************************************************
- * *
- * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
- * *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
- * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
- * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
- * *
- * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
- * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
- * *
- ********************************************************************
-
- function: PCM data vector blocking, windowing and dis/reassembly
-
- ********************************************************************/
-
-#include
-#include "ogg.h"
-#include "mdct.h"
-#include "ivorbiscodec.h"
-#include "codec_internal.h"
-#include "misc.h"
-#include "window_lookup.h"
-
-int vorbis_dsp_restart(vorbis_dsp_state *v){
- if(!v)return -1;
- {
- vorbis_info *vi=v->vi;
- codec_setup_info *ci;
-
- if(!vi)return -1;
- ci=vi->codec_setup;
- if(!ci)return -1;
-
- v->out_end=-1;
- v->out_begin=-1;
-
- v->granulepos=-1;
- v->sequence=-1;
- v->sample_count=-1;
- }
- return 0;
-}
-
-vorbis_dsp_state *vorbis_dsp_create(vorbis_info *vi){
- int i;
-
- vorbis_dsp_state *v=_ogg_calloc(1,sizeof(*v));
- codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
-
- v->vi=vi;
-
- v->work=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->work));
- v->mdctright=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->mdctright));
- for(i=0;ichannels;i++){
- v->work[i]=(ogg_int32_t *)_ogg_calloc(1,(ci->blocksizes[1]>>1)*
- sizeof(*v->work[i]));
- v->mdctright[i]=(ogg_int32_t *)_ogg_calloc(1,(ci->blocksizes[1]>>2)*
- sizeof(*v->mdctright[i]));
- }
-
- v->lW=0; /* previous window size */
- v->W=0; /* current window size */
-
- vorbis_dsp_restart(v);
- return v;
-}
-
-void vorbis_dsp_destroy(vorbis_dsp_state *v){
- int i;
- if(v){
- vorbis_info *vi=v->vi;
-
- if(v->work){
- for(i=0;ichannels;i++)
- if(v->work[i])_ogg_free(v->work[i]);
- _ogg_free(v->work);
- }
- if(v->mdctright){
- for(i=0;ichannels;i++)
- if(v->mdctright[i])_ogg_free(v->mdctright[i]);
- _ogg_free(v->mdctright);
- }
-
- _ogg_free(v);
- }
-}
-
-static LOOKUP_T *_vorbis_window(int left){
- switch(left){
- case 32:
- return vwin64;
- case 64:
- return vwin128;
- case 128:
- return vwin256;
- case 256:
- return vwin512;
- case 512:
- return vwin1024;
- case 1024:
- return vwin2048;
- case 2048:
- return vwin4096;
-#ifndef LIMIT_TO_64kHz
- case 4096:
- return vwin8192;
-#endif
- default:
- return(0);
- }
-}
-
-/* pcm==0 indicates we just want the pending samples, no more */
-int vorbis_dsp_pcmout(vorbis_dsp_state *v,ogg_int16_t *pcm,int samples){
- vorbis_info *vi=v->vi;
- codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
- if(v->out_begin>-1 && v->out_beginout_end){
- int n=v->out_end-v->out_begin;
- if(pcm){
- int i;
- if(n>samples)n=samples;
- for(i=0;ichannels;i++)
- mdct_unroll_lap(ci->blocksizes[0],ci->blocksizes[1],
- v->lW,v->W,v->work[i],v->mdctright[i],
- _vorbis_window(ci->blocksizes[0]>>1),
- _vorbis_window(ci->blocksizes[1]>>1),
- pcm+i,vi->channels,
- v->out_begin,v->out_begin+n);
- }
- return(n);
- }
- return(0);
-}
-
-int vorbis_dsp_read(vorbis_dsp_state *v,int s){
- if(s && v->out_begin+s>v->out_end)return(OV_EINVAL);
- v->out_begin+=s;
- return(0);
-}
-
-long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){
- codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
- oggpack_buffer opb;
- int mode;
- int modebits=0;
- int v=ci->modes;
-
- oggpack_readinit(&opb,op->packet);
-
- /* Check the packet type */
- if(oggpack_read(&opb,1)!=0){
- /* Oops. This is not an audio data packet */
- return(OV_ENOTAUDIO);
- }
-
- while(v>1){
- modebits++;
- v>>=1;
- }
-
- /* read our mode and pre/post windowsize */
- mode=oggpack_read(&opb,modebits);
- if(mode==-1)return(OV_EBADPACKET);
- return(ci->blocksizes[ci->mode_param[mode].blockflag]);
-}
-
-
-static int ilog(ogg_uint32_t v){
- int ret=0;
- if(v)--v;
- while(v){
- ret++;
- v>>=1;
- }
- return(ret);
-}
-
-int vorbis_dsp_synthesis(vorbis_dsp_state *vd,ogg_packet *op,int decodep){
- vorbis_info *vi=vd->vi;
- codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
- int mode,i;
-
- oggpack_readinit(&vd->opb,op->packet);
-
- /* Check the packet type */
- if(oggpack_read(&vd->opb,1)!=0){
- /* Oops. This is not an audio data packet */
- return OV_ENOTAUDIO ;
- }
-
- /* read our mode and pre/post windowsize */
- mode=oggpack_read(&vd->opb,ilog(ci->modes));
- if(mode==-1 || mode>=ci->modes) return OV_EBADPACKET;
-
- /* shift information we still need from last window */
- vd->lW=vd->W;
- vd->W=ci->mode_param[mode].blockflag;
- for(i=0;ichannels;i++)
- mdct_shift_right(ci->blocksizes[vd->lW],vd->work[i],vd->mdctright[i]);
-
- if(vd->W){
- int temp;
- oggpack_read(&vd->opb,1);
- temp=oggpack_read(&vd->opb,1);
- if(temp==-1) return OV_EBADPACKET;
- }
-
- /* packet decode and portions of synthesis that rely on only this block */
- if(decodep){
- mapping_inverse(vd,ci->map_param+ci->mode_param[mode].mapping);
-
- if(vd->out_begin==-1){
- vd->out_begin=0;
- vd->out_end=0;
- }else{
- vd->out_begin=0;
- vd->out_end=ci->blocksizes[vd->lW]/4+ci->blocksizes[vd->W]/4;
- }
- }
-
- /* track the frame number... This is for convenience, but also
- making sure our last packet doesn't end with added padding.
-
- This is not foolproof! It will be confused if we begin
- decoding at the last page after a seek or hole. In that case,
- we don't have a starting point to judge where the last frame
- is. For this reason, vorbisfile will always try to make sure
- it reads the last two marked pages in proper sequence */
-
- /* if we're out of sequence, dump granpos tracking until we sync back up */
- if(vd->sequence==-1 || vd->sequence+1 != op->packetno-3){
- /* out of sequence; lose count */
- vd->granulepos=-1;
- vd->sample_count=-1;
- }
-
- vd->sequence=op->packetno;
- vd->sequence=vd->sequence-3;
-
- if(vd->sample_count==-1){
- vd->sample_count=0;
- }else{
- vd->sample_count+=
- ci->blocksizes[vd->lW]/4+ci->blocksizes[vd->W]/4;
- }
-
- if(vd->granulepos==-1){
- if(op->granulepos!=-1){ /* only set if we have a
- position to set to */
-
- vd->granulepos=op->granulepos;
-
- /* is this a short page? */
- if(vd->sample_count>vd->granulepos){
- /* corner case; if this is both the first and last audio page,
- then spec says the end is cut, not beginning */
- if(op->e_o_s){
- /* trim the end */
- /* no preceeding granulepos; assume we started at zero (we'd
- have to in a short single-page stream) */
- /* granulepos could be -1 due to a seek, but that would result
- in a long coun t, not short count */
-
- vd->out_end-=vd->sample_count-vd->granulepos;
- }else{
- /* trim the beginning */
- vd->out_begin+=vd->sample_count-vd->granulepos;
- if(vd->out_begin>vd->out_end)
- vd->out_begin=vd->out_end;
- }
-
- }
-
- }
- }else{
- vd->granulepos+=
- ci->blocksizes[vd->lW]/4+ci->blocksizes[vd->W]/4;
- if(op->granulepos!=-1 && vd->granulepos!=op->granulepos){
-
- if(vd->granulepos>op->granulepos){
- long extra=vd->granulepos-op->granulepos;
-
- if(extra)
- if(op->e_o_s){
- /* partial last frame. Strip the extra samples off */
- vd->out_end-=extra;
- } /* else {Shouldn't happen *unless* the bitstream is out of
- spec. Either way, believe the bitstream } */
- } /* else {Shouldn't happen *unless* the bitstream is out of
- spec. Either way, believe the bitstream } */
- vd->granulepos=op->granulepos;
- }
- }
-
- return(0);
-}
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/floor0.c
--- a/misc/libtremor/tremor/floor0.c Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/floor0.c Sat Nov 03 00:34:35 2012 +0400
@@ -6,7 +6,7 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
- * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
+ * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
@@ -21,12 +21,23 @@
#include "ogg.h"
#include "ivorbiscodec.h"
#include "codec_internal.h"
+#include "registry.h"
#include "codebook.h"
#include "misc.h"
-#include "os.h"
+#include "block.h"
#define LSP_FRACBITS 14
-extern const ogg_int32_t FLOOR_fromdB_LOOKUP[];
+
+typedef struct {
+ long n;
+ int ln;
+ int m;
+ int *linearmap;
+
+ vorbis_info_floor0 *vi;
+ ogg_int32_t *lsp_look;
+
+} vorbis_look_floor0;
/*************** LSP decode ********************/
@@ -37,7 +48,7 @@
returns in m.8 format */
static long ADJUST_SQRT2[2]={8192,5792};
-static inline ogg_int32_t vorbis_invsqlook_i(long a,long e){
+STIN ogg_int32_t vorbis_invsqlook_i(long a,long e){
long i=(a&0x7fff)>>(INVSQ_LOOKUP_I_SHIFT-1);
long d=a&INVSQ_LOOKUP_I_MASK; /* 0.10 */
long val=INVSQ_LOOKUP_I[i]- /* 1.16 */
@@ -49,60 +60,60 @@
/* interpolated lookup based fromdB function, domain -140dB to 0dB only */
/* a is in n.12 format */
-#ifdef _LOW_ACCURACY_
-static inline ogg_int32_t vorbis_fromdBlook_i(long a){
- if(a>0) return 0x7fffffff;
- if(a<(-140<<12)) return 0;
- return FLOOR_fromdB_LOOKUP[((a+140)*467)>>20]<<9;
+STIN ogg_int32_t vorbis_fromdBlook_i(long a){
+ int i=(-a)>>(12-FROMdB2_SHIFT);
+ if(i<0) return 0x7fffffff;
+ if(i>=(FROMdB_LOOKUP_SZ<>FROMdB_SHIFT] * FROMdB2_LOOKUP[i&FROMdB2_MASK];
}
-#else
-static inline ogg_int32_t vorbis_fromdBlook_i(long a){
- if(a>0) return 0x7fffffff;
- if(a<(-140<<12)) return 0;
- return FLOOR_fromdB_LOOKUP[((a+(140<<12))*467)>>20];
-}
-#endif
/* interpolated lookup based cos function, domain 0 to PI only */
/* a is in 0.16 format, where 0==0, 2^^16-1==PI, return 0.14 */
-static inline ogg_int32_t vorbis_coslook_i(long a){
+STIN ogg_int32_t vorbis_coslook_i(long a){
int i=a>>COS_LOOKUP_I_SHIFT;
int d=a&COS_LOOKUP_I_MASK;
return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>>
COS_LOOKUP_I_SHIFT);
}
-/* interpolated half-wave lookup based cos function */
+/* interpolated lookup based cos function */
/* a is in 0.16 format, where 0==0, 2^^16==PI, return .LSP_FRACBITS */
-static inline ogg_int32_t vorbis_coslook2_i(long a){
- int i=a>>COS_LOOKUP_I_SHIFT;
- int d=a&COS_LOOKUP_I_MASK;
- return ((COS_LOOKUP_I[i]<>
- (COS_LOOKUP_I_SHIFT-LSP_FRACBITS+14);
+STIN ogg_int32_t vorbis_coslook2_i(long a){
+ a=a&0x1ffff;
+
+ if(a>0x10000)a=0x20000-a;
+ {
+ int i=a>>COS_LOOKUP_I_SHIFT;
+ int d=a&COS_LOOKUP_I_MASK;
+ a=((COS_LOOKUP_I[i]<>
+ (COS_LOOKUP_I_SHIFT-LSP_FRACBITS+14);
+ }
+
+ return(a);
}
-static const ogg_uint16_t barklook[54]={
- 0,51,102,154, 206,258,311,365,
- 420,477,535,594, 656,719,785,854,
- 926,1002,1082,1166, 1256,1352,1454,1564,
- 1683,1812,1953,2107, 2276,2463,2670,2900,
- 3155,3440,3756,4106, 4493,4919,5387,5901,
- 6466,7094,7798,8599, 9528,10623,11935,13524,
- 15453,17775,20517,23667, 27183,31004
+static const int barklook[28]={
+ 0,100,200,301, 405,516,635,766,
+ 912,1077,1263,1476, 1720,2003,2333,2721,
+ 3184,3742,4428,5285, 6376,7791,9662,12181,
+ 15624,20397,27087,36554
};
/* used in init only; interpolate the long way */
-static inline ogg_int32_t toBARK(int n){
+STIN ogg_int32_t toBARK(int n){
int i;
- for(i=0;i<54;i++)
+ for(i=0;i<27;i++)
if(n>=barklook[i] && n>17);
+ int gap=barklook[i+1]-barklook[i];
+ int del=n-barklook[i];
+
+ return((i<<15)+((del<<15)/gap));
}
}
@@ -122,11 +133,11 @@
static const unsigned char MLOOP_3[8]={0,1,2,2,3,3,3,3};
-void vorbis_lsp_to_curve(ogg_int32_t *curve,int n,int ln,
+void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
ogg_int32_t *lsp,int m,
ogg_int32_t amp,
ogg_int32_t ampoffset,
- ogg_int32_t nyq){
+ ogg_int32_t *icos){
/* 0 <= m < 256 */
@@ -135,27 +146,6 @@
int ampoffseti=ampoffset*4096;
int ampi=amp;
ogg_int32_t *ilsp=(ogg_int32_t *)alloca(m*sizeof(*ilsp));
-
- ogg_uint32_t inyq= (1UL<<31) / toBARK(nyq);
- ogg_uint32_t imap= (1UL<<31) / ln;
- ogg_uint32_t tBnyq1 = toBARK(nyq)<<1;
-
- /* Besenham for frequency scale to avoid a division */
- int f=0;
- int fdx=n;
- int fbase=nyq/fdx;
- int ferr=0;
- int fdy=nyq-fbase*fdx;
- int map=0;
-
-#ifdef _LOW_ACCURACY_
- ogg_uint32_t nextbark=((tBnyq1<<11)/ln)>>12;
-#else
- ogg_uint32_t nextbark=MULT31(imap>>1,tBnyq1);
-#endif
- int nextf=barklook[nextbark>>14]+(((nextbark&0x3fff)*
- (barklook[(nextbark>>14)+1]-barklook[nextbark>>14]))>>14);
-
/* lsp is in 8.24, range 0 to PI; coslook wants it in .16 0 to 1*/
for(i=0;i>15);
-
+ ogg_int32_t wi=icos[k];
#ifdef _V_LSP_MATH_ASM
lsp_loop_asm(&qi,&pi,&qexp,ilsp,wi,m);
@@ -215,9 +202,8 @@
for(j=3;j>25]))
- if(!(shift=MLOOP_2[(pi|qi)>>19]))
- shift=MLOOP_3[(pi|qi)>>16];
-
+ if(!(shift=MLOOP_2[(pi|qi)>>19]))
+ shift=MLOOP_3[(pi|qi)>>16];
qi=(qi>>shift)*labs(ilsp[j-1]-wi);
pi=(pi>>shift)*labs(ilsp[j]-wi);
qexp+=shift;
@@ -225,7 +211,7 @@
if(!(shift=MLOOP_1[(pi|qi)>>25]))
if(!(shift=MLOOP_2[(pi|qi)>>19]))
shift=MLOOP_3[(pi|qi)>>16];
-
+
/* pi,qi normalized collectively, both tracked using qexp */
if(m&1){
@@ -293,57 +279,32 @@
amp>>=9;
#endif
curve[i]= MULT31_SHIFT15(curve[i],amp);
-
- while(++i=fdx){
- ferr-=fdx;
- f++;
- }
- f+=fbase;
-
- if(f>=nextf)break;
-
- curve[i]= MULT31_SHIFT15(curve[i],amp);
- }
-
- while(1){
- map++;
-
- if(map+1>12;
-#else
- nextbark=MULT31((map+1)*(imap>>1),tBnyq1);
-#endif
- nextf=barklook[nextbark>>14]+
- (((nextbark&0x3fff)*
- (barklook[(nextbark>>14)+1]-barklook[nextbark>>14]))>>14);
- if(f<=nextf)break;
-
- }else{
- nextf=9999999;
- break;
- }
- }
- if(map>=ln){
- map=ln-1; /* guard against the approximation */
- nextf=9999999;
- }
+ while(map[++i]==k) curve[i]= MULT31_SHIFT15(curve[i],amp);
}
}
/*************** vorbis decode glue ************/
-void floor0_free_info(vorbis_info_floor *i){
+static void floor0_free_info(vorbis_info_floor *i){
vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
- if(info)_ogg_free(info);
+ if(info){
+ memset(info,0,sizeof(*info));
+ _ogg_free(info);
+ }
}
-vorbis_info_floor *floor0_info_unpack (vorbis_info *vi,oggpack_buffer *opb){
+static void floor0_free_look(vorbis_look_floor *i){
+ vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
+ if(look){
+
+ if(look->linearmap)_ogg_free(look->linearmap);
+ if(look->lsp_look)_ogg_free(look->lsp_look);
+ memset(look,0,sizeof(*look));
+ _ogg_free(look);
+ }
+}
+
+static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
int j;
@@ -358,13 +319,12 @@
if(info->order<1)goto err_out;
if(info->rate<1)goto err_out;
if(info->barkmap<1)goto err_out;
+ if(info->numbooks<1)goto err_out;
for(j=0;jnumbooks;j++){
info->books[j]=oggpack_read(opb,8);
- if(info->books[j]>=ci->books)goto err_out;
+ if(info->books[j]<0 || info->books[j]>=ci->books)goto err_out;
}
-
- if(oggpack_eop(opb))goto err_out;
return(info);
err_out:
@@ -372,35 +332,75 @@
return(NULL);
}
-int floor0_memosize(vorbis_info_floor *i){
+/* initialize Bark scale and normalization lookups. We could do this
+ with static tables, but Vorbis allows a number of possible
+ combinations, so it's best to do it computationally.
+
+ The below is authoritative in terms of defining scale mapping.
+ Note that the scale depends on the sampling rate as well as the
+ linear block and mapping sizes */
+
+static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi,
+ vorbis_info_floor *i){
+ int j;
+ vorbis_info *vi=vd->vi;
+ codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
- return info->order+1;
+ vorbis_look_floor0 *look=(vorbis_look_floor0 *)_ogg_calloc(1,sizeof(*look));
+ look->m=info->order;
+ look->n=ci->blocksizes[mi->blockflag]/2;
+ look->ln=info->barkmap;
+ look->vi=info;
+
+ /* the mapping from a linear scale to a smaller bark scale is
+ straightforward. We do *not* make sure that the linear mapping
+ does not skip bark-scale bins; the decoder simply skips them and
+ the encoder may do what it wishes in filling them. They're
+ necessary in some mapping combinations to keep the scale spacing
+ accurate */
+ look->linearmap=(int *)_ogg_malloc((look->n+1)*sizeof(*look->linearmap));
+ for(j=0;jn;j++){
+
+ int val=(look->ln*
+ ((toBARK(info->rate/2*j/look->n)<<11)/toBARK(info->rate/2)))>>11;
+
+ if(val>=look->ln)val=look->ln-1; /* guard against the approximation */
+ look->linearmap[j]=val;
+ }
+ look->linearmap[j]=-1;
+
+ look->lsp_look=(ogg_int32_t *)_ogg_malloc(look->ln*sizeof(*look->lsp_look));
+ for(j=0;jln;j++)
+ look->lsp_look[j]=vorbis_coslook2_i(0x10000*j/look->ln);
+
+ return look;
}
-ogg_int32_t *floor0_inverse1(vorbis_dsp_state *vd,vorbis_info_floor *i,
- ogg_int32_t *lsp){
- vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
+static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
+ vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
+ vorbis_info_floor0 *info=look->vi;
int j,k;
- int ampraw=oggpack_read(&vd->opb,info->ampbits);
+ int ampraw=oggpack_read(&vb->opb,info->ampbits);
if(ampraw>0){ /* also handles the -1 out of data case */
long maxval=(1<ampbits)-1;
int amp=((ampraw*info->ampdB)<<4)/maxval;
- int booknum=oggpack_read(&vd->opb,_ilog(info->numbooks));
+ int booknum=oggpack_read(&vb->opb,_ilog(info->numbooks));
if(booknum!=-1 && booknumnumbooks){ /* be paranoid */
- codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup;
- codebook *b=ci->book_param+info->books[booknum];
+ codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup;
+ codebook *b=ci->fullbooks+info->books[booknum];
ogg_int32_t last=0;
+ ogg_int32_t *lsp=(ogg_int32_t *)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1));
- for(j=0;jorder;j+=b->dim)
- if(vorbis_book_decodev_set(b,lsp+j,&vd->opb,b->dim,-24)==-1)goto eop;
- for(j=0;jorder;){
+ for(j=0;jm;j+=b->dim)
+ if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim,-24)==-1)goto eop;
+ for(j=0;jm;){
for(k=0;kdim;k++,j++)lsp[j]+=last;
last=lsp[j-1];
}
- lsp[info->order]=amp;
+ lsp[look->m]=amp;
return(lsp);
}
}
@@ -408,21 +408,28 @@
return(NULL);
}
-int floor0_inverse2(vorbis_dsp_state *vd,vorbis_info_floor *i,
- ogg_int32_t *lsp,ogg_int32_t *out){
- vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
- codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup;
+static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
+ void *memo,ogg_int32_t *out){
+ vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
+ vorbis_info_floor0 *info=look->vi;
- if(lsp){
- ogg_int32_t amp=lsp[info->order];
+ if(memo){
+ ogg_int32_t *lsp=(ogg_int32_t *)memo;
+ ogg_int32_t amp=lsp[look->m];
/* take the coefficients back to a spectral envelope curve */
- vorbis_lsp_to_curve(out,ci->blocksizes[vd->W]/2,info->barkmap,
- lsp,info->order,amp,info->ampdB,
- info->rate>>1);
+ vorbis_lsp_to_curve(out,look->linearmap,look->n,look->ln,
+ lsp,look->m,amp,info->ampdB,look->lsp_look);
return(1);
}
- memset(out,0,sizeof(*out)*ci->blocksizes[vd->W]/2);
+ memset(out,0,sizeof(*out)*look->n);
return(0);
}
+/* export hooks */
+vorbis_func_floor floor0_exportbundle={
+ &floor0_unpack,&floor0_look,&floor0_free_info,
+ &floor0_free_look,&floor0_inverse1,&floor0_inverse2
+};
+
+
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/floor1.c
--- a/misc/libtremor/tremor/floor1.c Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/floor1.c Sat Nov 03 00:34:35 2012 +0400
@@ -6,7 +6,7 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
- * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
+ * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
@@ -21,29 +21,44 @@
#include "ogg.h"
#include "ivorbiscodec.h"
#include "codec_internal.h"
+#include "registry.h"
#include "codebook.h"
#include "misc.h"
+#include "block.h"
-extern const ogg_int32_t FLOOR_fromdB_LOOKUP[];
#define floor1_rangedB 140 /* floor 1 fixed at -140dB to 0dB range */
-#define VIF_POSIT 63
+
+typedef struct {
+ int forward_index[VIF_POSIT+2];
+
+ int hineighbor[VIF_POSIT];
+ int loneighbor[VIF_POSIT];
+ int posts;
+
+ int n;
+ int quant_q;
+ vorbis_info_floor1 *vi;
+
+} vorbis_look_floor1;
/***********************************************/
-void floor1_free_info(vorbis_info_floor *i){
+static void floor1_free_info(vorbis_info_floor *i){
vorbis_info_floor1 *info=(vorbis_info_floor1 *)i;
if(info){
- if(info->class)_ogg_free(info->class);
- if(info->partitionclass)_ogg_free(info->partitionclass);
- if(info->postlist)_ogg_free(info->postlist);
- if(info->forward_index)_ogg_free(info->forward_index);
- if(info->hineighbor)_ogg_free(info->hineighbor);
- if(info->loneighbor)_ogg_free(info->loneighbor);
memset(info,0,sizeof(*info));
_ogg_free(info);
}
}
+static void floor1_free_look(vorbis_look_floor *i){
+ vorbis_look_floor1 *look=(vorbis_look_floor1 *)i;
+ if(look){
+ memset(look,0,sizeof(*look));
+ _ogg_free(look);
+ }
+}
+
static int ilog(unsigned int v){
int ret=0;
while(v){
@@ -53,41 +68,31 @@
return(ret);
}
-static int icomp(const void *a,const void *b){
- return(**(ogg_uint16_t **)a-**(ogg_uint16_t **)b);
-}
-
-vorbis_info_floor *floor1_info_unpack (vorbis_info *vi,oggpack_buffer *opb){
+static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
int j,k,count=0,maxclass=-1,rangebits;
- ogg_uint16_t *sortpointer[VIF_POSIT+2];
-
+
vorbis_info_floor1 *info=(vorbis_info_floor1 *)_ogg_calloc(1,sizeof(*info));
/* read partitions */
info->partitions=oggpack_read(opb,5); /* only 0 to 31 legal */
- info->partitionclass=
- (char *)_ogg_malloc(info->partitions*sizeof(*info->partitionclass));
for(j=0;jpartitions;j++){
info->partitionclass[j]=oggpack_read(opb,4); /* only 0 to 15 legal */
if(maxclasspartitionclass[j])maxclass=info->partitionclass[j];
}
/* read partition classes */
- info->class=
- (floor1class *)_ogg_malloc((maxclass+1)*sizeof(*info->class));
for(j=0;jclass[j].class_dim=oggpack_read(opb,3)+1; /* 1 to 8 */
- info->class[j].class_subs=oggpack_read(opb,2); /* 0,1,2,3 bits */
- if(oggpack_eop(opb)<0) goto err_out;
- if(info->class[j].class_subs)
- info->class[j].class_book=oggpack_read(opb,8);
- else
- info->class[j].class_book=0;
- if(info->class[j].class_book>=ci->books)goto err_out;
- for(k=0;k<(1<class[j].class_subs);k++){
- info->class[j].class_subbook[k]=oggpack_read(opb,8)-1;
- if(info->class[j].class_subbook[k]>=ci->books &&
- info->class[j].class_subbook[k]!=0xff)goto err_out;
+ info->class_dim[j]=oggpack_read(opb,3)+1; /* 1 to 8 */
+ info->class_subs[j]=oggpack_read(opb,2); /* 0,1,2,3 bits */
+ if(info->class_subs[j]<0)
+ goto err_out;
+ if(info->class_subs[j])info->class_book[j]=oggpack_read(opb,8);
+ if(info->class_book[j]<0 || info->class_book[j]>=ci->books)
+ goto err_out;
+ for(k=0;k<(1<class_subs[j]);k++){
+ info->class_subbook[j][k]=oggpack_read(opb,8)-1;
+ if(info->class_subbook[j][k]<-1 || info->class_subbook[j][k]>=ci->books)
+ goto err_out;
}
}
@@ -95,61 +100,16 @@
info->mult=oggpack_read(opb,2)+1; /* only 1,2,3,4 legal now */
rangebits=oggpack_read(opb,4);
- for(j=0,k=0;jpartitions;j++)
- count+=info->class[info->partitionclass[j]].class_dim;
- info->postlist=
- (ogg_uint16_t *)_ogg_malloc((count+2)*sizeof(*info->postlist));
- info->forward_index=
- (char *)_ogg_malloc((count+2)*sizeof(*info->forward_index));
- info->loneighbor=
- (char *)_ogg_malloc(count*sizeof(*info->loneighbor));
- info->hineighbor=
- (char *)_ogg_malloc(count*sizeof(*info->hineighbor));
-
- count=0;
for(j=0,k=0;jpartitions;j++){
- count+=info->class[info->partitionclass[j]].class_dim;
- if(count>VIF_POSIT)goto err_out;
+ count+=info->class_dim[info->partitionclass[j]];
for(;kpostlist[k+2]=oggpack_read(opb,rangebits);
- if(t>=(1<=(1<postlist[0]=0;
info->postlist[1]=1<posts=count+2;
-
- /* also store a sorted position index */
- for(j=0;jposts;j++)sortpointer[j]=info->postlist+j;
- qsort(sortpointer,info->posts,sizeof(*sortpointer),icomp);
-
- /* points from sort order back to range number */
- for(j=0;jposts;j++)
- info->forward_index[j]=sortpointer[j]-info->postlist;
-
- /* discover our neighbors for decode where we don't use fit flags
- (that would push the neighbors outward) */
- for(j=0;jposts-2;j++){
- int lo=0;
- int hi=1;
- int lx=0;
- int hx=info->postlist[1];
- int currentx=info->postlist[j+2];
- for(k=0;kpostlist[k];
- if(x>lx && xcurrentx){
- hi=k;
- hx=x;
- }
- }
- info->loneighbor[j]=lo;
- info->hineighbor[j]=hi;
- }
return(info);
@@ -158,6 +118,81 @@
return(NULL);
}
+static int icomp(const void *a,const void *b){
+ return(**(int **)a-**(int **)b);
+}
+
+static vorbis_look_floor *floor1_look(vorbis_dsp_state *vd,vorbis_info_mode *mi,
+ vorbis_info_floor *in){
+
+ int *sortpointer[VIF_POSIT+2];
+ vorbis_info_floor1 *info=(vorbis_info_floor1 *)in;
+ vorbis_look_floor1 *look=(vorbis_look_floor1 *)_ogg_calloc(1,sizeof(*look));
+ int i,j,n=0;
+
+ look->vi=info;
+ look->n=info->postlist[1];
+
+ /* we drop each position value in-between already decoded values,
+ and use linear interpolation to predict each new value past the
+ edges. The positions are read in the order of the position
+ list... we precompute the bounding positions in the lookup. Of
+ course, the neighbors can change (if a position is declined), but
+ this is an initial mapping */
+
+ for(i=0;ipartitions;i++)n+=info->class_dim[info->partitionclass[i]];
+ n+=2;
+ look->posts=n;
+
+ /* also store a sorted position index */
+ for(i=0;ipostlist+i;
+ qsort(sortpointer,n,sizeof(*sortpointer),icomp);
+
+ /* points from sort order back to range number */
+ for(i=0;iforward_index[i]=sortpointer[i]-info->postlist;
+
+ /* quantize values to multiplier spec */
+ switch(info->mult){
+ case 1: /* 1024 -> 256 */
+ look->quant_q=256;
+ break;
+ case 2: /* 1024 -> 128 */
+ look->quant_q=128;
+ break;
+ case 3: /* 1024 -> 86 */
+ look->quant_q=86;
+ break;
+ case 4: /* 1024 -> 64 */
+ look->quant_q=64;
+ break;
+ }
+
+ /* discover our neighbors for decode where we don't use fit flags
+ (that would push the neighbors outward) */
+ for(i=0;in;
+ int currentx=info->postlist[i+2];
+ for(j=0;jpostlist[j];
+ if(x>lx && xcurrentx){
+ hi=j;
+ hx=x;
+ }
+ }
+ look->loneighbor[i]=lo;
+ look->hineighbor[i]=hi;
+ }
+
+ return(look);
+}
+
static int render_point(int x0,int x1,int y0,int y1,int x){
y0&=0x7fff; /* mask off flag */
y1&=0x7fff;
@@ -174,6 +209,79 @@
}
}
+#ifdef _LOW_ACCURACY_
+# define XdB(n) ((((n)>>8)+1)>>1)
+#else
+# define XdB(n) (n)
+#endif
+
+static const ogg_int32_t FLOOR_fromdB_LOOKUP[256]={
+ XdB(0x000000e5), XdB(0x000000f4), XdB(0x00000103), XdB(0x00000114),
+ XdB(0x00000126), XdB(0x00000139), XdB(0x0000014e), XdB(0x00000163),
+ XdB(0x0000017a), XdB(0x00000193), XdB(0x000001ad), XdB(0x000001c9),
+ XdB(0x000001e7), XdB(0x00000206), XdB(0x00000228), XdB(0x0000024c),
+ XdB(0x00000272), XdB(0x0000029b), XdB(0x000002c6), XdB(0x000002f4),
+ XdB(0x00000326), XdB(0x0000035a), XdB(0x00000392), XdB(0x000003cd),
+ XdB(0x0000040c), XdB(0x00000450), XdB(0x00000497), XdB(0x000004e4),
+ XdB(0x00000535), XdB(0x0000058c), XdB(0x000005e8), XdB(0x0000064a),
+ XdB(0x000006b3), XdB(0x00000722), XdB(0x00000799), XdB(0x00000818),
+ XdB(0x0000089e), XdB(0x0000092e), XdB(0x000009c6), XdB(0x00000a69),
+ XdB(0x00000b16), XdB(0x00000bcf), XdB(0x00000c93), XdB(0x00000d64),
+ XdB(0x00000e43), XdB(0x00000f30), XdB(0x0000102d), XdB(0x0000113a),
+ XdB(0x00001258), XdB(0x0000138a), XdB(0x000014cf), XdB(0x00001629),
+ XdB(0x0000179a), XdB(0x00001922), XdB(0x00001ac4), XdB(0x00001c82),
+ XdB(0x00001e5c), XdB(0x00002055), XdB(0x0000226f), XdB(0x000024ac),
+ XdB(0x0000270e), XdB(0x00002997), XdB(0x00002c4b), XdB(0x00002f2c),
+ XdB(0x0000323d), XdB(0x00003581), XdB(0x000038fb), XdB(0x00003caf),
+ XdB(0x000040a0), XdB(0x000044d3), XdB(0x0000494c), XdB(0x00004e10),
+ XdB(0x00005323), XdB(0x0000588a), XdB(0x00005e4b), XdB(0x0000646b),
+ XdB(0x00006af2), XdB(0x000071e5), XdB(0x0000794c), XdB(0x0000812e),
+ XdB(0x00008993), XdB(0x00009283), XdB(0x00009c09), XdB(0x0000a62d),
+ XdB(0x0000b0f9), XdB(0x0000bc79), XdB(0x0000c8b9), XdB(0x0000d5c4),
+ XdB(0x0000e3a9), XdB(0x0000f274), XdB(0x00010235), XdB(0x000112fd),
+ XdB(0x000124dc), XdB(0x000137e4), XdB(0x00014c29), XdB(0x000161bf),
+ XdB(0x000178bc), XdB(0x00019137), XdB(0x0001ab4a), XdB(0x0001c70e),
+ XdB(0x0001e4a1), XdB(0x0002041f), XdB(0x000225aa), XdB(0x00024962),
+ XdB(0x00026f6d), XdB(0x000297f0), XdB(0x0002c316), XdB(0x0002f109),
+ XdB(0x000321f9), XdB(0x00035616), XdB(0x00038d97), XdB(0x0003c8b4),
+ XdB(0x000407a7), XdB(0x00044ab2), XdB(0x00049218), XdB(0x0004de23),
+ XdB(0x00052f1e), XdB(0x0005855c), XdB(0x0005e135), XdB(0x00064306),
+ XdB(0x0006ab33), XdB(0x00071a24), XdB(0x0007904b), XdB(0x00080e20),
+ XdB(0x00089422), XdB(0x000922da), XdB(0x0009bad8), XdB(0x000a5cb6),
+ XdB(0x000b091a), XdB(0x000bc0b1), XdB(0x000c8436), XdB(0x000d5471),
+ XdB(0x000e3233), XdB(0x000f1e5f), XdB(0x001019e4), XdB(0x001125c1),
+ XdB(0x00124306), XdB(0x001372d5), XdB(0x0014b663), XdB(0x00160ef7),
+ XdB(0x00177df0), XdB(0x001904c1), XdB(0x001aa4f9), XdB(0x001c603d),
+ XdB(0x001e384f), XdB(0x00202f0f), XdB(0x0022467a), XdB(0x002480b1),
+ XdB(0x0026dff7), XdB(0x002966b3), XdB(0x002c1776), XdB(0x002ef4fc),
+ XdB(0x0032022d), XdB(0x00354222), XdB(0x0038b828), XdB(0x003c67c2),
+ XdB(0x004054ae), XdB(0x004482e8), XdB(0x0048f6af), XdB(0x004db488),
+ XdB(0x0052c142), XdB(0x005821ff), XdB(0x005ddc33), XdB(0x0063f5b0),
+ XdB(0x006a74a7), XdB(0x00715faf), XdB(0x0078bdce), XdB(0x0080967f),
+ XdB(0x0088f1ba), XdB(0x0091d7f9), XdB(0x009b5247), XdB(0x00a56a41),
+ XdB(0x00b02a27), XdB(0x00bb9ce2), XdB(0x00c7ce12), XdB(0x00d4ca17),
+ XdB(0x00e29e20), XdB(0x00f15835), XdB(0x0101074b), XdB(0x0111bb4e),
+ XdB(0x01238531), XdB(0x01367704), XdB(0x014aa402), XdB(0x016020a7),
+ XdB(0x017702c3), XdB(0x018f6190), XdB(0x01a955cb), XdB(0x01c4f9cf),
+ XdB(0x01e269a8), XdB(0x0201c33b), XdB(0x0223265a), XdB(0x0246b4ea),
+ XdB(0x026c9302), XdB(0x0294e716), XdB(0x02bfda13), XdB(0x02ed9793),
+ XdB(0x031e4e09), XdB(0x03522ee4), XdB(0x03896ed0), XdB(0x03c445e2),
+ XdB(0x0402efd6), XdB(0x0445ac4b), XdB(0x048cbefc), XdB(0x04d87013),
+ XdB(0x05290c67), XdB(0x057ee5ca), XdB(0x05da5364), XdB(0x063bb204),
+ XdB(0x06a36485), XdB(0x0711d42b), XdB(0x0787710e), XdB(0x0804b299),
+ XdB(0x088a17ef), XdB(0x0918287e), XdB(0x09af747c), XdB(0x0a50957e),
+ XdB(0x0afc2f19), XdB(0x0bb2ef7f), XdB(0x0c759034), XdB(0x0d44d6ca),
+ XdB(0x0e2195bc), XdB(0x0f0cad0d), XdB(0x10070b62), XdB(0x1111aeea),
+ XdB(0x122da66c), XdB(0x135c120f), XdB(0x149e24d9), XdB(0x15f525b1),
+ XdB(0x176270e3), XdB(0x18e7794b), XdB(0x1a85c9ae), XdB(0x1c3f06d1),
+ XdB(0x1e14f07d), XdB(0x200963d7), XdB(0x221e5ccd), XdB(0x2455f870),
+ XdB(0x26b2770b), XdB(0x29363e2b), XdB(0x2be3db5c), XdB(0x2ebe06b6),
+ XdB(0x31c7a55b), XdB(0x3503ccd4), XdB(0x3875c5aa), XdB(0x3c210f44),
+ XdB(0x4009632b), XdB(0x4432b8cf), XdB(0x48a149bc), XdB(0x4d59959e),
+ XdB(0x52606733), XdB(0x57bad899), XdB(0x5d6e593a), XdB(0x6380b298),
+ XdB(0x69f80e9a), XdB(0x70dafda8), XdB(0x78307d76), XdB(0x7fffffff),
+};
+
static void render_line(int n, int x0,int x1,int y0,int y1,ogg_int32_t *d){
int dy=y1-y0;
int adx=x1-x0;
@@ -202,48 +310,42 @@
}
}
-int floor1_memosize(vorbis_info_floor *i){
- vorbis_info_floor1 *info=(vorbis_info_floor1 *)i;
- return info->posts;
-}
-
-static int quant_look[4]={256,128,86,64};
-
-ogg_int32_t *floor1_inverse1(vorbis_dsp_state *vd,vorbis_info_floor *in,
- ogg_int32_t *fit_value){
- vorbis_info_floor1 *info=(vorbis_info_floor1 *)in;
- codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup;
+static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){
+ vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
+ vorbis_info_floor1 *info=look->vi;
+ codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup;
int i,j,k;
- codebook *books=ci->book_param;
- int quant_q=quant_look[info->mult-1];
-
+ codebook *books=ci->fullbooks;
+
/* unpack wrapped/predicted values from stream */
- if(oggpack_read(&vd->opb,1)==1){
- fit_value[0]=oggpack_read(&vd->opb,ilog(quant_q-1));
- fit_value[1]=oggpack_read(&vd->opb,ilog(quant_q-1));
+ if(oggpack_read(&vb->opb,1)==1){
+ int *fit_value=(int *)_vorbis_block_alloc(vb,(look->posts)*sizeof(*fit_value));
+
+ fit_value[0]=oggpack_read(&vb->opb,ilog(look->quant_q-1));
+ fit_value[1]=oggpack_read(&vb->opb,ilog(look->quant_q-1));
/* partition by partition */
/* partition by partition */
for(i=0,j=2;ipartitions;i++){
int classv=info->partitionclass[i];
- int cdim=info->class[classv].class_dim;
- int csubbits=info->class[classv].class_subs;
+ int cdim=info->class_dim[classv];
+ int csubbits=info->class_subs[classv];
int csub=1<class[classv].class_book,&vd->opb);
+ cval=vorbis_book_decode(books+info->class_book[classv],&vb->opb);
if(cval==-1)goto eop;
}
for(k=0;kclass[classv].class_subbook[cval&(csub-1)];
+ int book=info->class_subbook[classv][cval&(csub-1)];
cval>>=csubbits;
- if(book!=0xff){
- if((fit_value[j+k]=vorbis_book_decode(books+book,&vd->opb))==-1)
+ if(book>=0){
+ if((fit_value[j+k]=vorbis_book_decode(books+book,&vb->opb))==-1)
goto eop;
}else{
fit_value[j+k]=0;
@@ -253,13 +355,13 @@
}
/* unwrap positive values and reconsitute via linear interpolation */
- for(i=2;iposts;i++){
- int predicted=render_point(info->postlist[info->loneighbor[i-2]],
- info->postlist[info->hineighbor[i-2]],
- fit_value[info->loneighbor[i-2]],
- fit_value[info->hineighbor[i-2]],
+ for(i=2;iposts;i++){
+ int predicted=render_point(info->postlist[look->loneighbor[i-2]],
+ info->postlist[look->hineighbor[i-2]],
+ fit_value[look->loneighbor[i-2]],
+ fit_value[look->hineighbor[i-2]],
info->postlist[i]);
- int hiroom=quant_q-predicted;
+ int hiroom=look->quant_q-predicted;
int loroom=predicted;
int room=(hiroomloneighbor[i-2]]&=0x7fff;
- fit_value[info->hineighbor[i-2]]&=0x7fff;
+ fit_value[look->loneighbor[i-2]]&=0x7fff;
+ fit_value[look->hineighbor[i-2]]&=0x7fff;
}else{
fit_value[i]=predicted|0x8000;
@@ -295,21 +397,23 @@
return(NULL);
}
-int floor1_inverse2(vorbis_dsp_state *vd,vorbis_info_floor *in,
- ogg_int32_t *fit_value,ogg_int32_t *out){
- vorbis_info_floor1 *info=(vorbis_info_floor1 *)in;
+static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo,
+ ogg_int32_t *out){
+ vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
+ vorbis_info_floor1 *info=look->vi;
- codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup;
- int n=ci->blocksizes[vd->W]/2;
+ codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup;
+ int n=ci->blocksizes[vb->W]/2;
int j;
- if(fit_value){
+ if(memo){
/* render the lines */
+ int *fit_value=(int *)memo;
int hx=0;
int lx=0;
int ly=fit_value[0]*info->mult;
- for(j=1;jposts;j++){
- int current=info->forward_index[j];
+ for(j=1;jposts;j++){
+ int current=look->forward_index[j];
int hy=fit_value[current]&0x7fff;
if(hy==fit_value[current]){
@@ -328,3 +432,10 @@
memset(out,0,sizeof(*out)*n);
return(0);
}
+
+/* export hooks */
+vorbis_func_floor floor1_exportbundle={
+ &floor1_unpack,&floor1_look,&floor1_free_info,
+ &floor1_free_look,&floor1_inverse1,&floor1_inverse2
+};
+
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/floor_lookup.c
--- a/misc/libtremor/tremor/floor_lookup.c Sun Oct 21 01:28:33 2012 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-/********************************************************************
- * *
- * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
- * *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
- * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
- * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
- * *
- * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
- * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
- * *
- ********************************************************************
-
- function: floor dB lookup
-
- ********************************************************************/
-
-#include "os.h"
-
-#ifdef _LOW_ACCURACY_
-# define XdB(n) ((((n)>>8)+1)>>1)
-#else
-# define XdB(n) (n)
-#endif
-
-const ogg_int32_t FLOOR_fromdB_LOOKUP[256]={
- XdB(0x000000e5), XdB(0x000000f4), XdB(0x00000103), XdB(0x00000114),
- XdB(0x00000126), XdB(0x00000139), XdB(0x0000014e), XdB(0x00000163),
- XdB(0x0000017a), XdB(0x00000193), XdB(0x000001ad), XdB(0x000001c9),
- XdB(0x000001e7), XdB(0x00000206), XdB(0x00000228), XdB(0x0000024c),
- XdB(0x00000272), XdB(0x0000029b), XdB(0x000002c6), XdB(0x000002f4),
- XdB(0x00000326), XdB(0x0000035a), XdB(0x00000392), XdB(0x000003cd),
- XdB(0x0000040c), XdB(0x00000450), XdB(0x00000497), XdB(0x000004e4),
- XdB(0x00000535), XdB(0x0000058c), XdB(0x000005e8), XdB(0x0000064a),
- XdB(0x000006b3), XdB(0x00000722), XdB(0x00000799), XdB(0x00000818),
- XdB(0x0000089e), XdB(0x0000092e), XdB(0x000009c6), XdB(0x00000a69),
- XdB(0x00000b16), XdB(0x00000bcf), XdB(0x00000c93), XdB(0x00000d64),
- XdB(0x00000e43), XdB(0x00000f30), XdB(0x0000102d), XdB(0x0000113a),
- XdB(0x00001258), XdB(0x0000138a), XdB(0x000014cf), XdB(0x00001629),
- XdB(0x0000179a), XdB(0x00001922), XdB(0x00001ac4), XdB(0x00001c82),
- XdB(0x00001e5c), XdB(0x00002055), XdB(0x0000226f), XdB(0x000024ac),
- XdB(0x0000270e), XdB(0x00002997), XdB(0x00002c4b), XdB(0x00002f2c),
- XdB(0x0000323d), XdB(0x00003581), XdB(0x000038fb), XdB(0x00003caf),
- XdB(0x000040a0), XdB(0x000044d3), XdB(0x0000494c), XdB(0x00004e10),
- XdB(0x00005323), XdB(0x0000588a), XdB(0x00005e4b), XdB(0x0000646b),
- XdB(0x00006af2), XdB(0x000071e5), XdB(0x0000794c), XdB(0x0000812e),
- XdB(0x00008993), XdB(0x00009283), XdB(0x00009c09), XdB(0x0000a62d),
- XdB(0x0000b0f9), XdB(0x0000bc79), XdB(0x0000c8b9), XdB(0x0000d5c4),
- XdB(0x0000e3a9), XdB(0x0000f274), XdB(0x00010235), XdB(0x000112fd),
- XdB(0x000124dc), XdB(0x000137e4), XdB(0x00014c29), XdB(0x000161bf),
- XdB(0x000178bc), XdB(0x00019137), XdB(0x0001ab4a), XdB(0x0001c70e),
- XdB(0x0001e4a1), XdB(0x0002041f), XdB(0x000225aa), XdB(0x00024962),
- XdB(0x00026f6d), XdB(0x000297f0), XdB(0x0002c316), XdB(0x0002f109),
- XdB(0x000321f9), XdB(0x00035616), XdB(0x00038d97), XdB(0x0003c8b4),
- XdB(0x000407a7), XdB(0x00044ab2), XdB(0x00049218), XdB(0x0004de23),
- XdB(0x00052f1e), XdB(0x0005855c), XdB(0x0005e135), XdB(0x00064306),
- XdB(0x0006ab33), XdB(0x00071a24), XdB(0x0007904b), XdB(0x00080e20),
- XdB(0x00089422), XdB(0x000922da), XdB(0x0009bad8), XdB(0x000a5cb6),
- XdB(0x000b091a), XdB(0x000bc0b1), XdB(0x000c8436), XdB(0x000d5471),
- XdB(0x000e3233), XdB(0x000f1e5f), XdB(0x001019e4), XdB(0x001125c1),
- XdB(0x00124306), XdB(0x001372d5), XdB(0x0014b663), XdB(0x00160ef7),
- XdB(0x00177df0), XdB(0x001904c1), XdB(0x001aa4f9), XdB(0x001c603d),
- XdB(0x001e384f), XdB(0x00202f0f), XdB(0x0022467a), XdB(0x002480b1),
- XdB(0x0026dff7), XdB(0x002966b3), XdB(0x002c1776), XdB(0x002ef4fc),
- XdB(0x0032022d), XdB(0x00354222), XdB(0x0038b828), XdB(0x003c67c2),
- XdB(0x004054ae), XdB(0x004482e8), XdB(0x0048f6af), XdB(0x004db488),
- XdB(0x0052c142), XdB(0x005821ff), XdB(0x005ddc33), XdB(0x0063f5b0),
- XdB(0x006a74a7), XdB(0x00715faf), XdB(0x0078bdce), XdB(0x0080967f),
- XdB(0x0088f1ba), XdB(0x0091d7f9), XdB(0x009b5247), XdB(0x00a56a41),
- XdB(0x00b02a27), XdB(0x00bb9ce2), XdB(0x00c7ce12), XdB(0x00d4ca17),
- XdB(0x00e29e20), XdB(0x00f15835), XdB(0x0101074b), XdB(0x0111bb4e),
- XdB(0x01238531), XdB(0x01367704), XdB(0x014aa402), XdB(0x016020a7),
- XdB(0x017702c3), XdB(0x018f6190), XdB(0x01a955cb), XdB(0x01c4f9cf),
- XdB(0x01e269a8), XdB(0x0201c33b), XdB(0x0223265a), XdB(0x0246b4ea),
- XdB(0x026c9302), XdB(0x0294e716), XdB(0x02bfda13), XdB(0x02ed9793),
- XdB(0x031e4e09), XdB(0x03522ee4), XdB(0x03896ed0), XdB(0x03c445e2),
- XdB(0x0402efd6), XdB(0x0445ac4b), XdB(0x048cbefc), XdB(0x04d87013),
- XdB(0x05290c67), XdB(0x057ee5ca), XdB(0x05da5364), XdB(0x063bb204),
- XdB(0x06a36485), XdB(0x0711d42b), XdB(0x0787710e), XdB(0x0804b299),
- XdB(0x088a17ef), XdB(0x0918287e), XdB(0x09af747c), XdB(0x0a50957e),
- XdB(0x0afc2f19), XdB(0x0bb2ef7f), XdB(0x0c759034), XdB(0x0d44d6ca),
- XdB(0x0e2195bc), XdB(0x0f0cad0d), XdB(0x10070b62), XdB(0x1111aeea),
- XdB(0x122da66c), XdB(0x135c120f), XdB(0x149e24d9), XdB(0x15f525b1),
- XdB(0x176270e3), XdB(0x18e7794b), XdB(0x1a85c9ae), XdB(0x1c3f06d1),
- XdB(0x1e14f07d), XdB(0x200963d7), XdB(0x221e5ccd), XdB(0x2455f870),
- XdB(0x26b2770b), XdB(0x29363e2b), XdB(0x2be3db5c), XdB(0x2ebe06b6),
- XdB(0x31c7a55b), XdB(0x3503ccd4), XdB(0x3875c5aa), XdB(0x3c210f44),
- XdB(0x4009632b), XdB(0x4432b8cf), XdB(0x48a149bc), XdB(0x4d59959e),
- XdB(0x52606733), XdB(0x57bad899), XdB(0x5d6e593a), XdB(0x6380b298),
- XdB(0x69f80e9a), XdB(0x70dafda8), XdB(0x78307d76), XdB(0x7fffffff),
-};
-
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/framing.c
--- a/misc/libtremor/tremor/framing.c Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/framing.c Sat Nov 03 00:34:35 2012 +0400
@@ -156,11 +156,19 @@
}
/* duplicate a reference (pointing to the same actual buffer memory)
- and increment buffer refcount. If the desired segment is zero
- length, a zero length ref is returned. */
-static ogg_reference *ogg_buffer_sub(ogg_reference *or,long length){
+ and increment buffer refcount. If the desired segment begins out
+ of range, NULL is returned; if the desired segment is simply zero
+ length, a zero length ref is returned. Partial range overlap
+ returns the overlap of the ranges */
+static ogg_reference *ogg_buffer_sub(ogg_reference *or,long begin,long length){
ogg_reference *ret=0,*head=0;
-
+
+ /* walk past any preceeding fragments we don't want */
+ while(or && begin>=or->length){
+ begin-=or->length;
+ or=or->next;
+ }
+
/* duplicate the reference chain; increment refcounts */
while(or && length){
ogg_reference *temp=_fetch_ref(or->buffer->ptr.owner);
@@ -170,11 +178,12 @@
ret=temp;
head=temp;
head->buffer=or->buffer;
- head->begin=or->begin;
+ head->begin=or->begin+begin;
head->length=length;
- if(head->length>or->length)
- head->length=or->length;
+ if(head->length>or->length-begin)
+ head->length=or->length-begin;
+ begin=0;
length-=head->length;
or=or->next;
}
@@ -418,43 +427,43 @@
int ogg_page_version(ogg_page *og){
oggbyte_buffer ob;
- if(oggbyte_init(&ob,og->header))return -1;
+ oggbyte_init(&ob,og->header);
return oggbyte_read1(&ob,4);
}
int ogg_page_continued(ogg_page *og){
oggbyte_buffer ob;
- if(oggbyte_init(&ob,og->header))return -1;
+ oggbyte_init(&ob,og->header);
return oggbyte_read1(&ob,5)&0x01;
}
int ogg_page_bos(ogg_page *og){
oggbyte_buffer ob;
- if(oggbyte_init(&ob,og->header))return -1;
+ oggbyte_init(&ob,og->header);
return oggbyte_read1(&ob,5)&0x02;
}
int ogg_page_eos(ogg_page *og){
oggbyte_buffer ob;
- if(oggbyte_init(&ob,og->header))return -1;
+ oggbyte_init(&ob,og->header);
return oggbyte_read1(&ob,5)&0x04;
}
ogg_int64_t ogg_page_granulepos(ogg_page *og){
oggbyte_buffer ob;
- if(oggbyte_init(&ob,og->header))return -1;
+ oggbyte_init(&ob,og->header);
return oggbyte_read8(&ob,6);
}
ogg_uint32_t ogg_page_serialno(ogg_page *og){
oggbyte_buffer ob;
- if(oggbyte_init(&ob,og->header)) return 0xffffffffUL;
+ oggbyte_init(&ob,og->header);
return oggbyte_read4(&ob,14);
}
ogg_uint32_t ogg_page_pageno(ogg_page *og){
oggbyte_buffer ob;
- if(oggbyte_init(&ob,og->header))return 0xffffffffUL;
+ oggbyte_init(&ob,og->header);
return oggbyte_read4(&ob,18);
}
@@ -1070,7 +1079,7 @@
_next_lace(&ob,os);
}else{
if(op){
- op->packet=ogg_buffer_sub(os->body_tail,os->body_fill&FINMASK);
+ op->packet=ogg_buffer_sub(os->body_tail,0,os->body_fill&FINMASK);
op->bytes=os->body_fill&FINMASK;
}
}
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/info.c
--- a/misc/libtremor/tremor/info.c Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/info.c Sat Nov 03 00:34:35 2012 +0400
@@ -25,8 +25,9 @@
#include "ivorbiscodec.h"
#include "codec_internal.h"
#include "codebook.h"
+#include "registry.h"
+#include "window.h"
#include "misc.h"
-#include "os.h"
/* helpers */
static void _v_readstring(oggpack_buffer *o,char *buf,int bytes){
@@ -95,8 +96,8 @@
if(vc->user_comments)_ogg_free(vc->user_comments);
if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
if(vc->vendor)_ogg_free(vc->vendor);
+ memset(vc,0,sizeof(*vc));
}
- memset(vc,0,sizeof(*vc));
}
/* blocksize 0 is guaranteed to be short, 1 is guarantted to be long.
@@ -118,35 +119,31 @@
if(ci){
- if(ci->mode_param)_ogg_free(ci->mode_param);
+ for(i=0;imodes;i++)
+ if(ci->mode_param[i])_ogg_free(ci->mode_param[i]);
- if(ci->map_param){
- for(i=0;imaps;i++) /* unpack does the range checking */
- mapping_clear_info(ci->map_param+i);
- _ogg_free(ci->map_param);
- }
+ for(i=0;imaps;i++) /* unpack does the range checking */
+ if(ci->map_param[i])
+ _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]);
- if(ci->floor_param){
- for(i=0;ifloors;i++) /* unpack does the range checking */
- if(ci->floor_type[i])
- floor1_free_info(ci->floor_param[i]);
- else
- floor0_free_info(ci->floor_param[i]);
- _ogg_free(ci->floor_param);
- _ogg_free(ci->floor_type);
- }
+ for(i=0;ifloors;i++) /* unpack does the range checking */
+ if(ci->floor_param[i])
+ _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
+
+ for(i=0;iresidues;i++) /* unpack does the range checking */
+ if(ci->residue_param[i])
+ _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]);
- if(ci->residue_param){
- for(i=0;iresidues;i++) /* unpack does the range checking */
- res_clear_info(ci->residue_param+i);
- _ogg_free(ci->residue_param);
+ for(i=0;ibooks;i++){
+ if(ci->book_param[i]){
+ /* knows if the book was not alloced */
+ vorbis_staticbook_destroy(ci->book_param[i]);
+ }
+ if(ci->fullbooks)
+ vorbis_book_clear(ci->fullbooks+i);
}
-
- if(ci->book_param){
- for(i=0;ibooks;i++)
- vorbis_book_clear(ci->book_param+i);
- _ogg_free(ci->book_param);
- }
+ if(ci->fullbooks)
+ _ogg_free(ci->fullbooks);
_ogg_free(ci);
}
@@ -222,53 +219,70 @@
/* codebooks */
ci->books=oggpack_read(opb,8)+1;
- ci->book_param=(codebook *)_ogg_calloc(ci->books,sizeof(*ci->book_param));
- for(i=0;ibooks;i++)
- if(vorbis_book_unpack(opb,ci->book_param+i))goto err_out;
+ /*ci->book_param=_ogg_calloc(ci->books,sizeof(*ci->book_param));*/
+ for(i=0;ibooks;i++){
+ ci->book_param[i]=(static_codebook *)_ogg_calloc(1,sizeof(*ci->book_param[i]));
+ if(vorbis_staticbook_unpack(opb,ci->book_param[i]))goto err_out;
+ }
- /* time backend settings, not actually used */
- i=oggpack_read(opb,6);
- for(;i>=0;i--)
- if(oggpack_read(opb,16)!=0)goto err_out;
+ /* time backend settings */
+ ci->times=oggpack_read(opb,6)+1;
+ /*ci->time_type=_ogg_malloc(ci->times*sizeof(*ci->time_type));*/
+ /*ci->time_param=_ogg_calloc(ci->times,sizeof(void *));*/
+ for(i=0;itimes;i++){
+ ci->time_type[i]=oggpack_read(opb,16);
+ if(ci->time_type[i]<0 || ci->time_type[i]>=VI_TIMEB)goto err_out;
+ /* ci->time_param[i]=_time_P[ci->time_type[i]]->unpack(vi,opb);
+ Vorbis I has no time backend */
+ /*if(!ci->time_param[i])goto err_out;*/
+ }
/* floor backend settings */
ci->floors=oggpack_read(opb,6)+1;
- ci->floor_param=_ogg_malloc(sizeof(*ci->floor_param)*ci->floors);
- ci->floor_type=_ogg_malloc(sizeof(*ci->floor_type)*ci->floors);
+ /*ci->floor_type=_ogg_malloc(ci->floors*sizeof(*ci->floor_type));*/
+ /*ci->floor_param=_ogg_calloc(ci->floors,sizeof(void *));*/
for(i=0;ifloors;i++){
ci->floor_type[i]=oggpack_read(opb,16);
if(ci->floor_type[i]<0 || ci->floor_type[i]>=VI_FLOORB)goto err_out;
- if(ci->floor_type[i])
- ci->floor_param[i]=floor1_info_unpack(vi,opb);
- else
- ci->floor_param[i]=floor0_info_unpack(vi,opb);
+ ci->floor_param[i]=_floor_P[ci->floor_type[i]]->unpack(vi,opb);
if(!ci->floor_param[i])goto err_out;
}
/* residue backend settings */
ci->residues=oggpack_read(opb,6)+1;
- ci->residue_param=_ogg_malloc(sizeof(*ci->residue_param)*ci->residues);
- for(i=0;iresidues;i++)
- if(res_unpack(ci->residue_param+i,vi,opb))goto err_out;
+ /*ci->residue_type=_ogg_malloc(ci->residues*sizeof(*ci->residue_type));*/
+ /*ci->residue_param=_ogg_calloc(ci->residues,sizeof(void *));*/
+ for(i=0;iresidues;i++){
+ ci->residue_type[i]=oggpack_read(opb,16);
+ if(ci->residue_type[i]<0 || ci->residue_type[i]>=VI_RESB)goto err_out;
+ ci->residue_param[i]=_residue_P[ci->residue_type[i]]->unpack(vi,opb);
+ if(!ci->residue_param[i])goto err_out;
+ }
/* map backend settings */
ci->maps=oggpack_read(opb,6)+1;
- ci->map_param=_ogg_malloc(sizeof(*ci->map_param)*ci->maps);
+ /*ci->map_type=_ogg_malloc(ci->maps*sizeof(*ci->map_type));*/
+ /*ci->map_param=_ogg_calloc(ci->maps,sizeof(void *));*/
for(i=0;imaps;i++){
- if(oggpack_read(opb,16)!=0)goto err_out;
- if(mapping_info_unpack(ci->map_param+i,vi,opb))goto err_out;
+ ci->map_type[i]=oggpack_read(opb,16);
+ if(ci->map_type[i]<0 || ci->map_type[i]>=VI_MAPB)goto err_out;
+ ci->map_param[i]=_mapping_P[ci->map_type[i]]->unpack(vi,opb);
+ if(!ci->map_param[i])goto err_out;
}
/* mode settings */
ci->modes=oggpack_read(opb,6)+1;
- ci->mode_param=
- (vorbis_info_mode *)_ogg_malloc(ci->modes*sizeof(*ci->mode_param));
+ /*vi->mode_param=_ogg_calloc(vi->modes,sizeof(void *));*/
for(i=0;imodes;i++){
- ci->mode_param[i].blockflag=oggpack_read(opb,1);
- if(oggpack_read(opb,16))goto err_out;
- if(oggpack_read(opb,16))goto err_out;
- ci->mode_param[i].mapping=oggpack_read(opb,8);
- if(ci->mode_param[i].mapping>=ci->maps)goto err_out;
+ ci->mode_param[i]=(vorbis_info_mode *)_ogg_calloc(1,sizeof(*ci->mode_param[i]));
+ ci->mode_param[i]->blockflag=oggpack_read(opb,1);
+ ci->mode_param[i]->windowtype=oggpack_read(opb,16);
+ ci->mode_param[i]->transformtype=oggpack_read(opb,16);
+ ci->mode_param[i]->mapping=oggpack_read(opb,8);
+
+ if(ci->mode_param[i]->windowtype>=VI_WINDOWB)goto err_out;
+ if(ci->mode_param[i]->transformtype>=VI_WINDOWB)goto err_out;
+ if(ci->mode_param[i]->mapping>=ci->maps)goto err_out;
}
if(oggpack_read(opb,1)!=1)goto err_out; /* top level EOP check */
@@ -284,7 +298,7 @@
with bitstream comments and a third packet that holds the
codebook. */
-int vorbis_dsp_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op){
+int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op){
oggpack_buffer opb;
if(op){
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/ivorbiscodec.h
--- a/misc/libtremor/tremor/ivorbiscodec.h Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/ivorbiscodec.h Sat Nov 03 00:34:35 2012 +0400
@@ -25,9 +25,6 @@
#include "ogg.h"
-struct vorbis_dsp_state;
-typedef struct vorbis_dsp_state vorbis_dsp_state;
-
typedef struct vorbis_info{
int version;
int channels;
@@ -56,7 +53,80 @@
void *codec_setup;
} vorbis_info;
+/* vorbis_dsp_state buffers the current vorbis audio
+ analysis/synthesis state. The DSP state belongs to a specific
+ logical bitstream ****************************************************/
+typedef struct vorbis_dsp_state{
+ int analysisp;
+ vorbis_info *vi;
+
+ ogg_int32_t **pcm;
+ ogg_int32_t **pcmret;
+ int pcm_storage;
+ int pcm_current;
+ int pcm_returned;
+
+ int preextrapolate;
+ int eofflag;
+
+ long lW;
+ long W;
+ long nW;
+ long centerW;
+
+ ogg_int64_t granulepos;
+ ogg_int64_t sequence;
+
+ void *backend_state;
+} vorbis_dsp_state;
+
+typedef struct vorbis_block{
+ /* necessary stream state for linking to the framing abstraction */
+ ogg_int32_t **pcm; /* this is a pointer into local storage */
+ oggpack_buffer opb;
+
+ long lW;
+ long W;
+ long nW;
+ int pcmend;
+ int mode;
+
+ int eofflag;
+ ogg_int64_t granulepos;
+ ogg_int64_t sequence;
+ vorbis_dsp_state *vd; /* For read-only access of configuration */
+
+ /* local storage to avoid remallocing; it's up to the mapping to
+ structure it */
+ void *localstore;
+ long localtop;
+ long localalloc;
+ long totaluse;
+ struct alloc_chain *reap;
+
+} vorbis_block;
+
+/* vorbis_block is a single block of data to be processed as part of
+the analysis/synthesis stream; it belongs to a specific logical
+bitstream, but is independant from other vorbis_blocks belonging to
+that logical bitstream. *************************************************/
+
+struct alloc_chain{
+ void *ptr;
+ struct alloc_chain *next;
+};
+
+/* vorbis_info contains all the setup information specific to the
+ specific compression/decompression mode in progress (eg,
+ psychoacoustic settings, channel setup, options, codebook
+ etc). vorbis_info and substructures are in backends.h.
+*********************************************************************/
+
+/* the comments are not part of vorbis_info so that vorbis_info can be
+ static storage */
typedef struct vorbis_comment{
+ /* unlimited user comment fields. libvorbis writes 'libvorbis'
+ whatever vendor is set to in encode */
char **user_comments;
int *comment_lengths;
int comments;
@@ -65,6 +135,18 @@
} vorbis_comment;
+/* libvorbis encodes in two abstraction layers; first we perform DSP
+ and produce a packet (see docs/analysis.txt). The packet is then
+ coded into a framed OggSquish bitstream by the second layer (see
+ docs/framing.txt). Decode is the reverse process; we sync/frame
+ the bitstream and extract individual packets, then decode the
+ packet back into PCM audio.
+
+ The extra framing/packetizing is used in streaming formats, such as
+ files. Over the net (such as with UDP), the framing and
+ packetization aren't necessary as they're provided by the transport
+ and the streaming layer is not used */
+
/* Vorbis PRIMITIVES: general ***************************************/
extern void vorbis_info_init(vorbis_info *vi);
@@ -78,6 +160,22 @@
extern int vorbis_comment_query_count(vorbis_comment *vc, char *tag);
extern void vorbis_comment_clear(vorbis_comment *vc);
+extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
+extern int vorbis_block_clear(vorbis_block *vb);
+extern void vorbis_dsp_clear(vorbis_dsp_state *v);
+
+/* Vorbis PRIMITIVES: synthesis layer *******************************/
+extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,
+ ogg_packet *op);
+
+extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
+extern int vorbis_synthesis_restart(vorbis_dsp_state *v);
+extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep);
+extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
+extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm);
+extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples);
+extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op);
+
/* Vorbis ERRORS and return codes ***********************************/
#define OV_FALSE -1
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/ivorbisfile.h
--- a/misc/libtremor/tremor/ivorbisfile.h Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/ivorbisfile.h Sat Nov 03 00:34:35 2012 +0400
@@ -6,7 +6,7 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
- * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
+ * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
@@ -26,6 +26,7 @@
#include
#include "ivorbiscodec.h"
+#define CHUNKSIZE 1024
/* The function prototypes for the callbacks are basically the same as for
* the stdio functions fread, fseek, fclose, ftell.
* The one difference is that the FILE * arguments have been replaced with
@@ -43,6 +44,12 @@
long (*tell_func) (void *datasource);
} ov_callbacks;
+#define NOTOPEN 0
+#define PARTOPEN 1
+#define OPENED 2
+#define STREAMSET 3
+#define INITSET 4
+
typedef struct OggVorbis_File {
void *datasource; /* Pointer to a FILE *, etc. */
int seekable;
@@ -57,8 +64,8 @@
ogg_int64_t *dataoffsets;
ogg_uint32_t *serialnos;
ogg_int64_t *pcmlengths;
- vorbis_info vi;
- vorbis_comment vc;
+ vorbis_info *vi;
+ vorbis_comment *vc;
/* Decoding working state local storage */
ogg_int64_t pcm_offset;
@@ -71,7 +78,8 @@
ogg_stream_state *os; /* take physical pages, weld into a logical
stream of packets */
- vorbis_dsp_state *vd; /* central working state for the packet->PCM decoder */
+ vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
+ vorbis_block vb; /* local working space for packet->PCM decode */
ov_callbacks callbacks;
@@ -110,7 +118,7 @@
extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
-extern long ov_read(OggVorbis_File *vf,void *buffer,int length,
+extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
int *bitstream);
#ifdef __cplusplus
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/lsp_lookup.h
--- a/misc/libtremor/tremor/lsp_lookup.h Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/lsp_lookup.h Sat Nov 03 00:34:35 2012 +0400
@@ -20,6 +20,34 @@
#include "os_types.h"
+#define FROMdB_LOOKUP_SZ 35
+#define FROMdB2_LOOKUP_SZ 32
+#define FROMdB_SHIFT 5
+#define FROMdB2_SHIFT 3
+#define FROMdB2_MASK 31
+
+static const ogg_int32_t FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={
+ 0x003fffff, 0x0028619b, 0x00197a96, 0x0010137a,
+ 0x000a24b0, 0x00066666, 0x000409c3, 0x00028c42,
+ 0x00019b8c, 0x000103ab, 0x0000a3d7, 0x00006760,
+ 0x0000413a, 0x00002928, 0x000019f8, 0x00001062,
+ 0x00000a56, 0x00000686, 0x0000041e, 0x00000299,
+ 0x000001a3, 0x00000109, 0x000000a7, 0x00000069,
+ 0x00000042, 0x0000002a, 0x0000001a, 0x00000011,
+ 0x0000000b, 0x00000007, 0x00000004, 0x00000003,
+ 0x00000002, 0x00000001, 0x00000001};
+
+static const ogg_int32_t FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={
+ 0x000001fc, 0x000001f5, 0x000001ee, 0x000001e7,
+ 0x000001e0, 0x000001d9, 0x000001d2, 0x000001cc,
+ 0x000001c5, 0x000001bf, 0x000001b8, 0x000001b2,
+ 0x000001ac, 0x000001a6, 0x000001a0, 0x0000019a,
+ 0x00000194, 0x0000018e, 0x00000188, 0x00000183,
+ 0x0000017d, 0x00000178, 0x00000172, 0x0000016d,
+ 0x00000168, 0x00000163, 0x0000015e, 0x00000159,
+ 0x00000154, 0x0000014f, 0x0000014a, 0x00000145,
+};
+
#define INVSQ_LOOKUP_I_SHIFT 10
#define INVSQ_LOOKUP_I_MASK 1023
static const long INVSQ_LOOKUP_I[64+1]={
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/mapping0.c
--- a/misc/libtremor/tremor/mapping0.c Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/mapping0.c Sat Nov 03 00:34:35 2012 +0400
@@ -6,7 +6,7 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
- * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
+ * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
@@ -24,17 +24,96 @@
#include "mdct.h"
#include "codec_internal.h"
#include "codebook.h"
+#include "window.h"
+#include "registry.h"
#include "misc.h"
-void mapping_clear_info(vorbis_info_mapping *info){
+/* simplistic, wasteful way of doing this (unique lookup for each
+ mode/submapping); there should be a central repository for
+ identical lookups. That will require minor work, so I'm putting it
+ off as low priority.
+
+ Why a lookup for each backend in a given mode? Because the
+ blocksize is set by the mode, and low backend lookups may require
+ parameters from other areas of the mode/mapping */
+
+typedef struct {
+ vorbis_info_mode *mode;
+ vorbis_info_mapping0 *map;
+
+ vorbis_look_floor **floor_look;
+
+ vorbis_look_residue **residue_look;
+
+ vorbis_func_floor **floor_func;
+ vorbis_func_residue **residue_func;
+
+ int ch;
+ long lastframe; /* if a different mode is called, we need to
+ invalidate decay */
+} vorbis_look_mapping0;
+
+static void mapping0_free_info(vorbis_info_mapping *i){
+ vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)i;
if(info){
- if(info->chmuxlist)_ogg_free(info->chmuxlist);
- if(info->submaplist)_ogg_free(info->submaplist);
- if(info->coupling)_ogg_free(info->coupling);
memset(info,0,sizeof(*info));
+ _ogg_free(info);
}
}
+static void mapping0_free_look(vorbis_look_mapping *look){
+ int i;
+ vorbis_look_mapping0 *l=(vorbis_look_mapping0 *)look;
+ if(l){
+
+ for(i=0;imap->submaps;i++){
+ l->floor_func[i]->free_look(l->floor_look[i]);
+ l->residue_func[i]->free_look(l->residue_look[i]);
+ }
+
+ _ogg_free(l->floor_func);
+ _ogg_free(l->residue_func);
+ _ogg_free(l->floor_look);
+ _ogg_free(l->residue_look);
+ memset(l,0,sizeof(*l));
+ _ogg_free(l);
+ }
+}
+
+static vorbis_look_mapping *mapping0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
+ vorbis_info_mapping *m){
+ int i;
+ vorbis_info *vi=vd->vi;
+ codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
+ vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)_ogg_calloc(1,sizeof(*look));
+ vorbis_info_mapping0 *info=look->map=(vorbis_info_mapping0 *)m;
+ look->mode=vm;
+
+ look->floor_look=(vorbis_look_floor **)_ogg_calloc(info->submaps,sizeof(*look->floor_look));
+
+ look->residue_look=(vorbis_look_residue **)_ogg_calloc(info->submaps,sizeof(*look->residue_look));
+
+ look->floor_func=(vorbis_func_floor **)_ogg_calloc(info->submaps,sizeof(*look->floor_func));
+ look->residue_func=(vorbis_func_residue **)_ogg_calloc(info->submaps,sizeof(*look->residue_func));
+
+ for(i=0;isubmaps;i++){
+ int floornum=info->floorsubmap[i];
+ int resnum=info->residuesubmap[i];
+
+ look->floor_func[i]=_floor_P[ci->floor_type[floornum]];
+ look->floor_look[i]=look->floor_func[i]->
+ look(vd,vm,ci->floor_param[floornum]);
+ look->residue_func[i]=_residue_P[ci->residue_type[resnum]];
+ look->residue_look[i]=look->residue_func[i]->
+ look(vd,vm,ci->residue_param[resnum]);
+
+ }
+
+ look->ch=vi->channels;
+
+ return(look);
+}
+
static int ilog(unsigned int v){
int ret=0;
if(v)--v;
@@ -46,9 +125,9 @@
}
/* also responsible for range checking */
-int mapping_info_unpack(vorbis_info_mapping *info,vorbis_info *vi,
- oggpack_buffer *opb){
+static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb){
int i;
+ vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)_ogg_calloc(1,sizeof(*info));
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
memset(info,0,sizeof(*info));
@@ -59,12 +138,10 @@
if(oggpack_read(opb,1)){
info->coupling_steps=oggpack_read(opb,8)+1;
- info->coupling=
- _ogg_malloc(info->coupling_steps*sizeof(*info->coupling));
-
+
for(i=0;icoupling_steps;i++){
- int testM=info->coupling[i].mag=oggpack_read(opb,ilog(vi->channels));
- int testA=info->coupling[i].ang=oggpack_read(opb,ilog(vi->channels));
+ int testM=info->coupling_mag[i]=oggpack_read(opb,ilog(vi->channels));
+ int testA=info->coupling_ang[i]=oggpack_read(opb,ilog(vi->channels));
if(testM<0 ||
testA<0 ||
@@ -78,79 +155,68 @@
if(oggpack_read(opb,2)>0)goto err_out; /* 2,3:reserved */
if(info->submaps>1){
- info->chmuxlist=_ogg_malloc(sizeof(*info->chmuxlist)*vi->channels);
for(i=0;ichannels;i++){
info->chmuxlist[i]=oggpack_read(opb,4);
if(info->chmuxlist[i]>=info->submaps)goto err_out;
}
}
-
- info->submaplist=_ogg_malloc(sizeof(*info->submaplist)*info->submaps);
for(i=0;isubmaps;i++){
int temp=oggpack_read(opb,8);
- info->submaplist[i].floor=oggpack_read(opb,8);
- if(info->submaplist[i].floor>=ci->floors)goto err_out;
- info->submaplist[i].residue=oggpack_read(opb,8);
- if(info->submaplist[i].residue>=ci->residues)goto err_out;
+ if(temp>=ci->times)goto err_out;
+ info->floorsubmap[i]=oggpack_read(opb,8);
+ if(info->floorsubmap[i]>=ci->floors)goto err_out;
+ info->residuesubmap[i]=oggpack_read(opb,8);
+ if(info->residuesubmap[i]>=ci->residues)goto err_out;
}
- return 0;
+ return info;
err_out:
- mapping_clear_info(info);
- return -1;
+ mapping0_free_info(info);
+ return(NULL);
}
-int mapping_inverse(vorbis_dsp_state *vd,vorbis_info_mapping *info){
+static int seq=0;
+static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
+ vorbis_dsp_state *vd=vb->vd;
vorbis_info *vi=vd->vi;
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
+ private_state *b=(private_state *)vd->backend_state;
+ vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)l;
+ vorbis_info_mapping0 *info=look->map;
int i,j;
- long n=ci->blocksizes[vd->W];
+ long n=vb->pcmend=ci->blocksizes[vb->W];
- ogg_int32_t **pcmbundle=
- (ogg_int32_t **)alloca(sizeof(*pcmbundle)*vi->channels);
- int *zerobundle=
- (int *)alloca(sizeof(*zerobundle)*vi->channels);
- int *nonzero=
- (int *)alloca(sizeof(*nonzero)*vi->channels);
- ogg_int32_t **floormemo=
- (void **)alloca(sizeof(*floormemo)*vi->channels);
+ ogg_int32_t **pcmbundle=(ogg_int32_t **)alloca(sizeof(*pcmbundle)*vi->channels);
+ int *zerobundle=(int *)alloca(sizeof(*zerobundle)*vi->channels);
+
+ int *nonzero =(int *)alloca(sizeof(*nonzero)*vi->channels);
+ void **floormemo=(void **)alloca(sizeof(*floormemo)*vi->channels);
+ /* time domain information decode (note that applying the
+ information would have to happen later; we'll probably add a
+ function entry to the harness for that later */
+ /* NOT IMPLEMENTED */
+
/* recover the spectral envelope; store it in the PCM vector for now */
for(i=0;ichannels;i++){
- int submap=0;
- int floorno;
-
- if(info->submaps>1)
- submap=info->chmuxlist[i];
- floorno=info->submaplist[submap].floor;
-
- if(ci->floor_type[floorno]){
- /* floor 1 */
- floormemo[i]=alloca(sizeof(*floormemo[i])*
- floor1_memosize(ci->floor_param[floorno]));
- floormemo[i]=floor1_inverse1(vd,ci->floor_param[floorno],floormemo[i]);
- }else{
- /* floor 0 */
- floormemo[i]=alloca(sizeof(*floormemo[i])*
- floor0_memosize(ci->floor_param[floorno]));
- floormemo[i]=floor0_inverse1(vd,ci->floor_param[floorno],floormemo[i]);
- }
-
+ int submap=info->chmuxlist[i];
+ floormemo[i]=look->floor_func[submap]->
+ inverse1(vb,look->floor_look[submap]);
if(floormemo[i])
nonzero[i]=1;
else
nonzero[i]=0;
- memset(vd->work[i],0,sizeof(*vd->work[i])*n/2);
+ memset(vb->pcm[i],0,sizeof(*vb->pcm[i])*n/2);
}
/* channel coupling can 'dirty' the nonzero listing */
for(i=0;icoupling_steps;i++){
- if(nonzero[info->coupling[i].mag] ||
- nonzero[info->coupling[i].ang]){
- nonzero[info->coupling[i].mag]=1;
- nonzero[info->coupling[i].ang]=1;
+ if(nonzero[info->coupling_mag[i]] ||
+ nonzero[info->coupling_ang[i]]){
+ nonzero[info->coupling_mag[i]]=1;
+ nonzero[info->coupling_ang[i]]=1;
}
}
@@ -158,26 +224,27 @@
for(i=0;isubmaps;i++){
int ch_in_bundle=0;
for(j=0;jchannels;j++){
- if(!info->chmuxlist || info->chmuxlist[j]==i){
+ if(info->chmuxlist[j]==i){
if(nonzero[j])
zerobundle[ch_in_bundle]=1;
else
zerobundle[ch_in_bundle]=0;
- pcmbundle[ch_in_bundle++]=vd->work[j];
+ pcmbundle[ch_in_bundle++]=vb->pcm[j];
}
}
- res_inverse(vd,ci->residue_param+info->submaplist[i].residue,
- pcmbundle,zerobundle,ch_in_bundle);
+ look->residue_func[i]->inverse(vb,look->residue_look[i],
+ pcmbundle,zerobundle,ch_in_bundle);
}
//for(j=0;jchannels;j++)
//_analysis_output("coupled",seq+j,vb->pcm[j],-8,n/2,0,0);
+
/* channel coupling */
for(i=info->coupling_steps-1;i>=0;i--){
- ogg_int32_t *pcmM=vd->work[info->coupling[i].mag];
- ogg_int32_t *pcmA=vd->work[info->coupling[i].ang];
+ ogg_int32_t *pcmM=vb->pcm[info->coupling_mag[i]];
+ ogg_int32_t *pcmA=vb->pcm[info->coupling_ang[i]];
for(j=0;jchannels;i++){
- ogg_int32_t *pcm=vd->work[i];
- int submap=0;
- int floorno;
-
- if(info->submaps>1)
- submap=info->chmuxlist[i];
- floorno=info->submaplist[submap].floor;
-
- if(ci->floor_type[floorno]){
- /* floor 1 */
- floor1_inverse2(vd,ci->floor_param[floorno],floormemo[i],pcm);
- }else{
- /* floor 0 */
- floor0_inverse2(vd,ci->floor_param[floorno],floormemo[i],pcm);
- }
+ ogg_int32_t *pcm=vb->pcm[i];
+ int submap=info->chmuxlist[i];
+ look->floor_func[submap]->
+ inverse2(vb,look->floor_look[submap],floormemo[i],pcm);
}
//for(j=0;jchannels;j++)
@@ -229,12 +285,38 @@
/* transform the PCM data; takes PCM vector, vb; modifies PCM vector */
/* only MDCT right now.... */
- for(i=0;ichannels;i++)
- mdct_backward(n,vd->work[i]);
+ for(i=0;ichannels;i++){
+ ogg_int32_t *pcm=vb->pcm[i];
+ mdct_backward(n,pcm,pcm);
+ }
//for(j=0;jchannels;j++)
//_analysis_output("imdct",seq+j,vb->pcm[j],-24,n,0,0);
+ /* window the data */
+ for(i=0;ichannels;i++){
+ ogg_int32_t *pcm=vb->pcm[i];
+ if(nonzero[i])
+ _vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW);
+ else
+ for(j=0;jchannels;j++)
+ //_analysis_output("window",seq+j,vb->pcm[j],-24,n,0,0);
+
+ seq+=vi->channels;
/* all done! */
return(0);
}
+
+/* export hooks */
+vorbis_func_mapping mapping0_exportbundle={
+ &mapping0_unpack,
+ &mapping0_look,
+ &mapping0_free_info,
+ &mapping0_free_look,
+ &mapping0_inverse
+};
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/mdct.c
--- a/misc/libtremor/tremor/mdct.c Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/mdct.c Sat Nov 03 00:34:35 2012 +0400
@@ -6,14 +6,14 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
- * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
+ * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
function: normalized modified discrete cosine transform
power of two length transform only [64 <= n ]
- last mod: $Id: mdct.c,v 1.9.6.5 2003/04/29 04:03:27 xiphmont Exp $
+ last mod: $Id: mdct.c,v 1.9 2002/10/16 09:17:39 xiphmont Exp $
Original algorithm adapted long ago from _The use of multirate filter
banks for coding of high quality digital audio_, by T. Sporer,
@@ -33,62 +33,23 @@
********************************************************************/
#include "ivorbiscodec.h"
-#include "os.h"
+#include "codebook.h"
#include "misc.h"
#include "mdct.h"
#include "mdct_lookup.h"
-STIN void presymmetry(DATA_TYPE *in,int n2,int step){
- DATA_TYPE *aX;
- DATA_TYPE *bX;
- LOOKUP_T *T;
- int n4=n2>>1;
-
- aX = in+n2-3;
- T = sincos_lookup0;
-
- do{
- REG_TYPE r0= aX[0];
- REG_TYPE r2= aX[2];
- XPROD31( r0, r2, T[0], T[1], &aX[0], &aX[2] ); T+=step;
- aX-=4;
- }while(aX>=in+n4);
- do{
- REG_TYPE r0= aX[0];
- REG_TYPE r2= aX[2];
- XPROD31( r0, r2, T[1], T[0], &aX[0], &aX[2] ); T-=step;
- aX-=4;
- }while(aX>=in);
-
- aX = in+n2-4;
- bX = in;
- T = sincos_lookup0;
- do{
- REG_TYPE ri0= aX[0];
- REG_TYPE ri2= aX[2];
- REG_TYPE ro0= bX[0];
- REG_TYPE ro2= bX[2];
-
- XNPROD31( ro2, ro0, T[1], T[0], &aX[0], &aX[2] ); T+=step;
- XNPROD31( ri2, ri0, T[0], T[1], &bX[0], &bX[2] );
-
- aX-=4;
- bX+=4;
- }while(aX>=in+n4);
-
-}
/* 8 point butterfly (in place) */
STIN void mdct_butterfly_8(DATA_TYPE *x){
- REG_TYPE r0 = x[0] + x[1];
- REG_TYPE r1 = x[0] - x[1];
- REG_TYPE r2 = x[2] + x[3];
- REG_TYPE r3 = x[2] - x[3];
- REG_TYPE r4 = x[4] + x[5];
- REG_TYPE r5 = x[4] - x[5];
- REG_TYPE r6 = x[6] + x[7];
- REG_TYPE r7 = x[6] - x[7];
+ REG_TYPE r0 = x[4] + x[0];
+ REG_TYPE r1 = x[4] - x[0];
+ REG_TYPE r2 = x[5] + x[1];
+ REG_TYPE r3 = x[5] - x[1];
+ REG_TYPE r4 = x[6] + x[2];
+ REG_TYPE r5 = x[6] - x[2];
+ REG_TYPE r6 = x[7] + x[3];
+ REG_TYPE r7 = x[7] - x[3];
x[0] = r5 + r3;
x[1] = r7 - r1;
@@ -103,25 +64,29 @@
/* 16 point butterfly (in place, 4 register) */
STIN void mdct_butterfly_16(DATA_TYPE *x){
-
- REG_TYPE r0, r1, r2, r3;
-
- r0 = x[ 8] - x[ 9]; x[ 8] += x[ 9];
- r1 = x[10] - x[11]; x[10] += x[11];
- r2 = x[ 1] - x[ 0]; x[ 9] = x[ 1] + x[0];
- r3 = x[ 3] - x[ 2]; x[11] = x[ 3] + x[2];
- x[ 0] = MULT31((r0 - r1) , cPI2_8);
- x[ 1] = MULT31((r2 + r3) , cPI2_8);
- x[ 2] = MULT31((r0 + r1) , cPI2_8);
- x[ 3] = MULT31((r3 - r2) , cPI2_8);
+
+ REG_TYPE r0, r1;
+
+ r0 = x[ 0] - x[ 8]; x[ 8] += x[ 0];
+ r1 = x[ 1] - x[ 9]; x[ 9] += x[ 1];
+ x[ 0] = MULT31((r0 + r1) , cPI2_8);
+ x[ 1] = MULT31((r1 - r0) , cPI2_8);
MB();
- r2 = x[12] - x[13]; x[12] += x[13];
- r3 = x[14] - x[15]; x[14] += x[15];
- r0 = x[ 4] - x[ 5]; x[13] = x[ 5] + x[ 4];
- r1 = x[ 7] - x[ 6]; x[15] = x[ 7] + x[ 6];
- x[ 4] = r2; x[ 5] = r1;
- x[ 6] = r3; x[ 7] = r0;
+ r0 = x[10] - x[ 2]; x[10] += x[ 2];
+ r1 = x[ 3] - x[11]; x[11] += x[ 3];
+ x[ 2] = r1; x[ 3] = r0;
+ MB();
+
+ r0 = x[12] - x[ 4]; x[12] += x[ 4];
+ r1 = x[13] - x[ 5]; x[13] += x[ 5];
+ x[ 4] = MULT31((r0 - r1) , cPI2_8);
+ x[ 5] = MULT31((r0 + r1) , cPI2_8);
+ MB();
+
+ r0 = x[14] - x[ 6]; x[14] += x[ 6];
+ r1 = x[15] - x[ 7]; x[15] += x[ 7];
+ x[ 6] = r0; x[ 7] = r1;
MB();
mdct_butterfly_8(x);
@@ -131,40 +96,48 @@
/* 32 point butterfly (in place, 4 register) */
STIN void mdct_butterfly_32(DATA_TYPE *x){
- REG_TYPE r0, r1, r2, r3;
+ REG_TYPE r0, r1;
+
+ r0 = x[30] - x[14]; x[30] += x[14];
+ r1 = x[31] - x[15]; x[31] += x[15];
+ x[14] = r0; x[15] = r1;
+ MB();
- r0 = x[16] - x[17]; x[16] += x[17];
- r1 = x[18] - x[19]; x[18] += x[19];
- r2 = x[ 1] - x[ 0]; x[17] = x[ 1] + x[ 0];
- r3 = x[ 3] - x[ 2]; x[19] = x[ 3] + x[ 2];
- XNPROD31( r0, r1, cPI3_8, cPI1_8, &x[ 0], &x[ 2] );
- XPROD31 ( r2, r3, cPI1_8, cPI3_8, &x[ 1], &x[ 3] );
+ r0 = x[28] - x[12]; x[28] += x[12];
+ r1 = x[29] - x[13]; x[29] += x[13];
+ XNPROD31( r0, r1, cPI1_8, cPI3_8, &x[12], &x[13] );
+ MB();
+
+ r0 = x[26] - x[10]; x[26] += x[10];
+ r1 = x[27] - x[11]; x[27] += x[11];
+ x[10] = MULT31((r0 - r1) , cPI2_8);
+ x[11] = MULT31((r0 + r1) , cPI2_8);
MB();
- r0 = x[20] - x[21]; x[20] += x[21];
- r1 = x[22] - x[23]; x[22] += x[23];
- r2 = x[ 5] - x[ 4]; x[21] = x[ 5] + x[ 4];
- r3 = x[ 7] - x[ 6]; x[23] = x[ 7] + x[ 6];
- x[ 4] = MULT31((r0 - r1) , cPI2_8);
- x[ 5] = MULT31((r3 + r2) , cPI2_8);
- x[ 6] = MULT31((r0 + r1) , cPI2_8);
- x[ 7] = MULT31((r3 - r2) , cPI2_8);
+ r0 = x[24] - x[ 8]; x[24] += x[ 8];
+ r1 = x[25] - x[ 9]; x[25] += x[ 9];
+ XNPROD31( r0, r1, cPI3_8, cPI1_8, &x[ 8], &x[ 9] );
+ MB();
+
+ r0 = x[22] - x[ 6]; x[22] += x[ 6];
+ r1 = x[ 7] - x[23]; x[23] += x[ 7];
+ x[ 6] = r1; x[ 7] = r0;
MB();
- r0 = x[24] - x[25]; x[24] += x[25];
- r1 = x[26] - x[27]; x[26] += x[27];
- r2 = x[ 9] - x[ 8]; x[25] = x[ 9] + x[ 8];
- r3 = x[11] - x[10]; x[27] = x[11] + x[10];
- XNPROD31( r0, r1, cPI1_8, cPI3_8, &x[ 8], &x[10] );
- XPROD31 ( r2, r3, cPI3_8, cPI1_8, &x[ 9], &x[11] );
+ r0 = x[ 4] - x[20]; x[20] += x[ 4];
+ r1 = x[ 5] - x[21]; x[21] += x[ 5];
+ XPROD31 ( r0, r1, cPI3_8, cPI1_8, &x[ 4], &x[ 5] );
MB();
- r0 = x[28] - x[29]; x[28] += x[29];
- r1 = x[30] - x[31]; x[30] += x[31];
- r2 = x[12] - x[13]; x[29] = x[13] + x[12];
- r3 = x[15] - x[14]; x[31] = x[15] + x[14];
- x[12] = r0; x[13] = r3;
- x[14] = r1; x[15] = r2;
+ r0 = x[ 2] - x[18]; x[18] += x[ 2];
+ r1 = x[ 3] - x[19]; x[19] += x[ 3];
+ x[ 2] = MULT31((r1 + r0) , cPI2_8);
+ x[ 3] = MULT31((r1 - r0) , cPI2_8);
+ MB();
+
+ r0 = x[ 0] - x[16]; x[16] += x[ 0];
+ r1 = x[ 1] - x[17]; x[17] += x[ 1];
+ XPROD31 ( r0, r1, cPI1_8, cPI3_8, &x[ 0], &x[ 1] );
MB();
mdct_butterfly_16(x);
@@ -174,30 +147,87 @@
/* N/stage point generic N stage butterfly (in place, 2 register) */
STIN void mdct_butterfly_generic(DATA_TYPE *x,int points,int step){
- LOOKUP_T *T = sincos_lookup0;
- DATA_TYPE *x1 = x + points - 4;
- DATA_TYPE *x2 = x + (points>>1) - 4;
- REG_TYPE r0, r1, r2, r3;
+ LOOKUP_T *T = sincos_lookup0;
+ DATA_TYPE *x1 = x + points - 8;
+ DATA_TYPE *x2 = x + (points>>1) - 8;
+ REG_TYPE r0;
+ REG_TYPE r1;
do{
- r0 = x1[0] - x1[1]; x1[0] += x1[1];
- r1 = x1[3] - x1[2]; x1[2] += x1[3];
- r2 = x2[1] - x2[0]; x1[1] = x2[1] + x2[0];
- r3 = x2[3] - x2[2]; x1[3] = x2[3] + x2[2];
- XPROD31( r1, r0, T[0], T[1], &x2[0], &x2[2] );
- XPROD31( r2, r3, T[0], T[1], &x2[1], &x2[3] ); T+=step;
- x1-=4;
- x2-=4;
+ r0 = x1[6] - x2[6]; x1[6] += x2[6];
+ r1 = x2[7] - x1[7]; x1[7] += x2[7];
+ XPROD31( r1, r0, T[0], T[1], &x2[6], &x2[7] ); T+=step;
+
+ r0 = x1[4] - x2[4]; x1[4] += x2[4];
+ r1 = x2[5] - x1[5]; x1[5] += x2[5];
+ XPROD31( r1, r0, T[0], T[1], &x2[4], &x2[5] ); T+=step;
+
+ r0 = x1[2] - x2[2]; x1[2] += x2[2];
+ r1 = x2[3] - x1[3]; x1[3] += x2[3];
+ XPROD31( r1, r0, T[0], T[1], &x2[2], &x2[3] ); T+=step;
+
+ r0 = x1[0] - x2[0]; x1[0] += x2[0];
+ r1 = x2[1] - x1[1]; x1[1] += x2[1];
+ XPROD31( r1, r0, T[0], T[1], &x2[0], &x2[1] ); T+=step;
+
+ x1-=8; x2-=8;
}while(Tsincos_lookup0);
+ do{
+ r0 = x2[6] - x1[6]; x1[6] += x2[6];
+ r1 = x2[7] - x1[7]; x1[7] += x2[7];
+ XPROD31( r0, r1, T[0], T[1], &x2[6], &x2[7] ); T+=step;
+
+ r0 = x2[4] - x1[4]; x1[4] += x2[4];
+ r1 = x2[5] - x1[5]; x1[5] += x2[5];
+ XPROD31( r0, r1, T[0], T[1], &x2[4], &x2[5] ); T+=step;
+
+ r0 = x2[2] - x1[2]; x1[2] += x2[2];
+ r1 = x2[3] - x1[3]; x1[3] += x2[3];
+ XPROD31( r0, r1, T[0], T[1], &x2[2], &x2[3] ); T+=step;
+
+ r0 = x2[0] - x1[0]; x1[0] += x2[0];
+ r1 = x2[1] - x1[1]; x1[1] += x2[1];
+ XPROD31( r0, r1, T[0], T[1], &x2[0], &x2[1] ); T+=step;
+
+ x1-=8; x2-=8;
+ }while(Tsincos_lookup0);
}
@@ -205,14 +235,15 @@
int stages=8-shift;
int i,j;
-
+
for(i=0;--stages>0;i++){
for(j=0;j<(1<>i)*j,points>>i,4<<(i+shift));
}
-
+
for(j=0;j>8]|(bitrev[(x&0x0f0)>>4]<<4)|(((int)bitrev[x&0x00f])<<8);
}
-STIN void mdct_bitreverse(DATA_TYPE *x,int n,int shift){
+STIN void mdct_bitreverse(DATA_TYPE *x,int n,int step,int shift){
+
int bit = 0;
- DATA_TYPE *w = x+(n>>1);
+ DATA_TYPE *w0 = x;
+ DATA_TYPE *w1 = x = w0+(n>>1);
+ LOOKUP_T *T = (step>=4)?(sincos_lookup0+(step>>1)):sincos_lookup1;
+ LOOKUP_T *Ttop = T+1024;
+ DATA_TYPE r2;
do{
- DATA_TYPE b = bitrev12(bit++);
- DATA_TYPE *xx = x + (b>>shift);
- REG_TYPE r;
-
- w -= 2;
-
- if(w>xx){
+ DATA_TYPE r3 = bitrev12(bit++);
+ DATA_TYPE *x0 = x + ((r3 ^ 0xfff)>>shift) -1;
+ DATA_TYPE *x1 = x + (r3>>shift);
- r = xx[0];
- xx[0] = w[0];
- w[0] = r;
-
- r = xx[1];
- xx[1] = w[1];
- w[1] = r;
- }
- }while(w>x);
-}
+ REG_TYPE r0 = x0[0] + x1[0];
+ REG_TYPE r1 = x1[1] - x0[1];
-STIN void mdct_step7(DATA_TYPE *x,int n,int step){
- DATA_TYPE *w0 = x;
- DATA_TYPE *w1 = x+(n>>1);
- LOOKUP_T *T = (step>=4)?(sincos_lookup0+(step>>1)):sincos_lookup1;
- LOOKUP_T *Ttop = T+1024;
- REG_TYPE r0, r1, r2, r3;
-
- do{
- w1 -= 2;
+ XPROD32( r0, r1, T[1], T[0], &r2, &r3 ); T+=step;
- r0 = w0[0] + w1[0];
- r1 = w1[1] - w0[1];
- r2 = MULT32(r0, T[1]) + MULT32(r1, T[0]);
- r3 = MULT32(r1, T[1]) - MULT32(r0, T[0]);
- T+=step;
+ w1 -= 4;
- r0 = (w0[1] + w1[1])>>1;
- r1 = (w0[0] - w1[0])>>1;
+ r0 = (x0[1] + x1[1])>>1;
+ r1 = (x0[0] - x1[0])>>1;
w0[0] = r0 + r2;
w0[1] = r1 + r3;
+ w1[2] = r0 - r2;
+ w1[3] = r3 - r1;
+
+ r3 = bitrev12(bit++);
+ x0 = x + ((r3 ^ 0xfff)>>shift) -1;
+ x1 = x + (r3>>shift);
+
+ r0 = x0[0] + x1[0];
+ r1 = x1[1] - x0[1];
+
+ XPROD32( r0, r1, T[1], T[0], &r2, &r3 ); T+=step;
+
+ r0 = (x0[1] + x1[1])>>1;
+ r1 = (x0[0] - x1[0])>>1;
+ w0[2] = r0 + r2;
+ w0[3] = r1 + r3;
w1[0] = r0 - r2;
w1[1] = r3 - r1;
- w0 += 2;
+ w0 += 4;
}while(T>shift) -1;
+ DATA_TYPE *x1 = x + (r3>>shift);
+
+ REG_TYPE r0 = x0[0] + x1[0];
+ REG_TYPE r1 = x1[1] - x0[1];
- r0 = w0[0] + w1[0];
- r1 = w1[1] - w0[1];
- T-=step;
- r2 = MULT32(r0, T[0]) + MULT32(r1, T[1]);
- r3 = MULT32(r1, T[0]) - MULT32(r0, T[1]);
+ T-=step; XPROD32( r0, r1, T[0], T[1], &r2, &r3 );
- r0 = (w0[1] + w1[1])>>1;
- r1 = (w0[0] - w1[0])>>1;
+ w1 -= 4;
+
+ r0 = (x0[1] + x1[1])>>1;
+ r1 = (x0[0] - x1[0])>>1;
w0[0] = r0 + r2;
w0[1] = r1 + r3;
+ w1[2] = r0 - r2;
+ w1[3] = r3 - r1;
+
+ r3 = bitrev12(bit++);
+ x0 = x + ((r3 ^ 0xfff)>>shift) -1;
+ x1 = x + (r3>>shift);
+
+ r0 = x0[0] + x1[0];
+ r1 = x1[1] - x0[1];
+
+ T-=step; XPROD32( r0, r1, T[0], T[1], &r2, &r3 );
+
+ r0 = (x0[1] + x1[1])>>1;
+ r1 = (x0[0] - x1[0])>>1;
+ w0[2] = r0 + r2;
+ w0[3] = r1 + r3;
w1[0] = r0 - r2;
w1[1] = r3 - r1;
- w0 += 2;
+ w0 += 4;
}while(w0>1;
+ int n4=n>>2;
+ DATA_TYPE *iX;
+ DATA_TYPE *oX;
LOOKUP_T *T;
LOOKUP_T *V;
- DATA_TYPE *iX =x+(n>>1);
- step>>=2;
-
- switch(step) {
- default:
- T=(step>=4)?(sincos_lookup0+(step>>1)):sincos_lookup1;
- do{
- REG_TYPE r0 = x[0];
- REG_TYPE r1 = -x[1];
- XPROD31( r0, r1, T[0], T[1], x, x+1); T+=step;
- x +=2;
- }while(x>1;
- t1 = (*T++)>>1;
- do{
- r0 = x[0];
- r1 = -x[1];
- t0 += (v0 = (*V++)>>1);
- t1 += (v1 = (*V++)>>1);
- XPROD31( r0, r1, t0, t1, x, x+1 );
-
- r0 = x[2];
- r1 = -x[3];
- v0 += (t0 = (*T++)>>1);
- v1 += (t1 = (*T++)>>1);
- XPROD31( r0, r1, v0, v1, x+2, x+3 );
-
- x += 4;
- }while(x>2);
- t1 += (q1 = (v1-t1)>>2);
- r0 = x[0];
- r1 = -x[1];
- XPROD31( r0, r1, t0, t1, x, x+1 );
- t0 = v0-q0;
- t1 = v1-q1;
- r0 = x[2];
- r1 = -x[3];
- XPROD31( r0, r1, t0, t1, x+2, x+3 );
-
- t0 = *T++;
- t1 = *T++;
- v0 += (q0 = (t0-v0)>>2);
- v1 += (q1 = (t1-v1)>>2);
- r0 = x[4];
- r1 = -x[5];
- XPROD31( r0, r1, v0, v1, x+4, x+5 );
- v0 = t0-q0;
- v1 = t1-q1;
- r0 = x[6];
- r1 = -x[7];
- XPROD31( r0, r1, v0, v1, x+5, x+6 );
-
- x+=8;
- }while(x>1,step);
- mdct_butterflies(in,n>>1,shift);
- mdct_bitreverse(in,n,shift);
- mdct_step7(in,n,step);
- mdct_step8(in,n,step);
-}
+ /* rotate */
+
+ iX = in+n2-7;
+ oX = out+n2+n4;
+ T = sincos_lookup0;
-void mdct_shift_right(int n, DATA_TYPE *in, DATA_TYPE *right){
- int i;
- n>>=2;
- in+=1;
+ do{
+ oX-=4;
+ XPROD31( iX[4], iX[6], T[0], T[1], &oX[2], &oX[3] ); T+=step;
+ XPROD31( iX[0], iX[2], T[0], T[1], &oX[0], &oX[1] ); T+=step;
+ iX-=8;
+ }while(iX>=in+n4);
+ do{
+ oX-=4;
+ XPROD31( iX[4], iX[6], T[1], T[0], &oX[2], &oX[3] ); T-=step;
+ XPROD31( iX[0], iX[2], T[1], T[0], &oX[0], &oX[1] ); T-=step;
+ iX-=8;
+ }while(iX>=in);
- for(i=0;i=in+n4);
+ do{
+ T-=step; XNPROD31( iX[6], iX[4], T[1], T[0], &oX[0], &oX[1] );
+ T-=step; XNPROD31( iX[2], iX[0], T[1], T[0], &oX[2], &oX[3] );
+ iX-=8;
+ oX+=4;
+ }while(iX>=in);
-void mdct_unroll_lap(int n0,int n1,
- int lW,int W,
- DATA_TYPE *in,
- DATA_TYPE *right,
- LOOKUP_T *w0,
- LOOKUP_T *w1,
- ogg_int16_t *out,
- int step,
- int start, /* samples, this frame */
- int end /* samples, this frame */){
+ mdct_butterflies(out+n2,n2,shift);
+ mdct_bitreverse(out,n,step,shift);
+
+ /* rotate + window */
+
+ step>>=2;
+ {
+ DATA_TYPE *oX1=out+n2+n4;
+ DATA_TYPE *oX2=out+n2+n4;
+ DATA_TYPE *iX =out;
- DATA_TYPE *l=in+(W&&lW ? n1>>1 : n0>>1);
- DATA_TYPE *r=right+(lW ? n1>>2 : n0>>2);
- DATA_TYPE *post;
- LOOKUP_T *wR=(W && lW ? w1+(n1>>1) : w0+(n0>>1));
- LOOKUP_T *wL=(W && lW ? w1 : w0 );
+ switch(step) {
+ default: {
+ T=(step>=4)?(sincos_lookup0+(step>>1)):sincos_lookup1;
+ do{
+ oX1-=4;
+ XPROD31( iX[0], -iX[1], T[0], T[1], &oX1[3], &oX2[0] ); T+=step;
+ XPROD31( iX[2], -iX[3], T[0], T[1], &oX1[2], &oX2[1] ); T+=step;
+ XPROD31( iX[4], -iX[5], T[0], T[1], &oX1[1], &oX2[2] ); T+=step;
+ XPROD31( iX[6], -iX[7], T[0], T[1], &oX1[0], &oX2[3] ); T+=step;
+ oX2+=4;
+ iX+=8;
+ }while(iX>2)-(n0>>2) : 0 );
- int halfLap=(lW && W ? (n1>>2) : (n0>>2) );
- int postLap=(!lW && W ? (n1>>2)-(n0>>2) : 0 );
- int n,off;
+ case 1: {
+ /* linear interpolation between table values: offset=0.5, step=1 */
+ REG_TYPE t0,t1,v0,v1;
+ T = sincos_lookup0;
+ V = sincos_lookup1;
+ t0 = (*T++)>>1;
+ t1 = (*T++)>>1;
+ do{
+ oX1-=4;
- /* preceeding direct-copy lapping from previous frame, if any */
- if(preLap){
- n = (endpost){
- *out = CLIP_TO_15((*--r)>>9);
- out+=step;
+ t0 += (v0 = (*V++)>>1);
+ t1 += (v1 = (*V++)>>1);
+ XPROD31( iX[0], -iX[1], t0, t1, &oX1[3], &oX2[0] );
+ v0 += (t0 = (*T++)>>1);
+ v1 += (t1 = (*T++)>>1);
+ XPROD31( iX[2], -iX[3], v0, v1, &oX1[2], &oX2[1] );
+ t0 += (v0 = (*V++)>>1);
+ t1 += (v1 = (*V++)>>1);
+ XPROD31( iX[4], -iX[5], t0, t1, &oX1[1], &oX2[2] );
+ v0 += (t0 = (*T++)>>1);
+ v1 += (t1 = (*T++)>>1);
+ XPROD31( iX[6], -iX[7], v0, v1, &oX1[0], &oX2[3] );
+
+ oX2+=4;
+ iX+=8;
+ }while(iX>2);
+ t1 += (q1 = (v1-t1)>>2);
+ XPROD31( iX[0], -iX[1], t0, t1, &oX1[3], &oX2[0] );
+ t0 = v0-q0;
+ t1 = v1-q1;
+ XPROD31( iX[2], -iX[3], t0, t1, &oX1[2], &oX2[1] );
+
+ t0 = *T++;
+ t1 = *T++;
+ v0 += (q0 = (t0-v0)>>2);
+ v1 += (q1 = (t1-v1)>>2);
+ XPROD31( iX[4], -iX[5], v0, v1, &oX1[1], &oX2[2] );
+ v0 = t0-q0;
+ v1 = t1-q1;
+ XPROD31( iX[6], -iX[7], v0, v1, &oX1[0], &oX2[3] );
+
+ oX2+=4;
+ iX+=8;
+ }while(iXpost){
- l-=2;
- *out = CLIP_TO_15((MULT31(*--r,*--wR) + MULT31(*l,*wL++))>>9);
- out+=step;
- }
+
+ iX=out+n2+n4;
+ oX1=out+n4;
+ oX2=oX1;
+
+ do{
+ oX1-=4;
+ iX-=4;
+
+ oX2[0] = -(oX1[3] = iX[3]);
+ oX2[1] = -(oX1[2] = iX[2]);
+ oX2[2] = -(oX1[1] = iX[1]);
+ oX2[3] = -(oX1[0] = iX[0]);
- n = (end>9);
- out+=step;
- l+=2;
- }
+ oX2+=4;
+ }while(oX2>9);
- out+=step;
- l+=2;
- }
+ do{
+ oX1-=4;
+ oX1[0]= iX[3];
+ oX1[1]= iX[2];
+ oX1[2]= iX[1];
+ oX1[3]= iX[0];
+ iX+=4;
+ }while(oX1>oX2);
}
}
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/mdct.h
--- a/misc/libtremor/tremor/mdct.h Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/mdct.h Sat Nov 03 00:34:35 2012 +0400
@@ -6,7 +6,7 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
- * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
+ * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
@@ -34,15 +34,8 @@
#define cPI1_8 (0x7641af3d)
#endif
-extern void mdct_backward(int n, DATA_TYPE *in);
-extern void mdct_shift_right(int n, DATA_TYPE *in, DATA_TYPE *right);
-extern void mdct_unroll_lap(int n0,int n1,
- int lW,int W,
- DATA_TYPE *in,DATA_TYPE *right,
- LOOKUP_T *w0,LOOKUP_T *w1,
- ogg_int16_t *out,
- int step,
- int start,int end /* samples, this frame */);
+extern void mdct_forward(int n, DATA_TYPE *in, DATA_TYPE *out);
+extern void mdct_backward(int n, DATA_TYPE *in, DATA_TYPE *out);
#endif
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/misc.c
--- a/misc/libtremor/tremor/misc.c Sun Oct 21 01:28:33 2012 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/********************************************************************
- * *
- * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
- * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
- * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
- * *
- * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
- * by the XIPHOPHORUS Company http://www.xiph.org/ *
- * *
- ********************************************************************/
-
-#define HEAD_ALIGN 64
-#include
-#include
-#include
-#define MISC_C
-#include "misc.h"
-#include
-
-static void **pointers=NULL;
-static long *insertlist=NULL; /* We can't embed this in the pointer list;
- a pointer can have any value... */
-
-static char **files=NULL;
-static long *file_bytes=NULL;
-static int filecount=0;
-
-static int ptop=0;
-static int palloced=0;
-static int pinsert=0;
-
-typedef struct {
- char *file;
- long line;
- long ptr;
- long bytes;
-} head;
-
-long global_bytes=0;
-long start_time=-1;
-
-static void *_insert(void *ptr,long bytes,char *file,long line){
- ((head *)ptr)->file=file;
- ((head *)ptr)->line=line;
- ((head *)ptr)->ptr=pinsert;
- ((head *)ptr)->bytes=bytes-HEAD_ALIGN;
-
- if(pinsert>=palloced){
- palloced+=64;
- if(pointers){
- pointers=(void **)realloc(pointers,sizeof(void **)*palloced);
- insertlist=(long *)realloc(insertlist,sizeof(long *)*palloced);
- }else{
- pointers=(void **)malloc(sizeof(void **)*palloced);
- insertlist=(long *)malloc(sizeof(long *)*palloced);
- }
- }
-
- pointers[pinsert]=ptr;
-
- if(pinsert==ptop)
- pinsert=++ptop;
- else
- pinsert=insertlist[pinsert];
-
-#ifdef _VDBG_GRAPHFILE
- {
- FILE *out;
- struct timeval tv;
- static struct timezone tz;
- int i;
- char buffer[80];
- gettimeofday(&tv,&tz);
-
- for(i=0;ifile;
- long bytes =((head *)ptr)->bytes;
- int i;
-
- gettimeofday(&tv,&tz);
- fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
- global_bytes);
- fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000),
- global_bytes-((head *)ptr)->bytes);
- fclose(out);
-
- for(i=0;ibytes;
-
- insert=((head *)ptr)->ptr;
- insertlist[insert]=pinsert;
- pinsert=insert;
-
- if(pointers[insert]==NULL){
- fprintf(stderr,"DEBUGGING MALLOC ERROR: freeing previously freed memory\n");
- fprintf(stderr,"\t%s %ld\n",((head *)ptr)->file,((head *)ptr)->line);
- }
-
- if(global_bytes<0){
- fprintf(stderr,"DEBUGGING MALLOC ERROR: freeing unmalloced memory\n");
- }
-
- pointers[insert]=NULL;
-}
-
-void _VDBG_dump(void){
- int i;
- for(i=0;ifile,ptr->line);
- }
-
-}
-
-extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line){
- if(bytes<0) abort();
- bytes+=HEAD_ALIGN;
- if(ptr){
- ptr-=HEAD_ALIGN;
- _ripremove(ptr);
- ptr=realloc(ptr,bytes);
- }else{
- ptr=malloc(bytes);
- memset(ptr,0,bytes);
- }
- return _insert(ptr,bytes,file,line);
-}
-
-extern void _VDBG_free(void *ptr,char *file,long line){
- if(ptr){
- ptr-=HEAD_ALIGN;
- _ripremove(ptr);
- free(ptr);
- }
-}
-
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/misc.h
--- a/misc/libtremor/tremor/misc.h Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/misc.h Sat Nov 03 00:34:35 2012 +0400
@@ -6,7 +6,7 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
- * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
+ * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
@@ -18,26 +18,10 @@
#ifndef _V_RANDOM_H_
#define _V_RANDOM_H_
#include "ivorbiscodec.h"
-#include "os_types.h"
-
-/*#define _VDBG_GRAPHFILE "_0.m"*/
-
-#ifdef _VDBG_GRAPHFILE
-extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line);
-extern void _VDBG_free(void *ptr,char *file,long line);
-
-#undef _ogg_malloc
-#undef _ogg_calloc
-#undef _ogg_realloc
-#undef _ogg_free
-
-#define _ogg_malloc(x) _VDBG_malloc(NULL,(x),__FILE__,__LINE__)
-#define _ogg_calloc(x,y) _VDBG_malloc(NULL,(x)*(y),__FILE__,__LINE__)
-#define _ogg_realloc(x,y) _VDBG_malloc((x),(y),__FILE__,__LINE__)
-#define _ogg_free(x) _VDBG_free((x),__FILE__,__LINE__)
-#endif
+#include "os.h"
#include "asm_arm.h"
+#include /* for abs() */
#ifndef _V_WIDE_MATH
#define _V_WIDE_MATH
@@ -45,7 +29,9 @@
#ifndef _LOW_ACCURACY_
/* 64 bit multiply */
+#if !(defined WIN32 && defined WINCE)
#include
+#endif
#if BYTE_ORDER==LITTLE_ENDIAN
union magic {
@@ -58,26 +44,26 @@
#endif
#if BYTE_ORDER==BIG_ENDIAN
-union magic {
+/*union magic {
struct {
ogg_int32_t hi;
ogg_int32_t lo;
} halves;
ogg_int64_t whole;
-};
+};*/
#endif
-static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
+STIN ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
union magic magic;
magic.whole = (ogg_int64_t)x * y;
return magic.halves.hi;
}
-static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
+STIN ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
return MULT32(x,y)<<1;
}
-static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
+STIN ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
union magic magic;
magic.whole = (ogg_int64_t)x * y;
return ((ogg_uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17);
@@ -99,15 +85,15 @@
* tables in this case.
*/
-static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
+STIN ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
return (x >> 9) * y; /* y preshifted >>23 */
}
-static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
+STIN ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
return (x >> 8) * y; /* y preshifted >>23 */
}
-static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
+STIN ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
return (x >> 6) * y; /* y preshifted >>9 */
}
@@ -144,7 +130,7 @@
#else
-static inline void XPROD32(ogg_int32_t a, ogg_int32_t b,
+STIN void XPROD32(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
{
@@ -152,7 +138,7 @@
*y = MULT32(b, t) - MULT32(a, v);
}
-static inline void XPROD31(ogg_int32_t a, ogg_int32_t b,
+STIN void XPROD31(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
{
@@ -160,7 +146,7 @@
*y = MULT31(b, t) - MULT31(a, v);
}
-static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
+STIN void XNPROD31(ogg_int32_t a, ogg_int32_t b,
ogg_int32_t t, ogg_int32_t v,
ogg_int32_t *x, ogg_int32_t *y)
{
@@ -175,7 +161,7 @@
#ifndef _V_CLIP_MATH
#define _V_CLIP_MATH
-static inline ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
+STIN ogg_int32_t CLIP_TO_15(ogg_int32_t x) {
int ret=x;
ret-= ((x<=32767)-1)&(x-32767);
ret-= ((x>=-32768)-1)&(x+32768);
@@ -184,6 +170,73 @@
#endif
+STIN ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap,
+ ogg_int32_t b,ogg_int32_t bp,
+ ogg_int32_t *p){
+ if(a && b){
+#ifndef _LOW_ACCURACY_
+ *p=ap+bp+32;
+ return MULT32(a,b);
+#else
+ *p=ap+bp+31;
+ return (a>>15)*(b>>16);
+#endif
+ }else
+ return 0;
+}
+
+int _ilog(unsigned int);
+
+STIN ogg_int32_t VFLOAT_MULTI(ogg_int32_t a,ogg_int32_t ap,
+ ogg_int32_t i,
+ ogg_int32_t *p){
+
+ int ip=_ilog(abs(i))-31;
+ return VFLOAT_MULT(a,ap,i<<-ip,ip,p);
+}
+
+STIN ogg_int32_t VFLOAT_ADD(ogg_int32_t a,ogg_int32_t ap,
+ ogg_int32_t b,ogg_int32_t bp,
+ ogg_int32_t *p){
+
+ if(!a){
+ *p=bp;
+ return b;
+ }else if(!b){
+ *p=ap;
+ return a;
+ }
+
+ /* yes, this can leak a bit. */
+ if(ap>bp){
+ int shift=ap-bp+1;
+ *p=ap+1;
+ a>>=1;
+ if(shift<32){
+ b=(b+(1<<(shift-1)))>>shift;
+ }else{
+ b=0;
+ }
+ }else{
+ int shift=bp-ap+1;
+ *p=bp+1;
+ b>>=1;
+ if(shift<32){
+ a=(a+(1<<(shift-1)))>>shift;
+ }else{
+ a=0;
+ }
+ }
+
+ a+=b;
+ if((a&0xc0000000)==0xc0000000 ||
+ (a&0xc0000000)==0){
+ a<<=1;
+ (*p)--;
+ }
+ return(a);
+}
+
#endif
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/os.h
--- a/misc/libtremor/tremor/os.h Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/os.h Sat Nov 03 00:34:35 2012 +0400
@@ -41,6 +41,8 @@
# define rint(x) (floor((x)+0.5f))
# define NO_FLOAT_MATH_LIB
# define FAST_HYPOT(a, b) sqrt((a)*(a) + (b)*(b))
+# define LITTLE_ENDIAN 1
+# define BYTE_ORDER LITTLE_ENDIAN
#endif
#ifdef HAVE_ALLOCA_H
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/os_types.h
--- a/misc/libtremor/tremor/os_types.h Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/os_types.h Sat Nov 03 00:34:35 2012 +0400
@@ -40,7 +40,6 @@
typedef __int32 ogg_int32_t;
typedef unsigned __int32 ogg_uint32_t;
typedef __int16 ogg_int16_t;
- typedef unsigned __int16 ogg_uint16_t;
# else
/* Cygwin */
#include <_G_config.h>
@@ -48,23 +47,20 @@
typedef _G_int32_t ogg_int32_t;
typedef _G_uint32_t ogg_uint32_t;
typedef _G_int16_t ogg_int16_t;
- typedef _G_uint16_t ogg_uint16_t;
# endif
#elif defined(__MACOS__)
# include
typedef SInt16 ogg_int16_t;
- typedef UInt16 ogg_uint16_t;
typedef SInt32 ogg_int32_t;
typedef UInt32 ogg_uint32_t;
typedef SInt64 ogg_int64_t;
-#elif defined(__MACOSX__) /* MacOS X Framework build */
+#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
# include
typedef int16_t ogg_int16_t;
- typedef u_int16_t ogg_uint16_t;
typedef int32_t ogg_int32_t;
typedef u_int32_t ogg_uint32_t;
typedef int64_t ogg_int64_t;
@@ -78,7 +74,6 @@
/* OS/2 GCC */
typedef short ogg_int16_t;
- typedef unsigned short ogg_uint16_t;
typedef int ogg_int32_t;
typedef unsigned int ogg_uint32_t;
typedef long long ogg_int64_t;
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/res012.c
--- a/misc/libtremor/tremor/res012.c Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/res012.c Sat Nov 03 00:34:35 2012 +0400
@@ -6,7 +6,7 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
- * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
+ * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
* BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
* *
********************************************************************
@@ -21,15 +21,50 @@
#include "ogg.h"
#include "ivorbiscodec.h"
#include "codec_internal.h"
+#include "registry.h"
#include "codebook.h"
#include "misc.h"
#include "os.h"
+#include "block.h"
-void res_clear_info(vorbis_info_residue *info){
+typedef struct {
+ vorbis_info_residue0 *info;
+ int map;
+
+ int parts;
+ int stages;
+ codebook *fullbooks;
+ codebook *phrasebook;
+ codebook ***partbooks;
+
+ int partvals;
+ int **decodemap;
+
+} vorbis_look_residue0;
+
+void res0_free_info(vorbis_info_residue *i){
+ vorbis_info_residue0 *info=(vorbis_info_residue0 *)i;
if(info){
- if(info->stagemasks)_ogg_free(info->stagemasks);
- if(info->stagebooks)_ogg_free(info->stagebooks);
memset(info,0,sizeof(*info));
+ _ogg_free(info);
+ }
+}
+
+void res0_free_look(vorbis_look_residue *i){
+ int j;
+ if(i){
+
+ vorbis_look_residue0 *look=(vorbis_look_residue0 *)i;
+
+ for(j=0;jparts;j++)
+ if(look->partbooks[j])_ogg_free(look->partbooks[j]);
+ _ogg_free(look->partbooks);
+ for(j=0;jpartvals;j++)
+ _ogg_free(look->decodemap[j]);
+ _ogg_free(look->decodemap);
+
+ memset(look,0,sizeof(*look));
+ _ogg_free(look);
}
}
@@ -42,193 +77,266 @@
return(ret);
}
+static int icount(unsigned int v){
+ int ret=0;
+ while(v){
+ ret+=v&1;
+ v>>=1;
+ }
+ return(ret);
+}
+
/* vorbis_info is for range checking */
-int res_unpack(vorbis_info_residue *info,
- vorbis_info *vi,oggpack_buffer *opb){
- int j,k;
+vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){
+ int j,acc=0;
+ vorbis_info_residue0 *info=(vorbis_info_residue0 *)_ogg_calloc(1,sizeof(*info));
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
- memset(info,0,sizeof(*info));
- info->type=oggpack_read(opb,16);
- if(info->type>2 || info->type<0)goto errout;
info->begin=oggpack_read(opb,24);
info->end=oggpack_read(opb,24);
info->grouping=oggpack_read(opb,24)+1;
info->partitions=oggpack_read(opb,6)+1;
info->groupbook=oggpack_read(opb,8);
- if(info->groupbook>=ci->books)goto errout;
-
- info->stagemasks=_ogg_malloc(info->partitions*sizeof(*info->stagemasks));
- info->stagebooks=_ogg_malloc(info->partitions*8*sizeof(*info->stagebooks));
for(j=0;jpartitions;j++){
int cascade=oggpack_read(opb,3);
if(oggpack_read(opb,1))
cascade|=(oggpack_read(opb,5)<<3);
- info->stagemasks[j]=cascade;
+ info->secondstages[j]=cascade;
+
+ acc+=icount(cascade);
}
+ for(j=0;jbooklist[j]=oggpack_read(opb,8);
+
+ if(info->groupbook>=ci->books)goto errout;
+ for(j=0;jbooklist[j]>=ci->books)goto errout;
+
+ return(info);
+ errout:
+ res0_free_info(info);
+ return(NULL);
+}
+
+vorbis_look_residue *res0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
+ vorbis_info_residue *vr){
+ vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr;
+ vorbis_look_residue0 *look=(vorbis_look_residue0 *)_ogg_calloc(1,sizeof(*look));
+ codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup;
- for(j=0;jpartitions;j++){
- for(k=0;k<8;k++){
- if((info->stagemasks[j]>>k)&1){
- unsigned char book=oggpack_read(opb,8);
- if(book>=ci->books)goto errout;
- info->stagebooks[j*8+k]=book;
- if(k+1>info->stages)info->stages=k+1;
- }else
- info->stagebooks[j*8+k]=0xff;
+ int j,k,acc=0;
+ int dim;
+ int maxstage=0;
+ look->info=info;
+ look->map=vm->mapping;
+
+ look->parts=info->partitions;
+ look->fullbooks=ci->fullbooks;
+ look->phrasebook=ci->fullbooks+info->groupbook;
+ dim=look->phrasebook->dim;
+
+ look->partbooks=(codebook ***)_ogg_calloc(look->parts,sizeof(*look->partbooks));
+
+ for(j=0;jparts;j++){
+ int stages=ilog(info->secondstages[j]);
+ if(stages){
+ if(stages>maxstage)maxstage=stages;
+ look->partbooks[j]=(codebook **)_ogg_calloc(stages,sizeof(*look->partbooks[j]));
+ for(k=0;ksecondstages[j]&(1<partbooks[j][k]=ci->fullbooks+info->booklist[acc++];
+#ifdef TRAIN_RES
+ look->training_data[k][j]=calloc(look->partbooks[j][k]->entries,
+ sizeof(***look->training_data));
+#endif
+ }
}
}
- if(oggpack_eop(opb))goto errout;
+ look->partvals=look->parts;
+ for(j=1;jpartvals*=look->parts;
+ look->stages=maxstage;
+ look->decodemap=(int **)_ogg_malloc(look->partvals*sizeof(*look->decodemap));
+ for(j=0;jpartvals;j++){
+ long val=j;
+ long mult=look->partvals/look->parts;
+ look->decodemap[j]=(int *)_ogg_malloc(dim*sizeof(*look->decodemap[j]));
+ for(k=0;kparts;
+ look->decodemap[j][k]=deco;
+ }
+ }
- return 0;
- errout:
- res_clear_info(info);
- return 1;
+ return(look);
}
-int res_inverse(vorbis_dsp_state *vd,vorbis_info_residue *info,
- ogg_int32_t **in,int *nonzero,int ch){
-
- int i,j,k,s,used=0;
- codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup;
- codebook *phrasebook=ci->book_param+info->groupbook;
+
+/* a truncated packet here just means 'stop working'; it's not an error */
+static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
+ ogg_int32_t **in,int ch,
+ long (*decodepart)(codebook *, ogg_int32_t *,
+ oggpack_buffer *,int,int)){
+
+ long i,j,k,l,s;
+ vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
+ vorbis_info_residue0 *info=look->info;
+
+ /* move all this setup out later */
int samples_per_partition=info->grouping;
- int partitions_per_word=phrasebook->dim;
- int pcmend=ci->blocksizes[vd->W];
+ int partitions_per_word=look->phrasebook->dim;
+ int max=vb->pcmend>>1;
+ int end=(info->endend:max);
+ int n=end-info->begin;
- if(info->type<2){
- int max=pcmend>>1;
- int end=(info->endend:max);
- int n=end-info->begin;
+ if(n>0){
+ int partvals=n/samples_per_partition;
+ int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
+ int ***partword=(int ***)alloca(ch*sizeof(*partword));
+
+ for(j=0;j0){
- int partvals=n/samples_per_partition;
- int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
+ for(s=0;sstages;s++){
- for(i=0;iphrasebook,&vb->opb);
+ if(temp==-1)goto eopbreak;
+ partword[j][l]=look->decodemap[temp];
+ if(partword[j][l]==NULL)goto errout;
+ }
+ }
- char **partword=(char **)alloca(ch*sizeof(*partword));
- for(j=0;jstages;s++){
-
- for(i=0;i=0;k--)
- partword[0][i+k]=partword[0][i+k+1]*info->partitions;
-
- for(j=1;j=0;k--)
- partword[j][i+k]=partword[j-1][i+k];
-
- for(j=0;jopb);
- if(oggpack_eop(&vd->opb))goto eopbreak;
-
- /* this can be done quickly in assembly due to the quotient
- always being at most six bits */
- for(k=0;kbegin+i*samples_per_partition;
+ if(info->secondstages[partword[j][l][k]]&(1<partbooks[partword[j][l][k]][s];
+ if(stagebook){
+ if(decodepart(stagebook,in[j]+offset,&vb->opb,
+ samples_per_partition,-8)==-1)goto eopbreak;
}
}
-
- /* now we decode residual values for the partitions */
- for(k=0;kbegin+i*samples_per_partition;
- if(info->stagemasks[partword[j][i]]&(1<book_param+
- info->stagebooks[(partword[j][i]<<3)+s];
- if(info->type){
- if(vorbis_book_decodev_add(stagebook,in[j]+offset,&vd->opb,
- samples_per_partition,-8)==-1)
- goto eopbreak;
- }else{
- if(vorbis_book_decodevs_add(stagebook,in[j]+offset,&vd->opb,
- samples_per_partition,-8)==-1)
- goto eopbreak;
- }
- }
- }
}
- }
- }
- }
- }else{
- int max=(pcmend*ch)>>1;
- int end=(info->endend:max);
- int n=end-info->begin;
-
- if(n>0){
- int partvals=n/samples_per_partition;
- int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
-
- char *partword=
- (char *)alloca(partwords*partitions_per_word*sizeof(*partword));
- int beginoff=info->begin/ch;
-
- for(i=0;istages;s++){
- for(i=0;i=0;k--)
- partword[i+k]=partword[i+k+1]*info->partitions;
-
- /* fetch the partition word */
- temp=vorbis_book_decode(phrasebook,&vd->opb);
- if(temp==-1)goto eopbreak;
-
- /* this can be done quickly in assembly due to the quotient
- always being at most six bits */
- for(k=0;kstagemasks[partword[i]]&(1<book_param+
- info->stagebooks[(partword[i]<<3)+s];
- if(vorbis_book_decodevv_add(stagebook,in,
- i*samples_per_partition+beginoff,ch,
- &vd->opb,
- samples_per_partition,-8)==-1)
- goto eopbreak;
- }
- }
- }
}
}
}
errout:
eopbreak:
-
- return 0;
-}
+ return(0);
+}
+
+int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl,
+ ogg_int32_t **in,int *nonzero,int ch){
+ int i,used=0;
+ for(i=0;iinfo;
+
+ /* move all this setup out later */
+ int samples_per_partition=info->grouping;
+ int partitions_per_word=look->phrasebook->dim;
+ int max=(vb->pcmend*ch)>>1;
+ int end=(info->endend:max);
+ int n=end-info->begin;
+ if(n>0){
+
+ int partvals=n/samples_per_partition;
+ int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
+ int **partword=(int **)_vorbis_block_alloc(vb,partwords*sizeof(*partword));
+ int beginoff=info->begin/ch;
+
+ for(i=0;istages;s++){
+ for(i=0,l=0;iphrasebook,&vb->opb);
+ if(temp==-1)goto eopbreak;
+ partword[l]=look->decodemap[temp];
+ if(partword[l]==NULL)goto errout;
+ }
+
+ /* now we decode residual values for the partitions */
+ for(k=0;ksecondstages[partword[l][k]]&(1<partbooks[partword[l][k]][s];
+
+ if(stagebook){
+ if(vorbis_book_decodevv_add(stagebook,in,
+ i*samples_per_partition+beginoff,ch,
+ &vb->opb,
+ samples_per_partition,-8)==-1)
+ goto eopbreak;
+ }
+ }
+ }
+ }
+ }
+ errout:
+ eopbreak:
+ return(0);
+}
+
+
+vorbis_func_residue residue0_exportbundle={
+ &res0_unpack,
+ &res0_look,
+ &res0_free_info,
+ &res0_free_look,
+ &res0_inverse
+};
+
+vorbis_func_residue residue1_exportbundle={
+ &res0_unpack,
+ &res0_look,
+ &res0_free_info,
+ &res0_free_look,
+ &res1_inverse
+};
+
+vorbis_func_residue residue2_exportbundle={
+ &res0_unpack,
+ &res0_look,
+ &res0_free_info,
+ &res0_free_look,
+ &res2_inverse
+};
diff -r 3331b30e4ef1 -r 88fde28bbda6 misc/libtremor/tremor/vorbisfile.c
--- a/misc/libtremor/tremor/vorbisfile.c Sun Oct 21 01:28:33 2012 +0400
+++ b/misc/libtremor/tremor/vorbisfile.c Sat Nov 03 00:34:35 2012 +0400
@@ -12,7 +12,7 @@
********************************************************************
function: stdio-based convenience library for opening/seeking/decoding
- last mod: $Id: vorbisfile.c,v 1.6.2.4 2003/04/29 04:03:27 xiphmont Exp $
+ last mod: $Id: vorbisfile.c,v 1.6 2003/03/30 23:40:56 xiphmont Exp $
********************************************************************/
@@ -22,19 +22,11 @@
#include
#include
-#include "codec_internal.h"
+#include "ivorbiscodec.h"
#include "ivorbisfile.h"
-#include "os.h"
#include "misc.h"
-#define NOTOPEN 0
-#define PARTOPEN 1
-#define OPENED 2
-#define STREAMSET 3 /* serialno and link set, but not to current link */
-#define LINKSET 4 /* serialno and link set to current link */
-#define INITSET 5
-
/* A 'chained bitstream' is a Vorbis bitstream that contains more than
one logical bitstream arranged end to end (the only form of Ogg
multiplexing allowed in a Vorbis bitstream; grouping [parallel
@@ -72,10 +64,10 @@
unsigned char *buffer=ogg_sync_bufferin(vf->oy,CHUNKSIZE);
long bytes=(vf->callbacks.read_func)(buffer,1,CHUNKSIZE,vf->datasource);
if(bytes>0)ogg_sync_wrote(vf->oy,bytes);
- if(bytes==0 && errno)return -1;
- return bytes;
+ if(bytes==0 && errno)return(-1);
+ return(bytes);
}else
- return 0;
+ return(0);
}
/* save a tiny smidge of verbosity to make the code more readable */
@@ -111,7 +103,7 @@
while(1){
long more;
- if(boundary>0 && vf->offset>=boundary)return OV_FALSE;
+ if(boundary>0 && vf->offset>=boundary)return(OV_FALSE);
more=ogg_sync_pageseek(vf->oy,og);
if(more<0){
@@ -120,18 +112,18 @@
}else{
if(more==0){
/* send more paramedics */
- if(!boundary)return OV_FALSE;
+ if(!boundary)return(OV_FALSE);
{
long ret=_get_data(vf);
- if(ret==0)return OV_EOF;
- if(ret<0)return OV_EREAD;
+ if(ret==0)return(OV_EOF);
+ if(ret<0)return(OV_EREAD);
}
}else{
/* got a page. Return the offset at the page beginning,
advance the internal offset past the page end */
ogg_int64_t ret=vf->offset;
vf->offset+=more;
- return ret;
+ return(ret);
}
}
@@ -157,7 +149,7 @@
_seek_helper(vf,begin);
while(vf->offsetoffset);
- if(ret==OV_EREAD)return OV_EREAD;
+ if(ret==OV_EREAD)return(OV_EREAD);
if(ret<0){
break;
}else{
@@ -171,9 +163,9 @@
ret=_get_next_page(vf,og,CHUNKSIZE);
if(ret<0)
/* this shouldn't be possible */
- return OV_EFAULT;
+ return(OV_EFAULT);
- return offset;
+ return(offset);
}
/* finds each bitstream link one at a time using a bisection search
@@ -204,7 +196,7 @@
_seek_helper(vf,bisect);
ret=_get_next_page(vf,&og,-1);
- if(ret==OV_EREAD)return OV_EREAD;
+ if(ret==OV_EREAD)return(OV_EREAD);
if(ret<0 || ogg_page_serialno(&og)!=currentno){
endsearched=bisect;
if(ret>=0)next=ret;
@@ -216,7 +208,7 @@
_seek_helper(vf,next);
ret=_get_next_page(vf,&og,-1);
- if(ret==OV_EREAD)return OV_EREAD;
+ if(ret==OV_EREAD)return(OV_EREAD);
if(searched>=end || ret<0){
ogg_page_release(&og);
@@ -228,33 +220,17 @@
ret=_bisect_forward_serialno(vf,next,vf->offset,
end,ogg_page_serialno(&og),m+1);
ogg_page_release(&og);
- if(ret==OV_EREAD)return OV_EREAD;
+ if(ret==OV_EREAD)return(OV_EREAD);
}
vf->offsets[m]=begin;
vf->serialnos[m]=currentno;
- return 0;
-}
-
-static int _decode_clear(OggVorbis_File *vf){
- if(vf->ready_state==INITSET){
- vorbis_dsp_destroy(vf->vd);
- vf->vd=0;
- vf->ready_state=STREAMSET;
- }
-
- if(vf->ready_state>=STREAMSET){
- vorbis_info_clear(&vf->vi);
- vorbis_comment_clear(&vf->vc);
- vf->ready_state=OPENED;
- }
- return 0;
+ return(0);
}
/* uses the local ogg_stream storage in vf; this is important for
non-streaming input sources */
/* consumes the page that's passed in (if any) */
-/* state is LINKSET upon successful return */
static int _fetch_headers(OggVorbis_File *vf,
vorbis_info *vi,
@@ -265,17 +241,16 @@
ogg_packet op={0,0,0,0,0,0};
int i,ret;
- if(vf->ready_state>OPENED)_decode_clear(vf);
-
if(!og_ptr){
ogg_int64_t llret=_get_next_page(vf,&og,CHUNKSIZE);
- if(llret==OV_EREAD)return OV_EREAD;
+ if(llret==OV_EREAD)return(OV_EREAD);
if(llret<0)return OV_ENOTVORBIS;
og_ptr=&og;
}
ogg_stream_reset_serialno(vf->os,ogg_page_serialno(og_ptr));
if(serialno)*serialno=vf->os->serialno;
+ vf->ready_state=STREAMSET;
/* extract the initial header from the first page and verify that the
Ogg bitstream is in fact Vorbis data */
@@ -293,7 +268,7 @@
ret=OV_EBADHEADER;
goto bail_header;
}
- if((ret=vorbis_dsp_headerin(vi,vc,&op))){
+ if((ret=vorbis_synthesis_headerin(vi,vc,&op))){
goto bail_header;
}
i++;
@@ -307,7 +282,6 @@
ogg_packet_release(&op);
ogg_page_release(&og);
- vf->ready_state=LINKSET;
return 0;
bail_header:
@@ -320,45 +294,22 @@
return ret;
}
-/* we no longer preload all vorbis_info (and the associated
- codec_setup) structs. Call this to seek and fetch the info from
- the bitstream, if needed */
-static int _set_link_number(OggVorbis_File *vf,int link){
- if(link != vf->current_link) _decode_clear(vf);
- if(vf->ready_state