Re: [flexcoders] JPGEncoder with progress support?
As far as I know, callLater is part of the Flex framework. You can't use that if you're writing your own AS3 classes that do nothing with the framework... cheers, jon On Sep 23, 2007, at 1:29 PM, Arpit Mathur wrote: on using timer for screen updates: Is there any advantage (or disadvantage) of that vs. callLater ?
RE: [flexcoders] JPGEncoder with progress support?
callLater() is a method of the UIComponent class. JPEGEncoder is part of the Flex 3 framework (mx.graphics.codec.JPEGEncoder) but it doesn't extend UIComponent. - Gordon From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jon Bradley Sent: Monday, September 24, 2007 6:04 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] JPGEncoder with progress support? As far as I know, callLater is part of the Flex framework. You can't use that if you're writing your own AS3 classes that do nothing with the framework... cheers, jon On Sep 23, 2007, at 1:29 PM, Arpit Mathur wrote: on using timer for screen updates: Is there any advantage (or disadvantage) of that vs. callLater ?
RE: [flexcoders] JPGEncoder with progress support?
the corelib version This class is now an official part of Flex 3: mx.graphics.codec.JPEGEncoder. - Gordon From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jon Bradley Sent: Saturday, September 22, 2007 11:03 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] JPGEncoder with progress support? Sure does Doug! Thanks for the tips. I'm actually re-writing the corelib version now to make it more efficient for larger images. Right now encoding a 2k image takes much longer than I'm happy with. :) I was doing a bit more research and will be breaking it up into 'chunks' with progress events, hopefully. If I get a good result I'll post back the code to the corelib project. peace, jon On Sep 22, 2007, at 1:38 PM, Doug McCune wrote: This is doable, but requires a little more work than you probably think. To do this you would modify JPEGEncoder, if you're using Moxie take a look at the JPEGEncoder class around line 121. You'll see this double for loop: for (var ypos:int = 0; ypos height; ypos += 8) { for (var xpos:int = 0; xpos width; xpos += 8) { RGB2YUV(source, xpos, ypos, width, height); DCY = processDU(YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT); DCU = processDU(UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); DCV = processDU(VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); } } As far as I can tell that's where the bulk of the processing happens. What you're going to want to do is add progress events dispatching in there. But simply dispatching progress events isn't going to be enough. That would effectively give you notifications for progress of encoding, but since flash player is single threaded, your display won't ever have time to update while those for loops are running. So you'll need to split the processing up into smaller tasks and insert idle times between them. You'll want to use the Timer class to make your code wait for a given period (I've found that even just a few milliseconds is enough for the display to update). I would split up the algorithm to process one row at a time (so basically that inner for loop gets turned into its own function). Then have the function that processes a row start a timer once it's completed, and once that timer completes, then run the function for the next row and so on until you finish. That was you can dispatch a progress event for each row and the display will have time to update. Hope some of that makes sense. Doug
Re: [flexcoders] JPGEncoder with progress support?
Yea - but I haven't bothered to dl the flex 3 sdk yet. Ah, so much to do... :) Plus, I think it could use some some speeding up and control over whether or not to distribute the processing into chunks or as one continuous processed block. On Sep 23, 2007, at 12:43 PM, Gordon Smith wrote: the corelib version This class is now an official part of Flex 3: mx.graphics.codec.JPEGEncoder.
Re: [flexcoders] JPGEncoder with progress support?
on using timer for screen updates: Is there any advantage (or disadvantage) of that vs. callLater ? On 9/23/07, Gordon Smith [EMAIL PROTECTED] wrote: the corelib version This class is now an official part of Flex 3: mx.graphics.codec.JPEGEncoder. - Gordon -- *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Jon Bradley *Sent:* Saturday, September 22, 2007 11:03 AM *To:* flexcoders@yahoogroups.com *Subject:* Re: [flexcoders] JPGEncoder with progress support? Sure does Doug! Thanks for the tips. I'm actually re-writing the corelib version now to make it more efficient for larger images. Right now encoding a 2k image takes much longer than I'm happy with. :) I was doing a bit more research and will be breaking it up into 'chunks' with progress events, hopefully. If I get a good result I'll post back the code to the corelib project. peace, jon On Sep 22, 2007, at 1:38 PM, Doug McCune wrote: This is doable, but requires a little more work than you probably think. To do this you would modify JPEGEncoder, if you're using Moxie take a look at the JPEGEncoder class around line 121. You'll see this double for loop: for (var ypos:int = 0; ypos height; ypos += 8) { for (var xpos:int = 0; xpos width; xpos += 8) { RGB2YUV(source, xpos, ypos, width, height); DCY = processDU(YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT); DCU = processDU(UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); DCV = processDU(VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); } } As far as I can tell that's where the bulk of the processing happens. What you're going to want to do is add progress events dispatching in there. But simply dispatching progress events isn't going to be enough. That would effectively give you notifications for progress of encoding, but since flash player is single threaded, your display won't ever have time to update while those for loops are running. So you'll need to split the processing up into smaller tasks and insert idle times between them. You'll want to use the Timer class to make your code wait for a given period (I've found that even just a few milliseconds is enough for the display to update). I would split up the algorithm to process one row at a time (so basically that inner for loop gets turned into its own function). Then have the function that processes a row start a timer once it's completed, and once that timer completes, then run the function for the next row and so on until you finish. That was you can dispatch a progress event for each row and the display will have time to update. Hope some of that makes sense. Doug -- Arpit Mathur Lead Software Engineer, Comcast Interactive Media --- post your flex tips on http://flextips.corank.com
[flexcoders] JPGEncoder with progress support?
Has anyone attempted to modify the corelib JPGEncoder to support progress. Rather than letting it bang away for a seemingly long time, I'd like to provide feedback for JPG (and PNG) compression if possible. many thanks for any pointers... - jon
Re: [flexcoders] JPGEncoder with progress support?
This is doable, but requires a little more work than you probably think. To do this you would modify JPEGEncoder, if you're using Moxie take a look at the JPEGEncoder class around line 121. You'll see this double for loop: for (var ypos:int = 0; ypos height; ypos += 8) { for (var xpos:int = 0; xpos width; xpos += 8) { RGB2YUV(source, xpos, ypos, width, height); DCY = processDU(YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT); DCU = processDU(UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); DCV = processDU(VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); } } As far as I can tell that's where the bulk of the processing happens. What you're going to want to do is add progress events dispatching in there. But simply dispatching progress events isn't going to be enough. That would effectively give you notifications for progress of encoding, but since flash player is single threaded, your display won't ever have time to update while those for loops are running. So you'll need to split the processing up into smaller tasks and insert idle times between them. You'll want to use the Timer class to make your code wait for a given period (I've found that even just a few milliseconds is enough for the display to update). I would split up the algorithm to process one row at a time (so basically that inner for loop gets turned into its own function). Then have the function that processes a row start a timer once it's completed, and once that timer completes, then run the function for the next row and so on until you finish. That was you can dispatch a progress event for each row and the display will have time to update. Hope some of that makes sense. Doug On 9/22/07, Jon Bradley [EMAIL PROTECTED] wrote: Has anyone attempted to modify the corelib JPGEncoder to support progress. Rather than letting it bang away for a seemingly long time, I'd like to provide feedback for JPG (and PNG) compression if possible. many thanks for any pointers... - jon
Re: [flexcoders] JPGEncoder with progress support?
Sure does Doug! Thanks for the tips. I'm actually re-writing the corelib version now to make it more efficient for larger images. Right now encoding a 2k image takes much longer than I'm happy with. :) I was doing a bit more research and will be breaking it up into 'chunks' with progress events, hopefully. If I get a good result I'll post back the code to the corelib project. peace, jon On Sep 22, 2007, at 1:38 PM, Doug McCune wrote: This is doable, but requires a little more work than you probably think. To do this you would modify JPEGEncoder, if you're using Moxie take a look at the JPEGEncoder class around line 121. You'll see this double for loop: for (var ypos:int = 0; ypos height; ypos += 8) { for (var xpos:int = 0; xpos width; xpos += 8) { RGB2YUV(source, xpos, ypos, width, height); DCY = processDU(YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT); DCU = processDU(UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); DCV = processDU(VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); } } As far as I can tell that's where the bulk of the processing happens. What you're going to want to do is add progress events dispatching in there. But simply dispatching progress events isn't going to be enough. That would effectively give you notifications for progress of encoding, but since flash player is single threaded, your display won't ever have time to update while those for loops are running. So you'll need to split the processing up into smaller tasks and insert idle times between them. You'll want to use the Timer class to make your code wait for a given period (I've found that even just a few milliseconds is enough for the display to update). I would split up the algorithm to process one row at a time (so basically that inner for loop gets turned into its own function). Then have the function that processes a row start a timer once it's completed, and once that timer completes, then run the function for the next row and so on until you finish. That was you can dispatch a progress event for each row and the display will have time to update. Hope some of that makes sense. Doug