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