/* */ package quicktime.app.image;
/* */
/* */ import java.awt.Dimension;
/* */ import quicktime.QTException;
/* */ import quicktime.QTRuntimeException;
/* */ import quicktime.QTSession;
/* */ import quicktime.app.anim.TwoDSprite;
/* */ import quicktime.qd.QDDimension;
/* */ import quicktime.std.clocks.TimeBase;
/* */ import quicktime.std.image.DSequence;
/* */ import quicktime.std.image.ICMFrameTime;
/* */ import quicktime.std.image.ImageDescription;
/* */ import quicktime.std.movies.Atom;
/* */ import quicktime.std.movies.AtomContainer;
/* */ import quicktime.std.movies.AtomData;
/* */ import quicktime.util.EndianOrder;
/* */ import quicktime.util.QTUtils;
/* */ import quicktime.util.RawEncodedImage;
/* */
/* */ /** @deprecated */
/* */ public class QTTransition extends QTFilter
/* */ {
/* */ QTFilter.ImageContainer drawDestListener;
/* 88 */ private int srcB = QTUtils.toOSType("srcB");
/* */
/* 90 */ private int mEffectDuration = 2000;
/* 91 */ private boolean mDoTime = true;
/* */ private int fps;
/* 94 */ private boolean doProfile = false;
/* 95 */ private long profileTime = 0L;
/* */ private int framesRendered;
/* */ QTEffectPresenter thePresenter;
/* */
/* */ /** @deprecated */
/* */ public QTTransition()
/* */ throws QTException
/* */ {
/* 61 */ this(new QDDimension(0, 0));
/* */ }
/* */
/* */ /** @deprecated */
/* */ public QTTransition(Dimension paramDimension)
/* */ throws QTException
/* */ {
/* 71 */ this(new QDDimension(paramDimension.width, paramDimension.height));
/* */ }
/* */
/* */ /** @deprecated */
/* */ public QTTransition(QDDimension paramQDDimension)
/* */ throws QTException
/* */ {
/* 80 */ super(2, paramQDDimension);
/* 81 */ setFramesPerSecond(20);
/* 82 */ this.currentFrame = 0;
/* */ }
/* */
/* */ /** @deprecated */
/* */ public void setEffect(AtomContainer paramAtomContainer)
/* */ throws QTException
/* */ {
/* 109 */ if (paramAtomContainer == null) {
/* 110 */ this.effectSamplePtr = null;
/* 111 */ if (this.effectSample != null) this.effectSample.unlock();
/* 112 */ this.effectSample = null;
/* 113 */ return;
/* */ }
/* */
/* 116 */ this.effectSample = paramAtomContainer;
/* 117 */ Atom localAtom1 = Atom.kParentIsContainer;
/* 118 */ int i = this.effectSample.countChildrenOfType(localAtom1, 1936876320);
/* 119 */ for (int j = 0; j < i; j++) {
/* 120 */ localObject = this.effectSample.findChildByIndex_Atom(localAtom1, 1936876320, 1);
/* 121 */ this.effectSample.removeAtom((Atom)localObject);
/* */ }
/* */
/* 124 */ this.effectSample.insertChild(localAtom1, 1936876320, 1, 0, EndianOrder.flipNativeToBigEndian32(this.srcA));
/* 125 */ this.effectSample.insertChild(localAtom1, 1936876320, 2, 0, EndianOrder.flipNativeToBigEndian32(this.srcB));
/* */
/* 127 */ Atom localAtom2 = this.effectSample.findChildByID_Atom(localAtom1, 2003329396, 1);
/* 128 */ this.effectSample.lock();
/* 129 */ Object localObject = this.effectSample.getAtomData(localAtom2);
/* */
/* 131 */ this.effectDesc.setCType(EndianOrder.flipBigEndianToNative32(((AtomData)localObject).getInt(0)));
/* 132 */ this.effectSamplePtr = RawEncodedImage.fromQTPointer(this.effectSample.toQTPointer());
/* */
/* 135 */ setUpSequence();
/* */ }
/* */
/* */ public void setDestinationImage(ImageSpec paramImageSpec)
/* */ throws QTException
/* */ {
/* 141 */ if (paramImageSpec != null) {
/* 142 */ if (this.drawDestListener != null)
/* 143 */ this.drawDestListener.dispose();
/* 144 */ this.drawDestListener = new QTFilter.ImageContainer(this, paramImageSpec);
/* */ } else {
/* 146 */ this.drawDestListener.dispose();
/* 147 */ this.drawDestListener = null;
/* */ }
/* 149 */ setUpSequence();
/* */ }
/* */
/* */ public ImageSpec getDestinationImage()
/* */ {
/* 155 */ return this.drawDestListener.image;
/* */ }
/* */
/* */ /** @deprecated */
/* */ protected synchronized boolean setUpSequence()
/* */ throws QTException
/* */ {
/* 167 */ if ((super.setUpSequence()) && (this.drawDestListener != null)) {
/* 168 */ this.drawDestListener.prepareSequence(this.srcB);
/* 169 */ return true;
/* */ }
/* */
/* 172 */ return false;
/* */ }
/* */
/* */ /** @deprecated */
/* */ public synchronized void doTransition()
/* */ throws QTException
/* */ {
/* 182 */ if (this.effectSequence == null) return;
/* */
/* 184 */ _doEffect();
/* 185 */ swapImages();
/* */ }
/* */
/* */ /** @deprecated */
/* */ public void swapImages()
/* */ throws QTException
/* */ {
/* 193 */ QTFilter.ImageContainer localImageContainer = this.drawSourceListener;
/* 194 */ this.drawSourceListener = this.drawDestListener;
/* 195 */ this.drawDestListener = localImageContainer;
/* */
/* 197 */ this.drawSourceListener.prepareSequence(this.srcA);
/* 198 */ this.drawDestListener.prepareSequence(this.srcB);
/* */
/* 200 */ redraw(null);
/* */ }
/* */
/* */ public synchronized void setFrames(int paramInt)
/* */ throws QTException
/* */ {
/* 206 */ this.mNumberOfFrames = (paramInt < 1 ? 1 : paramInt);
/* 207 */ this.mEffectDuration = ((int)(this.mNumberOfFrames / getFramesPerSecond() * 1000.0F + 0.5D));
/* 208 */ if (this.mEffectDuration < 1) this.mEffectDuration = 1;
/* 209 */ this.ft.setScale(this.mNumberOfFrames);
/* 210 */ this.ft.setDuration(this.mNumberOfFrames);
/* 211 */ this.ft.setVirtualDuration(this.mNumberOfFrames);
/* 212 */ if (this.currentFrame > this.mNumberOfFrames) this.currentFrame = this.mNumberOfFrames;
/* */ }
/* */
/* */ /** @deprecated */
/* */ public void setFramesPerSecond(int paramInt)
/* */ throws QTException
/* */ {
/* 220 */ this.mNumberOfFrames = ((int)(this.mEffectDuration / 1000.0F * paramInt + 0.5F));
/* 221 */ this.ft.setScale(this.mNumberOfFrames);
/* 222 */ this.ft.setDuration(this.mNumberOfFrames);
/* 223 */ this.ft.setVirtualDuration(this.mNumberOfFrames);
/* 224 */ if (this.currentFrame > this.mNumberOfFrames) {
/* 225 */ this.currentFrame = this.mNumberOfFrames;
/* */ }
/* 227 */ this.ft.setFrameNumber(this.currentFrame);
/* 228 */ this.fps = paramInt;
/* */ }
/* */
/* */ /** @deprecated */
/* */ public int getFramesPerSecond()
/* */ {
/* 238 */ return this.fps;
/* */ }
/* */
/* */ /** @deprecated */
/* */ public void setCurrentFrame(int paramInt)
/* */ {
/* 248 */ this.currentFrame = paramInt;
/* 249 */ if (this.currentFrame > this.mNumberOfFrames) this.currentFrame = this.mNumberOfFrames;
/* */ }
/* */
/* */ /** @deprecated */
/* */ public synchronized void setTime(int paramInt)
/* */ throws QTException
/* */ {
/* 258 */ this.mEffectDuration = (paramInt < 1 ? 1 : paramInt);
/* 259 */ this.mNumberOfFrames = ((int)(this.mEffectDuration / 1000.0D * getFramesPerSecond() + 0.5D));
/* 260 */ if (this.mNumberOfFrames < 1) this.mNumberOfFrames = 1;
/* 261 */ this.ft.setScale(this.mNumberOfFrames);
/* 262 */ this.ft.setDuration(this.mNumberOfFrames);
/* 263 */ this.ft.setVirtualDuration(this.mNumberOfFrames);
/* 264 */ if (this.currentFrame > this.mNumberOfFrames) this.currentFrame = this.mNumberOfFrames;
/* */ }
/* */
/* */ /** @deprecated */
/* */ public int getTime()
/* */ {
/* 271 */ return this.mEffectDuration;
/* */ }
/* */
/* */ /** @deprecated */
/* */ public synchronized void doTime(boolean paramBoolean)
/* */ {
/* 279 */ this.mDoTime = paramBoolean;
/* */ }
/* */
/* */ /** @deprecated */
/* */ public boolean isTime()
/* */ {
/* 287 */ return this.mDoTime;
/* */ }
/* */
/* */ /** @deprecated */
/* */ private final void _doEffect()
/* */ throws QTException
/* */ {
/* 298 */ if (this.effectSequence == null) return;
/* */
/* 300 */ int i = this.currentFrame;
/* 301 */ this.currentFrame = 1;
/* */
/* 303 */ Thread localThread = Thread.currentThread();
/* 304 */ int j = localThread.getPriority();
/* 305 */ localThread.setPriority(10);
/* */
/* 307 */ long l1 = System.currentTimeMillis();
/* 308 */ if (this.doProfile)
/* 309 */ this.framesRendered = 0;
/* */ try
/* */ {
/* 312 */ this.inEffect = true;
/* 313 */ if (isTime()) {
/* 314 */ float f1 = this.mEffectDuration / 1000.0F * getFramesPerSecond();
/* 315 */ float f2 = 0.0F;
/* 316 */ float f3 = 0.0F;
/* 317 */ drawAdvanceCurrentFrame();
/* 318 */ if (this.mNumberOfFrames > 1)
/* */ while (true) {
/* 320 */ long l2 = System.currentTimeMillis();
/* 321 */ int k = this.currentFrame;
/* 322 */ drawAdvanceCurrentFrame();
/* 323 */ if (this.currentFrame >= this.mNumberOfFrames) {
/* 324 */ if (k == this.mNumberOfFrames) break;
/* 325 */ drawAdvanceCurrentFrame();
/* 326 */ break;
/* */ }
/* */
/* 329 */ long l3 = System.currentTimeMillis();
/* 330 */ f2 = (float)(l3 - l2);
/* 331 */ long l4 = this.mEffectDuration - (l3 - l1);
/* 332 */ if (l4 <= 0L) {
/* 333 */ this.currentFrame = this.mNumberOfFrames;
/* 334 */ drawAdvanceCurrentFrame();
/* 335 */ break;
/* */ }
/* 337 */ f3 = (float)(l4 / (this.mNumberOfFrames - this.currentFrame));
/* 338 */ float f4 = f3 - f2;
/* 339 */ if (f4 < 0.0F) {
/* 340 */ this.currentFrame += (int)(f2 / f3 + 0.5F);
/* 341 */ if (this.currentFrame >= this.mNumberOfFrames) {
/* 342 */ this.currentFrame = this.mNumberOfFrames;
/* 343 */ drawAdvanceCurrentFrame();
/* 344 */ break;
/* */ }
/* */ } else {
/* */ try {
/* 348 */ Thread.sleep(()f4);
/* */ } catch (InterruptedException localInterruptedException) {
/* */ }
/* */ }
/* */ }
/* 353 */ if (this.doProfile)
/* 354 */ this.profileTime = (System.currentTimeMillis() - l1);
/* */ }
/* */ else {
/* 357 */ this.currentFrame = 1;
/* */ while (true) { drawAdvanceCurrentFrame();
/* 359 */ if (this.currentFrame == 1) break;
/* 360 */ Thread.yield();
/* */ }
/* */ }
/* 363 */ this.inEffect = false;
/* */ }
/* */ finally
/* */ {
/* 367 */ localThread.setPriority(j);
/* 368 */ this.currentFrame = i;
/* 369 */ this.inEffect = false;
/* */ }
/* 371 */ if (this.doProfile)
/* 372 */ this.profileTime = (System.currentTimeMillis() - l1);
/* */ }
/* */
/* */ /** @deprecated */
/* */ public void setProfiled(boolean paramBoolean)
/* */ {
/* 383 */ this.doProfile = paramBoolean;
/* */ }
/* */
/* */ /** @deprecated */
/* */ public boolean isProfiled()
/* */ {
/* 390 */ return this.doProfile;
/* */ }
/* */
/* */ /** @deprecated */
/* */ public int profileFramesRendered()
/* */ {
/* 400 */ if (!this.doProfile) return 0;
/* 401 */ return this.framesRendered;
/* */ }
/* */
/* */ /** @deprecated */
/* */ public int profileDuration()
/* */ {
/* 411 */ if (!this.doProfile) return 0;
/* 412 */ return (int)this.profileTime;
/* */ }
/* */
/* */ private void drawAdvanceCurrentFrame() throws QTException {
/* 416 */ this.tb.setValue(this.currentFrame, this.mNumberOfFrames);
/* 417 */ this.ft.setValue(this.currentFrame);
/* 418 */ this.effectSequence.decompressFrameWhen(this.effectSamplePtr, 0, this.ft);
/* 419 */ this.currentFrame += 1;
/* 420 */ this.framesRendered += 1;
/* 421 */ if (this.currentFrame > this.mNumberOfFrames)
/* 422 */ this.currentFrame = 1;
/* 423 */ if (this.thePresenter != null)
/* 424 */ this.thePresenter.sprite.invalidate();
/* */ }
/* */
/* */ static
/* */ {
/* 49 */ if ((QTSession.isCurrentOS(4)) && (QTSession.getJavaVersion() >= 65540))
/* 50 */ throw new QTRuntimeException("Unsupported on Mac OS X and Java 1.4 and higher.");
/* */ }
/* */ }
/* Location: Z:\System\Library\Java\Extensions\QTJava.zip
* Qualified Name: quicktime.app.image.QTTransition
* JD-Core Version: 0.6.2
*/