diff options
Diffstat (limited to 'libavformat/rtpdec_latm.c')
-rw-r--r-- | libavformat/rtpdec_latm.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/libavformat/rtpdec_latm.c b/libavformat/rtpdec_latm.c index 9893aeb..a25c07f 100644 --- a/libavformat/rtpdec_latm.c +++ b/libavformat/rtpdec_latm.c @@ -2,30 +2,28 @@ * RTP Depacketization of MP4A-LATM, RFC 3016 * Copyright (c) 2010 Martin Storsjo * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/avstring.h" - -#include "libavcodec/bitstream.h" - #include "avio_internal.h" #include "rtpdec_formats.h" #include "internal.h" +#include "libavutil/avstring.h" +#include "libavcodec/get_bits.h" struct PayloadContext { AVIOContext *dyn_buf; @@ -37,7 +35,7 @@ struct PayloadContext { static void latm_close_context(PayloadContext *data) { ffio_free_dyn_buf(&data->dyn_buf); - av_free(data->buf); + av_freep(&data->buf); } static int latm_parse_packet(AVFormatContext *ctx, PayloadContext *data, @@ -60,7 +58,7 @@ static int latm_parse_packet(AVFormatContext *ctx, PayloadContext *data, if (!(flags & RTP_FLAG_MARKER)) return AVERROR(EAGAIN); - av_free(data->buf); + av_freep(&data->buf); data->len = avio_close_dyn_buf(data->dyn_buf, &data->buf); data->dyn_buf = NULL; data->pos = 0; @@ -94,7 +92,7 @@ static int latm_parse_packet(AVFormatContext *ctx, PayloadContext *data, static int parse_fmtp_config(AVStream *st, const char *value) { int len = ff_hex_to_data(NULL, value), i, ret = 0; - BitstreamContext bc; + GetBitContext gb; uint8_t *config; int audio_mux_version, same_time_framing, num_programs, num_layers; @@ -103,12 +101,12 @@ static int parse_fmtp_config(AVStream *st, const char *value) if (!config) return AVERROR(ENOMEM); ff_hex_to_data(config, value); - bitstream_init8(&bc, config, len); - audio_mux_version = bitstream_read(&bc, 1); - same_time_framing = bitstream_read(&bc, 1); - bitstream_skip(&bc, 6); /* num_sub_frames */ - num_programs = bitstream_read(&bc, 4); - num_layers = bitstream_read(&bc, 3); + init_get_bits(&gb, config, len*8); + audio_mux_version = get_bits(&gb, 1); + same_time_framing = get_bits(&gb, 1); + skip_bits(&gb, 6); /* num_sub_frames */ + num_programs = get_bits(&gb, 4); + num_layers = get_bits(&gb, 3); if (audio_mux_version != 0 || same_time_framing != 1 || num_programs != 0 || num_layers != 0) { avpriv_report_missing_feature(NULL, "LATM config (%d,%d,%d,%d)", @@ -118,15 +116,12 @@ static int parse_fmtp_config(AVStream *st, const char *value) goto end; } av_freep(&st->codecpar->extradata); - st->codecpar->extradata_size = (bitstream_bits_left(&bc) + 7) / 8; - st->codecpar->extradata = av_mallocz(st->codecpar->extradata_size + - AV_INPUT_BUFFER_PADDING_SIZE); - if (!st->codecpar->extradata) { + if (ff_alloc_extradata(st->codecpar, (get_bits_left(&gb) + 7)/8)) { ret = AVERROR(ENOMEM); goto end; } for (i = 0; i < st->codecpar->extradata_size; i++) - st->codecpar->extradata[i] = bitstream_read(&bc, 8); + st->codecpar->extradata[i] = get_bits(&gb, 8); end: av_free(config); |