Home | History | Annotate | Download | only in inc
      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 
     41 #ifdef _ANDROID_
     42 extern "C"{
     43 #include<utils/Log.h>
     44 }
     45 #ifdef ENABLE_DEBUG_LOW
     46 #undef DEBUG_PRINT_LOW
     47 #define DEBUG_PRINT_LOW ALOGE
     48 #else
     49 #undef DEBUG_PRINT_LOW
     50 #define DEBUG_PRINT_LOW
     51 #endif
     52 #ifdef ENABLE_DEBUG_HIGH
     53 #undef DEBUG_PRINT_HIGH
     54 #define DEBUG_PRINT_HIGH ALOGE
     55 #else
     56 #undef DEBUG_PRINT_HIGH
     57 #define DEBUG_PRINT_HIGH
     58 #endif
     59 #ifdef ENABLE_DEBUG_ERROR
     60 #undef DEBUG_PRINT_ERROR
     61 #define DEBUG_PRINT_ERROR ALOGE
     62 #else
     63 #undef DEBUG_PRINT_ERROR
     64 #define DEBUG_PRINT_ERROR
     65 #endif
     66 
     67 #else //_ANDROID_
     68 #undef DEBUG_PRINT_LOW
     69 #undef DEBUG_PRINT_HIGH
     70 #undef DEBUG_PRINT_ERROR
     71 #define DEBUG_PRINT_LOW printf
     72 #define DEBUG_PRINT_HIGH printf
     73 #define DEBUG_PRINT_ERROR printf
     74 #endif // _ANDROID_
     75 
     76 #define SEI_PAYLOAD_FRAME_PACKING_ARRANGEMENT 0x2D
     77 #define H264_START_CODE 0x01
     78 #define NAL_TYPE_SEI 0x06
     79 #define VDEC_OMX_SEI 0x7F000007
     80 #define FRAME_PACK_SIZE 18
     81 #define H264_EMULATION_BYTE 0x03
     82 class extra_data_handler
     83 {
     84 public:
     85   extra_data_handler();
     86   ~extra_data_handler();
     87   OMX_U32 parse_extra_data(OMX_BUFFERHEADERTYPE *buf_hdr);
     88   OMX_U32 create_extra_data(OMX_BUFFERHEADERTYPE *buf_hdr);
     89   OMX_U32 get_frame_pack_data(OMX_QCOM_FRAME_PACK_ARRANGEMENT *frame_pack);
     90   OMX_U32 set_frame_pack_data(OMX_QCOM_FRAME_PACK_ARRANGEMENT *frame_pack);
     91 private:
     92   OMX_QCOM_FRAME_PACK_ARRANGEMENT frame_packing_arrangement;
     93   OMX_U8 *rbsp_buf;
     94   OMX_U32 bit_ptr;
     95   OMX_U32 byte_ptr;
     96   OMX_U32 pack_sei;
     97   OMX_U32 sei_payload_type;
     98   OMX_U32 d_u(OMX_U32 num_bits);
     99   OMX_U32 d_ue();
    100   OMX_U32 parse_frame_pack(OMX_U32 payload_size);
    101   OMX_S32 parse_rbsp(OMX_U8 *buf, OMX_U32 len);
    102   OMX_S32 parse_sei(OMX_U8 *buffer, OMX_U32 buffer_length);
    103   OMX_U32 e_u(OMX_U32 symbol, OMX_U32 num_bits);
    104   OMX_U32 e_ue(OMX_U32 symbol);
    105   OMX_U32 create_frame_pack();
    106   OMX_S32 create_rbsp(OMX_U8 *buf, OMX_U32 nalu_type);
    107   OMX_U32 create_sei(OMX_U8 *buffer);
    108   OMX_S32 parse_sliceinfo(OMX_BUFFERHEADERTYPE *pBufHdr,
    109      OMX_OTHER_EXTRADATATYPE *pExtra);
    110   OMX_S32 parse_ltrinfo(OMX_BUFFERHEADERTYPE *pBufHdr,
    111      OMX_OTHER_EXTRADATATYPE *pExtra);
    112 };
    113 
    114 #endif
    115