summaryrefslogtreecommitdiff
path: root/src/i965_encoder_vp8.h
blob: 0740abd31675164957e54eb4f200071594e9e713 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
/*
 * Copyright © 2017 Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Authors:
 *    Xiang, Haihao <haihao.xiang@intel.com>
 *
 */

#ifndef I965_ENCODER_VP8_H
#define I965_ENCODER_VP8_H

#include <drm.h>
#include <i915_drm.h>
#include <intel_bufmgr.h>

#include "i965_gpe_utils.h"

#define VP8_ME_MV_DATA_SIZE_MULTIPLIER     3
#define VP8_HISTOGRAM_SIZE                 (136 * sizeof(unsigned int))
#define VP8_FRAME_HEADER_SIZE              4096
#define VP8_MODE_PROPABILITIES_SIZE        96

#define VP8_NUM_COEFF_PLANES               4
#define VP8_NUM_COEFF_BANDS                8
#define VP8_NUM_LOCAL_COMPLEXITIES         3
#define VP8_NUM_COEFF_NODES                11
#define VP8_COEFFS_PROPABILITIES_SIZE      (VP8_NUM_COEFF_PLANES * VP8_NUM_COEFF_BANDS * VP8_NUM_LOCAL_COMPLEXITIES * VP8_NUM_COEFF_NODES)

#define VP8_TOKEN_BITS_DATA_SIZE           (16 * sizeof(unsigned int))

#define VP8_HEADER_METADATA_SIZE           (32 * sizeof(unsigned int))
#define VP8_PICTURE_STATE_CMD_SIZE         (37 * sizeof(unsigned int))
#define VP8_PICTURE_STATE_SIZE             (VP8_PICTURE_STATE_CMD_SIZE + VP8_HEADER_METADATA_SIZE + (16 * sizeof(unsigned int)))

#define VP8_MPU_BITSTREAM_SIZE             128
#define VP8_TPU_BITSTREAM_SIZE             1344
#define VP8_ENTROPY_COST_TABLE_SIZE        (256 * sizeof(unsigned int))

#define VP8_TOKEN_STATISTICS_SIZE          (304 * sizeof(unsigned int))

#define VP8_INTERMEDIATE_PARTITION0_SIZE   (64 * 1024)

#define VP8_REPAK_DECISION_BUF_SIZE        (4 * sizeof(unsigned int))

#define VP8_MAX_SEGMENTS                   4

#define VP8_ENCODE_STATUS_NUM                  512

#define VP8_HEADER_METADATA_SIZE           (32  * sizeof(unsigned int))
#define VP8_PICTURE_STATE_CMD_SIZE         (37  * sizeof(unsigned int))
#define VP8_PICTURE_STATE_SIZE             (VP8_PICTURE_STATE_CMD_SIZE + VP8_HEADER_METADATA_SIZE + (16 * sizeof(unsigned int)))
#define VP8_HEADER_METADATA_OFFSET         (VP8_PICTURE_STATE_CMD_SIZE + (3 * sizeof(unsigned int)))

#define VDBOX0_MMIO_BASE                                        0x12000
#define VDBOX1_MMIO_BASE                                        0x1c000

#define VP8_MFC_IMAGE_STATUS_MASK_REG_OFFSET                    0x900
#define VP8_MFC_IMAGE_STATUS_CTRL_REG_OFFSET                    0x904
#define VP8_MFC_BITSTREAM_BYTECOUNT_FRAME_REG_OFFSET            0x908

#define VP8_MFX_BRC_DQ_INDEX_REG_OFFSET                         0x910
#define VP8_MFX_BRC_D_LOOP_FILTER_REG_OFFSET                    0x914
#define VP8_MFX_BRC_CUMULATIVE_DQ_INDEX01_REG_OFFSET            0x918
#define VP8_MFX_BRC_CUMULATIVE_DQ_INDEX23_REG_OFFSET            0x91C
#define VP8_MFX_BRC_CUMULATIVE_D_LOOP_FILTER01_REG_OFFSET       0x920
#define VP8_MFX_BRC_CUMULATIVE_D_LOOP_FILTER23_REG_OFFSET       0x924
#define VP8_MFX_BRC_CONVERGENCE_STATUS_REG_OFFSET               0x928

struct encode_state;
struct intel_encoder_context;

struct i965_encoder_vp8_surface {
    VADriverContextP ctx;
    VASurfaceID scaled_4x_surface_id;
    struct object_surface *scaled_4x_surface_obj;
    VASurfaceID scaled_16x_surface_id;
    struct object_surface *scaled_16x_surface_obj;
    unsigned int qp_index;
};

enum vp8_binding_table_offset_vp8_brc_init_reset {
    VP8_BTI_BRC_INIT_RESET_HISTORY = 0,
    VP8_BTI_BRC_INIT_RESET_DISTORTION,
    VP8_BTI_BRC_INIT_RESET_NUM_SURFACES
};

struct vp8_brc_init_reset_curbe_data {
    struct {
        uint32_t profile_level_max_frame;
    } dw0;

    struct {
        uint32_t init_buf_full_in_bits;
    } dw1;

    struct {
        uint32_t buf_size_in_bits;
    } dw2;

    struct {
        uint32_t average_bitrate;
    } dw3;

    struct {
        uint32_t max_bitrate;
    } dw4;

    struct {
        uint32_t min_bitrate;
    } dw5;

    struct {
        uint32_t frame_rate_m;
    } dw6;

    struct {
        uint32_t frame_rate_d;
    } dw7;

    struct {
        uint32_t brc_flag: 16;
        uint32_t gop_minus1: 16;
    } dw8;

    struct {
        uint32_t reserved: 16;
        uint32_t frame_width_in_bytes: 16;
    } dw9;

    struct {
        uint32_t frame_height_in_bytes: 16;
        uint32_t avbr_accuracy: 16;
    } dw10;

    struct {
        uint32_t avbr_convergence: 16;
        uint32_t min_qp: 16;
    } dw11;

    struct {
        uint32_t max_qp: 16;
        uint32_t level_qp: 16;
    } dw12;

    struct {
        uint32_t max_section_pct: 16;
        uint32_t under_shoot_cbr_pct: 16;
    } dw13;

    struct {
        uint32_t vbr_bias_pct: 16;
        uint32_t min_section_pct: 16;
    } dw14;

    struct {
        uint32_t instant_rate_threshold_0_for_p: 8;
        uint32_t instant_rate_threshold_1_for_p: 8;
        uint32_t instant_rate_threshold_2_for_p: 8;
        uint32_t instant_rate_threshold_3_for_p: 8;
    } dw15;

    struct {
        uint32_t reserved;
    } dw16;

    struct {
        uint32_t instant_rate_threshold_0_for_i: 8;
        uint32_t instant_rate_threshold_1_for_i: 8;
        uint32_t instant_rate_threshold_2_for_i: 8;
        uint32_t instant_rate_threshold_3_for_i: 8;
    } dw17;

    struct {
        uint32_t deviation_threshold_0_for_p: 8; // Signed byte
        uint32_t deviation_threshold_1_for_p: 8; // Signed byte
        uint32_t deviation_threshold_2_for_p: 8; // Signed byte
        uint32_t deviation_threshold_3_for_p: 8; // Signed byte
    } dw18;

    struct {
        uint32_t deviation_threshold_4_for_p: 8; // Signed byte
        uint32_t deviation_threshold_5_for_p: 8; // Signed byte
        uint32_t deviation_threshold_6_for_p: 8; // Signed byte
        uint32_t deviation_threshold_7_for_p: 8; // Signed byte
    } dw19;

    struct {
        uint32_t deviation_threshold_0_for_vbr: 8; // Signed byte
        uint32_t deviation_threshold_1_for_vbr: 8; // Signed byte
        uint32_t deviation_threshold_2_for_vbr: 8; // Signed byte
        uint32_t deviation_threshold_3_for_vbr: 8; // Signed byte
    } dw20;

    struct {
        uint32_t deviation_threshold_4_for_vbr: 8; // Signed byte
        uint32_t deviation_threshold_5_for_vbr: 8; // Signed byte
        uint32_t deviation_threshold_6_for_vbr: 8; // Signed byte
        uint32_t deviation_threshold_7_for_vbr: 8; // Signed byte
    } dw21;

    struct {
        uint32_t deviation_threshold_0_for_i: 8; // Signed byte
        uint32_t deviation_threshold_1_for_i: 8; // Signed byte
        uint32_t deviation_threshold_2_for_i: 8; // Signed byte
        uint32_t deviation_threshold_3_for_i: 8; // Signed byte
    } dw22;

    struct {
        uint32_t deviation_threshold_4_for_i: 8; // Signed byte
        uint32_t deviation_threshold_5_for_i: 8; // Signed byte
        uint32_t deviation_threshold_6_for_i: 8; // Signed byte
        uint32_t deviation_threshold_7_for_i: 8; // Signed byte
    } dw23;

    struct {
        uint32_t num_t_levels: 8;
        uint32_t reserved: 24;
    } dw24;

    struct {
        uint32_t reserved;
    } dw25;

    struct {
        uint32_t history_buffer_bti;
    } dw26;

    struct {
        uint32_t distortion_buffer_bti;
    } dw27;
};

#define VP8_BRC_INIT                    0
#define VP8_BRC_RESET                   1
#define NUM_VP8_BRC_RESET               2

struct i965_encoder_vp8_brc_init_reset_context {
    struct i965_gpe_context gpe_contexts[NUM_VP8_BRC_RESET];
};

struct scaling_curbe_parameters {
    unsigned int input_picture_width;
    unsigned int input_picture_height;
    char is_field_picture;
    char flatness_check_enabled;
    char mb_variance_output_enabled;
    char mb_pixel_average_output_enabled;
};

struct scaling_surface_parameters {
    struct object_surface *input_obj_surface;
    struct object_surface *output_obj_surface;
    unsigned int input_width;
    unsigned int input_height;
    unsigned int output_width;
    unsigned int output_height;
};

enum vp8_binding_table_offset_scaling {
    VP8_BTI_SCALING_FRAME_SRC_Y                 = 0,
    VP8_BTI_SCALING_FRAME_DST_Y                 = 1,
    VP8_BTI_SCALING_FIELD_TOP_SRC_Y             = 0,
    VP8_BTI_SCALING_FIELD_TOP_DST_Y             = 1,
    VP8_BTI_SCALING_FIELD_BOT_SRC_Y             = 2,
    VP8_BTI_SCALING_FIELD_BOT_DST_Y             = 3,
    VP8_BTI_SCALING_FRAME_FLATNESS_DST          = 4,
    VP8_BTI_SCALING_FIELD_TOP_FLATNESS_DST      = 4,
    VP8_BTI_SCALING_FIELD_BOT_FLATNESS_DST      = 5,
    VP8_BTI_SCALING_FRAME_MBVPROCSTATS_DST      = 6,
    VP8_BTI_SCALING_FIELD_TOP_MBVPROCSTATS_DST  = 6,
    VP8_BTI_SCALING_FIELD_BOT_MBVPROCSTATS_DST  = 7,
    VP8_BTI_SCALING_NUM_SURFACES                = 8
};

