Write huffman bit codes to a memory block */
| 362 | |
| 363 | /* Write huffman bit codes to a memory block */ |
| 364 | static int write_huff_codes(uint8_t *src, uint8_t *dst, int dst_size, |
| 365 | int width, int height, HuffEntry *he) |
| 366 | { |
| 367 | PutBitContext pb; |
| 368 | int i, j; |
| 369 | int count; |
| 370 | |
| 371 | init_put_bits(&pb, dst, dst_size); |
| 372 | |
| 373 | /* Write the codes */ |
| 374 | for (j = 0; j < height; j++) { |
| 375 | for (i = 0; i < width; i++) |
| 376 | put_bits(&pb, he[src[i]].len, he[src[i]].code); |
| 377 | |
| 378 | src += width; |
| 379 | } |
| 380 | |
| 381 | /* Pad output to a 32-bit boundary */ |
| 382 | count = put_bits_count(&pb) & 0x1F; |
| 383 | |
| 384 | if (count) |
| 385 | put_bits(&pb, 32 - count, 0); |
| 386 | |
| 387 | /* Flush the rest with zeroes */ |
| 388 | flush_put_bits(&pb); |
| 389 | |
| 390 | /* Return the amount of bytes written */ |
| 391 | return put_bytes_output(&pb); |
| 392 | } |
| 393 | |
| 394 | static int encode_plane(AVCodecContext *avctx, const uint8_t *src, |
| 395 | uint8_t *dst, ptrdiff_t stride, int plane_no, |
no test coverage detected