1 /*
2 * PNM image format
3 * Copyright (c) 2002, 2003 Fabrice Bellard
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
25
27 const AVFrame *p,
int *got_packet)
28 {
29 uint8_t *bytestream, *bytestream_start, *bytestream_end;
30 int i, h, h1,
c,
n, linesize,
ret;
32
35 avctx->
height) + 200)) < 0)
37
38 bytestream_start =
39 bytestream = pkt->
data;
40 bytestream_end = pkt->
data + pkt->
size;
41
43 h1 = h;
46 c = '4';
47 n = (avctx->
width + 7) >> 3;
48 break;
50 c = '5';
52 break;
54 c = '5';
56 break;
58 c = '6';
60 break;
62 c = '6';
64 break;
69 }
70 c = '5';
72 h1 = (h * 3) / 2;
73 break;
75 c = '5';
77 h1 = (h * 3) / 2;
78 break;
79 default:
80 return -1;
81 }
82 snprintf(bytestream, bytestream_end - bytestream,
83 "P%c\n%d %d\n", c, avctx->
width, h1);
84 bytestream += strlen(bytestream);
87 snprintf(bytestream, bytestream_end - bytestream,
88 "%d\n", maxdepth);
89 bytestream += strlen(bytestream);
90 }
91
94 for (i = 0; i < h; i++) {
95 memcpy(bytestream, ptr, n);
97 ptr += linesize;
98 }
99
101 h >>= 1;
102 n >>= 1;
105 for (i = 0; i < h; i++) {
106 memcpy(bytestream, ptr1, n);
108 memcpy(bytestream, ptr2, n);
112 }
113 }
114 pkt->
size = bytestream - bytestream_start;
116 *got_packet = 1;
117
118 return 0;
119 }
120
122 {
126
129
130 return 0;
131 }
132
134 {
136 return 0;
137 }
138
139 #if CONFIG_PGM_ENCODER
150 },
151 };
152 #endif
153
154 #if CONFIG_PGMYUV_ENCODER
165 },
166 };
167 #endif
168
169 #if CONFIG_PPM_ENCODER
180 },
181 };
182 #endif
183
184 #if CONFIG_PBM_ENCODER
195 };
196 #endif