struct vp8_scaling_curbe_data {
    struct {
        uint32_t input_picture_width: 16;
        uint32_t input_picture_height: 16;
    } dw0;

    union {
        uint32_t input_y_bti_frame;
        uint32_t input_y_bti_top_field;
    } dw1;

    union {
        uint32_t output_y_bti_frame;
        uint32_t output_y_bti_top_field;
    } dw2;

    struct {
        uint32_t input_y_bti_bottom_field;
    } dw3;

    struct {
        uint32_t output_y_bti_bottom_field;
    } dw4;

    struct {
        uint32_t flatness_threshold;
    } dw5;

    struct {
        uint32_t enable_mb_flatness_check: 1;
        uint32_t enable_mb_variance_output: 1;
        uint32_t enable_mb_pixel_average_output: 1;
        uint32_t reserved: 29;
    } dw6;

    struct {
        uint32_t reserved;
    } dw7;

    union {
        uint32_t flatness_output_bti_frame;
        uint32_t flatness_output_bti_top_field;
    } dw8;

    struct {
        uint32_t flatness_output_bti_bottom_field;
    } dw9;

    union {
        uint32_t mbv_proc_stats_bti_frame;
        uint32_t mbv_proc_stats_bti_top_field;
    } dw10;

    struct {
        uint32_t mbv_proc_stats_bti_bottom_field;
    } dw11;
};

#define VP8_SCALING_4X                  0
#define VP8_SCALING_16X                 1
#define NUM_VP8_SCALING                 2

struct i965_encoder_vp8_scaling_context {
    struct i965_gpe_context gpe_contexts[NUM_VP8_SCALING];
};

enum VP8_ME_MODES {
    VP8_ME_MODE_ME16X_BEFORE_ME4X       = 0,
    VP8_ME_MODE_ME16X_ONLY              = 1,
    VP8_ME_MODE_ME4X_ONLY               = 2,
    VP8_ME_MODE_ME4X_AFTER_ME16X        = 3
};

struct me_curbe_parameters {
    unsigned int down_scaled_width_in_mbs;
    unsigned int down_scaled_height_in_mbs;
    int use_16x_me;
};

struct me_surface_parameters {
    int use_16x_me;
};

struct vp8_search_path_delta {
    char search_path_delta_x: 4;
    char search_path_delta_y: 4;
};

enum vp8_binding_table_offset_me {
    VP8_BTI_ME_MV_DATA                  = 0,
    VP8_BTI_16X_ME_MV_DATA              = 2,
    VP8_BTI_ME_DISTORTION               = 3,
    VP8_BTI_ME_MIN_DIST_BRC_DATA        = 4,
    VP8_BTI_VME_INTER_PRED              = 5,
    VP8_BTI_ME_REF1_PIC                 = 6,
    VP8_BTI_ME_REF2_PIC                 = 8,
    VP8_BTI_ME_REF3_PIC                 = 10,
    VP8_BTI_ME_NUM_SURFACES             = 11
};

struct vp8_me_curbe_data {
    struct {
        uint32_t skip_mode_enable: 1;
        uint32_t adaptive_enable: 1;
        uint32_t bi_mix_dis: 1;
        uint32_t reserved0: 2;
        uint32_t early_ime_success_enable: 1;
        uint32_t reserved1: 1;
        uint32_t t8x8_flag_for_inter_enable: 1;
        uint32_t reserved2: 16;
        uint32_t early_ime_stop: 8;
    } dw0;

    struct {
        uint32_t max_num_mvs: 6;
        uint32_t reserved0: 10;
        uint32_t bi_weight: 6;
        uint32_t reserved1: 6;
        uint32_t uni_mix_disable: 1;
        uint32_t reserved2: 3;
    } dw1;

    struct {
        uint32_t max_len_sp: 8;
        uint32_t max_num_su: 8;
        uint32_t reserved0: 16;
    } dw2;

    struct {
        uint32_t src_size: 2;
        uint32_t reserved0: 2;
        uint32_t mb_type_remap: 2;
        uint32_t src_Access: 1;
        uint32_t ref_access: 1;
        uint32_t search_ctrl: 3;
        uint32_t dual_search_path_option: 1;
        uint32_t sub_pel_mode: 2;
        uint32_t skip_type: 1;
        uint32_t disable_field_cache_allocation: 1;
        uint32_t inter_chroma_mode: 1;
        uint32_t ft_enable: 1;
        uint32_t bme_disable_fbr: 1;
        uint32_t block_based_skip_enable: 1;
        uint32_t inter_sad: 2;
        uint32_t intra_sad: 2;
        uint32_t sub_mb_part_mask: 7;
        uint32_t reserved1: 1;
    } dw3;

    struct {
        uint32_t reserved0: 8;
        uint32_t picture_height_minus1: 8;
        uint32_t picture_width: 8;
        uint32_t reserved1: 8;
    } dw4;

    struct {
        uint32_t reserved0: 8;
        uint32_t qp_prime_y: 8;
        uint32_t ref_width: 8;
        uint32_t ref_height: 8;

    } dw5;

    struct {
        uint32_t reserved0: 3;
        uint32_t me_mode: 2;
        uint32_t reserved1: 3;
        uint32_t super_combine_dist: 8;
        uint32_t max_vmv_range: 16;
    } dw6;

    struct {
        uint32_t reserved0: 16;
        uint32_t mv_cost_scale_factor: 2;
        uint32_t bilinear_enable: 1;
        uint32_t src_field_polarity: 1;
        uint32_t weightedsad_harr: 1;
        uint32_t ac_only_haar: 1;
        uint32_t ref_id_cost_mode: 1;
        uint32_t reserved1: 1;
        uint32_t skip_center_mask: 8;
    } dw7;

    struct {
        uint32_t mode_0_cost: 8;
        uint32_t mode_1_cost: 8;
        uint32_t mode_2_cost: 8;
        uint32_t mode_3_cost: 8;
    } dw8;

    struct {
        uint32_t mode_4_cost: 8;
        uint32_t mode_5_cost: 8;
        uint32_t mode_6_cost: 8;
        uint32_t mode_7_cost: 8;
    } dw9;

    struct {
        uint32_t mode_8_cost: 8;
        uint32_t mode_9_cost: 8;
        uint32_t ref_id_cost: 8;
        uint32_t chroma_intra_mode_cost: 8;
    } dw10;

    struct {
        uint32_t mv_0_cost: 8;
        uint32_t mv_1_cost: 8;
        uint32_t mv_2_cost: 8;
        uint32_t mv_3_cost: 8;
    } dw11;

    struct {
        uint32_t mv_4_cost: 8;
        uint32_t mv_5_cost: 8;
        uint32_t mv_6_cost: 8;
        uint32_t mv_7_cost: 8;
    } dw12;

    struct {
        uint32_t num_ref_idx_l0_minus1: 8;
        uint32_t num_ref_idx_l1_minus1: 8;
        uint32_t actual_mb_width: 8;
        uint32_t actual_mb_height: 8;
    } dw13;

    struct {
        uint32_t l0_ref_pic_polarity_bits: 8;
        uint32_t l1_ref_pic_polarity_bits: 2;
        uint32_t reserved: 12;
    } dw14;

    struct {
        uint32_t reserved;
    } dw15;

    struct {
        struct vp8_search_path_delta sp_delta_0;
        struct vp8_search_path_delta sp_delta_1;
        struct vp8_search_path_delta sp_delta_2;
        struct vp8_search_path_delta sp_delta_3;
    } dw16;

    struct {
        struct vp8_search_path_delta sp_delta_4;
        struct vp8_search_path_delta sp_delta_5;
        struct vp8_search_path_delta sp_delta_6;
        struct vp8_search_path_delta sp_delta_7;
    } dw17;

    struct {
        struct vp8_search_path_delta sp_delta_8;
        struct vp8_search_path_delta sp_delta_9;
        struct vp8_search_path_delta sp_delta_10;
        struct vp8_search_path_delta sp_delta_11;
    } dw18;

    struct {
        struct vp8_search_path_delta sp_delta_12;
        struct vp8_search_path_delta sp_delta_13;
        struct vp8_search_path_delta sp_delta_14;
        struct vp8_search_path_delta sp_delta_15;
    } dw19;

    struct {
        struct vp8_search_path_delta sp_delta_16;
        struct vp8_search_path_delta sp_delta_17;
        struct vp8_search_path_delta sp_delta_18;
        struct vp8_search_path_delta sp_delta_19;
    } dw20;

    struct {
        struct vp8_search_path_delta sp_delta_20;
        struct vp8_search_path_delta sp_delta_21;
        struct vp8_search_path_delta sp_delta_22;
        struct vp8_search_path_delta sp_delta_23;
    } dw21;

    struct {
        struct vp8_search_path_delta sp_delta_24;
        struct vp8_search_path_delta sp_delta_25;
        struct vp8_search_path_delta sp_delta_26;
        struct vp8_search_path_delta sp_delta_27;
    } dw22;

    struct {
        struct vp8_search_path_delta sp_delta_28;
        struct vp8_search_path_delta sp_delta_29;
        struct vp8_search_path_delta sp_delta_30;
        struct vp8_search_path_delta sp_delta_31;
    } dw23;

    struct {
        struct vp8_search_path_delta sp_delta_32;
        struct vp8_search_path_delta sp_delta_33;
        struct vp8_search_path_delta sp_delta_34;
        struct vp8_search_path_delta sp_delta_35;
    } dw24;

    struct {
        struct vp8_search_path_delta sp_delta_36;
        struct vp8_search_path_delta sp_delta_37;
        struct vp8_search_path_delta sp_delta_38;
        struct vp8_search_path_delta sp_delta_39;
    } dw25;

    struct {
        struct vp8_search_path_delta sp_delta_40;
        struct vp8_search_path_delta sp_delta_41;
        struct vp8_search_path_delta sp_delta_42;
        struct vp8_search_path_delta sp_delta_43;
    } dw26;

    struct {
        struct vp8_search_path_delta sp_delta_44;
        struct vp8_search_path_delta sp_delta_45;
        struct vp8_search_path_delta sp_delta_46;
        struct vp8_search_path_delta sp_delta_47;
    } dw27;

    struct {
        struct vp8_search_path_delta sp_delta_48;
        struct vp8_search_path_delta sp_delta_49;
        struct vp8_search_path_delta sp_delta_50;
        struct vp8_search_path_delta sp_delta_51;
    } dw28;

