1/*--------------------------------------------------------------------------
2Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
3
4Redistribution and use in source and binary forms, with or without
5modification, are permitted provided that the following conditions are met:
6    * Redistributions of source code must retain the above copyright
7      notice, this list of conditions and the following disclaimer.
8    * Redistributions in binary form must reproduce the above copyright
9      notice, this list of conditions and the following disclaimer in the
10      documentation and/or other materials provided with the distribution.
11    * Neither the name of Code Aurora nor
12      the names of its contributors may be used to endorse or promote
13      products derived from this software without specific prior written
14      permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27--------------------------------------------------------------------------*/
28
29#ifndef __EXTRA_DATA_HANDLER_H__
30#define __EXTRA_DATA_HANDLER_H__
31
32#include <stdio.h>
33#include <stdint.h>
34#include <string.h>
35#include <stdlib.h>
36#include "OMX_QCOMExtns.h"
37#include<linux/msm_vidc_dec.h>
38#include<linux/msm_vidc_enc.h>
39
40
41#ifdef _ANDROID_
42extern "C"{
43#include<utils/Log.h>
44}
45#ifdef ENABLE_DEBUG_LOW
46#define DEBUG_PRINT_LOW ALOGV
47#else
48#define DEBUG_PRINT_LOW
49#endif
50#ifdef ENABLE_DEBUG_HIGH
51#define DEBUG_PRINT_HIGH ALOGV
52#else
53#define DEBUG_PRINT_HIGH
54#endif
55#ifdef ENABLE_DEBUG_ERROR
56#define DEBUG_PRINT_ERROR ALOGE
57#else
58#define DEBUG_PRINT_ERROR
59#endif
60
61#else //_ANDROID_
62#define DEBUG_PRINT_LOW printf
63#define DEBUG_PRINT_HIGH printf
64#define DEBUG_PRINT_ERROR printf
65#endif // _ANDROID_
66
67#define SEI_PAYLOAD_FRAME_PACKING_ARRANGEMENT 0x2D
68#define H264_START_CODE 0x01
69#define NAL_TYPE_SEI 0x06
70#define VDEC_OMX_SEI 0x7F000007
71#define FRAME_PACK_SIZE 18
72#define H264_EMULATION_BYTE 0x03
73class extra_data_handler
74{
75public:
76  extra_data_handler();
77  ~extra_data_handler();
78  OMX_U32 parse_extra_data(OMX_BUFFERHEADERTYPE *buf_hdr);
79  OMX_U32 create_extra_data(OMX_BUFFERHEADERTYPE *buf_hdr);
80  OMX_U32 get_frame_pack_data(OMX_QCOM_FRAME_PACK_ARRANGEMENT *frame_pack);
81  OMX_U32 set_frame_pack_data(OMX_QCOM_FRAME_PACK_ARRANGEMENT *frame_pack);
82private:
83  OMX_QCOM_FRAME_PACK_ARRANGEMENT frame_packing_arrangement;
84  OMX_U8 *rbsp_buf;
85  OMX_U32 bit_ptr;
86  OMX_U32 byte_ptr;
87  OMX_U32 pack_sei;
88  OMX_U32 sei_payload_type;
89  OMX_U32 d_u(OMX_U32 num_bits);
90  OMX_U32 d_ue();
91  OMX_U32 parse_frame_pack(OMX_U32 payload_size);
92  OMX_S32 parse_rbsp(OMX_U8 *buf, OMX_U32 len);
93  OMX_S32 parse_sei(OMX_U8 *buffer, OMX_U32 buffer_length);
94  OMX_U32 e_u(OMX_U32 symbol, OMX_U32 num_bits);
95  OMX_U32 e_ue(OMX_U32 symbol);
96  OMX_U32 create_frame_pack();
97  OMX_S32 create_rbsp(OMX_U8 *buf, OMX_U32 nalu_type);
98  OMX_U32 create_sei(OMX_U8 *buffer);
99  OMX_S32 parse_sliceinfo(OMX_BUFFERHEADERTYPE *pBufHdr,
100     OMX_OTHER_EXTRADATATYPE *pExtra);
101};
102
103#endif
104