Skip to content
This repository was archived by the owner on May 20, 2024. It is now read-only.

Commit d322e7e

Browse files
committed
Release 2021.6.0
New in This Release =================== * Updated CPU runtime to API 2.5 * HEVC 4:2:2 planar decode support added to CPU runtime For more information on the preview C++/Python APIs and Samples, see https://software.intel.com/content/www/us/en/develop/articles/onevpl-preview-examples.html oneVPL 2021.6.0 has been updated to include functional and security updates. Users should update to the latest version.
1 parent a259736 commit d322e7e

23 files changed

+1703
-214
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ install(
5959
COMPONENT license)
6060

6161
include(cmake/PackageTarget.cmake)
62+
include(InstallRequiredSystemLibraries)
6263

6364
if(BUILD_TESTS)
6465
enable_testing()

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# oneAPI Video Processing Library CPU Implementation
1+
# ![oneAPI](assets/oneapi-logo.png "oneAPI") Video Processing Library CPU Implementation
22

33
The oneAPI Video Processing Library (oneVPL) provides a single video processing
44
API for encode, decode, and video processing that works across a wide range of
@@ -12,9 +12,9 @@ This repository contains a CPU implementation of the specification.
1212
as part of the [oneVPL base repository](https://github.com/oneapi-src/oneVPL).
1313

1414
---
15-
This project is part of the larger [oneAPI](https://www.oneapi.com/) project.
16-
See the [oneAPI Specification](https://spec.oneapi.com) and
17-
[oneVPL Specification](https://spec.oneapi.com/versions/latest/elements/oneVPL/source/index.html)
15+
This project is part of the larger [oneAPI](https://www.oneapi.io/) project.
16+
See the [oneAPI Specification](https://spec.oneapi.io) and
17+
[oneVPL Specification](https://spec.oneapi.io/versions/latest/elements/oneVPL/source/index.html)
1818
for more information.
1919

2020

@@ -61,26 +61,26 @@ Video processing (+raw frame formats) supported by the CPU software implementati
6161
|---------------|-------------|-------------|
6262

6363
Note: I420 = 8 bit/420. I010=10 bit/420.
64-
64+
6565

6666
## Installation
6767
You can install oneVPL CPU implementation:
6868

6969
- from [oneVPL home page](https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/onevpl.html) as a part of Intel® oneAPI Base Toolkit or standalone.
7070

71-
### Installation from Source
71+
### Installation from Source
7272
See [Installation from Sources](INSTALL.md) for details.
7373

7474
## Usage
7575

7676
### Configure the Environment
7777

78-
If you install to standard system locations, applications can find the dispatcher library and
78+
If you install to standard system locations, applications can find the dispatcher library and
7979
the dispatcher's default search rules will find your CPU implementation.
8080

8181
Otherwise you need to set up the environment search paths. This is easiest to manage when the
82-
install location <vpl-install-location> for oneVPL base is the same directory as used for the
83-
CPU implementation. In that case you can use the following steps:
82+
install location <vpl-install-location> for oneVPL base is the same directory as used for the
83+
CPU implementation. In that case you can use the following steps:
8484

8585
For Linux:
8686
```

assets/oneapi-logo.png

9.86 KB
Loading

cmake/oneAPIInstallDirs.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,9 @@ foreach(
7272
gnuinstalldirs_get_absolute_install_dir(ONEAPI_INSTALL_FULL_${dir}
7373
ONEAPI_INSTALL_${dir} ${dir})
7474
endforeach()
75+
76+
if(WIN32)
77+
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ${CMAKE_INSTALL_BINDIR})
78+
else()
79+
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ${CMAKE_INSTALL_LIBDIR})
80+
endif()

cpu/src/cpu_common.cpp

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ AVPixelFormat MFXFourCC2AVPixelFormat(uint32_t fourcc) {
1919
return AV_PIX_FMT_BGRA;
2020
case MFX_FOURCC_I420:
2121
return AV_PIX_FMT_YUV420P;
22+
case MFX_FOURCC_I422:
23+
return AV_PIX_FMT_YUV422P;
24+
case MFX_FOURCC_I210:
25+
return AV_PIX_FMT_YUV422P10LE;
2226
}
2327
return (AVPixelFormat)-1;
2428
}
@@ -35,8 +39,10 @@ uint32_t AVPixelFormat2MFXFourCC(int format) {
3539
return MFX_FOURCC_RGB4;
3640
case AV_PIX_FMT_YUV420P:
3741
return MFX_FOURCC_I420;
38-
default:
39-
return 0;
42+
case AV_PIX_FMT_YUV422P:
43+
return MFX_FOURCC_I422;
44+
case AV_PIX_FMT_YUV422P10LE:
45+
return MFX_FOURCC_I210;
4046
}
4147
return 0;
4248
}
@@ -95,6 +101,18 @@ mfxStatus AVFrame2mfxFrameSurface(mfxFrameSurface1 *surface,
95101
info->BitDepthChroma = 10;
96102
info->ChromaFormat = MFX_CHROMAFORMAT_YUV420;
97103
break;
104+
case AV_PIX_FMT_YUV422P10LE:
105+
info->FourCC = MFX_FOURCC_I210;
106+
info->BitDepthLuma = 10;
107+
info->BitDepthChroma = 10;
108+
info->ChromaFormat = MFX_CHROMAFORMAT_YUV422;
109+
break;
110+
case AV_PIX_FMT_YUV422P:
111+
info->FourCC = MFX_FOURCC_I422;
112+
info->BitDepthLuma = 8;
113+
info->BitDepthChroma = 8;
114+
info->ChromaFormat = MFX_CHROMAFORMAT_YUV422;
115+
break;
98116
case AV_PIX_FMT_YUV420P:
99117
case AV_PIX_FMT_YUVJ420P:
100118
info->FourCC = MFX_FOURCC_IYUV;
@@ -135,6 +153,18 @@ mfxStatus AVFrame2mfxFrameSurface(mfxFrameSurface1 *surface,
135153
w = info->Width;
136154
h = info->Height;
137155
}
156+
else if (frame->format == AV_PIX_FMT_YUV422P10LE) {
157+
RET_IF_FALSE(info->FourCC == MFX_FOURCC_I210, MFX_ERR_INCOMPATIBLE_VIDEO_PARAM);
158+
159+
w = info->Width * 2;
160+
h = info->Height;
161+
}
162+
else if (frame->format == AV_PIX_FMT_YUV422P) {
163+
RET_IF_FALSE(info->FourCC == MFX_FOURCC_I422, MFX_ERR_INCOMPATIBLE_VIDEO_PARAM);
164+
165+
w = info->Width;
166+
h = info->Height;
167+
}
138168
else if (frame->format == AV_PIX_FMT_BGRA) {
139169
RET_IF_FALSE(info->FourCC == MFX_FOURCC_RGB4, MFX_ERR_INCOMPATIBLE_VIDEO_PARAM);
140170

@@ -153,6 +183,25 @@ mfxStatus AVFrame2mfxFrameSurface(mfxFrameSurface1 *surface,
153183
memcpy_s(data->B + offset, w, frame->data[0] + y * frame->linesize[0], w);
154184
}
155185
}
186+
else if ((frame->format == AV_PIX_FMT_YUV422P) || (frame->format == AV_PIX_FMT_YUV422P10LE)) {
187+
// copy Y plane
188+
for (y = 0; y < h; y++) {
189+
offset = pitch * (y + info->CropY) + info->CropX;
190+
memcpy_s(data->Y + offset, w, frame->data[0] + y * frame->linesize[0], w);
191+
}
192+
193+
// copy U plane
194+
for (y = 0; y < h; y++) {
195+
offset = pitch / 2 * (y + info->CropY) + info->CropX;
196+
memcpy_s(data->U + offset, w / 2, frame->data[1] + y * frame->linesize[1], w / 2);
197+
}
198+
199+
// copy V plane
200+
for (y = 0; y < h; y++) {
201+
offset = pitch / 2 * (y + info->CropY) + info->CropX;
202+
memcpy_s(data->V + offset, w / 2, frame->data[2] + y * frame->linesize[2], w / 2);
203+
}
204+
}
156205
else {
157206
// copy Y plane
158207
for (y = 0; y < h; y++) {
@@ -187,6 +236,8 @@ mfxStatus CheckFrameInfoCommon(mfxFrameInfo *info, mfxU32 codecId) {
187236
switch (info->FourCC) {
188237
case MFX_FOURCC_I420:
189238
case MFX_FOURCC_I010:
239+
case MFX_FOURCC_I422:
240+
case MFX_FOURCC_I210:
190241
break;
191242
default:
192243
return MFX_ERR_INVALID_VIDEO_PARAM;
@@ -207,6 +258,7 @@ mfxStatus CheckFrameInfoCommon(mfxFrameInfo *info, mfxU32 codecId) {
207258
if (info->BitDepthLuma > 8 || info->BitDepthChroma > 8) {
208259
switch (info->FourCC) {
209260
case MFX_FOURCC_I010:
261+
case MFX_FOURCC_I210:
210262
//case MFX_FOURCC_P010: // for later
211263
break;
212264
default:
@@ -219,7 +271,9 @@ mfxStatus CheckFrameInfoCommon(mfxFrameInfo *info, mfxU32 codecId) {
219271
// RET_IF_FALSE(info->Shift, MFX_ERR_INVALID_VIDEO_PARAM);
220272
//}
221273

222-
RET_IF_FALSE(info->ChromaFormat == MFX_CHROMAFORMAT_YUV420, MFX_ERR_INVALID_VIDEO_PARAM);
274+
RET_IF_FALSE((info->ChromaFormat == MFX_CHROMAFORMAT_YUV420) ||
275+
(info->ChromaFormat == MFX_CHROMAFORMAT_YUV422),
276+
MFX_ERR_INVALID_VIDEO_PARAM);
223277
RET_IF_FALSE((info->FrameRateExtN == 0 && info->FrameRateExtD == 0) ||
224278
(info->FrameRateExtN != 0 && info->FrameRateExtD != 0),
225279
MFX_ERR_INCOMPATIBLE_VIDEO_PARAM);
@@ -242,7 +296,8 @@ mfxStatus CheckFrameInfoCodecs(mfxFrameInfo *info, mfxU32 codecId) {
242296
case MFX_CODEC_AVC:
243297
case MFX_CODEC_HEVC:
244298
case MFX_CODEC_AV1:
245-
if (info->FourCC != MFX_FOURCC_I420 && info->FourCC != MFX_FOURCC_I010)
299+
if (info->FourCC != MFX_FOURCC_I420 && info->FourCC != MFX_FOURCC_I010 &&
300+
info->FourCC != MFX_FOURCC_I422 && info->FourCC != MFX_FOURCC_I210)
246301
return MFX_ERR_INVALID_VIDEO_PARAM;
247302
break;
248303
default:
@@ -255,11 +310,13 @@ mfxStatus CheckFrameInfoCodecs(mfxFrameInfo *info, mfxU32 codecId) {
255310
case MFX_CODEC_AVC:
256311
case MFX_CODEC_HEVC:
257312
case MFX_CODEC_AV1:
258-
if (info->ChromaFormat != MFX_CHROMAFORMAT_YUV420)
313+
if (info->ChromaFormat != MFX_CHROMAFORMAT_YUV420 &&
314+
info->ChromaFormat != MFX_CHROMAFORMAT_YUV422)
259315
return MFX_ERR_INVALID_VIDEO_PARAM;
260316
break;
261317
default:
262-
RET_IF_FALSE(info->ChromaFormat == MFX_CHROMAFORMAT_YUV420,
318+
RET_IF_FALSE(info->ChromaFormat == MFX_CHROMAFORMAT_YUV420 ||
319+
info->ChromaFormat == MFX_CHROMAFORMAT_YUV422,
263320
MFX_ERR_INVALID_VIDEO_PARAM);
264321
break;
265322
}

cpu/src/cpu_common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef CPU_SRC_CPU_COMMON_H_
88
#define CPU_SRC_CPU_COMMON_H_
99

10+
#include <algorithm>
1011
#include <chrono>
1112
#include <future>
1213
#include <map>
@@ -16,8 +17,13 @@
1617

1718
#include "vpl/mfxjpeg.h"
1819
#include "vpl/mfxstructures.h"
20+
#include "vpl/mfxsurfacepool.h"
1921
#include "vpl/mfxvideo.h"
2022

23+
static inline bool operator==(mfxGUID const &l, mfxGUID const &r) {
24+
return std::equal(l.Data, l.Data + 16, r.Data);
25+
}
26+
2127
#define ENABLE_LIBAV_AUTO_THREADS
2228

2329
// TODO(m) do we need this?

cpu/src/cpu_decode.cpp

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,14 @@ mfxStatus CpuDecode::ValidateDecodeParams(mfxVideoParam *par, bool canCorrect) {
7474
if (par->mfx.NumThread)
7575
return MFX_ERR_INVALID_VIDEO_PARAM;
7676

77+
//only YUV420 or YUV422 chromaformats accepted
7778
if ((par->mfx.FrameInfo.ChromaFormat) &&
78-
(par->mfx.FrameInfo.ChromaFormat != MFX_CHROMAFORMAT_YUV420))
79+
!((par->mfx.FrameInfo.ChromaFormat == MFX_CHROMAFORMAT_YUV420) ||
80+
(par->mfx.FrameInfo.ChromaFormat == MFX_CHROMAFORMAT_YUV422)))
7981
return MFX_ERR_INVALID_VIDEO_PARAM;
8082
}
8183

82-
//only I420 and I010 colorspaces allowed
84+
//only I420, I422, I010, and and I210 colorspaces allowed
8385
switch (par->mfx.FrameInfo.FourCC) {
8486
case MFX_FOURCC_I420:
8587
if (canCorrect) {
@@ -101,6 +103,26 @@ mfxStatus CpuDecode::ValidateDecodeParams(mfxVideoParam *par, bool canCorrect) {
101103
return MFX_ERR_INVALID_VIDEO_PARAM;
102104
}
103105
break;
106+
case MFX_FOURCC_I422:
107+
if (canCorrect) {
108+
if (par->mfx.FrameInfo.BitDepthLuma && par->mfx.FrameInfo.BitDepthLuma != 8)
109+
fixedIncompatible = true;
110+
if (par->mfx.FrameInfo.BitDepthChroma && par->mfx.FrameInfo.BitDepthChroma != 8)
111+
fixedIncompatible = true;
112+
par->mfx.FrameInfo.BitDepthLuma = 8;
113+
par->mfx.FrameInfo.BitDepthChroma = 8;
114+
par->mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV422;
115+
}
116+
else {
117+
if (par->mfx.FrameInfo.BitDepthLuma && (par->mfx.FrameInfo.BitDepthLuma != 8))
118+
return MFX_ERR_INVALID_VIDEO_PARAM;
119+
if (par->mfx.FrameInfo.BitDepthChroma && (par->mfx.FrameInfo.BitDepthChroma != 8))
120+
return MFX_ERR_INVALID_VIDEO_PARAM;
121+
if (par->mfx.FrameInfo.ChromaFormat &&
122+
(par->mfx.FrameInfo.ChromaFormat != MFX_CHROMAFORMAT_YUV422))
123+
return MFX_ERR_INVALID_VIDEO_PARAM;
124+
}
125+
break;
104126
case MFX_FOURCC_I010:
105127
if (canCorrect) {
106128
if (par->mfx.FrameInfo.BitDepthLuma && par->mfx.FrameInfo.BitDepthLuma != 10)
@@ -121,6 +143,26 @@ mfxStatus CpuDecode::ValidateDecodeParams(mfxVideoParam *par, bool canCorrect) {
121143
return MFX_ERR_INVALID_VIDEO_PARAM;
122144
}
123145
break;
146+
case MFX_FOURCC_I210:
147+
if (canCorrect) {
148+
if (par->mfx.FrameInfo.BitDepthLuma && par->mfx.FrameInfo.BitDepthLuma != 10)
149+
fixedIncompatible = true;
150+
if (par->mfx.FrameInfo.BitDepthChroma && par->mfx.FrameInfo.BitDepthChroma != 10)
151+
fixedIncompatible = true;
152+
par->mfx.FrameInfo.BitDepthLuma = 10;
153+
par->mfx.FrameInfo.BitDepthChroma = 10;
154+
par->mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV422;
155+
}
156+
else {
157+
if (par->mfx.FrameInfo.BitDepthLuma && (par->mfx.FrameInfo.BitDepthLuma != 10))
158+
return MFX_ERR_INVALID_VIDEO_PARAM;
159+
if (par->mfx.FrameInfo.BitDepthChroma && (par->mfx.FrameInfo.BitDepthChroma != 10))
160+
return MFX_ERR_INVALID_VIDEO_PARAM;
161+
if (par->mfx.FrameInfo.ChromaFormat &&
162+
(par->mfx.FrameInfo.ChromaFormat != MFX_CHROMAFORMAT_YUV422))
163+
return MFX_ERR_INVALID_VIDEO_PARAM;
164+
}
165+
break;
124166
default:
125167
return MFX_ERR_INVALID_VIDEO_PARAM;
126168
}
@@ -225,8 +267,8 @@ mfxStatus CpuDecode::InitDecode(mfxVideoParam *par, mfxBitstream *bs) {
225267
// todo: this only works if input is large enough to
226268
// decode a frame
227269
mfxBitstream bs2 = *bs;
228-
bs2.DataFlag = MFX_BITSTREAM_EOS;
229-
m_bStreamInfo = true;
270+
bs2.DataFlag |= MFX_BITSTREAM_EOS;
271+
m_bStreamInfo = true;
230272
DecodeFrame(&bs2, nullptr, nullptr);
231273
GetVideoParam(par);
232274
}
@@ -420,6 +462,12 @@ mfxStatus CpuDecode::DecodeFrame(mfxBitstream *bs,
420462
case AV_PIX_FMT_YUV420P10LE:
421463
m_param.mfx.FrameInfo.FourCC = MFX_FOURCC_I010;
422464
break;
465+
case AV_PIX_FMT_YUV422P10LE:
466+
m_param.mfx.FrameInfo.FourCC = MFX_FOURCC_I210;
467+
break;
468+
case AV_PIX_FMT_YUV422P:
469+
m_param.mfx.FrameInfo.FourCC = MFX_FOURCC_I422;
470+
break;
423471
case AV_PIX_FMT_YUV420P:
424472
case AV_PIX_FMT_YUVJ420P:
425473
default:
@@ -641,6 +689,18 @@ mfxStatus CpuDecode::GetVideoParam(mfxVideoParam *par) {
641689
par->mfx.FrameInfo.BitDepthChroma = 8;
642690
par->mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
643691
break;
692+
case AV_PIX_FMT_YUV422P10LE:
693+
par->mfx.FrameInfo.FourCC = MFX_FOURCC_I210;
694+
par->mfx.FrameInfo.BitDepthLuma = 10;
695+
par->mfx.FrameInfo.BitDepthChroma = 10;
696+
par->mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV422;
697+
break;
698+
case AV_PIX_FMT_YUV422P:
699+
par->mfx.FrameInfo.FourCC = MFX_FOURCC_I422;
700+
par->mfx.FrameInfo.BitDepthLuma = 8;
701+
par->mfx.FrameInfo.BitDepthChroma = 8;
702+
par->mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV422;
703+
break;
644704
default:
645705
//zero value after decodeheader indicates that
646706
//a supported decode fourcc could not be found

cpu/src/cpu_encode.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,9 @@ mfxStatus CpuEncode::InitEncode(mfxVideoParam *par) {
518518
m_avEncContext->gop_size = par->mfx.GopPicSize;
519519
// In case Jpeg, max_b_frames must be 0, otherwise avcodec_open2()'s crashed
520520
m_avEncContext->max_b_frames =
521-
(m_param.mfx.CodecId == MFX_CODEC_JPEG) ? 0 : par->mfx.GopRefDist;
521+
(m_param.mfx.CodecId == MFX_CODEC_JPEG || par->mfx.GopRefDist == 0)
522+
? 0
523+
: (par->mfx.GopRefDist - 1);
522524
m_avEncContext->bit_rate = par->mfx.TargetKbps * 1000; // prop is in kbps;
523525

524526
m_avEncContext->framerate.num = par->mfx.FrameInfo.FrameRateExtN;

cpu/src/cpu_frame.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,25 @@ mfxStatus CpuFrame::QueryInterface(mfxFrameSurface1 *surface, mfxGUID guid, mfxH
149149
RET_IF_FALSE(surface, MFX_ERR_NULL_PTR);
150150
RET_IF_FALSE(interface, MFX_ERR_NULL_PTR);
151151

152+
CpuFrame *cpu_frame = TryCast(surface);
153+
RET_IF_FALSE(cpu_frame, MFX_ERR_INVALID_HANDLE);
154+
155+
if (guid == (mfxGUID)MFX_GUID_SURFACE_POOL) {
156+
CpuFramePoolInterface *parentPoolInterface = cpu_frame->m_parentPoolInterface;
157+
RET_IF_FALSE(parentPoolInterface, MFX_ERR_NOT_INITIALIZED);
158+
159+
mfxSurfacePoolInterface *poolInterface = &(parentPoolInterface->m_surfacePoolInterface);
160+
RET_IF_FALSE(poolInterface, MFX_ERR_NOT_INITIALIZED);
161+
162+
if (poolInterface->Context == nullptr)
163+
return MFX_ERR_NOT_INITIALIZED;
164+
165+
// increase refcount every time interface is requested via QueryInterface
166+
poolInterface->AddRef(poolInterface);
167+
168+
*interface = (mfxHDL)poolInterface;
169+
return MFX_ERR_NONE;
170+
}
171+
152172
return MFX_ERR_NOT_IMPLEMENTED;
153173
}

0 commit comments

Comments
 (0)