    struct {
        struct vp8_search_path_delta sp_delta_52;
        struct vp8_search_path_delta sp_delta_53;
        struct vp8_search_path_delta sp_delta_54;
        struct vp8_search_path_delta sp_delta_55;
    } dw29;

    struct {
        uint32_t reserved0;
    } dw30;

    struct {
        uint32_t reserved0;
    } dw31;

    struct {
        uint32_t vp8_me_mv_output_data_bti;
    } dw32;

    struct {
        uint32_t vp8_me_mv_input_data_bti;
    } dw33;

    struct {
        uint32_t vp8_me_distorion_bti;
    } dw34;

    struct {
        uint32_t vp8_me_min_dist_brc_bti;
    } dw35;

    struct {
        uint32_t vp8_me_forward_ref_bti;
    } dw36;

    struct {
        uint32_t vp8_me_backward_ref_bti;
    } dw37;
};

#define VP8_ME_4X                       0
#define VP8_ME_16X                      1
#define NUM_VP8_ME                      2

struct i965_encoder_vp8_me_context {
    struct i965_gpe_context gpe_contexts[NUM_VP8_ME];
};

#define MAX_QP_VP8                      127
#define NUM_QP_VP8                      (MAX_QP_VP8 + 1)

#define DC_BIAS_SEGMENT_DEFAULT_VAL_VP8 1500

struct mbenc_surface_parameters {
    int i_frame_dist_in_use;
    struct i965_gpe_resource *me_brc_distortion_buffer;
};

enum vp8_binding_table_offset_mbenc {
    VP8_BTI_MBENC_PER_MB_OUT            = 0,
    VP8_BTI_MBENC_CURR_Y                = 1,
    VP8_BTI_MBENC_CURR_UV               = 2,

    VP8_BTI_MBENC_MB_MODE_COST_LUMA     = 3,
    VP8_BTI_MBENC_BLOCK_MODE_COST       = 4,
    VP8_BTI_MBENC_CHROMA_RECON          = 5,
    VP8_BTI_MBENC_SEGMENTATION_MAP      = 6,
    VP8_BTI_MBENC_HISTOGRAM             = 7,
    VP8_BTI_MBENC_I_VME_DEBUG_STREAMOUT = 8,
    VP8_BTI_MBENC_VME                   = 9,
    VP8_BTI_MBENC_IDIST                 = 10,
    VP8_BTI_MBENC_CURR_Y_DOWNSCALED     = 11,
    VP8_BTI_MBENC_VME_COARSE_INTRA      = 12,

    VP8_BTI_MBENC_MV_DATA_FROM_ME       = 3,
    VP8_BTI_MBENC_IND_MV_DATA           = 4,
    VP8_BTI_MBENC_REF_MB_COUNT          = 5,
    VP8_BTI_MBENC_INTER_PRED            = 8,
    VP8_BTI_MBENC_REF1_PIC              = 9,
    VP8_BTI_MBENC_REF2_PIC              = 11,
    VP8_BTI_MBENC_REF3_PIC              = 13,
    VP8_BTI_MBENC_P_PER_MB_QUANT        = 14,
    VP8_BTI_MBENC_INTER_PRED_DISTORTION = 15,
    VP8_BTI_MBENC_PRED_MV_DATA          = 16,
    VP8_BTI_MBENC_MODE_COST_UPDATE      = 17,
    VP8_BTI_MBENC_P_VME_DEBUG_STREAMOUT = 18,
    VP8_BTI_MBENC_NUM_SURFACES          = 19
};

struct vp8_mbenc_i_frame_curbe_data {
    struct {
        uint32_t frame_width: 16;
        uint32_t frame_height: 16;
    } dw0;

    struct {
        uint32_t frame_type: 1;
        uint32_t enable_segmentation: 1;
        uint32_t enable_hw_intra_prediction: 1;
        uint32_t enable_debug_dumps: 1;
        uint32_t enable_coeff_clamp: 1;
        uint32_t enable_chroma_ip_enhancement: 1;
        uint32_t enable_mpu_histogram_update: 1;
        uint32_t reserved0: 1;
        uint32_t vme_enable_tm_check: 1;
        uint32_t vme_distortion_measure: 2;
        uint32_t reserved1: 21;
    } dw1;

    struct {
        uint32_t lambda_seg_0: 16;
        uint32_t lambda_seg_1: 16;
    } dw2;

    struct {
        uint32_t lambda_seg_2: 16;
        uint32_t lambda_seg_3: 16;
    } dw3;

    struct {
        uint32_t all_dc_bias_segment_0: 16;
        uint32_t all_dc_bias_segment_1: 16;
    } dw4;

    struct {
        uint32_t all_dc_bias_segment_2: 16;
        uint32_t all_dc_bias_segment_3: 16;
    } dw5;

    struct {
        uint32_t chroma_dc_de_quant_segment_0: 16;
        uint32_t chroma_dc_de_quant_segment_1: 16;
    } dw6;

    struct {
        uint32_t chroma_dc_de_quant_segment_2: 16;
        uint32_t chroma_dc_de_quant_segment_3: 16;
    } dw7;

    struct {
        uint32_t chroma_ac_de_quant_segment0: 16;
        uint32_t chroma_ac_de_quant_segment1: 16;
    } dw8;

    struct {
        uint32_t chroma_ac_de_quant_segment2: 16;
        uint32_t chroma_ac_de_quant_segment3: 16;
    } dw9;

    struct {
        uint32_t chroma_ac0_threshold0_segment0: 16;
        uint32_t chroma_ac0_threshold1_segment0: 16;
    } dw10;

    struct {
        uint32_t chroma_ac0_threshold0_segment1: 16;
        uint32_t chroma_ac0_threshold1_segment1: 16;
    } dw11;

    struct {
        uint32_t chroma_ac0_threshold0_segment2: 16;
        uint32_t chroma_ac0_threshold1_segment2: 16;
    } dw12;

    struct {
        uint32_t chroma_ac0_threshold0_segment3: 16;
        uint32_t chroma_ac0_threshold1_segment3: 16;
    } dw13;

    struct {
        uint32_t chroma_dc_threshold0_segment0: 16;
        uint32_t chroma_dc_threshold1_segment0: 16;
    } dw14;

    struct {
        uint32_t chroma_dc_threshold2_segment0: 16;
        uint32_t chroma_dc_threshold3_segment0: 16;
    } dw15;

    struct {
        uint32_t chroma_dc_threshold0_segment1: 16;
        uint32_t chroma_dc_threshold1_segment1: 16;
    } dw16;

    struct {
        uint32_t chroma_dc_threshold2_segment1: 16;
        uint32_t chroma_dc_threshold3_segment1: 16;
    } dw17;

    struct {
        uint32_t chroma_dc_threshold0_segment2: 16;
        uint32_t chroma_dc_threshold1_segment2: 16;
    } dw18;

    struct {
        uint32_t chroma_dc_threshold2_segment2: 16;
        uint32_t chroma_dc_threshold3_segment2: 16;
    } dw19;

    struct {
        uint32_t chroma_dc_threshold0_segment3: 16;
        uint32_t chroma_dc_threshold1_segment3: 16;
    } dw20;

    struct {
        uint32_t chroma_dc_threshold2_segment3: 16;
        uint32_t chroma_dc_threshold3_segment3: 16;
    } dw21;

    struct {
        uint32_t chroma_ac1_threshold_segment0: 16;
        uint32_t chroma_ac1_threshold_segment1: 16;
    } dw22;

    struct {
        uint32_t chroma_ac1_threshold_segment2: 16;
        uint32_t chroma_ac1_threshold_segment3: 16;
    } dw23;

    struct {
        uint32_t vme_16x16_cost_segment0: 8;
        uint32_t vme_16x16_cost_segment1: 8;
        uint32_t vme_16x16_cost_segment2: 8;
        uint32_t vme_16x16_cost_segment3: 8;
    } dw24;

    struct {
        uint32_t vme_4x4_cost_segment0: 8;
        uint32_t vme_4x4_cost_segment1: 8;
        uint32_t vme_4x4_cost_segment2: 8;
        uint32_t vme_4x4_cost_segment3: 8;
    } dw25;

    struct {
        uint32_t vme_16x16_non_dc_penalty_segment0: 8;
        uint32_t vme_16x16_non_dc_penalty_segment1: 8;
        uint32_t vme_16x16_non_dc_penalty_segment2: 8;
        uint32_t vme_16x16_non_dc_penalty_segment3: 8;
    } dw26;

    struct {
        uint32_t vme_4x4_non_dc_penalty_segment0: 8;
        uint32_t vme_4x4_non_dc_penalty_segment1: 8;
        uint32_t vme_4x4_non_dc_penalty_segment2: 8;
        uint32_t vme_4x4_non_dc_penalty_segment3: 8;
    } dw27;

    struct {
        uint32_t reserved;
    } dw28;

    struct {
        uint32_t reserved;
    } dw29;

    struct {
        uint32_t reserved;
    } dw30;

    struct {
        uint32_t reserved;
    } dw31;

    struct {
        uint32_t mb_enc_per_mb_out_data_surf_bti;
    } dw32;

    struct {
        uint32_t mb_enc_curr_y_bti;
    } dw33;

    struct {
        uint32_t mb_enc_curr_uv_bti;
    } dw34;

    struct {
        uint32_t mb_mode_cost_luma_bti;
    } dw35;

    struct {
        uint32_t mb_enc_block_mode_cost_bti;
    } dw36;

    struct {
        uint32_t chroma_recon_surf_bti;
    } dw37;

    struct {
        uint32_t segmentation_map_bti;
    } dw38;

    struct {
        uint32_t histogram_bti;
    } dw39;

    struct {
        uint32_t mb_enc_vme_debug_stream_out_bti;
    } dw40;

    struct {
        uint32_t vme_bti;
    } dw41;

    struct {
        uint32_t idist_surface_bti;
    } dw42;

    struct {
        uint32_t curr_y_down_scaled_bti;
    } dw43;

    struct {
        uint32_t vme_coarse_intra_bti;
    } dw44;
};

struct vp8_mbenc_p_frame_curbe_data {
    struct {
        uint32_t frame_width: 16;
        uint32_t frame_height: 16;
    } dw0;

    struct {
        uint32_t frame_type: 1;
        uint32_t multiple_pred: 2;
        uint32_t hme_enable: 1;
        uint32_t hme_combine_overlap: 2;
        uint32_t all_fractional: 1;
        uint32_t enable_temporal_scalability: 1;
        uint32_t hme_combined_extra_su: 8;
        uint32_t ref_frame_flags: 4;
        uint32_t enable_segmentation: 1;
        uint32_t enable_segmentation_info_update: 1;
        uint32_t enable_coeff_clamp: 1;
        uint32_t multi_reference_qp_check: 1;
        uint32_t mode_cost_enable_flag: 1;
        uint32_t main_ref: 6;
        uint32_t enable_debug_dumps: 1;
    } dw1;

