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