1 /*-------------------------------------------------------------------------- 2 Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. 3 4 Redistribution and use in source and binary forms, with or without 5 modification, 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 The Linux Foundation 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 16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 ADVISED 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 #ifdef _ANDROID_ 41 extern "C" { 42 #include<utils/Log.h> 43 } 44 #endif // _ANDROID_ 45 46 #include "vidc_debug.h" 47 #define SEI_PAYLOAD_FRAME_PACKING_ARRANGEMENT 0x2D 48 #define H264_START_CODE 0x01 49 #define NAL_TYPE_SEI 0x06 50 #define VDEC_OMX_SEI 0x7F000007 51 #define FRAME_PACK_SIZE 18 52 #define H264_EMULATION_BYTE 0x03 53 class extra_data_handler 54 { 55 public: 56 extra_data_handler(); 57 ~extra_data_handler(); 58 OMX_U32 parse_extra_data(OMX_BUFFERHEADERTYPE *buf_hdr); 59 OMX_U32 create_extra_data(OMX_BUFFERHEADERTYPE *buf_hdr); 60 OMX_U32 get_frame_pack_data(OMX_QCOM_FRAME_PACK_ARRANGEMENT *frame_pack); 61 OMX_U32 set_frame_pack_data(OMX_QCOM_FRAME_PACK_ARRANGEMENT *frame_pack); 62 private: 63 OMX_QCOM_FRAME_PACK_ARRANGEMENT frame_packing_arrangement; 64 OMX_U8 *rbsp_buf; 65 OMX_U32 bit_ptr; 66 OMX_U32 byte_ptr; 67 OMX_U32 pack_sei; 68 OMX_U32 sei_payload_type; 69 OMX_U32 d_u(OMX_U32 num_bits); 70 OMX_U32 d_ue(); 71 OMX_U32 parse_frame_pack(void); 72 OMX_S32 parse_rbsp(OMX_U8 *buf, OMX_U32 len); 73 OMX_S32 parse_sei(OMX_U8 *buffer, OMX_U32 buffer_length); 74 OMX_U32 e_u(OMX_U32 symbol, OMX_U32 num_bits); 75 OMX_U32 e_ue(OMX_U32 symbol); 76 OMX_U32 create_frame_pack(); 77 OMX_S32 create_rbsp(OMX_U8 *buf, OMX_U32 nalu_type); 78 OMX_U32 create_sei(OMX_U8 *buffer); 79 OMX_S32 parse_sliceinfo(OMX_BUFFERHEADERTYPE *pBufHdr, 80 OMX_OTHER_EXTRADATATYPE *pExtra); 81 OMX_S32 parse_ltrinfo(OMX_OTHER_EXTRADATATYPE *pExtra); 82 }; 83 84 #endif 85