[FFmpeg-devel] [PATCH] libavutil: added a new function called av_compute_images_mse to calculate the mean squared error (MSE) between two YUV images.

Michael Niedermayer michaelni at gmx.at
Sat Jun 4 23:18:23 CEST 2011


On Sat, Jun 04, 2011 at 06:37:24PM +0200, Roger Pau Monné wrote:
> Made the suggested changes, but I haven't got enough knowledge to
> extend this function to other formats.

>  imgutils.c |   30 ++++++++++++++++++++++++++++++
>  imgutils.h |   13 +++++++++++++
>  2 files changed, 43 insertions(+)
> f092d5998b14b37e9c0ef4cdbd56858984b3a1be  0001-libavutil-added-a-new-function-called-av_compute_ima.patch
> From 5c00d2ac40cede458441df426e36b930f73a9da6 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Roger=20Pau=20Monn=E9?= <roger.pau at entel.upc.edu>
> Date: Sat, 4 Jun 2011 18:26:37 +0200
> Subject: [PATCH] libavutil: added a new function called av_compute_images_mse to calculate the mean squared error (MSE) between two YUV images.
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> 
> Signed-off-by: Roger Pau Monn� <roger.pau at entel.upc.edu>
> ---
>  libavutil/imgutils.c |   30 ++++++++++++++++++++++++++++++
>  libavutil/imgutils.h |   13 +++++++++++++
>  2 files changed, 43 insertions(+), 0 deletions(-)
> 
> diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
> index 8581150..3223d04 100644
> --- a/libavutil/imgutils.c
> +++ b/libavutil/imgutils.c
> @@ -274,3 +274,33 @@ void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
>          }
>      }
>  }
> +
> +double av_compute_images_mse(const uint8_t *ref_data[4], const uint8_t *data[4], const int linesizes[4], int width, int height, enum PixelFormat pix_fmt)
> +{
> +    const uint8_t *src_y    = ref_data[0];
> +    const uint8_t *coded_y  = data[0];
> +    const uint8_t *src_u    = ref_data[1];
> +    const uint8_t *coded_u  = data[1];
> +    const uint8_t *src_v    = ref_data[2];
> +    const uint8_t *coded_v  = data[2];
> +    int hsub = av_pix_fmt_descriptors[pix_fmt].log2_chroma_w;
> +    int vsub = av_pix_fmt_descriptors[pix_fmt].log2_chroma_h;
> +    double mse_r = 0.0;
> +
> +    for(int i = 0; i < height; i++) {
> +        for(int j = 0; j < width; j++) {
> +            if(j >= (width >> hsub) || i >= (height >> vsub))
> +                mse_r += pow(src_y[j] - coded_y[j], 2);
> +            else
> +                mse_r += pow(src_y[j] - coded_y[j] + src_u[j] - coded_u[j] + src_v[j] - coded_v[j], 2);

pow() is slow
double would make it hard to use in regression tests
the summing of luma and chroma is wrong

also this can be factorized with sse() in mpegvideo_enc.c


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Incandescent light bulbs waste a lot of energy as heat so the EU forbids them.
Their replacement, compact fluorescent lamps, much more expensive, dont fit in
many old lamps, flicker, contain toxic mercury, produce a fraction of the light
that is claimed and in a unnatural spectrum rendering colors different than
in natural light. Ah and we now need to turn the heaters up more in winter to
compensate the lower wasted heat. Who wins? Not the environment, thats for sure
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110604/bba6b959/attachment.asc>


More information about the ffmpeg-devel mailing list