mirror of
				https://github.com/webmproject/libwebp.git
				synced 2025-10-31 18:35:41 +01:00 
			
		
		
		
	re-organize the error-handling in the main loop a bit
Change-Id: Id74298131df9c33a86b989e15c11ffb6d04960d8
This commit is contained in:
		| @@ -801,26 +801,27 @@ int VP8EncLoop(VP8Encoder* const enc) { | |||||||
|     ok = VP8IteratorProgress(&it, 20); |     ok = VP8IteratorProgress(&it, 20); | ||||||
|   } while (ok && VP8IteratorNext(&it, it.yuv_out_)); |   } while (ok && VP8IteratorNext(&it, it.yuv_out_)); | ||||||
|  |  | ||||||
|   if (ok) { |   if (ok) {      // Finalize the partitions, check for extra errors. | ||||||
|     VP8AdjustFilterStrength(&it); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // Finalize the partitions |  | ||||||
|     for (p = 0; p < enc->num_parts_; ++p) { |     for (p = 0; p < enc->num_parts_; ++p) { | ||||||
|       VP8BitWriterFinish(enc->parts_ + p); |       VP8BitWriterFinish(enc->parts_ + p); | ||||||
|       ok &= !enc->parts_[p].error_; |       ok &= !enc->parts_[p].error_; | ||||||
|     } |     } | ||||||
|   // and byte counters |   } | ||||||
|   if (enc->pic_->stats) { |  | ||||||
|  |   if (ok) {      // All good. Finish up. | ||||||
|  |     if (enc->pic_->stats) {           // finalize byte counters... | ||||||
|       for (i = 0; i <= 2; ++i) { |       for (i = 0; i <= 2; ++i) { | ||||||
|         for (s = 0; s < NUM_MB_SEGMENTS; ++s) { |         for (s = 0; s < NUM_MB_SEGMENTS; ++s) { | ||||||
|           enc->residual_bytes_[i][s] = (int)((it.bit_count_[s][i] + 7) >> 3); |           enc->residual_bytes_[i][s] = (int)((it.bit_count_[s][i] + 7) >> 3); | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   if (!ok) {    // need to do some memory cleanup |     VP8AdjustFilterStrength(&it);     // ...and store filter stats. | ||||||
|  |   } else { | ||||||
|  |     // Something bad happened -> need to do some memory cleanup. | ||||||
|     VP8EncFreeBitWriters(enc); |     VP8EncFreeBitWriters(enc); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   return ok; |   return ok; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user