• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
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
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 #ifndef PV_M4V_CONFIG_PARSER_H_INCLUDED
19 #define PV_M4V_CONFIG_PARSER_H_INCLUDED
20 
21 #include "oscl_base.h"
22 #include "oscl_types.h"
23 
24 #define USE_LATER 0  // for some code that will be needed in the future
25 
26 #define MP4_INVALID_VOL_PARAM -1
27 #define SHORT_HEADER_MODE -4
28 
29 
30 #define VISUAL_OBJECT_SEQUENCE_START_CODE   0x01B0
31 #define VISUAL_OBJECT_SEQUENCE_END_CODE     0x01B1
32 #define VISUAL_OBJECT_START_CODE   0x01B5
33 #define VO_START_CODE           0x8
34 #define VO_HEADER_LENGTH        32
35 #define VOL_START_CODE 0x12
36 #define VOL_START_CODE_LENGTH 28
37 
38 #define GROUP_START_CODE    0x01B3
39 #define GROUP_START_CODE_LENGTH  32
40 
41 #define VOP_ID_CODE_LENGTH      5
42 #define VOP_TEMP_REF_CODE_LENGTH    16
43 
44 #define USER_DATA_START_CODE        0x01B2
45 #define USER_DATA_START_CODE_LENGTH 32
46 
47 #define SHORT_VIDEO_START_MARKER        0x20
48 #define SHORT_VIDEO_START_MARKER_LENGTH  22
49 
50 typedef struct
51 {
52     uint8 *data;
53     uint32 numBytes;
54     uint32 bytePos;
55     uint32 bitBuf;
56     uint32 dataBitPos;
57     uint32  bitPos;
58 } mp4StreamType;
59 
60 
61 int16 ShowBits(
62     mp4StreamType *pStream,
63     uint8 ucNBits,
64     uint32 *pulOutData
65 );
66 
67 int16 FlushBits(
68     mp4StreamType *pStream,
69     uint8 ucNBits
70 );
71 
72 int16 ReadBits(
73     mp4StreamType *pStream,
74     uint8 ucNBits,
75     uint32 *pulOutData
76 );
77 
78 
79 
80 int16 ByteAlign(
81     mp4StreamType *pStream
82 );
83 
84 
85 OSCL_IMPORT_REF int16 iDecodeVOLHeader(mp4StreamType *psBits, int32 *width, int32 *height, int32 *, int32 *, int32 *profilelevel);
86 OSCL_IMPORT_REF int16 iGetM4VConfigInfo(uint8 *buffer, int32 length, int32 *width, int32 *height, int32 *, int32 *);
87 int16 DecodeUserData(mp4StreamType *pStream);
88 OSCL_IMPORT_REF int16 iDecodeShortHeader(mp4StreamType *psBits, int32 *width, int32 *height, int32 *, int32 *);
89 OSCL_IMPORT_REF int16 iGetAVCConfigInfo(uint8 *buffer, int32 length, int32 *width, int32 *height, int32 *, int32 *, int32 *profile, int32 *level);
90 
91 int32 FindNAL(uint8** nal_pnt, uint8* buffer, int32 length);
92 int16 DecodeSPS(mp4StreamType *psBits, int32 *width, int32 *height, int32 *display_width, int32 *display_height, int32 *profile_idc, int32 *level_idc);
93 #if USE_LATER
94 int32 DecodeHRD(mp4StreamType *psBits);
95 int32 DecodeVUI(mp4StreamType *psBits);
96 #endif
97 int32 DecodePPS(mp4StreamType *psBits);
98 
99 void ue_v(mp4StreamType *psBits, uint32 *codeNum);
100 void se_v(mp4StreamType *psBits, int32 *value);
101 void Parser_EBSPtoRBSP(uint8 *nal_unit, int32 *size);
102 
103 #endif //PV_M4V_CONFIG_PARSER_H_INCLUDED
104 
105 
106