mpegts: Convert to the new bitstream reader

pull/117/merge
Alexandra Hájková 9 years ago committed by Diego Biurrun
parent 178b4ea5f9
commit 8d1997add6
  1. 48
      libavformat/mpegts.c

@ -26,9 +26,11 @@
#include "libavutil/dict.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavcodec/bitstream.h"
#include "libavcodec/bytestream.h"
#include "libavcodec/get_bits.h"
#include "libavcodec/opus.h"
#include "avformat.h"
#include "mpegts.h"
#include "internal.h"
@ -735,56 +737,56 @@ static void new_pes_packet(PESContext *pes, AVPacket *pkt)
static int read_sl_header(PESContext *pes, SLConfigDescr *sl,
const uint8_t *buf, int buf_size)
{
GetBitContext gb;
BitstreamContext bc;
int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;
int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
int dts_flag = -1, cts_flag = -1;
int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;
init_get_bits(&gb, buf, buf_size * 8);
bitstream_init(&bc, buf, buf_size * 8);
if (sl->use_au_start)
au_start_flag = get_bits1(&gb);
au_start_flag = bitstream_read_bit(&bc);
if (sl->use_au_end)
au_end_flag = get_bits1(&gb);
au_end_flag = bitstream_read_bit(&bc);
if (!sl->use_au_start && !sl->use_au_end)
au_start_flag = au_end_flag = 1;
if (sl->ocr_len > 0)
ocr_flag = get_bits1(&gb);
ocr_flag = bitstream_read_bit(&bc);
if (sl->use_idle)
idle_flag = get_bits1(&gb);
idle_flag = bitstream_read_bit(&bc);
if (sl->use_padding)
padding_flag = get_bits1(&gb);
padding_flag = bitstream_read_bit(&bc);
if (padding_flag)
padding_bits = get_bits(&gb, 3);
padding_bits = bitstream_read(&bc, 3);
if (!idle_flag && (!padding_flag || padding_bits != 0)) {
if (sl->packet_seq_num_len)
skip_bits_long(&gb, sl->packet_seq_num_len);
bitstream_skip(&bc, sl->packet_seq_num_len);
if (sl->degr_prior_len)
if (get_bits1(&gb))
skip_bits(&gb, sl->degr_prior_len);
if (bitstream_read_bit(&bc))
bitstream_skip(&bc, sl->degr_prior_len);
if (ocr_flag)
skip_bits_long(&gb, sl->ocr_len);
bitstream_skip(&bc, sl->ocr_len);
if (au_start_flag) {
if (sl->use_rand_acc_pt)
get_bits1(&gb);
bitstream_read_bit(&bc);
if (sl->au_seq_num_len > 0)
skip_bits_long(&gb, sl->au_seq_num_len);
bitstream_skip(&bc, sl->au_seq_num_len);
if (sl->use_timestamps) {
dts_flag = get_bits1(&gb);
cts_flag = get_bits1(&gb);
dts_flag = bitstream_read_bit(&bc);
cts_flag = bitstream_read_bit(&bc);
}
}
if (sl->inst_bitrate_len)
inst_bitrate_flag = get_bits1(&gb);
inst_bitrate_flag = bitstream_read_bit(&bc);
if (dts_flag == 1)
dts = get_bits64(&gb, sl->timestamp_len);
dts = bitstream_read_63(&bc, sl->timestamp_len);
if (cts_flag == 1)
cts = get_bits64(&gb, sl->timestamp_len);
cts = bitstream_read_63(&bc, sl->timestamp_len);
if (sl->au_len > 0)
skip_bits_long(&gb, sl->au_len);
bitstream_skip(&bc, sl->au_len);
if (inst_bitrate_flag)
skip_bits_long(&gb, sl->inst_bitrate_len);
bitstream_skip(&bc, sl->inst_bitrate_len);
}
if (dts != AV_NOPTS_VALUE)
@ -795,7 +797,7 @@ static int read_sl_header(PESContext *pes, SLConfigDescr *sl,
if (sl->timestamp_len && sl->timestamp_res)
avpriv_set_pts_info(pes->st, sl->timestamp_len, 1, sl->timestamp_res);
return (get_bits_count(&gb) + 7) >> 3;
return (bitstream_tell(&bc) + 7) >> 3;
}
/* return non zero if a packet could be constructed */

Loading…
Cancel
Save