8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.media.jfxmedia.control;
27
28 import java.util.EnumSet;
29 import java.util.HashMap;
30 import java.util.Map;
31
32 public enum VideoFormat {
33 /** Packed ARGB, in memory A,R,G,B alpha is NOT pre-multiplied.
34 * This is synonymous with BYTE_ARGB */
35 ARGB(FormatTypes.FORMAT_TYPE_ARGB),
36 /** Packed BGRA, in memory B,G,R,A alpha is pre-multiplied.
37 * This format is synonymous with BYTE_BGRA_PRE or little endian INT_ARGB_PRE */
38 BGRA_PRE(FormatTypes.FORMAT_TYPE_BGRA_PRE),
39 /** Planar YCbCr 4:2:0, alpha channel is optional. The presence of a fourth
40 * plane indicates alpha is present */
41 YCbCr_420p(FormatTypes.FORMAT_TYPE_YCBCR_420P),
42 /** Packed YCbCr 4:2:2, no alpha support (Only used on Mac currently). This
43 * format is synonymous with the 'yuvs' pixel format in QuickTime (tm) */
44 YCbCr_422(FormatTypes.FORMAT_TYPE_YCBCR_422);
45
46 private int nativeType; // value passed down to native code to represent this format
47 private static final Map<Integer, VideoFormat> lookupMap = new HashMap<Integer, VideoFormat>();
56 }
57
58 public int getNativeType() {
59 return nativeType;
60 }
61
62 public boolean isRGB() {
63 return this == ARGB || this == BGRA_PRE;
64 }
65
66 public boolean isEqualTo(int ntype) {
67 return nativeType == ntype;
68 }
69
70 public static VideoFormat formatForType(int ntype) {
71 return lookupMap.get(Integer.valueOf(ntype));
72 }
73
74 // Constants for JNI headers
75 public static class FormatTypes {
76 public static final int FORMAT_TYPE_ARGB = 1;
77 public static final int FORMAT_TYPE_BGRA_PRE = 2;
78 public static final int FORMAT_TYPE_YCBCR_420P = 100;
79 public static final int FORMAT_TYPE_YCBCR_422 = 101;
80 }
81 }
|
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.media.jfxmedia.control;
27
28 import java.lang.annotation.Native;
29 import java.util.EnumSet;
30 import java.util.HashMap;
31 import java.util.Map;
32
33 public enum VideoFormat {
34 /** Packed ARGB, in memory A,R,G,B alpha is NOT pre-multiplied.
35 * This is synonymous with BYTE_ARGB */
36 ARGB(FormatTypes.FORMAT_TYPE_ARGB),
37 /** Packed BGRA, in memory B,G,R,A alpha is pre-multiplied.
38 * This format is synonymous with BYTE_BGRA_PRE or little endian INT_ARGB_PRE */
39 BGRA_PRE(FormatTypes.FORMAT_TYPE_BGRA_PRE),
40 /** Planar YCbCr 4:2:0, alpha channel is optional. The presence of a fourth
41 * plane indicates alpha is present */
42 YCbCr_420p(FormatTypes.FORMAT_TYPE_YCBCR_420P),
43 /** Packed YCbCr 4:2:2, no alpha support (Only used on Mac currently). This
44 * format is synonymous with the 'yuvs' pixel format in QuickTime (tm) */
45 YCbCr_422(FormatTypes.FORMAT_TYPE_YCBCR_422);
46
47 private int nativeType; // value passed down to native code to represent this format
48 private static final Map<Integer, VideoFormat> lookupMap = new HashMap<Integer, VideoFormat>();
57 }
58
59 public int getNativeType() {
60 return nativeType;
61 }
62
63 public boolean isRGB() {
64 return this == ARGB || this == BGRA_PRE;
65 }
66
67 public boolean isEqualTo(int ntype) {
68 return nativeType == ntype;
69 }
70
71 public static VideoFormat formatForType(int ntype) {
72 return lookupMap.get(Integer.valueOf(ntype));
73 }
74
75 // Constants for JNI headers
76 public static class FormatTypes {
77 @Native public static final int FORMAT_TYPE_ARGB = 1;
78 @Native public static final int FORMAT_TYPE_BGRA_PRE = 2;
79 @Native public static final int FORMAT_TYPE_YCBCR_420P = 100;
80 @Native public static final int FORMAT_TYPE_YCBCR_422 = 101;
81 }
82 }
|