Closed jian2x closed 1 year ago
Issue tracking link: https://github.com/oneapi-src/oneVPL/issues/79
@jian2x LookAheadDepth works on ffmpeg. Here is an example cmd: ffmpeg -v verbose -i input.264 -c:v av1_qsv -look_ahead_depth 10 -extbrc 1 output.ivf My environment is linux and it works on my env.
I tried your code on my enviroment and it doesn't work neither. It reports error code 16 but doesn't hang, so I don't know if it is the same error with yours. I change your code like this:
@@ -181,6 +181,7 @@ int main(int argc, char *argv[]) {
isDraining = true;
}
+ encSurfaceIn->Info.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
encSurfaceIn->Data.TimeStamp = next_pts;
next_pts += 90000 / FRAMERATE;
@@ -200,7 +201,9 @@ int main(int argc, char *argv[]) {
if (syncp) {
// Encode output is not available on CPU until sync operation
// completes
- sts = MFXVideoCORE_SyncOperation(session, syncp, WAIT_100_MILLISECONDS);
+ do {
+ sts = MFXVideoCORE_SyncOperation(session, syncp, WAIT_100_MILLISECONDS);
+ } while (sts == MFX_WRN_IN_EXECUTION);
printf("MFXVideoCORE_SyncOperation returned %d\n", sts);
VERIFY(MFX_ERR_NONE == sts, "MFXVideoCORE_SyncOperation error");
WriteEncodedStream(bitstream, sink);
@@ -259,5 +262,4 @@ end:
else {
return 0;
}
-
}
Then, it works on my side.
According to https://github.com/oneapi-src/oneVPL/issues/79, the LA problem is fixed. I think we can close this issue.
A cursory look at the code in the oneVPL-intel-gpu suggests this option should work for AV1. At least there are plenty of references to it in apparent AV1 code.
To test this, I modified sample_encoder.cpp to encode AV1, but as soon as I specify the LookAheadDepth option the sync operation gives error -16 (undefined behaviour).
Without this option, the encode works correctly.
Am I doing something wrong?
I also noticed that both FFmpeg and QSVEnc appear to hang when attempting to use the lookahead depth option.
I am using Windows 11 Pro, latest 3802 driver and latest oneVPL release (2022.2.5).
Here is my modified code, which sets up the extra parameters.
//============================================================================== // Copyright Intel Corporation // // SPDX-License-Identifier: MIT //==============================================================================
/// /// A minimal oneAPI Video Processing Library (oneVPL) encode application, /// using 2.x API with internal memory management /// /// @file
include "util.h"
define TARGETKBPS 4000
define FRAMERATE 30
define OUTPUT_FILE "out.av1"
define BITSTREAM_BUFFER_SIZE 2000000
define MAJOR_API_VERSION_REQUIRED 2
define MINOR_API_VERSION_REQUIRED 2
void Usage(void) { printf("\n"); printf(" Usage : hello-encode\n"); printf(" -hw use hardware implementation\n"); printf(" -sw use software implementation\n"); printf(" -i input file name (raw frames)\n"); printf(" -w input width\n"); printf(" -h input height\n\n"); printf(" Example: hello-encode -i in.i420 -w 320 -h 240\n"); printf(" To view: ffplay %s\n\n", OUTPUT_FILE); printf(" * Encode raw frames to AV1 elementary stream in %s\n\n", OUTPUT_FILE); printf(" CPU native color format is I420/yuv420p. GPU native color format is " "NV12\n"); return; }
int main(int argc, char argv[]) { // Variables used for legacy and 2.x bool isDraining = false; bool isStillGoing = true; bool isFailed = false; FILE sink = NULL; FILE source = NULL; mfxBitstream bitstream = {}; mfxFrameSurface1 encSurfaceIn = NULL; mfxSession session = NULL; mfxSyncPoint syncp = {}; mfxU32 framenum = 0; mfxStatus sts = MFX_ERR_NONE; mfxStatus sts_r = MFX_ERR_NONE; Params cliParams = {}; mfxVideoParam encodeParams = {}; mfxExtCodingOption extc = {}; mfxExtCodingOption2 extco2 = {}; mfxExtCodingOption3 extco3 = {};
end: printf("Encoded %d frames\n", framenum);
}