Skip to content

Commit

Permalink
libvmaf: fail with monochrome VmafPicture in color aware feature extr…
Browse files Browse the repository at this point in the history
…actors
  • Loading branch information
kylophone authored and li-zhi committed Oct 16, 2021
1 parent d82bf17 commit c8f54f5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libvmaf/src/feature/ciede.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ static int init(VmafFeatureExtractor *fex, enum VmafPixelFormat pix_fmt,
CiedeState *s = fex->priv;
int err = 0;

if (pix_fmt == VMAF_PIX_FMT_YUV400P)
return -EINVAL;

if (pix_fmt == VMAF_PIX_FMT_YUV444P)
return 0;

Expand Down
3 changes: 3 additions & 0 deletions libvmaf/src/feature/integer_psnr.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ static int init(VmafFeatureExtractor *fex, enum VmafPixelFormat pix_fmt,
PsnrState *s = fex->priv;
s->peak = s->reduced_hbd_peak ? 255 * 1 << (bpc - 8) : (1 << bpc) - 1;

if (pix_fmt == VMAF_PIX_FMT_YUV400P)
s->enable_chroma = false;

for (unsigned i = 0; i < 3; i++) {
if (s->min_sse != 0.0) {
const int ss_hor = pix_fmt != VMAF_PIX_FMT_YUV444P;
Expand Down
15 changes: 15 additions & 0 deletions libvmaf/src/feature/third_party/xiph/psnr_hvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,20 @@ static double convert_score_db(double _score, double _weight)
return 10 * (-1 * log10(_weight * _score));
}

static int init(VmafFeatureExtractor *fex, enum VmafPixelFormat pix_fmt,
unsigned bpc, unsigned w, unsigned h)
{
(void) fex;
(void) bpc;
(void) w;
(void) h;

if (pix_fmt == VMAF_PIX_FMT_YUV400P)
return -EINVAL;
else
return 0;
}

static int extract(VmafFeatureExtractor *fex, VmafPicture *ref_pic,
VmafPicture *ref_pic_90, VmafPicture *dist_pic,
VmafPicture *dist_pic_90, unsigned index,
Expand Down Expand Up @@ -379,6 +393,7 @@ static const char *provided_features[] = {

VmafFeatureExtractor vmaf_fex_psnr_hvs = {
.name = "psnr_hvs",
.init = init,
.extract = extract,
.provided_features = provided_features,
};

0 comments on commit c8f54f5

Please sign in to comment.