Originally committed as revision 21512 to svn://svn.ffmpeg.org/ffmpeg/trunk
Ronald S. Bultje authored on 2010/01/29 01:08:13... | ... |
@@ -22,7 +22,7 @@ |
22 | 22 |
#define AVFORMAT_AVFORMAT_H |
23 | 23 |
|
24 | 24 |
#define LIBAVFORMAT_VERSION_MAJOR 52 |
25 |
-#define LIBAVFORMAT_VERSION_MINOR 47 |
|
25 |
+#define LIBAVFORMAT_VERSION_MINOR 48 |
|
26 | 26 |
#define LIBAVFORMAT_VERSION_MICRO 0 |
27 | 27 |
|
28 | 28 |
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |
... | ... |
@@ -33,6 +33,7 @@ |
33 | 33 |
#include "rtp_asf.h" |
34 | 34 |
#include "rtp_h264.h" |
35 | 35 |
#include "rtp_vorbis.h" |
36 |
+#include "rtpdec_h263.h" |
|
36 | 37 |
|
37 | 38 |
//#define DEBUG |
38 | 39 |
|
... | ... |
@@ -61,6 +62,8 @@ void av_register_rtp_dynamic_payload_handlers(void) |
61 | 61 |
{ |
62 | 62 |
ff_register_dynamic_payload_handler(&mp4v_es_handler); |
63 | 63 |
ff_register_dynamic_payload_handler(&mpeg4_generic_handler); |
64 |
+ ff_register_dynamic_payload_handler(&ff_h263_1998_dynamic_handler); |
|
65 |
+ ff_register_dynamic_payload_handler(&ff_h263_2000_dynamic_handler); |
|
64 | 66 |
ff_register_dynamic_payload_handler(&ff_h264_dynamic_handler); |
65 | 67 |
ff_register_dynamic_payload_handler(&ff_vorbis_dynamic_handler); |
66 | 68 |
|
... | ... |
@@ -301,6 +304,7 @@ RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *r |
301 | 301 |
case CODEC_ID_MP2: |
302 | 302 |
case CODEC_ID_MP3: |
303 | 303 |
case CODEC_ID_MPEG4: |
304 |
+ case CODEC_ID_H263: |
|
304 | 305 |
case CODEC_ID_H264: |
305 | 306 |
st->need_parsing = AVSTREAM_PARSE_FULL; |
306 | 307 |
break; |
307 | 308 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,108 @@ |
0 |
+/* |
|
1 |
+ * RTP H.263 Depacketizer, RFC 4629 |
|
2 |
+ * Copyright (c) 2010 Martin Storsjo |
|
3 |
+ * |
|
4 |
+ * This file is part of FFmpeg. |
|
5 |
+ * |
|
6 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
7 |
+ * modify it under the terms of the GNU Lesser General Public |
|
8 |
+ * License as published by the Free Software Foundation; either |
|
9 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
+ * Lesser General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU Lesser General Public |
|
17 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
+ */ |
|
20 |
+ |
|
21 |
+#include "avformat.h" |
|
22 |
+#include "rtpdec_h263.h" |
|
23 |
+#include "libavutil/intreadwrite.h" |
|
24 |
+ |
|
25 |
+static int h263_handle_packet(AVFormatContext *ctx, |
|
26 |
+ PayloadContext *data, |
|
27 |
+ AVStream *st, |
|
28 |
+ AVPacket * pkt, |
|
29 |
+ uint32_t * timestamp, |
|
30 |
+ const uint8_t * buf, |
|
31 |
+ int len, int flags) |
|
32 |
+{ |
|
33 |
+ uint8_t *ptr; |
|
34 |
+ uint16_t header; |
|
35 |
+ int startcode, vrc, picture_header; |
|
36 |
+ |
|
37 |
+ if (len < 2) { |
|
38 |
+ av_log(ctx, AV_LOG_ERROR, "Too short H.263 RTP packet\n"); |
|
39 |
+ return AVERROR_INVALIDDATA; |
|
40 |
+ } |
|
41 |
+ |
|
42 |
+ /* Decode the 16 bit H.263+ payload header, as described in section |
|
43 |
+ * 5.1 of RFC 4629. The fields of this header are: |
|
44 |
+ * - 5 reserved bits, should be ignored. |
|
45 |
+ * - One bit (P, startcode), indicating a picture start, picture segment |
|
46 |
+ * start or video sequence end. If set, two zero bytes should be |
|
47 |
+ * prepended to the payload. |
|
48 |
+ * - One bit (V, vrc), indicating the presence of an 8 bit Video |
|
49 |
+ * Redundancy Coding field after this 16 bit header. |
|
50 |
+ * - 6 bits (PLEN, picture_header), the length (in bytes) of an extra |
|
51 |
+ * picture header, following the VRC field. |
|
52 |
+ * - 3 bits (PEBIT), the number of bits to ignore of the last byte |
|
53 |
+ * of the extra picture header. (Not used at the moment.) |
|
54 |
+ */ |
|
55 |
+ header = AV_RB16(buf); |
|
56 |
+ startcode = (header & 0x0400) >> 9; |
|
57 |
+ vrc = header & 0x0200; |
|
58 |
+ picture_header = (header & 0x01f8) >> 3; |
|
59 |
+ buf += 2; |
|
60 |
+ len -= 2; |
|
61 |
+ |
|
62 |
+ if (vrc) { |
|
63 |
+ /* Skip VRC header if present, not used at the moment. */ |
|
64 |
+ buf += 1; |
|
65 |
+ len -= 1; |
|
66 |
+ } |
|
67 |
+ if (picture_header) { |
|
68 |
+ /* Skip extra picture header if present, not used at the moment. */ |
|
69 |
+ buf += picture_header; |
|
70 |
+ len -= picture_header; |
|
71 |
+ } |
|
72 |
+ |
|
73 |
+ if (len < 0) { |
|
74 |
+ av_log(ctx, AV_LOG_ERROR, "Too short H.263 RTP packet\n"); |
|
75 |
+ return AVERROR_INVALIDDATA; |
|
76 |
+ } |
|
77 |
+ |
|
78 |
+ if (av_new_packet(pkt, len + startcode)) { |
|
79 |
+ av_log(ctx, AV_LOG_ERROR, "Out of memory\n"); |
|
80 |
+ return AVERROR_NOMEM; |
|
81 |
+ } |
|
82 |
+ pkt->stream_index = st->index; |
|
83 |
+ ptr = pkt->data; |
|
84 |
+ |
|
85 |
+ if (startcode) { |
|
86 |
+ *ptr++ = 0; |
|
87 |
+ *ptr++ = 0; |
|
88 |
+ } |
|
89 |
+ memcpy(ptr, buf, len); |
|
90 |
+ |
|
91 |
+ return 0; |
|
92 |
+} |
|
93 |
+ |
|
94 |
+RTPDynamicProtocolHandler ff_h263_1998_dynamic_handler = { |
|
95 |
+ .enc_name = "H263-1998", |
|
96 |
+ .codec_type = CODEC_TYPE_VIDEO, |
|
97 |
+ .codec_id = CODEC_ID_H263, |
|
98 |
+ .parse_packet = h263_handle_packet, |
|
99 |
+}; |
|
100 |
+ |
|
101 |
+RTPDynamicProtocolHandler ff_h263_2000_dynamic_handler = { |
|
102 |
+ .enc_name = "H263-2000", |
|
103 |
+ .codec_type = CODEC_TYPE_VIDEO, |
|
104 |
+ .codec_id = CODEC_ID_H263, |
|
105 |
+ .parse_packet = h263_handle_packet, |
|
106 |
+}; |
|
107 |
+ |
0 | 108 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,30 @@ |
0 |
+/* |
|
1 |
+ * RTP H.263 Depacketizer, RFC 4629 |
|
2 |
+ * Copyright (c) 2010 Martin Storsjo |
|
3 |
+ * |
|
4 |
+ * This file is part of FFmpeg. |
|
5 |
+ * |
|
6 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
7 |
+ * modify it under the terms of the GNU Lesser General Public |
|
8 |
+ * License as published by the Free Software Foundation; either |
|
9 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
+ * Lesser General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU Lesser General Public |
|
17 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
+ */ |
|
20 |
+ |
|
21 |
+#ifndef AVFORMAT_RTPDEC_H263_H |
|
22 |
+#define AVFORMAT_RTPDEC_H263_H |
|
23 |
+ |
|
24 |
+#include "rtpdec.h" |
|
25 |
+ |
|
26 |
+extern RTPDynamicProtocolHandler ff_h263_1998_dynamic_handler; |
|
27 |
+extern RTPDynamicProtocolHandler ff_h263_2000_dynamic_handler; |
|
28 |
+ |
|
29 |
+#endif /* AVFORMAT_RTPDEC_H263_H */ |