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 _MP4DEC_API_H_ 19 #define _MP4DEC_API_H_ 20 21 #ifndef OSCL_BASE_H_INCLUDED 22 #include "oscl_base.h" 23 #endif 24 25 #ifndef OSCL_TYPES_H_INCLUDED 26 #include "oscl_types.h" 27 #endif 28 29 #define PV_TOLERATE_VOL_ERRORS 30 #define PV_MEMORY_POOL 31 32 #ifndef _PV_TYPES_ 33 #define _PV_TYPES_ 34 35 typedef uint Bool; 36 37 #define PV_CODEC_INIT 0 38 #define PV_CODEC_STOP 1 39 #endif 40 41 #define PV_TRUE 1 42 #define PV_FALSE 0 43 44 /* flag for post-processing 4/25/00 */ 45 46 #ifdef DEC_NOPOSTPROC 47 #undef PV_POSTPROC_ON /* enable compilation of post-processing code */ 48 #else 49 #define PV_POSTPROC_ON 50 #endif 51 52 #define PV_NO_POST_PROC 0 53 #define PV_DEBLOCK 1 54 #define PV_DERING 2 55 56 57 58 #include "visual_header.h" // struct VolInfo is defined 59 60 61 /**@name Structure and Data Types 62 * These type definitions specify the input / output from the PVMessage 63 * library. 64 */ 65 66 /*@{*/ 67 /* The application has to allocate space for this structure */ 68 typedef struct tagOutputFrame 69 { 70 uint8 *data; /* pointer to output YUV buffer */ 71 uint32 timeStamp; /* time stamp */ 72 } OutputFrame; 73 74 typedef struct tagApplicationData 75 { 76 int layer; /* current video layer */ 77 void *object; /* some optional data field */ 78 } applicationData; 79 80 /* Application controls, this structed shall be allocated */ 81 /* and initialized in the application. */ 82 typedef struct tagvideoDecControls 83 { 84 /* The following fucntion pointer is copied to BitstreamDecVideo structure */ 85 /* upon initialization and never used again. */ 86 int (*readBitstreamData)(uint8 *buf, int nbytes_required, void *appData); 87 applicationData appData; 88 89 uint8 *outputFrame; 90 void *videoDecoderData; /* this is an internal pointer that is only used */ 91 /* in the decoder library. */ 92 #ifdef PV_MEMORY_POOL 93 int32 size; 94 #endif 95 int nLayers; 96 /* pointers to VOL data for frame-based decoding. */ 97 uint8 *volbuf[2]; /* maximum of 2 layers for now */ 98 int32 volbuf_size[2]; 99 100 } VideoDecControls; 101 102 typedef enum 103 { 104 H263_MODE = 0, MPEG4_MODE, UNKNOWN_MODE 105 } MP4DecodingMode; 106 107 typedef enum 108 { 109 MP4_I_FRAME, MP4_P_FRAME, MP4_B_FRAME, MP4_BAD_FRAME 110 } MP4FrameType; 111 112 typedef struct tagVopHeaderInfo 113 { 114 int currLayer; 115 uint32 timestamp; 116 MP4FrameType frameType; 117 int refSelCode; 118 int16 quantizer; 119 } VopHeaderInfo; 120 121 /*--------------------------------------------------------------------------* 122 * VideoRefCopyInfo: 123 * OMAP DSP specific typedef structure, to support the user (ARM) copying 124 * of a Reference Frame into the Video Decoder. 125 *--------------------------------------------------------------------------*/ 126 typedef struct tagVideoRefCopyInfoPtr 127 { 128 uint8 *yChan; /* The Y component frame the user can copy a new reference to */ 129 uint8 *uChan; /* The U component frame the user can copy a new reference to */ 130 uint8 *vChan; /* The V component frame the user can copy a new reference to */ 131 uint8 *currentVop; /* The Vop for video the user can copy a new reference to */ 132 } VideoRefCopyInfoPtr; 133 134 typedef struct tagVideoRefCopyInfoData 135 { 136 int16 width; /* Width */ 137 int16 height; /* Height */ 138 int16 realWidth; /* Non-padded width, not a multiple of 16. */ 139 int16 realHeight; /* Non-padded height, not a multiple of 16. */ 140 } VideoRefCopyInfoData; 141 142 typedef struct tagVideoRefCopyInfo 143 { 144 VideoRefCopyInfoData data; 145 VideoRefCopyInfoPtr ptrs; 146 } VideoRefCopyInfo; 147 148 /*@}*/ 149 150 #ifdef __cplusplus 151 extern "C" 152 { 153 #endif 154 155 156 OSCL_IMPORT_REF Bool PVInitVideoDecoder(VideoDecControls *decCtrl, uint8 *volbuf[], int32 *volbuf_size, int nLayers, int width, int height, MP4DecodingMode mode); 157 Bool PVAllocVideoData(VideoDecControls *decCtrl, int width, int height, int nLayers); 158 OSCL_IMPORT_REF Bool PVCleanUpVideoDecoder(VideoDecControls *decCtrl); 159 Bool PVResetVideoDecoder(VideoDecControls *decCtrl); 160 OSCL_IMPORT_REF void PVSetReferenceYUV(VideoDecControls *decCtrl, uint8 *refYUV); 161 Bool PVDecSetReference(VideoDecControls *decCtrl, uint8 *refYUV, uint32 timestamp); 162 Bool PVDecSetEnhReference(VideoDecControls *decCtrl, uint8 *refYUV, uint32 timestamp); 163 OSCL_IMPORT_REF Bool PVDecodeVideoFrame(VideoDecControls *decCtrl, uint8 *bitstream[], uint32 *timestamp, int32 *buffer_size, uint use_ext_timestamp[], uint8* currYUV); 164 Bool PVDecodeVopHeader(VideoDecControls *decCtrl, uint8 *buffer[], uint32 timestamp[], int32 buffer_size[], VopHeaderInfo *header_info, uint use_ext_timestamp[], uint8 *currYUV); 165 Bool PVDecodeVopBody(VideoDecControls *decCtrl, int32 buffer_size[]); 166 void PVDecPostProcess(VideoDecControls *decCtrl, uint8 *outputYUV); 167 OSCL_IMPORT_REF void PVGetVideoDimensions(VideoDecControls *decCtrl, int32 *display_width, int32 *display_height); 168 OSCL_IMPORT_REF void PVSetPostProcType(VideoDecControls *decCtrl, int mode); 169 uint32 PVGetVideoTimeStamp(VideoDecControls *decoderControl); 170 int PVGetDecBitrate(VideoDecControls *decCtrl); 171 int PVGetDecFramerate(VideoDecControls *decCtrl); 172 uint8 *PVGetDecOutputFrame(VideoDecControls *decCtrl); 173 int PVGetLayerID(VideoDecControls *decCtrl); 174 int32 PVGetDecMemoryUsage(VideoDecControls *decCtrl); 175 OSCL_IMPORT_REF MP4DecodingMode PVGetDecBitstreamMode(VideoDecControls *decCtrl); 176 Bool PVExtractVolHeader(uint8 *video_buffer, uint8 *vol_header, int32 *vol_header_size); 177 int32 PVLocateFrameHeader(uint8 *video_buffer, int32 vop_size); 178 int32 PVLocateH263FrameHeader(uint8 *video_buffer, int32 vop_size); 179 Bool PVGetVolInfo(VideoDecControls *decCtrl, VolInfo *pVolInfo); // BX 6/24/04 180 Bool IsIntraFrame(VideoDecControls *decoderControl); 181 182 #ifdef __cplusplus 183 } 184 #endif 185 #endif /* _MP4DEC_API_H_ */ 186 187