Skip to content

Commit 26d7d50

Browse files
cchunboSherry-Lin
authored andcommitted
[Encode] Enable DS and HME for ICLLP AVC VDEnc
Change-Id: I9418e50f02f64579fb2aff64df02ffe259ac1f6f Signed-off-by: Chunbo Chen <chunbo.chen@intel.com> Signed-off-by: Yang Ning <ning.yang@intel.com> Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
1 parent 1e2e148 commit 26d7d50

26 files changed

+6085
-133
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ if (BUILD_KERNELS)
6565
message(FATAL_ERROR "Failed to find IGA")
6666
endif()
6767

68+
find_program(CMC cmc)
69+
if (NOT CMC)
70+
message(FATAL_ERROR "Failed to find CMC")
71+
endif()
72+
73+
find_program(PYTHON python)
74+
if (NOT PYTHON)
75+
message(FATAL_ERROR "Failed to find PYTHON")
76+
endif()
77+
6878
add_subdirectory(Tools/MediaDriverTools)
6979
endif()
7080

Tools/MediaDriverTools/KernelBinToSource/KernelBinToSource.cpp

Lines changed: 184 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
///////////////////////////////////////////////////////////////////////////////
1+
///////////////////////////////////////////////////////////////////////////////
22
/*
3-
* Copyright (c) 2017, Intel Corporation
3+
* Copyright (c) 2019, Intel Corporation
44
*
55
* Permission is hereby granted, free of charge, to any person obtaining a
66
* copy of this software and associated documentation files (the
@@ -12,15 +12,15 @@
1212
*
1313
* The above copyright notice and this permission notice shall be included
1414
* in all copies or substantial portions of the Software.
15-
*
15+
*
1616
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1717
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1818
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1919
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
2020
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
2121
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2222
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23-
*/
23+
*/
2424
///////////////////////////////////////////////////////////////////////////////
2525

2626
#include <iostream>
@@ -33,46 +33,49 @@
3333
#include <bits/stdc++.h>
3434

3535
static const int32_t MAJ_VERSION = 1;
36-
static const int32_t MIN_VERSION = 0;
36+
static const int32_t MIN_VERSION = 1;
3737
static const char *HEADER_EXT = ".h";
3838
static const char *SOURCE_EXT = ".c";
3939
static const char *PARAM_I = "-i";
4040
static const char *PARAM_O = "-o";
4141
static const char *PARAM_V = "-v";
42+
static const char *PARAM_INDEX = "-index";
43+
static const char *PARAM_TOTAL = "-t";
44+
4245
#ifdef LINUX_
4346
static const char *FILE_SEP = "/";
4447
#else
4548
static const char *FILE_SEP = "\\";
4649
#endif
4750

