[FFmpeg-devel] [PATCH 04/12] all: Use put_bytes_output() instead of put_bits_ptr - pb->buf
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Sat May 25 01:04:47 EEST 2024
Avoids accessing internals of PutBitContext.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
libavcodec/ljpegenc.c | 2 +-
libavcodec/proresenc_anatoliy.c | 2 +-
libavcodec/wmaenc.c | 2 +-
libavformat/mpegenc.c | 4 ++--
libavformat/swfenc.c | 6 +++---
5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 46546e2160..3443951af5 100644
--- a/libavcodec/ljpegenc.c
+++ b/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;
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 7b7618af9b..6ddb799297 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/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,
diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c
index 6949f08fb6..eaf0498ea2 100644
--- a/libavcodec/wmaenc.c
+++ b/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);
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 6b6763c30f..068bc9d71e 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -124,7 +124,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,
@@ -269,7 +269,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);
diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c
index d106e16d19..fc883b8023 100644
--- a/libavformat/swfenc.c
+++ b/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);
}
--
2.40.1
More information about the ffmpeg-devel
mailing list