summaryrefslogtreecommitdiffstats
path: root/mm-video/vidc/vdec/inc/frameparser.h
blob: 4575b0930eb95552c68c226e22524ce8c26bb031 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*--------------------------------------------------------------------------
Copyright (c) 2010, Code Aurora Forum. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of Code Aurora nor
      the names of its contributors may be used to endorse or promote
      products derived from this software without specific prior written
      permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------*/
#ifndef FRAMEPARSER_H
#define FRAMEPARSER_H

#include "OMX_Core.h"
#include "OMX_QCOMExtns.h"
#include "h264_utils.h"
//#include <stdlib.h>


enum codec_type
{
    CODEC_TYPE_MPEG4 = 0,
    CODEC_TYPE_H263 = 1,
    CODEC_TYPE_H264 = 2,
    CODEC_TYPE_VC1 = 3
};

enum state_start_code_parse
{
   A0,
   A1,
   A2,
   A3,
   A4
};

enum state_nal_parse
{
   NAL_LENGTH_ACC,
   NAL_PARSING
};

class frame_parse
{

public:
	H264_Utils *mutils;
	int init_start_codes (codec_type codec_type_parse);
	int parse_mpeg4_frame (OMX_BUFFERHEADERTYPE *source,
                         OMX_BUFFERHEADERTYPE *dest ,
						             OMX_U32 *partialframe);
	int init_nal_length (unsigned int nal_length);
	int parse_h264_nallength (OMX_BUFFERHEADERTYPE *source,
		                        OMX_BUFFERHEADERTYPE *dest ,
							              OMX_U32 *partialframe);
  void flush ();
  void update_metadata (unsigned int time_stamp ,unsigned int flags);
	 frame_parse ();
	~frame_parse ();

private:
   /*Variables for Start code based Parsing*/
   enum state_start_code_parse parse_state;
   unsigned char start_code[4];
   char mask_code[4];
   unsigned char last_byte,prev_one;

   /*Variables for NAL Length Parsing*/
   enum state_nal_parse state_nal;
   unsigned int nal_length;
   unsigned int accum_length;
   unsigned int bytes_tobeparsed;
   unsigned int time_stamp;
   unsigned int flags;
};

#endif /* FRAMEPARSER_H */