    struct {
        uint32_t lambda_intra_segment0: 16;
        uint32_t lambda_inter_segment0: 16;
    } dw2;

    struct {
        uint32_t lambda_intra_segment1: 16;
        uint32_t lambda_inter_segment1: 16;
    } dw3;

    struct {
        uint32_t lambda_intra_segment2: 16;
        uint32_t lambda_inter_segment2: 16;
    } dw4;

    struct {
        uint32_t lambda_intra_segment3: 16;
        uint32_t lambda_inter_segment3: 16;
    } dw5;

    struct {
        uint32_t reference_frame_sign_bias_0: 8;
        uint32_t reference_frame_sign_bias_1: 8;
        uint32_t reference_frame_sign_bias_2: 8;
        uint32_t reference_frame_sign_bias_3: 8;
    } dw6;

    struct {
        uint32_t raw_dist_threshold: 16;
        uint32_t temporal_layer_id: 8;
        uint32_t reserved_mbz: 8;
    } dw7;

    struct {
        uint32_t skip_mode_enable: 1;
        uint32_t adaptive_search_enable: 1;
        uint32_t bidirectional_mix_disbale: 1;
        uint32_t reserved_mbz1: 2;
        uint32_t early_ime_success_enable: 1;
        uint32_t reserved_mbz2: 1;
        uint32_t transform8x8_flag_for_inter_enable: 1;
        uint32_t reserved_mbz3: 16;
        uint32_t early_ime_successful_stop_threshold: 8;
    } dw8;

    struct {
        uint32_t max_num_of_motion_vectors: 6;
        uint32_t reserved_mbz1: 2;
        uint32_t ref_id_polarity_bits: 8;
        uint32_t bidirectional_weight: 6;
        uint32_t reserved_mbz2: 6;
        uint32_t unidirection_mix_enable: 1;
        uint32_t ref_pixel_bias_enable: 1;
        uint32_t reserved_mbz3: 2;
    } dw9;

    struct {
        uint32_t max_fixed_search_path_length: 8;
        uint32_t maximum_search_path_length: 8;
        uint32_t reserved_mbz: 16;
    } dw10;

    struct {
        uint32_t source_block_size: 2;
        uint32_t reserved_mbz1: 2;
        uint32_t inter_mb_type_road_map: 2;
        uint32_t source_access: 1;
        uint32_t reference_access: 1;
        uint32_t search_control: 3;
        uint32_t dual_search_path_option: 1;
        uint32_t sub_pel_mode: 2;
        uint32_t skip_mode_type: 1;
        uint32_t disable_field_cache_allocation: 1;
        uint32_t process_inter_chroma_pixels_mode: 1;
        uint32_t forward_trans_form_skip_check_enable: 1;
        uint32_t bme_disable_for_fbr_message: 1;
        uint32_t block_based_skip_enable: 1;
        uint32_t inter_sad_measure_adjustment: 2;
        uint32_t intra_sad_measure_adjustment: 2;
        uint32_t submacro_block_subPartition_mask: 6;
        uint32_t reserved_mbz2: 1;
    } dw11;

    struct {
        uint32_t reserved_mbz: 16;
        uint32_t reference_search_windows_width: 8;
        uint32_t reference_search_windows_height: 8;
    } dw12;

    struct {
        uint32_t mode_0_3_cost_seg0;
    } dw13;

    struct {
        uint32_t mode_4_7_cost_seg0;
    } dw14;

    struct {
        uint32_t mode_8_9_ref_id_chroma_cost_seg0;
    } dw15;

    struct {
        struct vp8_search_path_delta sp_delta_0;
        struct vp8_search_path_delta sp_delta_1;
        struct vp8_search_path_delta sp_delta_2;
        struct vp8_search_path_delta sp_delta_3;
    } dw16;

    struct {
        struct vp8_search_path_delta sp_delta_4;
        struct vp8_search_path_delta sp_delta_5;
        struct vp8_search_path_delta sp_delta_6;
        struct vp8_search_path_delta sp_delta_7;
    } dw17;

    struct {
        struct vp8_search_path_delta sp_delta_8;
        struct vp8_search_path_delta sp_delta_9;
        struct vp8_search_path_delta sp_delta_10;
        struct vp8_search_path_delta sp_delta_11;
    } dw18;

    struct {
        struct vp8_search_path_delta sp_delta_12;
        struct vp8_search_path_delta sp_delta_13;
        struct vp8_search_path_delta sp_delta_14;
        struct vp8_search_path_delta sp_delta_15;
    } dw19;

    struct {
        struct vp8_search_path_delta sp_delta_16;
        struct vp8_search_path_delta sp_delta_17;
        struct vp8_search_path_delta sp_delta_18;
        struct vp8_search_path_delta sp_delta_19;
    } dw20;

    struct {
        struct vp8_search_path_delta sp_delta_20;
        struct vp8_search_path_delta sp_delta_21;
        struct vp8_search_path_delta sp_delta_22;
        struct vp8_search_path_delta sp_delta_23;
    } dw21;

    struct {
        struct vp8_search_path_delta sp_delta_24;
        struct vp8_search_path_delta sp_delta_25;
        struct vp8_search_path_delta sp_delta_26;
        struct vp8_search_path_delta sp_delta_27;
    } dw22;

    struct {
        struct vp8_search_path_delta sp_delta_28;
        struct vp8_search_path_delta sp_delta_29;
        struct vp8_search_path_delta sp_delta_30;
        struct vp8_search_path_delta sp_delta_31;
    } dw23;

    struct {
        struct vp8_search_path_delta sp_delta_32;
        struct vp8_search_path_delta sp_delta_33;
        struct vp8_search_path_delta sp_delta_34;
        struct vp8_search_path_delta sp_delta_35;
    } dw24;

    struct {
        struct vp8_search_path_delta sp_delta_36;
        struct vp8_search_path_delta sp_delta_37;
        struct vp8_search_path_delta sp_delta_38;
        struct vp8_search_path_delta sp_delta_39;
    } dw25;

    struct {
        struct vp8_search_path_delta sp_delta_40;
        struct vp8_search_path_delta sp_delta_41;
        struct vp8_search_path_delta sp_delta_42;
        struct vp8_search_path_delta sp_delta_43;
    };

    struct {
        struct vp8_search_path_delta sp_delta_44;
        struct vp8_search_path_delta sp_delta_45;
        struct vp8_search_path_delta sp_delta_46;
        struct vp8_search_path_delta sp_delta_47;
    } dw27;

    struct {
        struct vp8_search_path_delta sp_delta_48;
        struct vp8_search_path_delta sp_delta_49;
        struct vp8_search_path_delta sp_delta_50;
        struct vp8_search_path_delta sp_delta_51;
    } dw28;

    struct {
        struct vp8_search_path_delta sp_delta_52;
        struct vp8_search_path_delta sp_delta_53;
        struct vp8_search_path_delta sp_delta_54;
        struct vp8_search_path_delta sp_delta_55;
    } dw29;

    struct {
        uint32_t mv_0_3_cost_seg0;
    } dw30;

    struct {
        uint32_t mv_4_7_cost_seg0;
    } dw31;

    struct {
        uint32_t intra_16x16_no_dc_penalty_segment0: 8;
        uint32_t intra_16x16_no_dc_penalty_segment1: 8;
        uint32_t reserved_mbz1: 7;
        uint32_t bilinear_enable: 1;
        uint32_t reserved_mbz2: 8;
    } dw32;

    struct {
        uint32_t hme_combine_len: 16;
        uint32_t intra_16x16_no_dc_penalty_segment2: 8;
        uint32_t intra_16x16_no_dc_penalty_segment3: 8;
    } dw33;

    struct {
        uint32_t mv_ref_cost_context_0_0_0: 16;
        uint32_t mv_ref_cost_context_0_0_1: 16;
    } dw34;

    struct {
        uint32_t mv_ref_cost_context_0_1_0: 16;
        uint32_t mv_ref_cost_context_0_1_1: 16;
    } dw35;

    struct {
        uint32_t mv_ref_cost_context_0_2_0: 16;
        uint32_t mv_ref_cost_context_0_2_1: 16;
    } dw36;

    struct {
        uint32_t mv_ref_cost_context_0_3_0: 16;
        uint32_t mv_ref_cost_context_0_3_1: 16;
    } dw37;

    struct {
        uint32_t mv_ref_cost_context_1_0_0: 16;
        uint32_t mv_ref_cost_context_1_0_1: 16;
    } dw38;

    struct {
        uint32_t mv_ref_cost_context_1_1_0: 16;
        uint32_t mv_ref_cost_context_1_1_1: 16;
    } dw39;

    struct {
        uint32_t mv_ref_cost_context_1_2_0: 16;
        uint32_t mv_ref_cost_context_1_2_1: 16;
    } dw40;

    struct {
        uint32_t mv_ref_cost_context_1_3_0: 16;
        uint32_t mv_ref_cost_context_1_3_1: 16;
    } dw41;

    struct {
        uint32_t mv_ref_cost_context_2_0_0: 16;
        uint32_t mv_ref_cost_context_2_0_1: 16;
    };

    struct {
        uint32_t mv_ref_cost_context_2_1_0: 16;
        uint32_t mv_ref_cost_context_2_1_1: 16;
    };

    struct {
        uint32_t mv_ref_cost_context_2_2_0: 16;
        uint32_t mv_ref_cost_context_2_2_1: 16;
    } dw44;

    struct {
        uint32_t mv_ref_cost_context_2_3_0: 16;
        uint32_t mv_ref_cost_context_2_3_1: 16;
    } dw45;

    struct {
        uint32_t mv_ref_cost_context_3_0_0: 16;
        uint32_t mv_ref_cost_context_3_0_1: 16;
    } dw46;

    struct {
        uint32_t mv_ref_cost_context_3_1_0: 16;
        uint32_t mv_ref_cost_context_3_1_1: 16;
    } dw47;

    struct {
        uint32_t mv_ref_cost_context_3_2_0: 16;
        uint32_t mv_ref_cost_context_3_2_1: 16;
    } dw48;

    struct {
        uint32_t mv_ref_cost_context_3_3_0: 16;
        uint32_t mv_ref_cost_context_3_3_1: 16;
    } dw49;

    struct {
        uint32_t mv_ref_cost_context_4_0_0: 16;
        uint32_t mv_ref_cost_context_4_0_1: 16;
    } dw50;

    struct {
        uint32_t mv_ref_cost_context_4_1_0: 16;
        uint32_t mv_ref_cost_context_4_1_1: 16;
    } dw51;

    struct {
        uint32_t mv_ref_cost_context_4_2_0: 16;
        uint32_t mv_ref_cost_context_4_2_1: 16;
    };

    struct {
        uint32_t mv_ref_cost_context_4_3_0: 16;
        uint32_t mv_ref_cost_context_4_3_1: 16;
    };

