[FFmpeg-cvslog] avcodec/speedhqenc: Add SpeedHQEncContext and move slice_start to it

Andreas Rheinhardt git at videolan.org
Fri Apr 1 19:18:10 EEST 2022


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Tue Jan 25 17:03:47 2022 +0100| [046736f3429920f2beac48518e2f5a96b53d793e] | committer: Andreas Rheinhardt

avcodec/speedhqenc: Add SpeedHQEncContext and move slice_start to it

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

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

 libavcodec/mpegvideo.h  |  3 ---
 libavcodec/speedhqenc.c | 19 ++++++++++++++-----
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 501ba26750..51d524f1fe 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -417,9 +417,6 @@ typedef struct MpegEncContext {
     int inter_intra_pred;
     int mspel;
 
-    /* SpeedHQ specific */
-    int slice_start;
-
     /* decompression specific */
     GetBitContext gb;
 
diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c
index 8dbb976248..ddb2b2e75c 100644
--- a/libavcodec/speedhqenc.c
+++ b/libavcodec/speedhqenc.c
@@ -57,6 +57,12 @@ static uint32_t speedhq_chr_dc_uni[512];
 
 static uint8_t uni_speedhq_ac_vlc_len[64 * 64 * 2];
 
+typedef struct SpeedHQEncContext {
+    MpegEncContext m;
+
+    int slice_start;
+} SpeedHQEncContext;
+
 static av_cold void speedhq_init_static_data(void)
 {
     ff_rl_init(&ff_rl_speedhq, speedhq_static_rl_table_store);
@@ -124,24 +130,27 @@ av_cold int ff_speedhq_encode_init(MpegEncContext *s)
 
 void ff_speedhq_encode_picture_header(MpegEncContext *s)
 {
+    SpeedHQEncContext *ctx = (SpeedHQEncContext*)s;
+
     put_bits_le(&s->pb, 8, 100 - s->qscale * 2);  /* FIXME why doubled */
     put_bits_le(&s->pb, 24, 4);  /* no second field */
 
+    ctx->slice_start = 4;
     /* length of first slice, will be filled out later */
-    s->slice_start = 4;
     put_bits_le(&s->pb, 24, 0);
 }
 
 void ff_speedhq_end_slice(MpegEncContext *s)
 {
+    SpeedHQEncContext *ctx = (SpeedHQEncContext*)s;
     int slice_len;
 
     flush_put_bits_le(&s->pb);
-    slice_len = s->pb.buf_ptr - (s->pb.buf + s->slice_start);
-    AV_WL24(s->pb.buf + s->slice_start, slice_len);
+    slice_len = put_bytes_output(&s->pb) - ctx->slice_start;
+    AV_WL24(s->pb.buf + ctx->slice_start, slice_len);
 
     /* length of next slice, will be filled out later */
-    s->slice_start = s->pb.buf_ptr - s->pb.buf;
+    ctx->slice_start = put_bytes_output(&s->pb);
     put_bits_le(&s->pb, 24, 0);
 }
 
@@ -274,7 +283,7 @@ const FFCodec ff_speedhq_encoder = {
     .p.type         = AVMEDIA_TYPE_VIDEO,
     .p.id           = AV_CODEC_ID_SPEEDHQ,
     .p.priv_class   = &ff_mpv_enc_class,
-    .priv_data_size = sizeof(MpegEncContext),
+    .priv_data_size = sizeof(SpeedHQEncContext),
     .init           = ff_mpv_encode_init,
     .encode2        = ff_mpv_encode_picture,
     .close          = ff_mpv_encode_end,



More information about the ffmpeg-cvslog mailing list