[FFmpeg-cvslog] mpegts: Convert to the new bitstream reader

Alexandra Hájková git at videolan.org
Tue Apr 4 21:52:36 EEST 2017


ffmpeg | branch: master | Alexandra Hájková <alexandra at khirnov.net> | Sat Apr 16 17:46:29 2016 +0200| [8d1997add6220b7d956dcfdcc9f711efb56ca30d] | committer: Diego Biurrun

mpegts: Convert to the new bitstream reader

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8d1997add6220b7d956dcfdcc9f711efb56ca30d
---

 libavformat/mpegts.c | 48 +++++++++++++++++++++++++-----------------------
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 28b6d37..5024404 100644
--- a/libavformat/mpegts.c
+++ b/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 */



More information about the ffmpeg-cvslog mailing list