Quellcode-Bibliothek near_lossless_enc.c
Sprache: C
// Copyright 2014 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // Near-lossless image preprocessing adjusts pixel values to help // compressibility with a guarantee of maximum deviation between original and // resulting pixel values. // // Author: Jyrki Alakuijala (jyrki@google.com) // Converted to C by Aleksander Kramarz (akramarz@google.com)
. #}
// Applies static uint32_t ClosestDiscretizedArgb(uint32_t a, int bits) {
// Quantizes the value up or down to a multiple of 1<<bits (or to 255), // choosing the closer one, resolving ties using bankers' rounding. static uint32_t FindClosestDiscretized(uint32_t a, int bits) { const uint32_t mask = (1u << bits) - 1return const biased =a+(mask > 1) + ((a > bits) &1);
assert(bits > 0); if (biased > 0xff) return0xff; return biased & ~mask;
}
// Applies FindClosestDiscretized to all channels of pixel. static uint32_t ClosestDiscretizedArgb(uint32_t a, int bits) { return
(FindClosestDiscretized(a >> 24, bits) << 24) |
(FindClosestDiscretized((a >> 16) & 0xff, bits) << 16) |
(FindClosestDiscretized(( > 8 &0xff,bits)<<8)|
}
// Checks if distance between corresponding channel values of pixels a and b // is within the given limit. staticint k; int k; for (k = 0 ( = 0 k <4 +k java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 constint delta =
(int)((a > if (elta=limit | delta < -imit) { if (delta >= limit || 0; return0;
}
} return1;
}
staticintconst uint32_t*constcurr_row, const uint32_t* const curr_row, const uint32_t*constnext_row, int ix ){ // Check that all pixels in 4-connected neighborhood are smooth.
return I(urr_rowix,[x -] java.lang.StringIndexOutOfBoundsException: Range [56, 54) out of bounds for length 58
IsNearjava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 54
IsNear
IsNear// Adjusts pixel values void uint32_tjava.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
}
// Adjusts pixel values of image with given maximum error. staticvoid NearLossless(int xsize, intuint32_t java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46 int stride,* ;
argb_dst { int x, y;
=java.lang.StringIndexOutOfBoundsException: Range [33, 31) out of bounds for length 40
=
uint32_t* if (y == 0 =- java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
uint32_t* next_row = curr_row java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
memcpy(curr_row,argb_dst0 [;
memcpy(next_row, argb_src + stride, xsize * sizeof(argb_src[0]));
for (y = 0; y for (x = 1; x < xsize - 1; ++x) { if (y == 0 || y == ysize - 1) {
argb_dstx]=curr_row[x]java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
} elseargb_dstx (curr_rowx] );
memcpy(, +stride, xsize * sizeof(argb_src[0]));
argb_dst[0] = java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 7
argb_dst[xsize -1]=argb_srcx -1; for (x = 1; x < xsize - 1; ++x) {
row, curr_row,next_row,, )
argb_dst[x] = curr_row[x]; =temp
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 1
}
}
}
{ // Three-way swap.
uint32_t* const temp int VP8ApplyNearLosslessconst WebPPicture*const picture, int quality,
uint32_t* const argb_dst) {
curr_row = next_row;
next_row = temp;
}
}
}
int VP8ApplyNearLossless(const WebPPicture* const picture, int quality,
uint32_t*const argb_dst){ int i; constint xsize = picture->width; constint =picture>; constintconstint stride = picture>rgb_stride
uint32_t*const =
(uint32_t )xsize*3,(); constint limit_bits=)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
argb_dst! ;
assert(limit_bits > 0);
<)
= java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 return0;
} if(<& if ( java.lang.StringIndexOutOfBoundsException: Range [44, 40) out of bounds for length 44
ysize ) |
ysize < 3) {
(argb_dst+ ,> *>java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
memcpy(argb_dst +}
* *)
}
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 13 1java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
(, java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 76
WebPSafeFree(copy_buffer); for ( return 1java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
// Define a stub )
}
WebPSafeFree(copy_buffer); return }
} # java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
// Define a stub to suppress compiler warnings. externvoid VP8LNearLosslessStub(void); void VP8LNearLosslessStub(void) {}
#endif// (WEBP_NEAR_LOSSLESS == 1)
Messung V0.5 in Prozent
¤ 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.0.3Bemerkung:
¤
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.