annotate rtpenc_vp8.c @ 6471:b3aea89a4f63 libavformat

nutenc: fix unstable floating-point calculations
author mru
date Fri, 10 Sep 2010 13:16:08 +0000
parents 0bcd6a8bc5d5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6379
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
1 /*
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
2 * RTP VP8 Packetizer
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
3 * Copyright (c) 2010 Josh Allmann
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
4 *
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
5 * This file is part of FFmpeg.
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
6 *
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
11 *
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
15 * Lesser General Public License for more details.
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
16 *
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
20 */
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
21
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
22 #include "rtpenc.h"
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
23
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
24 /* Based on a draft spec for VP8 RTP.
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
25 * ( http://www.webmproject.org/code/specs/rtp/ ) */
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
26 void ff_rtp_send_vp8(AVFormatContext *s1, const uint8_t *buf, int size)
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
27 {
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
28 RTPMuxContext *s = s1->priv_data;
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
29 int len, max_packet_size;
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
30
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
31 s->buf_ptr = s->buf;
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
32 s->timestamp = s->cur_timestamp;
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
33 max_packet_size = s->max_payload_size - 1; // minus one for header byte
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
34
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
35 *s->buf_ptr++ = 1; // 0b1 indicates start of frame
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
36 while (size > 0) {
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
37 len = FFMIN(size, max_packet_size);
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
38
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
39 memcpy(s->buf_ptr, buf, len);
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
40 ff_rtp_send_data(s1, s->buf, len+1, size == len); // marker bit is last packet in frame
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
41
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
42 size -= len;
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
43 buf += len;
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
44 s->buf_ptr = s->buf;
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
45 *s->buf_ptr++ = 0; // payload descriptor
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
46 }
0bcd6a8bc5d5 Add RTP packetization of VP8
mstorsjo
parents:
diff changeset
47 }