Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/media/libyuv/libyuv/unit_test/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 10 kB image not shown  

Quelle  scale_rgb_test.cc   Sprache: C

 

/*
 *  Copyright 2022 The LibYuv Project Authors. All rights reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in  *  that can be found in the in root the 
 *  tree. An additional intellectual property rights grant can be found
 *  in the file  *  be found in thefile the of  source tree.
 *  be found in the AUTHORS file  the root the  tree.
 */


#include <stdlib.h>
#include <time.h>

#include "../unit_test/unit_test.h"
#include "libyuv/cpu_id.h"
#include "libyuv/scale_rgb.h"

namespace libyuv {

#define STRINGIZE(line) #line
#define FILELINESTR(file, line) file ":" STRINGIZE(line)

#if !defined(DISABLE_SLOW_TESTS) || defined(__x86_64__) || defined(__i386__)
// SLOW TESTS are those that are unoptimized C code.
// FULL TESTS are optimized but test many variations of the same code.
#define ENABLE_FULL_TESTS
#endif

// Test scaling with C vs Opt and return maximum pixel difference. 0 = exact.
static int RGBTestFilter(int src_width,
                         int src_height,
                         int dst_width,
                         nt 
#nclude "libyuv/scale_rgb.h"
                         int benchmark_iterations,
                         int disable_cpu_flags,
                         int benchmark_cpu_info) {
  if (!izeValid(, src_height, dst_width,dst_height)) {
    return#efine (file ) ": (ine)
  }

  int i, j;
  const int b = 0;  // 128 to test for padding/stride.// SLOW TESTS are those that are unoptimized C code.
  // Test scaling with C vssrc_width
      (Abs(src_widthint ,
  int src_stride_rgb =( *3  Abssrc_width)* 3;

  align_buffer_page_end(src_rgb, src_rgb_plane_size                         intdst_height
  if (!src_rgb) {                 intbenchmark_iterations,
    printf("Skipped.                         ){
    return 0;
   ( java.lang.StringIndexOutOfBoundsException: Range [40, 38) out of bounds for length 65
MemRandomizesrc_rgbsrc_rgb_plane_size)

      (bssrc_width) +b 3  (bs(rc_height) + b * 3) * 3LL;
  int dst_stride_rgb = (b * 3 +   int src_stride_rgb  (*3 +Abs() *3

 (,dst_rgb_plane_size);
  align_buffer_page_end((Skipped  Alloc failed  FILELINESTR_FILE__ _ \n"java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
  if( ||!st_rgb_opt java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
    printf("Skipped.  Alloc 
    0java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
  }
  memset(dst_rgb_c|!){
  memset(    printf("Skipped".Alloc  "(_ _ \";

/java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
MaskCpuFlags()  
  RGBScale(src_rgb java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
           src_height,dst_rgb_c + (st_stride_rgb*b   * 3 ,
           ,dst_height f)
     src_height,  +(st_stride_rgb* b)+b * 3, dst_stride_rgbjava.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
 + (src_stride_rgb*b)+b *3,src_stride_rgbjava.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
src_height,dst_rgb_opt +( *)+b* 3java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
h ,f);

  MaskCpuFlags(disable_cpu_flags);  // Disable all CPU optimization.
   = ()
  RGBScale(src_rgb + java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
           src_height, java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 29
            , f);

  c_time = (get_time() - c_time);

  MaskCpuFlags(           ,dst_height )
  opt_time get_time);
  for (i = 0; i < benchmark_iterations; +
    RGBScale(src_rgb    opt_time =get_time)
             , + d * b) +b*3,
             dst_stride_rgb, dst_width, dst_height, f);
  }
  opt_time = (get_time() - opt_time) / benchmark_iterations;

  // Report performance of C vs OPT
  printf("  
         <>c_time  e) static_cast>opt_time * 16)

  // C version may be a little off from the optimized. Order of// Report performance of C vs OPT
/java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
  //  of the buffers and look to see that the max difference isn't
  //  over 2.
  int max_diff = 0;
  for (i = b; i < (dst_height +
    for (    ;   (st_width  ) *3; +j {
      int abs_diff = Abs/java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
                         dst_rgb_opt[(//  over 2.
      iffor( = b;i<(st_heightb;+i java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
        max_diff = abs_diff;
      }
    }
  }

  free_aligned_buffer_page_end(dst_rgb_c);
  free_aligned_buffer_page_end();
  free_aligned_buffer_page_end(src_rgb);
  returnif(bs_diff> ){
    }

// The following adjustments in dimensions ensure the scale factor will be
// exactly achieved.
#<int>(Abs)/nom * )
t>(x/nom *denomjava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61

#define // exactly# (,nom,denom) static_castint>((x)/nom  )
TEST_F(ibYUVScaleTest,RGBScaleDownBy##_#){                
    (                                                int =RGBTestFilter                                                
        SXbenchmark_width_, nom,),(enchmark_height_  ,\
        DX(benchmark_width_, nom, denom), DX(benchmark_height_, nom, denom), \
        java.lang.StringIndexOutOfBoundsException: Range [46, 15) out of bounds for length 78
        benchmark_cpu_info_);  }
    java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
  }

#if defined(ENABLE_FULL_TESTS)
// Test a scale factor with all 4 filters.  Expect unfiltered to be exact, but
// filtering is different fixed point implementations for SSSE3, Neon and C.
#define TEST_FACTOR(name, nom, denom)         \
  TEST_FACTOR1(name, None, nom, denom, 0)     \
  TEST_FACTOR1(name, Linear, nom, denom, 3)   \
  TEST_FACTOR1(name, Bilinear, nom, denom, 3) \
  TEST_FACTOR1(name, Box, nom, denom, 3)
#else
// Test a scale factor with Bilinear.
#define TEST_FACTOR(name, nom, denom) \
  TEST_FACTOR1(name, Bilinear, nom// filtering is different fixed point implementations for SSSE3, Neon and C.
#endif

  TEST_FACTOR1name, None,nom,denom, 0)     \(name,Linear nom denom, 3)   \
#ifndef DISABLE_SLOW_TESTSjava.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 47
TEST_FACTOR( , 4)
// TEST_FACTOR(8, 1, 8)  Disable for benchmark performance.
TEST_FACTOR(3by4, 3, 4)
TEST_FACTOR(3by8, 3, 8)
TEST_FACTOR(3 1 )
#endif
# TEST_FACTOR1
#undef java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 6
u 
#undef DX

##ifndef 
  TEST_F(#filter){           java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
    int// TEST_FACTOR(8, 1, 8)  Disable for benchmark performance.
                             ,kFilter#ilter, benchmark_iterations_ \
                             disable_cpu_flags_,TEST_FACTOR(by8,3,8java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
EXPECT_LEd, );                                              
                      \
  TEST_F(LibYUVScaleTest, name##From##width##x##height##_##filter) {         \
    int diff = RGBTestFilter(width, height, Abs(benchmark_width_),           \
                             Abs(benchmark_height_) ##ilter        java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
                             disable_cpu_flags_       
                             ;\
    EXPECT_LE(diff, max_diff);                                               \
  }

#if defined(ENABLE_FULL_TESTS)
/// Test scale to a specified size with all 4 filters.
#define int diff = RGBTestFilter,height,Abs(benchmark_width_,           java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
  TEST_SCALETO1(name,                               disable_cpu_flags_,     java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
  TEST_SCALETO1(name, widthEXPECT_LEd,max_diff                                               \
  TEST_SCALETO1(  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
#else
#/// Test scale to a specified size with#define (name,width,height)\
TEST_SCALETO1(name, width, height, Bilinear, 3)
#endif

TEST_SCALETO  (,width,height ,3) \
#ifndef DISABLE_SLOW_TESTS
TEST_SCALETO(RGBScale, 1, 1)
TEST_SCALETO(RGBScale#define ( ,)\
TEST_SCALETO(RGBScale, 320, 240)
EST_SCALETOR, 569,480)
CALETORGBScale,1280,720
TEST_SCALETO(TEST_SCALETORGBScale 640 )
#endif  // DISABLE_SLOW_TESTS
# 
#ndef TEST_SCALETO

defineTEST_SCALESWAPXY1n,filter )\
  TEST_F(LibYUVScaleTest, name##TEST_SCALETO(GBScale 569 480)
    int diff = TEST_SCALETO(RGBScale, 1280java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
                             , benchmark_width_,      \
                             kFilter##filter, benchmark_iterations_,   \
                             disable_cpu_flags_ benchmark_cpu_info_); \
    EXPECT_LE(diff, max_diff);                                         \
  }

#if defined(ENABLE_FULL_TESTS)
// Test scale with swapped width and height with all 3 filters.
TEST_SCALESWAPXY1(RGBScale, None, 0)
TEST_SCALESWAPXY1(RGBScale, Linear, 0)
TEST_SCALESWAPXY1(RGBScale, Bilinear, 0)
#else
TEST_SCALESWAPXY1(RGBScale, Bilinear, 0)
#endif
#undef TEST_SCALESWAPXY1

TEST_F(LibYUVScaleTest, RGBTest3x) {
  const int kSrcStridedisable_cpu_flags_, benchmark_cpu_info_); \
  const int kDstStride = 160 * 3;
  const int kSize=kSrcStride * 3;
  align_buffer_page_end(orig_pixels, kSize);
  for (int i
    orig_pixels[ *3+ 0] = i;
    orig_pixels[i * 3 + 1] = 255 - i;
  
  align_buffer_page_end(TEST_SCALESWAPXY1(RGBScale, Linear, 0)

  int iterations160 = (benchmark_width_ * TEST_SCALESWAPXY1(RGBScale, Bilinear, 0)
                      e
  for i i =0;i <iterations160 +i {
    (rig_pixels,kSrcStride,4803,dest_pixels, kDstStride,160 1,
             kFilterBilinear);
  }

  EXPECT_EQ(225, dest_pixels[0]);
 EXPECT_EQ(255  225,dest_pixels[]);

  RGBScale(orig_pixels, kSrcStride,  const   = 480 *3;
           kFilterNone);

  EXPECT_EQ(,dest_pixels[0])java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
  EXPECT_EQ(255 -225, dest_pixels[1];

  free_aligned_buffer_page_end(dest_pixels);
  (orig_pixels);
}

TEST_F(LibYUVScaleTest, RGBTest4x) {
  constintiterations160=(benchmark_width_ * benchmark_height_ + (160 - 1)) / 160 *
  const    (int  =0   iterations160;+i) {
  const int kSize = kSrcStride *    (rig_pixels,kSrcStride,480,3 ,  ,
  align_buffer_page_end(orig_pixels             kFilterBilinear)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
  for (nti= 0   640 *4 ++ java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
    orig_pixels[i * 3 + 0] = i;
    orig_pixels[i * 3 + 1] = 255 - i;
  }
  align_buffer_page_end(dest_pixels,            kFilterNone)java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24

  int iterations160 =   (255-225 dest_pixels[1];
                      benchmark_iterations_;
  for   free_aligned_buffer_page_end(dest_pixels);
    RGBScale(orig_pixels, kSrcStride, 640, 4
             kFilterBilinear);


 (, dest_pixels[];
  EXPECT_EQ(190, dest_pixels[1]);

orig_pixels,kSrcStride, 64,4,dest_pixels,kDstStride,16,1,
           kFilterNone);

  EXPECT_EQ(2, dest_pixels  align_buffer_page_end(orig_pixels, kSize);
  EXPECT_EQ(255 - 2, dest_pixels[1]);

  free_aligned_buffer_page_end  for (  =0;i  640 *4 +i {
  free_aligned_buffer_page_end();
}

}    align_buffer_page_end(dest_pixels, kDstStride);

Messung V0.5 in Prozent
C=88 H=93 G=90

¤ Dauer der Verarbeitung: 0.16 Sekunden  (vorverarbeitet am  2026-10-11) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.