OLD | NEW |
1 /* Copyright 2013 Google Inc. All Rights Reserved. | 1 /* Copyright 2013 Google Inc. All Rights Reserved. |
2 | 2 |
3 Distributed under MIT license. | 3 Distributed under MIT license. |
4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT | 4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT |
5 */ | 5 */ |
6 | 6 |
7 // Implementation of Brotli compressor. | 7 // Implementation of Brotli compressor. |
8 | 8 |
9 #include "./encode.h" | 9 #include "./encode.h" |
10 | 10 |
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 } | 1148 } |
1149 delete[] storage; | 1149 delete[] storage; |
1150 delete[] table; | 1150 delete[] table; |
1151 delete[] command_buf; | 1151 delete[] command_buf; |
1152 delete[] literal_buf; | 1152 delete[] literal_buf; |
1153 return ok; | 1153 return ok; |
1154 } | 1154 } |
1155 | 1155 |
1156 size_t in_bytes = 0; | 1156 size_t in_bytes = 0; |
1157 size_t out_bytes = 0; | 1157 size_t out_bytes = 0; |
1158 uint8_t* output; | 1158 uint8_t* output = NULL; |
1159 bool final_block = false; | 1159 bool final_block = false; |
1160 BrotliCompressor compressor(params); | 1160 BrotliCompressor compressor(params); |
1161 if (dictsize != 0) compressor.BrotliSetCustomDictionary(dictsize, dict); | 1161 if (dictsize != 0) compressor.BrotliSetCustomDictionary(dictsize, dict); |
1162 while (!final_block) { | 1162 while (!final_block) { |
1163 if (!CopyOneBlockToRingBuffer(in, &compressor, &in_bytes, &final_block)) { | 1163 if (!CopyOneBlockToRingBuffer(in, &compressor, &in_bytes, &final_block)) { |
1164 return false; | 1164 return false; |
1165 } | 1165 } |
1166 out_bytes = 0; | 1166 out_bytes = 0; |
1167 if (!compressor.WriteBrotliData(final_block, | 1167 if (!compressor.WriteBrotliData(final_block, |
1168 /* force_flush = */ false, | 1168 /* force_flush = */ false, |
1169 &out_bytes, &output)) { | 1169 &out_bytes, &output)) { |
1170 return false; | 1170 return false; |
1171 } | 1171 } |
1172 if (out_bytes > 0 && !out->Write(output, out_bytes)) { | 1172 if (out_bytes > 0 && !out->Write(output, out_bytes)) { |
1173 return false; | 1173 return false; |
1174 } | 1174 } |
1175 } | 1175 } |
1176 return true; | 1176 return true; |
1177 } | 1177 } |
1178 | 1178 |
1179 | 1179 |
1180 } // namespace brotli | 1180 } // namespace brotli |
OLD | NEW |