Skip to content

Commit

Permalink
Merge pull request #225 from thesword53/yuv444p16
Browse files Browse the repository at this point in the history
Fix YUV444 10 and 12 bits
  • Loading branch information
elFarto authored Oct 10, 2023
2 parents 0a924c1 + d40a44f commit 7c8b677
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 49 deletions.
12 changes: 1 addition & 11 deletions src/direct/direct-export-buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,7 @@ static BackingImage *direct_allocateBackingImage(NVDriver *drv, const NVSurface
break;

case cudaVideoSurfaceFormat_YUV444_16Bit:
switch (surface->bitDepth) {
case 10:
backingImage->format = NV_FORMAT_Q410;
break;
case 12:
backingImage->format = NV_FORMAT_Q412;
break;
default:
backingImage->format = NV_FORMAT_Q416;
break;
}
backingImage->format = NV_FORMAT_Q416;
break;

case cudaVideoSurfaceFormat_YUV444:
Expand Down
41 changes: 5 additions & 36 deletions src/vabackend.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,8 @@ const NVFormatInfo formatsInfo[] =
[NV_FORMAT_P012] = {2, 2, DRM_FORMAT_P012, true, false, {{1, DRM_FORMAT_R16, {0,0}}, {2, DRM_FORMAT_RG1616, {1,1}}}, {VA_FOURCC_P012, VA_LSB_FIRST, 24, 0,0,0,0,0}},
[NV_FORMAT_P016] = {2, 2, DRM_FORMAT_P016, true, false, {{1, DRM_FORMAT_R16, {0,0}}, {2, DRM_FORMAT_RG1616, {1,1}}}, {VA_FOURCC_P016, VA_LSB_FIRST, 24, 0,0,0,0,0}},
[NV_FORMAT_444P] = {1, 3, DRM_FORMAT_YUV444, false, true, {{1, DRM_FORMAT_R8, {0,0}}, {1, DRM_FORMAT_R8, {0,0}}, {1, DRM_FORMAT_R8, {0,0}}}, {VA_FOURCC_444P, VA_LSB_FIRST, 24, 0,0,0,0,0}},
// Nvidia decoder only supports YUV444 planar formats with 3 planes so we can't use VA_FOURCC_Y410, VA_FOURCC_Y412 and VA_FOURCC_Y416.
// VA_FOURCC_Q410, VA_FOURCC_Q412 and VA_FOURCC_Q416 aren't defined in va.h yet.
#if defined(VA_FOURCC_Q410) && defined(DRM_FORMAT_Q410)
[NV_FORMAT_Q410] = {2, 3, DRM_FORMAT_Q410, true, true, {{1, DRM_FORMAT_R16, {0,0}}, {1, DRM_FORMAT_R16, {0,0}}, {1, DRM_FORMAT_R16,{0,0}}}, {VA_FOURCC_Q410, VA_LSB_FIRST, 48, 0,0,0,0,0}},
#endif
#if defined(VA_FOURCC_Q412) && defined(DRM_FORMAT_Q412)
[NV_FORMAT_Q412] = {2, 3, DRM_FORMAT_Q412, true, true, {{1, DRM_FORMAT_R16, {0,0}}, {1, DRM_FORMAT_R16, {0,0}}, {1, DRM_FORMAT_R16,{0,0}}}, {VA_FOURCC_Q412, VA_LSB_FIRST, 48, 0,0,0,0,0}},
#endif
#if defined(VA_FOURCC_Q416) && defined(DRM_FORMAT_Q416)
[NV_FORMAT_Q416] = {2, 3, DRM_FORMAT_Q416, true, true, {{1, DRM_FORMAT_R16, {0,0}}, {1, DRM_FORMAT_R16, {0,0}}, {1, DRM_FORMAT_R16,{0,0}}}, {VA_FOURCC_Q416, VA_LSB_FIRST, 48, 0,0,0,0,0}},
#if VA_CHECK_VERSION(1, 20, 0)
[NV_FORMAT_Q416] = {2, 3, DRM_FORMAT_INVALID, true, true, {{1, DRM_FORMAT_R16, {0,0}}, {1, DRM_FORMAT_R16, {0,0}}, {1, DRM_FORMAT_R16,{0,0}}}, {VA_FOURCC_Q416, VA_LSB_FIRST, 48, 0,0,0,0,0}},
#endif
};

