1 /*
2 * Copyright (c) 2019-2023, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file     encode_av1_tile.h
24 //! \brief    Defines the common interface for av1 tile
25 //!
26 #ifndef __ENCODE_AV1_TILE_H__
27 #define __ENCODE_AV1_TILE_H__
28 #include "encode_tile.h"
29 #include "codec_def_encode_av1.h"
30 #include "encode_back_annotation_packet.h"
31 #include "mhw_vdbox_vdenc_itf.h"
32 #include "mhw_vdbox_avp_itf.h"
33 #include "mhw_hwcmd.h"
34 
35 namespace encode
36 {
37 struct Av1TileStatusInfo
38 {
39     uint32_t uiAv1PakStatistics = 0;
40     uint32_t uiVdencStatistics = 0;
41 };
42 
43 struct Av1TileGroupHeaderInfo
44 {
45     uint8_t     *pBuffer    = nullptr;
46     uint32_t    bitOffset   = 0;
47 };
48 struct Av1ReportTileGroupParams
49 {
50     uint8_t  TileGroupStart;
51     uint8_t  TileGroupEnd;
52     uint32_t TileGroupOBUSizeInBytes;
53     uint32_t TileGroupNum;
54     uint32_t FirstTileGroupByteOffset;
55 };
56 
57 //!
58 //! \brief VDENC_HEVC_VP9_FRAME_BASED_STATISTICS_STREAMOUT
59 //! \details
60 //!
61 //!
62 struct VdencStatistics
63 {
64     union
65     {
66         //!< DWORD 0
67         struct
68         {
69             uint32_t SumSadHaarForBestModeDecision : __CODEGEN_BITFIELD(0, 31);  //!< Sum sad\haar for best mode decision
70         };
71         uint32_t Value;
72     } DW0;
73 
74     union
75     {
76         //!< DWORD 1
77         struct
78         {
79             uint32_t IntraCuCountNormalized : __CODEGEN_BITFIELD(0, 19);   //!< Intra CU count normalized
80             uint32_t Reserved : __CODEGEN_BITFIELD(20, 31);  //!< Reserved
81         };
82     } DW1;
83 
84     union
85     {
86         //!< DWORD 2
87         struct
88         {
89             uint32_t NonSkipInterCuCountNormalized : __CODEGEN_BITFIELD(0, 19);   //!< Non-skip Inter CU count normalized
90             uint32_t Reserved : __CODEGEN_BITFIELD(20, 31);  //!< Reserved
91         };
92     } DW2;
93 
94     union
95     {
96         //!< DWORD 3
97         struct
98         {
99             uint32_t SegmentMapCount0 : __CODEGEN_BITFIELD(0, 19);   //!< segment map count 0
100             uint32_t Reserved : __CODEGEN_BITFIELD(20, 31);  //!< Reserved
101         };
102         uint32_t Value;
103     } DW3;
104 
105     union
106     {
107         //!< DWORD 4
108         struct
109         {
110             uint32_t SegmentMapCount1 : __CODEGEN_BITFIELD(0, 19);   //!< segment map count 1
111             uint32_t Reserved : __CODEGEN_BITFIELD(20, 31);  //!< Reserved
112         };
113         uint32_t Value;
114     } DW4;
115 
116     union
117     {
118         //!< DWORD 5
119         struct
120         {
121             uint32_t SegmentMapCount2 : __CODEGEN_BITFIELD(0, 19);   //!< segment map count 2
122             uint32_t Reserved : __CODEGEN_BITFIELD(20, 31);  //!< Reserved
123         };
124         uint32_t Value;
125     } DW5;
126 
127     union
128     {
129         //!< DWORD 6
130         struct
131         {
132             uint32_t SegmentMapCount3 : __CODEGEN_BITFIELD(0, 19);   //!< segment map count 3
133             uint32_t Reserved : __CODEGEN_BITFIELD(20, 31);  //!< Reserved
134         };
135         uint32_t Value;
136     } DW6;
137 
138     union
139     {
140         //!< DWORD 7
141         struct
142         {
143             uint32_t xGlobalMeSample0 : __CODEGEN_BITFIELD(0, 15);   //!< MV.x Global ME sample 0 (.25x,.25x)
144             uint32_t yGlobalMeSample0 : __CODEGEN_BITFIELD(16, 31);  //!< MV.y Global ME sample 0 (.25x,.25x)
145         };
146         uint32_t Value;
147     } DW7;
148 
149     union
150     {
151         //!< DWORD 8
152         struct
153         {
154             uint32_t xyGlobalMeSample1 : __CODEGEN_BITFIELD(0, 31);  //!< MV.xy Global ME sample 1 (.25x,.25x)
155         };
156         uint32_t Value;
157     } DW8;
158 
159     union
160     {
161         //!< DWORD 9
162         struct
163         {
164             uint32_t xyGlobalMeSample2 : __CODEGEN_BITFIELD(0, 31);  //!< MV.xy Global ME sample 2 (.25x,.25x)
165         };
166         uint32_t Value;
167     } DW9;
168 
169     union
170     {
171         //!< DWORD 10
172         struct
173         {
174             uint32_t xyGlobalMeSample3 : __CODEGEN_BITFIELD(0, 31);  //!< MV.xy Global ME sample 3 (.25x,.25x)
175         };
176         uint32_t Value;
177     } DW10;
178 
179     union
180     {
181         //!< DWORD 11
182         struct
183         {
184             uint32_t xyGlobalMeSample4 : __CODEGEN_BITFIELD(0, 31);  //!< MV.xy Global ME sample 4 (.25x,.25x)
185         };
186         uint32_t Value;
187     } DW11;
188 
189     union
190     {
191         //!< DWORD 12
192         struct
193         {
194             uint32_t xyGlobalMeSample5 : __CODEGEN_BITFIELD(0, 31);  //!< MV.xy Global ME sample 5 (.25x,.25x)
195         };
196         uint32_t Value;
197     } DW12;
198 
199     union
200     {
201         //!< DWORD 13
202         struct
203         {
204             uint32_t xyGlobalMeSample6 : __CODEGEN_BITFIELD(0, 31);  //!< MV.xy Global ME sample 6 (.25x,.25x)
205         };
206         uint32_t Value;
207     } DW13;
208 
209     union
210     {
211         //!< DWORD 14
212         struct
213         {
214             uint32_t xyGlobalMeSample7 : __CODEGEN_BITFIELD(0, 31);  //!< MV.xy Global ME sample 7 (.25x,.25x)
215         };
216         uint32_t Value;
217     } DW14;
218 
219     union
220     {
221         //!< DWORD 15
222         struct
223         {
224             uint32_t xyGlobalMeSample8 : __CODEGEN_BITFIELD(0, 31);  //!< MV.xy Global ME sample 8 (.25x,.25x)
225         };
226         uint32_t Value;
227     } DW15;
228 
229     union
230     {
231         //!< DWORD 16
232         struct
233         {
234             uint32_t RefIdForGlobalMeSample0 : __CODEGEN_BITFIELD(0, 1);    //!< RefID corresponding to of Global ME sample 0
235             uint32_t RefIdForGlobalMeSample1_8 : __CODEGEN_BITFIELD(2, 17);   //!< RefID corresponding to of Global ME sample 0
236             uint32_t Reserved : __CODEGEN_BITFIELD(18, 31);  //!< Reserved
237         };
238         uint32_t Value;
239     } DW16;
240 
241     union
242     {
243         //!< DWORD 17
244         struct
245         {
246             uint32_t PaletteCuCountNormalized : __CODEGEN_BITFIELD(0, 19);   //!< Palette CU Count Normalized
247             uint32_t Reserved : __CODEGEN_BITFIELD(20, 31);  //!< Reserved
248         };
249         uint32_t Value;
250     } DW17;
251 
252     union
253     {
254         //!< DWORD 18
255         struct
256         {
257             uint32_t IbcCuCountNormalized : __CODEGEN_BITFIELD(0, 19);   //!< IBC CU Count Normalized
258             uint32_t Reserved : __CODEGEN_BITFIELD(20, 31);  //!< Reserved
259         };
260         uint32_t Value;
261     } DW18;
262 
263     union
264     {
265         //!< DWORD 19
266         struct
267         {
268             uint32_t NumberSecondaryColorsChannel1 : __CODEGEN_BITFIELD(0, 15);   //!< Number of secondary colors (Channel1)
269             uint32_t NumberSecondaryColorsChannel0 : __CODEGEN_BITFIELD(16, 31);  //!< Number of secondary colors (Channel0)
270         };
271         uint32_t Value;
272     } DW19;
273 
274     union
275     {
276         //!< DWORD 20
277         struct
278         {
279             uint32_t NumberSecondaryColorsChannel2 : __CODEGEN_BITFIELD(0, 15);   //!< Number of secondary colors (Channel2)
280             uint32_t Reserved : __CODEGEN_BITFIELD(16, 31);  //!< Reserved
281         };
282         uint32_t Value;
283     } DW20;
284 
285     union
286     {
287         //!< DWORD 21
288         struct
289         {
290             uint32_t Reserved : __CODEGEN_BITFIELD(0, 31);  //!< Reserved
291         };
292         uint32_t Value;
293     } DW21;
294 
295     union
296     {
297         //!< DWORD 22
298         struct
299         {
300             uint32_t PositionTimerExpiration : __CODEGEN_BITFIELD(0, 15);   //!< Position of Timer expiration
301             uint32_t TimerExpireStatus : __CODEGEN_BITFIELD(16, 16);  //!< Timer Expire status
302             uint32_t Reserved : __CODEGEN_BITFIELD(17, 31);  //!< Reserved
303         };
304         uint32_t Value;
305     } DW22;
306 
307     union
308     {
309         //!< DWORD 23
310         struct
311         {
312             uint32_t LocationPanic : __CODEGEN_BITFIELD(0, 15);   //!< Location of panic
313             uint32_t PanicDetected : __CODEGEN_BITFIELD(16, 16);  //!< Panic detected
314             uint32_t Reserved : __CODEGEN_BITFIELD(17, 31);  //!< Reserved
315         };
316         uint32_t Value;
317     } DW23;
318 
319     union
320     {
321         //!< DWORD 24 - 28
322         uint32_t Value[5];
323     } DW24_28;
324 
325     union
326     {
327         //!< DWORD 29
328         struct
329         {
330             uint32_t SumSadHaarForBestModeDecisionBottomHalfPopulation : __CODEGEN_BITFIELD(0, 31);   //!< Sum sad\haar for best mode decision bottom half population
331         };
332         uint32_t Value;
333     } DW29;
334 
335     union
336     {
337         //!< DWORD 30
338         struct
339         {
340             uint32_t SumSadHaarForBestModeDecisionTopHalfPopulation : __CODEGEN_BITFIELD(0, 31);   //!< Sum sad\haar for best mode decision top half population
341         };
342         uint32_t Value;
343     } DW30;
344 
345     union
346     {
347         //!< DWORD 31
348         struct
349         {
350             uint32_t SumTopHalfPopulationOccurrences : __CODEGEN_BITFIELD(0, 15);   //!< Sum top half population occurrences
351             uint32_t SumBottomHalfPopulationOccurrences : __CODEGEN_BITFIELD(16, 31);  //!< Sum bottom half population occurrences
352         };
353         uint32_t Value;
354     } DW31;
355 
356     union
357     {
358         //!< DWORD 32
359         struct
360         {
361             uint32_t ReadRequestBank0 : __CODEGEN_BITFIELD(0, 23);   //!< Read Request Bank 0
362             uint32_t Reserved : __CODEGEN_BITFIELD(24, 31);  //!< Reserved
363         };
364         uint32_t Value;
365     } DW32;
366 
367     union
368     {
369         //!< DWORD 33
370         struct
371         {
372             uint32_t CacheMissCountBank0 : __CODEGEN_BITFIELD(0, 23);   //!< Cache Miss count Bank 0
373             uint32_t Reserved : __CODEGEN_BITFIELD(24, 31);  //!< Reserved
374         };
375         uint32_t Value;
376     } DW33;
377 
378     union
379     {
380         //!< DWORD 34
381         struct
382         {
383             uint32_t ReadRequestBank1 : __CODEGEN_BITFIELD(0, 23);   //!< Read Request Bank 1
384             uint32_t Reserved : __CODEGEN_BITFIELD(24, 31);  //!< Reserved
385         };
386         uint32_t Value;
387     } DW34;
388 
389     union
390     {
391         //!< DWORD 35
392         struct
393         {
394             uint32_t CacheMissCountBank1 : __CODEGEN_BITFIELD(0, 23);   //!< Cache Miss count Bank 1
395             uint32_t Reserved : __CODEGEN_BITFIELD(24, 31);  //!< Reserved
396         };
397         uint32_t Value;
398     } DW35;
399 
400     union
401     {
402         //!< DWORD 36
403         struct
404         {
405             uint32_t ReadRequestBank2 : __CODEGEN_BITFIELD(0, 23);   //!< Read Request Bank 2
406             uint32_t Reserved : __CODEGEN_BITFIELD(24, 31);  //!< Reserved
407         };
408         uint32_t Value;
409     } DW36;
410 
411     union
412     {
413         //!< DWORD 37
414         struct
415         {
416             uint32_t CacheMissCountBank2 : __CODEGEN_BITFIELD(0, 23);   //!< Cache Miss count Bank 2
417             uint32_t Reserved : __CODEGEN_BITFIELD(24, 31);  //!< Reserved
418         };
419         uint32_t Value;
420     } DW37;
421 
422     union
423     {
424         //!< DWORD 38
425         struct
426         {
427             uint32_t ReadRequestBank3 : __CODEGEN_BITFIELD(0, 23);   //!< Read Request Bank 3
428             uint32_t Reserved : __CODEGEN_BITFIELD(24, 31);  //!< Reserved
429         };
430         uint32_t Value;
431     } DW38;
432 
433     union
434     {
435         //!< DWORD 39
436         struct
437         {
438             uint32_t CacheMissCountBank3 : __CODEGEN_BITFIELD(0, 23);   //!< Cache Miss count Bank 3
439             uint32_t Reserved : __CODEGEN_BITFIELD(24, 31);  //!< Reserved
440         };
441         uint32_t Value;
442     } DW39;
443 
444     union
445     {
446         //!< DWORD 40
447         struct
448         {
449             uint32_t ReadRequestBank4 : __CODEGEN_BITFIELD(0, 23);   //!< Read Request Bank 4
450             uint32_t Reserved : __CODEGEN_BITFIELD(24, 31);  //!< Reserved
451         };
452         uint32_t Value;
453     } DW40;
454 
455     union
456     {
457         //!< DWORD 41
458         struct
459         {
460             uint32_t CacheMissCountBank4 : __CODEGEN_BITFIELD(0, 23);   //!< Cache Miss count Bank 4
461             uint32_t Reserved : __CODEGEN_BITFIELD(24, 31);  //!< Reserved
462         };
463         uint32_t Value;
464     } DW41;
465 
466     union
467     {
468         //!< DWORD 42
469         struct
470         {
471             uint32_t HimeRequestCount : __CODEGEN_BITFIELD(0, 23);   //!< HIME request count
472             uint32_t Reserved : __CODEGEN_BITFIELD(24, 31);  //!< Reserved
473         };
474         uint32_t Value;
475     } DW42;
476 
477     union
478     {
479         //!< DWORD 43
480         struct
481         {
482             uint32_t HimeRequestArbitraionLostCycleCount : __CODEGEN_BITFIELD(0, 23);   //!< HIME request arbitraion lost cycle count
483             uint32_t Reserved : __CODEGEN_BITFIELD(24, 31);  //!< Reserved
484         };
485         uint32_t Value;
486     } DW43;
487 
488     union
489     {
490         //!< DWORD 44
491         struct
492         {
493             uint32_t HimeRequestStallCount : __CODEGEN_BITFIELD(0, 23);   //!< HIME Request Stall count
494             uint32_t Reserved : __CODEGEN_BITFIELD(24, 31);  //!< Reserved
495         };
496         uint32_t Value;
497     } DW44;
498 
499     union
500     {
501         //!< DWORD 45 - 46
502         uint32_t Value[2];
503     } DW45_46;
504 
505     union
506     {
507         //!< DWORD 47
508         struct
509         {
510             uint32_t TotalReferenceReadCount : __CODEGEN_BITFIELD(0, 31);  //!< Total Reference Read count
511         };
512         uint32_t Value;
513     } DW47;
514 
515     union
516     {
517         //!< DWORD 48 - 303
518         uint32_t Value[256];
519     } DW48_303;
520 
521     //! \brief Explicit member initialization function
522     VdencStatistics();
523 
524     static const size_t dwSize   = 304;
525     static const size_t byteSize = 1216;
526 };
527 
528 struct Av1TileInfo
529 {
530     uint16_t tileId      = 0;
531     uint16_t tgTileNum   = 0;
532     uint16_t tileGroupId = 0;
533 
534     uint16_t tileColPositionInSb = 0;
535     uint16_t tileRowPositionInSb = 0;
536 
537     uint16_t tileWidthInSbMinus1  = 0;
538     uint16_t tileHeightInSbMinus1 = 0;
539 
540     uint32_t tileStartXInLCU = 0;
541     uint32_t tileStartYInLCU = 0;
542     uint32_t tileEndXInLCU   = 0;
543     uint32_t tileEndYInLCU   = 0;
544 
545     bool firstTileInAFrame    = false;
546     bool lastTileOfColumn     = false;
547     bool lastTileOfRow        = false;
548     bool firstTileOfTileGroup = false;
549     bool lastTileOfTileGroup  = false;
550     bool lastTileOfFrame      = false;
551 };
552 
553 class Av1EncodeTile : public EncodeTile, public mhw::vdbox::vdenc::Itf::ParSetting, public mhw::vdbox::avp::Itf::ParSetting
554 {
555 public:
556     Av1EncodeTile(MediaFeatureManager *featureManager,
557         EncodeAllocator *allocator,
558         CodechalHwInterfaceNext *hwInterface,
559         void *constSettings);
560 
561     virtual ~Av1EncodeTile();
562 
563     //!
564     //! \brief  Init encode parameter
565     //! \param  [in] settings
566     //!         Pointer to settings
567     //! \return MOS_STATUS
568     //!         MOS_STATUS_SUCCESS if success, else fail reason
569     //!
570     virtual MOS_STATUS Init(void *settings) override;
571 
572     //!
573     //! \brief  Update encode parameter
574     //! \param  [in] params
575     //!         Pointer to parameters
576     //! \return MOS_STATUS
577     //!         MOS_STATUS_SUCCESS if success, else fail reason
578     //!
579     virtual MOS_STATUS Update(void *params) override;
580 
581     MOS_STATUS IsFirstTileInGroup(bool &firstTileInGroup, uint32_t &tileGroupIdx) const;
582     MOS_STATUS SetHucCtrlBuffer(VdencAv1HucCtrlBigData& hucCtrlBuffer);
583 
584     MHW_SETPAR_DECL_HDR(VDENC_PIPE_BUF_ADDR_STATE);
585 
586     MHW_SETPAR_DECL_HDR(VDENC_WALKER_STATE);
587 
588     MHW_SETPAR_DECL_HDR(VDENC_HEVC_VP9_TILE_SLICE_STATE);
589 
590     MHW_SETPAR_DECL_HDR(AVP_PIC_STATE);
591 
592     MHW_SETPAR_DECL_HDR(AVP_PIPE_MODE_SELECT);
593 
594     MHW_SETPAR_DECL_HDR(AVP_TILE_CODING);
595 
596     MHW_SETPAR_DECL_HDR(AVP_IND_OBJ_BASE_ADDR_STATE);
597 
598     MHW_SETPAR_DECL_HDR(AVP_PAK_INSERT_OBJECT);
599 
600     MHW_SETPAR_DECL_HDR(AVP_PIPE_BUF_ADDR_STATE);
601 
602     MHW_SETPAR_DECL_HDR(VDENC_CMD2);
603 
604     MOS_STATUS GetTileStatsOffset(uint32_t &offset);
605 
606     MOS_STATUS GetTileStatusInfo(Av1TileStatusInfo &av1TileStatsOffset, Av1TileStatusInfo &av1StatsSize);
607 
GetTileGroupInfo(PCODEC_AV1_ENCODE_TILE_GROUP_PARAMS & tileGroupParams,uint32_t & numTilegroups)608     MOS_STATUS GetTileGroupInfo(PCODEC_AV1_ENCODE_TILE_GROUP_PARAMS& tileGroupParams, uint32_t& numTilegroups)
609     {
610         tileGroupParams = m_av1TileGroupParams;
611         numTilegroups = m_numTileGroups;
612         return MOS_STATUS_SUCCESS;
613     }
614     void       WriteObuHeader(Av1TileGroupHeaderInfo &buf, const PCODEC_AV1_ENCODE_PICTURE_PARAMS &av1PicParam);
615     void       WriteBit(Av1TileGroupHeaderInfo &buf, uint8_t bit);
616     void       WriteLiteral(Av1TileGroupHeaderInfo &buf, uint64_t data, uint64_t bits);
617     uint8_t    write_leb128(uint64_t in_value, uint64_t &out_encoded_value, const uint8_t fixed_output_len);
618     uint16_t   CeilLog2(uint16_t x);
619     uint16_t   TileLog2(uint16_t blksize, uint16_t target);
620     uint16_t   PrepareTileGroupHeaderAv1(uint8_t *buffer, uint32_t index, const PCODEC_AV1_ENCODE_PICTURE_PARAMS &av1PicParam);
621     MOS_STATUS TileSizeCheck(const PCODEC_AV1_ENCODE_PICTURE_PARAMS &av1PicParam);
622     MOS_STATUS MakeTileGroupHeaderAv1(void *params);
623     MOS_STATUS GetTileGroupReportParams(uint32_t idx, const Av1ReportTileGroupParams *&reportTileData);
624     MOS_STATUS ReadObuSize(const uint8_t *ObuOffset, uint32_t &size);
625     MOS_STATUS GetTileInfo(Av1TileInfo *av1TileInfo) const;
GetDummyIdx(uint8_t & idx)626     MOS_STATUS GetDummyIdx(uint8_t &idx) { idx = m_firstDummyIdx; return MOS_STATUS_SUCCESS;}
627 
628 protected:
629     //!
630     //! \brief  Calculate one tile's width and height
631     //!
632     //! \param  [in] av1PicParams
633     //!         Picture params used for cal
634     //! \param  [out] rowBd
635     //!         Tile row boundary
636     //! \param  [out] colBd
637     //!         Tile column boundary
638     //!
639     //! \return   MOS_STATUS
640     //!           MOS_STATUS_SUCCESS if success, else fail reason
641     //!
642     MOS_STATUS CalculateTilesBoundary(
643         PCODEC_AV1_ENCODE_PICTURE_PARAMS av1PicParams,
644         uint32_t *rowBd,
645         uint32_t *colBd);
646 
647     //!
648     //! \brief  Calculate Lcu number by tile layout
649     //!
650     //! \param  [in] av1PicParams
651     //!         Picture params used for cal
652     //!
653     //! \return   MOS_STATUS
654     //!           MOS_STATUS_SUCCESS if success, else fail reason
655     //!
656     MOS_STATUS CalculateNumLcuByTiles(PCODEC_AV1_ENCODE_PICTURE_PARAMS av1PicParams);
657 
658     //!
659     //! \brief  Calculate one tile's width and height
660     //!
661     //! \param  [in] av1PicParams
662     //!         Picture params used for cal
663     //! \param  [in] av1SeqParams
664     //!         Sequence params used for cal
665     //! \param  [in] rowIndex
666     //!         Tile row index
667     //! \param  [in] colIndex
668     //!         Tile column index
669     //! \param  [in] rowBd
670     //!         Tile row boundary
671     //! \param  [in] colBd
672     //!         Tile column boundary
673     //!
674     //! \return   MOS_STATUS
675     //!           MOS_STATUS_SUCCESS if success, else fail reason
676     //!
677     MOS_STATUS CalculateTileWidthAndHeight(
678         PCODEC_AV1_ENCODE_PICTURE_PARAMS  av1PicParams,
679         uint32_t  rowIndex,
680         uint32_t  colIndex,
681         uint32_t *rowBd,
682         uint32_t *colBd);
683 
684     //!
685     //! \brief    Allocate Tile Statistics
686     //!
687     //! \param  [in] params
688     //!         Pointer to parameters
689     //!
690     //! \return   MOS_STATUS
691     //!           MOS_STATUS_SUCCESS if success, else fail reason
692     //!
693     MOS_STATUS AllocateTileStatistics(void *params) override;
694 
695 
696     virtual MOS_STATUS SetTileData(void *params) override;
697 
698     MOS_STATUS SetTileGroupReportParams();
699 
700     PCODEC_AV1_ENCODE_TILE_GROUP_PARAMS m_av1TileGroupParams = nullptr;   //!< Pointer to slice parameter
701 
702     Av1ReportTileGroupParams *m_reportTileGroupParams[EncodeBasicFeature::m_uncompressedSurfaceNum] = {};
703 
704     uint32_t              m_numTileGroups    = 0;        //!< Total number of tile groups in current frame
705     uint32_t              m_numSbInPic       = 0;        //!< Total number of Sb in pic cal by each tile
706 
707     Av1TileStatusInfo m_av1TileStatsOffset  = {};   //!< Page aligned offsets used to program AVP / VDEnc pipe and HuC PAK Integration kernel input
708     Av1TileStatusInfo m_av1FrameStatsOffset = {};   //!< Page aligned offsets used to program HuC PAK Integration kernel output, HuC BRC kernel input
709     Av1TileStatusInfo m_av1StatsSize        = {};   //!< HEVC Statistics size
710 
711     static const uint32_t m_av1VdencStateSize = 1216;    // VDEnc Statistic: 48DWs (3CLs) of HMDC Frame Stats + 256 DWs (16CLs) of Histogram Stats = 1216 bytes
712     std::vector<uint8_t>  m_tgHeaderBuf       = {};
713 
714     uint8_t               m_firstDummyIdx     = 0;
715 
716 MEDIA_CLASS_DEFINE_END(encode__Av1EncodeTile)
717 };
718 
719 }  // namespace encode
720 
721 #endif  // !__ENCODE_AV1_TILE_H__
722