[FFmpeg-devel] [PATCH] RTP/Vorbis payload implementation (GSoC qual task)

Colin McQuillan m.niloc
Mon Apr 13 13:58:01 CEST 2009


2009/4/12 Michael Niedermayer <michaelni at gmx.at>:
> On Sun, Apr 12, 2009 at 01:48:26PM +0100, Colin McQuillan wrote:
>> Thanks for the reviews! Updated patch attached.
>>
>> 2009/4/12 Luca Barbato <lu_zero at gentoo.org>:
>> [...]
>> >
>> > +/**
>> > + * Length encoding described in RFC5215 section 3.1.1.
>> > + */
>> > +static int read_base128(uint8_t ** buf, uint8_t * buf_end)
>> > +{
>> > + ? ?int n = 0;
>> > + ? ?for (; *buf < buf_end; ++*buf) {
>> > + ? ? ? ?n <<= 7;
>> > + ? ? ? ?n += **buf & 0x7f;
>> > + ? ? ? ?if (!(**buf & 0x80)) {
>> > + ? ? ? ? ? ?++*buf;
>> > + ? ? ? ? ? ?return n;
>> > + ? ? ? ?}
>> > + ? ?}
>> > + ? ?return 0;
>> > +}
>> >
>> > You should use the implementation that's already present in ffmpeg.
>> >
>>
>> There's a ByteIOContext function ff_get_v but I couldn't find anything
>> for plain bytes (I grepped for <<=\?\s*7 and \*\s*128).
>>
>> 2009/4/12 Michael Niedermayer <michaelni at gmx.at>:
>> [...]
>>
>> >
>> >> +
>> >> + ? ? ? ?/* loop on each attribute */
>> >> + ? ? ? ?while (rtsp_next_attr_and_value
>> >> + ? ? ? ? ? ? ? (&p, attr, sizeof(attr), value, value_alloc)) {
>> >> + ? ? ? ? ? ?/* grab the codec extra_data from the config parameter of the fmtp line */
>> >> + ? ? ? ? ? ?sdp_parse_fmtp_config_vorbis(stream, vorbis_data, attr, value);
>> >> + ? ? ? ?}
>> >> + ? ? ? ?av_free(value);
>> >
>> > also duplicate to at least rtp_h264.c
>> >
>> [...]
>>
>> The while loop is common to both. Would you suggest a
>
> the whole fmtp parsing looks common
>

rtp_vorbis.c now uses the existing fmtp parsing code in rtsp.c instead
of the approach of rtp_h264.c.

>
> [...]
>> +/**
>> + * Out-of-band headers, described in RFC 5251 section 3.2.1
>> + */
>> +static unsigned int
>> +parse_packed_headers(const uint8_t * packed_headers,
>> + ? ? ? ? ? ? ? ? ? ? const uint8_t * packed_headers_end,
>> + ? ? ? ? ? ? ? ? ? ? AVCodecContext * codec, PayloadContext * vorbis_data)
>> +{
>> + ? ?unsigned num_packed, num_headers, length, length1, length2;
>> + ? ?uint8_t *ptr;
>> +
>
>> + ? ?num_packed = bytestream_get_be32(&packed_headers);
>> + ? ?vorbis_data->ident = bytestream_get_be24(&packed_headers);
>> + ? ?length = bytestream_get_be16(&packed_headers);
>
> vertical align
>
>
>> + ? ?num_headers = get_base128(&packed_headers, packed_headers_end);
>> + ? ?length1 = get_base128(&packed_headers, packed_headers_end);
>> + ? ?length2 = get_base128(&packed_headers, packed_headers_end);
>
> same
>
>
> [...]
>> + ? ?ptr = codec->extradata = av_mallocz(length + length / 255 + 64);
>> + ? ?if (!ptr) {
>> + ? ? ? ?av_log(codec, AV_LOG_ERROR, "Out of memory");
>> + ? ? ? ?return -1;
>
> AVERROR(ENOMEM)
>
> [...]

Updated patch attached.

--
Colin McQuillan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffmpeg-vorbis-rtp-3.patch
Type: text/x-diff
Size: 12843 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090413/33683576/attachment.patch>



More information about the ffmpeg-devel mailing list