Mercurial > libavformat.hg
annotate mpjpeg.c @ 1258:558c75bd81a0 libavformat
attribute_deprecated
author | michael |
---|---|
date | Sun, 20 Aug 2006 10:42:11 +0000 |
parents | d18cc9a1fd02 |
children | 0899bfe4105c |
rev | line source |
---|---|
47
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
1 /* |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
2 * Multipart JPEG format |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
3 * Copyright (c) 2000, 2001, 2002, 2003 Fabrice Bellard. |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
4 * |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
5 * This library is free software; you can redistribute it and/or |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
6 * modify it under the terms of the GNU Lesser General Public |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
7 * License as published by the Free Software Foundation; either |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
8 * version 2 of the License, or (at your option) any later version. |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
9 * |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
13 * Lesser General Public License for more details. |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
14 * |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Lesser General Public |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
16 * License along with this library; if not, write to the Free Software |
896
edbe5c3717f9
Update licensing information: The FSF changed postal address.
diego
parents:
858
diff
changeset
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
47
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
18 */ |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
19 #include "avformat.h" |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
20 |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
21 /* Multipart JPEG */ |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
22 |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
23 #define BOUNDARY_TAG "ffserver" |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
24 |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
25 static int mpjpeg_write_header(AVFormatContext *s) |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
26 { |
65 | 27 uint8_t buf1[256]; |
47
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
28 |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
29 snprintf(buf1, sizeof(buf1), "--%s\n", BOUNDARY_TAG); |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
30 put_buffer(&s->pb, buf1, strlen(buf1)); |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
31 put_flush_packet(&s->pb); |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
32 return 0; |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
33 } |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
34 |
468 | 35 static int mpjpeg_write_packet(AVFormatContext *s, AVPacket *pkt) |
47
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
36 { |
65 | 37 uint8_t buf1[256]; |
47
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
38 |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
39 snprintf(buf1, sizeof(buf1), "Content-type: image/jpeg\n\n"); |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
40 put_buffer(&s->pb, buf1, strlen(buf1)); |
468 | 41 put_buffer(&s->pb, pkt->data, pkt->size); |
47
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
42 |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
43 snprintf(buf1, sizeof(buf1), "\n--%s\n", BOUNDARY_TAG); |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
44 put_buffer(&s->pb, buf1, strlen(buf1)); |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
45 put_flush_packet(&s->pb); |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
46 return 0; |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
47 } |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
48 |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
49 static int mpjpeg_write_trailer(AVFormatContext *s) |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
50 { |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
51 return 0; |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
52 } |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
53 |
1169 | 54 AVOutputFormat mpjpeg_muxer = { |
47
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
55 "mpjpeg", |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
56 "Mime multipart JPEG format", |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
57 "multipart/x-mixed-replace;boundary=" BOUNDARY_TAG, |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
58 "mjpg", |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
59 0, |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
60 CODEC_ID_NONE, |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
61 CODEC_ID_MJPEG, |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
62 mpjpeg_write_header, |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
63 mpjpeg_write_packet, |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
64 mpjpeg_write_trailer, |
45308962220f
added jpeg image encoder and decoder (new YUV handling routines and mjpeg codec fixes are necessary to go further)
bellard
parents:
diff
changeset
|
65 }; |