Debian Codegraph @

src/com/drew/metadata/mp4/media/Mp4VideoDescriptor.java

raw symbols SCIP
1 /*
2 * Copyright 2002-2019 Drew Noakes and contributors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * More information about this project is available at:
17 *
18 * https://drewnoakes.com/code/exif/
19 * https://github.com/drewnoakes/metadata-extractor
20 */
21 package com.drew.metadata.mp4.media;
22
23 import com.drew.lang.annotations.NotNull;
24 import com.drew.metadata.TagDescriptor;
25
26 import static com.drew.metadata.mp4.media.Mp4VideoDirectory.*;
27
28 public class Mp4VideoDescriptor extends TagDescriptor<Mp4VideoDirectory>
29 {
30 public Mp4VideoDescriptor(@NotNull Mp4VideoDirectory directory)
31 {
32 super(directory);
33 }
34
35 @Override
36 public String getDescription(int tagType)
37 {
38 switch (tagType) {
39 case TAG_HEIGHT:
40 case TAG_WIDTH:
41 return getPixelDescription(tagType);
42 case TAG_DEPTH:
43 return getDepthDescription();
44 case TAG_COLOR_TABLE:
45 return getColorTableDescription();
46 case TAG_GRAPHICS_MODE:
47 return getGraphicsModeDescription();
48 default:
49 return super.getDescription(tagType);
50 }
51 }
52
53 private String getPixelDescription(int tagType)
54 {
55 String value = _directory.getString(tagType);
56 return value == null ? null : value + " pixels";
57 }
58
59 private String getDepthDescription()
60 {
61 Integer value = _directory.getInteger(TAG_DEPTH);
62 if (value == null)
63 return null;
64
65 switch (value) {
66 case (1):
67 case (2):
68 case (4):
69 case (8):
70 case (16):
71 case (24):
72 case (32):
73 return value + "-bit color";
74 case (40):
75 case (36):
76 case (34):
77 return (value - 32) + "-bit grayscale";
78 default:
79 return "Unknown (" + value + ")";
80 }
81 }
82
83 private String getColorTableDescription()
84 {
85 Integer value = _directory.getInteger(TAG_COLOR_TABLE);
86 if (value == null)
87 return null;
88
89 switch (value) {
90 case (-1):
91 Integer depth = _directory.getInteger(TAG_DEPTH);
92 if (depth == null)
93 return "None";
94
95 if (depth < 16) {
96 return "Default";
97 } else {
98 return "None";
99 }
100 case (0):
101 return "Color table within file";
102 default:
103 return "Unknown (" + value + ")";
104 }
105 }
106
107 private String getGraphicsModeDescription()
108 {
109 Integer value = _directory.getInteger(TAG_GRAPHICS_MODE);
110 if (value == null)
111 return null;
112
113 switch (value) {
114 case (0x00):
115 return "Copy";
116 case (0x40):
117 return "Dither copy";
118 case (0x20):
119 return "Blend";
120 case (0x24):
121 return "Transparent";
122 case (0x100):
123 return "Straight alpha";
124 case (0x101):
125 return "Premul white alpha";
126 case (0x102):
127 return "Premul black alpha";
128 case (0x104):
129 return "Straight alpha blend";
130 case (0x103):
131 return "Composition (dither copy)";
132 default:
133 return "Unknown (" + value + ")";
134 }
135 }
136 }