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 * @file    M4_VideoEditingCommon.h
19 * @brief    Video Editing (VSS3GPP, MCS, PTO3GPP) common definitions
20 * @note
21 ******************************************************************************
22*/
23
24#ifndef __M4_VIDEOEDITINGCOMMON_H__
25#define __M4_VIDEOEDITINGCOMMON_H__
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/**
32 *    Version */
33/* CHANGE_VERSION_HERE */
34#define M4VIDEOEDITING_VERSION_MAJOR    3
35#define M4VIDEOEDITING_VERSION_MINOR    1
36#define M4VIDEOEDITING_VERSION_REVISION    0
37
38#define M4VIDEOEDITING_VIDEO_UNKNOWN_PROFILE 0x7fffffff
39#define M4VIDEOEDITING_VIDEO_UNKNOWN_LEVEL 0x7fffffff
40
41/**
42 ******************************************************************************
43 * enum        M4VIDEOEDITING_FileType
44 * @brief    This enum defines the file format type to be used
45 ******************************************************************************
46*/
47typedef enum {
48    M4VIDEOEDITING_kFileType_3GPP        = 0,      /**< 3GPP file media type : input & output */
49    M4VIDEOEDITING_kFileType_MP4         = 1,      /**< MP4  file media type : input          */
50    M4VIDEOEDITING_kFileType_AMR         = 2,      /**< AMR  file media type : input & output */
51    M4VIDEOEDITING_kFileType_MP3         = 3,      /**< MP3  file media type : input          */
52    M4VIDEOEDITING_kFileType_PCM         = 4,      /**< PCM RAW file media type : input    RC */
53    M4VIDEOEDITING_kFileType_JPG         = 5,      /**< STILL PICTURE FEATURE: JPG file media
54                                                        type : input AND OUTPUT */
55    M4VIDEOEDITING_kFileType_BMP         = 6,      /**< STILL PICTURE FEATURE: BMP file media
56                                                        type : input only */
57    M4VIDEOEDITING_kFileType_GIF         = 7,      /**< STILL PICTURE FEATURE: GIF file media
58                                                        type : input only */
59    M4VIDEOEDITING_kFileType_PNG         = 8,      /**< STILL PICTURE FEATURE: PNG file media
60                                                        type : input only */
61    M4VIDEOEDITING_kFileType_ARGB8888    = 9,      /**< STILL PICTURE FEATURE: ARGB8888 file
62                                                        media type : input only */
63    M4VIDEOEDITING_kFileType_M4V         = 10,     /**< M4V  file media type : input only     */
64    M4VIDEOEDITING_kFileType_Unsupported = 255     /**< Unsupported file media type           */
65} M4VIDEOEDITING_FileType;
66
67
68/**
69 ******************************************************************************
70 * enum        M4VIDEOEDITING_VideoFormat
71 * @brief    This enum defines the avalaible video compression formats.
72 ******************************************************************************
73*/
74typedef enum
75{
76    M4VIDEOEDITING_kNoneVideo = 0, /**< Video not present */
77    M4VIDEOEDITING_kH263 = 1, /**< H263 video */
78    M4VIDEOEDITING_kH264 = 2,    /**< H264 video */
79    M4VIDEOEDITING_kMPEG4 = 3, /**< MPEG-4 video */
80    M4VIDEOEDITING_kNullVideo = 254,  /**< Do not care video type, use NULL encoder */
81    M4VIDEOEDITING_kUnsupportedVideo = 255    /**< Unsupported video stream type */
82} M4VIDEOEDITING_VideoFormat;
83
84/**
85 ******************************************************************************
86 * enum        M4VIDEOEDITING_AudioFormat
87 * @brief    This enum defines the avalaible audio format.
88 * @note    HE_AAC, HE_AAC_v2 and MP3 can not be used for the output audio format
89 ******************************************************************************
90*/
91typedef enum {
92    M4VIDEOEDITING_kNoneAudio            = 0,    /**< Audio not present */
93    M4VIDEOEDITING_kAMR_NB              = 1,    /**< AMR Narrow Band audio */
94    M4VIDEOEDITING_kAAC                    = 2,    /**< AAC audio */
95    M4VIDEOEDITING_kAACplus                = 3,    /**< AAC+ audio */
96    M4VIDEOEDITING_keAACplus             = 4,    /**< Enhanced AAC+ audio */
97    M4VIDEOEDITING_kMP3                 = 5,    /**< MP3 audio */
98    M4VIDEOEDITING_kEVRC                = 6,    /**< EVRC audio */
99    M4VIDEOEDITING_kPCM                 = 7,    /**< PCM audio */
100    M4VIDEOEDITING_kNullAudio           = 254,  /**< Do not care audio type, use NULL encoder */
101    M4VIDEOEDITING_kUnsupportedAudio    = 255    /**< Unsupported audio stream type */
102} M4VIDEOEDITING_AudioFormat;
103
104/**
105 ******************************************************************************
106 * enum        M4VIDEOEDITING_VideoFrameSize
107 * @brief    This enum defines the available output frame sizes.
108 ******************************************************************************
109*/
110typedef enum
111{
112    M4VIDEOEDITING_kSQCIF=0, /**< SQCIF 128x96  */
113    M4VIDEOEDITING_kQQVGA,   /**< QQVGA 160x120 */
114    M4VIDEOEDITING_kQCIF,    /**< QCIF  176x144 */
115    M4VIDEOEDITING_kQVGA,    /**< QVGA  320x240 */
116    M4VIDEOEDITING_kCIF,     /**< CIF   352x288 */
117    M4VIDEOEDITING_kVGA,     /**< VGA   640x480 */
118/* +PR LV5807 */
119    M4VIDEOEDITING_kWVGA,    /**< WVGA 800x480 */
120    M4VIDEOEDITING_kNTSC,    /**< NTSC 720x480 */
121/* -PR LV5807 */
122
123/* +CR Google */
124    M4VIDEOEDITING_k640_360,  /**< 640x360 */
125    M4VIDEOEDITING_k854_480,  /**< 854x480 */
126    M4VIDEOEDITING_k1280_720, /**< 720p 1280x720 */
127    M4VIDEOEDITING_k1080_720, /**< 720p 1080x720 */
128    M4VIDEOEDITING_k960_720,  /**< 720p 960x720 */
129    M4VIDEOEDITING_k1920_1080 /**<1080p 1920x1080*/
130/* -CR Google */
131
132} M4VIDEOEDITING_VideoFrameSize;
133
134
135/**
136 ******************************************************************************
137 * enum        M4VIDEOEDITING_Videoframerate
138 * @brief    This enum defines the available video framerates.
139 ******************************************************************************
140*/
141typedef enum
142{
143    M4VIDEOEDITING_k5_FPS = 0,
144    M4VIDEOEDITING_k7_5_FPS,
145    M4VIDEOEDITING_k10_FPS,
146    M4VIDEOEDITING_k12_5_FPS,
147    M4VIDEOEDITING_k15_FPS,
148    M4VIDEOEDITING_k20_FPS,
149    M4VIDEOEDITING_k25_FPS,
150    M4VIDEOEDITING_k30_FPS
151} M4VIDEOEDITING_VideoFramerate;
152
153
154/**
155 ******************************************************************************
156 * enum        M4VIDEOEDITING_AudioSamplingFrequency
157 * @brief    This enum defines the available output audio sampling frequencies
158 * @note    8 kHz is the only supported frequency for AMR-NB output
159 * @note    16 kHz is the only supported frequency for AAC output
160 * @note    The recommended practice is to use the Default value when setting the encoding parameters
161 ******************************************************************************
162*/
163typedef enum {
164    M4VIDEOEDITING_kDefault_ASF    = 0,    /**< Default Audio Sampling Frequency for selected
165                                                 Audio output format */
166    M4VIDEOEDITING_k8000_ASF    = 8000,    /**< Note: Default audio Sampling Frequency for
167                                                    AMR-NB output */
168    M4VIDEOEDITING_k11025_ASF    = 11025,
169    M4VIDEOEDITING_k12000_ASF    = 12000,
170    M4VIDEOEDITING_k16000_ASF    = 16000,    /**< Note: Default audio Sampling Frequency
171                                                     for AAC output */
172    M4VIDEOEDITING_k22050_ASF    = 22050,
173    M4VIDEOEDITING_k24000_ASF    = 24000,
174    M4VIDEOEDITING_k32000_ASF    = 32000,
175    M4VIDEOEDITING_k44100_ASF    = 44100,
176    M4VIDEOEDITING_k48000_ASF    = 48000
177
178} M4VIDEOEDITING_AudioSamplingFrequency;
179
180
181/**
182 ******************************************************************************
183 * enum        M4VIDEOEDITING_Bitrate
184 * @brief    This enum defines the available audio or video bitrates.
185 ******************************************************************************
186*/
187typedef enum
188{
189    M4VIDEOEDITING_kVARIABLE_KBPS = -1,     /* no regulation */
190    M4VIDEOEDITING_kUndefinedBitrate = 0,   /* undefined */
191    M4VIDEOEDITING_k8_KBPS = 8000,
192    M4VIDEOEDITING_k9_2_KBPS = 9200,        /* evrc only */
193    M4VIDEOEDITING_k12_2_KBPS = 12200,      /* amr only */
194    M4VIDEOEDITING_k16_KBPS = 16000,
195    M4VIDEOEDITING_k24_KBPS = 24000,
196    M4VIDEOEDITING_k32_KBPS = 32000,
197    M4VIDEOEDITING_k40_KBPS = 40000,
198    M4VIDEOEDITING_k48_KBPS = 48000,
199    M4VIDEOEDITING_k56_KBPS = 56000,
200    M4VIDEOEDITING_k64_KBPS = 64000,
201    M4VIDEOEDITING_k80_KBPS = 80000,
202    M4VIDEOEDITING_k96_KBPS = 96000,
203    M4VIDEOEDITING_k112_KBPS = 112000,
204    M4VIDEOEDITING_k128_KBPS = 128000,
205    M4VIDEOEDITING_k160_KBPS = 160000,
206    M4VIDEOEDITING_k192_KBPS = 192000,
207    M4VIDEOEDITING_k224_KBPS = 224000,
208    M4VIDEOEDITING_k256_KBPS = 256000,
209    M4VIDEOEDITING_k288_KBPS = 288000,
210    M4VIDEOEDITING_k320_KBPS = 320000,
211    M4VIDEOEDITING_k384_KBPS = 384000,
212    M4VIDEOEDITING_k512_KBPS = 512000,
213    M4VIDEOEDITING_k800_KBPS = 800000,
214/*+ New Encoder bitrates */
215    M4VIDEOEDITING_k2_MBPS = 2000000,
216    M4VIDEOEDITING_k5_MBPS = 5000000,
217    M4VIDEOEDITING_k8_MBPS = 8000000,
218/*- New Encoder bitrates */
219} M4VIDEOEDITING_Bitrate;
220
221
222/**
223 ******************************************************************************
224 * structure    M4VIDEOEDITING_FtypBox
225 * @brief        Information to build the 'ftyp' atom
226 ******************************************************************************
227*/
228#define M4VIDEOEDITING_MAX_COMPATIBLE_BRANDS 10
229typedef struct
230{
231    /* All brand fields are actually char[4] stored in big-endian integer format */
232
233    M4OSA_UInt32    major_brand;           /* generally '3gp4'            */
234    M4OSA_UInt32    minor_version;         /* generally '0000' or 'x.x '  */
235    M4OSA_UInt32    nbCompatibleBrands;    /* number of compatible brands */
236    M4OSA_UInt32    compatible_brands[M4VIDEOEDITING_MAX_COMPATIBLE_BRANDS]; /* array of
237                                                                         max compatible brands */
238
239} M4VIDEOEDITING_FtypBox;
240
241/* Some useful brands */
242#define M4VIDEOEDITING_BRAND_0000  0x00000000
243#define M4VIDEOEDITING_BRAND_3G2A  0x33673261
244#define M4VIDEOEDITING_BRAND_3GP4  0x33677034
245#define M4VIDEOEDITING_BRAND_3GP5  0x33677035
246#define M4VIDEOEDITING_BRAND_3GP6  0x33677036
247#define M4VIDEOEDITING_BRAND_AVC1  0x61766331
248#define M4VIDEOEDITING_BRAND_EMP   0x656D7020
249#define M4VIDEOEDITING_BRAND_ISOM  0x69736F6D
250#define M4VIDEOEDITING_BRAND_MP41  0x6D703431
251#define M4VIDEOEDITING_BRAND_MP42  0x6D703432
252#define M4VIDEOEDITING_BRAND_VFJ1  0x76666A31
253
254/**
255 ******************************************************************************
256 * enum     M4VIDEOEDITING_ClipProperties
257 * @brief   This structure gathers the information related to an input file
258 ******************************************************************************
259*/
260typedef struct {
261
262    /**
263     * Common */
264    M4OSA_Bool                          bAnalysed;           /**< Flag to know if the file has
265                                                                  been already analysed or not */
266    M4OSA_UInt8                         Version[3];          /**< Version of the libraries used to
267                                                                  perform the clip analysis */
268    M4OSA_UInt32                        uiClipDuration;      /**< Clip duration (in ms) */
269    M4VIDEOEDITING_FileType             FileType;            /**< .3gp, .amr, .mp3 */
270    M4VIDEOEDITING_FtypBox              ftyp;                /**< 3gp 'ftyp' atom, major_brand =
271                                                                    0 if not used */
272
273    /**
274     * Video */
275    M4VIDEOEDITING_VideoFormat          VideoStreamType;     /**< Format of the video stream */
276    M4OSA_UInt32                        uiClipVideoDuration; /**< Video track duration (in ms) */
277    M4OSA_UInt32                        uiVideoBitrate;      /**< Video average bitrate (in bps)*/
278    M4OSA_UInt32                        uiVideoMaxAuSize;    /**< Maximum Access Unit size of the
279                                                                  video stream */
280    M4OSA_UInt32                        uiVideoWidth;        /**< Video frame width */
281    M4OSA_UInt32                        uiVideoHeight;       /**< Video frame height */
282    M4OSA_UInt32                        uiVideoTimeScale;    /**< Video time scale */
283    M4OSA_Float                         fAverageFrameRate;   /**< Average frame rate of the video
284                                                                  stream */
285    M4OSA_Int32 uiVideoLevel;   /**< video level*/
286    M4OSA_Int32 uiVideoProfile; /**< video profile */
287
288    M4OSA_Bool                          bMPEG4dataPartition; /**< MPEG-4 uses data partitioning */
289    M4OSA_Bool                          bMPEG4rvlc;          /**< MPEG-4 uses RVLC tool */
290    M4OSA_Bool                          bMPEG4resynchMarker; /**< MPEG-4 stream uses Resynch
291                                                                   Marker */
292
293    /**
294     * Audio */
295    M4VIDEOEDITING_AudioFormat          AudioStreamType;     /**< Format of the audio stream */
296    M4OSA_UInt32                        uiClipAudioDuration; /**< Audio track duration (in ms) */
297    M4OSA_UInt32                        uiAudioBitrate;      /**< Audio average bitrate (in bps) */
298    M4OSA_UInt32                        uiAudioMaxAuSize;    /**< Maximum Access Unit size of the
299                                                                    audio stream */
300    M4OSA_UInt32                        uiNbChannels;        /**< Number of channels
301                                                                    (1=mono, 2=stereo) */
302    M4OSA_UInt32                        uiSamplingFrequency; /**< Sampling audio frequency
303                                                           (8000 for amr, 16000 or more for aac) */
304    M4OSA_UInt32                        uiExtendedSamplingFrequency; /**< Extended frequency for
305                                                                         AAC+, eAAC+ streams */
306    M4OSA_UInt32                        uiDecodedPcmSize;    /**< Size of the decoded PCM data */
307
308    /**
309     * Video editing compatibility chart */
310    M4OSA_Bool      bVideoIsEditable;                        /**< Video stream can be decoded and
311                                                                 re-encoded */
312    M4OSA_Bool      bAudioIsEditable;                        /**< Audio stream can be decoded and
313                                                                  re-encoded */
314    M4OSA_Bool      bVideoIsCompatibleWithMasterClip;        /**< Video properties match reference
315                                                                  clip properties */
316    M4OSA_Bool      bAudioIsCompatibleWithMasterClip;        /**< Audio properties match reference
317                                                                   clip properties */
318
319    /**
320     * Still Picture */
321    M4OSA_UInt32                        uiStillPicWidth;        /**< Image width */
322    M4OSA_UInt32                        uiStillPicHeight;       /**< Image height */
323    M4OSA_UInt32                        uiClipAudioVolumePercentage;
324    M4OSA_Bool                          bSetImageData;
325
326    M4OSA_Int32     videoRotationDegrees;        /**< Video rotation degree */
327
328} M4VIDEOEDITING_ClipProperties;
329
330
331#ifdef __cplusplus
332    }
333#endif
334
335#endif /* __M4_VIDEOEDITINGCOMMON_H__ */
336
337