| 196 | } |
| 197 | |
| 198 | static int encode_frame(AVCodecContext * avctx, unsigned char *buf, |
| 199 | int buf_size, void *data) |
| 200 | { |
| 201 | TiffEncoderContext *s = avctx->priv_data; |
| 202 | AVFrame *pict = data; |
| 203 | AVFrame *const p = (AVFrame *) & s->picture; |
| 204 | int i; |
| 205 | int n; |
| 206 | uint8_t *ptr = buf; |
| 207 | uint8_t *offset; |
| 208 | uint32_t strips; |
| 209 | uint32_t *strip_sizes = NULL; |
| 210 | uint32_t *strip_offsets = NULL; |
| 211 | int bytes_per_row; |
| 212 | uint32_t res[2] = { 72, 1 }; // image resolution (72/1) |
| 213 | static const uint16_t bpp_tab[] = { 8, 8, 8, 8 }; |
| 214 | int ret = -1; |
| 215 | int is_yuv = 0; |
| 216 | uint8_t *yuv_line = NULL; |
| 217 | int shift_h, shift_v; |
| 218 | |
| 219 | s->buf_start = buf; |
| 220 | s->buf = &ptr; |
| 221 | s->buf_size = buf_size; |
| 222 | |
| 223 | *p = *pict; |
| 224 | p->pict_type = FF_I_TYPE; |
| 225 | p->key_frame = 1; |
| 226 | avctx->coded_frame= &s->picture; |
| 227 | |
| 228 | s->compr = TIFF_PACKBITS; |
| 229 | if (avctx->compression_level == 0) { |
| 230 | s->compr = TIFF_RAW; |
| 231 | } else if(avctx->compression_level == 2) { |
| 232 | s->compr = TIFF_LZW; |
| 233 | #if CONFIG_ZLIB |
| 234 | } else if ((avctx->compression_level >= 3)) { |
| 235 | s->compr = TIFF_DEFLATE; |
| 236 | #endif |
| 237 | } |
| 238 | |
| 239 | s->width = avctx->width; |
| 240 | s->height = avctx->height; |
| 241 | s->subsampling[0] = 1; |
| 242 | s->subsampling[1] = 1; |
| 243 | |
| 244 | switch (avctx->pix_fmt) { |
| 245 | case PIX_FMT_RGB24: |
| 246 | s->bpp = 24; |
| 247 | s->photometric_interpretation = 2; |
| 248 | break; |
| 249 | case PIX_FMT_GRAY8: |
| 250 | s->bpp = 8; |
| 251 | s->photometric_interpretation = 1; |
| 252 | break; |
| 253 | case PIX_FMT_PAL8: |
| 254 | s->bpp = 8; |
| 255 | s->photometric_interpretation = 3; |
nothing calls this directly
no test coverage detected