1 /*
2  * Copyright (C) 2011 The Android Open Source Project
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 
17 
18 package android.filterfw.core;
19 
20 import android.filterfw.core.FrameFormat;
21 import android.filterfw.core.KeyValueMap;
22 
23 import java.util.Arrays;
24 
25 /**
26  * @hide
27  */
28 public class MutableFrameFormat extends FrameFormat {
29 
MutableFrameFormat()30     public MutableFrameFormat() {
31         super();
32     }
33 
MutableFrameFormat(int baseType, int target)34     public MutableFrameFormat(int baseType, int target) {
35         super(baseType, target);
36     }
37 
setBaseType(int baseType)38     public void setBaseType(int baseType) {
39         mBaseType = baseType;
40         mBytesPerSample = bytesPerSampleOf(baseType);
41     }
42 
setTarget(int target)43     public void setTarget(int target) {
44         mTarget = target;
45     }
46 
setBytesPerSample(int bytesPerSample)47     public void setBytesPerSample(int bytesPerSample) {
48         mBytesPerSample = bytesPerSample;
49         mSize = SIZE_UNKNOWN;
50     }
51 
setDimensions(int[] dimensions)52     public void setDimensions(int[] dimensions) {
53         mDimensions = (dimensions == null) ? null : Arrays.copyOf(dimensions, dimensions.length);
54         mSize = SIZE_UNKNOWN;
55     }
56 
setDimensions(int size)57     public void setDimensions(int size) {
58         int[] dimensions = new int[1];
59         dimensions[0] = size;
60         mDimensions = dimensions;
61         mSize = SIZE_UNKNOWN;
62     }
63 
setDimensions(int width, int height)64     public void setDimensions(int width, int height) {
65         int[] dimensions = new int[2];
66         dimensions[0] = width;
67         dimensions[1] = height;
68         mDimensions = dimensions;
69         mSize = SIZE_UNKNOWN;
70     }
71 
setDimensions(int width, int height, int depth)72     public void setDimensions(int width, int height, int depth) {
73         int[] dimensions = new int[3];
74         dimensions[0] = width;
75         dimensions[1] = height;
76         dimensions[2] = depth;
77         mDimensions = dimensions;
78         mSize = SIZE_UNKNOWN;
79     }
80 
setDimensionCount(int count)81     public void setDimensionCount(int count) {
82         mDimensions = new int[count];
83     }
84 
setObjectClass(Class objectClass)85     public void setObjectClass(Class objectClass) {
86         mObjectClass = objectClass;
87     }
88 
setMetaValue(String key, Object value)89     public void setMetaValue(String key, Object value) {
90         if (mMetaData == null) {
91             mMetaData = new KeyValueMap();
92         }
93         mMetaData.put(key, value);
94     }
95 
96 }
97