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";
70 tuple_type =
"RGB_ALPHA";
82 tuple_type =
"RGB_ALPHA";
92 bytestream = pkt->
data;
93 bytestream_end = pkt->
data + pkt->
size;
95 snprintf(bytestream, bytestream_end - bytestream,
96 "P7\nWIDTH %d\nHEIGHT %d\nDEPTH %d\nMAXVAL %d\nTUPLTYPE %s\nENDHDR\n",
97 w, h, depth, maxval, tuple_type);
98 bytestream += strlen(bytestream);
105 for (i = 0; i < h; i++) {
106 for (j = 0; j < w; j++)
107 *bytestream++ = ptr[j >> 3] >> (7 - j & 7) & 1;
111 for (i = 0; i < h; i++) {
112 memcpy(bytestream, ptr, n);
118 pkt->
size = bytestream - bytestream_start;