Browse Source

all: Use put_bytes_output() instead of put_bits_ptr - pb->buf

Avoids accessing internals of PutBitContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Andreas Rheinhardt 9 months ago
parent
commit
b98beb3704
5 changed files with 8 additions and 8 deletions
  1. 1 1
      libavcodec/ljpegenc.c
  2. 1 1
      libavcodec/proresenc_anatoliy.c
  3. 1 1
      libavcodec/wmaenc.c
  4. 2 2
      libavformat/mpegenc.c
  5. 3 3
      libavformat/swfenc.c

+ 1 - 1
libavcodec/ljpegenc.c

@@ -252,7 +252,7 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     ff_mjpeg_encode_picture_trailer(&pb, header_bits);
 
     flush_put_bits(&pb);
-    pkt->size   = put_bits_ptr(&pb) - pb.buf;
+    pkt->size   = put_bytes_output(&pb);
     *got_packet = 1;
 
     return 0;

+ 1 - 1
libavcodec/proresenc_anatoliy.c

@@ -382,7 +382,7 @@ static int encode_slice_plane(int16_t *blocks, int mb_count, uint8_t *buf, unsig
     encode_acs(&pb, blocks, blocks_per_slice, qmat, scan);
 
     flush_put_bits(&pb);
-    return put_bits_ptr(&pb) - pb.buf;
+    return put_bytes_output(&pb);
 }
 
 static av_always_inline unsigned encode_slice_data(AVCodecContext *avctx,

+ 1 - 1
libavcodec/wmaenc.c

@@ -425,7 +425,7 @@ static int encode_superframe(AVCodecContext *avctx, AVPacket *avpkt,
         put_bits(&s->pb, 8, 'N');
 
     flush_put_bits(&s->pb);
-    av_assert0(put_bits_ptr(&s->pb) - s->pb.buf == avctx->block_align);
+    av_assert0(put_bytes_output(&s->pb) == avctx->block_align);
 
     if (frame->pts != AV_NOPTS_VALUE)
         avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->initial_padding);

+ 2 - 2
libavformat/mpegenc.c

@@ -125,7 +125,7 @@ static int put_pack_header(AVFormatContext *ctx, uint8_t *buf,
         put_bits(&pb, 3, 0); /* stuffing length */
     }
     flush_put_bits(&pb);
-    return put_bits_ptr(&pb) - pb.buf;
+    return put_bytes_output(&pb);
 }
 
 static int put_system_header(AVFormatContext *ctx, uint8_t *buf,
@@ -270,7 +270,7 @@ static int put_system_header(AVFormatContext *ctx, uint8_t *buf,
     }
 
     flush_put_bits(&pb);
-    size = put_bits_ptr(&pb) - pb.buf;
+    size = put_bytes_output(&pb);
     /* patch packet size */
     AV_WB16(buf + 4, size - 6);
 

+ 3 - 3
libavformat/swfenc.c

@@ -124,7 +124,7 @@ static void put_swf_rect(AVIOContext *pb,
     put_bits(&p, nbits, ymax & mask);
 
     flush_put_bits(&p);
-    avio_write(pb, buf, put_bits_ptr(&p) - p.buf);
+    avio_write(pb, buf, put_bytes_output(&p));
 }
 
 static void put_swf_line_edge(PutBitContext *pb, int dx, int dy)
@@ -189,7 +189,7 @@ static void put_swf_matrix(AVIOContext *pb,
     put_bits(&p, nbits, ty);
 
     flush_put_bits(&p);
-    avio_write(pb, buf, put_bits_ptr(&p) - p.buf);
+    avio_write(pb, buf, put_bytes_output(&p));
 }
 
 static int swf_write_header(AVFormatContext *s)
@@ -323,7 +323,7 @@ static int swf_write_header(AVFormatContext *s)
         put_bits(&p, 5, 0);
 
         flush_put_bits(&p);
-        avio_write(pb, buf1, put_bits_ptr(&p) - p.buf);
+        avio_write(pb, buf1, put_bytes_output(&p));
 
         put_swf_end_tag(s);
     }