annotate pnm.c @ 2517:3d8bbb8e7156 libavcodec

use av_free() instead of free() where it's meant to.
author mmu_man
date Tue, 22 Feb 2005 11:37:03 +0000
parents f67b63ed036d
children b2846918585c
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 */
2422
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
112 if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\0' || avcodec_check_dimensions(avctx, w, h))
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
113 return -1;
2422
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
114
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
115 avctx->width = w;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
116 avctx->height = h;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
117 if (depth == 1) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
118 if (maxval == 1)
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
119 avctx->pix_fmt = PIX_FMT_MONOWHITE;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
120 else
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
121 avctx->pix_fmt = PIX_FMT_GRAY8;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
122 } else if (depth == 3) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
123 avctx->pix_fmt = PIX_FMT_RGB24;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
124 } else if (depth == 4) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
125 avctx->pix_fmt = PIX_FMT_RGBA32;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
126 } else {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
127 return -1;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
128 }
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
129 return 0;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
130 } else {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
131 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
132 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
133 pnm_get(s, buf1, sizeof(buf1));
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
134 avctx->width = atoi(buf1);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
135 if (avctx->width <= 0)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
136 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
137 pnm_get(s, buf1, sizeof(buf1));
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
138 avctx->height = atoi(buf1);
2422
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
139 if(avcodec_check_dimensions(avctx, avctx->width, avctx->height))
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
140 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
141 if (avctx->pix_fmt != PIX_FMT_MONOWHITE) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
142 pnm_get(s, buf1, sizeof(buf1));
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
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
145 /* more check if YUV420 */
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
146 if (avctx->pix_fmt == PIX_FMT_YUV420P) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
147 if ((avctx->width & 1) != 0)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
148 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
149 h = (avctx->height * 2);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
150 if ((h % 3) != 0)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
151 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
152 h /= 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
153 avctx->height = h;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
154 }
2348
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
155 return 0;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
156 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
157
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
158 static int pnm_decode_frame(AVCodecContext *avctx,
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
159 void *data, int *data_size,
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
160 uint8_t *buf, int buf_size)
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
161 {
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
162 PNMContext * const s = avctx->priv_data;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
163 AVFrame *picture = data;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
164 AVFrame * const p= (AVFrame*)&s->picture;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
165 int i, n, linesize, h;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
166 unsigned char *ptr;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
167
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
168 s->bytestream_start=
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
169 s->bytestream= buf;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
170 s->bytestream_end= buf + buf_size;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
171
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
172 if(pnm_decode_header(avctx, s) < 0)
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
173 return -1;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
174
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
175 if(p->data[0])
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
176 avctx->release_buffer(avctx, p);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
177
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
178 p->reference= 0;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
179 if(avctx->get_buffer(avctx, p) < 0){
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
180 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
181 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
182 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
183 p->pict_type= FF_I_TYPE;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
184 p->key_frame= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
185
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
186 switch(avctx->pix_fmt) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
187 default:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
188 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
189 case PIX_FMT_RGB24:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
190 n = avctx->width * 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
191 goto do_read;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
192 case PIX_FMT_GRAY8:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
193 n = avctx->width;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
194 goto do_read;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
195 case PIX_FMT_MONOWHITE:
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
196 case PIX_FMT_MONOBLACK:
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
197 n = (avctx->width + 7) >> 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
198 do_read:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
199 ptr = p->data[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
200 linesize = p->linesize[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
201 for(i = 0; i < avctx->height; i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
202 memcpy(ptr, s->bytestream, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
203 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
204 ptr += linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
205 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
206 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
207 case PIX_FMT_YUV420P:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
208 {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
209 unsigned char *ptr1, *ptr2;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
210
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
211 n = avctx->width;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
212 ptr = p->data[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
213 linesize = p->linesize[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
214 for(i = 0; i < avctx->height; i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
215 memcpy(ptr, s->bytestream, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
216 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
217 ptr += linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
218 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
219 ptr1 = p->data[1];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
220 ptr2 = p->data[2];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
221 n >>= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
222 h = avctx->height >> 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
223 for(i = 0; i < h; i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
224 memcpy(ptr1, s->bytestream, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
225 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
226 memcpy(ptr2, s->bytestream, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
227 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
228 ptr1 += p->linesize[1];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
229 ptr2 += p->linesize[2];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
230 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
231 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
232 break;
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
233 case PIX_FMT_RGBA32:
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
234 ptr = p->data[0];
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
235 linesize = p->linesize[0];
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
236 for(i = 0; i < avctx->height; i++) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
237 int j, r, g, b, a;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
238
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
239 for(j = 0;j < avctx->width; j++) {
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
240 r = *s->bytestream++;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
241 g = *s->bytestream++;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
242 b = *s->bytestream++;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
243 a = *s->bytestream++;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
244 ((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
245 }
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
246 ptr += linesize;
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
247 }
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
248 break;
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
249 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
250 *picture= *(AVFrame*)&s->picture;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
251 *data_size = sizeof(AVPicture);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
252
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
253 return s->bytestream - s->bytestream_start;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
254 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
255
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
256 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
257 PNMContext *s = avctx->priv_data;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
258 AVFrame *pict = data;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
259 AVFrame * const p= (AVFrame*)&s->picture;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
260 int i, h, h1, c, n, linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
261 uint8_t *ptr, *ptr1, *ptr2;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
262
2422
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
263 if(buf_size < avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height) + 200){
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
264 av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
265 return -1;
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
266 }
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
267
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
268 *p = *pict;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
269 p->pict_type= FF_I_TYPE;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
270 p->key_frame= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
271
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
272 s->bytestream_start=
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
273 s->bytestream= outbuf;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
274 s->bytestream_end= outbuf+buf_size;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
275
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
276 h = avctx->height;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
277 h1 = h;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
278 switch(avctx->pix_fmt) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
279 case PIX_FMT_MONOWHITE:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
280 c = '4';
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
281 n = (avctx->width + 7) >> 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
282 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
283 case PIX_FMT_GRAY8:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
284 c = '5';
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
285 n = avctx->width;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
286 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
287 case PIX_FMT_RGB24:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
288 c = '6';
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
289 n = avctx->width * 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
290 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
291 case PIX_FMT_YUV420P:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
292 c = '5';
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
293 n = avctx->width;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
294 h1 = (h * 3) / 2;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
295 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
296 default:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
297 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
298 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
299 snprintf(s->bytestream, s->bytestream_end - s->bytestream,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
300 "P%c\n%d %d\n",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
301 c, avctx->width, h1);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
302 s->bytestream += strlen(s->bytestream);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
303 if (avctx->pix_fmt != PIX_FMT_MONOWHITE) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
304 snprintf(s->bytestream, s->bytestream_end - s->bytestream,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
305 "%d\n", 255);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
306 s->bytestream += strlen(s->bytestream);
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
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
309 ptr = p->data[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
310 linesize = p->linesize[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
311 for(i=0;i<h;i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
312 memcpy(s->bytestream, ptr, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
313 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
314 ptr += linesize;
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
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
317 if (avctx->pix_fmt == PIX_FMT_YUV420P) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
318 h >>= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
319 n >>= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
320 ptr1 = p->data[1];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
321 ptr2 = p->data[2];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
322 for(i=0;i<h;i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
323 memcpy(s->bytestream, ptr1, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
324 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
325 memcpy(s->bytestream, ptr2, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
326 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
327 ptr1 += p->linesize[1];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
328 ptr2 += p->linesize[2];
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 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
331 return s->bytestream - s->bytestream_start;
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
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
334 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
335 PNMContext *s = avctx->priv_data;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
336 AVFrame *pict = data;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
337 AVFrame * const p= (AVFrame*)&s->picture;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
338 int i, h, w, n, linesize, depth, maxval;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
339 const char *tuple_type;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
340 uint8_t *ptr;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
341
2422
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
342 if(buf_size < avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height) + 200){
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
343 av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
344 return -1;
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
345 }
18b8b2dcc037 various security fixes and precautionary checks
michael
parents: 2349
diff changeset
346
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
347 *p = *pict;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
348 p->pict_type= FF_I_TYPE;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
349 p->key_frame= 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
350
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
351 s->bytestream_start=
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
352 s->bytestream= outbuf;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
353 s->bytestream_end= outbuf+buf_size;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
354
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
355 h = avctx->height;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
356 w = avctx->width;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
357 switch(avctx->pix_fmt) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
358 case PIX_FMT_MONOWHITE:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
359 n = (w + 7) >> 3;
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 = 1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
362 tuple_type = "BLACKANDWHITE";
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_GRAY8:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
365 n = w;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
366 depth = 1;
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 = "GRAYSCALE";
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_RGB24:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
371 n = w * 3;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
372 depth = 3;
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";
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 case PIX_FMT_RGBA32:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
377 n = w * 4;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
378 depth = 4;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
379 maxval = 255;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
380 tuple_type = "RGB_ALPHA";
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
381 break;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
382 default:
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
383 return -1;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
384 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
385 snprintf(s->bytestream, s->bytestream_end - s->bytestream,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
386 "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
387 w, h, depth, maxval, tuple_type);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
388 s->bytestream += strlen(s->bytestream);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
389
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
390 ptr = p->data[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
391 linesize = p->linesize[0];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
392
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
393 if (avctx->pix_fmt == PIX_FMT_RGBA32) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
394 int j;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
395 unsigned int v;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
396
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
397 for(i=0;i<h;i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
398 for(j=0;j<w;j++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
399 v = ((uint32_t *)ptr)[j];
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
400 *s->bytestream++ = v >> 16;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
401 *s->bytestream++ = v >> 8;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
402 *s->bytestream++ = v;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
403 *s->bytestream++ = v >> 24;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
404 }
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 } else {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
408 for(i=0;i<h;i++) {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
409 memcpy(s->bytestream, ptr, n);
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
410 s->bytestream += n;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
411 ptr += linesize;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
412 }
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 return s->bytestream - s->bytestream_start;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
415 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
416
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
417 #if 0
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
418 static int pnm_probe(AVProbeData *pd)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
419 {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
420 const char *p = pd->buf;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
421 if (pd->buf_size >= 8 &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
422 p[0] == 'P' &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
423 p[1] >= '4' && p[1] <= '6' &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
424 pnm_space(p[2]) )
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
425 return AVPROBE_SCORE_MAX - 1; /* to permit pgmyuv probe */
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
426 else
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
427 return 0;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
428 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
429
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
430 static int pgmyuv_probe(AVProbeData *pd)
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 if (match_ext(pd->filename, "pgmyuv"))
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
433 return AVPROBE_SCORE_MAX;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
434 else
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
435 return 0;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
436 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
437
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
438 static int pam_probe(AVProbeData *pd)
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
439 {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
440 const char *p = pd->buf;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
441 if (pd->buf_size >= 8 &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
442 p[0] == 'P' &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
443 p[1] == '7' &&
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
444 p[2] == '\n')
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
445 return AVPROBE_SCORE_MAX;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
446 else
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
447 return 0;
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
448 }
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
449 #endif
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
450
2348
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
451 static int pnm_parse(AVCodecParserContext *s,
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
452 AVCodecContext *avctx,
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
453 uint8_t **poutbuf, int *poutbuf_size,
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
454 const uint8_t *buf, int buf_size)
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
455 {
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
456 ParseContext *pc = s->priv_data;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
457 PNMContext pnmctx;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
458 int next;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
459
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
460 for(; pc->overread>0; pc->overread--){
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
461 pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
462 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
463 retry:
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
464 if(pc->index){
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
465 pnmctx.bytestream_start=
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
466 pnmctx.bytestream= pc->buffer;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
467 pnmctx.bytestream_end= pc->buffer + pc->index;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
468 }else{
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
469 pnmctx.bytestream_start=
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
470 pnmctx.bytestream= buf;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
471 pnmctx.bytestream_end= buf + buf_size;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
472 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
473 if(pnm_decode_header(avctx, &pnmctx) < 0){
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
474 if(pnmctx.bytestream < pnmctx.bytestream_end){
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
475 if(pc->index){
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
476 pc->index=0;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
477 }else{
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
478 buf++;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
479 buf_size--;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
480 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
481 goto retry;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
482 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
483 #if 0
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
484 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
485 memcpy(pc->buffer + pc->index, buf, pc->index);
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
486 pc->index += pc->index;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
487 buf += pc->index;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
488 buf_size -= pc->index;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
489 goto retry;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
490 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
491 #endif
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
492 next= END_NOT_FOUND;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
493 }else{
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
494 next= pnmctx.bytestream - pnmctx.bytestream_start
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
495 + avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
496 if(pnmctx.bytestream_start!=buf)
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
497 next-= pc->index;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
498 if(next > buf_size)
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
499 next= END_NOT_FOUND;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
500 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
501
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
502 if(ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size)<0){
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
503 *poutbuf = NULL;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
504 *poutbuf_size = 0;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
505 return buf_size;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
506 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
507 *poutbuf = (uint8_t *)buf;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
508 *poutbuf_size = buf_size;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
509 return next;
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
510 }
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
511
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
512 AVCodecParser pnm_parser = {
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
513 { CODEC_ID_PGM, CODEC_ID_PGMYUV, CODEC_ID_PPM, CODEC_ID_PBM, CODEC_ID_PAM},
2348
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
514 sizeof(ParseContext),
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
515 NULL,
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
516 pnm_parse,
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
517 ff_parse_close,
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
518 };
d02fb928ca44 pnm parser
michael
parents: 2344
diff changeset
519
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
520 AVCodec pgm_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
521 "pgm",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
522 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
523 CODEC_ID_PGM,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
524 sizeof(PNMContext),
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
525 common_init,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
526 pnm_encode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
527 NULL, //encode_end,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
528 pnm_decode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
529 .pix_fmts= (enum PixelFormat[]){PIX_FMT_GRAY8, -1},
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
530 };
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
531
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
532 AVCodec pgmyuv_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
533 "pgmyuv",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
534 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
535 CODEC_ID_PGMYUV,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
536 sizeof(PNMContext),
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
537 common_init,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
538 pnm_encode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
539 NULL, //encode_end,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
540 pnm_decode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
541 .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
542 };
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
543
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
544 AVCodec ppm_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
545 "ppm",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
546 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
547 CODEC_ID_PPM,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
548 sizeof(PNMContext),
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
549 common_init,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
550 pnm_encode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
551 NULL, //encode_end,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
552 pnm_decode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
553 .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, -1},
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
554 };
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
555
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
556 AVCodec pbm_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
557 "pbm",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
558 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
559 CODEC_ID_PBM,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
560 sizeof(PNMContext),
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
561 common_init,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
562 pnm_encode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
563 NULL, //encode_end,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
564 pnm_decode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
565 .pix_fmts= (enum PixelFormat[]){PIX_FMT_MONOWHITE, -1},
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
566 };
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
567
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
568 AVCodec pam_encoder = {
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
569 "pam",
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
570 CODEC_TYPE_VIDEO,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
571 CODEC_ID_PAM,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
572 sizeof(PNMContext),
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
573 common_init,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
574 pam_encode_frame,
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
575 NULL, //encode_end,
2349
f7f4f06a55c9 merge pam_decode_frame() into pnm_decode_frame()
michael
parents: 2348
diff changeset
576 pnm_decode_frame,
2344
f09680c5e8f4 move p*m from image/lavf -> image2/lavc
michael
parents:
diff changeset
577 .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
578 };