 |
Welcome to the Natami / Amiga ForumThis forum is for AMIGA fans interested in the new NATAMI platform.
Please read the forum usage manual.
|
Welcome to the Natami lounge. Meet new AMIGA friends here and enjoy having a friendly chit chat. |
|
|---|
Thomas Richter Germany
| | (MX-Board Owner) Posts 1425 02 Jun 2012 15:28
| Well, while I believe that we have to wait for a very long time for the super-fast JPEG 2000 implementation that was promised here a while ago, I wasn't idle. No, I didn't make a super-fast JPEG codec because I don't care. But I did a JPEG codec, from ground up, with only reading the specs. However, this wasn't an akademic exercise, and actually not really a part of the Natami development (though see below!). The point was more to advance JPEG as a standard. If you don't know, I'm a member in this club, and this is something a subgroup of us is currently looking into. So it requires a demo code to trigger the interest of the committee. And there it is: EXTERNAL LINK The login name is "anonymous", then password is "jpeg". The bug tracker is here: EXTERNAL LINK The cool and new feature of this code is "lossless coding", and 12bpp support (HDR-image support), that is, you can now code your images without loss in JPEG, fully backwards compatible. Which means that all existing implementations will be able to view the images all right, though likely with a minimal loss. If you do not tolerate any loss, you need to decode with this codec. The code is free software, released under GPLv3, ready for everyone to look at, use and compile. And if you check out how the codec works, you'll clearly notice my Amiga background: Tag lists and hooks all over the place, but now in nice C++. Unfortunately, I was not able to add a couple of nice tricks to make it faster. As this codec was partially paid for by my industry partners, I cannot release all their technology for free. (Only some. (-;) Anyhow, have fun. And probably someone wants to turn this into an Amiga datatype, or a library.
| |
Gone Gahgah Australia
| | Posts 237 02 Jun 2012 16:42
| I knew you were smart. Well done and thank you for doing that for the community as well. Hopefully someone will be able to take it up. I got back into some dabbling this past week and have been having enough trouble just trying to squash bugs in some ilbm reading and remapping code (let alone trying to code the whole jpeg like you've done). Can't remember why I was rolling my own code instead of using a datatype but there probably was a reason. Probably it was the only way I could remap the data into image format for some home grown image classes that include transparent backgrounds (kinda BOB like I guess but without all the extra fields). I finally got my code to load TCL's Amiga Tick checkmark correctly (after squashing 5 bugs) and have been changing over to loading icons instead of using hard coded ones. I still have a few bugs. At times it gives different random icons a white background. I always love random occurances. Also sometimes it maps occasional bits as transparent that shouldn't be and I don't know why as yet. At least they always seem to be the same bits so there is at least a pattern hopefully. Fun, fun, fun. Here's a picture just to show the nice icons. I'm no artist but the new qualifier icons look a bit better than the old ones. If you look you can see there is still a bit of a mix of old and new which have to be integrated some day and that I haven't worked on realigning things yet in the change. EXTERNAL LINK Also you can see how the Open & Save icons have decided to have white backgrounds this time and how a few bits on the Amiga key are transparent that shouldn't be?
| |
Gone Gahgah Australia
| | Posts 237 17 Jun 2012 00:43
| Hey Thomas. You've shown a great deal of understanding of the Amiga system and I was wondering if you might know whether something is feasible? Is it possible to set the WFLG_MENUSTATE flag of the active window from the commodity chain and do so safely? I'm contemplating whether I can move my menu system outside of Intuition (for the moment). The reason I'm contemplating it is so that I can draw my own menu strip and also so that I can bypass the 32menu*64item*32subitem limits. Not to say that that number is usually ever a problem but one of the things I like about the Amiga was the notion to not set limits. Also some programs, like Open Office, use subsubitems which isn't currently supported. I got around menu bars eating up menu items by getting the first menu item to draw them but I could replace that completely also. So back to the main question; do you have any warnings on the use of WFLG_MENUSTATE outside Intuition inside the commodity chain?
| |
Thomas Richter Germany
| | (MX-Board Owner) Posts 1425 17 Jun 2012 12:32
| gone gahgah wrote:
| Is it possible to set the WFLG_MENUSTATE flag of the active window from the commodity chain and do so safely?
|
Not at least by calling intuition from the commodity chain. This chain is run in the context of the input.device task, and *typically* intuition works by also placing events on the very chain and then waiting for its input handler to do the work. In other words, many intuition calls will place an event in the input device event chain and then wait for the intuition input handler to respond. This clearly doesn't work if you're calling from the input device task yourself.Thus, what you can do is run another task, forward a message from the input.device task to that task, and do the operations from there so you cannot deadlock. The signalling between the commodity handler and the worker task should then be asynchronous, of course. gone gahgah wrote:
| The reason I'm contemplating it is so that I can draw my own menu strip and also so that I can bypass the 32menu*64item*32subitem limits.
|
It is only a limit in so far as event signalling goes. But anyhow, if you have more than 64 items or 32 subitems, you have a usability problem in first place. Menus should never grow that large.So long, Thomas
| |
Gone Gahgah Australia
| | Posts 237 17 Jun 2012 13:45
| Thomas Richter wrote:
| | It is only a limit in so far as event signalling goes. But anyhow, if you have more than 64 items or 32 subitems, you have a usability problem in first place. Menus should never grow that large. |
I absolutely agree. About the most I have ever seen is 37 menu items ie. in Audacity in its "Effects" menu. I mean primarily for further sublevels like OpenOffice which has: "Tools>>Macros>>Organize Macros>>OpenOffice.org Basic..." I would expect developers to create menus as size sensible and usable as possible; but it wouldn't hurt to accommodate users if they choose to have many items for whatever reason - though its not likely to be the case for many people if anyone.
Thomas Richter wrote:
| Not at least by calling intuition from the commodity chain. This chain is run in the context of the input.device task, and *typically* intuition works by also placing events on the very chain and then waiting for its input handler to do the work. In other words, many intuition calls will place an event in the input device event chain and then wait for the intuition input handler to respond. This clearly doesn't work if you're calling from the input device task yourself. Thus, what you can do is run another task, forward a message from the input.device task to that task, and do the operations from there so you cannot deadlock. The signalling between the commodity handler and the worker task should then be asynchronous, of course. |
What would likely happen if the commodity intercepted the menu button, found the window the mouse was over, and directly set its WFLG_MENUSTATE (after activating the window like autopoint), before drawing menus (instead of Intuition), and then undrew the alternate menu and cleared the flag when the menu button was released? Would you know of some of the likely side-effects (including crash?) Does the WFLG_MENUSTATE flag stop any drawing into the screen while the menu is active? (I'd like to support both screen blocking and non-blocking options for menus). Cheers.
| |
Thomas Richter Germany
| | (MX-Board Owner) Posts 1425 20 Jun 2012 19:09
| gone gahgah wrote:
| I mean primarily for further sublevels like OpenOffice which has: "Tools>>Macros>>Organize Macros>>OpenOffice.org Basic..."
|
Not exactly a prime example of good usability. I don't see how the *current* intuition could support this. Fortunately, intuition is pretty closed, thus doesn't provide you much insight into its inner workings. Thus, this cannot be changed without changing intuition (which is not such a bad plan, either).gone gahgah wrote:
| What would likely happen if the commodity intercepted the menu button,
|
How do you do that? As far as I remember, Cx sits behind the intuition input handler, and thus only receives "cooked" events intuition already worked on, so you cannot intercept them. For that, you need an input handler ahead of intuition, but then you don't know whether you received a RMB for a menu. Or you do, but then need to implement *all* the intuition handling yourself, i.e. RMB trap Double RMB requester, MenuVerify etc... MagicMenu tried this, and of course, failed to run reliable.gone gahgah wrote:
| found the window the mouse was over,
|
How do you do that? The problem is here that the window arrangement is in the hands of intuition. What you can do is *lock the layerinfo*, get from the mouse position the layer it is on (WhichLayer()) from there work upwards to the window. But this information doesn't help you much because you cannot ensure that the pointer you receive remains valid at the time you use it - only intuition can. And you cannot lock intuition for the pointer to stay valid because then you cannot call intuition functions. It is the classical intuition "chicken and egg" problem.gone gahgah wrote:
| and directly set its WFLG_MENUSTATE (after activating the window like autopoint), before drawing menus (instead of Intuition), and then undrew the alternate menu and cleared the flag when the menu button was released? Would you know of some of the likely side-effects (including crash?)
|
It would "work" in the same sense MagicMenus "worked". Which means, with a lot of effort, you could make it work "most of the time", with potential race conditions, and potential compatibility issues (MagicMenus never implemented the intuition MenuVerify logic correctly, for example - it could not, due to reasons I indicated above).gone gahgah wrote:
| Does the WFLG_MENUSTATE flag stop any drawing into the screen while the menu is active? (I'd like to support both screen blocking and non-blocking options for menus).
|
I don't know, but I would believe that intuition rather sets this flag than looking at it. In a program, what *you* can do is to enable the MenuVerify IDCMP messages and then react on what you get from intuition. Or, possibly better, just set RMBTrap and instead of rendering menus by intuition, open borderless windows that look like menus. *This* works. It would be inconsistent with the rest of the system, and the menus wouldn't look like intuition menus, but it is waterproof and valid. One would probably have to play a bit with the window input focus now that I think about it, but this seems solvable.
| |
Gone Gahgah Australia
| | Posts 237 21 Jun 2012 11:46
| Thomas Richter wrote:
| | Not exactly a prime example of good usability. I don't see how the *current* intuition could support this. Fortunately, intuition is pretty closed, thus doesn't provide you much insight into its inner workings. Thus, this cannot be changed without changing intuition (which is not such a bad plan, either). |
I think apps in most cases should avoid this, even if programmed with these expanded menus, but I am keen to allow users to do it themselves when they want too, and also the odd time in apps where it hopefully makes sense to do so. I don't think it would be a wasted feature. It was that or having cycle items in menus which I've decided against.Thomas Richter wrote:
| | How do you do that? As far as I remember, Cx sits behind the intuition input handler, and thus only receives "cooked" events intuition already worked on, so you cannot intercept them. For that, you need an input handler ahead of intuition, but then you don't know whether you received a RMB for a menu. Or you do, but then need to implement *all* the intuition handling yourself, i.e. RMB trap Double RMB requester, MenuVerify etc... MagicMenu tried this, and of course, failed to run reliable. |
Thomas, the CX input handler is before the Intuition input handler in the chain. EXTERNAL LINK So all the events are raw and the input chain can be changed in the ways you mentioned. MagicMenu did have problems though. I thought MagicMenu actually illegally patched Intuition?gone gahgah wrote:
| | found the window the mouse was over, |
Thomas Richter wrote:
| | How do you do that? The problem is here that the window arrangement is in the hands of intuition. What you can do is *lock the layerinfo*, get from the mouse position the layer it is on (WhichLayer()) from there work upwards to the window. But this information doesn't help you much because you cannot ensure that the pointer you receive remains valid at the time you use it - only intuition can. And you cannot lock intuition for the pointer to stay valid because then you cannot call intuition functions. It is the classical intuition "chicken and egg" problem. |
I already do that with my 'mousezone' commodity using the process you describe. This is the same as how autopoint works too. The input event comes with a mouse position which is what Intuition receives as well.gone gahgah wrote:
| | and directly set its WFLG_MENUSTATE (after activating the window like autopoint), before drawing menus (instead of Intuition), and then undrew the alternate menu and cleared the flag when the menu button was released? Would you know of some of the likely side-effects (including crash?) |
Thomas Richter wrote:
| | It would "work" in the same sense MagicMenus "worked". Which means, with a lot of effort, you could make it work "most of the time", with potential race conditions, and potential compatibility issues (MagicMenus never implemented the intuition MenuVerify logic correctly, for example - it could not, due to reasons I indicated above). |
I'm only hoping to do it for apps that are specifically programmed to use the new menus. I'd leave the rest be handled as normal. Would that work?gone gahgah wrote:
| | Does the WFLG_MENUSTATE flag stop any drawing into the screen while the menu is active? (I'd like to support both screen blocking and non-blocking options for menus). |
Thomas Richter wrote:
| | I don't know, but I would believe that intuition rather sets this flag than looking at it. |
Intuition would set it for some purpose. The description for the flag says "Window is active with Menus on". I was just seeing if you might know. I guess I can test it by adding a "watcher" to my MouseZone commodity that specifically tests this and try different things.Thomas Richter wrote:
| | In a program, what *you* can do is to enable the MenuVerify IDCMP messages and then react on what you get from intuition. Or, possibly better, just set RMBTrap and instead of rendering menus by intuition, open borderless windows that look like menus. *This* works. It would be inconsistent with the rest of the system, and the menus wouldn't look like intuition menus, but it is waterproof and valid. One would probably have to play a bit with the window input focus now that I think about it, but this seems solvable. |
It would be system problem free but then you have to wait for the program to process the events which could make it feel laggy. That's what I want to avoid. For example, I've designed the zoneclass 'gadgets' to avoid causing lagginess by being able to delay their rendering so that they don't cause any lag to the input chain.I'll try to get to testing this flag hopefully sometime soon.
| |
Jacek Rafal Tatko Espania
| | Posts 607 21 Jun 2012 13:01
| Thomas , how much code would be required to fit the optimal jpeg codec ? Aproximately ... Would it be possible & make sense to write it in Assembler to achieve the ultimate goal , save space & execution time or would it be almost equally in size & execution speed if one would use C(++) ( , python , ) and assembler , in a mix - as it happens most of the time ? How much time would it take on our platform to give it The Best in jpeg codec programming ?
| |
Thomas Richter Germany
| | (MX-Board Owner) Posts 1425 21 Jun 2012 20:07
| gone gahgah wrote:
| Thomas, the CX input handler is before the Intuition input handler in the chain. EXTERNAL LINK So all the events are raw and the input chain can be changed in the ways you mentioned. MagicMenu did have problems though. I thought MagicMenu actually illegally patched Intuition?
|
Well, I do have problems with patches, but that is not exactly the point, and not quite the problem. The problem is a logical design problem, namely that I'm not aware of a method to circumvent the intuition menu handling without either running into the risk of deadlocking, or without having race conditions somewhere. Magic Menu tried a lot to avoid these, but they cannot be completely avoided. See my answer where the problem actually comes from.gone gahgah wrote:
| I already do that with my 'mousezone' commodity using the process you describe. This is the same as how autopoint works too. The input event comes with a mouse position which is what Intuition receives as well.
|
Oh, sure, but this causes a race-condition: You do not know whether the window pointer you have is actually valid the time you run into an ActivateWindow(). IOWs, Autopoint is not safe and may crash the system. If the window goes away between the test of autopoint, and the actual call of ActivateWindow(), you'll be doomed. Since we're multithreaded, this may actually happen.gone gahgah wrote:
| I'm only hoping to do it for apps that are specifically programmed to use the new menus. I'd leave the rest be handled as normal. Would that work?
|
I wonder what the requirements for such applications would be. Honestly, I don't know.gone gahgah wrote:
| I was just seeing if you might know. I guess I can test it by adding a "watcher" to my MouseZone commodity that specifically tests this and try different things.
|
Well, while I don't know exactly intuition uses this flag internally, but the reason why nothing else can be drawn on the screen while the menu is active is a different one: This is a side effect that intuition holds the LayerInfo lock of the screen the window is on, which prevents other layers (and hence windows) to be created on top of the menu.gone gahgah wrote:
| It would be system problem free but then you have to wait for the program to process the events which could make it feel laggy.
|
Fair enough, question is whether it matters.So long, Thomas
| |
Thomas Richter Germany
| | (MX-Board Owner) Posts 1425 21 Jun 2012 20:22
| Jacek Rafal Tatko wrote:
| Thomas , how much code would be required to fit the optimal jpeg codec ? Aproximately ...
|
Depends on your metric, i.e. what you mean by "optimal". And depends on the platform, and the means you have.Just to give you an idea: There is always new hardware coming out you can adapt to, and for that reason algorithms always change a bit. I have here my own JPEG 2000 codec I'm working on, actually more or less since the last ten(!) years. I wouldn't call it optimal. Just damn pretty good. (-; For JPEG, the story is about the same: The professional JPEG (not the implementation I linked to above) also has a history of about the same time, even a bit longer. I would neither call it "optimal", but you'll have a pretty hard time finding something faster and more robust. Jacek Rafal Tatko wrote:
| Would it be possible & make sense to write it in Assembler to achieve the ultimate goal , save space & execution time or would it be almost equally in size & execution speed if one would use C(++) ( , python , ) and assembler , in a mix - as it happens most of the time ?
|
I'm a bit scratching my head over this question. The question is not so much whether you could in principle, but whether you would. JPEG baseline is not so big, so this is a doable project. Complete JPEG (and not just the stuff everyone does) is considerably larger and complex. What I linked above is a *complete* JPEG and not just the ... IJG gives you. That would take longer. JPEG 2000 would take incredibly long.The problem is not really taking an algorithm and translating it line by line into assembler. You don't reach optimality this way. A bubblesort in assembler is still an O(N^2) algorithm, and still slow. Typically, you rewrite an implementation several times before it becomes ideal or you're at least happy about it. The wavelet transformation in my JPEG 2000 I wrote three times (or four times if you count in my latest archivements). You don't do that with assembler - refactoring is a must in projects such size, and refactoring in assembler is a headache. Writing complex(!) software simply doesn't work by writing code line by line - it is an endless process of refactoring and improvement after improvement - it is a dynamic living piece of work, where assembly would slow you down to a crawl. IOW, theoretically yes. Practically, you're likely dead before reaching the quality you reach in other languages. Jacek Rafal Tatko wrote:
| How much time would it take on our platform to give it The Best in jpeg codec programming ?
|
Is a full JPEG better than baseline only? I would say so. Does it take longer to optimize? I would say so. How long do you want to wait? That is the question. Not *when* to reach an optimum. You simply don't.
| |
Gone Gahgah Australia
| | Posts 237 21 Jun 2012 23:30
| Thomas Richter wrote:
| | Oh, sure, but this causes a race-condition: You do not know whether the window pointer you have is actually valid the time you run into an ActivateWindow(). IOWs, Autopoint is not safe and may crash the system. If the window goes away between the test of autopoint, and the actual call of ActivateWindow(), you'll be doomed. Since we're multithreaded, this may actually happen. |
I did a search for the Autopoint code but only came up with the AROS version which appears to be like you say. I was sure the original Autopoint code used LockIBase() to prevent what you're saying? I'm sure I got the idea to use LockIBase() from somewhere. As per the Libraries manual: "It is sometimes necessary to examine the IntuitionBase structure. Items such as the address of the active screen and window, current mouse coordinates and more can be found there. It is never a good idea to simply read these fields, as they are prone to sudden change. The IntuitionBase structure must always be locked before looking at its fields." As I mentioned, I try to make sure I keep the lock in place for as short a time as possible as per the manual: "It is necessary to inform Intuition that an application is about to examine IntuitionBase so that Intuition will not change any variables and IntuitionBase will remain static during the access. The call LockIBase() will lock the state of IntuitionBase so that it may be examined. During the time that the application has IntuitionBase locked, all Intuition input processing is frozen. Make every effort to examine IntuitionBase and release the lock as quickly as possible."
| |
Thomas Richter Germany
| | (MX-Board Owner) Posts 1425 22 Jun 2012 12:43
| gone gahgah wrote:
| I did a search for the Autopoint code but only came up with the AROS version which appears to be like you say. I was sure the original Autopoint code used LockIBase() to prevent what you're saying?
|
No, that wouldn't work either. You cannot call ActivateWindow() with IBase locked because then intuition will deadlock. Intuition will first lock IBase itself (harmless, since it is already locked), then generate an event for the input handler, transmit this to the input handler, then unlock IBase. The input handler, requiring access to IBase, will then lock it itself, modify the window structures, and unlock IBase again. And this latter step fails if the caller had IBase locked.As I already said, there is no solution to this problem. It is a typical intuition design problem - unless *you* control the lifetime of the window, the window pointer helps little. A similar problem appears in MagicMenu. There is no fix, and no patch, and it could actually not be any different. You are basically manipulating an object you do not own, and hence do not control the lifetime of.
| |
Gone Gahgah Australia
| | Posts 237 22 Jun 2012 15:09
| Hmmm, I was contemplating if ActivateWindow() might be a problem. I had thought that I must have actually tested it but I mustn't have. I only have the MouseZone commodity running and don't appear to have made an AutoPoint commodity of my own so I can't have. Must have just assumed it would work which is never good. I will test it anyway to confirm though I do believe you. That's why I ask you; you seem to know these little details somehow. It's not a problem for my zoneclass gadgets as I do ensure that there is a way to stop windows closing while the gadgets are being talked too so that is okay. It may or may not be the problem either for moving newer menus outside Intuition into the commodities chain but there may be other problems that you have mentioned and suspect. I'll have to test the idea out which shouldn't be too hard to do in a simple form. But it would be a bit of a bummer for AutoPoint. I can certainly guarantee that zoneclass compliant windows will stay around but I couldn't guarantee that for other windows. Maybe what I'm doing could be a longer term solution at some point? It is however illegal at the moment as I'm purloining a windows structure bit without official sanction. I don't like doing unsanctioned aka possible future fail things either - including hacking Intuition like MagicMenu.
| |
Jacek Rafal Tatko Espania
| | Posts 607 23 Jun 2012 16:23
| .oO A cool looking & illustrative view on several sorting algorithms : O(n^2) : EXTERNAL LINK General : EXTERNAL LINK Oo.JRT
| |
Jacek Rafal Tatko Espania
| | Posts 607 01 Jul 2012 00:14
| Thank You Thomas for sharing your thoughts , I got some inspiration and some questions answered . Regarding my metric or what I would call optimal ... I am very obsessed with the idea of optimal code , aware of huge complexities throughout programm creation and systemic integration , I would call optimal code the least amount of commands that use the least amount of clocks and bytes on a processor to achieve what has to be done most efficiently . My idea of efficiency is maxing it out , no matter how , so the complex programs while running concurrently would be always more responsive compared to clunkerplatforms that use a lot of pipelines and clocks per command like intels with MS-OS's ( Multiple Sklerosis OS , or Apple's Unix-variant , or Linux's ) . My idea is to write once a marvel algorithm & enjoy it henceforth . In the case of Amiga|Natami , I would say that a possible approach would be to glue the inicial vision in C | C++ and then retrofit improvements with Assembler using the very best macro-asm libraries out there , to create them with modularity and with an eye for universality if and as needed to obtain tiny small and highly efficient programs that fullfill all kind of needed functions . All that will become over time an asset that can be significant , even in the case of producing a higher clocked processor in the future , better is . A programm or codec would consume less clocks , be more responsive in a running system , shuffle less bytes per task and consume upto e.g. 4x less energy . This CISC can use upto 5 parameters per command in one cycle at best ... to some point such advantages can be leveraged and other tricks are known to the most experienced . It would be a cool culture ... as programming is art . I think that it is of course a huge goal , that is why it can only be achieved as a ' game ' , open to all that participate in the platform . It must become and be more funny to do , otherwise the motivation would not take off . In the end , we would beat others to the clock . ( Boing Clock Boing Clock , Boing Boom Chack , you get the idea :) I want Natami to be the best of the best and the best of the rest . I see things from the perspective of an ( extremely , highly obsessed ) artist of a future that is yet to come , to be envisioned thoroughly :D Well , in any case , I hope you found that entertaining enough & somewhat clarifying my idealistic & optimistic view of bits'n'bytes . Oo.JRT - Scaring the Hell out of a Meditating Guru .oO 555
| |
|
|
|
|