Revision 45aa9080

View differences:

Changelog
50 50
- Deluxe Paint Animation playback system
51 51
- SIPR decoder
52 52
- Adobe Filmstrip muxer and demuxer
53
- RTP depacketization of H.263
53 54

  
54 55

  
55 56

  
libavformat/Makefile
213 213
                                            rdt.o         \
214 214
                                            rtp.o         \
215 215
                                            rtpdec.o      \
216
                                            rtpdec_h263.o \
216 217
                                            rtp_asf.o     \
217 218
                                            rtp_h264.o    \
218 219
                                            rtp_vorbis.o
libavformat/avformat.h
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, \
libavformat/rtpdec.c
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 62
{
62 63
    ff_register_dynamic_payload_handler(&mp4v_es_handler);
63 64
    ff_register_dynamic_payload_handler(&mpeg4_generic_handler);
65
    ff_register_dynamic_payload_handler(&ff_h263_1998_dynamic_handler);
66
    ff_register_dynamic_payload_handler(&ff_h263_2000_dynamic_handler);
64 67
    ff_register_dynamic_payload_handler(&ff_h264_dynamic_handler);
65 68
    ff_register_dynamic_payload_handler(&ff_vorbis_dynamic_handler);
66 69

  
......
301 304
        case CODEC_ID_MP2:
302 305
        case CODEC_ID_MP3:
303 306
        case CODEC_ID_MPEG4:
307
        case CODEC_ID_H263:
304 308
        case CODEC_ID_H264:
305 309
            st->need_parsing = AVSTREAM_PARSE_FULL;
306 310
            break;
libavformat/rtpdec_h263.c
1
/*
2
 * RTP H.263 Depacketizer, RFC 4629
3
 * Copyright (c) 2010 Martin Storsjo
4
 *
5
 * This file is part of FFmpeg.
6
 *
7
 * FFmpeg is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * FFmpeg is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with FFmpeg; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 */
21

  
22
#include "avformat.h"
23
#include "rtpdec_h263.h"
24
#include "libavutil/intreadwrite.h"
25

  
26
static int h263_handle_packet(AVFormatContext *ctx,
27
                              PayloadContext *data,
28
                              AVStream *st,
29
                              AVPacket * pkt,
30
                              uint32_t * timestamp,
31
                              const uint8_t * buf,
32
                              int len, int flags)
33
{
34
    uint8_t *ptr;
35
    uint16_t header;
36
    int startcode, vrc, picture_header;
37

  
38
    if (len < 2) {
39
        av_log(ctx, AV_LOG_ERROR, "Too short H.263 RTP packet\n");
40
        return AVERROR_INVALIDDATA;
41
    }
42

  
43
    /* Decode the 16 bit H.263+ payload header, as described in section
44
     * 5.1 of RFC 4629. The fields of this header are:
45
     * - 5 reserved bits, should be ignored.
46
     * - One bit (P, startcode), indicating a picture start, picture segment
47
     *   start or video sequence end. If set, two zero bytes should be
48
     *   prepended to the payload.
49
     * - One bit (V, vrc), indicating the presence of an 8 bit Video
50
     *   Redundancy Coding field after this 16 bit header.
51
     * - 6 bits (PLEN, picture_header), the length (in bytes) of an extra
52
     *   picture header, following the VRC field.
53
     * - 3 bits (PEBIT), the number of bits to ignore of the last byte
54
     *   of the extra picture header. (Not used at the moment.)
55
     */
56
    header = AV_RB16(buf);
57
    startcode      = (header & 0x0400) >> 9;
58
    vrc            =  header & 0x0200;
59
    picture_header = (header & 0x01f8) >> 3;
60
    buf += 2;
61
    len -= 2;
62

  
63
    if (vrc) {
64
        /* Skip VRC header if present, not used at the moment. */
65
        buf += 1;
66
        len -= 1;
67
    }
68
    if (picture_header) {
69
        /* Skip extra picture header if present, not used at the moment. */
70
        buf += picture_header;
71
        len -= picture_header;
72
    }
73

  
74
    if (len < 0) {
75
        av_log(ctx, AV_LOG_ERROR, "Too short H.263 RTP packet\n");
76
        return AVERROR_INVALIDDATA;
77
    }
78

  
79
    if (av_new_packet(pkt, len + startcode)) {
80
        av_log(ctx, AV_LOG_ERROR, "Out of memory\n");
81
        return AVERROR_NOMEM;
82
    }
83
    pkt->stream_index = st->index;
84
    ptr = pkt->data;
85

  
86
    if (startcode) {
87
        *ptr++ = 0;
88
        *ptr++ = 0;
89
    }
90
    memcpy(ptr, buf, len);
91

  
92
    return 0;
93
}
94

  
95
RTPDynamicProtocolHandler ff_h263_1998_dynamic_handler = {
96
    .enc_name         = "H263-1998",
97
    .codec_type       = CODEC_TYPE_VIDEO,
98
    .codec_id         = CODEC_ID_H263,
99
    .parse_packet     = h263_handle_packet,
100
};
101

  
102
RTPDynamicProtocolHandler ff_h263_2000_dynamic_handler = {
103
    .enc_name         = "H263-2000",
104
    .codec_type       = CODEC_TYPE_VIDEO,
105
    .codec_id         = CODEC_ID_H263,
106
    .parse_packet     = h263_handle_packet,
107
};
108

  
libavformat/rtpdec_h263.h
1
/*
2
 * RTP H.263 Depacketizer, RFC 4629
3
 * Copyright (c) 2010 Martin Storsjo
4
 *
5
 * This file is part of FFmpeg.
6
 *
7
 * FFmpeg is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * FFmpeg is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with FFmpeg; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 */
21

  
22
#ifndef AVFORMAT_RTPDEC_H263_H
23
#define AVFORMAT_RTPDEC_H263_H
24

  
25
#include "rtpdec.h"
26

  
27
extern RTPDynamicProtocolHandler ff_h263_1998_dynamic_handler;
28
extern RTPDynamicProtocolHandler ff_h263_2000_dynamic_handler;
29

  
30
#endif /* AVFORMAT_RTPDEC_H263_H */

Also available in: Unified diff