1 /*
2 * Copyright (c) 2020-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 //! \file     decode_vp9_basic_feature.cpp
24 //! \brief    Defines the common interface for decode vp9 parameter
25 //!
26 
27 #include "decode_vp9_basic_feature.h"
28 #include "decode_utils.h"
29 #include "decode_allocator.h"
30 #include "decode_resource_auto_lock.h"
31 #include "mos_os_cp_interface_specific.h"
32 
33 namespace decode
34 {
Vp9BasicFeature(DecodeAllocator * allocator,void * hwInterface,PMOS_INTERFACE osInterface)35 Vp9BasicFeature::Vp9BasicFeature(DecodeAllocator *allocator, void *hwInterface, PMOS_INTERFACE osInterface) : DecodeBasicFeature(allocator, hwInterface, osInterface)
36 {
37     if (hwInterface != nullptr)
38     {
39         m_osInterface  = osInterface;
40         m_hcpItf       = ((CodechalHwInterfaceNext*)hwInterface)->GetHcpInterfaceNext();
41     }
42 
43     for (uint8_t i = 0; i < CODEC_VP9_NUM_CONTEXTS; i++)
44     {
45         m_pendingResetFullTables[i] = 0;
46         m_pendingCopySegProbs[i]    = 0;
47     }
48 
49     MOS_ZeroMemory(&m_resVp9SegmentIdBuffer, sizeof(m_resVp9SegmentIdBuffer));
50     MOS_ZeroMemory(&m_resVp9MvTemporalBuffer, sizeof(m_resVp9MvTemporalBuffer));
51 
52     MOS_ZeroMemory(&m_interProbSaved, sizeof(m_interProbSaved));
53     MOS_ZeroMemory(&m_segTreeProbs, sizeof(m_segTreeProbs));
54     MOS_ZeroMemory(&m_segPredProbs, sizeof(m_segPredProbs));
55     MOS_ZeroMemory(&m_probUpdateFlags, sizeof(m_probUpdateFlags));
56 
57     MOS_ZeroMemory(&m_lastRefSurface, sizeof(m_lastRefSurface));
58     MOS_ZeroMemory(&m_goldenRefSurface, sizeof(m_goldenRefSurface));
59     MOS_ZeroMemory(&m_altRefSurface, sizeof(m_altRefSurface));
60     MOS_ZeroMemory(&m_resDataBuffer, sizeof(m_resDataBuffer));
61 
62     m_prevFrameParams.value = 0;
63 }
64 
~Vp9BasicFeature()65 Vp9BasicFeature::~Vp9BasicFeature()
66 {
67     if (m_allocator != nullptr)
68     {
69         for (uint8_t i = 0; i < CODEC_VP9_NUM_CONTEXTS + 1; i++)
70         {
71             if (!m_allocator->ResourceIsNull(&m_resVp9ProbBuffer[i]->OsResource))
72             {
73                 m_allocator->Destroy(m_resVp9ProbBuffer[i]);
74             }
75         }
76 
77         if (!m_allocator->ResourceIsNull(&m_resVp9SegmentIdBuffer->OsResource))
78         {
79             m_allocator->Destroy(m_resVp9SegmentIdBuffer);
80         }
81     }
82 }
83 
Init(void * setting)84 MOS_STATUS Vp9BasicFeature::Init(void *setting)
85 {
86     DECODE_FUNC_CALL();
87 
88     PERF_UTILITY_AUTO(__FUNCTION__, PERF_DECODE, PERF_LEVEL_HAL);
89 
90     DECODE_CHK_NULL(setting);
91 
92     DECODE_CHK_STATUS(DecodeBasicFeature::Init(setting));
93     CodechalSetting *codecSettings = (CodechalSetting *)setting;
94 
95     if (codecSettings->lumaChromaDepth & CODECHAL_LUMA_CHROMA_DEPTH_8_BITS)
96         m_vp9DepthIndicator = 0;
97     if (codecSettings->lumaChromaDepth & CODECHAL_LUMA_CHROMA_DEPTH_10_BITS)
98         m_vp9DepthIndicator = 1;
99     if (codecSettings->lumaChromaDepth & CODECHAL_LUMA_CHROMA_DEPTH_12_BITS)
100         m_vp9DepthIndicator = 2;
101 
102     DECODE_CHK_STATUS(m_refFrames.Init(this, *m_allocator));
103 
104     InitDefaultProbBufferTable();
105 
106     return MOS_STATUS_SUCCESS;
107 }
108 
DetermineInternalBufferUpdate()109 MOS_STATUS Vp9BasicFeature ::DetermineInternalBufferUpdate()
110 {
111     MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
112 
113     DECODE_FUNC_CALL();
114 
115     bool    keyFrame       = !m_vp9PicParams->PicFlags.fields.frame_type;
116     bool    intraOnly      = m_vp9PicParams->PicFlags.fields.intra_only;
117     uint8_t curFrameCtxIdx = (uint8_t)m_vp9PicParams->PicFlags.fields.frame_context_idx;
118     bool    isScaling      = ((m_vp9PicParams->FrameWidthMinus1 + 1) == m_prevFrmWidth) &&
119                              ((m_vp9PicParams->FrameHeightMinus1 + 1) == m_prevFrmHeight)
120                          ? false
121                          : true;
122     bool resetAll       = ((keyFrame ||
123                          m_vp9PicParams->PicFlags.fields.error_resilient_mode) ||
124                      (m_vp9PicParams->PicFlags.fields.reset_frame_context == 3 &&
125                          m_vp9PicParams->PicFlags.fields.intra_only));
126     bool resetSpecified = (m_vp9PicParams->PicFlags.fields.reset_frame_context == 2 &&
127                            m_vp9PicParams->PicFlags.fields.intra_only);
128 
129     bool copySegProbs      = false;  // indicating if current frame's prob buffer need to update seg tree/pred probs.
130     bool resetPartialTbl   = false;  // indicating if current frame need to do partial reset from offset 1667 to 2010.
131 
132     //propogate ProbUpdateFlags
133     MOS_ZeroMemory(&m_probUpdateFlags, sizeof(m_probUpdateFlags));
134 
135     m_resetSegIdBuffer = keyFrame ||
136                          isScaling ||
137                          m_vp9PicParams->PicFlags.fields.error_resilient_mode ||
138                          m_vp9PicParams->PicFlags.fields.intra_only;
139 
140     m_frameCtxIdx = curFrameCtxIdx;  //indicate which prob buffer need to be used by current frame decode
141     if (!m_vp9PicParams->PicFlags.fields.frame_type ||
142         m_vp9PicParams->PicFlags.fields.intra_only ||
143         m_vp9PicParams->PicFlags.fields.error_resilient_mode)
144     {
145         //always use frame context idx 0 in this case
146         m_frameCtxIdx = 0;
147     }
148 
149     //check if seg tree/pred probs need to be updated in prob buffer of current frame
150     //and also mark the flag bPendingResetSegProbs for other prob buffers
151 
152     if (m_vp9PicParams->PicFlags.fields.segmentation_enabled &&
153         m_vp9PicParams->PicFlags.fields.segmentation_update_map)
154     {
155         copySegProbs = true;
156         for (uint8_t ctxIdx = 0; ctxIdx < CODEC_VP9_NUM_CONTEXTS; ctxIdx++)
157         {
158             m_pendingCopySegProbs[ctxIdx] = true;
159         }
160         //set current frame's prob buffer pending copy to false
161         m_pendingCopySegProbs[m_frameCtxIdx] = false;
162 
163         MOS_SecureMemcpy(m_segTreeProbs, 7, m_vp9PicParams->SegTreeProbs, 7);
164         MOS_SecureMemcpy(m_segPredProbs, 3, m_vp9PicParams->SegPredProbs, 3);
165     }
166     else if (m_vp9PicParams->PicFlags.fields.segmentation_enabled &&
167              m_pendingCopySegProbs[m_frameCtxIdx])
168     {
169         copySegProbs                         = true;
170         m_pendingCopySegProbs[m_frameCtxIdx] = false;
171     }
172 
173     //check if probs in frame context table need to be updated for current frame's prob buffer
174     //and also mark the flag bPendingResetFullTables for other prob buffers
175     if (resetAll)
176     {
177         m_probUpdateFlags.bResetFull = true;
178         m_pendingResetPartial = (keyFrame || intraOnly);
179 
180         //prob buffer 0 will be used for current frame decoding
181         for (uint8_t ctxIdx = 1; ctxIdx < CODEC_VP9_NUM_CONTEXTS; ctxIdx++)
182         {
183             m_pendingResetFullTables[ctxIdx] = true;
184         }
185         m_saveInterProbs = false;
186     }
187     else if (resetSpecified)
188     {
189         //intra only frame:prob buffer 0 will always be used for current frame decoding
190         if (curFrameCtxIdx == 0)
191         {
192             //do prob table 0 reset
193             m_probUpdateFlags.bResetFull = true;
194             m_pendingResetPartial = true;
195             m_saveInterProbs      = false;
196         }
197         else
198         {
199             //not do reset right now, pending the reset full table of specified ctx until a later frame use it to do decode
200             m_pendingResetFullTables[curFrameCtxIdx] = true;
201             if (!m_pendingResetPartial)
202             {
203                 if (!m_saveInterProbs)
204                 {
205                     m_probUpdateFlags.bProbSave = true;
206                     m_saveInterProbs  = true;
207                 }
208                 resetPartialTbl = true;
209             }
210         }
211     }
212     else if (intraOnly)
213     {
214         //prob buffer 0 will be used for current frame decoding
215         if (!m_pendingResetPartial)
216         {
217             if (!m_saveInterProbs)
218             {
219                 m_probUpdateFlags.bProbSave = true;
220                 m_saveInterProbs  = true;
221             }
222             resetPartialTbl = true;
223         }
224     }
225     else if (m_pendingResetFullTables[curFrameCtxIdx])
226     {
227         //here curFrameCtxIdx != 0, frame is inter frame
228         m_probUpdateFlags.bResetFull             = true;
229         m_pendingResetFullTables[curFrameCtxIdx] = false;
230     }
231     else if (curFrameCtxIdx == 0 && m_pendingResetPartial)
232     {
233         //here curFrameCtxIdx = 0, frame is inter frame
234         resetPartialTbl       = true;
235         m_pendingResetPartial = false;
236     }
237     else if (curFrameCtxIdx == 0 && m_saveInterProbs)
238     {
239         //here curFrameCtxIdx = 0, frame is inter frame
240         m_probUpdateFlags.bProbRestore = true;
241         m_saveInterProbs  = false;
242     }
243 
244     //decide if prob buffer need to do a full udpate or partial upate
245     if (m_probUpdateFlags.bResetFull && copySegProbs)
246     {
247         //update the whole prob buffer
248         m_fullProbBufferUpdate = true;
249     }
250     else
251     {
252         //partial buffer update
253         m_fullProbBufferUpdate = false;
254     }
255 
256     if (copySegProbs)
257     {
258         m_probUpdateFlags.bSegProbCopy = true;
259         MOS_SecureMemcpy(m_probUpdateFlags.SegTreeProbs, 7, m_segTreeProbs, 7);
260         MOS_SecureMemcpy(m_probUpdateFlags.SegPredProbs, 3, m_segPredProbs, 3);
261     }
262     m_probUpdateFlags.bProbReset       = m_probUpdateFlags.bResetFull || resetPartialTbl;
263     m_probUpdateFlags.bResetKeyDefault = (keyFrame || intraOnly);
264 
265     return eStatus;
266 }
267 
AllocateSegmentBuffer()268 MOS_STATUS Vp9BasicFeature ::AllocateSegmentBuffer()
269 
270 {
271     uint32_t widthInSb   = MOS_ROUNDUP_DIVIDE(m_width, CODEC_VP9_SUPER_BLOCK_WIDTH);
272     uint32_t heightInSb  = MOS_ROUNDUP_DIVIDE(m_height, CODEC_VP9_SUPER_BLOCK_HEIGHT);
273     uint8_t  maxBitDepth = 8 + m_vp9DepthIndicator * 2;
274 
275     mhw::vdbox::hcp::HcpBufferSizePar hcpBufSizeParam;
276     MOS_ZeroMemory(&hcpBufSizeParam, sizeof(hcpBufSizeParam));
277     hcpBufSizeParam.ucMaxBitDepth = maxBitDepth;
278     hcpBufSizeParam.dwPicWidth    = widthInSb;
279     hcpBufSizeParam.dwPicHeight   = heightInSb;
280 
281     // m_chromaFormat was initialized in decode_basic_feature.cpp and got from codechal settings
282     hcpBufSizeParam.ucChromaFormat = m_chromaFormat;
283 
284     if (m_hcpItf->GetVp9BufferSize(mhw::vdbox::hcp::HCP_INTERNAL_BUFFER_TYPE::SEGMENT_ID, &hcpBufSizeParam) != MOS_STATUS_SUCCESS)
285     {
286         DECODE_ASSERTMESSAGE("Failed to get SegmentIdBuffer size.");
287     }
288 
289     if (m_resVp9SegmentIdBuffer == nullptr)
290     {
291         m_resVp9SegmentIdBuffer = m_allocator->AllocateBuffer(
292             hcpBufSizeParam.dwBufferSize, "Vp9SegmentIdBuffer", resourceInternalReadWriteCache, notLockableVideoMem);
293         DECODE_CHK_NULL(m_resVp9SegmentIdBuffer);
294     }
295     else
296     {
297         DECODE_CHK_STATUS(m_allocator->Resize(
298             m_resVp9SegmentIdBuffer, hcpBufSizeParam.dwBufferSize, notLockableVideoMem));
299     }
300 
301     DECODE_CHK_NULL(m_resVp9SegmentIdBuffer);
302     return MOS_STATUS_SUCCESS;
303 }
304 
Update(void * params)305 MOS_STATUS Vp9BasicFeature::Update(void *params)
306 {
307     DECODE_FUNC_CALL();
308 
309     PERF_UTILITY_AUTO(__FUNCTION__, PERF_DECODE, PERF_LEVEL_HAL);
310 
311     DECODE_CHK_NULL(params);
312     //DestSurface info dependency on m_vp9PicParams.
313     CodechalDecodeParams *decodeParams = (CodechalDecodeParams *)params;
314     m_vp9PicParams                     = static_cast<CODEC_VP9_PIC_PARAMS *>(decodeParams->m_picParams);
315     DECODE_CHK_NULL(m_vp9PicParams);
316 
317     DECODE_CHK_STATUS(DecodeBasicFeature::Update(params));
318 
319     m_pictureCodingType = m_vp9PicParams->PicFlags.fields.frame_type ? P_TYPE : I_TYPE;
320 
321     m_vp9SegmentParams = static_cast<CODEC_VP9_SEGMENT_PARAMS *>(decodeParams->m_iqMatrixBuffer);
322     DECODE_CHK_NULL(m_vp9SegmentParams);
323 
324     DECODE_CHK_STATUS(SetPictureStructs());
325 
326     m_vp9SliceParams = static_cast<CODEC_VP9_SLICE_PARAMS *>(decodeParams->m_sliceParams);
327 
328     // No BSBytesInBuffer is sent from App, driver here just give an estimation.
329     if (m_vp9SliceParams != nullptr && m_vp9SliceParams->wBadSliceChopping != 0)
330     {
331         m_vp9PicParams->BSBytesInBuffer =
332             (m_vp9PicParams->FrameWidthMinus1 + 1) * (m_vp9PicParams->FrameHeightMinus1 + 1) * 6;
333     }
334 
335     //update bitstream size  for this picture :m_datasize
336     DECODE_CHK_STATUS(SetRequiredBitstreamSize(m_vp9PicParams->BSBytesInBuffer));
337 
338     return MOS_STATUS_SUCCESS;
339 }
340 
SetRequiredBitstreamSize(uint32_t requiredSize)341 MOS_STATUS Vp9BasicFeature::SetRequiredBitstreamSize(uint32_t requiredSize)
342 {
343     DECODE_FUNC_CALL();
344 
345     if (requiredSize > m_dataSize)
346     {
347         m_dataOffset = 0;
348         m_dataSize   = MOS_ALIGN_CEIL(requiredSize, MHW_CACHELINE_SIZE);
349     }
350 
351     DECODE_NORMALMESSAGE("Estimate bitstream size in this Frame: %u", requiredSize);
352     return MOS_STATUS_SUCCESS;
353 }
354 
SetPictureStructs()355 MOS_STATUS Vp9BasicFeature::SetPictureStructs()
356 {
357     DECODE_FUNC_CALL();
358 
359     m_curRenderPic = m_vp9PicParams->CurrPic;
360     DECODE_CHK_COND(m_curRenderPic.FrameIdx >= CODECHAL_NUM_UNCOMPRESSED_SURFACE_VP9,
361         "currPic.FrameIdx is out of range!");
362 
363     m_width  = (uint32_t)m_vp9PicParams->FrameWidthMinus1 + 1;
364     m_height = (uint32_t)m_vp9PicParams->FrameHeightMinus1 + 1;
365 
366     m_frameWidthAlignedMinBlk  = MOS_ALIGN_CEIL(m_vp9PicParams->FrameWidthMinus1 + 1, CODEC_VP9_MIN_BLOCK_WIDTH);
367     m_frameHeightAlignedMinBlk = MOS_ALIGN_CEIL(m_vp9PicParams->FrameHeightMinus1 + 1, CODEC_VP9_MIN_BLOCK_WIDTH);
368 
369     m_allocatedWidthInSb  = MOS_ROUNDUP_DIVIDE(m_width, CODEC_VP9_SUPER_BLOCK_WIDTH);
370     m_allocatedHeightInSb = MOS_ROUNDUP_DIVIDE(m_height, CODEC_VP9_SUPER_BLOCK_HEIGHT);
371 
372     // Overwrite the actual surface height with the coded height and width of the frame
373     // for VP9 since it's possible for a VP9 frame to change size during playback
374     m_destSurface.dwWidth  = m_vp9PicParams->FrameWidthMinus1 + 1;
375     m_destSurface.dwHeight = m_vp9PicParams->FrameHeightMinus1 + 1;
376 
377 
378     //update MV temp buffer index
379     if (m_vp9PicParams->PicFlags.fields.frame_type == CODEC_VP9_INTER_FRAME &&
380         !m_vp9PicParams->PicFlags.fields.intra_only)
381     {
382         m_curMvTempBufIdx = (m_curMvTempBufIdx + 1) % CODECHAL_VP9_NUM_MV_BUFFERS;
383         m_colMvTempBufIdx = (m_curMvTempBufIdx < 1) ? (CODECHAL_VP9_NUM_MV_BUFFERS - 1) : (m_curMvTempBufIdx - 1);
384     }
385 
386     // Allocate segment buffer
387     AllocateSegmentBuffer();
388 
389     // Allocate MV buffer
390     AllocateVP9MVBuffer();
391 
392     DECODE_CHK_STATUS(m_refFrames.UpdatePicture(*m_vp9PicParams));
393 
394     DECODE_CHK_STATUS(SetSegmentData());
395 
396     //set update flag
397     DetermineInternalBufferUpdate();
398 
399     return MOS_STATUS_SUCCESS;
400 }
401 
SetSegmentData()402 MOS_STATUS Vp9BasicFeature::SetSegmentData()
403 {
404     DECODE_FUNC_CALL();
405 
406     if ((!m_vp9PicParams->filter_level))
407     {
408         PCODEC_VP9_SEG_PARAMS vp9SegData = &m_vp9SegmentParams->SegData[0];
409 
410         for (uint8_t i = 0; i < 8; i++)
411         {
412             *((uint32_t *)&vp9SegData->FilterLevel[0][0]) = 0;
413             *((uint32_t *)&vp9SegData->FilterLevel[2][0]) = 0;
414             vp9SegData++;  // Go on to next record.
415         }
416     }
417     return MOS_STATUS_SUCCESS;
418 }
419 
AllocateVP9MVBuffer()420 MOS_STATUS Vp9BasicFeature::AllocateVP9MVBuffer()
421 {
422     DECODE_FUNC_CALL();
423 
424     uint32_t widthInSb   = MOS_ROUNDUP_DIVIDE(m_width, CODEC_VP9_SUPER_BLOCK_WIDTH);
425     uint32_t heightInSb  = MOS_ROUNDUP_DIVIDE(m_height, CODEC_VP9_SUPER_BLOCK_HEIGHT);
426     uint8_t  maxBitDepth = 8 + m_vp9DepthIndicator * 2;
427 
428     mhw::vdbox::hcp::HcpBufferSizePar hcpBufSizeParam;
429     MOS_ZeroMemory(&hcpBufSizeParam, sizeof(hcpBufSizeParam));
430     hcpBufSizeParam.ucMaxBitDepth = maxBitDepth;
431     hcpBufSizeParam.dwPicWidth    = widthInSb;
432     hcpBufSizeParam.dwPicHeight   = heightInSb;
433 
434     // m_chromaFormat was initialized in decode_basic_feature.cpp and got from codechal settings
435     hcpBufSizeParam.ucChromaFormat = m_chromaFormat;
436 
437     if (m_hcpItf->GetVp9BufferSize(mhw::vdbox::hcp::HCP_INTERNAL_BUFFER_TYPE::CURR_MV_TEMPORAL,
438             &hcpBufSizeParam) != MOS_STATUS_SUCCESS)
439     {
440         DECODE_ASSERTMESSAGE("Failed to MvBuffer size.");
441     }
442 
443     for (uint8_t i = 0; i < CODECHAL_VP9_NUM_MV_BUFFERS; i++)
444     {
445         if (m_resVp9MvTemporalBuffer[i] == nullptr)
446         {
447             m_resVp9MvTemporalBuffer[i] = m_allocator->AllocateBuffer(
448                 hcpBufSizeParam.dwBufferSize, "MvTemporalBuffer", resourceInternalReadWriteCache, notLockableVideoMem);
449             DECODE_CHK_NULL(m_resVp9MvTemporalBuffer[i]);
450         }
451         else
452         {
453             DECODE_CHK_STATUS(m_allocator->Resize(
454                 m_resVp9MvTemporalBuffer[i], hcpBufSizeParam.dwBufferSize, notLockableVideoMem));
455         }
456     }
457 
458     return MOS_STATUS_SUCCESS;
459 }
460 
InitDefaultProbBufferTable()461 MOS_STATUS Vp9BasicFeature ::InitDefaultProbBufferTable()
462 {
463     DECODE_FUNC_CALL();
464 
465     for (uint8_t i = 0; i < CODEC_VP9_NUM_CONTEXTS + 1; i++)
466     {
467         if (m_osInterface->osCpInterface->IsHMEnabled())
468         {
469             m_resVp9ProbBuffer[i] = m_allocator->AllocateBuffer(
470                 MOS_ALIGN_CEIL(CODEC_VP9_PROB_MAX_NUM_ELEM, CODECHAL_PAGE_SIZE), "Vp9ProbabilityBuffer",
471                 resourceInternalRead, notLockableVideoMem);
472             DECODE_CHK_NULL(m_resVp9ProbBuffer[i]);
473         }
474         else
475         {
476             m_resVp9ProbBuffer[i] = m_allocator->AllocateBuffer(
477                 MOS_ALIGN_CEIL(CODEC_VP9_PROB_MAX_NUM_ELEM, CODECHAL_PAGE_SIZE), "Vp9ProbabilityBuffer",
478                 resourceInternalRead, lockableVideoMem);
479             DECODE_CHK_NULL(m_resVp9ProbBuffer[i]);
480 
481             ResourceAutoLock resLock(m_allocator, &m_resVp9ProbBuffer[i]->OsResource);
482             auto             data = (uint8_t *)resLock.LockResourceForWrite();
483 
484             DECODE_CHK_NULL(data);
485 
486             MOS_ZeroMemory(data, CODEC_VP9_PROB_MAX_NUM_ELEM);
487             //initialize seg_tree_prob and seg_pred_prob
488             MOS_FillMemory((data + CODEC_VP9_SEG_PROB_OFFSET), 7, CODEC_VP9_MAX_PROB);
489             MOS_FillMemory((data + CODEC_VP9_SEG_PROB_OFFSET + 7), 3, CODEC_VP9_MAX_PROB);\
490         }
491     }
492 
493     return MOS_STATUS_SUCCESS;
494 }
495 
496 }  // namespace decode
497