    struct {
        uint32_t mv_ref_cost_context_5_0_0: 16;
        uint32_t mv_ref_cost_context_5_0_1: 16;
    };

    struct {
        uint32_t mv_ref_cost_context_5_1_0: 16;
        uint32_t mv_ref_cost_context_5_1_1: 16;
    } dw55;

    struct {
        uint32_t mv_ref_cost_context_5_2_0: 16;
        uint32_t mv_ref_cost_context_5_2_1: 16;
    } dw56;

    struct {
        uint32_t mv_ref_cost_context_5_3_0: 16;
        uint32_t mv_ref_cost_context_5_3_1: 16;
    } dw57;

    struct {
        uint32_t enc_cost_16x16: 16;
        uint32_t enc_cost_16x8: 16;
    } dw58;

    struct {
        uint32_t enc_cost_8x8: 16;
        uint32_t enc_cost_4x4: 16;
    } dw59;

    struct {
        uint32_t frame_count_probability_ref_frame_cost_0: 16;
        uint32_t frame_count_probability_ref_frame_cost_1: 16;
    } dw60;

    struct {
        uint32_t frame_count_probability_ref_frame_cost_2: 16;
        uint32_t frame_count_probability_ref_frame_cost_3: 16;
    } dw61;

    struct {
        uint32_t average_qp_of_last_ref_frame: 8;
        uint32_t average_qp_of_gold_ref_frame: 8;
        uint32_t average_qp_of_alt_ref_frame: 8;
        uint32_t reserved_mbz: 8;
    } dw62;

    struct {
        uint32_t intra_4x4_no_dc_penalty_segment0: 8;
        uint32_t intra_4x4_no_dc_penalty_segment1: 8;
        uint32_t intra_4x4_no_dc_penalty_segment2: 8;
        uint32_t intra_4x4_no_dc_penalty_segment3: 8;
    } dw63;

    struct {
        uint32_t mode_0_3_cost_seg1;
    } dw64;

    struct {
        uint32_t mode_4_7_cost_seg1;
    } dw65;

    struct {
        uint32_t mode_8_9_ref_id_chroma_cost_seg1;
    } dw66;

    struct {
        uint32_t mv_0_3_cost_seg1;
    } dw67;

    struct {
        uint32_t mv_4_7_cost_seg1;
    } dw68;

    struct {
        uint32_t mode_0_3_cost_seg2;
    } dw69;

    struct {
        uint32_t mode_4_7_cost_seg2;
    } dw70;

    struct {
        uint32_t mode_8_9_ref_id_chroma_cost_seg2;
    } dw71;

    struct {
        uint32_t mv_0_3_cost_seg2;
    } dw72;

    struct {
        uint32_t mv_4_7_cost_seg2;
    } dw73;

    struct {
        uint32_t mode_0_3_cost_seg3;
    } dw74;

    struct {
        uint32_t mode_4_7_cost_seg3;
    } dw75;

    struct {
        uint32_t mode_8_9_ref_id_chroma_cost_seg3;
    } dw76;

    struct {
        uint32_t mv_0_3_cost_seg3;
    } dw77;

    struct {
        uint32_t mv_4_7_cost_seg3;
    } dw78;

    struct {
        uint32_t new_mv_skip_threshold_segment0: 16;
        uint32_t new_mv_skip_threshold_segment1: 16;
    } dw79;

    struct {
        uint32_t new_mv_skip_threshold_segment2: 16;
        uint32_t new_mv_skip_threshold_segment3: 16;
    } dw80;

    struct {
        uint32_t per_mb_output_data_surface_bti;
    } dw81;

    struct {
        uint32_t current_picture_y_surface_bti;
    } dw82;

    struct {
        uint32_t current_picture_interleaved_uv_surface_bti;
    } dw83;

    struct {
        uint32_t hme_mv_data_surface_bti;
    } dw84;

    struct {
        uint32_t mv_data_surface_bti;
    } dw85;

    struct {
        uint32_t mb_count_per_reference_frame_bti;
    } dw86;

    struct {
        uint32_t vme_inter_prediction_bti;
    } dw87;

    struct {
        uint32_t active_ref1_bti;
    } dw88;

    struct {
        uint32_t active_ref2_bti;
    } dw89;

    struct {
        uint32_t active_ref3_bti;
    } dw90;

    struct {
        uint32_t per_mb_quant_data_bti;
    } dw91;

    struct {
        uint32_t segment_map_bti;
    } dw92;

    struct {
        uint32_t inter_prediction_distortion_bti;
    } dw93;

    struct {
        uint32_t histogram_bti;
    } dw94;

    struct {
        uint32_t pred_mv_data_bti;
    } dw95;

    struct {
        uint32_t mode_cost_update_bti;
    } dw96;

    struct {
        uint32_t kernel_debug_dump_bti;
    } dw97;
};

#define VP8_MBENC_I_FRAME_DIST          0
#define VP8_MBENC_I_FRAME_LUMA          1
#define VP8_MBENC_I_FRAME_CHROMA        2
#define VP8_MBENC_P_FRAME               3
#define NUM_VP8_MBENC                   4

struct i965_encoder_vp8_mbenc_context {
    struct i965_gpe_context gpe_contexts[NUM_VP8_MBENC];
    dri_bo *luma_chroma_dynamic_buffer;
};

enum vp8_binding_table_offset_brc_update {
    VP8_BTI_BRC_UPDATE_HISTORY                  = 1,
    VP8_BTI_BRC_UPDATE_PAK_STATISTICS_OUTPUT    = 2,
    VP8_BTI_BRC_UPDATE_MFX_ENCODER_CFG_READ     = 3,
    VP8_BTI_BRC_UPDATE_MFX_ENCODER_CFG_WRITE    = 4,
    VP8_BTI_BRC_UPDATE_MBENC_CURBE_READ         = 5,
    VP8_BTI_BRC_UPDATE_MBENC_CURBE_WRITE        = 6,
    VP8_BTI_BRC_UPDATE_DISTORTION_SURFACE       = 7,
    VP8_BTI_BRC_UPDATE_CONSTANT_DATA            = 8,
    VP8_BTI_BRC_UPDATE_SEGMENT_MAP              = 9,
    VP8_BTI_BRC_UPDATE_MPU_CURBE_READ           = 10,
    VP8_BTI_BRC_UPDATE_MPU_CURBE_WRITE          = 11,
    VP8_BTI_BRC_UPDATE_TPU_CURBE_READ           = 12,
    VP8_BTI_BRC_UPDATE_TPU_CURBE_WRITE          = 13,
    VP8_BTI_BRC_UPDATE_NUM_SURFACES             = 14
};

struct brc_update_surface_parameters {
    struct i965_gpe_context *mbenc_gpe_context;
    struct i965_gpe_context *mpu_gpe_context;
    struct i965_gpe_context *tpu_gpe_context;
};

struct vp8_brc_update_curbe_data {
    struct {
        uint32_t target_size;
    } dw0;

    struct {
        uint32_t frame_number;
    } dw1;

    struct {
        uint32_t picture_header_size;
    } dw2;

    struct {
        uint32_t start_global_adjust_frame0: 16;
        uint32_t start_global_adjust_frame1: 16;
    } dw3;

    struct {
        uint32_t start_global_adjust_frame2: 16;
        uint32_t start_global_adjust_frame3: 16;
    } dw4;

    struct {
        uint32_t target_size_flag: 8;
        uint32_t brc_flag: 8;
        uint32_t max_num_paks: 8;
        uint32_t curr_frame_type: 8;
    } dw5;

    struct {
        uint32_t tid: 8;
        uint32_t num_t_levels: 8;
        uint32_t reserved0: 16;
    } dw6;

    struct {
        uint32_t reserved0;
    } dw7;

    struct {
        uint32_t start_global_adjust_mult0: 8;
        uint32_t start_global_adjust_mult1: 8;
        uint32_t start_global_adjust_mult2: 8;
        uint32_t start_global_adjust_mult3: 8;
    } dw8;

    struct {
        uint32_t start_global_adjust_mult4: 8;
        uint32_t start_global_adjust_div0: 8;
        uint32_t start_global_adjust_div1: 8;
        uint32_t start_global_adjust_div2: 8;
    } dw9;

    struct {
        uint32_t start_global_adjust_div3: 8;
        uint32_t start_global_adjust_div4: 8;
        uint32_t qp_threshold0: 8;
        uint32_t qp_threshold1: 8;
    } dw10;

    struct {
        uint32_t qp_threshold2: 8;
        uint32_t qp_threshold3: 8;
        uint32_t g_rate_ratio_threshold0: 8;
        uint32_t g_rate_ratio_threshold1: 8;
    } dw11;

    struct {
        uint32_t g_rate_ratio_threshold2: 8;
        uint32_t g_rate_ratio_threshold3: 8;
        uint32_t g_rate_ratio_threshold4: 8;
        uint32_t g_rate_ratio_threshold5: 8;
    } dw12;

    struct {
        uint32_t g_rate_ratio_threshold_qp0: 8;
        uint32_t g_rate_ratio_threshold_qp1: 8;
        uint32_t g_rate_ratio_threshold_qp2: 8;
        uint32_t g_rate_ratio_threshold_qp3: 8;
    } dw13;

    struct {
        uint32_t g_rate_ratio_threshold_qp4: 8;
        uint32_t g_rate_ratio_threshold_qp5: 8;
        uint32_t g_rate_ratio_threshold_qp6: 8;
        uint32_t index_of_previous_qp: 8;
    } dw14;

    struct {
        uint32_t frame_width_in_mb: 16;
        uint32_t frame_height_in_mb: 16;
    } dw15;

    struct {
        uint32_t p_frame_qp_seg0: 8;
        uint32_t p_frame_qp_seg1: 8;
        uint32_t p_frame_qp_seg2: 8;
        uint32_t p_frame_qp_seg3: 8;
    } dw16;

    struct {
        uint32_t key_frame_qp_seg0: 8;
        uint32_t key_frame_qp_seg1: 8;
        uint32_t key_frame_qp_seg2: 8;
        uint32_t key_frame_qp_seg3: 8;
    } dw17;

    struct {
        uint32_t qdelta_plane0: 8;
        uint32_t qdelta_plane1: 8;
        uint32_t qdelta_plane2: 8;
        uint32_t qdelta_plane3: 8;
    } dw18;

    struct {
        uint32_t qdelta_plane4: 8;
        uint32_t qindex: 8;
        uint32_t main_ref: 8;
        uint32_t ref_frame_flags: 8;
    } dw19;

    struct {
        uint32_t seg_on: 8;
        uint32_t mb_rc: 8;
        uint32_t brc_method: 8;
        uint32_t vme_intra_prediction: 8;
    } dw20;