Expand Down Expand Up @@ -505,17 +497,14 @@ static VAStatus nvQueryConfigProfiles(
profile_list[profiles++] = VAProfileAV1Profile1;
}

// Currently VAAPI doesn't support yuv444p10 yuv444p12 and yuv444p16
#if defined(VA_FOURCC_Q410) && defined(DRM_FORMAT_Q410)
#if VA_CHECK_VERSION(1, 20, 0)
if (drv->supports16BitSurface) {
if (doesGPUSupportCodec(cudaVideoCodec_HEVC, 10, cudaVideoChromaFormat_444, NULL, NULL)) {
profile_list[profiles++] = VAProfileHEVCMain444_10;
}
#if (defined(VA_FOURCC_Q412) && defined(DRM_FORMAT_Q412)) || (defined(VA_FOURCC_Q416) && defined(DRM_FORMAT_Q416))
if (doesGPUSupportCodec(cudaVideoCodec_HEVC, 12, cudaVideoChromaFormat_444, NULL, NULL)) {
profile_list[profiles++] = VAProfileHEVCMain444_12;
}
#endif
if (doesGPUSupportCodec(cudaVideoCodec_VP9, 10, cudaVideoChromaFormat_444, NULL, NULL)) {
profile_list[profiles++] = VAProfileVP9Profile3; //color depth: 10–12 bit, 4:2:2, 4:4:0, 4:4:4
}
Expand Down Expand Up @@ -1786,13 +1775,7 @@ static VAStatus nvQuerySurfaceAttributes(
int cnt = 4;
if (cfg->chromaFormat == cudaVideoChromaFormat_444) {
cnt += 1;
#ifdef VA_FOURCC_Q410
cnt += 1;
#endif
#ifdef VA_FOURCC_Q412
cnt += 1;
#endif
#ifdef VA_FOURCC_Q416
#if VA_CHECK_VERSION(1, 20, 0)
cnt += 1;
#endif
} else {
Expand Down Expand Up @@ -1848,21 +1831,7 @@ static VAStatus nvQuerySurfaceAttributes(
attrib_list[attrib_idx].value.type = VAGenericValueTypeInteger;
attrib_list[attrib_idx].value.value.i = VA_FOURCC_444P;
attrib_idx += 1;
#ifdef VA_FOURCC_Q410
attrib_list[attrib_idx].type = VASurfaceAttribPixelFormat;
attrib_list[attrib_idx].flags = 0;
attrib_list[attrib_idx].value.type = VAGenericValueTypeInteger;
attrib_list[attrib_idx].value.value.i = VA_FOURCC_Q410;
attrib_idx += 1;
#endif
#ifdef VA_FOURCC_Q412
attrib_list[attrib_idx].type = VASurfaceAttribPixelFormat;
attrib_list[attrib_idx].flags = 0;
attrib_list[attrib_idx].value.type = VAGenericValueTypeInteger;
attrib_list[attrib_idx].value.value.i = VA_FOURCC_Q412;
attrib_idx += 1;
#endif
#ifdef VA_FOURCC_Q416
#if VA_CHECK_VERSION(1, 20, 0)
attrib_list[attrib_idx].type = VASurfaceAttribPixelFormat;
attrib_list[attrib_idx].flags = 0;
attrib_list[attrib_idx].value.type = VAGenericValueTypeInteger;
Expand Down
2 changes: 0 additions & 2 deletions src/vabackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ typedef enum
NV_FORMAT_P012,
NV_FORMAT_P016,
NV_FORMAT_444P,
NV_FORMAT_Q410,
NV_FORMAT_Q412,
NV_FORMAT_Q416
} NVFormat;

Expand Down

0 comments on commit 7c8b677

Please sign in to comment.