[FFmpeg-devel] [PATCH] avfilter/vf_psnr: >8 bit support
Michael Niedermayer
michaelni at gmx.at
Sun Sep 8 18:50:21 CEST 2013
On Sun, Sep 08, 2013 at 02:54:43PM +0000, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
> libavfilter/vf_psnr.c | 75 ++++++++++++++++++++++++++++++++++++++++-----------
> 1 file changed, 59 insertions(+), 16 deletions(-)
>
> diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
> index ef638ff..8aa1543 100644
> --- a/libavfilter/vf_psnr.c
> +++ b/libavfilter/vf_psnr.c
> @@ -48,6 +48,11 @@ typedef struct PSNRContext {
> int nb_components;
> int planewidth[4];
> int planeheight[4];
> +
> + void (*compute_mse)(struct PSNRContext *s,
> + const uint8_t *m[4], const int ml[4],
> + const uint8_t *r[4], const int rl[4],
> + int w, int h, double mse[4]);
> } PSNRContext;
>
> #define OFFSET(x) offsetof(PSNRContext, x)
> @@ -61,7 +66,7 @@ static const AVOption psnr_options[] = {
>
> AVFILTER_DEFINE_CLASS(psnr);
>
> -static inline int pow2(int base)
> +static inline unsigned pow2(unsigned base)
> {
> return base*base;
> }
> @@ -98,6 +103,33 @@ void compute_images_mse(PSNRContext *s,
> }
> }
>
> +static inline
> +void compute_images_mse_16bit(PSNRContext *s,
> + const uint8_t *main_data[4], const int main_linesizes[4],
> + const uint8_t *ref_data[4], const int ref_linesizes[4],
> + int w, int h, double mse[4])
> +{
> + int i, c, j;
> +
> + for (c = 0; c < s->nb_components; c++) {
> + const int outw = s->planewidth[c];
> + const int outh = s->planeheight[c];
> + const uint16_t *main_line = (uint16_t *)main_data[c];
> + const uint16_t *ref_line = (uint16_t *)ref_data[c];
> + const int ref_linesize = ref_linesizes[c] / 2;
> + const int main_linesize = main_linesizes[c] / 2;
> + int64_t m = 0;
> +
> + for (i = 0; i < outh; i++) {
> + for (j = 0; j < outw; j++)
> + m += pow2(main_line[j] - ref_line[j]);
> + ref_line += ref_linesize;
> + main_line += main_linesize;
> + }
> + mse[c] = m / (outw * outh);
rounding to nearest should be better
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
You can kill me, but you cannot change the truth.
-------------- 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/20130908/c04222c0/attachment.asc>
More information about the ffmpeg-devel
mailing list