* Encode one strip in tiff file * * @param s Tiff context * @param src Input buffer * @param dst Output buffer * @param n Size of input buffer * @param compr Compression method * @return Number of output bytes. If an output error is encountered, -1 returned */
| 148 | * @return Number of output bytes. If an output error is encountered, -1 returned |
| 149 | */ |
| 150 | static int encode_strip(TiffEncoderContext * s, const int8_t * src, |
| 151 | uint8_t * dst, int n, int compr) |
| 152 | { |
| 153 | |
| 154 | switch (compr) { |
| 155 | #if CONFIG_ZLIB |
| 156 | case TIFF_DEFLATE: |
| 157 | case TIFF_ADOBE_DEFLATE: |
| 158 | { |
| 159 | unsigned long zlen = s->buf_size - (*s->buf - s->buf_start); |
| 160 | if (compress(dst, &zlen, src, n) != Z_OK) { |
| 161 | av_log(s->avctx, AV_LOG_ERROR, "Compressing failed\n"); |
| 162 | return -1; |
| 163 | } |
| 164 | return zlen; |
| 165 | } |
| 166 | #endif |
| 167 | case TIFF_RAW: |
| 168 | if (check_size(s, n)) |
| 169 | return -1; |
| 170 | memcpy(dst, src, n); |
| 171 | return n; |
| 172 | case TIFF_PACKBITS: |
| 173 | return ff_rle_encode(dst, s->buf_size - (*s->buf - s->buf_start), src, 1, n, 2, 0xff, -1, 0); |
| 174 | case TIFF_LZW: |
| 175 | return ff_lzw_encode(s->lzws, src, n); |
| 176 | default: |
| 177 | return -1; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | static void pack_yuv(TiffEncoderContext * s, uint8_t * dst, int lnum) |
| 182 | { |
no test coverage detected