4851
static const char *COPYRIGHT =
49-
"/* \n"
50-
" * Copyright (c) 2019, Intel Corporation \n"
51-
" * \n"
52-
" * Permission is hereby granted, free of charge, to any person obtaining a \n"
53-
" * copy of this software and associated documentation files (the \n"
54-
" * 'Software'), to deal in the Software without restriction, including \n"
55-
" * without limitation the rights to use, copy, modify, merge, publish, \n"
56-
" * distribute, sublicense, and/or sell copies of the Software, and to \n"
57-
" * permit persons to whom the Software is furnished to do so, subject to \n"
58-
" * the following conditions: \n"
59-
" * \n"
60-
" * The above copyright notice and this permission notice shall be included \n"
61-
" * in all copies or substantial portions of the Software. \n"
62-
" * \n"
63-
" * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS \n"
64-
" * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF \n"
65-
" * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. \n"
66-
" * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY \n"
67-
" * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, \n"
68-
" * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE \n"
69-
" * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n"
70-
"*/ \n"
71-
" \n"
72-
"//////////////////////////////////////////////////////////////////////////////// \n"
73-
"// !!! WARNING - AUTO GENERATED FILE. DO NOT EDIT DIRECTLY. !!! \n"
74-
"// Generated by KernelBinToSource.exe tool \n"
75-
"//////////////////////////////////////////////////////////////////////////////// \n"
52+
"/*\n"
53+
" * Copyright (c) 2019, Intel Corporation\n"
54+
" *\n"
55+
" * Permission is hereby granted, free of charge, to any person obtaining a\n"
56+
" * copy of this software and associated documentation files (the\n"
57+
" * 'Software'), to deal in the Software without restriction, including\n"
58+
" * without limitation the rights to use, copy, modify, merge, publish,\n"
59+
" * distribute, sublicense, and/or sell copies of the Software, and to\n"
60+
" * permit persons to whom the Software is furnished to do so, subject to\n"
61+
" * the following conditions:\n"
62+
" *\n"
63+
" * The above copyright notice and this permission notice shall be included\n"
64+
" * in all copies or substantial portions of the Software.\n"
65+
" *\n"
66+
" * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS\n"
67+
" * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n"
68+
" * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n"
69+
" * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n"
70+
" * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n"
71+
" * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n"
72+
" * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
73+
"*/\n"
74+
"\n"
75+
"////////////////////////////////////////////////////////////////////////////////\n"
76+
"// !!! WARNING - AUTO GENERATED FILE. DO NOT EDIT DIRECTLY. !!!\n"
77+
"// Generated by KernelBinToSource.exe tool\n"
78+
"////////////////////////////////////////////////////////////////////////////////\n"
7679
;
7780

7881
//-----------------------------------------------------------------------------
@@ -171,6 +174,120 @@ int32_t writeHeaderFile(
171174
return iStatus;
172175
}
173176

177+
//-----------------------------------------------------------------------------
178+
// Writes Partial Source file
179+
//-----------------------------------------------------------------------------
180+
int32_t writePartialSourceFile(
181+
const uint32_t *pBuffer,
182+
uint32_t uiSize,
183+
const std::string &sFileName,
184+
const std::string &sVarName,
185+
const uint32_t &index,
186+
const uint32_t &total)
187+
{
188+
int32_t iStatus = -1;
189+
std::ofstream oOutStream;
190+
std::stringstream oSs;
191+
std::string sSizeName;
192+
std::string sPlatformName;
193+
const uint32_t uiHexLen = 11;
194+
char sHex[uiHexLen];
195+
uint32_t offset_size = 0;
196+
uint32_t final_size = (uiSize + total) * sizeof(uint32_t);
197+
uint32_t stub = 0;
198+
199+
oOutStream.open(sFileName.c_str(), std::ios::out | std::ios::trunc );
200+
if (!oOutStream.is_open())
201+
{
202+
printf("Error: Unable to open file '%s' for writing\n", sFileName.c_str());
203+
goto finish;
204+
}
205+
206+
sSizeName = "extern const unsigned int " + sVarName + "_SIZE";
207+
208+
sPlatformName = sVarName;
209+
sPlatformName.erase(0, sPlatformName.find_first_of('G',3) + 1);
210+
211+
oSs << COPYRIGHT << std::endl;
212+
oSs << "#ifdef IGFX_GEN" << sPlatformName.c_str() << "_SUPPORTED" << std::endl;
213+
oSs << sSizeName.c_str() << " = " << final_size << ";" << std::endl
214+
<< "extern const unsigned int " << sVarName.c_str() << "[] ="
215+
<< std::endl << "{";
216+
217+
for(stub = 0; stub < total; stub++)
218+
{
219+
if (stub % 8 == 0)
220+
{
221+
oSs << std::endl << " ";
222+
}
223+
224+
if( stub == index + 1)
225+
{
226+
offset_size = uiSize * sizeof(uint32_t);
227+
}
228+
229+
snprintf(sHex, uiHexLen, "0x%08x", offset_size);
230+
231+
sHex[uiHexLen - 1] = '\0';
232+
233+
if (stub % 8 == 7)
234+
{
235+
oSs << sHex << ",";
236+
}else
237+
{
238+
oSs << sHex << ", ";
239+
}
240+
}
241+
242+
for (uint32_t i = 0; i < uiSize; i++)
243+
{
244+
if ((i + stub) % 8 == 0)
245+
{
246+
oSs << std::endl << " ";
247+
}
248+
249+
snprintf(sHex, uiHexLen, "0x%08x", pBuffer[i]);
250+
sHex[uiHexLen - 1] = '\0';
251+
oSs << sHex;
252+
253+
if (i < (uiSize - 1))
254+
{
255+
if ((i + stub) % 8 == 7)
256+
{
257+
oSs << ",";
258+
}
259+
else
260+
{
261+
oSs << ", ";
262+
}
263+
}
264+
}
265+
266+
oSs << std::endl << "};" << std::endl;
267+
268+
//Dummy kernel filled with 216 bytes
269+
oSs << "#else" << std::endl
270+
<< sSizeName.c_str() << " = 216;" << std::endl
271+
<< "extern const unsigned int " << sVarName.c_str() << "[] = {" << std::endl
272+
<< " 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000," << std::endl
273+
<< "};" << std::endl
274+
<< "#endif" << std::endl;
275+
276+
oOutStream << oSs.rdbuf();
277+
278+
printf("Source file '%s' generated successfully!\n", sFileName.c_str());
279+
280+
iStatus = 0;
281+
282+
finish:
283+
if (oOutStream.is_open())
284+
{
285+
oOutStream.close();
286+
}
287+
288+
return iStatus;
289+
}
290+
174291
//-----------------------------------------------------------------------------
175292
// Writes the Source file
176293
//-----------------------------------------------------------------------------
@@ -225,6 +342,7 @@ int32_t writeSourceFile(
225342
}
226343
oSs << std::endl << "};" << std::endl;
227344

