| OLD | NEW |
| 1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // This code is licensed under the same terms as WebM: | 3 // Use of this source code is governed by a BSD-style license |
| 4 // Software License Agreement: http://www.webmproject.org/license/software/ | 4 // that can be found in the COPYING file in the root of the source |
| 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ | 5 // tree. An additional intellectual property rights grant can be found |
| 6 // in the file PATENTS. All contributing project authors may |
| 7 // be found in the AUTHORS file in the root of the source tree. |
| 6 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
| 7 // | 9 // |
| 8 // WebP encoder: main entry point | 10 // WebP encoder: main entry point |
| 9 // | 11 // |
| 10 // Author: Skal (pascal.massimino@gmail.com) | 12 // Author: Skal (pascal.massimino@gmail.com) |
| 11 | 13 |
| 12 #include <assert.h> | 14 #include <assert.h> |
| 13 #include <stdlib.h> | 15 #include <stdlib.h> |
| 14 #include <string.h> | 16 #include <string.h> |
| 15 #include <math.h> | 17 #include <math.h> |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 } | 381 } |
| 380 | 382 |
| 381 enc = InitVP8Encoder(config, pic); | 383 enc = InitVP8Encoder(config, pic); |
| 382 if (enc == NULL) return 0; // pic->error is already set. | 384 if (enc == NULL) return 0; // pic->error is already set. |
| 383 // Note: each of the tasks below account for 20% in the progress report. | 385 // Note: each of the tasks below account for 20% in the progress report. |
| 384 ok = VP8EncAnalyze(enc); | 386 ok = VP8EncAnalyze(enc); |
| 385 | 387 |
| 386 // Analysis is done, proceed to actual coding. | 388 // Analysis is done, proceed to actual coding. |
| 387 ok = ok && VP8EncStartAlpha(enc); // possibly done in parallel | 389 ok = ok && VP8EncStartAlpha(enc); // possibly done in parallel |
| 388 if (!enc->use_tokens_) { | 390 if (!enc->use_tokens_) { |
| 389 ok = VP8EncLoop(enc); | 391 ok = ok && VP8EncLoop(enc); |
| 390 } else { | 392 } else { |
| 391 ok = VP8EncTokenLoop(enc); | 393 ok = ok && VP8EncTokenLoop(enc); |
| 392 } | 394 } |
| 393 ok = ok && VP8EncFinishAlpha(enc); | 395 ok = ok && VP8EncFinishAlpha(enc); |
| 394 #ifdef WEBP_EXPERIMENTAL_FEATURES | 396 #ifdef WEBP_EXPERIMENTAL_FEATURES |
| 395 ok = ok && VP8EncFinishLayer(enc); | 397 ok = ok && VP8EncFinishLayer(enc); |
| 396 #endif | 398 #endif |
| 397 | 399 |
| 398 ok = ok && VP8EncWrite(enc); | 400 ok = ok && VP8EncWrite(enc); |
| 399 StoreStats(enc); | 401 StoreStats(enc); |
| 400 if (!ok) { | 402 if (!ok) { |
| 401 VP8EncFreeBitWriters(enc); | 403 VP8EncFreeBitWriters(enc); |
| 402 } | 404 } |
| 403 ok &= DeleteVP8Encoder(enc); // must always be called, even if !ok | 405 ok &= DeleteVP8Encoder(enc); // must always be called, even if !ok |
| 404 } else { | 406 } else { |
| 405 // Make sure we have ARGB samples. | 407 // Make sure we have ARGB samples. |
| 406 if (pic->argb == NULL && !WebPPictureYUVAToARGB(pic)) { | 408 if (pic->argb == NULL && !WebPPictureYUVAToARGB(pic)) { |
| 407 return 0; | 409 return 0; |
| 408 } | 410 } |
| 409 | 411 |
| 410 ok = VP8LEncodeImage(config, pic); // Sets pic->error in case of problem. | 412 ok = VP8LEncodeImage(config, pic); // Sets pic->error in case of problem. |
| 411 } | 413 } |
| 412 | 414 |
| 413 return ok; | 415 return ok; |
| 414 } | 416 } |
| 415 | 417 |
| 416 #if defined(__cplusplus) || defined(c_plusplus) | 418 #if defined(__cplusplus) || defined(c_plusplus) |
| 417 } // extern "C" | 419 } // extern "C" |
| 418 #endif | 420 #endif |
| OLD | NEW |