• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 Copyright (c) 2011 Stanislav Vitvitskiy
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy of this
5 software and associated documentation files (the "Software"), to deal in the Software
6 without restriction, including without limitation the rights to use, copy, modify,
7 merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
8 permit persons to whom the Software is furnished to do so, subject to the following
9 conditions:
10 
11 The above copyright notice and this permission notice shall be included in all copies or
12 substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16 PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
17 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
19 OR OTHER DEALINGS IN THE SOFTWARE.
20 */
21 package com.googlecode.mp4parser.h264.model;
22 
23 /**
24  * Chroma format enum
25  *
26  * @author Stanislav Vitvitskiy
27  */
28 public class ChromaFormat {
29     public static ChromaFormat MONOCHROME = new ChromaFormat(0, 0, 0);
30     public static ChromaFormat YUV_420 = new ChromaFormat(1, 2, 2);
31     public static ChromaFormat YUV_422 = new ChromaFormat(2, 2, 1);
32     public static ChromaFormat YUV_444 = new ChromaFormat(3, 1, 1);
33 
34     private int id;
35     private int subWidth;
36     private int subHeight;
37 
ChromaFormat(int id, int subWidth, int subHeight)38     public ChromaFormat(int id, int subWidth, int subHeight) {
39         this.id = id;
40         this.subWidth = subWidth;
41         this.subHeight = subHeight;
42     }
43 
fromId(int id)44     public static ChromaFormat fromId(int id) {
45         if (id == MONOCHROME.id) {
46             return MONOCHROME;
47         } else if (id == YUV_420.id) {
48             return YUV_420;
49         } else if (id == YUV_422.id) {
50             return YUV_422;
51         } else if (id == YUV_444.id) {
52             return YUV_444;
53         }
54         return null;
55     }
56 
getId()57     public int getId() {
58         return id;
59     }
60 
getSubWidth()61     public int getSubWidth() {
62         return subWidth;
63     }
64 
getSubHeight()65     public int getSubHeight() {
66         return subHeight;
67     }
68 
69     @Override
toString()70     public String toString() {
71         return "ChromaFormat{" + "\n" +
72                 "id=" + id + ",\n" +
73                 " subWidth=" + subWidth + ",\n" +
74                 " subHeight=" + subHeight +
75                 '}';
76     }
77 }
78