1 /*
2 * Copyright (c) 2020-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_vp9_hpu_packet.cpp
24 //! \brief Defines the implementation of HPU (header's probability update) packet for VP9
25 //!
26 #include "encode_vp9_hpu_packet.h"
27 #include "encode_vp9_brc.h"
28 #include "encode_vp9_hpu.h"
29 #include "encode_vp9_segmentation.h"
30 #include "encode_vp9_pak.h"
31 #include "codec_def_vp9_probs.h"
32 #include "encode_vp9_vdenc_feature_manager.h"
33 #include "encode_status_report_defs.h"
34
35 namespace encode
36 {
37 extern const uint8_t Keyframe_Default_Probs[2048] = {
38 0x64, 0x42, 0x14, 0x98, 0x0f, 0x65, 0x03, 0x88, 0x25, 0x05, 0x34, 0x0d, 0x00, 0x00, 0x00, 0x00,
39 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42 0xc3, 0x1d, 0xb7, 0x54, 0x31, 0x88, 0x08, 0x2a, 0x47, 0x1f, 0x6b, 0xa9, 0x23, 0x63, 0x9f, 0x11,
43 0x52, 0x8c, 0x08, 0x42, 0x72, 0x02, 0x2c, 0x4c, 0x01, 0x13, 0x20, 0x28, 0x84, 0xc9, 0x1d, 0x72,
44 0xbb, 0x0d, 0x5b, 0x9d, 0x07, 0x4b, 0x7f, 0x03, 0x3a, 0x5f, 0x01, 0x1c, 0x2f, 0x45, 0x8e, 0xdd,
45 0x2a, 0x7a, 0xc9, 0x0f, 0x5b, 0x9f, 0x06, 0x43, 0x79, 0x01, 0x2a, 0x4d, 0x01, 0x11, 0x1f, 0x66,
46 0x94, 0xe4, 0x43, 0x75, 0xcc, 0x11, 0x52, 0x9a, 0x06, 0x3b, 0x72, 0x02, 0x27, 0x4b, 0x01, 0x0f,
47 0x1d, 0x9c, 0x39, 0xe9, 0x77, 0x39, 0xd4, 0x3a, 0x30, 0xa3, 0x1d, 0x28, 0x7c, 0x0c, 0x1e, 0x51,
48 0x03, 0x0c, 0x1f, 0xbf, 0x6b, 0xe2, 0x7c, 0x75, 0xcc, 0x19, 0x63, 0x9b, 0x1d, 0x94, 0xd2, 0x25,
49 0x7e, 0xc2, 0x08, 0x5d, 0x9d, 0x02, 0x44, 0x76, 0x01, 0x27, 0x45, 0x01, 0x11, 0x21, 0x29, 0x97,
50 0xd5, 0x1b, 0x7b, 0xc1, 0x03, 0x52, 0x90, 0x01, 0x3a, 0x69, 0x01, 0x20, 0x3c, 0x01, 0x0d, 0x1a,
51 0x3b, 0x9f, 0xdc, 0x17, 0x7e, 0xc6, 0x04, 0x58, 0x97, 0x01, 0x42, 0x72, 0x01, 0x26, 0x47, 0x01,
52 0x12, 0x22, 0x72, 0x88, 0xe8, 0x33, 0x72, 0xcf, 0x0b, 0x53, 0x9b, 0x03, 0x38, 0x69, 0x01, 0x21,
53 0x41, 0x01, 0x11, 0x22, 0x95, 0x41, 0xea, 0x79, 0x39, 0xd7, 0x3d, 0x31, 0xa6, 0x1c, 0x24, 0x72,
54 0x0c, 0x19, 0x4c, 0x03, 0x10, 0x2a, 0xd6, 0x31, 0xdc, 0x84, 0x3f, 0xbc, 0x2a, 0x41, 0x89, 0x55,
55 0x89, 0xdd, 0x68, 0x83, 0xd8, 0x31, 0x6f, 0xc0, 0x15, 0x57, 0x9b, 0x02, 0x31, 0x57, 0x01, 0x10,
56 0x1c, 0x59, 0xa3, 0xe6, 0x5a, 0x89, 0xdc, 0x1d, 0x64, 0xb7, 0x0a, 0x46, 0x87, 0x02, 0x2a, 0x51,
57 0x01, 0x11, 0x21, 0x6c, 0xa7, 0xed, 0x37, 0x85, 0xde, 0x0f, 0x61, 0xb3, 0x04, 0x48, 0x87, 0x01,
58 0x2d, 0x55, 0x01, 0x13, 0x26, 0x7c, 0x92, 0xf0, 0x42, 0x7c, 0xe0, 0x11, 0x58, 0xaf, 0x04, 0x3a,
59 0x7a, 0x01, 0x24, 0x4b, 0x01, 0x12, 0x25, 0x8d, 0x4f, 0xf1, 0x7e, 0x46, 0xe3, 0x42, 0x3a, 0xb6,
60 0x1e, 0x2c, 0x88, 0x0c, 0x22, 0x60, 0x02, 0x14, 0x2f, 0xe5, 0x63, 0xf9, 0x8f, 0x6f, 0xeb, 0x2e,
61 0x6d, 0xc0, 0x52, 0x9e, 0xec, 0x5e, 0x92, 0xe0, 0x19, 0x75, 0xbf, 0x09, 0x57, 0x95, 0x03, 0x38,
62 0x63, 0x01, 0x21, 0x39, 0x53, 0xa7, 0xed, 0x44, 0x91, 0xde, 0x0a, 0x67, 0xb1, 0x02, 0x48, 0x83,
63 0x01, 0x29, 0x4f, 0x01, 0x14, 0x27, 0x63, 0xa7, 0xef, 0x2f, 0x8d, 0xe0, 0x0a, 0x68, 0xb2, 0x02,
64 0x49, 0x85, 0x01, 0x2c, 0x55, 0x01, 0x16, 0x2f, 0x7f, 0x91, 0xf3, 0x47, 0x81, 0xe4, 0x11, 0x5d,
65 0xb1, 0x03, 0x3d, 0x7c, 0x01, 0x29, 0x54, 0x01, 0x15, 0x34, 0x9d, 0x4e, 0xf4, 0x8c, 0x48, 0xe7,
66 0x45, 0x3a, 0xb8, 0x1f, 0x2c, 0x89, 0x0e, 0x26, 0x69, 0x08, 0x17, 0x3d, 0x7d, 0x22, 0xbb, 0x34,
67 0x29, 0x85, 0x06, 0x1f, 0x38, 0x25, 0x6d, 0x99, 0x33, 0x66, 0x93, 0x17, 0x57, 0x80, 0x08, 0x43,
68 0x65, 0x01, 0x29, 0x3f, 0x01, 0x13, 0x1d, 0x1f, 0x9a, 0xb9, 0x11, 0x7f, 0xaf, 0x06, 0x60, 0x91,
69 0x02, 0x49, 0x72, 0x01, 0x33, 0x52, 0x01, 0x1c, 0x2d, 0x17, 0xa3, 0xc8, 0x0a, 0x83, 0xb9, 0x02,
70 0x5d, 0x94, 0x01, 0x43, 0x6f, 0x01, 0x29, 0x45, 0x01, 0x0e, 0x18, 0x1d, 0xb0, 0xd9, 0x0c, 0x91,
71 0xc9, 0x03, 0x65, 0x9c, 0x01, 0x45, 0x6f, 0x01, 0x27, 0x3f, 0x01, 0x0e, 0x17, 0x39, 0xc0, 0xe9,
72 0x19, 0x9a, 0xd7, 0x06, 0x6d, 0xa7, 0x03, 0x4e, 0x76, 0x01, 0x30, 0x45, 0x01, 0x15, 0x1d, 0xca,
73 0x69, 0xf5, 0x6c, 0x6a, 0xd8, 0x12, 0x5a, 0x90, 0x21, 0xac, 0xdb, 0x40, 0x95, 0xce, 0x0e, 0x75,
74 0xb1, 0x05, 0x5a, 0x8d, 0x02, 0x3d, 0x5f, 0x01, 0x25, 0x39, 0x21, 0xb3, 0xdc, 0x0b, 0x8c, 0xc6,
75 0x01, 0x59, 0x94, 0x01, 0x3c, 0x68, 0x01, 0x21, 0x39, 0x01, 0x0c, 0x15, 0x1e, 0xb5, 0xdd, 0x08,
76 0x8d, 0xc6, 0x01, 0x57, 0x91, 0x01, 0x3a, 0x64, 0x01, 0x1f, 0x37, 0x01, 0x0c, 0x14, 0x20, 0xba,
77 0xe0, 0x07, 0x8e, 0xc6, 0x01, 0x56, 0x8f, 0x01, 0x3a, 0x64, 0x01, 0x1f, 0x37, 0x01, 0x0c, 0x16,
78 0x39, 0xc0, 0xe3, 0x14, 0x8f, 0xcc, 0x03, 0x60, 0x9a, 0x01, 0x44, 0x70, 0x01, 0x2a, 0x45, 0x01,
79 0x13, 0x20, 0xd4, 0x23, 0xd7, 0x71, 0x2f, 0xa9, 0x1d, 0x30, 0x69, 0x4a, 0x81, 0xcb, 0x6a, 0x78,
80 0xcb, 0x31, 0x6b, 0xb2, 0x13, 0x54, 0x90, 0x04, 0x32, 0x54, 0x01, 0x0f, 0x19, 0x47, 0xac, 0xd9,
81 0x2c, 0x8d, 0xd1, 0x0f, 0x66, 0xad, 0x06, 0x4c, 0x85, 0x02, 0x33, 0x59, 0x01, 0x18, 0x2a, 0x40,
82 0xb9, 0xe7, 0x1f, 0x94, 0xd8, 0x08, 0x67, 0xaf, 0x03, 0x4a, 0x83, 0x01, 0x2e, 0x51, 0x01, 0x12,
83 0x1e, 0x41, 0xc4, 0xeb, 0x19, 0x9d, 0xdd, 0x05, 0x69, 0xae, 0x01, 0x43, 0x78, 0x01, 0x26, 0x45,
84 0x01, 0x0f, 0x1e, 0x41, 0xcc, 0xee, 0x1e, 0x9c, 0xe0, 0x07, 0x6b, 0xb1, 0x02, 0x46, 0x7c, 0x01,
85 0x2a, 0x49, 0x01, 0x12, 0x22, 0xe1, 0x56, 0xfb, 0x90, 0x68, 0xeb, 0x2a, 0x63, 0xb5, 0x55, 0xaf,
86 0xef, 0x70, 0xa5, 0xe5, 0x1d, 0x88, 0xc8, 0x0c, 0x67, 0xa2, 0x06, 0x4d, 0x7b, 0x02, 0x35, 0x54,
87 0x4b, 0xb7, 0xef, 0x1e, 0x9b, 0xdd, 0x03, 0x6a, 0xab, 0x01, 0x4a, 0x80, 0x01, 0x2c, 0x4c, 0x01,
88 0x11, 0x1c, 0x49, 0xb9, 0xf0, 0x1b, 0x9f, 0xde, 0x02, 0x6b, 0xac, 0x01, 0x4b, 0x7f, 0x01, 0x2a,
89 0x49, 0x01, 0x11, 0x1d, 0x3e, 0xbe, 0xee, 0x15, 0x9f, 0xde, 0x02, 0x6b, 0xac, 0x01, 0x48, 0x7a,
90 0x01, 0x28, 0x47, 0x01, 0x12, 0x20, 0x3d, 0xc7, 0xf0, 0x1b, 0xa1, 0xe2, 0x04, 0x71, 0xb4, 0x01,
91 0x4c, 0x81, 0x01, 0x2e, 0x50, 0x01, 0x17, 0x29, 0x07, 0x1b, 0x99, 0x05, 0x1e, 0x5f, 0x01, 0x10,
92 0x1e, 0x32, 0x4b, 0x7f, 0x39, 0x4b, 0x7c, 0x1b, 0x43, 0x6c, 0x0a, 0x36, 0x56, 0x01, 0x21, 0x34,
93 0x01, 0x0c, 0x12, 0x2b, 0x7d, 0x97, 0x1a, 0x6c, 0x94, 0x07, 0x53, 0x7a, 0x02, 0x3b, 0x59, 0x01,
94 0x26, 0x3c, 0x01, 0x11, 0x1b, 0x17, 0x90, 0xa3, 0x0d, 0x70, 0x9a, 0x02, 0x4b, 0x75, 0x01, 0x32,
95 0x51, 0x01, 0x1f, 0x33, 0x01, 0x0e, 0x17, 0x12, 0xa2, 0xb9, 0x06, 0x7b, 0xab, 0x01, 0x4e, 0x7d,
96 0x01, 0x33, 0x56, 0x01, 0x1f, 0x36, 0x01, 0x0e, 0x17, 0x0f, 0xc7, 0xe3, 0x03, 0x96, 0xcc, 0x01,
97 0x5b, 0x92, 0x01, 0x37, 0x5f, 0x01, 0x1e, 0x35, 0x01, 0x0b, 0x14, 0x13, 0x37, 0xf0, 0x13, 0x3b,
98 0xc4, 0x03, 0x34, 0x69, 0x29, 0xa6, 0xcf, 0x68, 0x99, 0xc7, 0x1f, 0x7b, 0xb5, 0x0e, 0x65, 0x98,
99 0x05, 0x48, 0x6a, 0x01, 0x24, 0x34, 0x23, 0xb0, 0xd3, 0x0c, 0x83, 0xbe, 0x02, 0x58, 0x90, 0x01,
100 0x3c, 0x65, 0x01, 0x24, 0x3c, 0x01, 0x10, 0x1c, 0x1c, 0xb7, 0xd5, 0x08, 0x86, 0xbf, 0x01, 0x56,
101 0x8e, 0x01, 0x38, 0x60, 0x01, 0x1e, 0x35, 0x01, 0x0c, 0x14, 0x14, 0xbe, 0xd7, 0x04, 0x87, 0xc0,
102 0x01, 0x54, 0x8b, 0x01, 0x35, 0x5b, 0x01, 0x1c, 0x31, 0x01, 0x0b, 0x14, 0x0d, 0xc4, 0xd8, 0x02,
103 0x89, 0xc0, 0x01, 0x56, 0x8f, 0x01, 0x39, 0x63, 0x01, 0x20, 0x38, 0x01, 0x0d, 0x18, 0xd3, 0x1d,
104 0xd9, 0x60, 0x2f, 0x9c, 0x16, 0x2b, 0x57, 0x4e, 0x78, 0xc1, 0x6f, 0x74, 0xba, 0x2e, 0x66, 0xa4,
105 0x0f, 0x50, 0x80, 0x02, 0x31, 0x4c, 0x01, 0x12, 0x1c, 0x47, 0xa1, 0xcb, 0x2a, 0x84, 0xc0, 0x0a,
106 0x62, 0x96, 0x03, 0x45, 0x6d, 0x01, 0x2c, 0x46, 0x01, 0x12, 0x1d, 0x39, 0xba, 0xd3, 0x1e, 0x8c,
107 0xc4, 0x04, 0x5d, 0x92, 0x01, 0x3e, 0x66, 0x01, 0x26, 0x41, 0x01, 0x10, 0x1b, 0x2f, 0xc7, 0xd9,
108 0x0e, 0x91, 0xc4, 0x01, 0x58, 0x8e, 0x01, 0x39, 0x62, 0x01, 0x24, 0x3e, 0x01, 0x0f, 0x1a, 0x1a,
109 0xdb, 0xe5, 0x05, 0x9b, 0xcf, 0x01, 0x5e, 0x97, 0x01, 0x3c, 0x68, 0x01, 0x24, 0x3e, 0x01, 0x10,
110 0x1c, 0xe9, 0x1d, 0xf8, 0x92, 0x2f, 0xdc, 0x2b, 0x34, 0x8c, 0x64, 0xa3, 0xe8, 0xb3, 0xa1, 0xde,
111 0x3f, 0x8e, 0xcc, 0x25, 0x71, 0xae, 0x1a, 0x59, 0x89, 0x12, 0x44, 0x61, 0x55, 0xb5, 0xe6, 0x20,
112 0x92, 0xd1, 0x07, 0x64, 0xa4, 0x03, 0x47, 0x79, 0x01, 0x2d, 0x4d, 0x01, 0x12, 0x1e, 0x41, 0xbb,
113 0xe6, 0x14, 0x94, 0xcf, 0x02, 0x61, 0x9f, 0x01, 0x44, 0x74, 0x01, 0x28, 0x46, 0x01, 0x0e, 0x1d,
114 0x28, 0xc2, 0xe3, 0x08, 0x93, 0xcc, 0x01, 0x5e, 0x9b, 0x01, 0x41, 0x70, 0x01, 0x27, 0x42, 0x01,
115 0x0e, 0x1a, 0x10, 0xd0, 0xe4, 0x03, 0x97, 0xcf, 0x01, 0x62, 0xa0, 0x01, 0x43, 0x75, 0x01, 0x29,
116 0x4a, 0x01, 0x11, 0x1f, 0x11, 0x26, 0x8c, 0x07, 0x22, 0x50, 0x01, 0x11, 0x1d, 0x25, 0x4b, 0x80,
117 0x29, 0x4c, 0x80, 0x1a, 0x42, 0x74, 0x0c, 0x34, 0x5e, 0x02, 0x20, 0x37, 0x01, 0x0a, 0x10, 0x32,
118 0x7f, 0x9a, 0x25, 0x6d, 0x98, 0x10, 0x52, 0x79, 0x05, 0x3b, 0x55, 0x01, 0x23, 0x36, 0x01, 0x0d,
119 0x14, 0x28, 0x8e, 0xa7, 0x11, 0x6e, 0x9d, 0x02, 0x47, 0x70, 0x01, 0x2c, 0x48, 0x01, 0x1b, 0x2d,
120 0x01, 0x0b, 0x11, 0x1e, 0xaf, 0xbc, 0x09, 0x7c, 0xa9, 0x01, 0x4a, 0x74, 0x01, 0x30, 0x4e, 0x01,
121 0x1e, 0x31, 0x01, 0x0b, 0x12, 0x0a, 0xde, 0xdf, 0x02, 0x96, 0xc2, 0x01, 0x53, 0x80, 0x01, 0x30,
122 0x4f, 0x01, 0x1b, 0x2d, 0x01, 0x0b, 0x11, 0x24, 0x29, 0xeb, 0x1d, 0x24, 0xc1, 0x0a, 0x1b, 0x6f,
123 0x55, 0xa5, 0xde, 0xb1, 0xa2, 0xd7, 0x6e, 0x87, 0xc3, 0x39, 0x71, 0xa8, 0x17, 0x53, 0x78, 0x0a,
124 0x31, 0x3d, 0x55, 0xbe, 0xdf, 0x24, 0x8b, 0xc8, 0x05, 0x5a, 0x92, 0x01, 0x3c, 0x67, 0x01, 0x26,
125 0x41, 0x01, 0x12, 0x1e, 0x48, 0xca, 0xdf, 0x17, 0x8d, 0xc7, 0x02, 0x56, 0x8c, 0x01, 0x38, 0x61,
126 0x01, 0x24, 0x3d, 0x01, 0x10, 0x1b, 0x37, 0xda, 0xe1, 0x0d, 0x91, 0xc8, 0x01, 0x56, 0x8d, 0x01,
127 0x39, 0x63, 0x01, 0x23, 0x3d, 0x01, 0x0d, 0x16, 0x0f, 0xeb, 0xd4, 0x01, 0x84, 0xb8, 0x01, 0x54,
128 0x8b, 0x01, 0x39, 0x61, 0x01, 0x22, 0x38, 0x01, 0x0e, 0x17, 0xb5, 0x15, 0xc9, 0x3d, 0x25, 0x7b,
129 0x0a, 0x26, 0x47, 0x2f, 0x6a, 0xac, 0x5f, 0x68, 0xad, 0x2a, 0x5d, 0x9f, 0x12, 0x4d, 0x83, 0x04,
130 0x32, 0x51, 0x01, 0x11, 0x17, 0x3e, 0x93, 0xc7, 0x2c, 0x82, 0xbd, 0x1c, 0x66, 0x9a, 0x12, 0x4b,
131 0x73, 0x02, 0x2c, 0x41, 0x01, 0x0c, 0x13, 0x37, 0x99, 0xd2, 0x18, 0x82, 0xc2, 0x03, 0x5d, 0x92,
132 0x01, 0x3d, 0x61, 0x01, 0x1f, 0x32, 0x01, 0x0a, 0x10, 0x31, 0xba, 0xdf, 0x11, 0x94, 0xcc, 0x01,
133 0x60, 0x8e, 0x01, 0x35, 0x53, 0x01, 0x1a, 0x2c, 0x01, 0x0b, 0x11, 0x0d, 0xd9, 0xd4, 0x02, 0x88,
134 0xb4, 0x01, 0x4e, 0x7c, 0x01, 0x32, 0x53, 0x01, 0x1d, 0x31, 0x01, 0x0e, 0x17, 0xc5, 0x0d, 0xf7,
135 0x52, 0x11, 0xde, 0x19, 0x11, 0xa2, 0x7e, 0xba, 0xf7, 0xea, 0xbf, 0xf3, 0xb0, 0xb1, 0xea, 0x68,
136 0x9e, 0xdc, 0x42, 0x80, 0xba, 0x37, 0x5a, 0x89, 0x6f, 0xc5, 0xf2, 0x2e, 0x9e, 0xdb, 0x09, 0x68,
137 0xab, 0x02, 0x41, 0x7d, 0x01, 0x2c, 0x50, 0x01, 0x11, 0x5b, 0x68, 0xd0, 0xf5, 0x27, 0xa8, 0xe0,
138 0x03, 0x6d, 0xa2, 0x01, 0x4f, 0x7c, 0x01, 0x32, 0x66, 0x01, 0x2b, 0x66, 0x54, 0xdc, 0xf6, 0x1f,
139 0xb1, 0xe7, 0x02, 0x73, 0xb4, 0x01, 0x4f, 0x86, 0x01, 0x37, 0x4d, 0x01, 0x3c, 0x4f, 0x2b, 0xf3,
140 0xf0, 0x08, 0xb4, 0xd9, 0x01, 0x73, 0xa6, 0x01, 0x54, 0x79, 0x01, 0x33, 0x43, 0x01, 0x10, 0x06,
141 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
142 0xc0, 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
143 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
144 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
145 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
146 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
147 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9e, 0x61, 0x5e, 0x5d,
148 0x18, 0x63, 0x55, 0x77, 0x2c, 0x3e, 0x3b, 0x43, 0x95, 0x35, 0x35, 0x5e, 0x14, 0x30, 0x53, 0x35,
149 0x18, 0x34, 0x12, 0x12, 0x96, 0x28, 0x27, 0x4e, 0x0c, 0x1a, 0x43, 0x21, 0x0b, 0x18, 0x07, 0x05,
150 0xae, 0x23, 0x31, 0x44, 0x0b, 0x1b, 0x39, 0x0f, 0x09, 0x0c, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00,
151 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
152 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
153 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
154 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
155 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
156 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
157 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
158 0x90, 0x0b, 0x36, 0x9d, 0xc3, 0x82, 0x2e, 0x3a, 0x6c, 0x76, 0x0f, 0x7b, 0x94, 0x83, 0x65, 0x2c,
159 0x5d, 0x83, 0x71, 0x0c, 0x17, 0xbc, 0xe2, 0x8e, 0x1a, 0x20, 0x7d, 0x78, 0x0b, 0x32, 0x7b, 0xa3,
160 0x87, 0x40, 0x4d, 0x67, 0x71, 0x09, 0x24, 0x9b, 0x6f, 0x9d, 0x20, 0x2c, 0xa1, 0x74, 0x09, 0x37,
161 0xb0, 0x4c, 0x60, 0x25, 0x3d, 0x95, 0x73, 0x09, 0x1c, 0x8d, 0xa1, 0xa7, 0x15, 0x19, 0xc1, 0x78,
162 0x0c, 0x20, 0x91, 0xc3, 0x8e, 0x20, 0x26, 0x56, 0x74, 0x0c, 0x40, 0x78, 0x8c, 0x7d, 0x31, 0x73,
163 0x79, 0x66, 0x13, 0x42, 0xa2, 0xb6, 0x7a, 0x23, 0x3b, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
164 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
165 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
166 };
167
168 extern const uint8_t Inter_Default_Probs[2048] = {
169 0x64, 0x42, 0x14, 0x98, 0x0f, 0x65, 0x03, 0x88, 0x25, 0x05, 0x34, 0x0d, 0x00, 0x00, 0x00, 0x00,
170 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
171 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
172 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
173 0xc3, 0x1d, 0xb7, 0x54, 0x31, 0x88, 0x08, 0x2a, 0x47, 0x1f, 0x6b, 0xa9, 0x23, 0x63, 0x9f, 0x11,
174 0x52, 0x8c, 0x08, 0x42, 0x72, 0x02, 0x2c, 0x4c, 0x01, 0x13, 0x20, 0x28, 0x84, 0xc9, 0x1d, 0x72,
175 0xbb, 0x0d, 0x5b, 0x9d, 0x07, 0x4b, 0x7f, 0x03, 0x3a, 0x5f, 0x01, 0x1c, 0x2f, 0x45, 0x8e, 0xdd,
176 0x2a, 0x7a, 0xc9, 0x0f, 0x5b, 0x9f, 0x06, 0x43, 0x79, 0x01, 0x2a, 0x4d, 0x01, 0x11, 0x1f, 0x66,
177 0x94, 0xe4, 0x43, 0x75, 0xcc, 0x11, 0x52, 0x9a, 0x06, 0x3b, 0x72, 0x02, 0x27, 0x4b, 0x01, 0x0f,
178 0x1d, 0x9c, 0x39, 0xe9, 0x77, 0x39, 0xd4, 0x3a, 0x30, 0xa3, 0x1d, 0x28, 0x7c, 0x0c, 0x1e, 0x51,
179 0x03, 0x0c, 0x1f, 0xbf, 0x6b, 0xe2, 0x7c, 0x75, 0xcc, 0x19, 0x63, 0x9b, 0x1d, 0x94, 0xd2, 0x25,
180 0x7e, 0xc2, 0x08, 0x5d, 0x9d, 0x02, 0x44, 0x76, 0x01, 0x27, 0x45, 0x01, 0x11, 0x21, 0x29, 0x97,
181 0xd5, 0x1b, 0x7b, 0xc1, 0x03, 0x52, 0x90, 0x01, 0x3a, 0x69, 0x01, 0x20, 0x3c, 0x01, 0x0d, 0x1a,
182 0x3b, 0x9f, 0xdc, 0x17, 0x7e, 0xc6, 0x04, 0x58, 0x97, 0x01, 0x42, 0x72, 0x01, 0x26, 0x47, 0x01,
183 0x12, 0x22, 0x72, 0x88, 0xe8, 0x33, 0x72, 0xcf, 0x0b, 0x53, 0x9b, 0x03, 0x38, 0x69, 0x01, 0x21,
184 0x41, 0x01, 0x11, 0x22, 0x95, 0x41, 0xea, 0x79, 0x39, 0xd7, 0x3d, 0x31, 0xa6, 0x1c, 0x24, 0x72,
185 0x0c, 0x19, 0x4c, 0x03, 0x10, 0x2a, 0xd6, 0x31, 0xdc, 0x84, 0x3f, 0xbc, 0x2a, 0x41, 0x89, 0x55,
186 0x89, 0xdd, 0x68, 0x83, 0xd8, 0x31, 0x6f, 0xc0, 0x15, 0x57, 0x9b, 0x02, 0x31, 0x57, 0x01, 0x10,
187 0x1c, 0x59, 0xa3, 0xe6, 0x5a, 0x89, 0xdc, 0x1d, 0x64, 0xb7, 0x0a, 0x46, 0x87, 0x02, 0x2a, 0x51,
188 0x01, 0x11, 0x21, 0x6c, 0xa7, 0xed, 0x37, 0x85, 0xde, 0x0f, 0x61, 0xb3, 0x04, 0x48, 0x87, 0x01,
189 0x2d, 0x55, 0x01, 0x13, 0x26, 0x7c, 0x92, 0xf0, 0x42, 0x7c, 0xe0, 0x11, 0x58, 0xaf, 0x04, 0x3a,
190 0x7a, 0x01, 0x24, 0x4b, 0x01, 0x12, 0x25, 0x8d, 0x4f, 0xf1, 0x7e, 0x46, 0xe3, 0x42, 0x3a, 0xb6,
191 0x1e, 0x2c, 0x88, 0x0c, 0x22, 0x60, 0x02, 0x14, 0x2f, 0xe5, 0x63, 0xf9, 0x8f, 0x6f, 0xeb, 0x2e,
192 0x6d, 0xc0, 0x52, 0x9e, 0xec, 0x5e, 0x92, 0xe0, 0x19, 0x75, 0xbf, 0x09, 0x57, 0x95, 0x03, 0x38,
193 0x63, 0x01, 0x21, 0x39, 0x53, 0xa7, 0xed, 0x44, 0x91, 0xde, 0x0a, 0x67, 0xb1, 0x02, 0x48, 0x83,
194 0x01, 0x29, 0x4f, 0x01, 0x14, 0x27, 0x63, 0xa7, 0xef, 0x2f, 0x8d, 0xe0, 0x0a, 0x68, 0xb2, 0x02,
195 0x49, 0x85, 0x01, 0x2c, 0x55, 0x01, 0x16, 0x2f, 0x7f, 0x91, 0xf3, 0x47, 0x81, 0xe4, 0x11, 0x5d,
196 0xb1, 0x03, 0x3d, 0x7c, 0x01, 0x29, 0x54, 0x01, 0x15, 0x34, 0x9d, 0x4e, 0xf4, 0x8c, 0x48, 0xe7,
197 0x45, 0x3a, 0xb8, 0x1f, 0x2c, 0x89, 0x0e, 0x26, 0x69, 0x08, 0x17, 0x3d, 0x7d, 0x22, 0xbb, 0x34,
198 0x29, 0x85, 0x06, 0x1f, 0x38, 0x25, 0x6d, 0x99, 0x33, 0x66, 0x93, 0x17, 0x57, 0x80, 0x08, 0x43,
199 0x65, 0x01, 0x29, 0x3f, 0x01, 0x13, 0x1d, 0x1f, 0x9a, 0xb9, 0x11, 0x7f, 0xaf, 0x06, 0x60, 0x91,
200 0x02, 0x49, 0x72, 0x01, 0x33, 0x52, 0x01, 0x1c, 0x2d, 0x17, 0xa3, 0xc8, 0x0a, 0x83, 0xb9, 0x02,
201 0x5d, 0x94, 0x01, 0x43, 0x6f, 0x01, 0x29, 0x45, 0x01, 0x0e, 0x18, 0x1d, 0xb0, 0xd9, 0x0c, 0x91,
202 0xc9, 0x03, 0x65, 0x9c, 0x01, 0x45, 0x6f, 0x01, 0x27, 0x3f, 0x01, 0x0e, 0x17, 0x39, 0xc0, 0xe9,
203 0x19, 0x9a, 0xd7, 0x06, 0x6d, 0xa7, 0x03, 0x4e, 0x76, 0x01, 0x30, 0x45, 0x01, 0x15, 0x1d, 0xca,
204 0x69, 0xf5, 0x6c, 0x6a, 0xd8, 0x12, 0x5a, 0x90, 0x21, 0xac, 0xdb, 0x40, 0x95, 0xce, 0x0e, 0x75,
205 0xb1, 0x05, 0x5a, 0x8d, 0x02, 0x3d, 0x5f, 0x01, 0x25, 0x39, 0x21, 0xb3, 0xdc, 0x0b, 0x8c, 0xc6,
206 0x01, 0x59, 0x94, 0x01, 0x3c, 0x68, 0x01, 0x21, 0x39, 0x01, 0x0c, 0x15, 0x1e, 0xb5, 0xdd, 0x08,
207 0x8d, 0xc6, 0x01, 0x57, 0x91, 0x01, 0x3a, 0x64, 0x01, 0x1f, 0x37, 0x01, 0x0c, 0x14, 0x20, 0xba,
208 0xe0, 0x07, 0x8e, 0xc6, 0x01, 0x56, 0x8f, 0x01, 0x3a, 0x64, 0x01, 0x1f, 0x37, 0x01, 0x0c, 0x16,
209 0x39, 0xc0, 0xe3, 0x14, 0x8f, 0xcc, 0x03, 0x60, 0x9a, 0x01, 0x44, 0x70, 0x01, 0x2a, 0x45, 0x01,
210 0x13, 0x20, 0xd4, 0x23, 0xd7, 0x71, 0x2f, 0xa9, 0x1d, 0x30, 0x69, 0x4a, 0x81, 0xcb, 0x6a, 0x78,
211 0xcb, 0x31, 0x6b, 0xb2, 0x13, 0x54, 0x90, 0x04, 0x32, 0x54, 0x01, 0x0f, 0x19, 0x47, 0xac, 0xd9,
212 0x2c, 0x8d, 0xd1, 0x0f, 0x66, 0xad, 0x06, 0x4c, 0x85, 0x02, 0x33, 0x59, 0x01, 0x18, 0x2a, 0x40,
213 0xb9, 0xe7, 0x1f, 0x94, 0xd8, 0x08, 0x67, 0xaf, 0x03, 0x4a, 0x83, 0x01, 0x2e, 0x51, 0x01, 0x12,
214 0x1e, 0x41, 0xc4, 0xeb, 0x19, 0x9d, 0xdd, 0x05, 0x69, 0xae, 0x01, 0x43, 0x78, 0x01, 0x26, 0x45,
215 0x01, 0x0f, 0x1e, 0x41, 0xcc, 0xee, 0x1e, 0x9c, 0xe0, 0x07, 0x6b, 0xb1, 0x02, 0x46, 0x7c, 0x01,
216 0x2a, 0x49, 0x01, 0x12, 0x22, 0xe1, 0x56, 0xfb, 0x90, 0x68, 0xeb, 0x2a, 0x63, 0xb5, 0x55, 0xaf,
217 0xef, 0x70, 0xa5, 0xe5, 0x1d, 0x88, 0xc8, 0x0c, 0x67, 0xa2, 0x06, 0x4d, 0x7b, 0x02, 0x35, 0x54,
218 0x4b, 0xb7, 0xef, 0x1e, 0x9b, 0xdd, 0x03, 0x6a, 0xab, 0x01, 0x4a, 0x80, 0x01, 0x2c, 0x4c, 0x01,
219 0x11, 0x1c, 0x49, 0xb9, 0xf0, 0x1b, 0x9f, 0xde, 0x02, 0x6b, 0xac, 0x01, 0x4b, 0x7f, 0x01, 0x2a,
220 0x49, 0x01, 0x11, 0x1d, 0x3e, 0xbe, 0xee, 0x15, 0x9f, 0xde, 0x02, 0x6b, 0xac, 0x01, 0x48, 0x7a,
221 0x01, 0x28, 0x47, 0x01, 0x12, 0x20, 0x3d, 0xc7, 0xf0, 0x1b, 0xa1, 0xe2, 0x04, 0x71, 0xb4, 0x01,
222 0x4c, 0x81, 0x01, 0x2e, 0x50, 0x01, 0x17, 0x29, 0x07, 0x1b, 0x99, 0x05, 0x1e, 0x5f, 0x01, 0x10,
223 0x1e, 0x32, 0x4b, 0x7f, 0x39, 0x4b, 0x7c, 0x1b, 0x43, 0x6c, 0x0a, 0x36, 0x56, 0x01, 0x21, 0x34,
224 0x01, 0x0c, 0x12, 0x2b, 0x7d, 0x97, 0x1a, 0x6c, 0x94, 0x07, 0x53, 0x7a, 0x02, 0x3b, 0x59, 0x01,
225 0x26, 0x3c, 0x01, 0x11, 0x1b, 0x17, 0x90, 0xa3, 0x0d, 0x70, 0x9a, 0x02, 0x4b, 0x75, 0x01, 0x32,
226 0x51, 0x01, 0x1f, 0x33, 0x01, 0x0e, 0x17, 0x12, 0xa2, 0xb9, 0x06, 0x7b, 0xab, 0x01, 0x4e, 0x7d,
227 0x01, 0x33, 0x56, 0x01, 0x1f, 0x36, 0x01, 0x0e, 0x17, 0x0f, 0xc7, 0xe3, 0x03, 0x96, 0xcc, 0x01,
228 0x5b, 0x92, 0x01, 0x37, 0x5f, 0x01, 0x1e, 0x35, 0x01, 0x0b, 0x14, 0x13, 0x37, 0xf0, 0x13, 0x3b,
229 0xc4, 0x03, 0x34, 0x69, 0x29, 0xa6, 0xcf, 0x68, 0x99, 0xc7, 0x1f, 0x7b, 0xb5, 0x0e, 0x65, 0x98,
230 0x05, 0x48, 0x6a, 0x01, 0x24, 0x34, 0x23, 0xb0, 0xd3, 0x0c, 0x83, 0xbe, 0x02, 0x58, 0x90, 0x01,
231 0x3c, 0x65, 0x01, 0x24, 0x3c, 0x01, 0x10, 0x1c, 0x1c, 0xb7, 0xd5, 0x08, 0x86, 0xbf, 0x01, 0x56,
232 0x8e, 0x01, 0x38, 0x60, 0x01, 0x1e, 0x35, 0x01, 0x0c, 0x14, 0x14, 0xbe, 0xd7, 0x04, 0x87, 0xc0,
233 0x01, 0x54, 0x8b, 0x01, 0x35, 0x5b, 0x01, 0x1c, 0x31, 0x01, 0x0b, 0x14, 0x0d, 0xc4, 0xd8, 0x02,
234 0x89, 0xc0, 0x01, 0x56, 0x8f, 0x01, 0x39, 0x63, 0x01, 0x20, 0x38, 0x01, 0x0d, 0x18, 0xd3, 0x1d,
235 0xd9, 0x60, 0x2f, 0x9c, 0x16, 0x2b, 0x57, 0x4e, 0x78, 0xc1, 0x6f, 0x74, 0xba, 0x2e, 0x66, 0xa4,
236 0x0f, 0x50, 0x80, 0x02, 0x31, 0x4c, 0x01, 0x12, 0x1c, 0x47, 0xa1, 0xcb, 0x2a, 0x84, 0xc0, 0x0a,
237 0x62, 0x96, 0x03, 0x45, 0x6d, 0x01, 0x2c, 0x46, 0x01, 0x12, 0x1d, 0x39, 0xba, 0xd3, 0x1e, 0x8c,
238 0xc4, 0x04, 0x5d, 0x92, 0x01, 0x3e, 0x66, 0x01, 0x26, 0x41, 0x01, 0x10, 0x1b, 0x2f, 0xc7, 0xd9,
239 0x0e, 0x91, 0xc4, 0x01, 0x58, 0x8e, 0x01, 0x39, 0x62, 0x01, 0x24, 0x3e, 0x01, 0x0f, 0x1a, 0x1a,
240 0xdb, 0xe5, 0x05, 0x9b, 0xcf, 0x01, 0x5e, 0x97, 0x01, 0x3c, 0x68, 0x01, 0x24, 0x3e, 0x01, 0x10,
241 0x1c, 0xe9, 0x1d, 0xf8, 0x92, 0x2f, 0xdc, 0x2b, 0x34, 0x8c, 0x64, 0xa3, 0xe8, 0xb3, 0xa1, 0xde,
242 0x3f, 0x8e, 0xcc, 0x25, 0x71, 0xae, 0x1a, 0x59, 0x89, 0x12, 0x44, 0x61, 0x55, 0xb5, 0xe6, 0x20,
243 0x92, 0xd1, 0x07, 0x64, 0xa4, 0x03, 0x47, 0x79, 0x01, 0x2d, 0x4d, 0x01, 0x12, 0x1e, 0x41, 0xbb,
244 0xe6, 0x14, 0x94, 0xcf, 0x02, 0x61, 0x9f, 0x01, 0x44, 0x74, 0x01, 0x28, 0x46, 0x01, 0x0e, 0x1d,
245 0x28, 0xc2, 0xe3, 0x08, 0x93, 0xcc, 0x01, 0x5e, 0x9b, 0x01, 0x41, 0x70, 0x01, 0x27, 0x42, 0x01,
246 0x0e, 0x1a, 0x10, 0xd0, 0xe4, 0x03, 0x97, 0xcf, 0x01, 0x62, 0xa0, 0x01, 0x43, 0x75, 0x01, 0x29,
247 0x4a, 0x01, 0x11, 0x1f, 0x11, 0x26, 0x8c, 0x07, 0x22, 0x50, 0x01, 0x11, 0x1d, 0x25, 0x4b, 0x80,
248 0x29, 0x4c, 0x80, 0x1a, 0x42, 0x74, 0x0c, 0x34, 0x5e, 0x02, 0x20, 0x37, 0x01, 0x0a, 0x10, 0x32,
249 0x7f, 0x9a, 0x25, 0x6d, 0x98, 0x10, 0x52, 0x79, 0x05, 0x3b, 0x55, 0x01, 0x23, 0x36, 0x01, 0x0d,
250 0x14, 0x28, 0x8e, 0xa7, 0x11, 0x6e, 0x9d, 0x02, 0x47, 0x70, 0x01, 0x2c, 0x48, 0x01, 0x1b, 0x2d,
251 0x01, 0x0b, 0x11, 0x1e, 0xaf, 0xbc, 0x09, 0x7c, 0xa9, 0x01, 0x4a, 0x74, 0x01, 0x30, 0x4e, 0x01,
252 0x1e, 0x31, 0x01, 0x0b, 0x12, 0x0a, 0xde, 0xdf, 0x02, 0x96, 0xc2, 0x01, 0x53, 0x80, 0x01, 0x30,
253 0x4f, 0x01, 0x1b, 0x2d, 0x01, 0x0b, 0x11, 0x24, 0x29, 0xeb, 0x1d, 0x24, 0xc1, 0x0a, 0x1b, 0x6f,
254 0x55, 0xa5, 0xde, 0xb1, 0xa2, 0xd7, 0x6e, 0x87, 0xc3, 0x39, 0x71, 0xa8, 0x17, 0x53, 0x78, 0x0a,
255 0x31, 0x3d, 0x55, 0xbe, 0xdf, 0x24, 0x8b, 0xc8, 0x05, 0x5a, 0x92, 0x01, 0x3c, 0x67, 0x01, 0x26,
256 0x41, 0x01, 0x12, 0x1e, 0x48, 0xca, 0xdf, 0x17, 0x8d, 0xc7, 0x02, 0x56, 0x8c, 0x01, 0x38, 0x61,
257 0x01, 0x24, 0x3d, 0x01, 0x10, 0x1b, 0x37, 0xda, 0xe1, 0x0d, 0x91, 0xc8, 0x01, 0x56, 0x8d, 0x01,
258 0x39, 0x63, 0x01, 0x23, 0x3d, 0x01, 0x0d, 0x16, 0x0f, 0xeb, 0xd4, 0x01, 0x84, 0xb8, 0x01, 0x54,
259 0x8b, 0x01, 0x39, 0x61, 0x01, 0x22, 0x38, 0x01, 0x0e, 0x17, 0xb5, 0x15, 0xc9, 0x3d, 0x25, 0x7b,
260 0x0a, 0x26, 0x47, 0x2f, 0x6a, 0xac, 0x5f, 0x68, 0xad, 0x2a, 0x5d, 0x9f, 0x12, 0x4d, 0x83, 0x04,
261 0x32, 0x51, 0x01, 0x11, 0x17, 0x3e, 0x93, 0xc7, 0x2c, 0x82, 0xbd, 0x1c, 0x66, 0x9a, 0x12, 0x4b,
262 0x73, 0x02, 0x2c, 0x41, 0x01, 0x0c, 0x13, 0x37, 0x99, 0xd2, 0x18, 0x82, 0xc2, 0x03, 0x5d, 0x92,
263 0x01, 0x3d, 0x61, 0x01, 0x1f, 0x32, 0x01, 0x0a, 0x10, 0x31, 0xba, 0xdf, 0x11, 0x94, 0xcc, 0x01,
264 0x60, 0x8e, 0x01, 0x35, 0x53, 0x01, 0x1a, 0x2c, 0x01, 0x0b, 0x11, 0x0d, 0xd9, 0xd4, 0x02, 0x88,
265 0xb4, 0x01, 0x4e, 0x7c, 0x01, 0x32, 0x53, 0x01, 0x1d, 0x31, 0x01, 0x0e, 0x17, 0xc5, 0x0d, 0xf7,
266 0x52, 0x11, 0xde, 0x19, 0x11, 0xa2, 0x7e, 0xba, 0xf7, 0xea, 0xbf, 0xf3, 0xb0, 0xb1, 0xea, 0x68,
267 0x9e, 0xdc, 0x42, 0x80, 0xba, 0x37, 0x5a, 0x89, 0x6f, 0xc5, 0xf2, 0x2e, 0x9e, 0xdb, 0x09, 0x68,
268 0xab, 0x02, 0x41, 0x7d, 0x01, 0x2c, 0x50, 0x01, 0x11, 0x5b, 0x68, 0xd0, 0xf5, 0x27, 0xa8, 0xe0,
269 0x03, 0x6d, 0xa2, 0x01, 0x4f, 0x7c, 0x01, 0x32, 0x66, 0x01, 0x2b, 0x66, 0x54, 0xdc, 0xf6, 0x1f,
270 0xb1, 0xe7, 0x02, 0x73, 0xb4, 0x01, 0x4f, 0x86, 0x01, 0x37, 0x4d, 0x01, 0x3c, 0x4f, 0x2b, 0xf3,
271 0xf0, 0x08, 0xb4, 0xd9, 0x01, 0x73, 0xa6, 0x01, 0x54, 0x79, 0x01, 0x33, 0x43, 0x01, 0x10, 0x06,
272 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
273 0xc0, 0x80, 0x40, 0x02, 0xad, 0x22, 0x07, 0x91, 0x55, 0x07, 0xa6, 0x3f, 0x07, 0x5e, 0x42, 0x08,
274 0x40, 0x2e, 0x11, 0x51, 0x1f, 0x19, 0x1d, 0x1e, 0xeb, 0xa2, 0x24, 0xff, 0x22, 0x03, 0x95, 0x90,
275 0x09, 0x66, 0xbb, 0xe1, 0xef, 0xb7, 0x77, 0x60, 0x29, 0x21, 0x10, 0x4d, 0x4a, 0x8e, 0x8e, 0xac,
276 0xaa, 0xee, 0xf7, 0x32, 0x7e, 0x7b, 0xdd, 0xe2, 0x41, 0x20, 0x12, 0x90, 0xa2, 0xc2, 0x29, 0x33,
277 0x62, 0x84, 0x44, 0x12, 0xa5, 0xd9, 0xc4, 0x2d, 0x28, 0x4e, 0xad, 0x50, 0x13, 0xb0, 0xf0, 0xc1,
278 0x40, 0x23, 0x2e, 0xdd, 0x87, 0x26, 0xc2, 0xf8, 0x79, 0x60, 0x55, 0x1d, 0xc7, 0x7a, 0x8d, 0x93,
279 0x3f, 0x9f, 0x94, 0x85, 0x76, 0x79, 0x68, 0x72, 0xae, 0x49, 0x57, 0x5c, 0x29, 0x53, 0x52, 0x63,
280 0x32, 0x35, 0x27, 0x27, 0xb1, 0x3a, 0x3b, 0x44, 0x1a, 0x3f, 0x34, 0x4f, 0x19, 0x11, 0x0e, 0x0c,
281 0xde, 0x22, 0x1e, 0x48, 0x10, 0x2c, 0x3a, 0x20, 0x0c, 0x0a, 0x07, 0x06, 0x20, 0x40, 0x60, 0x80,
282 0xe0, 0x90, 0xc0, 0xa8, 0xc0, 0xb0, 0xc0, 0xc6, 0xc6, 0xf5, 0xd8, 0x88, 0x8c, 0x94, 0xa0, 0xb0,
283 0xc0, 0xe0, 0xea, 0xea, 0xf0, 0x80, 0xd8, 0x80, 0xb0, 0xa0, 0xb0, 0xb0, 0xc0, 0xc6, 0xc6, 0xd0,
284 0xd0, 0x88, 0x8c, 0x94, 0xa0, 0xb0, 0xc0, 0xe0, 0xea, 0xea, 0xf0, 0x80, 0x80, 0x40, 0x60, 0x70,
285 0x40, 0x40, 0x60, 0x40, 0x80, 0x80, 0x40, 0x60, 0x70, 0x40, 0x40, 0x60, 0x40, 0xa0, 0x80, 0xa0,
286 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
287 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
288 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
289 0x78, 0x07, 0x4c, 0xb0, 0xd0, 0x7e, 0x1c, 0x36, 0x67, 0x30, 0x0c, 0x9a, 0x9b, 0x8b, 0x5a, 0x22,
290 0x75, 0x77, 0x43, 0x06, 0x19, 0xcc, 0xf3, 0x9e, 0x0d, 0x15, 0x60, 0x61, 0x05, 0x2c, 0x83, 0xb0,
291 0x8b, 0x30, 0x44, 0x61, 0x53, 0x05, 0x2a, 0x9c, 0x6f, 0x98, 0x1a, 0x31, 0x98, 0x50, 0x05, 0x3a,
292 0xb2, 0x4a, 0x53, 0x21, 0x3e, 0x91, 0x56, 0x05, 0x20, 0x9a, 0xc0, 0xa8, 0x0e, 0x16, 0xa3, 0x55,
293 0x05, 0x20, 0x9c, 0xd8, 0x94, 0x13, 0x1d, 0x49, 0x4d, 0x07, 0x40, 0x74, 0x84, 0x7a, 0x25, 0x7e,
294 0x78, 0x65, 0x15, 0x6b, 0xb5, 0xc0, 0x67, 0x13, 0x43, 0x7d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
295 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
296 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
297 };
298
Init()299 MOS_STATUS Vp9HpuPkt::Init()
300 {
301 ENCODE_FUNC_CALL();
302 ENCODE_CHK_STATUS_RETURN(EncodeHucPkt::Init());
303 ENCODE_CHK_NULL_RETURN(m_featureManager);
304
305 m_basicFeature = dynamic_cast<Vp9BasicFeature *>(m_featureManager->GetFeature(Vp9FeatureIDs::basicFeature));
306 ENCODE_CHK_NULL_RETURN(m_basicFeature);
307
308 return MOS_STATUS_SUCCESS;
309 }
310
Submit(MOS_COMMAND_BUFFER * commandBuffer,uint8_t packetPhase)311 MOS_STATUS Vp9HpuPkt::Submit(MOS_COMMAND_BUFFER *commandBuffer, uint8_t packetPhase)
312 {
313 ENCODE_FUNC_CALL();
314
315 // Disable super frame state
316 ENCODE_CHK_STATUS_RETURN(SetSuperFrameHucPass(false));
317 ENCODE_CHK_STATUS_RETURN(PatchHucProbCommands(commandBuffer, packetPhase));
318
319 return MOS_STATUS_SUCCESS;
320 }
321
PatchHucProbCommands(MOS_COMMAND_BUFFER * commandBuffer,uint8_t packetPhase)322 MOS_STATUS Vp9HpuPkt::PatchHucProbCommands(MOS_COMMAND_BUFFER *commandBuffer, uint8_t packetPhase)
323 {
324 ENCODE_FUNC_CALL();
325 ENCODE_CHK_NULL_RETURN(m_basicFeature);
326 ENCODE_CHK_NULL_RETURN(m_basicFeature->m_recycleBuf);
327
328 // To match watchdog timer threshold in codechal
329 ENCODE_CHK_STATUS_RETURN(m_miItf->SetWatchdogTimerThreshold(m_basicFeature->m_frameWidth, m_basicFeature->m_frameHeight, true));
330
331 uint16_t perfTag = m_pipeline->IsFirstPass() ? CODECHAL_ENCODE_PERFTAG_CALL_VP9_HPU
332 : CODECHAL_ENCODE_PERFTAG_CALL_VP9_HPU_SECOND_PASS;
333 SetPerfTag(perfTag, (uint16_t)m_basicFeature->m_mode, m_basicFeature->m_pictureCodingType);
334
335 // Construct picture state 2nd level batch buffer
336 RUN_FEATURE_INTERFACE_RETURN(Vp9EncodePak, Vp9FeatureIDs::vp9PakFeature, ConstructPicStateBatchBuffer, m_pipeline);
337
338 // Construct pak insert batch buffer
339 RUN_FEATURE_INTERFACE_RETURN(Vp9EncodePak, Vp9FeatureIDs::vp9PakFeature, ConstructPakInsertObjBatchBuffer);
340
341 bool firstTaskInPhase = ((packetPhase & firstPacket) == firstPacket);
342 bool requestProlog = false;
343
344 if (!m_pipeline->IsSingleTaskPhaseSupported() || firstTaskInPhase)
345 {
346 // Send command buffer header at the beginning (OS dependent)
347 requestProlog = true;
348 }
349
350 ENCODE_CHK_STATUS_RETURN(Execute(commandBuffer, true, requestProlog));
351
352 // Write HUC_STATUS mask: DW1 (mask value)
353 auto &storeDataParams = m_miItf->MHW_GETPAR_F(MI_STORE_DATA_IMM)();
354 storeDataParams = {};
355 storeDataParams.pOsResource = m_basicFeature->m_recycleBuf->GetBuffer(VdencBrcPakMmioBuffer, 0);
356 storeDataParams.dwResourceOffset = sizeof(uint32_t);
357 storeDataParams.dwValue = 1 << 31; //Repak bit for HUC is bit 31
358 ENCODE_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(MI_STORE_DATA_IMM)(commandBuffer));
359
360 // Store HUC_STATUS register: DW0 (actual value)
361 ENCODE_CHK_COND_RETURN((m_vdboxIndex > MHW_VDBOX_NODE_1), "ERROR - vdbox index exceed the maximum");
362 ENCODE_CHK_NULL_RETURN(m_hwInterface->GetHucInterfaceNext());
363 auto mmioRegisters = m_hwInterface->GetHucInterfaceNext()->GetMmioRegisters(m_vdboxIndex);
364
365 auto &miStoreRegMemParams = m_miItf->MHW_GETPAR_F(MI_STORE_REGISTER_MEM)();
366 miStoreRegMemParams = {};
367 miStoreRegMemParams.presStoreBuffer = m_basicFeature->m_recycleBuf->GetBuffer(VdencBrcPakMmioBuffer, 0);
368 miStoreRegMemParams.dwOffset = 0;
369 miStoreRegMemParams.dwRegister = mmioRegisters->hucStatusRegOffset;
370 ENCODE_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(MI_STORE_REGISTER_MEM)(commandBuffer));
371
372 // For superframe pass, after HuC executes, write the updated size (combined frame size) to status report
373 // So app knows total size instead of just the showframe size
374 if (m_superFrameHucPass)
375 {
376 MediaStatusReport *statusReport = m_pipeline->GetStatusReportInstance();
377 ENCODE_CHK_NULL_RETURN(statusReport);
378
379 MOS_RESOURCE *osResource = nullptr;
380 uint32_t offset = 0;
381
382 EncodeStatusReadParams params;
383 MOS_ZeroMemory(¶ms, sizeof(params));
384
385 ENCODE_CHK_STATUS_RETURN(statusReport->GetAddress(encode::statusReportMfxBitstreamByteCountPerFrame, osResource, offset));
386 params.resBitstreamByteCountPerFrame = osResource;
387 params.bitstreamByteCountPerFrameOffset = offset;
388
389 auto virtualAddrParams = m_hucItf->MHW_GETPAR_F(HUC_VIRTUAL_ADDR_STATE)();
390 auto ©MemMemParams = m_miItf->MHW_GETPAR_F(MI_COPY_MEM_MEM)();
391 copyMemMemParams = {};
392 copyMemMemParams.presSrc = virtualAddrParams.regionParams[11].presRegion;
393 copyMemMemParams.dwSrcOffset = 0; // Updated framesize is 1st DW in buffer
394 copyMemMemParams.presDst = params.resBitstreamByteCountPerFrame;
395 copyMemMemParams.dwDstOffset = params.bitstreamByteCountPerFrameOffset;
396 ENCODE_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(MI_COPY_MEM_MEM)(commandBuffer));
397
398 if (m_pipeline->IsLastPass() && m_pipeline->IsLastPipe())
399 {
400 // Update m_prevFrameInfo here when super frame pass is enabled, otherwise update at Vp9VdencPkt
401 ENCODE_CHK_STATUS_RETURN(m_basicFeature->UpdateParameters());
402 }
403 }
404
405 CODECHAL_DEBUG_TOOL(
406 ENCODE_CHK_STATUS_RETURN(DumpInput());)
407
408 return MOS_STATUS_SUCCESS;
409 }
410
CalculateCommandSize(uint32_t & commandBufferSize,uint32_t & requestedPatchListSize)411 MOS_STATUS Vp9HpuPkt::CalculateCommandSize(uint32_t &commandBufferSize, uint32_t &requestedPatchListSize)
412 {
413 ENCODE_FUNC_CALL();
414
415 auto osInterface = m_hwInterface->GetOsInterface();
416 ENCODE_CHK_NULL_RETURN(osInterface);
417
418 uint32_t hucCommandsSize = 0;
419 uint32_t hucPatchListSize = 0;
420 MHW_VDBOX_STATE_CMDSIZE_PARAMS stateCmdSizeParams;
421
422 ENCODE_CHK_STATUS_RETURN(m_hwInterface->GetHucStateCommandSize(
423 m_basicFeature->m_mode, (uint32_t *)&hucCommandsSize, (uint32_t *)&hucPatchListSize, &stateCmdSizeParams));
424
425 commandBufferSize = hucCommandsSize;
426 requestedPatchListSize = osInterface->bUsesPatchList ? hucPatchListSize : 0;
427
428 if (m_pipeline->IsSingleTaskPhaseSupported())
429 {
430 commandBufferSize *= m_pipeline->GetPassNum();
431 }
432
433 // 4K align since allocation is in chunks of 4K bytes.
434 commandBufferSize = MOS_ALIGN_CEIL(commandBufferSize, CODECHAL_PAGE_SIZE);
435
436 return MOS_STATUS_SUCCESS;
437 }
438
DumpOutput()439 MOS_STATUS Vp9HpuPkt::DumpOutput()
440 {
441 ENCODE_FUNC_CALL();
442
443 #if USE_CODECHAL_DEBUG_TOOL
444
445 uint32_t vdencPicState2ndLevelBatchBufferSize = 0;
446 RUN_FEATURE_INTERFACE_RETURN(Vp9EncodePak, Vp9FeatureIDs::vp9PakFeature, GetVdencPictureState2ndLevelBatchBufferSize, vdencPicState2ndLevelBatchBufferSize);
447
448 CodechalHucRegionDumpType dumpType = m_superFrameHucPass ? hucRegionDumpHpuSuperFrame : hucRegionDumpHpu;
449
450 ENCODE_CHK_STATUS_RETURN(DumpRegion(0, "_UpdatedProbBuffer", false, dumpType, (32 * CODECHAL_CACHELINE_SIZE)));
451 ENCODE_CHK_STATUS_RETURN(DumpRegion(2, "_ProbBuffer", false, dumpType, (32 * CODECHAL_CACHELINE_SIZE)));
452 ENCODE_CHK_STATUS_RETURN(DumpRegion(3, "_ProbDeltaBuffer", false, dumpType, (29 * CODECHAL_CACHELINE_SIZE)));
453 ENCODE_CHK_STATUS_RETURN(DumpRegion(4, "_UncompressedHdr", false, dumpType, CODECHAL_ENCODE_VP9_PAK_INSERT_UNCOMPRESSED_HEADER));
454 ENCODE_CHK_STATUS_RETURN(DumpRegion(5, "_CompressedHdr", false, dumpType, (32 * CODECHAL_CACHELINE_SIZE)));
455 ENCODE_CHK_STATUS_RETURN(DumpRegion(6, "_SecondLevelBatchBuffer", false, dumpType, vdencPicState2ndLevelBatchBufferSize));
456 ENCODE_CHK_STATUS_RETURN(DumpRegion(10, "_SuperFrameBuffer", false, dumpType, CODECHAL_ENCODE_VP9_BRC_SUPER_FRAME_BUFFER_SIZE));
457 ENCODE_CHK_STATUS_RETURN(DumpRegion(11, "_DataExtension", false, dumpType, CODECHAL_ENCODE_VP9_VDENC_DATA_EXTENSION_SIZE));
458
459 #endif // USE_CODECHAL_DEBUG_TOOL
460
461 return MOS_STATUS_SUCCESS;
462 }
463
AllocateResources()464 MOS_STATUS Vp9HpuPkt::AllocateResources()
465 {
466 ENCODE_FUNC_CALL();
467 ENCODE_CHK_STATUS_RETURN(EncodeHucPkt::AllocateResources());
468
469 MOS_RESOURCE *allocatedBuffer = nullptr;
470
471 // Initiate allocation parameters
472 MOS_ALLOC_GFXRES_PARAMS allocParamsForBufferLinear;
473 MOS_ZeroMemory(&allocParamsForBufferLinear, sizeof(MOS_ALLOC_GFXRES_PARAMS));
474 allocParamsForBufferLinear.Type = MOS_GFXRES_BUFFER;
475 allocParamsForBufferLinear.TileType = MOS_TILE_LINEAR;
476 allocParamsForBufferLinear.Format = Format_Buffer;
477
478 // Huc default prob buffer
479 allocParamsForBufferLinear.dwBytes = sizeof(Keyframe_Default_Probs) + sizeof(Inter_Default_Probs);
480 allocParamsForBufferLinear.pBufName = "HucDefaultProbBuffer";
481 allocParamsForBufferLinear.ResUsageType = MOS_HW_RESOURCE_USAGE_ENCODE_INTERNAL_READ_WRITE_CACHE;
482 allocatedBuffer = m_allocator->AllocateResource(allocParamsForBufferLinear, false);
483 ENCODE_CHK_NULL_RETURN(allocatedBuffer);
484 m_resHucDefaultProbBuffer = *allocatedBuffer;
485
486 uint8_t *data = (uint8_t *)m_allocator->LockResourceForWrite(&m_resHucDefaultProbBuffer);
487 ENCODE_CHK_NULL_RETURN(data);
488 MOS_SecureMemcpy(data, sizeof(Keyframe_Default_Probs), Keyframe_Default_Probs, sizeof(Keyframe_Default_Probs));
489 MOS_SecureMemcpy(data + sizeof(Keyframe_Default_Probs), sizeof(Inter_Default_Probs), Inter_Default_Probs, sizeof(Inter_Default_Probs));
490 m_allocator->UnLock(&m_resHucDefaultProbBuffer);
491
492 return MOS_STATUS_SUCCESS;
493 }
494
SetDmemBuffer() const495 MOS_STATUS Vp9HpuPkt::SetDmemBuffer() const
496 {
497 // From CodechalVdencVp9State::SetDmemHuCVp9Prob()
498 ENCODE_FUNC_CALL();
499 ENCODE_CHK_NULL_RETURN(m_basicFeature);
500 ENCODE_CHK_NULL_RETURN(m_basicFeature->m_vp9PicParams);
501 ENCODE_CHK_NULL_RETURN(m_basicFeature->m_vp9SeqParams);
502 ENCODE_CHK_NULL_RETURN(m_basicFeature->m_vp9SegmentParams);
503
504 const CODEC_VP9_ENCODE_PIC_PARAMS * vp9PicParams = m_basicFeature->m_vp9PicParams;
505 const CODEC_VP9_ENCODE_SEQUENCE_PARAMS *vp9SeqParams = m_basicFeature->m_vp9SeqParams;
506 const CODEC_VP9_ENCODE_SEGMENT_PARAMS * vp9SegmentParams = m_basicFeature->m_vp9SegmentParams;
507
508 auto hpuFeature = dynamic_cast<Vp9EncodeHpu *>(m_featureManager->GetFeature(Vp9FeatureIDs::vp9HpuFeature));
509 ENCODE_CHK_NULL_RETURN(hpuFeature);
510 auto brcFeature = dynamic_cast<Vp9EncodeBrc *>(m_featureManager->GetFeature(Vp9FeatureIDs::vp9BrcFeature));
511 ENCODE_CHK_NULL_RETURN(brcFeature);
512
513 PMOS_RESOURCE hucProbDmemBuffer = nullptr;
514 HucProbDmem * dmem = nullptr;
515
516 auto currPass = m_pipeline->GetCurrentPass();
517 ENCODE_CHK_STATUS_RETURN(hpuFeature->GetHucProbDmemBuffer(currPass, hucProbDmemBuffer));
518 ENCODE_CHK_NULL_RETURN(hucProbDmemBuffer);
519
520 dmem = (HucProbDmem *)m_allocator->LockResourceForWrite(hucProbDmemBuffer);
521 ENCODE_CHK_NULL_RETURN(dmem);
522
523 // For BRC cases, HuC needs to be called on Pass 1
524 if (m_superFrameHucPass)
525 {
526 dmem->HuCPassNum = CODECHAL_ENCODE_VP9_HUC_SUPERFRAME_PASS;
527 }
528 else
529 {
530 if (m_basicFeature->m_dysBrc)
531 {
532 // For BRC+Dynamic Scaling, we need to run as HUC pass 1 in the last pass since the curr_pass was changed to 0.
533 dmem->HuCPassNum = currPass != 0;
534 }
535 else
536 {
537 // For Non-dynamic scaling BRC cases, HuC needs to run as HuC pass one only in last pass.
538 dmem->HuCPassNum = ((brcFeature->IsVdencBrcEnabled() && currPass == 1) ? 0 : (currPass != 0));
539 }
540 }
541
542 dmem->FrameWidth = m_basicFeature->m_oriFrameWidth;
543 dmem->FrameHeight = m_basicFeature->m_oriFrameHeight;
544
545 for (auto i = 0; i < CODEC_VP9_MAX_SEGMENTS; ++i)
546 {
547 dmem->SegmentRef[i] = (vp9SegmentParams->SegData[i].SegmentFlags.fields.SegmentReferenceEnabled == true) ? vp9SegmentParams->SegData[i].SegmentFlags.fields.SegmentReference : CODECHAL_ENCODE_VP9_REF_SEGMENT_DISABLED;
548 dmem->SegmentSkip[i] = vp9SegmentParams->SegData[i].SegmentFlags.fields.SegmentSkipped;
549 }
550
551 if (vp9PicParams->PicFlags.fields.frame_type == CODEC_VP9_KEY_FRAME && currPass == 0)
552 {
553 for (auto i = 1; i < CODEC_VP9_NUM_CONTEXTS; i++)
554 {
555 PMOS_RESOURCE resProbBuffer = nullptr;
556 ENCODE_CHK_STATUS_RETURN(hpuFeature->GetProbabilityBuffer(i, resProbBuffer));
557 ENCODE_CHK_NULL_RETURN(resProbBuffer);
558
559 // Get resProbBuffer from Vp9EncodeBrc feature class
560 uint8_t *data = (uint8_t *)m_allocator->LockResourceForWrite(resProbBuffer);
561 ENCODE_CHK_NULL_RETURN(data);
562
563 hpuFeature->ContextBufferInit(data, 0);
564 hpuFeature->CtxBufDiffInit(data, 0);
565
566 ENCODE_CHK_STATUS_RETURN(m_allocator->UnLock(resProbBuffer));
567 }
568 }
569
570 // in multipasses, only delta seg qp (SegCodeAbs = 0) is supported, confirmed by the arch team
571 dmem->SegCodeAbs = 0;
572 dmem->SegTemporalUpdate = vp9PicParams->PicFlags.fields.segmentation_temporal_update;
573 dmem->LastRefIndex = vp9PicParams->RefFlags.fields.LastRefIdx;
574 dmem->GoldenRefIndex = vp9PicParams->RefFlags.fields.GoldenRefIdx;
575 dmem->AltRefIndex = vp9PicParams->RefFlags.fields.AltRefIdx;
576 dmem->RefreshFrameFlags = vp9PicParams->RefFlags.fields.refresh_frame_flags;
577 dmem->RefFrameFlags = m_basicFeature->m_ref.RefFrameFlags();
578 dmem->ContextFrameTypes = m_basicFeature->m_contextFrameTypes[vp9PicParams->PicFlags.fields.frame_context_idx];
579 dmem->FrameToShow = GetReferenceBufferSlotIndex(dmem->RefreshFrameFlags);
580
581 dmem->FrameCtrl.FrameType = vp9PicParams->PicFlags.fields.frame_type;
582 dmem->FrameCtrl.ShowFrame = vp9PicParams->PicFlags.fields.show_frame;
583 dmem->FrameCtrl.ErrorResilientMode = vp9PicParams->PicFlags.fields.error_resilient_mode;
584 dmem->FrameCtrl.IntraOnly = vp9PicParams->PicFlags.fields.intra_only;
585 dmem->FrameCtrl.ContextReset = vp9PicParams->PicFlags.fields.reset_frame_context;
586 dmem->FrameCtrl.LastRefFrameBias = vp9PicParams->RefFlags.fields.LastRefSignBias;
587 dmem->FrameCtrl.GoldenRefFrameBias = vp9PicParams->RefFlags.fields.GoldenRefSignBias;
588 dmem->FrameCtrl.AltRefFrameBias = vp9PicParams->RefFlags.fields.AltRefSignBias;
589 dmem->FrameCtrl.AllowHighPrecisionMv = vp9PicParams->PicFlags.fields.allow_high_precision_mv;
590 dmem->FrameCtrl.McompFilterMode = vp9PicParams->PicFlags.fields.mcomp_filter_type;
591 dmem->FrameCtrl.RefreshFrameContext = vp9PicParams->PicFlags.fields.refresh_frame_context;
592 dmem->FrameCtrl.TxMode = m_basicFeature->m_txMode;
593 dmem->FrameCtrl.FrameParallelDecode = vp9PicParams->PicFlags.fields.frame_parallel_decoding_mode;
594 dmem->FrameCtrl.CompPredMode = vp9PicParams->PicFlags.fields.comp_prediction_mode;
595 dmem->FrameCtrl.FrameContextIdx = vp9PicParams->PicFlags.fields.frame_context_idx;
596 dmem->FrameCtrl.SharpnessLevel = vp9PicParams->sharpness_level;
597 dmem->FrameCtrl.log2TileRows = vp9PicParams->log2_tile_rows;
598 dmem->FrameCtrl.log2TileCols = vp9PicParams->log2_tile_columns;
599
600 // For DyS CQP or BRC case there is no Repak on last pass. So disable the Repak flag here.
601 // We also disable repak pass in TU7 speed mode usage for performance reasons
602 dmem->RePak = (m_pipeline->GetPassNum() > 1 && m_pipeline->IsLastPass() && !(m_basicFeature->m_dysCqp || m_basicFeature->m_dysBrc) &&
603 !TargetUsage::isSpeed(vp9SeqParams->TargetUsage));
604
605 dmem->PrevFrameInfo = m_basicFeature->m_prevFrameInfo;
606 if (dmem->RePak && m_basicFeature->m_adaptiveRepakSupported)
607 {
608 MOS_SecureMemcpy(dmem->RePakThreshold,
609 sizeof(uint32_t) * CODEC_VP9_QINDEX_RANGE,
610 m_basicFeature->m_rePakThreshold,
611 sizeof(uint32_t) * CODEC_VP9_QINDEX_RANGE);
612 }
613
614 RUN_FEATURE_INTERFACE_RETURN(Vp9Segmentation, Vp9FeatureIDs::vp9Segmentation, SetDmemForHucProb, dmem);
615
616 dmem->LFLevelBitOffset = vp9PicParams->BitOffsetForLFLevel;
617 dmem->QIndexBitOffset = vp9PicParams->BitOffsetForQIndex;
618 dmem->SegBitOffset = vp9PicParams->BitOffsetForSegmentation + 1; // exclude segment_enable bit
619 dmem->SegLengthInBits = vp9PicParams->BitSizeForSegmentation - 1; // exclude segment_enable bit
620 dmem->UnCompHdrTotalLengthInBits = vp9PicParams->BitOffsetForFirstPartitionSize + 16;
621 dmem->PicStateOffset = m_basicFeature->m_hucPicStateOffset;
622 dmem->SLBBSize = m_basicFeature->m_hucSlbbSize;
623 dmem->IVFHeaderSize = (m_basicFeature->m_frameNum == 0) ? 44 : 12;
624 dmem->VDEncImgStateOffset = m_basicFeature->m_slbbImgStateOffset;
625 dmem->PakOnlyEnable = (dmem->RePak && m_basicFeature->m_vdencPakonlyMultipassEnabled)?1:0;
626
627 ENCODE_CHK_STATUS_RETURN(m_allocator->UnLock(hucProbDmemBuffer));
628
629 return MOS_STATUS_SUCCESS;
630 }
631
GetReferenceBufferSlotIndex(uint8_t refreshFlags) const632 uint8_t Vp9HpuPkt::GetReferenceBufferSlotIndex(uint8_t refreshFlags) const
633 {
634 // Even if there could be multiple reference frames in the buffer
635 // but here we only retrieve the one which has the smallest index
636
637 if (refreshFlags == 0)
638 {
639 return 0;
640 }
641
642 refreshFlags = ~refreshFlags;
643
644 uint8_t refSlotIndex = 0;
645 while (refreshFlags & 1)
646 {
647 refreshFlags >>= 1;
648 refSlotIndex++;
649 }
650
651 return refSlotIndex;
652 }
653
654 #if USE_CODECHAL_DEBUG_TOOL
DumpInput()655 MOS_STATUS Vp9HpuPkt::DumpInput()
656 {
657 ENCODE_FUNC_CALL();
658
659 CodechalDebugInterface *debugInterface = m_pipeline->GetDebugInterface();
660 ENCODE_CHK_NULL_RETURN(debugInterface);
661
662 uint32_t currentPass = m_pipeline->GetCurrentPass();
663 uint32_t vdencPicState2ndLevelBatchBufferSize = 0;
664 RUN_FEATURE_INTERFACE_RETURN(Vp9EncodePak, Vp9FeatureIDs::vp9PakFeature, GetVdencPictureState2ndLevelBatchBufferSize, vdencPicState2ndLevelBatchBufferSize);
665 PMOS_RESOURCE hucProbDmemBuffer = nullptr;
666 RUN_FEATURE_INTERFACE_RETURN(Vp9EncodeHpu, Vp9FeatureIDs::vp9HpuFeature, GetHucProbDmemBuffer, currentPass, hucProbDmemBuffer);
667 ENCODE_CHK_NULL_RETURN(hucProbDmemBuffer);
668
669 CodechalHucRegionDumpType dumpType = m_superFrameHucPass ? hucRegionDumpHpuSuperFrame : hucRegionDumpHpu;
670
671 ENCODE_CHK_STATUS_RETURN(debugInterface->DumpHucDmem(
672 hucProbDmemBuffer,
673 sizeof(HucProbDmem),
674 currentPass,
675 dumpType));
676
677 ENCODE_CHK_STATUS_RETURN(DumpRegion(0, "_ProbBuffer", true, dumpType, (32 * CODECHAL_CACHELINE_SIZE)));
678 ENCODE_CHK_STATUS_RETURN(DumpRegion(1, "_CountersBuffer", true, dumpType, (193 * CODECHAL_CACHELINE_SIZE)));
679 ENCODE_CHK_STATUS_RETURN(DumpRegion(7, "_SecondLevelBatchBuffer", true, dumpType, vdencPicState2ndLevelBatchBufferSize));
680 ENCODE_CHK_STATUS_RETURN(DumpRegion(8, "_UncompressedHdr", true, dumpType, CODECHAL_ENCODE_VP9_PAK_INSERT_UNCOMPRESSED_HEADER));
681 ENCODE_CHK_STATUS_RETURN(DumpRegion(9, "_DefaultProbs", true, dumpType, sizeof(Keyframe_Default_Probs) + sizeof(Inter_Default_Probs)));
682
683 return MOS_STATUS_SUCCESS;
684 }
685 #endif // USE_CODECHAL_DEBUG_TOOL
686
MHW_SETPAR_DECL_SRC(HUC_IMEM_STATE,Vp9HpuPkt)687 MHW_SETPAR_DECL_SRC(HUC_IMEM_STATE, Vp9HpuPkt)
688 {
689 ENCODE_FUNC_CALL();
690
691 params.kernelDescriptor = m_vdboxHucVp9VdencProbKernelDescriptor;
692
693 return MOS_STATUS_SUCCESS;
694 }
695
MHW_SETPAR_DECL_SRC(HUC_DMEM_STATE,Vp9HpuPkt)696 MHW_SETPAR_DECL_SRC(HUC_DMEM_STATE, Vp9HpuPkt)
697 {
698 ENCODE_FUNC_CALL();
699
700 ENCODE_CHK_STATUS_RETURN(SetDmemBuffer());
701
702 params.function = HPU_VP9;
703 params.passNum = static_cast<uint8_t>(m_pipeline->GetPassNum());
704 params.currentPass = static_cast<uint8_t>(m_pipeline->GetCurrentPass());
705 PMOS_RESOURCE hucProbDmemBuffer = nullptr;
706 RUN_FEATURE_INTERFACE_RETURN(Vp9EncodeHpu, Vp9FeatureIDs::vp9HpuFeature, GetHucProbDmemBuffer, m_pipeline->GetCurrentPass(), hucProbDmemBuffer);
707 ENCODE_CHK_NULL_RETURN(hucProbDmemBuffer);
708 params.hucDataSource = hucProbDmemBuffer;
709 params.dataLength = MOS_ALIGN_CEIL(sizeof(HucProbDmem), CODECHAL_CACHELINE_SIZE);
710 params.dmemOffset = HUC_DMEM_OFFSET_RTOS_GEMS;
711
712 return MOS_STATUS_SUCCESS;
713 }
714
MHW_SETPAR_DECL_SRC(HUC_VIRTUAL_ADDR_STATE,Vp9HpuPkt)715 MHW_SETPAR_DECL_SRC(HUC_VIRTUAL_ADDR_STATE, Vp9HpuPkt)
716 {
717 ENCODE_FUNC_CALL();
718
719 params.function = HPU_VP9;
720
721 ENCODE_CHK_NULL_RETURN(m_basicFeature);
722
723 auto currPass = m_pipeline->GetCurrentPass();
724
725 // Input regions: 0, 1
726 // Output regions: 2, 3
727 RUN_FEATURE_INTERFACE_RETURN(Vp9EncodeHpu, Vp9FeatureIDs::vp9HpuFeature, SetRegions, params);
728 // Input regions: 7, 8
729 // Output regions: 4, 5, 6, 10, 11
730 RUN_FEATURE_INTERFACE_RETURN(Vp9EncodePak, Vp9FeatureIDs::vp9PakFeature, SetRegionsForHucProb, params, currPass);
731
732 // Region 1: Overwrite
733 if (m_basicFeature->m_scalableMode)
734 {
735 Vp9TileStatusInfo vp9TileStatsOffset = {};
736 Vp9TileStatusInfo vp9FrameStatsOffset = {};
737 Vp9TileStatusInfo vp9StatsSize = {};
738 RUN_FEATURE_INTERFACE_RETURN(Vp9EncodeTile, Vp9FeatureIDs::encodeTile, GetTileStatusInfo, vp9TileStatsOffset, vp9FrameStatsOffset, vp9StatsSize);
739 MOS_RESOURCE *resHuCPakAggregatedFrameStatsBuffer = nullptr;
740 RUN_FEATURE_INTERFACE_RETURN(Vp9EncodeTile, Vp9FeatureIDs::encodeTile, GetHucPakAggregatedFrameStatsBuffer, resHuCPakAggregatedFrameStatsBuffer);
741
742 params.regionParams[1].presRegion = resHuCPakAggregatedFrameStatsBuffer;
743 params.regionParams[1].dwOffset = vp9FrameStatsOffset.counterBuffer;
744 }
745
746 params.regionParams[9].presRegion = const_cast<PMOS_RESOURCE>(&m_resHucDefaultProbBuffer);
747
748 return MOS_STATUS_SUCCESS;
749 }
750
751 } // namespace encode
752