1 /*
2 * Copyright (c) 2017, 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     codechal_encode_wp.h
24 //! \brief    Defines base class for weighted prediction kernel
25 //!
26 
27 #ifndef __CODECHAL_ENCODE_WP_H__
28 #define __CODECHAL_ENCODE_WP_H__
29 
30 #include "codechal.h"
31 #include "codechal_hw.h"
32 #include "codechal_encoder_base.h"
33 
34 //!
35 //! \class    CodechalEncodeWP
36 //! \brief    Weighted prediction kernel base class
37 //! \details  Entry point to create weighted prediction class instance
38 //!
39 //!         This class defines the base class for weighted prediction feature, it includes
40 //!         common member fields, functions, interfaces etc shared by all Gens.
41 //!
42 //!         To create an instance, client needs to call #CodechalEncodeWP::CreateWPState()
43 //!
44 class CodechalEncodeWP
45 {
46 public:
47     //!
48     //! \struct      SliceParams
49     //! \brief       Slice parameters
50     //!
51     struct SliceParams
52     {
53         /*! \brief Specifies the weights and offsets used for explicit mode weighted prediction.
54         *
55         *    Weigths[i][j][k][m]:
56         *        \n - i: the reference picture list (0 or 1)
57         *        \n - j: reference to entry j in RefPicList (has range [0...31])
58         *        \n - k: the YUV component (0 = luma, 1 = Cb chroma, 2 = Cr chroma)
59         *        \n - m: the weight or offset used in the weighted prediction process (0 = weight, 1 = offset)
60         */
61         uint16_t        weights[2][32][3][2] = {};
62         uint8_t         luma_log2_weight_denom = 0; //!< Same as AVC syntax element.
63     };
64 
65     //!
66     //! \struct      CurbeParams
67     //! \brief     Curbe params for WP kernel
68     //!
69     struct CurbeParams
70     {
71         uint8_t                          refPicListIdx = 0;
72         uint32_t                         wpIdx = 0;
73         SliceParams                      *slcParams = nullptr;
74     };
75 
76     //!
77     //! \struct      SurfaceParams
78     //! \brief       Surface params for WP kernel
79     //!
80     struct SurfaceParams
81     {
82         uint8_t                          wpOutListIdx = 0;
83         PMOS_SURFACE                     refFrameInput = nullptr;
84         MOS_SURFACE                      weightedPredOutputPicList[CODEC_NUM_WP_FRAME] = {};
85         bool                             refIsBottomField = false;
86     };
87 
88     //!
89     //! \struct      KernelParams
90     //! \brief       Kernel params for WP kernel
91     //!
92     struct KernelParams
93     {
94         bool                             useRefPicList1 = false;
95         uint32_t                         wpIndex = 0;
96         SliceParams                      *slcWPParams = nullptr;
97         PMOS_SURFACE                     refFrameInput = nullptr;
98         bool                             refIsBottomField = false;
99         bool                             *useWeightedSurfaceForL0 = nullptr;
100         bool                             *useWeightedSurfaceForL1 = nullptr;
101     };
102 
103     //!
104     //! \enum      KernelBTI
105     //! \brief     Weighted prediction kernel binding table
106     //!
107     enum KernelBTI
108     {
109         wpInputRefSurface = 0,
110         wpOutputScaledSurface = 1,
111         wpNumSurfaces = 2,
112     };
113 
114     //!
115     //! \brief    Set kernel base
116     //!
117     //! \param    [in] kernelBase
118     //!           Kernel base
119     //!
SetKernelBase(uint8_t * kernelBase)120     void SetKernelBase(uint8_t *kernelBase) { m_kernelBase = kernelBase; }
121 
122     //!
123     //! \brief    Get WP output picture list
124     //!
125     //! \param    [in] index
126     //!           Index
127     //!
128     //! \return   PMOS_SURFACE
129     //!           Pointer to MOS surface
130     //!
GetWPOutputPicList(uint8_t index)131     PMOS_SURFACE GetWPOutputPicList(uint8_t index) { return &m_surfaceParams.weightedPredOutputPicList[index]; }
132 
133     //!
134     //! \brief    Copy constructor
135     //!
136     CodechalEncodeWP(const CodechalEncodeWP&) = delete;
137 
138     //!
139     //! \brief    Copy assignment operator
140     //!
141     CodechalEncodeWP& operator=(const CodechalEncodeWP&) = delete;
142 
143     //!
144     //! \brief    Destructor
145     //!
146     virtual ~CodechalEncodeWP();
147 
148     //!
149     //! \brief    Get weighted prediction BT count
150     //!
151     //! \return   Number of BTI
152     //!
153     uint8_t GetBTCount();
154 
155     //!
156     //! \brief    Initialize weighted prediction kernel state
157     //!
158     //! \return   MOS_STATUS
159     //!           MOS_STATUS_SUCCESS if success, else fail reason
160     //!
161     virtual MOS_STATUS InitKernelState();
162 
163     //!
164     //! \brief    Weighted prediction kernel function
165     //!
166     //! \param    [in] params
167     //!           Pointer to KernelParams
168     //!
169     //! \return   MOS_STATUS
170     //!           MOS_STATUS_SUCCESS if success, else fail reason
171     //!
172     virtual MOS_STATUS Execute(KernelParams *params);
173 
174     //!
175     //! \brief    Allocate weighted prediction surface
176     //!
177     //! \param    [in] binary
178     //!           Kernel binary
179     //!
180     //! \param    [in] operation
181     //!           Encode operation
182     //!
183     //! \param    [in] krnStateIdx
184     //!           Kernel state index
185     //!
186     //! \param    [in] krnHeader
187     //!           Kernel header
188     //!
189     //! \param    [in] krnSize
190     //!           Kernel size
191     //!
192     //! \return   MOS_STATUS
193     //!           MOS_STATUS_SUCCESS if success, else fail reason
194     //!
195     MOS_STATUS(*pfnGetKernelHeaderAndSize) (
196         void                            *binary,
197         EncOperation                    operation,
198         uint32_t                        krnStateIdx,
199         void                            *krnHeader,
200         uint32_t                        *krnSize) {};
201 
202 protected:
203     //!
204     //! \brief    Weighted prediction kernel header struct
205     //!
206     struct KernelHeader
207     {
208         int                     kernelCount = 0;
209         CODECHAL_KERNEL_HEADER  header = {};
210     };
211 
212     //!
213     //! \brief    Weighted prediction kernel Curbe data
214     //!
215     struct CurbeData
216     {
217         // DW0
218         union
219         {
220             struct
221             {
222                 uint32_t   defaultWeight    : MOS_BITFIELD_RANGE(0, 15);
223                 uint32_t   defaultOffset    : MOS_BITFIELD_RANGE(16, 31);
224             };
225             struct
226             {
227                 uint32_t   value;
228             };
229         } DW0;
230 
231         // DW1
232         union
233         {
234             struct
235             {
236                 uint32_t   roi0XLeft        : MOS_BITFIELD_RANGE(0, 15);
237                 uint32_t   roi0YTop         : MOS_BITFIELD_RANGE(16, 31);
238             };
239             struct
240             {
241                 uint32_t   value;
242             };
243         } DW1;
244 
245         // DW2
246         union
247         {
248             struct
249             {
250                 uint32_t   roi0XRight       : MOS_BITFIELD_RANGE(0, 15);
251                 uint32_t   roi0YBottom      : MOS_BITFIELD_RANGE(16, 31);
252             };
253             struct
254             {
255                 uint32_t   value;
256             };
257         } DW2;
258 
259         // DW3
260         union
261         {
262             struct
263             {
264                 uint32_t   roi0Weight       : MOS_BITFIELD_RANGE(0, 15);
265                 uint32_t   roi0Offset       : MOS_BITFIELD_RANGE(16, 31);
266             };
267             struct
268             {
269                 uint32_t   value;
270             };
271         } DW3;
272 
273         // DW4
274         union
275         {
276             struct
277             {
278                 uint32_t   roi1XLeft        : MOS_BITFIELD_RANGE( 0, 15);
279                 uint32_t   roi1YTop         : MOS_BITFIELD_RANGE(16, 31);
280             };
281             struct
282             {
283                 uint32_t   value;
284             };
285         } DW4;
286 
287         // DW5
288         union
289         {
290             struct
291             {
292                 uint32_t   roi1XRight       : MOS_BITFIELD_RANGE( 0, 15);
293                 uint32_t   roi1YBottom      : MOS_BITFIELD_RANGE(16, 31);
294             };
295             struct
296             {
297                 uint32_t   value;
298             };
299         } DW5;
300 
301         // DW6
302         union
303         {
304             struct
305             {
306                 uint32_t   roi1Weight       : MOS_BITFIELD_RANGE (0, 15);
307                 uint32_t   roi1Offset       : MOS_BITFIELD_RANGE(16, 31);
308             };
309             struct
310             {
311                 uint32_t   value;
312             };
313         } DW6;
314 
315         // DW7
316         union
317         {
318             struct
319             {
320                 uint32_t   roi2XLeft        : MOS_BITFIELD_RANGE (0, 15);
321                 uint32_t   roi2YTop         : MOS_BITFIELD_RANGE(16, 31);
322             };
323             struct
324             {
325                 uint32_t   value;
326             };
327         } DW7;
328 
329         // DW8
330         union
331         {
332             struct
333             {
334                 uint32_t   roi2XRight       : MOS_BITFIELD_RANGE (0, 15);
335                 uint32_t   roi2YBottom      : MOS_BITFIELD_RANGE(16, 31);
336             };
337             struct
338             {
339                 uint32_t   value;
340             };
341         } DW8;
342 
343         // DW9
344         union
345         {
346             struct
347             {
348                 uint32_t   roi2Weight       : MOS_BITFIELD_RANGE (0, 15);
349                 uint32_t   roi2Offset       : MOS_BITFIELD_RANGE(16, 31);
350             };
351             struct
352             {
353                 uint32_t   value;
354             };
355         } DW9;
356 
357         // DW10
358         union
359         {
360             struct
361             {
362                 uint32_t   roi3XLeft        : MOS_BITFIELD_RANGE (0, 15);
363                 uint32_t   roi3YTop         : MOS_BITFIELD_RANGE(16, 31);
364             };
365             struct
366             {
367                 uint32_t   value;
368             };
369         } DW10;
370 
371         // DW11
372         union
373         {
374             struct
375             {
376                 uint32_t   roi3XRight       : MOS_BITFIELD_RANGE (0, 15);
377                 uint32_t   roi3YBottom      : MOS_BITFIELD_RANGE(16, 31);
378             };
379             struct
380             {
381                 uint32_t   value;
382             };
383         } DW11;
384 
385         // DW12
386         union
387         {
388             struct
389             {
390                 uint32_t   roi3Weight       : MOS_BITFIELD_RANGE (0, 15);
391                 uint32_t   roi3Offset       : MOS_BITFIELD_RANGE(16, 31);
392             };
393             struct
394             {
395                 uint32_t   value;
396             };
397         } DW12;
398 
399         // DW13
400         union
401         {
402             struct
403             {
404                 uint32_t   roi4XLeft        : MOS_BITFIELD_RANGE (0, 15);
405                 uint32_t   roi4YTop         : MOS_BITFIELD_RANGE(16, 31);
406             };
407             struct
408             {
409                 uint32_t   value;
410             };
411         } DW13;
412 
413         // DW14
414         union
415         {
416             struct
417             {
418                 uint32_t   roi4XRight       : MOS_BITFIELD_RANGE( 0, 15);
419                 uint32_t   roi4YBottom      : MOS_BITFIELD_RANGE(16, 31);
420             };
421             struct
422             {
423                 uint32_t   value;
424             };
425         } DW14;
426 
427         // DW15
428         union
429         {
430             struct
431             {
432                 uint32_t   roi4Weight       : MOS_BITFIELD_RANGE( 0, 15);
433                 uint32_t   roi4Offset       : MOS_BITFIELD_RANGE(16, 31);
434             };
435             struct
436             {
437                 uint32_t   value;
438             };
439         } DW15;
440 
441         // DW16
442         union
443         {
444             struct
445             {
446                 uint32_t   roi5XLeft        : MOS_BITFIELD_RANGE( 0, 15);
447                 uint32_t   roi5YTop         : MOS_BITFIELD_RANGE(16, 31);
448             };
449             struct
450             {
451                 uint32_t   value;
452             };
453         } DW16;
454 
455         // DW17
456         union
457         {
458             struct
459             {
460                 uint32_t   roi5XRight       : MOS_BITFIELD_RANGE( 0, 15);
461                 uint32_t   roi5YBottom      : MOS_BITFIELD_RANGE(16, 31);
462             };
463             struct
464             {
465                 uint32_t   value;
466             };
467         } DW17;
468 
469         // DW18
470         union
471         {
472             struct
473             {
474                 uint32_t   roi5Weight       : MOS_BITFIELD_RANGE( 0, 15);
475                 uint32_t   roi5Offset       : MOS_BITFIELD_RANGE(16, 31);
476             };
477             struct
478             {
479                 uint32_t   value;
480             };
481         } DW18;
482 
483         // DW19
484         union
485         {
486             struct
487             {
488                 uint32_t   roi6XLeft        : MOS_BITFIELD_RANGE( 0, 15);
489                 uint32_t   roi6YTop         : MOS_BITFIELD_RANGE(16, 31);
490             };
491             struct
492             {
493                 uint32_t   value;
494             };
495         } DW19;
496 
497         // DW20
498         union
499         {
500             struct
501             {
502                 uint32_t   roi6XRight       : MOS_BITFIELD_RANGE( 0, 15);
503                 uint32_t   roi6YBottom      : MOS_BITFIELD_RANGE(16, 31);
504             };
505             struct
506             {
507                 uint32_t   value;
508             };
509         } DW20;
510 
511         // DW21
512         union
513         {
514             struct
515             {
516                 uint32_t   roi6Weight       : MOS_BITFIELD_RANGE( 0, 15);
517                 uint32_t   roi6Offset       : MOS_BITFIELD_RANGE(16, 31);
518             };
519             struct
520             {
521                 uint32_t   value;
522             };
523         } DW21;
524 
525         // DW22
526         union
527         {
528             struct
529             {
530                 uint32_t   roi7XLeft        : MOS_BITFIELD_RANGE( 0, 15);
531                 uint32_t   roi7YTop         : MOS_BITFIELD_RANGE(16, 31);
532             };
533             struct
534             {
535                 uint32_t   value;
536             };
537         } DW22;
538 
539         // DW23
540         union
541         {
542             struct
543             {
544                 uint32_t   roi7XRight       : MOS_BITFIELD_RANGE( 0, 15);
545                 uint32_t   roi7YBottom      : MOS_BITFIELD_RANGE(16, 31);
546             };
547             struct
548             {
549                 uint32_t   value;
550             };
551         } DW23;
552 
553         // DW24
554         union
555         {
556             struct
557             {
558                 uint32_t   roi7Weight       : MOS_BITFIELD_RANGE( 0, 15);
559                 uint32_t   roi7Offset       : MOS_BITFIELD_RANGE(16, 31);
560             };
561             struct
562             {
563                 uint32_t   value;
564             };
565         } DW24;
566 
567         // DW25
568         union
569         {
570             struct
571             {
572                 uint32_t   roi8XLeft        : MOS_BITFIELD_RANGE( 0, 15);
573                 uint32_t   roi8YTop         : MOS_BITFIELD_RANGE(16, 31);
574             };
575             struct
576             {
577                 uint32_t   value;
578             };
579         } DW25;
580 
581         // DW26
582         union
583         {
584             struct
585             {
586                 uint32_t   roi8XRight       : MOS_BITFIELD_RANGE( 0, 15);
587                 uint32_t   roi8YBottom      : MOS_BITFIELD_RANGE(16, 31);
588             };
589             struct
590             {
591                 uint32_t   value;
592             };
593         } DW26;
594 
595         // DW27
596         union
597         {
598             struct
599             {
600                 uint32_t   roi8Weight       : MOS_BITFIELD_RANGE( 0, 15);
601                 uint32_t   roi8Offset       : MOS_BITFIELD_RANGE(16, 31);
602             };
603             struct
604             {
605                 uint32_t   value;
606             };
607         } DW27;
608 
609         // DW28
610         union
611         {
612             struct
613             {
614                 uint32_t   roi9XLeft        : MOS_BITFIELD_RANGE( 0, 15);
615                 uint32_t   roi9YTop         : MOS_BITFIELD_RANGE(16, 31);
616             };
617             struct
618             {
619                 uint32_t   value;
620             };
621         } DW28;
622 
623         // DW29
624         union
625         {
626             struct
627             {
628                 uint32_t   roi9XRight       : MOS_BITFIELD_RANGE( 0, 15);
629                 uint32_t   roi9YBottom      : MOS_BITFIELD_RANGE(16, 31);
630             };
631             struct
632             {
633                 uint32_t   value;
634             };
635         } DW29;
636 
637         // DW30
638         union
639         {
640             struct
641             {
642                 uint32_t   roi9Weight       : MOS_BITFIELD_RANGE( 0, 15);
643                 uint32_t   roi9Offset       : MOS_BITFIELD_RANGE(16, 31);
644             };
645             struct
646             {
647                 uint32_t   value;
648             };
649         } DW30;
650 
651         // DW31
652         union
653         {
654             struct
655             {
656                 uint32_t   roi10XLeft       : MOS_BITFIELD_RANGE( 0, 15);
657                 uint32_t   roi10YTop        : MOS_BITFIELD_RANGE(16, 31);
658             };
659             struct
660             {
661                 uint32_t   value;
662             };
663         } DW31;
664 
665         // DW32
666         union
667         {
668             struct
669             {
670                 uint32_t   roi10XRight      : MOS_BITFIELD_RANGE( 0, 15);
671                 uint32_t   roi10YBottom     : MOS_BITFIELD_RANGE(16, 31);
672             };
673             struct
674             {
675                 uint32_t   value;
676             };
677         } DW32;
678 
679         // DW33
680         union
681         {
682             struct
683             {
684                 uint32_t   roi10Weight      : MOS_BITFIELD_RANGE( 0, 15);
685                 uint32_t   roi10Offset      : MOS_BITFIELD_RANGE(16, 31);
686             };
687             struct
688             {
689                 uint32_t   value;
690             };
691         } DW33;
692 
693         // DW34
694         union
695         {
696             struct
697             {
698                 uint32_t   roi11XLeft       : MOS_BITFIELD_RANGE( 0, 15);
699                 uint32_t   roi11YTop        : MOS_BITFIELD_RANGE(16, 31);
700             };
701             struct
702             {
703                 uint32_t   value;
704             };
705         } DW34;
706 
707         // DW35
708         union
709         {
710             struct
711             {
712                 uint32_t   roi11XRight      : MOS_BITFIELD_RANGE( 0, 15);
713                 uint32_t   roi11YBottom     : MOS_BITFIELD_RANGE(16, 31);
714             };
715             struct
716             {
717                 uint32_t   value;
718             };
719         } DW35;
720 
721         // DW36
722         union
723         {
724             struct
725             {
726                 uint32_t   roi11Weight      : MOS_BITFIELD_RANGE( 0, 15);
727                 uint32_t   roi11Offset      : MOS_BITFIELD_RANGE(16, 31);
728             };
729             struct
730             {
731                 uint32_t   value;
732             };
733         } DW36;
734 
735         // DW37
736         union
737         {
738             struct
739             {
740                 uint32_t   roi12XLeft      : MOS_BITFIELD_RANGE( 0, 15);
741                 uint32_t   roi12YTop       : MOS_BITFIELD_RANGE(16, 31);
742             };
743             struct
744             {
745                 uint32_t   value;
746             };
747         } DW37;
748 
749         // DW38
750         union
751         {
752             struct
753             {
754                 uint32_t   roi12XRight     : MOS_BITFIELD_RANGE( 0, 15);
755                 uint32_t   roi12YBottom    : MOS_BITFIELD_RANGE(16, 31);
756             };
757             struct
758             {
759                 uint32_t   value;
760             };
761         } DW38;
762 
763         // DW39
764         union
765         {
766             struct
767             {
768                 uint32_t   roi12Weight     : MOS_BITFIELD_RANGE( 0, 15);
769                 uint32_t   roi12Offset     : MOS_BITFIELD_RANGE(16, 31);
770             };
771             struct
772             {
773                 uint32_t   value;
774             };
775         } DW39;
776 
777         // DW40
778         union
779         {
780             struct
781             {
782                 uint32_t   roi13XLeft      : MOS_BITFIELD_RANGE( 0, 15);
783                 uint32_t   roi13YTop       : MOS_BITFIELD_RANGE(16, 31);
784             };
785             struct
786             {
787                 uint32_t   value;
788             };
789         } DW40;
790 
791         // DW41
792         union
793         {
794             struct
795             {
796                 uint32_t   roi13XRight     : MOS_BITFIELD_RANGE( 0, 15);
797                 uint32_t   roi13YBottom    : MOS_BITFIELD_RANGE(16, 31);
798             };
799             struct
800             {
801                 uint32_t   value;
802             };
803         } DW41;
804 
805         // DW42
806         union
807         {
808             struct
809             {
810                 uint32_t   roi13Weight    : MOS_BITFIELD_RANGE( 0, 15);
811                 uint32_t   roi13Offset    : MOS_BITFIELD_RANGE(16, 31);
812             };
813             struct
814             {
815                 uint32_t   value;
816             };
817         } DW42;
818 
819         // DW43
820         union
821         {
822             struct
823             {
824                 uint32_t   roi14XLeft     : MOS_BITFIELD_RANGE( 0, 15);
825                 uint32_t   roi14YTop      : MOS_BITFIELD_RANGE(16, 31);
826             };
827             struct
828             {
829                 uint32_t   value;
830             };
831         } DW43;
832 
833         // DW44
834         union
835         {
836             struct
837             {
838                 uint32_t   roi14XRight    : MOS_BITFIELD_RANGE( 0, 15);
839                 uint32_t   roi14YBottom   : MOS_BITFIELD_RANGE(16, 31);
840             };
841             struct
842             {
843                 uint32_t   value;
844             };
845         } DW44;
846 
847         // DW45
848         union
849         {
850             struct
851             {
852                 uint32_t   roi14Weight    : MOS_BITFIELD_RANGE( 0, 15);
853                 uint32_t   roi14Offset    : MOS_BITFIELD_RANGE(16, 31);
854             };
855             struct
856             {
857                 uint32_t   value;
858             };
859         } DW45;
860 
861         // DW46
862         union
863         {
864             struct
865             {
866                 uint32_t   roi15XLeft     : MOS_BITFIELD_RANGE( 0, 15);
867                 uint32_t   roi15YTop      : MOS_BITFIELD_RANGE(16, 31);
868             };
869             struct
870             {
871                 uint32_t   value;
872             };
873         } DW46;
874 
875         // DW47
876         union
877         {
878             struct
879             {
880                 uint32_t   roi15XRight    : MOS_BITFIELD_RANGE( 0, 15);
881                 uint32_t   roi15YBottom   : MOS_BITFIELD_RANGE(16, 31);
882             };
883             struct
884             {
885                 uint32_t   value;
886             };
887         } DW47;
888 
889         // DW48
890         union
891         {
892             struct
893             {
894                 uint32_t   roi15Weight    : MOS_BITFIELD_RANGE( 0, 15);
895                 uint32_t   roi15Offset    : MOS_BITFIELD_RANGE(16, 31);
896             };
897             struct
898             {
899                 uint32_t   value;
900             };
901         } DW48;
902 
903         // DW49
904         union
905         {
906             struct
907             {
908                 uint32_t   inputSurface   : MOS_BITFIELD_RANGE( 0, 31);
909             };
910             struct
911             {
912                 uint32_t   value;
913             };
914         } DW49;
915 
916         // DW50
917         union
918         {
919             struct
920             {
921                 uint32_t   outputSurface  : MOS_BITFIELD_RANGE( 0, 31);
922             };
923             struct
924             {
925                 uint32_t   value;
926             };
927         } DW50;
928     };
929     C_ASSERT(MOS_BYTES_TO_DWORDS(sizeof(CurbeData)) == 51);
930 
931     //!
932     //! \brief    Constructor
933     //!
934     CodechalEncodeWP(CodechalEncoderState* encoder);
935 
936     CodechalEncoderState*       m_encoder = nullptr;                         //!< Pointer to ENCODER base class
937     MOS_INTERFACE               *m_osInterface = nullptr;                    //!< OS interface
938     CodechalHwInterface         *m_hwInterface = nullptr;                    //!< HW interface
939     CodechalDebugInterface      *m_debugInterface = nullptr;                 //!< Debug interface
940     MhwMiInterface              *m_miInterface = nullptr;                    //!< Common Mi Interface
941     MhwRenderInterface          *m_renderInterface = nullptr;                //!< Render engine interface
942     XMHW_STATE_HEAP_INTERFACE   *m_stateHeapInterface = nullptr;             //!< State heap class interface
943     MHW_KERNEL_STATE            *m_kernelState = nullptr;                    //!< WP kernel state
944 
945     uint32_t                    m_curbeLength = 0;                           //!< WP kernel Curbe length
946     uint32_t                    m_kernelUID = 0;                             //!< WP kernel UID
947     uint32_t                    m_combinedKernelSize = 0;                    //!< Combined kernel size
948     uint8_t                     *m_kernelBase = nullptr;                     //!< kernel binary base address
949     CurbeParams                 m_curbeParams = {};                          //!< Curbe parameters
950     SurfaceParams               m_surfaceParams = {};                        //!< Surface parameters
951 
952     //!
953     //! Reference to data members in Encoder class
954     //!
955     bool&                       m_useHwScoreboard;
956     bool&                       m_renderContextUsesNullHw;
957     bool&                       m_groupIdSelectSupported;
958     bool&                       m_singleTaskPhaseSupported;
959     bool&                       m_firstTaskInPhase;
960     bool&                       m_lastTaskInPhase;
961     bool&                       m_hwWalker;
962     uint8_t&                    m_groupId;
963     uint16_t&                   m_pictureCodingType;
964     uint32_t&                   m_mode;
965     uint32_t&                   m_verticalLineStride;
966     uint32_t&                   m_maxBtCount;
967     uint32_t&                   m_vmeStatesSize;
968     uint32_t&                   m_storeData;
969     uint32_t&                   m_frameWidth;
970     uint32_t&                   m_frameHeight;
971     uint32_t&                   m_frameFieldHeight;
972     CODEC_PICTURE&              m_currOriginalPic;
973     MHW_WALKER_MODE&            m_walkerMode;
974 
975 protected:
976     //!
977     //! \brief    Allocate weighted prediction surface
978     //!
979     //! \return   MOS_STATUS
980     //!           MOS_STATUS_SUCCESS if success, else fail reason
981     //!
982     MOS_STATUS AllocateResources();
983 
984     //!
985     //! \brief    Release weighted prediction surface
986     //!
987     //! \return   MOS_STATUS
988     //!           MOS_STATUS_SUCCESS if success, else fail reason
989     //!
990     void ReleaseResources();
991 
992     //!
993     //! \brief    Setup Curbe for weighted prediction kernel
994     //!
995     //! \return   MOS_STATUS
996     //!           MOS_STATUS_SUCCESS if success, else fail reason
997     //!
998     MOS_STATUS SetCurbe();
999 
1000     //!
1001     //! \brief    Send surface for weighted prediction kernel
1002     //!
1003     //! \return   MOS_STATUS
1004     //!           MOS_STATUS_SUCCESS if success, else fail reason
1005     //!
1006     MOS_STATUS SendSurface(PMOS_COMMAND_BUFFER cmdBuffer);
1007 };
1008 
1009 #endif  // __CODECHAL_ENCODE_WP_H__
1010