* 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"
#define RTP_H261_PAYLOAD_HEADER_SIZE 4
uint32_t timestamp;
};
-static void h261_free_dyn_buffer(AVIOContext **dyn_buf)
-{
- uint8_t *ptr_dyn_buffer;
- avio_close_dyn_buf(*dyn_buf, &ptr_dyn_buffer);
- av_free(ptr_dyn_buffer);
- *dyn_buf = NULL;
-}
-
-static av_cold void h261_free_context(PayloadContext *pl_ctx)
+static av_cold void h261_close_context(PayloadContext *pl_ctx)
{
/* return if context is invalid */
if (!pl_ctx)
return;
/* free buffer if it is valid */
- if (pl_ctx->buf) {
- h261_free_dyn_buffer(&pl_ctx->buf);
- }
+ ffio_free_dyn_buf(&pl_ctx->buf);
}
static int h261_handle_packet(AVFormatContext *ctx, PayloadContext *rtp_h261_ctx,
/* drop data of previous packets in case of non-continuous (lossy) packet stream */
if (rtp_h261_ctx->buf && rtp_h261_ctx->timestamp != *timestamp) {
- h261_free_dyn_buffer(&rtp_h261_ctx->buf);
+ ffio_free_dyn_buf(&rtp_h261_ctx->buf);
rtp_h261_ctx->endbyte_bits = 0;
}
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;
.codec_id = AV_CODEC_ID_H261,
.need_parsing = AVSTREAM_PARSE_FULL,
.priv_data_size = sizeof(PayloadContext),
- .free = h261_free_context,
+ .close = h261_close_context,
.parse_packet = h261_handle_packet,
.static_payload_id = 31,
};