1 /*
2 * Copyright (c) 2021, 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 //!
24 //! \file     decode_vp9_buffer_update.cpp
25 //! \brief    Defines the interface for vp9 buffer update
26 //! \details  Defines the interface to handle the vp9 buffer update for
27 //!           segment id buffer and probability buffer.
28 //!
29 #include "decode_vp9_buffer_update.h"
30 #include "decode_basic_feature.h"
31 #include "decode_vp9_pipeline.h"
32 #include "decode_resource_auto_lock.h"
33 #include "decode_huc_packet_creator_base.h"
34 #include "mos_os_cp_interface_specific.h"
35 
36 namespace decode
37 {
DecodeVp9BufferUpdate(Vp9Pipeline * pipeline,MediaTask * task,uint8_t numVdbox)38 DecodeVp9BufferUpdate::DecodeVp9BufferUpdate(Vp9Pipeline *pipeline, MediaTask *task, uint8_t numVdbox)
39     : DecodeSubPipeline(pipeline, task, numVdbox)
40 {
41 }
42 
~DecodeVp9BufferUpdate()43 DecodeVp9BufferUpdate::~DecodeVp9BufferUpdate()
44 {
45     if (m_allocator != nullptr)
46     {
47         m_allocator->Destroy(m_segmentInitBuffer);
48     }
49 }
50 
Init(CodechalSetting & settings)51 MOS_STATUS DecodeVp9BufferUpdate::Init(CodechalSetting &settings)
52 {
53     DECODE_CHK_NULL(m_pipeline);
54 
55     CodechalHwInterfaceNext *hwInterface = m_pipeline->GetHwInterface();
56     DECODE_CHK_NULL(hwInterface);
57     PMOS_INTERFACE osInterface = hwInterface->GetOsInterface();
58     DECODE_CHK_NULL(osInterface);
59     InitScalabilityPars(osInterface);
60 
61     m_allocator     = m_pipeline->GetDecodeAllocator();
62     DECODE_CHK_NULL(m_allocator);
63 
64     MediaFeatureManager *featureManager = m_pipeline->GetFeatureManager();
65     DECODE_CHK_NULL(featureManager);
66     m_basicFeature = dynamic_cast<Vp9BasicFeature *>(featureManager->GetFeature(FeatureIDs::basicFeature));
67     DECODE_CHK_NULL(m_basicFeature);
68 
69     HucPacketCreatorBase *hucPktCreator = dynamic_cast<HucPacketCreatorBase *>(m_pipeline);
70     DECODE_CHK_NULL(hucPktCreator);
71     m_sgementbufferResetPkt = hucPktCreator->CreateHucCopyPkt(m_pipeline, m_task, hwInterface);
72     DECODE_CHK_NULL(m_sgementbufferResetPkt);
73     MediaPacket *packet     = dynamic_cast<MediaPacket *>(m_sgementbufferResetPkt);
74     DECODE_CHK_NULL(packet);
75     DECODE_CHK_STATUS(RegisterPacket(DecodePacketId(m_pipeline, hucCopyPacketId), *packet));
76     DECODE_CHK_STATUS(packet->Init());
77 
78     HucPacketCreatorBase *probUpdateCreator = dynamic_cast<HucPacketCreatorBase *>(m_pipeline);
79     DECODE_CHK_NULL(probUpdateCreator);
80     auto probUpdatePkt = probUpdateCreator->CreateProbUpdatePkt(m_pipeline, m_task, hwInterface);
81     DECODE_CHK_NULL(probUpdatePkt);
82     DECODE_CHK_STATUS(RegisterPacket(DecodePacketId(this, HucVp9ProbUpdatePktId), *probUpdatePkt));
83     DECODE_CHK_STATUS(probUpdatePkt->Init());
84 
85     return MOS_STATUS_SUCCESS;
86 }
87 
Prepare(DecodePipelineParams & params)88 MOS_STATUS DecodeVp9BufferUpdate::Prepare(DecodePipelineParams &params)
89 {
90     if (m_pipeline->IsFirstProcessPipe(params))
91     {
92         DECODE_CHK_STATUS(Begin());
93 
94         if (m_basicFeature->m_resetSegIdBuffer)
95         {
96             DECODE_CHK_NULL(m_basicFeature->m_resVp9SegmentIdBuffer);
97             uint32_t allocSize = m_basicFeature->m_resVp9SegmentIdBuffer->size;
98             DECODE_CHK_STATUS(AllocateSegmentInitBuffer(allocSize));
99 
100             HucCopyPktItf::HucCopyParams copyParams;
101             copyParams.srcBuffer  = &m_segmentInitBuffer->OsResource;
102             copyParams.srcOffset  = 0;
103             copyParams.destBuffer = &(m_basicFeature->m_resVp9SegmentIdBuffer->OsResource);
104             copyParams.destOffset = 0;
105             copyParams.copyLength = allocSize;
106             m_sgementbufferResetPkt->PushCopyParams(copyParams);
107 
108             DECODE_CHK_STATUS(ActivatePacket(DecodePacketId(m_pipeline, hucCopyPacketId), true, 0, 0));
109         }
110 
111         if (m_basicFeature->m_osInterface->osCpInterface->IsHMEnabled())
112         {
113             DECODE_CHK_STATUS(ActivatePacket(DecodePacketId(this, HucVp9ProbUpdatePktId), true, 0, 0));
114         }
115         else
116         {
117             if (m_basicFeature->m_fullProbBufferUpdate)
118             {
119                 DECODE_CHK_STATUS(ProbBufFullUpdatewithDrv());
120             }
121             else
122             {
123                 DECODE_CHK_STATUS(ProbBufferPartialUpdatewithDrv());
124             }
125         }
126     }
127     return MOS_STATUS_SUCCESS;
128 }
129 
ProbBufFullUpdatewithDrv()130 MOS_STATUS DecodeVp9BufferUpdate ::ProbBufFullUpdatewithDrv()
131 {
132     MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
133 
134     DECODE_FUNC_CALL();
135 
136     ResourceAutoLock resLock(m_allocator, &(m_basicFeature->m_resVp9ProbBuffer[m_basicFeature->m_frameCtxIdx]->OsResource));
137     auto             data = (uint8_t *)resLock.LockResourceForWrite();
138     DECODE_CHK_NULL(data);
139 
140     DECODE_CHK_STATUS(ContextBufferInit(
141         data, (m_basicFeature->m_probUpdateFlags.bResetKeyDefault ? true : false)));
142     DECODE_CHK_STATUS(MOS_SecureMemcpy(
143         (data + CODEC_VP9_SEG_PROB_OFFSET),
144         7,
145         m_basicFeature->m_probUpdateFlags.SegTreeProbs,
146         7));
147     DECODE_CHK_STATUS(MOS_SecureMemcpy(
148         (data + CODEC_VP9_SEG_PROB_OFFSET + 7),
149         3,
150         m_basicFeature->m_probUpdateFlags.SegPredProbs,
151         3));
152 
153     return eStatus;
154 }
155 
ProbBufferPartialUpdatewithDrv()156 MOS_STATUS DecodeVp9BufferUpdate ::ProbBufferPartialUpdatewithDrv()
157 {
158     MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
159 
160     DECODE_FUNC_CALL();
161 
162     if (m_basicFeature->m_probUpdateFlags.bSegProbCopy ||
163         m_basicFeature->m_probUpdateFlags.bProbSave ||
164         m_basicFeature->m_probUpdateFlags.bProbReset ||
165         m_basicFeature->m_probUpdateFlags.bProbRestore)
166     {
167         ResourceAutoLock resLock(m_allocator, &(m_basicFeature->m_resVp9ProbBuffer[m_basicFeature->m_frameCtxIdx]->OsResource));
168         auto             data = (uint8_t *)resLock.LockResourceForWrite();
169 
170         DECODE_CHK_NULL(data);
171 
172         if (m_basicFeature->m_probUpdateFlags.bSegProbCopy)
173         {
174             DECODE_CHK_STATUS(MOS_SecureMemcpy(
175                 (data + CODEC_VP9_SEG_PROB_OFFSET),
176                 7,
177                 m_basicFeature->m_probUpdateFlags.SegTreeProbs,
178                 7));
179             DECODE_CHK_STATUS(MOS_SecureMemcpy(
180                 (data + CODEC_VP9_SEG_PROB_OFFSET + 7),
181                 3,
182                 m_basicFeature->m_probUpdateFlags.SegPredProbs,
183                 3));
184         }
185 
186         if (m_basicFeature->m_probUpdateFlags.bProbSave)
187         {
188             DECODE_CHK_STATUS(MOS_SecureMemcpy(
189                 m_basicFeature->m_interProbSaved,
190                 CODECHAL_VP9_INTER_PROB_SIZE,
191                 data + CODEC_VP9_INTER_PROB_OFFSET,
192                 CODECHAL_VP9_INTER_PROB_SIZE));
193         }
194 
195         if (m_basicFeature->m_probUpdateFlags.bProbReset)
196         {
197             if (m_basicFeature->m_probUpdateFlags.bResetFull)
198             {
199                 DECODE_CHK_STATUS(ContextBufferInit(
200                     data, (m_basicFeature->m_probUpdateFlags.bResetKeyDefault ? true : false)));
201             }
202             else
203             {
204                 DECODE_CHK_STATUS(CtxBufDiffInit(
205                     data, (m_basicFeature->m_probUpdateFlags.bResetKeyDefault ? true : false)));
206             }
207         }
208 
209         if (m_basicFeature->m_probUpdateFlags.bProbRestore)
210         {
211             DECODE_CHK_STATUS(MOS_SecureMemcpy(
212                 data + CODEC_VP9_INTER_PROB_OFFSET,
213                 CODECHAL_VP9_INTER_PROB_SIZE,
214                 m_basicFeature->m_interProbSaved,
215                 CODECHAL_VP9_INTER_PROB_SIZE));
216         }
217     }
218 
219     return eStatus;
220 }
221 
ContextBufferInit(uint8_t * ctxBuffer,bool setToKey)222 MOS_STATUS DecodeVp9BufferUpdate::ContextBufferInit(
223     uint8_t *ctxBuffer,
224     bool     setToKey)
225 {
226     MOS_ZeroMemory(ctxBuffer, CODEC_VP9_SEG_PROB_OFFSET);
227 
228     int32_t  i, j;
229     uint32_t byteCnt = 0;
230     //TX probs
231     for (i = 0; i < CODEC_VP9_TX_SIZE_CONTEXTS; i++)
232     {
233         for (j = 0; j < CODEC_VP9_TX_SIZES - 3; j++)
234         {
235             ctxBuffer[byteCnt++] = DefaultTxProbs.p8x8[i][j];
236         }
237     }
238     for (i = 0; i < CODEC_VP9_TX_SIZE_CONTEXTS; i++)
239     {
240         for (j = 0; j < CODEC_VP9_TX_SIZES - 2; j++)
241         {
242             ctxBuffer[byteCnt++] = DefaultTxProbs.p16x16[i][j];
243         }
244     }
245     for (i = 0; i < CODEC_VP9_TX_SIZE_CONTEXTS; i++)
246     {
247         for (j = 0; j < CODEC_VP9_TX_SIZES - 1; j++)
248         {
249             ctxBuffer[byteCnt++] = DefaultTxProbs.p32x32[i][j];
250         }
251     }
252 
253     //52 bytes of zeros
254     byteCnt += 52;
255 
256     uint8_t blocktype          = 0;
257     uint8_t reftype            = 0;
258     uint8_t coeffbands         = 0;
259     uint8_t unConstrainedNodes = 0;
260     uint8_t prevCoefCtx        = 0;
261     //coeff probs
262     for (blocktype = 0; blocktype < CODEC_VP9_BLOCK_TYPES; blocktype++)
263     {
264         for (reftype = 0; reftype < CODEC_VP9_REF_TYPES; reftype++)
265         {
266             for (coeffbands = 0; coeffbands < CODEC_VP9_COEF_BANDS; coeffbands++)
267             {
268                 uint8_t numPrevCoeffCtxts = (coeffbands == 0) ? 3 : CODEC_VP9_PREV_COEF_CONTEXTS;
269                 for (prevCoefCtx = 0; prevCoefCtx < numPrevCoeffCtxts; prevCoefCtx++)
270                 {
271                     for (unConstrainedNodes = 0; unConstrainedNodes < CODEC_VP9_UNCONSTRAINED_NODES; unConstrainedNodes++)
272                     {
273                         ctxBuffer[byteCnt++] = DefaultCoefProbs4x4[blocktype][reftype][coeffbands][prevCoefCtx][unConstrainedNodes];
274                     }
275                 }
276             }
277         }
278     }
279 
280     for (blocktype = 0; blocktype < CODEC_VP9_BLOCK_TYPES; blocktype++)
281     {
282         for (reftype = 0; reftype < CODEC_VP9_REF_TYPES; reftype++)
283         {
284             for (coeffbands = 0; coeffbands < CODEC_VP9_COEF_BANDS; coeffbands++)
285             {
286                 uint8_t numPrevCoeffCtxts = (coeffbands == 0) ? 3 : CODEC_VP9_PREV_COEF_CONTEXTS;
287                 for (prevCoefCtx = 0; prevCoefCtx < numPrevCoeffCtxts; prevCoefCtx++)
288                 {
289                     for (unConstrainedNodes = 0; unConstrainedNodes < CODEC_VP9_UNCONSTRAINED_NODES; unConstrainedNodes++)
290                     {
291                         ctxBuffer[byteCnt++] = DefaultCoefPprobs8x8[blocktype][reftype][coeffbands][prevCoefCtx][unConstrainedNodes];
292                     }
293                 }
294             }
295         }
296     }
297 
298     for (blocktype = 0; blocktype < CODEC_VP9_BLOCK_TYPES; blocktype++)
299     {
300         for (reftype = 0; reftype < CODEC_VP9_REF_TYPES; reftype++)
301         {
302             for (coeffbands = 0; coeffbands < CODEC_VP9_COEF_BANDS; coeffbands++)
303             {
304                 uint8_t numPrevCoeffCtxts = (coeffbands == 0) ? 3 : CODEC_VP9_PREV_COEF_CONTEXTS;
305                 for (prevCoefCtx = 0; prevCoefCtx < numPrevCoeffCtxts; prevCoefCtx++)
306                 {
307                     for (unConstrainedNodes = 0; unConstrainedNodes < CODEC_VP9_UNCONSTRAINED_NODES; unConstrainedNodes++)
308                     {
309                         ctxBuffer[byteCnt++] = DefaultCoefProbs16x16[blocktype][reftype][coeffbands][prevCoefCtx][unConstrainedNodes];
310                     }
311                 }
312             }
313         }
314     }
315 
316     for (blocktype = 0; blocktype < CODEC_VP9_BLOCK_TYPES; blocktype++)
317     {
318         for (reftype = 0; reftype < CODEC_VP9_REF_TYPES; reftype++)
319         {
320             for (coeffbands = 0; coeffbands < CODEC_VP9_COEF_BANDS; coeffbands++)
321             {
322                 uint8_t numPrevCoeffCtxts = (coeffbands == 0) ? 3 : CODEC_VP9_PREV_COEF_CONTEXTS;
323                 for (prevCoefCtx = 0; prevCoefCtx < numPrevCoeffCtxts; prevCoefCtx++)
324                 {
325                     for (unConstrainedNodes = 0; unConstrainedNodes < CODEC_VP9_UNCONSTRAINED_NODES; unConstrainedNodes++)
326                     {
327                         ctxBuffer[byteCnt++] = DefaultCoefProbs32x32[blocktype][reftype][coeffbands][prevCoefCtx][unConstrainedNodes];
328                     }
329                 }
330             }
331         }
332     }
333 
334     //16 bytes of zeros
335     byteCnt += 16;
336 
337     // mb skip probs
338     for (i = 0; i < CODEC_VP9_MBSKIP_CONTEXTS; i++)
339     {
340         ctxBuffer[byteCnt++] = DefaultMbskipProbs[i];
341     }
342 
343     // populate prob values which are different between Key and Non-Key frame
344     CtxBufDiffInit(ctxBuffer, setToKey);
345 
346     //skip Seg tree/pred probs, updating not done in this function.
347     byteCnt = CODEC_VP9_SEG_PROB_OFFSET;
348     byteCnt += 7;
349     byteCnt += 3;
350 
351     //28 bytes of zeros
352     for (i = 0; i < 28; i++)
353     {
354         ctxBuffer[byteCnt++] = 0;
355     }
356 
357     //Just a check.
358     if (byteCnt > CODEC_VP9_PROB_MAX_NUM_ELEM)
359     {
360         CODECHAL_PUBLIC_ASSERTMESSAGE("Error: FrameContext array out-of-bounds, byteCnt = %d!\n", byteCnt);
361         return MOS_STATUS_NO_SPACE;
362     }
363     else
364     {
365         return MOS_STATUS_SUCCESS;
366     }
367 }
368 
CtxBufDiffInit(uint8_t * ctxBuffer,bool setToKey)369 MOS_STATUS DecodeVp9BufferUpdate::CtxBufDiffInit(
370     uint8_t *ctxBuffer,
371     bool     setToKey)
372 {
373     int32_t  i, j;
374     uint32_t byteCnt = CODEC_VP9_INTER_PROB_OFFSET;
375     //inter mode probs. have to be zeros for Key frame
376     for (i = 0; i < CODEC_VP9_INTER_MODE_CONTEXTS; i++)
377     {
378         for (j = 0; j < CODEC_VP9_INTER_MODES - 1; j++)
379         {
380             if (!setToKey)
381             {
382                 ctxBuffer[byteCnt++] = DefaultInterModeProbs[i][j];
383             }
384             else
385             {
386                 //zeros for key frame
387                 byteCnt++;
388             }
389         }
390     }
391     //switchable interprediction probs
392     for (i = 0; i < CODEC_VP9_SWITCHABLE_FILTERS + 1; i++)
393     {
394         for (j = 0; j < CODEC_VP9_SWITCHABLE_FILTERS - 1; j++)
395         {
396             if (!setToKey)
397             {
398                 ctxBuffer[byteCnt++] = DefaultSwitchableInterpProb[i][j];
399             }
400             else
401             {
402                 //zeros for key frame
403                 byteCnt++;
404             }
405         }
406     }
407     //intra inter probs
408     for (i = 0; i < CODEC_VP9_INTRA_INTER_CONTEXTS; i++)
409     {
410         if (!setToKey)
411         {
412             ctxBuffer[byteCnt++] = DefaultIntraInterProb[i];
413         }
414         else
415         {
416             //zeros for key frame
417             byteCnt++;
418         }
419     }
420     //comp inter probs
421     for (i = 0; i < CODEC_VP9_COMP_INTER_CONTEXTS; i++)
422     {
423         if (!setToKey)
424         {
425             ctxBuffer[byteCnt++] = DefaultCompInterProb[i];
426         }
427         else
428         {
429             //zeros for key frame
430             byteCnt++;
431         }
432     }
433     //single ref probs
434     for (i = 0; i < CODEC_VP9_REF_CONTEXTS; i++)
435     {
436         for (j = 0; j < 2; j++)
437         {
438             if (!setToKey)
439             {
440                 ctxBuffer[byteCnt++] = DefaultSingleRefProb[i][j];
441             }
442             else
443             {
444                 //zeros for key frame
445                 byteCnt++;
446             }
447         }
448     }
449     //comp ref probs
450     for (i = 0; i < CODEC_VP9_REF_CONTEXTS; i++)
451     {
452         if (!setToKey)
453         {
454             ctxBuffer[byteCnt++] = DefaultCompRefProb[i];
455         }
456         else
457         {
458             //zeros for key frame
459             byteCnt++;
460         }
461     }
462     //y mode probs
463     for (i = 0; i < CODEC_VP9_BLOCK_SIZE_GROUPS; i++)
464     {
465         for (j = 0; j < CODEC_VP9_INTRA_MODES - 1; j++)
466         {
467             if (!setToKey)
468             {
469                 ctxBuffer[byteCnt++] = DefaultIFYProb[i][j];
470             }
471             else
472             {
473                 //zeros for key frame, since HW will not use this buffer, but default right buffer.
474                 byteCnt++;
475             }
476         }
477     }
478     //partition probs, key & intra-only frames use key type, other inter frames use inter type
479     for (i = 0; i < CODECHAL_VP9_PARTITION_CONTEXTS; i++)
480     {
481         for (j = 0; j < CODEC_VP9_PARTITION_TYPES - 1; j++)
482         {
483             if (setToKey)
484             {
485                 ctxBuffer[byteCnt++] = DefaultKFPartitionProb[i][j];
486             }
487             else
488             {
489                 ctxBuffer[byteCnt++] = DefaultPartitionProb[i][j];
490             }
491         }
492     }
493     //nmvc joints
494     for (i = 0; i < (CODEC_VP9_MV_JOINTS - 1); i++)
495     {
496         if (!setToKey)
497         {
498             ctxBuffer[byteCnt++] = DefaultNmvContext.joints[i];
499         }
500         else
501         {
502             //zeros for key frame
503             byteCnt++;
504         }
505     }
506     //nmvc comps
507     for (i = 0; i < 2; i++)
508     {
509         if (!setToKey)
510         {
511             ctxBuffer[byteCnt++] = DefaultNmvContext.comps[i].sign;
512             for (j = 0; j < (CODEC_VP9_MV_CLASSES - 1); j++)
513             {
514                 ctxBuffer[byteCnt++] = DefaultNmvContext.comps[i].classes[j];
515             }
516             for (j = 0; j < (CODECHAL_VP9_CLASS0_SIZE - 1); j++)
517             {
518                 ctxBuffer[byteCnt++] = DefaultNmvContext.comps[i].class0[j];
519             }
520             for (j = 0; j < CODECHAL_VP9_MV_OFFSET_BITS; j++)
521             {
522                 ctxBuffer[byteCnt++] = DefaultNmvContext.comps[i].bits[j];
523             }
524         }
525         else
526         {
527             byteCnt += 1;
528             byteCnt += (CODEC_VP9_MV_CLASSES - 1);
529             byteCnt += (CODECHAL_VP9_CLASS0_SIZE - 1);
530             byteCnt += (CODECHAL_VP9_MV_OFFSET_BITS);
531         }
532     }
533     for (i = 0; i < 2; i++)
534     {
535         if (!setToKey)
536         {
537             for (j = 0; j < CODECHAL_VP9_CLASS0_SIZE; j++)
538             {
539                 for (int32_t k = 0; k < (CODEC_VP9_MV_FP_SIZE - 1); k++)
540                 {
541                     ctxBuffer[byteCnt++] = DefaultNmvContext.comps[i].class0_fp[j][k];
542                 }
543             }
544             for (j = 0; j < (CODEC_VP9_MV_FP_SIZE - 1); j++)
545             {
546                 ctxBuffer[byteCnt++] = DefaultNmvContext.comps[i].fp[j];
547             }
548         }
549         else
550         {
551             byteCnt += (CODECHAL_VP9_CLASS0_SIZE * (CODEC_VP9_MV_FP_SIZE - 1));
552             byteCnt += (CODEC_VP9_MV_FP_SIZE - 1);
553         }
554     }
555     for (i = 0; i < 2; i++)
556     {
557         if (!setToKey)
558         {
559             ctxBuffer[byteCnt++] = DefaultNmvContext.comps[i].class0_hp;
560             ctxBuffer[byteCnt++] = DefaultNmvContext.comps[i].hp;
561         }
562         else
563         {
564             byteCnt += 2;
565         }
566     }
567 
568     //47 bytes of zeros
569     byteCnt += 47;
570 
571     //uv mode probs
572     for (i = 0; i < CODEC_VP9_INTRA_MODES; i++)
573     {
574         for (j = 0; j < CODEC_VP9_INTRA_MODES - 1; j++)
575         {
576             if (setToKey)
577             {
578                 ctxBuffer[byteCnt++] = DefaultKFUVModeProb[i][j];
579             }
580             else
581             {
582                 ctxBuffer[byteCnt++] = DefaultIFUVProbs[i][j];
583             }
584         }
585     }
586 
587     return MOS_STATUS_SUCCESS;
588 }
589 
Begin()590 MOS_STATUS DecodeVp9BufferUpdate::Begin()
591 {
592     DECODE_CHK_STATUS(DecodeSubPipeline::Reset());
593 
594     return MOS_STATUS_SUCCESS;
595 }
596 
AllocateSegmentInitBuffer(uint32_t allocSize)597 MOS_STATUS DecodeVp9BufferUpdate::AllocateSegmentInitBuffer(uint32_t allocSize)
598 {
599     DECODE_CHK_NULL(m_allocator);
600 
601     if (m_segmentInitBuffer == nullptr)
602     {
603         m_segmentInitBuffer = m_allocator->AllocateBuffer(
604             allocSize, "Vp9SegmentIdInitBuffer", resourceInternalRead, lockableVideoMem, true, 0);
605         DECODE_CHK_NULL(m_segmentInitBuffer);
606         return MOS_STATUS_SUCCESS;
607     }
608 
609     if (allocSize > m_segmentInitBuffer->size)
610     {
611         DECODE_CHK_STATUS(m_allocator->Resize(m_segmentInitBuffer, allocSize, lockableVideoMem, true, 0));
612     }
613 
614     return MOS_STATUS_SUCCESS;
615 }
616 
GetMediaFunction()617 MediaFunction DecodeVp9BufferUpdate::GetMediaFunction()
618 {
619     return VdboxDecodeWaFunc;
620 }
621 
InitScalabilityPars(PMOS_INTERFACE osInterface)622 void DecodeVp9BufferUpdate::InitScalabilityPars(PMOS_INTERFACE osInterface)
623 {
624     m_decodeScalabilityPars.disableScalability = true;
625     m_decodeScalabilityPars.disableRealTile    = true;
626     m_decodeScalabilityPars.enableVE           = MOS_VE_SUPPORTED(osInterface);
627     m_decodeScalabilityPars.numVdbox           = m_numVdbox;
628 }
629 
630 }  // namespace decode
631