| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
package com.drew.metadata.mov.atoms; |
| 22 |
|
| 23 |
import com.drew.lang.SequentialReader; |
| 24 |
import com.drew.metadata.mov.QuickTimeDirectory; |
| 25 |
import com.drew.metadata.mp4.Mp4Directory; |
| 26 |
|
| 27 |
import java.io.IOException; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
public class TrackHeaderAtom extends FullAtom { |
| 37 |
int[] matrix = new int[9]; |
| 38 |
long width; |
| 39 |
long height; |
| 40 |
|
| 41 |
public TrackHeaderAtom(SequentialReader reader, Atom atom) throws IOException { |
| 42 |
super(reader, atom); |
| 43 |
|
| 44 |
if (version == 1) { |
| 45 |
reader.skip(48); |
| 46 |
} else { |
| 47 |
reader.skip(36); |
| 48 |
} |
| 49 |
|
| 50 |
for (int i = 0; i < 9; i++) { |
| 51 |
matrix[i] = reader.getInt32(); |
| 52 |
} |
| 53 |
width = reader.getInt32(); |
| 54 |
height = reader.getInt32(); |
| 55 |
} |
| 56 |
|
| 57 |
public void addMetadata(QuickTimeDirectory directory) { |
| 58 |
if (width != 0 && height != 0 && directory.getDoubleObject(Mp4Directory.TAG_ROTATION) == null) { |
| 59 |
double x = matrix[1] + matrix[4]; |
| 60 |
double y = matrix[0] + matrix[3]; |
| 61 |
double theta = Math.atan2(y, x); |
| 62 |
double degree = Math.toDegrees(theta) - 45; |
| 63 |
directory.setDouble(QuickTimeDirectory.TAG_ROTATION, degree); |
| 64 |
} |
| 65 |
} |
| 66 |
} |