source: svn/trunk/newcon3bcm2_21bu/magnum/portinginterface/xvd/7552/bxvd_decoder.h

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 10.7 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2011, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: bxvd_decoder.h $
11 * $brcm_Revision: Hydra_Software_Devel/7 $
12 * $brcm_Date: 9/20/11 3:33p $
13 *
14 * [File Description:]
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/portinginterface/xvd/7401/bxvd_decoder.h $
19 *
20 * Hydra_Software_Devel/7   9/20/11 3:33p btosi
21 * SW7425-1261: only clear bTruncatingGop in ..._ReleaseGopTail
22 *
23 * Hydra_Software_Devel/6   4/4/11 11:28a btosi
24 * SW7405-4736: added support for BXVD_DecoderDbg_P_PrintUnifiedPicture
25 *
26 * Hydra_Software_Devel/5   10/29/10 11:31a btosi
27 * SW7422-27: adding support for 3D
28 *
29 * Hydra_Software_Devel/4   6/16/10 12:56p btosi
30 * SW7405-4365: added support for using the new timer functions
31 *
32 * Hydra_Software_Devel/3   6/7/10 10:24a delkert
33 * SW7405-3925: Modify RequestPictureDrop_isr API to allow update of
34 * requested count with actual count requested from decoder
35 *
36 * Hydra_Software_Devel/2   6/3/10 11:55a btosi
37 * SW7630-83: removed unused elements
38 *
39 * Hydra_Software_Devel/1   2/25/10 4:24p nilesh
40 * SW7405-2993: XDM Merge
41 *
42 ***************************************************************************/
43
44#ifndef BXVD_DECODER_H_
45#define BXVD_DECODER_H_
46
47#include "bxvd.h"
48#include "bxvd_decoder_timer.h"
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54/*
55 * type definitions
56 */
57
58#define BXVD_DECODER_DQT_DEADLOCK_THRESHOLD     4
59
60/* The maximum number of fields that the decoder will request AVD to drop.
61 */
62#define BXVD_DECODER_MAX_FIELDS_TO_DROP   16
63
64
65/* Support for processing sets of picture.  Stereo/3D is an
66 * example of when multiple pictures would be processed as a set.
67 */
68typedef enum BXVD_Decoder_P_PictureSetType
69{
70   BXVD_Decoder_P_PictureSet_eSingle = 0,
71   BXVD_Decoder_P_PictureSet_eBase,
72   BXVD_Decoder_P_PictureSet_eDependent,
73
74   BXVD_Decoder_P_PictureSet_eMax
75
76} BXVD_Decoder_P_PictureSetType;
77
78
79#define BXVD_P_DECODER_PICTURE_QUEUE_DEPTH 64
80
81typedef struct BXVD_Decoder_P_PictureContext
82{
83   /* Support for processing sets of pictures. Currently sets are only of
84    * size "2", hence "uiSetCount" is not used.  It will be needed to
85    * support larger multiview sets.
86    */
87   BXVD_Decoder_P_PictureSetType    eSetType;
88   uint32_t                         uiSetCount;
89
90   /* Drop if not a complete set of pictures (not TSM related) */
91   bool                       bDropPicture;
92
93   /* SW7422-72: for 3D support dereferenced some of the PPB data
94    * prior to calling BXVD_Decoder_S_UnifiedQ_ValidatePicture
95    * TODO: redo logic only parse this information once.
96    */
97   BXDM_Picture_3D st3D;
98
99   /* TODO: does this need to be a display element or
100    * could it just be a BXVD_P_PPB *?
101    */
102   BXVD_P_DisplayElement stPPB;
103
104   /* If a dependent picture, will point to the associated base picture. */
105   struct BXVD_Decoder_P_PictureContext * pBasePicture;
106
107   /* Points to the next dependent picture in the list.  NULL if the last one. */
108   struct BXVD_Decoder_P_PictureContext * pDependentPicture;
109
110} BXVD_Decoder_P_PictureContext;
111
112typedef struct BXVD_Decoder_P_PictureContextQueue
113{
114   uint32_t uiWriteOffset;
115
116   BXVD_Decoder_P_PictureContext    astPictureContext[ BXVD_P_MAX_ELEMENTS_IN_DISPLAY_QUEUE ];
117
118} BXVD_Decoder_P_PictureContextQueue;
119
120/*
121 * Unified picture queue types.
122 */
123
124typedef struct BXVD_Decoder_P_UnifiedPictureContext
125{
126   bool  bInUse;
127
128   BXVD_P_PPB * pPPBPhysical;
129   BXVD_P_PPB * pPPB;
130
131   BXVD_Decoder_P_PictureSetType    eSetType;
132   uint32_t                         uiSetCount;
133   uint32_t                         uiDropCount;   /* the AVD drop count at the time this picture was received. */
134
135   /* for debug */
136   uint32_t uiIndex;
137
138   BXDM_Picture stUnifiedPicture;
139
140   /* For implementing the Unified Queue as a linked list. */
141   struct BXVD_Decoder_P_UnifiedPictureContext * pstPreviousUniContext;
142   struct BXVD_Decoder_P_UnifiedPictureContext * pstNextUniContext;
143
144   /* For managing sets of pictures; e.g. MVC. */
145   struct BXVD_Decoder_P_UnifiedPictureContext * pstDependentUniContext;
146
147} BXVD_Decoder_P_UnifiedPictureContext;
148
149
150typedef struct BXVD_Decoder_P_UnifiedPictureQueue
151{
152   uint32_t uiReadOffset; /* Always the picture under evaluation */
153   uint32_t uiWriteOffset; /* if uiWriteOffset == uiReadOffset, queue is empty */
154
155   uint32_t uiSearchIndex;
156
157   int32_t  iNumPictures;
158
159   int32_t  iNumUsedElements;
160
161   BXVD_Decoder_P_UnifiedPictureContext * pstContextTail;
162   BXVD_Decoder_P_UnifiedPictureContext * pstContextHead;
163
164   BXVD_Decoder_P_UnifiedPictureContext astUnifiedContext[ BXVD_P_DECODER_PICTURE_QUEUE_DEPTH ];
165
166} BXVD_Decoder_P_UnifiedPictureQueue;
167
168
169typedef struct BXVD_Decoder_P_DQTContext
170{
171   /*
172    * Parameters to support "Display Queue Trick Mode"
173    */
174   bool    bFoundStartOfGop;   /* indicates that the beginning of a GOP has been detected */
175   uint32_t    uiSearchRdOffset;   /* for looking ahead to find the end of the GOP */
176
177   bool  bDqtEnabled;       /* enables the reverse playback of GOPs */
178
179   bool  bConvertGopToUniPics;   /* indicates in the middle of playing a GOP backwards */
180
181   uint32_t  uiReverseReadOffset;    /* read pointer when walking backwards through the display queue */
182
183   uint32_t  uiEndOfGopOffset;   /* end of the current GOP, used to updated the display queue read pointer */
184
185   /*
186    * Variables for dectecting a deadlock condition and dealing with the subsequent clean up.
187    */
188   uint32_t  uiPreviousWrOffset;                 /* delivery queue write pointer from the previous vsync */
189   uint32_t  uiTimesOffsetRepeated;        /* how many vsync's the write pointer has remained the same */
190   uint32_t    uiDeadlockThreshold;        /* number of vsync's to wait for a new picture in the delivery queue */
191
192   bool    bTruncatingGop;           /* truncating the current GOP  */
193   uint32_t    uiCleanupOffset;    /* delivery queue offset for releasing the pictures at the end of a GOP */
194
195   bool        bValidPicTag;               /* indicates if "uiCurrentPicTag" is valid */
196   uint32_t    uiCurrentPicTag;        /* picture tag of the current GOP */
197
198} BXVD_Decoder_P_DQTContext;
199
200typedef struct BXVD_Decoder_P_DNR
201{
202 unsigned int saved_mb_cnt;
203 unsigned int adj_Qp_ref;
204 unsigned int adj_Qp_pre;
205} BXVD_Decoder_P_DNR;
206
207
208/* A bit of overkill for one counter, perhaps more
209 * will be added later.
210 */
211typedef struct BXVD_Decoder_Counters
212{
213   uint32_t uiDecoderInputOverflow;  /* Number of times the decoder input has gotten into an overflow state. */
214   uint32_t uiVsyncCount;           /* The number times BXVD_Decoder_DisplayInterruptEvent_isr has
215                                     * been called.  Conditionally reset in BXVD_Decoder_StartDecode_isr.
216                                     */
217}  BXVD_Decoder_Counters;
218
219typedef struct BXVD_Decoder_P_LogData
220{
221
222   /* Used for debug logging. */
223   uint32_t    uiVsyncsPerSecond;
224   uint32_t    uiCallbackCount;
225   uint32_t    uiPicturesFromAvd;      /* count of pictures received from AVD. */
226   uint32_t    uiPicturesToAvd;        /* count of pictures returned to AVD. */
227   uint32_t    uiPicturesToPP;         /* count of pictures sent to PP */
228   uint32_t    uiPicturesFromPP;         /* count of pictures returned from PP */
229
230   /* For timing callbacks and functions calls. */
231   BXVD_DecoderTimer_P_Data   stTimerData;
232
233} BXVD_Decoder_P_LogData;
234
235typedef struct BXVD_P_Decoder_Context
236{
237   bool  bDecoderHasBeenInitialized;   /* set in BXVD_Decoder_StartDecode_isr */
238
239   BXVD_Decoder_P_PictureContextQueue  stPictureContextQueue;
240
241   BXVD_Decoder_P_UnifiedPictureQueue  stUnifiedPictureQueue;
242
243   BXVD_Decoder_P_DQTContext  stDqtCntxt;
244
245   BXVD_Decoder_P_DNR         stDNRInfo;
246
247   BXVD_Decoder_Counters      stCounters;
248
249   uint32_t                   uiDropCountSnapshot;
250
251   bool                       bHostSparseMode; /* Host Sparse Mode */
252   bool                       bReversePlayback; /* DQT */
253   BXVD_MPEGPulldownOverride  ePulldownOverride;
254   bool                       bCRCMode;
255
256   /* For debug. */
257   BXVD_Decoder_P_LogData   stLogData;
258
259#if BXVD_DM_ENABLE_YUV_GRAB_MODE
260   /* variables assocated with the "grab" debug mode */
261   bool  bGrabRvc;
262   bool  bGrabPpb;
263   bool  bGrabYuv;
264#endif
265
266} BXVD_P_Decoder_Context;
267
268typedef struct BXVD_Decoder_P_LocalState
269{
270   uint32_t uiDeliveryQueueWriteOffset;   /* snapshot the offset to avoid race conditions. */
271
272} BXVD_Decoder_P_LocalState;
273
274
275/*
276 * Public functions.
277 */
278BERR_Code
279BXVD_Decoder_GetPictureCount_isr(
280         BXVD_ChannelHandle hXvdCh,
281         uint32_t *puiPictureCount
282         );
283
284BERR_Code
285BXDM_PP_PP_Decoder_PeekAtPicture_isr(
286         BXVD_ChannelHandle hXvdCh,
287         uint32_t uiIndex,
288         BXDM_Picture **pUnifiedPicture
289         );
290
291BERR_Code
292BXVD_Decoder_GetNextPicture_isr(
293         BXVD_ChannelHandle hXvdCh,
294         BXDM_Picture **pUnifiedPicture
295         );
296
297BERR_Code
298BXVD_Decoder_ReleasePicture_isr(
299         BXVD_ChannelHandle hXvdCh,
300         BXDM_Picture *pUnifiedPicture,
301         const BXDM_Decoder_ReleasePictureInfo *pReleasePictureInfo
302         );
303
304BERR_Code
305BXVD_Decoder_GetPictureDropPendingCount_isr(
306         BXVD_ChannelHandle hXvdCh,
307         uint32_t *puiPictureDropPendingCount
308         );
309
310BERR_Code
311BXVD_Decoder_RequestPictureDrop_isr(
312         BXVD_ChannelHandle hXvdCh,
313         uint32_t *puiPictureDropRequestCount
314         );
315
316BERR_Code
317BXVD_Decoder_DisplayInterruptEvent_isr(
318         BXVD_ChannelHandle hXvdCh
319         );
320
321BERR_Code
322BXVD_Decoder_GetDMInterface(
323         BXVD_ChannelHandle hXvdCh,
324         BXDM_Decoder_Interface *pstDecoderInterface,
325         void **pPrivateContext
326         );
327
328BERR_Code
329BXVD_Decoder_GetPPBParameterQueueInfo_isr(
330         BXVD_ChannelHandle hXvdCh,
331         const BXVD_PPBParameterInfo* apstPPBParameterInfo[],
332         uint32_t uiPPBParameterInfoCount,
333         uint32_t *puiValidPPBParameterInfoCount
334   );
335
336BERR_Code
337BXVD_Decoder_SetCRCMode_isr(
338         BXVD_ChannelHandle hXvdCh,
339         bool bEnable);
340
341BERR_Code
342BXVD_Decoder_GetCRCMode_isr(
343         BXVD_ChannelHandle hXvdCh,
344         bool *pbEnable);
345
346
347BERR_Code
348BXVD_Decoder_StartDecode_isr(
349         BXVD_ChannelHandle hXvdCh
350         );
351
352BERR_Code
353BXVD_Decoder_StopDecode_isr(
354         BXVD_ChannelHandle hXvdCh
355         );
356
357BERR_Code
358BXVD_Decoder_WatchdogReset_isr(
359         BXVD_ChannelHandle hXvdCh
360         );
361
362
363BERR_Code
364BXVD_Decoder_P_ComputeAspectRatio(
365         BXVD_P_PPB * pPPB,
366         BXDM_Picture * pstXdmPicture
367         );
368
369BERR_Code
370BXVD_Decoder_GetCounters_isr(
371      BXVD_ChannelHandle hXvdCh,
372      BXVD_Decoder_Counters * pstCounters
373      );
374
375
376#ifdef __cplusplus
377}
378#endif
379
380#endif /* BXVD_DECODER_H_ */
Note: See TracBrowser for help on using the repository browser.