Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: third_party/libwebp/enc/token.c

Issue 116213006: Update libwebp to 0.4.0 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: After Blink Roll Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libwebp/enc/syntax.c ('k') | third_party/libwebp/enc/tree.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/libwebp/enc/token.c
diff --git a/third_party/libwebp/enc/token.c b/third_party/libwebp/enc/token.c
index 6a63371f71e90e81d1cc4dc8060aa8efd3eee6ba..e696642f168a60b198a5b0e6ce2451cf8fbbf3a9 100644
--- a/third_party/libwebp/enc/token.c
+++ b/third_party/libwebp/enc/token.c
@@ -20,12 +20,9 @@
#include <stdlib.h>
#include <string.h>
+#include "./cost.h"
#include "./vp8enci.h"
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
#if !defined(DISABLE_TOKEN_BUFFER)
// we use pages to reduce the number of memcpy()
@@ -238,6 +235,29 @@ int VP8EmitTokens(VP8TBuffer* const b, VP8BitWriter* const bw,
return 1;
}
+// Size estimation
+size_t VP8EstimateTokenSize(VP8TBuffer* const b, const uint8_t* const probas) {
+ size_t size = 0;
+ const VP8Tokens* p = b->pages_;
+ if (b->error_) return 0;
+ while (p != NULL) {
+ const VP8Tokens* const next = p->next_;
+ const int N = (next == NULL) ? b->left_ : 0;
+ int n = MAX_NUM_TOKEN;
+ while (n-- > N) {
+ const uint16_t token = p->tokens_[n];
+ const int bit = token & (1 << 15);
+ if (token & FIXED_PROBA_BIT) {
+ size += VP8BitCost(bit, token & 0xffu);
+ } else {
+ size += VP8BitCost(bit, probas[token & 0x3fffu]);
+ }
+ }
+ p = next;
+ }
+ return size;
+}
+
//------------------------------------------------------------------------------
#else // DISABLE_TOKEN_BUFFER
@@ -251,6 +271,3 @@ void VP8TBufferClear(VP8TBuffer* const b) {
#endif // !DISABLE_TOKEN_BUFFER
-#if defined(__cplusplus) || defined(c_plusplus)
-} // extern "C"
-#endif
« no previous file with comments | « third_party/libwebp/enc/syntax.c ('k') | third_party/libwebp/enc/tree.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698