| 35 | } PHMEncContext; |
| 36 | |
| 37 | static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, |
| 38 | const AVFrame *p, int *got_packet) |
| 39 | { |
| 40 | PHMEncContext *s = avctx->priv_data; |
| 41 | uint8_t *bytestream, *bytestream_start, *bytestream_end; |
| 42 | int i, h, h1, c, n, linesize, ret; |
| 43 | int size = av_image_get_buffer_size(avctx->pix_fmt, |
| 44 | avctx->width, avctx->height, 1); |
| 45 | |
| 46 | if (size < 0) |
| 47 | return size; |
| 48 | |
| 49 | if ((ret = ff_get_encode_buffer(avctx, pkt, size + 200U, 0)) < 0) |
| 50 | return ret; |
| 51 | |
| 52 | bytestream_start = |
| 53 | bytestream = pkt->data; |
| 54 | bytestream_end = pkt->data + pkt->size; |
| 55 | |
| 56 | h = avctx->height; |
| 57 | h1 = h; |
| 58 | switch (avctx->pix_fmt) { |
| 59 | case AV_PIX_FMT_MONOWHITE: |
| 60 | c = '4'; |
| 61 | n = (avctx->width + 7) >> 3; |
| 62 | break; |
| 63 | case AV_PIX_FMT_GRAY8: |
| 64 | c = '5'; |
| 65 | n = avctx->width; |
| 66 | break; |
| 67 | case AV_PIX_FMT_GRAY16BE: |
| 68 | c = '5'; |
| 69 | n = avctx->width * 2; |
| 70 | break; |
| 71 | case AV_PIX_FMT_RGB24: |
| 72 | c = '6'; |
| 73 | n = avctx->width * 3; |
| 74 | break; |
| 75 | case AV_PIX_FMT_RGB48BE: |
| 76 | c = '6'; |
| 77 | n = avctx->width * 6; |
| 78 | break; |
| 79 | case AV_PIX_FMT_YUV420P: |
| 80 | if (avctx->width & 1 || avctx->height & 1) { |
| 81 | av_log(avctx, AV_LOG_ERROR, "pgmyuv needs even width and height\n"); |
| 82 | return AVERROR(EINVAL); |
| 83 | } |
| 84 | c = '5'; |
| 85 | n = avctx->width; |
| 86 | h1 = (h * 3) / 2; |
| 87 | break; |
| 88 | case AV_PIX_FMT_YUV420P16BE: |
| 89 | c = '5'; |
| 90 | n = avctx->width * 2; |
| 91 | h1 = (h * 3) / 2; |
| 92 | break; |
| 93 | case AV_PIX_FMT_GBRPF32BE: |
| 94 | case AV_PIX_FMT_GBRPF32LE: |
nothing calls this directly
no test coverage detected