annotate jpeg.c @ 25:bceee17e8d75 libavformat

removed redundant 4CC
author mmu_man
date Fri, 17 Jan 2003 09:22:52 +0000
parents 39c4c4336486
children 45308962220f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1 /*
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
2 * JPEG based formats
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
3 * Copyright (c) 2000, 2001 Fabrice Bellard.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
4 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
9 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
13 * Lesser General Public License for more details.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
14 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
18 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
19 #include "avformat.h"
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
20
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
21 /* Multipart JPEG */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
22
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
23 #define BOUNDARY_TAG "ffserver"
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
24
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
25 static int mpjpeg_write_header(AVFormatContext *s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
26 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
27 UINT8 buf1[256];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
28
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
29 snprintf(buf1, sizeof(buf1), "--%s\n", BOUNDARY_TAG);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
30 put_buffer(&s->pb, buf1, strlen(buf1));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
31 put_flush_packet(&s->pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
32 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
33 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
34
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
35 static int mpjpeg_write_packet(AVFormatContext *s, int stream_index,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
36 UINT8 *buf, int size, int force_pts)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
37 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
38 UINT8 buf1[256];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
39
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
40 snprintf(buf1, sizeof(buf1), "Content-type: image/jpeg\n\n");
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
41 put_buffer(&s->pb, buf1, strlen(buf1));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
42 put_buffer(&s->pb, buf, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
43
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
44 snprintf(buf1, sizeof(buf1), "\n--%s\n", BOUNDARY_TAG);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
45 put_buffer(&s->pb, buf1, strlen(buf1));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
46 put_flush_packet(&s->pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
47 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
48 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
49
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
50 static int mpjpeg_write_trailer(AVFormatContext *s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
51 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
52 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
53 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
54
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
55 static AVOutputFormat mpjpeg_format = {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
56 "mpjpeg",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
57 "Mime multipart JPEG format",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
58 "multipart/x-mixed-replace;boundary=" BOUNDARY_TAG,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
59 "mjpg",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
60 0,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
61 CODEC_ID_NONE,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
62 CODEC_ID_MJPEG,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
63 mpjpeg_write_header,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
64 mpjpeg_write_packet,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
65 mpjpeg_write_trailer,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
66 };
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
67
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
68
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
69 /*************************************/
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
70 /* single frame JPEG */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
71
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
72 static int single_jpeg_write_header(AVFormatContext *s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
73 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
74 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
75 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
76
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
77 static int single_jpeg_write_packet(AVFormatContext *s, int stream_index,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
78 UINT8 *buf, int size, int force_pts)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
79 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
80 put_buffer(&s->pb, buf, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
81 put_flush_packet(&s->pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
82 return 1; /* no more data can be sent */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
83 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
84
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
85 static int single_jpeg_write_trailer(AVFormatContext *s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
86 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
87 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
88 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
89
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
90 static AVOutputFormat single_jpeg_format = {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
91 "singlejpeg",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
92 "single JPEG image",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
93 "image/jpeg",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
94 NULL, /* note: no extension to favorize jpeg multiple images match */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
95 0,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
96 CODEC_ID_NONE,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
97 CODEC_ID_MJPEG,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
98 single_jpeg_write_header,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
99 single_jpeg_write_packet,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
100 single_jpeg_write_trailer,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
101 };
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
102
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
103 /*************************************/
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
104 /* multiple jpeg images */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
105
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
106 typedef struct JpegContext {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
107 char path[1024];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
108 int img_number;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
109 } JpegContext;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
110
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
111 static int jpeg_write_header(AVFormatContext *s1)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
112 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
113 JpegContext *s;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
114
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
115 s = av_mallocz(sizeof(JpegContext));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
116 if (!s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
117 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
118 s1->priv_data = s;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
119 pstrcpy(s->path, sizeof(s->path), s1->filename);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
120 s->img_number = 1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
121 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
122 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
123
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
124 static int jpeg_write_packet(AVFormatContext *s1, int stream_index,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
125 UINT8 *buf, int size, int force_pts)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
126 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
127 JpegContext *s = s1->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
128 char filename[1024];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
129 ByteIOContext f1, *pb = &f1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
130
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
131 if (get_frame_filename(filename, sizeof(filename),
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
132 s->path, s->img_number) < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
133 return -EIO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
134 if (url_fopen(pb, filename, URL_WRONLY) < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
135 return -EIO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
136
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
137 put_buffer(pb, buf, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
138 put_flush_packet(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
139
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
140 url_fclose(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
141 s->img_number++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
142
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
143 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
144 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
145
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
146 static int jpeg_write_trailer(AVFormatContext *s1)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
147 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
148 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
149 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
150
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
151 /***/
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
152
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
153 static int jpeg_read_header(AVFormatContext *s1, AVFormatParameters *ap)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
154 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
155 JpegContext *s;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
156 int i;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
157 char buf[1024];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
158 ByteIOContext pb1, *f = &pb1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
159 AVStream *st;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
160
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
161 s = av_mallocz(sizeof(JpegContext));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
162 if (!s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
163 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
164 s1->priv_data = s;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
165 pstrcpy(s->path, sizeof(s->path), s1->filename);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
166
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
167 s1->nb_streams = 1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
168 st = av_mallocz(sizeof(AVStream));
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
169 if (!st) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
170 av_free(s);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
171 return -ENOMEM;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
172 }
5
39c4c4336486 cleanup
michaelni
parents: 0
diff changeset
173 avcodec_get_context_defaults(&st->codec);
39c4c4336486 cleanup
michaelni
parents: 0
diff changeset
174
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
175 s1->streams[0] = st;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
176 s->img_number = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
177
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
178 /* try to find the first image */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
179 for(i=0;i<5;i++) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
180 if (get_frame_filename(buf, sizeof(buf), s->path, s->img_number) < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
181 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
182 if (url_fopen(f, buf, URL_RDONLY) >= 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
183 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
184 s->img_number++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
185 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
186 if (i == 5)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
187 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
188 url_fclose(f);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
189 st->codec.codec_type = CODEC_TYPE_VIDEO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
190 st->codec.codec_id = CODEC_ID_MJPEG;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
191
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
192 if (!ap || !ap->frame_rate)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
193 st->codec.frame_rate = 25 * FRAME_RATE_BASE;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
194 else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
195 st->codec.frame_rate = ap->frame_rate;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
196 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
197 fail:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
198 av_free(s);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
199 return -EIO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
200 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
201
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
202 static int jpeg_read_packet(AVFormatContext *s1, AVPacket *pkt)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
203 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
204 JpegContext *s = s1->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
205 char filename[1024];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
206 int size;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
207 ByteIOContext f1, *f = &f1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
208
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
209 if (get_frame_filename(filename, sizeof(filename),
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
210 s->path, s->img_number) < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
211 return -EIO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
212
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
213 f = &f1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
214 if (url_fopen(f, filename, URL_RDONLY) < 0)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
215 return -EIO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
216
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
217 size = url_seek(url_fileno(f), 0, SEEK_END);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
218 url_seek(url_fileno(f), 0, SEEK_SET);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
219
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
220 av_new_packet(pkt, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
221 pkt->stream_index = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
222 get_buffer(f, pkt->data, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
223
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
224 url_fclose(f);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
225 s->img_number++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
226 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
227 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
228
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
229 static int jpeg_read_close(AVFormatContext *s1)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
230 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
231 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
232 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
233
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
234 static AVInputFormat jpeg_iformat = {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
235 "jpeg",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
236 "JPEG image",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
237 sizeof(JpegContext),
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
238 NULL,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
239 jpeg_read_header,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
240 jpeg_read_packet,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
241 jpeg_read_close,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
242 NULL,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
243 .flags = AVFMT_NOFILE | AVFMT_NEEDNUMBER,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
244 .extensions = "jpg,jpeg",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
245 };
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
246
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
247 static AVOutputFormat jpeg_oformat = {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
248 "jpeg",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
249 "JPEG image",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
250 "image/jpeg",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
251 "jpg,jpeg",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
252 sizeof(JpegContext),
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
253 CODEC_ID_NONE,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
254 CODEC_ID_MJPEG,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
255 jpeg_write_header,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
256 jpeg_write_packet,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
257 jpeg_write_trailer,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
258 .flags = AVFMT_NOFILE | AVFMT_NEEDNUMBER,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
259 };
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
260
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
261 int jpeg_init(void)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
262 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
263 av_register_output_format(&mpjpeg_format);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
264 av_register_output_format(&single_jpeg_format);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
265 av_register_input_format(&jpeg_iformat);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
266 av_register_output_format(&jpeg_oformat);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
267 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
268 }