    struct {
        uint32_t current_frame_qpindex: 8;
        uint32_t last_frame_qpindex: 8;
        uint32_t gold_frame_qpindex: 8;
        uint32_t alt_frame_qpindex: 8;
    } dw21;

    struct {
        uint32_t historyt_buffer_bti;
    } dw22;

    struct {
        uint32_t pak_statistics_bti;
    } dw23;

    struct {
        uint32_t mfx_vp8_encoder_cfg_read_bti;
    } dw24;

    struct {
        uint32_t mfx_vp8_encoder_cfg_write_bti;
    } dw25;

    struct {
        uint32_t mbenc_curbe_read_bti;
    } dw26;

    struct {
        uint32_t mbenc_curbe_write_bti;
    } dw27;

    struct {
        uint32_t distortion_bti;
    } dw28;

    struct {
        uint32_t constant_data_bti;
    } dw29;

    struct {
        uint32_t segment_map_bti;
    } dw30;

    struct {
        uint32_t mpu_curbe_read_bti;
    } dw31;

    struct {
        uint32_t mpu_curbe_write_bti;
    } dw32;

    struct {
        uint32_t tpu_curbe_read_bti;
    } dw33;

    struct {
        uint32_t tpu_curbe_write_bti;
    } dw34;
};

#define VP8_BRC_UPDATE                  0
#define NUM_VP8_BRC_UPDATE              1

struct i965_encoder_vp8_brc_update_context {
    struct i965_gpe_context gpe_contexts[NUM_VP8_BRC_UPDATE];
};

enum vp8_binding_table_offset_mpu {
    VP8_BTI_MPU_HISTOGRAM               = 0,
    VP8_BTI_MPU_REF_MODE_PROBABILITY    = 1,
    VP8_BTI_MPU_CURR_MODE_PROBABILITY   = 2,
    VP8_BTI_MPU_REF_TOKEN_PROBABILITY   = 3,
    VP8_BTI_MPU_CURR_TOKEN_PROBABILITY  = 4,
    VP8_BTI_MPU_HEADER_BITSTREAM        = 5,
    VP8_BTI_MPU_HEADER_METADATA         = 6,
    VP8_BTI_MPU_PICTURE_STATE           = 7,
    VP8_BTI_MPU_MPU_BITSTREAM           = 8,
    VP8_BTI_MPU_TOKEN_BITS_DATA_TABLE   = 9,
    VP8_BTI_MPU_VME_DEBUG_STREAMOUT     = 10,
    VP8_BTI_MPU_ENTROPY_COST_TABLE      = 11,
    VP8_BTI_MPU_MODE_COST_UPDATE        = 12,
    VP8_BTI_MPU_NUM_SURFACES            = 13
};

struct vp8_mpu_curbe_data {
    struct {
        uint32_t frame_width: 16;
        uint32_t frame_height: 16;
    } dw0;

    struct {
        uint32_t frame_type: 1;
        uint32_t version: 3;
        uint32_t show_frame: 1;
        uint32_t horizontal_scale_code: 2;
        uint32_t vertical_scale_code: 2;
        uint32_t color_space_type: 1;
        uint32_t clamp_type: 1;
        uint32_t partition_num_l2: 2;
        uint32_t enable_segmentation: 1;
        uint32_t seg_map_update: 1;
        uint32_t segmentation_feature_update: 1;
        uint32_t segmentation_feature_mode: 1;
        uint32_t loop_filter_type: 1;
        uint32_t sharpness_level: 3;
        uint32_t loop_filter_adjustment_on: 1;
        uint32_t mb_no_coeffiscient_skip: 1;
        uint32_t golden_reference_copy_flag: 2;
        uint32_t alternate_reference_copy_flag: 2;
        uint32_t last_frame_update: 1;
        uint32_t sign_bias_golden: 1;
        uint32_t sign_bias_alt_ref: 1;
        uint32_t refresh_entropy_p: 1;
        uint32_t forced_lf_update_for_key_frame: 1;
    } dw1;

    struct {
        uint32_t loop_filter_level: 6;
        uint32_t reserved0: 2;
        uint32_t qindex: 7;
        uint32_t reserved1: 1;
        uint32_t y1_dc_qindex: 8;
        uint32_t y2_dc_qindex: 8;
    } dw2;

    struct {
        uint32_t y2_ac_qindex: 8;
        uint32_t uv_dc_qindex: 8;
        uint32_t uv_ac_qindex: 8;
        uint32_t feature_data0_segment0: 8;
    } dw3;

    struct {
        uint32_t feature_data0_segment1: 8;
        uint32_t feature_data0_segment2: 8;
        uint32_t feature_data0_segment3: 8;
        uint32_t feature_data1_segment0: 8;
    } dw4;

    struct {
        uint32_t feature_data1_segment1: 8;
        uint32_t feature_data1_segment2: 8;
        uint32_t feature_data1_segment3: 8;
        uint32_t ref_lf_delta0: 8;
    } dw5;

    struct {
        uint32_t ref_lf_delta1: 8;
        uint32_t ref_lf_delta2: 8;
        uint32_t ref_lf_delta3: 8;
        uint32_t mode_lf_delta0: 8;
    } dw6;

    struct {
        uint32_t mode_lf_delta1: 8;
        uint32_t mode_lf_delta2: 8;
        uint32_t mode_lf_delta3: 8;
        uint32_t forced_token_surface_read: 1;
        uint32_t mode_cost_enable_flag: 1;
        uint32_t mc_filter_select: 1;
        uint32_t chroma_full_pixel_mc_filter_mode: 1;
        uint32_t max_num_pak_passes: 4;

    } dw7;

    struct {
        uint32_t temporal_layer_id: 8;
        uint32_t num_t_levels: 8;
        uint32_t reserved: 16;
    } dw8;

    struct {
        uint32_t reserved;
    } dw9;

    struct {
        uint32_t reserved;
    } dw10;

    struct {
        uint32_t reserved;
    } dw11;

    struct {
        uint32_t histogram_bti;
    } dw12;

    struct {
        uint32_t reference_mode_probability_bti;
    } dw13;

    struct {
        uint32_t mode_probability_bti;
    } dw14;

    struct {
        uint32_t reference_token_probability_bti;
    } dw15;

    struct {
        uint32_t token_probability_bti;
    } dw16;

    struct {
        uint32_t frame_header_bitstream_bti;
    } dw17;

    struct {
        uint32_t header_meta_data_bti;
    } dw18;

    struct {
        uint32_t picture_state_bti;
    } dw19;

    struct {
        uint32_t mpu_bitstream_bti;
    } dw20;

    struct {
        uint32_t token_bits_data_bti;
    } dw21;

    struct {
        uint32_t kernel_debug_dump_bti;
    } dw22;

    struct {
        uint32_t entropy_cost_bti;
    } dw23;

    struct {
        uint32_t mode_cost_update_bti;
    } dw24;
};

struct vp8_mfx_encoder_cfg_cmd {
    union {
        struct {
            uint32_t dword_length: 12;
            uint32_t reserved: 4;
            uint32_t sub_opcode_b: 5;
            uint32_t sub_opcode_a: 3;
            uint32_t media_command_opcode: 3;
            uint32_t pipeline: 2;
            uint32_t command_type: 3;
        };

        uint32_t value;
    } dw0;

    struct {
        uint32_t performance_counter_enable: 1;
        uint32_t final_bitstream_output_disable: 1;
        uint32_t token_statistics_output_enable: 1;
        uint32_t bitstream_statistics_output_enable: 1;
        uint32_t update_segment_feature_data_flag: 1;
        uint32_t skip_final_bitstream_when_over_under_flow: 1;
        uint32_t rate_control_initial_pass: 1;
        uint32_t per_segment_delta_qindex_loop_filter_disable: 1;
        uint32_t finer_brc_enable: 1;
        uint32_t compressed_bitstream_output_disable: 1;
        uint32_t clock_gating_disable: 1;
        uint32_t reserved: 21;
    } dw1;

    struct {
        uint32_t max_frame_bit_count_rate_control_enable_mask: 1;
        uint32_t min_frame_bit_count_rate_control_enable_mask: 1;
        uint32_t max_inter_mb_bit_count_check_enable_mask: 1;
        uint32_t max_intra_mb_bit_count_check_enable_mask: 1;
        uint32_t inter_mediate_bit_buffer_overrun_enable_mask: 1;
        uint32_t final_bistream_buffer_overrun_enable_mask: 1;
        uint32_t qindex_clamp_high_mask_for_underflow: 1;
        uint32_t qindex_clamp_high_mask_for_overflow: 1;
        uint32_t reserved: 24;
    } dw2;

    struct {
        uint32_t max_inter_mb_bit_count: 12;
        uint32_t reserved0: 4;
        uint32_t max_intra_mb_bit_count_limit: 12;
        uint32_t reserved1: 4;
    } dw3;

    struct {
        uint32_t frame_bit_rate_max: 14;
        uint32_t frame_bit_rate_max_unit: 1;
        uint32_t frame_bit_rate_max_unit_mode: 1;
        uint32_t frame_bit_rate_min: 14;
        uint32_t frame_bit_rate_min_unit: 1;
        uint32_t frame_bit_rate_min_unit_mode: 1;
    } dw4;

    struct {
        uint32_t frame_delta_qindex_max0: 8;
        uint32_t frame_delta_qindex_max1: 8;
        uint32_t frame_delta_qindex_max2: 8;
        uint32_t frame_delta_qindex_max3: 8;
    } dw5;

    struct {
        uint32_t frame_delta_qindex_min0: 8;
        uint32_t frame_delta_qindex_min1: 8;
        uint32_t frame_delta_qindex_min2: 8;
        uint32_t frame_delta_qindex_min3: 8;
    } dw6;

    struct {
        uint32_t per_segment_frame_delta_qindex_max1;
    } dw7;

    struct {
        uint32_t per_segment_frame_delta_qindex_min1;
    } dw8;

    struct {
        uint32_t per_segment_frame_delta_qindex_max2;
    } dw9;

    struct {
        uint32_t per_segment_frame_delta_qindex_min2;
    } dw10;

    struct {
        uint32_t per_segment_frame_delta_qindex_max3;
    } dw11;

    struct {
        uint32_t per_segment_frame_delta_qindex_min3;
    } dw12;

    struct {
        uint32_t frame_delta_loop_filter_max0: 8;
        uint32_t frame_delta_loop_filter_max1: 8;
        uint32_t frame_delta_loop_filter_max2: 8;
        uint32_t frame_delta_loop_filter_max3: 8;
    } dw13;

    struct {
        uint32_t frame_delta_loop_filter_min0: 8;
        uint32_t frame_delta_loop_filter_min1: 8;
        uint32_t frame_delta_loop_filter_min2: 8;
        uint32_t frame_delta_loop_filter_min3: 8;
    } dw14;

    struct {
        uint32_t per_segment_frame_delta_loop_filter_max1;
    } dw15;

