annotate pnm.c @ 2365:b76a4977447a libavcodec

Fixed typo which caused incorrect motion prediction in B-frames. patch by (Loren Merritt <lorenm ta u tod washington tod edu>)
author michael
date Wed, 24 Nov 2004 22:50:49 +0000
parents f7f4f06a55c9
children 18b8b2dcc037
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
1 /*
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
2 * PNM image format
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
3 * Copyright (c) 2002, 2003 Fabrice Bellard.
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
4 *
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
9 *
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
13 * Lesser General Public License for more details.
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
14 *
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
18 */
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
19 #include "avcodec.h"
2348
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
20 #include "mpegvideo.h" //only for ParseContext
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
21
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
22 typedef struct PNMContext {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
23 uint8_t *bytestream;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
24 uint8_t *bytestream_start;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
25 uint8_t *bytestream_end;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
26 AVFrame picture;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
27 } PNMContext;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
28
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
29 static inline int pnm_space(int c)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
30 {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
31 return (c == ' ' || c == '\n' || c == '\r' || c == '\t');
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
32 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
33
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
34 static void pnm_get(PNMContext *sc, char *str, int buf_size)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
35 {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
36 char *s;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
37 int c;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
38
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
39 /* skip spaces and comments */
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
40 for(;;) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
41 c = *sc->bytestream++;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
42 if (c == '#') {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
43 do {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
44 c = *sc->bytestream++;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
45 } while (c != '\n' && sc->bytestream < sc->bytestream_end);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
46 } else if (!pnm_space(c)) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
47 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
48 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
49 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
50
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
51 s = str;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
52 while (sc->bytestream < sc->bytestream_end && !pnm_space(c)) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
53 if ((s - str) < buf_size - 1)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
54 *s++ = c;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
55 c = *sc->bytestream++;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
56 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
57 *s = '\0';
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
58 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
59
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
60 static int common_init(AVCodecContext *avctx){
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
61 PNMContext *s = avctx->priv_data;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
62
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
63 avcodec_get_frame_defaults((AVFrame*)&s->picture);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
64 avctx->coded_frame= (AVFrame*)&s->picture;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
65
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
66 return 0;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
67 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
68
2348
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
69 static int pnm_decode_header(AVCodecContext *avctx, PNMContext * const s){
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
70 char buf1[32], tuple_type[32];
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
71 int h, w, depth, maxval;;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
72
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
73 pnm_get(s, buf1, sizeof(buf1));
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
74 if (!strcmp(buf1, "P4")) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
75 avctx->pix_fmt = PIX_FMT_MONOWHITE;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
76 } else if (!strcmp(buf1, "P5")) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
77 if (avctx->codec_id == CODEC_ID_PGMYUV)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
78 avctx->pix_fmt = PIX_FMT_YUV420P;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
79 else
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
80 avctx->pix_fmt = PIX_FMT_GRAY8;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
81 } else if (!strcmp(buf1, "P6")) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
82 avctx->pix_fmt = PIX_FMT_RGB24;
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
83 } else if (!strcmp(buf1, "P7")) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
84 w = -1;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
85 h = -1;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
86 maxval = -1;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
87 depth = -1;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
88 tuple_type[0] = '\0';
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
89 for(;;) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
90 pnm_get(s, buf1, sizeof(buf1));
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
91 if (!strcmp(buf1, "WIDTH")) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
92 pnm_get(s, buf1, sizeof(buf1));
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
93 w = strtol(buf1, NULL, 10);
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
94 } else if (!strcmp(buf1, "HEIGHT")) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
95 pnm_get(s, buf1, sizeof(buf1));
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
96 h = strtol(buf1, NULL, 10);
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
97 } else if (!strcmp(buf1, "DEPTH")) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
98 pnm_get(s, buf1, sizeof(buf1));
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
99 depth = strtol(buf1, NULL, 10);
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
100 } else if (!strcmp(buf1, "MAXVAL")) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
101 pnm_get(s, buf1, sizeof(buf1));
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
102 maxval = strtol(buf1, NULL, 10);
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
103 } else if (!strcmp(buf1, "TUPLETYPE")) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
104 pnm_get(s, tuple_type, sizeof(tuple_type));
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
105 } else if (!strcmp(buf1, "ENDHDR")) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
106 break;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
107 } else {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
108 return -1;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
109 }
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
110 }
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
111 /* check that all tags are present */
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
112 if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\0')
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
113 return -1;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
114 avctx->width = w;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
115 avctx->height = h;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
116 if (depth == 1) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
117 if (maxval == 1)
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
118 avctx->pix_fmt = PIX_FMT_MONOWHITE;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
119 else
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
120 avctx->pix_fmt = PIX_FMT_GRAY8;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
121 } else if (depth == 3) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
122 avctx->pix_fmt = PIX_FMT_RGB24;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
123 } else if (depth == 4) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
124 avctx->pix_fmt = PIX_FMT_RGBA32;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
125 } else {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
126 return -1;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
127 }
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
128 return 0;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
129 } else {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
130 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
131 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
132 pnm_get(s, buf1, sizeof(buf1));
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
133 avctx->width = atoi(buf1);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
134 if (avctx->width <= 0)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
135 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
136 pnm_get(s, buf1, sizeof(buf1));
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
137 avctx->height = atoi(buf1);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
138 if (avctx->height <= 0)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
139 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
140 if (avctx->pix_fmt != PIX_FMT_MONOWHITE) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
141 pnm_get(s, buf1, sizeof(buf1));
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
142 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
143
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
144 /* more check if YUV420 */
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
145 if (avctx->pix_fmt == PIX_FMT_YUV420P) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
146 if ((avctx->width & 1) != 0)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
147 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
148 h = (avctx->height * 2);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
149 if ((h % 3) != 0)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
150 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
151 h /= 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
152 avctx->height = h;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
153 }
2348
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
154 return 0;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
155 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
156
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
157 static int pnm_decode_frame(AVCodecContext *avctx,
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
158 void *data, int *data_size,
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
159 uint8_t *buf, int buf_size)
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
160 {
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
161 PNMContext * const s = avctx->priv_data;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
162 AVFrame *picture = data;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
163 AVFrame * const p= (AVFrame*)&s->picture;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
164 int i, n, linesize, h;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
165 unsigned char *ptr;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
166
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
167 /* special case for last picture */
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
168 if (buf_size == 0) {
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
169 return 0;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
170 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
171
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
172 s->bytestream_start=
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
173 s->bytestream= buf;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
174 s->bytestream_end= buf + buf_size;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
175
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
176 if(pnm_decode_header(avctx, s) < 0)
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
177 return -1;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
178
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
179 if(p->data[0])
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
180 avctx->release_buffer(avctx, p);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
181
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
182 p->reference= 0;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
183 if(avctx->get_buffer(avctx, p) < 0){
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
184 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
185 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
186 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
187 p->pict_type= FF_I_TYPE;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
188 p->key_frame= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
189
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
190 switch(avctx->pix_fmt) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
191 default:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
192 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
193 case PIX_FMT_RGB24:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
194 n = avctx->width * 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
195 goto do_read;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
196 case PIX_FMT_GRAY8:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
197 n = avctx->width;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
198 goto do_read;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
199 case PIX_FMT_MONOWHITE:
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
200 case PIX_FMT_MONOBLACK:
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
201 n = (avctx->width + 7) >> 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
202 do_read:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
203 ptr = p->data[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
204 linesize = p->linesize[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
205 for(i = 0; i < avctx->height; i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
206 memcpy(ptr, s->bytestream, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
207 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
208 ptr += linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
209 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
210 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
211 case PIX_FMT_YUV420P:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
212 {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
213 unsigned char *ptr1, *ptr2;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
214
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
215 n = avctx->width;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
216 ptr = p->data[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
217 linesize = p->linesize[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
218 for(i = 0; i < avctx->height; i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
219 memcpy(ptr, s->bytestream, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
220 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
221 ptr += linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
222 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
223 ptr1 = p->data[1];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
224 ptr2 = p->data[2];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
225 n >>= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
226 h = avctx->height >> 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
227 for(i = 0; i < h; i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
228 memcpy(ptr1, s->bytestream, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
229 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
230 memcpy(ptr2, s->bytestream, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
231 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
232 ptr1 += p->linesize[1];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
233 ptr2 += p->linesize[2];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
234 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
235 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
236 break;
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
237 case PIX_FMT_RGBA32:
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
238 ptr = p->data[0];
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
239 linesize = p->linesize[0];
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
240 for(i = 0; i < avctx->height; i++) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
241 int j, r, g, b, a;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
242
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
243 for(j = 0;j < avctx->width; j++) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
244 r = *s->bytestream++;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
245 g = *s->bytestream++;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
246 b = *s->bytestream++;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
247 a = *s->bytestream++;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
248 ((uint32_t *)ptr)[j] = (a << 24) | (r << 16) | (g << 8) | b;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
249 }
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
250 ptr += linesize;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
251 }
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
252 break;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
253 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
254 *picture= *(AVFrame*)&s->picture;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
255 *data_size = sizeof(AVPicture);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
256
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
257 return s->bytestream - s->bytestream_start;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
258 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
259
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
260 static int pnm_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int buf_size, void *data){
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
261 PNMContext *s = avctx->priv_data;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
262 AVFrame *pict = data;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
263 AVFrame * const p= (AVFrame*)&s->picture;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
264 int i, h, h1, c, n, linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
265 uint8_t *ptr, *ptr1, *ptr2;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
266
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
267 *p = *pict;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
268 p->pict_type= FF_I_TYPE;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
269 p->key_frame= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
270
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
271 s->bytestream_start=
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
272 s->bytestream= outbuf;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
273 s->bytestream_end= outbuf+buf_size;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
274
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
275 h = avctx->height;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
276 h1 = h;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
277 switch(avctx->pix_fmt) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
278 case PIX_FMT_MONOWHITE:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
279 c = '4';
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
280 n = (avctx->width + 7) >> 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
281 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
282 case PIX_FMT_GRAY8:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
283 c = '5';
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
284 n = avctx->width;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
285 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
286 case PIX_FMT_RGB24:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
287 c = '6';
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
288 n = avctx->width * 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
289 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
290 case PIX_FMT_YUV420P:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
291 c = '5';
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
292 n = avctx->width;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
293 h1 = (h * 3) / 2;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
294 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
295 default:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
296 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
297 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
298 snprintf(s->bytestream, s->bytestream_end - s->bytestream,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
299 "P%c\n%d %d\n",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
300 c, avctx->width, h1);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
301 s->bytestream += strlen(s->bytestream);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
302 if (avctx->pix_fmt != PIX_FMT_MONOWHITE) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
303 snprintf(s->bytestream, s->bytestream_end - s->bytestream,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
304 "%d\n", 255);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
305 s->bytestream += strlen(s->bytestream);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
306 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
307
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
308 ptr = p->data[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
309 linesize = p->linesize[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
310 for(i=0;i<h;i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
311 memcpy(s->bytestream, ptr, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
312 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
313 ptr += linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
314 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
315
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
316 if (avctx->pix_fmt == PIX_FMT_YUV420P) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
317 h >>= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
318 n >>= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
319 ptr1 = p->data[1];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
320 ptr2 = p->data[2];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
321 for(i=0;i<h;i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
322 memcpy(s->bytestream, ptr1, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
323 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
324 memcpy(s->bytestream, ptr2, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
325 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
326 ptr1 += p->linesize[1];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
327 ptr2 += p->linesize[2];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
328 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
329 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
330 return s->bytestream - s->bytestream_start;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
331 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
332
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
333 static int pam_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, int buf_size, void *data){
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
334 PNMContext *s = avctx->priv_data;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
335 AVFrame *pict = data;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
336 AVFrame * const p= (AVFrame*)&s->picture;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
337 int i, h, w, n, linesize, depth, maxval;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
338 const char *tuple_type;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
339 uint8_t *ptr;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
340
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
341 *p = *pict;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
342 p->pict_type= FF_I_TYPE;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
343 p->key_frame= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
345 s->bytestream_start=
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
346 s->bytestream= outbuf;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
347 s->bytestream_end= outbuf+buf_size;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
348
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
349 h = avctx->height;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
350 w = avctx->width;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
351 switch(avctx->pix_fmt) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
352 case PIX_FMT_MONOWHITE:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
353 n = (w + 7) >> 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
354 depth = 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
355 maxval = 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
356 tuple_type = "BLACKANDWHITE";
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
357 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
358 case PIX_FMT_GRAY8:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
359 n = w;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
360 depth = 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
361 maxval = 255;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
362 tuple_type = "GRAYSCALE";
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
363 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
364 case PIX_FMT_RGB24:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
365 n = w * 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
366 depth = 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
367 maxval = 255;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
368 tuple_type = "RGB";
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
369 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
370 case PIX_FMT_RGBA32:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
371 n = w * 4;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
372 depth = 4;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
373 maxval = 255;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
374 tuple_type = "RGB_ALPHA";
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
375 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
376 default:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
377 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
378 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
379 snprintf(s->bytestream, s->bytestream_end - s->bytestream,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
380 "P7\nWIDTH %d\nHEIGHT %d\nDEPTH %d\nMAXVAL %d\nTUPLETYPE %s\nENDHDR\n",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
381 w, h, depth, maxval, tuple_type);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
382 s->bytestream += strlen(s->bytestream);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
383
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
384 ptr = p->data[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
385 linesize = p->linesize[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
386
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
387 if (avctx->pix_fmt == PIX_FMT_RGBA32) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
388 int j;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
389 unsigned int v;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
390
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
391 for(i=0;i<h;i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
392 for(j=0;j<w;j++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
393 v = ((uint32_t *)ptr)[j];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
394 *s->bytestream++ = v >> 16;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
395 *s->bytestream++ = v >> 8;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
396 *s->bytestream++ = v;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
397 *s->bytestream++ = v >> 24;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
398 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
399 ptr += linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
400 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
401 } else {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
402 for(i=0;i<h;i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
403 memcpy(s->bytestream, ptr, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
404 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
405 ptr += linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
406 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
407 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
408 return s->bytestream - s->bytestream_start;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
409 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
410
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
411 #if 0
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
412 static int pnm_probe(AVProbeData *pd)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
413 {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
414 const char *p = pd->buf;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
415 if (pd->buf_size >= 8 &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
416 p[0] == 'P' &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
417 p[1] >= '4' && p[1] <= '6' &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
418 pnm_space(p[2]) )
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
419 return AVPROBE_SCORE_MAX - 1; /* to permit pgmyuv probe */
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
420 else
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
421 return 0;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
422 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
423
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
424 static int pgmyuv_probe(AVProbeData *pd)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
425 {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
426 if (match_ext(pd->filename, "pgmyuv"))
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
427 return AVPROBE_SCORE_MAX;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
428 else
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
429 return 0;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
430 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
431
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
432 static int pam_probe(AVProbeData *pd)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
433 {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
434 const char *p = pd->buf;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
435 if (pd->buf_size >= 8 &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
436 p[0] == 'P' &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
437 p[1] == '7' &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
438 p[2] == '\n')
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
439 return AVPROBE_SCORE_MAX;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
440 else
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
441 return 0;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
442 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
443 #endif
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
444
2348
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
445 static int pnm_parse(AVCodecParserContext *s,
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
446 AVCodecContext *avctx,
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
447 uint8_t **poutbuf, int *poutbuf_size,
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
448 const uint8_t *buf, int buf_size)
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
449 {
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
450 ParseContext *pc = s->priv_data;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
451 PNMContext pnmctx;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
452 int next;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
453
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
454 for(; pc->overread>0; pc->overread--){
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
455 pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
456 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
457 retry:
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
458 if(pc->index){
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
459 pnmctx.bytestream_start=
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
460 pnmctx.bytestream= pc->buffer;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
461 pnmctx.bytestream_end= pc->buffer + pc->index;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
462 }else{
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
463 pnmctx.bytestream_start=
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
464 pnmctx.bytestream= buf;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
465 pnmctx.bytestream_end= buf + buf_size;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
466 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
467 if(pnm_decode_header(avctx, &pnmctx) < 0){
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
468 if(pnmctx.bytestream < pnmctx.bytestream_end){
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
469 if(pc->index){
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
470 pc->index=0;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
471 }else{
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
472 buf++;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
473 buf_size--;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
474 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
475 goto retry;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
476 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
477 #if 0
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
478 if(pc->index && pc->index*2 + FF_INPUT_BUFFER_PADDING_SIZE < pc->buffer_size && buf_size > pc->index){
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
479 memcpy(pc->buffer + pc->index, buf, pc->index);
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
480 pc->index += pc->index;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
481 buf += pc->index;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
482 buf_size -= pc->index;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
483 goto retry;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
484 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
485 #endif
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
486 next= END_NOT_FOUND;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
487 }else{
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
488 next= pnmctx.bytestream - pnmctx.bytestream_start
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
489 + avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
490 if(pnmctx.bytestream_start!=buf)
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
491 next-= pc->index;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
492 if(next > buf_size)
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
493 next= END_NOT_FOUND;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
494 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
495
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
496 if(ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size)<0){
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
497 *poutbuf = NULL;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
498 *poutbuf_size = 0;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
499 return buf_size;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
500 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
501 *poutbuf = (uint8_t *)buf;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
502 *poutbuf_size = buf_size;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
503 return next;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
504 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
505
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
506 AVCodecParser pnm_parser = {
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
507 { CODEC_ID_PGM, CODEC_ID_PGMYUV, CODEC_ID_PPM, CODEC_ID_PBM, CODEC_ID_PAM},
2348
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
508 sizeof(ParseContext),
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
509 NULL,
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
510 pnm_parse,
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
511 ff_parse_close,
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
512 };
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
513
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
514 AVCodec pgm_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
515 "pgm",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
516 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
517 CODEC_ID_PGM,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
518 sizeof(PNMContext),
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
519 common_init,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
520 pnm_encode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
521 NULL, //encode_end,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
522 pnm_decode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
523 .pix_fmts= (enum PixelFormat[]){PIX_FMT_GRAY8, -1},
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
524 };
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
525
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
526 AVCodec pgmyuv_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
527 "pgmyuv",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
528 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
529 CODEC_ID_PGMYUV,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
530 sizeof(PNMContext),
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
531 common_init,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
532 pnm_encode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
533 NULL, //encode_end,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
534 pnm_decode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
535 .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
536 };
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
537
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
538 AVCodec ppm_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
539 "ppm",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
540 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
541 CODEC_ID_PPM,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
542 sizeof(PNMContext),
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
543 common_init,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
544 pnm_encode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
545 NULL, //encode_end,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
546 pnm_decode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
547 .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, -1},
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
548 };
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
549
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
550 AVCodec pbm_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
551 "pbm",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
552 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
553 CODEC_ID_PBM,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
554 sizeof(PNMContext),
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
555 common_init,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
556 pnm_encode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
557 NULL, //encode_end,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
558 pnm_decode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
559 .pix_fmts= (enum PixelFormat[]){PIX_FMT_MONOWHITE, -1},
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
560 };
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
561
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
562 AVCodec pam_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
563 "pam",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
564 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
565 CODEC_ID_PAM,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
566 sizeof(PNMContext),
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
567 common_init,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
568 pam_encode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
569 NULL, //encode_end,
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
570 pnm_decode_frame,
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
571 .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGBA32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, -1},
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
572 };