X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Fvf_libvmaf.c;h=14c3216b3a8d63bd08140e445a2fa68ba755a2f7;hb=c53f9f436440be4e180aa3895920ef21019c076f;hp=249e50c720097e6d91bbea9b78e4d6c1461d80fc;hpb=5ca7eb36b7353f9e6af05a5a952eead5f6d326dd;p=ffmpeg diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c index 249e50c7200..14c3216b3a8 100644 --- a/libavfilter/vf_libvmaf.c +++ b/libavfilter/vf_libvmaf.c @@ -110,6 +110,7 @@ FRAMESYNC_DEFINE_CLASS(libvmaf, LIBVMAFContext, fs); const type *main_ptr = (const type *) s->gmain->data[0]; \ \ float *ptr = ref_data; \ + float factor = 1.f / (1 << (bits - 8)); \ \ int h = s->height; \ int w = s->width; \ @@ -118,7 +119,7 @@ FRAMESYNC_DEFINE_CLASS(libvmaf, LIBVMAFContext, fs); \ for (i = 0; i < h; i++) { \ for ( j = 0; j < w; j++) { \ - ptr[j] = (float)ref_ptr[j]; \ + ptr[j] = ref_ptr[j] * factor; \ } \ ref_ptr += ref_stride / sizeof(*ref_ptr); \ ptr += stride / sizeof(*ptr); \ @@ -128,7 +129,7 @@ FRAMESYNC_DEFINE_CLASS(libvmaf, LIBVMAFContext, fs); \ for (i = 0; i < h; i++) { \ for (j = 0; j < w; j++) { \ - ptr[j] = (float)main_ptr[j]; \ + ptr[j] = main_ptr[j] * factor; \ } \ main_ptr += main_stride / sizeof(*main_ptr); \ ptr += stride / sizeof(*ptr); \ @@ -234,6 +235,9 @@ static av_cold int init(AVFilterContext *ctx) s->gref = av_frame_alloc(); s->gmain = av_frame_alloc(); + if (!s->gref || !s->gmain) + return AVERROR(ENOMEM); + s->error = 0; s->vmaf_thread_created = 0;