    struct {
        uint32_t per_segment_frame_delta_loop_filter_min1;
    } dw16;

    struct {
        uint32_t per_segment_frame_delta_loop_filter_max2;
    } dw17;

    struct {
        uint32_t per_segment_frame_delta_loop_filter_min2;
    } dw18;

    struct {
        uint32_t per_segment_frame_delta_loop_filter_max3;
    } dw19;

    struct {
        uint32_t per_segment_frame_delta_loop_filter_min3;
    } dw20;

    struct {
        uint32_t frame_bit_rate_max_delta: 15;
        uint32_t reserved0: 1;
        uint32_t frame_bit_rate_min_delta: 15;
        uint32_t reserved1: 1;
    } dw21;

    struct {
        uint32_t min_frame_w_size: 16;
        uint32_t min_frame_w_size_unit: 2;
        uint32_t reserved0: 2;
        uint32_t bitstream_format_version: 3;
        uint32_t show_frame: 1;
        uint32_t reserved1: 8;
    } dw22;

    struct {
        uint32_t horizontal_size_code: 16;
        uint32_t vertical_size_code: 16;
    } dw23;

    struct {
        uint32_t frame_header_bit_count;
    } dw24;

    struct {
        uint32_t frame_header_bin_buffer_qindex_update_pointer;
    } dw25;

    struct {
        uint32_t frame_header_bin_buffer_loopfilter_update_pointer;
    } dw26;

    struct {
        uint32_t frame_header_bin_buffer_token_update_pointer;
    } dw27;

    struct {
        uint32_t frame_header_bin_buffer_MvupdatePointer;
    } dw28;

    struct {
        uint32_t cv0_neg_clamp_value0: 4;
        uint32_t cv1: 4;
        uint32_t cv2: 4;
        uint32_t cv3: 4;
        uint32_t cv4: 4;
        uint32_t cv5: 4;
        uint32_t cv6: 4;
        uint32_t clamp_values_cv7: 4;
    } dw29;
};

struct vp8_mpu_encoder_config_parameters {
    struct i965_gpe_resource *config_buffer;
    unsigned int is_first_pass;
    unsigned int command_offset;
    unsigned int buffer_size;
};

#define VP8_MPU                         0
#define NUM_VP8_MPU                     1

struct i965_encoder_vp8_mpu_context {
    struct i965_gpe_context gpe_contexts[NUM_VP8_MPU];
    dri_bo *dynamic_buffer;
};

enum vp8_binding_table_offset_tpu {
    VP8_BTI_TPU_PAK_TOKEN_STATISTICS            = 0,
    VP8_BTI_TPU_TOKEN_UPDATE_FLAGS              = 1,
    VP8_BTI_TPU_ENTROPY_COST_TABLE              = 2,
    VP8_BTI_TPU_HEADER_BITSTREAM                = 3,
    VP8_BTI_TPU_DEFAULT_TOKEN_PROBABILITY       = 4,
    VP8_BTI_TPU_PICTURE_STATE                   = 5,
    VP8_BTI_TPU_MPU_CURBE_DATA                  = 6,
    VP8_BTI_TPU_HEADER_METADATA                 = 7,
    VP8_BTI_TPU_TOKEN_PROBABILITY               = 8,
    VP8_BTI_TPU_PAK_HW_PASS1_PROBABILITY        = 9,
    VP8_BTI_TPU_KEY_TOKEN_PROBABILITY           = 10,
    VP8_BTI_TPU_UPDATED_TOKEN_PROBABILITY       = 11,
    VP8_BTI_TPU_PAK_HW_PASS2_PROBABILITY        = 12,
    VP8_BTI_TPU_VME_DEBUG_STREAMOUT             = 13,
    VP8_BTI_TPU_REPAK_DECISION                  = 14,
    VP8_BTI_TPU_NUM_SURFACES                    = 15
};

struct vp8_tpu_curbe_data {
    struct {
        uint32_t mbs_in_frame;
    } dw0;

    struct {
        uint32_t frame_type: 1;
        uint32_t enable_segmentation: 1;
        uint32_t rebinarization_frame_hdr: 1;
        uint32_t refresh_entropy_p: 1;
        uint32_t mb_no_coeffiscient_skip: 1;
        uint32_t reserved: 27;
    } dw1;

    struct {
        uint32_t token_probability_start_offset: 16;
        uint32_t token_probability_end_offset: 16;
    } dw2;

    struct {
        uint32_t frame_header_bit_count: 16;
        uint32_t max_qp: 8;
        uint32_t min_qp: 8;
    } dw3;

    struct {
        uint32_t loop_filter_level_segment0: 8;
        uint32_t loop_filter_level_segment1: 8;
        uint32_t loop_filter_level_segment2: 8;
        uint32_t loop_filter_level_segment3: 8;
    } dw4;

    struct {
        uint32_t quantization_index_segment0: 8;
        uint32_t quantization_index_segment1: 8;
        uint32_t quantization_index_segment2: 8;
        uint32_t quantization_index_segment3: 8;
    } dw5;

    struct {
        uint32_t pak_pass_num;
    } dw6;

    struct {
        uint32_t token_cost_delta_threshold: 16;
        uint32_t skip_cost_delta_threshold: 16;
    } dw7;

    struct {
        uint32_t cumulative_dqindex01;
    } dw8;

    struct {
        uint32_t cumulative_dqindex02;
    } dw9;

    struct {
        uint32_t cumulative_loop_filter01;
    } dw10;

    struct {
        uint32_t cumulative_loop_filter02;
    } dw11;

    struct {
        uint32_t pak_token_statistics_bti;
    } dw12;

    struct {
        uint32_t token_update_flags_bti;
    } dw13;

    struct {
        uint32_t entropy_cost_table_bti;
    } dw14;

    struct {
        uint32_t frame_header_bitstream_bti;
    } dw15;

    struct {
        uint32_t default_token_probability_bti;
    } dw16;

    struct {
        uint32_t picture_state_bti;
    } dw17;

    struct {
        uint32_t mpu_curbe_data_bti;
    } dw18;

    struct {
        uint32_t header_meta_data_bti;
    } dw19;

    struct {
        uint32_t token_probability_bti;
    } dw20;

    struct {
        uint32_t pak_hardware_token_probability_pass1_bti;
    } dw21;

    struct {
        uint32_t key_frame_token_probability_bti;
    } dw22;

    struct {
        uint32_t updated_token_probability_bti;
    } dw23;

    struct {
        uint32_t pak_hardware_token_probability_pass2_bti;
    } dw24;

    struct {
        uint32_t kernel_debug_dump_bti;
    } dw25;

    struct {
        uint32_t repak_decision_surface_bti;
    } dw26;
};

#define VP8_TPU                         0
#define NUM_VP8_TPU                     1

struct i965_encoder_vp8_tpu_context {
    struct i965_gpe_context gpe_contexts[NUM_VP8_TPU];
    dri_bo *dynamic_buffer;
};

struct vp8_encoder_kernel_parameters {
    unsigned int                curbe_size;
    unsigned int                inline_data_size;
    unsigned int                external_data_size;
};

enum VP8_ENCODER_WALKER_DEGREE {
    VP8_ENCODER_NO_DEGREE       = 0,
    VP8_ENCODER_45_DEGREE,
    VP8_ENCODER_26_DEGREE,
    VP8_ENCODER_46_DEGREE,
    VP8_ENCODER_45Z_DEGREE
};

struct vp8_encoder_kernel_walker_parameter {
    unsigned int                walker_degree;
    unsigned int                use_scoreboard;
    unsigned int                scoreboard_mask;
    unsigned int                no_dependency;
    unsigned int                resolution_x;
    unsigned int                resolution_y;
};

struct vp8_encoder_scoreboard_parameters {
    unsigned int                mask;
    unsigned int                type;
    unsigned int                enable;
};

#define VP8_BRC_HISTORY_BUFFER_SIZE     704

#define VP8_BRC_SINGLE_PASS             1 /* No IPCM case */
#define VP8_BRC_MINIMUM_NUM_PASSES      2 /* 2 to cover IPCM case */
#define VP8_BRC_DEFAULT_NUM_PASSES      4
#define VP8_BRC_MAXIMUM_NUM_PASSES      7

#define VP8_BRC_IMG_STATE_SIZE_PER_PASS 128

#define VP8_BRC_CONSTANT_DATA_SIZE      2880

struct vp8_brc_pak_statistics {
    // DWORD 0
    struct {
        uint32_t bitstream_byte_count_per_frame;
    } dw0;

    // DWORD 1
    struct {
        uint32_t bitstream_byte_count_frame_no_headers;
    } dw1;

    // DWORD 2
    struct {
        uint32_t num_of_pak_passes_executed: 16;
        uint32_t reserved: 16;
    } dw2;

    // DWORD 3
    struct {
        uint32_t previous_qp: 32;
    } dw3;

    // DWORD 4 - 1st pass IMAGE_STATUS_CONTROL_MMIO
    struct {
        uint32_t max_macroblock_conformance_flag: 1;
        uint32_t frame_bit_count_over_underflow: 1;
        uint32_t reserved0: 14;
        uint32_t suggested_slice_qp_delta: 8;
        uint32_t reserved1: 8;
    } dw4;

    // DWORD 5 - 2nd pass IMAGE_STATUS_CONTROL_MMIO
    struct {
        uint32_t max_macroblock_conformance_flag: 1;
        uint32_t frame_bit_count_over_underflow: 1;
        uint32_t reserved0: 14;
        uint32_t suggested_slice_qp_delta: 8;
        uint32_t reserved1: 8;
    } dw5;

    // DWORD 6 - 3rd pass IMAGE_STATUS_CONTROL_MMIO
    struct {
        uint32_t max_macroblock_conformance_flag: 1;
        uint32_t frame_bit_count_over_underflow: 1;
        uint32_t reserved0: 14;
        uint32_t suggested_slice_qp_delta: 8;
        uint32_t reserved1: 8;
    } dw6;

    // DWORD 7 - 4th pass IMAGE_STATUS_CONTROL_MMIO
    struct {
        uint32_t max_macroblock_conformance_flag: 1;
        uint32_t frame_bit_count_over_underflow: 1;
        uint32_t reserved0: 14;
        uint32_t suggested_slice_qp_delta: 8;
        uint32_t reserved1: 8;
    } dw7;

    // DWORD 8 - 5th pass IMAGE_STATUS_CONTROL_MMIO
    struct {
        uint32_t max_macroblock_conformance_flag: 1;
        uint32_t frame_bit_count_over_underflow: 1;
        uint32_t reserved0: 14;
        uint32_t suggested_slice_qp_delta: 8;
        uint32_t reserved1: 8;
    } dw8;