345+
//Dummy kernel filled with 216 bytes
228346
oSs << "#else" << std::endl
229347
<< sSizeName.c_str() << " = 216;" << std::endl
230348
<< "extern const unsigned int " << sVarName.c_str() << "[] = {" << std::endl
@@ -253,7 +371,9 @@ int32_t writeSourceFile(
253371
int32_t createSourceFile(
254372
const std::string &sInputFile,
255373
const std::string &sOutputDir,
256-
const std::string &sVar)
374+
const std::string &sVar,
375+
const uint32_t &index,
376+
const uint32_t &total)
257377
{
258378
struct stat StatResult;
259379
int32_t iStatus = -1;
@@ -316,7 +436,7 @@ int32_t createSourceFile(
316436
pBuffer = new uint32_t[uiIntSize];
317437
pBuffer[uiIntSize - 1] = 0; // set the last entry as 0 for handling non uint32_t file sizes.
318438
oInStream.read(reinterpret_cast<char*>(pBuffer), uiSize);
319-
439+
320440
if (oInStream.bad())
321441
{
322442
printf("Error: Unable to read from file '%s'\n", sInputFile.c_str());
@@ -325,7 +445,13 @@ int32_t createSourceFile(
325445

326446
{
327447
std::transform(sVarName.begin(), sVarName.end(), sVarName.begin(), ::toupper);
328-
iStatus = writeSourceFile(pBuffer, uiIntSize, sOutputFile, sVarName);
448+
449+
if(index == -1)
450+
{
451+
iStatus = writeSourceFile(pBuffer, uiIntSize, sOutputFile, sVarName);
452+
}else{
453+
iStatus = writePartialSourceFile(pBuffer, uiIntSize, sOutputFile, sVarName, index, total);
454+
}
329455
}
330456

331457
finish:
@@ -445,10 +571,15 @@ void printUsage(const std::string &sProgram)
445571
<< " (" << PARAM_I << " InPath)"
446572
<< " [" << PARAM_O << " OutPath]"
447573
<< " [" << PARAM_V << " VarName]"
574+
<< " [" << PARAM_INDEX << " Kernel Index]"
575+
<< " [" << PARAM_TOTAL << " Kernel Total]"
448576
<< std::endl
449577
<< " " << PARAM_I << " Path to Kernel binary input file (required)" << std::endl
450578
<< " " << PARAM_O << " Path to Kernel binary output directory (optional)" << std::endl
451-
<< " " << PARAM_V << " Variable Name on the generated source file (optional)" << std::endl;
579+
<< " " << PARAM_V << " Variable Name on the generated source file (optional)" << std::endl
580+
<< " " << PARAM_INDEX << " Variable kernel Index (optional)" << std::endl
581+
<< " " << PARAM_TOTAL << " Variable kernel total count (optional)" << std::endl;
582+
452583
}
453584

454585
//-----------------------------------------------------------------------------
@@ -460,7 +591,9 @@ int32_t parseInput(
460591
const std::string &sProgram,
461592
std::string &sInput,
462593
std::string &sOutput,
463-
std::string &sVarName)
594+
std::string &sVarName,
595+
uint32_t &index,
596+
uint32_t &total)
464597
{
465598
int32_t iStatus = -1;
466599

@@ -484,6 +617,14 @@ int32_t parseInput(
484617
{
485618
sVarName = argv[i+1];
486619
}
620+
else if (0 == strcmp(PARAM_INDEX, argv[i]))
621+
{
622+
index = atoi(argv[i+1]);
623+
}
624+
else if (0 == strcmp(PARAM_TOTAL, argv[i]))
625+
{
626+
total = atoi(argv[i+1]) + 1;
627+
}
487628
else
488629
{
489630
std::cout << "Error: Invalid option " << argv[i] << std::endl;
@@ -527,21 +668,24 @@ int32_t main(int argc, char *argv[])
527668
std::string sProgram = getFileName(argv[0]);
528669
std::cout << std::endl
529670
<< sProgram.c_str() << " v" << MAJ_VERSION << "." << MIN_VERSION << std::endl
530-
<< "(c) Intel Corporation 2017. All rights reserved." << std::endl << std::endl;
671+
<< "(c) Intel Corporation 2019. All rights reserved." << std::endl << std::endl;
531672

532673
int32_t iStatus = -1;
533674
std::string sInputPath;
534675
std::string sOutputDir;
535676
std::string sVarName;
677+
uint32_t index=-1;
678+
uint32_t total=-1;
536679

537-
iStatus = parseInput(argc, argv, sProgram, sInputPath, sOutputDir, sVarName);
680+
iStatus = parseInput(argc, argv, sProgram, sInputPath, sOutputDir, sVarName, index, total);
538681
if (iStatus != 0)
539682
{
540683
goto finish;
541684
}
542685

543686
iStatus = createHeaderFile(sInputPath, sOutputDir, sVarName);
544-
iStatus = createSourceFile(sInputPath, sOutputDir, sVarName);
687+
688+
iStatus = createSourceFile(sInputPath, sOutputDir, sVarName, index, total);
545689

546690
finish:
547691
return iStatus;

media_driver/agnostic/common/codec/hal/codechal_encode_avc_base.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2018, Intel Corporation
2+
* Copyright (c) 2017-2019, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -3418,10 +3418,6 @@ void CodechalEncodeAvcBase::UpdateSSDSliceCount()
34183418

34193419
MOS_STATUS CodechalEncodeAvcBase::AddIshSize( uint32_t kuid , uint8_t* kernelBase)
34203420
{
3421-
#ifndef _FULL_OPEN_SOURCE
3422-
CODECHAL_ENCODE_CHK_NULL_RETURN(kernelBase);
3423-
#endif
3424-
34253421
uint8_t* kernelBinary;
34263422
uint32_t kernelSize;
34273423

0 commit comments

Comments
 (0)