26 const AVFrame *p,
int *got_packet)
28 uint8_t *bytestream_start, *bytestream, *bytestream_end;
29 int i, h, w,
n, linesize,
depth, maxval,
ret;
30 const char *tuple_type;
40 tuple_type =
"BLACKANDWHITE";
46 tuple_type =
"GRAYSCALE";
52 tuple_type =
"GRAYSCALE";
58 tuple_type =
"GRAYSCALE_ALPHA";
64 tuple_type =
"GRAYSCALE_ALPHA";
76 tuple_type =
"RGB_ALPHA";
88 tuple_type =
"RGB_ALPHA";
98 bytestream = pkt->
data;
99 bytestream_end = pkt->
data + pkt->
size;
101 snprintf(bytestream, bytestream_end - bytestream,
102 "P7\nWIDTH %d\nHEIGHT %d\nDEPTH %d\nMAXVAL %d\nTUPLTYPE %s\nENDHDR\n",
103 w, h, depth, maxval, tuple_type);
104 bytestream += strlen(bytestream);
111 for (i = 0; i < h; i++) {
112 for (j = 0; j < w; j++)
113 *bytestream++ = ptr[j >> 3] >> (7 - j & 7) & 1;
117 for (i = 0; i < h; i++) {
118 memcpy(bytestream, ptr, n);
124 pkt->
size = bytestream - bytestream_start;