From 1434683241f423378f5485aab929e94e400e05b4 Mon Sep 17 00:00:00 2001 From: Alexandra Hájková Date: Sun, 17 Apr 2016 16:59:24 +0200 Subject: rtp: convert to the new bitstream reader --- libavformat/rtpdec.c | 2 +- libavformat/rtpdec_h261.c | 18 +++++++++--------- libavformat/rtpdec_h263_rfc2190.c | 18 +++++++++--------- libavformat/rtpdec_latm.c | 20 ++++++++++---------- libavformat/rtpdec_mpeg4.c | 10 +++++----- libavformat/rtpdec_qt.c | 30 +++++++++++++++--------------- libavformat/rtpenc_h263_rfc2190.c | 26 +++++++++++++------------- 7 files changed, 62 insertions(+), 62 deletions(-) diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 2512239880..3140fed2a3 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -22,7 +22,7 @@ #include "libavutil/mathematics.h" #include "libavutil/avstring.h" #include "libavutil/time.h" -#include "libavcodec/get_bits.h" +#include "libavcodec/bitstream.h" #include "avformat.h" #include "network.h" #include "srtp.h" diff --git a/libavformat/rtpdec_h261.c b/libavformat/rtpdec_h261.c index 00086c21c5..1cc62718d9 100644 --- a/libavformat/rtpdec_h261.c +++ b/libavformat/rtpdec_h261.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavcodec/get_bits.h" +#include "libavcodec/bitstream.h" #include "avformat.h" #include "avio_internal.h" #include "rtpdec_formats.h" @@ -118,18 +118,18 @@ static int h261_handle_packet(AVFormatContext *ctx, PayloadContext *rtp_h261_ctx avio_w8(rtp_h261_ctx->buf, rtp_h261_ctx->endbyte); } else { /* ebit/sbit values inconsistent, assuming packet loss */ - GetBitContext gb; - init_get_bits(&gb, buf, len*8 - ebit); - skip_bits(&gb, sbit); + BitstreamContext bc; + bitstream_init(&bc, buf, len*8 - ebit); + bitstream_skip(&bc, sbit); if (rtp_h261_ctx->endbyte_bits) { - rtp_h261_ctx->endbyte |= get_bits(&gb, 8 - rtp_h261_ctx->endbyte_bits); + rtp_h261_ctx->endbyte |= bitstream_read(&bc, 8 - rtp_h261_ctx->endbyte_bits); avio_w8(rtp_h261_ctx->buf, rtp_h261_ctx->endbyte); } - while (get_bits_left(&gb) >= 8) - avio_w8(rtp_h261_ctx->buf, get_bits(&gb, 8)); - rtp_h261_ctx->endbyte_bits = get_bits_left(&gb); + while (bitstream_bits_left(&bc) >= 8) + avio_w8(rtp_h261_ctx->buf, bitstream_read(&bc, 8)); + rtp_h261_ctx->endbyte_bits = bitstream_bits_left(&bc); if (rtp_h261_ctx->endbyte_bits) - rtp_h261_ctx->endbyte = get_bits(&gb, rtp_h261_ctx->endbyte_bits) << + rtp_h261_ctx->endbyte = bitstream_read(&bc, rtp_h261_ctx->endbyte_bits) << (8 - rtp_h261_ctx->endbyte_bits); ebit = 0; len = 0; diff --git a/libavformat/rtpdec_h263_rfc2190.c b/libavformat/rtpdec_h263_rfc2190.c index 019eea779b..ff7ce76c96 100644 --- a/libavformat/rtpdec_h263_rfc2190.c +++ b/libavformat/rtpdec_h263_rfc2190.c @@ -30,7 +30,7 @@ #include "rtpdec_formats.h" #include "libavutil/attributes.h" #include "libavutil/intreadwrite.h" -#include "libavcodec/get_bits.h" +#include "libavcodec/bitstream.h" struct PayloadContext { AVIOContext *buf; @@ -141,18 +141,18 @@ static int h263_handle_packet(AVFormatContext *ctx, PayloadContext *data, avio_w8(data->buf, data->endbyte); } else { /* Start/end skip bits not matching - missed packets? */ - GetBitContext gb; - init_get_bits(&gb, buf, len*8 - ebit); - skip_bits(&gb, sbit); + BitstreamContext bc; + bitstream_init(&bc, buf, len*8 - ebit); + bitstream_skip(&bc, sbit); if (data->endbyte_bits) { - data->endbyte |= get_bits(&gb, 8 - data->endbyte_bits); + data->endbyte |= bitstream_read(&bc, 8 - data->endbyte_bits); avio_w8(data->buf, data->endbyte); } - while (get_bits_left(&gb) >= 8) - avio_w8(data->buf, get_bits(&gb, 8)); - data->endbyte_bits = get_bits_left(&gb); + while (bitstream_bits_left(&bc) >= 8) + avio_w8(data->buf, bitstream_read(&bc, 8)); + data->endbyte_bits = bitstream_bits_left(&bc); if (data->endbyte_bits) - data->endbyte = get_bits(&gb, data->endbyte_bits) << + data->endbyte = bitstream_read(&bc, data->endbyte_bits) << (8 - data->endbyte_bits); ebit = 0; len = 0; diff --git a/libavformat/rtpdec_latm.c b/libavformat/rtpdec_latm.c index 6be0a25d2b..326d141a89 100644 --- a/libavformat/rtpdec_latm.c +++ b/libavformat/rtpdec_latm.c @@ -23,7 +23,7 @@ #include "rtpdec_formats.h" #include "internal.h" #include "libavutil/avstring.h" -#include "libavcodec/get_bits.h" +#include "libavcodec/bitstream.h" struct PayloadContext { AVIOContext *dyn_buf; @@ -92,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; - GetBitContext gb; + BitstreamContext bc; uint8_t *config; int audio_mux_version, same_time_framing, num_programs, num_layers; @@ -101,12 +101,12 @@ static int parse_fmtp_config(AVStream *st, const char *value) if (!config) return AVERROR(ENOMEM); ff_hex_to_data(config, value); - 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); + bitstream_init(&bc, config, len*8); + 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); if (audio_mux_version != 0 || same_time_framing != 1 || num_programs != 0 || num_layers != 0) { av_log(NULL, AV_LOG_WARNING, "Unsupported LATM config (%d,%d,%d,%d)\n", @@ -116,7 +116,7 @@ static int parse_fmtp_config(AVStream *st, const char *value) goto end; } av_freep(&st->codecpar->extradata); - st->codecpar->extradata_size = (get_bits_left(&gb) + 7)/8; + 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) { @@ -124,7 +124,7 @@ static int parse_fmtp_config(AVStream *st, const char *value) goto end; } for (i = 0; i < st->codecpar->extradata_size; i++) - st->codecpar->extradata[i] = get_bits(&gb, 8); + st->codecpar->extradata[i] = bitstream_read(&bc, 8); end: av_free(config); diff --git a/libavformat/rtpdec_mpeg4.c b/libavformat/rtpdec_mpeg4.c index d5fea4f59c..6d5081dcc0 100644 --- a/libavformat/rtpdec_mpeg4.c +++ b/libavformat/rtpdec_mpeg4.c @@ -31,7 +31,7 @@ #include "internal.h" #include "libavutil/attributes.h" #include "libavutil/avstring.h" -#include "libavcodec/get_bits.h" +#include "libavcodec/bitstream.h" #define MAX_AAC_HBR_FRAME_SIZE 8191 @@ -113,7 +113,7 @@ static int parse_fmtp_config(AVCodecParameters *par, char *value) static int rtp_parse_mp4_au(PayloadContext *data, const uint8_t *buf, int len) { int au_headers_length, au_header_size, i; - GetBitContext getbitcontext; + BitstreamContext bctx; if (len < 2) return AVERROR_INVALIDDATA; @@ -134,7 +134,7 @@ static int rtp_parse_mp4_au(PayloadContext *data, const uint8_t *buf, int len) if (len < data->au_headers_length_bytes) return AVERROR_INVALIDDATA; - init_get_bits(&getbitcontext, buf, data->au_headers_length_bytes * 8); + bitstream_init(&bctx, buf, data->au_headers_length_bytes * 8); /* XXX: Wrong if optional additional sections are present (cts, dts etc...) */ au_header_size = data->sizelength + data->indexlength; @@ -151,8 +151,8 @@ static int rtp_parse_mp4_au(PayloadContext *data, const uint8_t *buf, int len) } for (i = 0; i < data->nb_au_headers; ++i) { - data->au_headers[i].size = get_bits_long(&getbitcontext, data->sizelength); - data->au_headers[i].index = get_bits_long(&getbitcontext, data->indexlength); + data->au_headers[i].size = bitstream_read(&bctx, data->sizelength); + data->au_headers[i].index = bitstream_read(&bctx, data->indexlength); } return 0; diff --git a/libavformat/rtpdec_qt.c b/libavformat/rtpdec_qt.c index 97df210916..d9e8fe8c43 100644 --- a/libavformat/rtpdec_qt.c +++ b/libavformat/rtpdec_qt.c @@ -31,7 +31,7 @@ #include "rtp.h" #include "rtpdec.h" #include "isom.h" -#include "libavcodec/get_bits.h" +#include "libavcodec/bitstream.h" struct PayloadContext { AVPacket pkt; @@ -45,7 +45,7 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, int len, uint16_t seq, int flags) { AVIOContext pb; - GetBitContext gb; + BitstreamContext bc; int packing_scheme, has_payload_desc, has_packet_info, alen, has_marker_bit = flags & RTP_FLAG_MARKER, keyframe; @@ -71,38 +71,38 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, * The RTP payload is described in: * http://developer.apple.com/quicktime/icefloe/dispatch026.html */ - init_get_bits(&gb, buf, len << 3); + bitstream_init(&bc, buf, len << 3); ffio_init_context(&pb, buf, len, 0, NULL, NULL, NULL, NULL); if (len < 4) return AVERROR_INVALIDDATA; - skip_bits(&gb, 4); // version - if ((packing_scheme = get_bits(&gb, 2)) == 0) + bitstream_skip(&bc, 4); // version + if ((packing_scheme = bitstream_read(&bc, 2)) == 0) return AVERROR_INVALIDDATA; - keyframe = get_bits1(&gb); - has_payload_desc = get_bits1(&gb); - has_packet_info = get_bits1(&gb); - skip_bits(&gb, 23); // reserved:7, cache payload info:1, payload ID:15 + keyframe = bitstream_read_bit(&bc); + has_payload_desc = bitstream_read_bit(&bc); + has_packet_info = bitstream_read_bit(&bc); + bitstream_skip(&bc, 23); // reserved:7, cache payload info:1, payload ID:15 if (has_payload_desc) { int data_len, pos, is_start, is_finish; uint32_t tag; - pos = get_bits_count(&gb) >> 3; + pos = bitstream_tell(&bc) >> 3; if (pos + 12 > len) return AVERROR_INVALIDDATA; - skip_bits(&gb, 2); // has non-I-frames:1, is sparse:1 - is_start = get_bits1(&gb); - is_finish = get_bits1(&gb); + bitstream_skip(&bc, 2); // has non-I-frames:1, is sparse:1 + is_start = bitstream_read_bit(&bc); + is_finish = bitstream_read_bit(&bc); if (!is_start || !is_finish) { avpriv_request_sample(s, "RTP-X-QT with payload description " "split over several packets"); return AVERROR_PATCHWELCOME; } - skip_bits(&gb, 12); // reserved - data_len = get_bits(&gb, 16); + bitstream_skip(&bc, 12); // reserved + data_len = bitstream_read(&bc, 16); avio_seek(&pb, pos + 4, SEEK_SET); tag = avio_rl32(&pb); diff --git a/libavformat/rtpenc_h263_rfc2190.c b/libavformat/rtpenc_h263_rfc2190.c index b8d7a0ab1c..2429f5a394 100644 --- a/libavformat/rtpenc_h263_rfc2190.c +++ b/libavformat/rtpenc_h263_rfc2190.c @@ -22,7 +22,7 @@ #include "avformat.h" #include "rtpenc.h" #include "libavcodec/put_bits.h" -#include "libavcodec/get_bits.h" +#include "libavcodec/bitstream.h" struct H263Info { int src; @@ -103,7 +103,7 @@ void ff_rtp_send_h263_rfc2190(AVFormatContext *s1, const uint8_t *buf, int size, { RTPMuxContext *s = s1->priv_data; int len, sbits = 0, ebits = 0; - GetBitContext gb; + BitstreamContext bc; struct H263Info info = { 0 }; struct H263State state = { 0 }; int mb_info_pos = 0, mb_info_count = mb_info_size / 12; @@ -111,17 +111,17 @@ void ff_rtp_send_h263_rfc2190(AVFormatContext *s1, const uint8_t *buf, int size, s->timestamp = s->cur_timestamp; - init_get_bits(&gb, buf, size*8); - if (get_bits(&gb, 22) == 0x20) { /* Picture Start Code */ - info.tr = get_bits(&gb, 8); - skip_bits(&gb, 2); /* PTYPE start, H.261 disambiguation */ - skip_bits(&gb, 3); /* Split screen, document camera, freeze picture release */ - info.src = get_bits(&gb, 3); - info.i = get_bits(&gb, 1); - info.u = get_bits(&gb, 1); - info.s = get_bits(&gb, 1); - info.a = get_bits(&gb, 1); - info.pb = get_bits(&gb, 1); + bitstream_init(&bc, buf, size * 8); + if (bitstream_read(&bc, 22) == 0x20) { /* Picture Start Code */ + info.tr = bitstream_read(&bc, 8); + bitstream_skip(&bc, 2); /* PTYPE start, H.261 disambiguation */ + bitstream_skip(&bc, 3); /* Split screen, document camera, freeze picture release */ + info.src = bitstream_read(&bc, 3); + info.i = bitstream_read(&bc, 1); + info.u = bitstream_read(&bc, 1); + info.s = bitstream_read(&bc, 1); + info.a = bitstream_read(&bc, 1); + info.pb = bitstream_read(&bc, 1); } while (size > 0) { -- cgit v1.2.3