    // DWORD 9 - 6th pass IMAGE_STATUS_CONTROL_MMIO
    struct {
        uint32_t max_macroblock_conformance_flag: 1;
        uint32_t frame_bit_count_over_underflow: 1;
        uint32_t reserved0: 14;
        uint32_t suggested_slice_qp_delta: 8;
        uint32_t reserved1: 8;
    } dw9;

    // DWORD 10 - 7th pass IMAGE_STATUS_CONTROL_MMIO
    struct {
        uint32_t max_macroblock_conformance_flag: 1;
        uint32_t frame_bit_count_over_underflow: 1;
        uint32_t reserved0: 14;
        uint32_t suggested_slice_qp_delta: 8;
        uint32_t reserved1: 8;
    } dw10;

    // DWORD 11
    struct {
        uint32_t reserved;
    } dw11;

    struct {
        uint32_t reserved;
    } dw12;

    struct {
        uint32_t reserved;
    } dw13;

    struct {
        uint32_t reserved;
    } dw14;

    struct {
        uint32_t reserved;
    } dw15;
};

enum vp8_media_state_type {
    VP8_MEDIA_STATE_ENC_I_FRAME_CHROMA = 0,
    VP8_MEDIA_STATE_ENC_I_FRAME_LUMA,
    VP8_MEDIA_STATE_ENC_I_FRAME_DIST,
    VP8_MEDIA_STATE_ENC_P_FRAME,
    VP8_MEDIA_STATE_16X_SCALING,
    VP8_MEDIA_STATE_4X_SCALING,
    VP8_MEDIA_STATE_16X_ME,
    VP8_MEDIA_STATE_4X_ME,
    VP8_MEDIA_STATE_BRC_INIT_RESET,
    VP8_MEDIA_STATE_BRC_UPDATE,
    VP8_MEDIA_STATE_MPU,
    VP8_MEDIA_STATE_TPU,
    VP8_NUM_MEDIA_STATES
};

struct vp8_vdbox_image_status_control {
    uint32_t max_mb_conformance_flag: 1;
    uint32_t frame_bitcount_flag: 1;
    uint32_t panic: 1;
    uint32_t missing_huffman_code: 1;
    uint32_t reserved0: 4;
    uint32_t total_num_pass: 4;
    uint32_t reserved1: 1;
    uint32_t num_pass_polarity_change: 2;
    uint32_t cumulative_slice_qp_polarity_change: 1;
    uint32_t suggested_slice_qpdelta: 8;
    uint32_t cumulative_slice_delta_qp: 8;
};

struct vp8_encode_status {
    uint32_t bitstream_byte_count_per_frame;
    uint32_t pad0;
    uint32_t image_status_mask;
    struct vp8_vdbox_image_status_control image_status_ctrl;
    uint32_t pad2;
};

struct i965_encoder_vp8_encode_status_buffer {
    dri_bo *bo;
    uint32_t base_offset;
    uint32_t size;

    uint32_t bitstream_byte_count_offset;
    uint32_t image_status_mask_offset;
    uint32_t image_status_ctrl_offset;
};

#ifndef MAX_MFX_REFERENCE_SURFACES
#define MAX_MFX_REFERENCE_SURFACES              16
#endif

struct i965_encoder_vp8_context {
    struct i965_gpe_table *gpe_table;

    struct i965_encoder_vp8_brc_init_reset_context brc_init_reset_context;
    struct i965_encoder_vp8_scaling_context scaling_context;
    struct i965_encoder_vp8_me_context me_context;
    struct i965_encoder_vp8_mbenc_context mbenc_context;
    struct i965_encoder_vp8_brc_update_context brc_update_context;
    struct i965_encoder_vp8_mpu_context mpu_context;

    struct i965_encoder_vp8_tpu_context tpu_context;

    struct i965_gpe_resource reference_frame_mb_count_buffer;
    struct i965_gpe_resource mb_mode_cost_luma_buffer;
    struct i965_gpe_resource block_mode_cost_buffer;
    struct i965_gpe_resource chroma_recon_buffer;
    struct i965_gpe_resource per_mb_quant_data_buffer;
    struct i965_gpe_resource pred_mv_data_buffer;
    struct i965_gpe_resource mode_cost_update_buffer;

    struct i965_gpe_resource brc_history_buffer;
    struct i965_gpe_resource brc_segment_map_buffer;
    struct i965_gpe_resource brc_distortion_buffer;
    struct i965_gpe_resource brc_pak_statistics_buffer;
    struct i965_gpe_resource brc_vp8_cfg_command_read_buffer;
    struct i965_gpe_resource brc_vp8_cfg_command_write_buffer;
    struct i965_gpe_resource brc_vp8_constant_data_buffer;
    struct i965_gpe_resource brc_pak_statistics_dump_buffer;

    struct i965_gpe_resource me_4x_mv_data_buffer;
    struct i965_gpe_resource me_4x_distortion_buffer;
    struct i965_gpe_resource me_16x_mv_data_buffer;

    struct i965_gpe_resource histogram_buffer;

    struct i965_gpe_resource pak_intra_row_store_scratch_buffer;
    struct i965_gpe_resource pak_deblocking_filter_row_store_scratch_buffer;
    struct i965_gpe_resource pak_mpc_row_store_scratch_buffer;
    struct i965_gpe_resource pak_stream_out_buffer;
    struct i965_gpe_resource pak_frame_header_buffer;
    struct i965_gpe_resource pak_intermediate_buffer;
    struct i965_gpe_resource pak_mpu_tpu_mode_probs_buffer;
    struct i965_gpe_resource pak_mpu_tpu_ref_mode_probs_buffer;
    struct i965_gpe_resource pak_mpu_tpu_coeff_probs_buffer;
    struct i965_gpe_resource pak_mpu_tpu_ref_coeff_probs_buffer;
    struct i965_gpe_resource pak_mpu_tpu_token_bits_data_buffer;
    struct i965_gpe_resource pak_mpu_tpu_picture_state_buffer;
    struct i965_gpe_resource pak_mpu_tpu_mpu_bitstream_buffer;
    struct i965_gpe_resource pak_mpu_tpu_tpu_bitstream_buffer;
    struct i965_gpe_resource pak_mpu_tpu_entropy_cost_table_buffer;
    struct i965_gpe_resource pak_mpu_tpu_pak_token_statistics_buffer;
    struct i965_gpe_resource pak_mpu_tpu_pak_token_update_flags_buffer;
    struct i965_gpe_resource pak_mpu_tpu_default_token_probability_buffer;
    struct i965_gpe_resource pak_mpu_tpu_key_frame_token_probability_buffer;
    struct i965_gpe_resource pak_mpu_tpu_updated_token_probability_buffer;
    struct i965_gpe_resource pak_mpu_tpu_hw_token_probability_pak_pass_2_buffer;
    struct i965_gpe_resource pak_mpu_tpu_repak_decision_buffer;

    struct i965_gpe_resource mb_coded_buffer;

    struct i965_encoder_vp8_encode_status_buffer encode_status_buffer;

    struct object_surface *ref_last_frame;
    struct object_surface *ref_gf_frame;
    struct object_surface *ref_arf_frame;

    unsigned long mv_offset;
    unsigned long mb_coded_buffer_size;

    unsigned int ref_frame_ctrl;
    unsigned int average_i_frame_qp;
    unsigned int average_p_frame_qp;

    /* TPU */
    unsigned int num_passes;
    unsigned int curr_pass;
    unsigned int repak_pass_iter_val;
    unsigned int min_pak_passes;

    unsigned int num_brc_pak_passes;

    unsigned int picture_width; /* in pixel */
    unsigned int picture_height;/* in pixel */
    unsigned int frame_width_in_mbs;
    unsigned int frame_height_in_mbs;
    unsigned int frame_width;   /* frame_width_in_mbs * 16 */
    unsigned int frame_height;  /* frame_height_in_mbs * 16 */
    unsigned int down_scaled_width_in_mb4x;
    unsigned int down_scaled_height_in_mb4x;
    unsigned int down_scaled_width_4x;
    unsigned int down_scaled_height_4x;
    unsigned int down_scaled_width_in_mb16x;
    unsigned int down_scaled_height_in_mb16x;
    unsigned int down_scaled_width_16x;
    unsigned int down_scaled_height_16x;
    unsigned int min_scaled_dimension;
    unsigned int min_scaled_dimension_in_mbs;

    unsigned int frame_type;
    unsigned int internal_rate_mode;
    unsigned short avbr_accuracy;
    unsigned short avbr_convergence;
    unsigned int frame_num;
    struct intel_fraction framerate;
    unsigned int gop_size;
    unsigned int brc_init_reset_buf_size_in_bits;
    unsigned int target_bit_rate;
    unsigned int max_bit_rate;
    unsigned int min_bit_rate;
    unsigned long init_vbv_buffer_fullness_in_bit;
    unsigned long vbv_buffer_size_in_bit;
    double brc_init_current_target_buf_full_in_bits;
    double brc_init_reset_input_bits_per_frame;

    unsigned int brc_initted: 1;
    unsigned int brc_need_reset: 1;
    unsigned int brc_mbenc_phase1_ignored: 1;
    unsigned int hme_supported: 1;
    unsigned int hme_16x_supported: 1;
    unsigned int hme_enabled            : 1;
    unsigned int hme_16x_enabled        : 1;
    unsigned int is_render_context: 1;
    unsigned int is_first_frame: 1;
    unsigned int is_first_two_frame: 1;
    unsigned int repak_supported: 1;
    unsigned int multiple_pass_brc_supported: 1;
    unsigned int use_hw_scoreboard: 1;
    unsigned int use_hw_non_stalling_scoreborad: 1;
    unsigned int ref_ctrl_optimization_done: 1;
    unsigned int brc_distortion_buffer_supported: 1;
    unsigned int brc_constant_buffer_supported: 1;
    unsigned int brc_distortion_buffer_need_reset: 1;
    unsigned int mbenc_curbe_updated_in_brc_update: 1;
    unsigned int mpu_curbe_updated_in_brc_update: 1;
    unsigned int mfx_encoder_config_command_initialized: 1;
    unsigned int tpu_curbe_updated_in_brc_update: 1;
    unsigned int tpu_required: 1;
    unsigned int submit_batchbuffer: 1;

    struct {
        dri_bo *bo;
    } post_deblocking_output;

    struct {
        dri_bo *bo;
    } pre_deblocking_output;

    struct {
        dri_bo *bo;
    } uncompressed_picture_source;

    struct {
        dri_bo *bo;
        int offset;
        int end_offset;
    } indirect_pak_bse_object;

    struct {
        dri_bo *bo;
    } deblocking_filter_row_store_scratch_buffer;

    struct {
        dri_bo *bo;
    } reference_surfaces[MAX_MFX_REFERENCE_SURFACES];

    unsigned int vdbox_idc;
    unsigned int vdbox_mmio_base;
    unsigned int idrt_entry_size;
    unsigned int mocs;
};

#endif /* I965_ENCODER_VP8_H */