[FFmpeg-devel] [PATCH 22/39] lavc/ffv1enc: stop using per-slice FFV1Context

Michael Niedermayer michael at niedermayer.cc
Wed Jul 24 22:42:51 EEST 2024


On Tue, Jul 16, 2024 at 07:11:37PM +0200, Anton Khirnov wrote:
> All remaining accesses to them are for fields that have the same value
> in the main encoder context.
> ---
>  libavcodec/ffv1enc.c          | 57 ++++++++++++++++-------------------
>  libavcodec/ffv1enc_template.c | 24 +++++++--------
>  2 files changed, 37 insertions(+), 44 deletions(-)
[...]
> +RENAME(encode_line)(FFV1Context *f, FFV1SliceContext *sc,
>                      int w, TYPE *sample[3], int plane_index, int bits)
>  {
>      PlaneContext *const p = &sc->plane[plane_index];
> @@ -36,12 +35,12 @@ RENAME(encode_line)(FFV1Context *f,
>  
>      if (f->ac != AC_GOLOMB_RICE) {
>          if (c->bytestream_end - c->bytestream < w * 35) {
> -            av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
> +            av_log(f->avctx, AV_LOG_ERROR, "encoded frame too large\n");
>              return AVERROR_INVALIDDATA;
>          }
>      } else {
>          if (put_bytes_left(&sc->pb, 0) < w * 4) {
> -            av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
> +            av_log(f->avctx, AV_LOG_ERROR, "encoded frame too large\n");
>              return AVERROR_INVALIDDATA;
>          }
>      }
> @@ -73,7 +72,7 @@ RENAME(encode_line)(FFV1Context *f,
>          diff = fold(diff, bits);
>  
>          if (f->ac != AC_GOLOMB_RICE) {
> -            if (s->flags & AV_CODEC_FLAG_PASS1) {
> +            if (f->flags & AV_CODEC_FLAG_PASS1) {
>                  put_symbol_inline(c, p->state[context], diff, 1, sc->rc_stat,
>                                    sc->rc_stat2[p->quant_table_index][context]);
>              } else {
> @@ -103,7 +102,7 @@ RENAME(encode_line)(FFV1Context *f,
>                  }
>              }
>  
> -            ff_dlog(s->avctx, "count:%d index:%d, mode:%d, x:%d pos:%d\n",
> +            ff_dlog(f->avctx, "count:%d index:%d, mode:%d, x:%d pos:%d\n",
>                      run_count, run_index, run_mode, x,
>                      (int)put_bits_count(&sc->pb));
>  

iam not sure if carrying a 2nd pointer around in the loops in encode_line() for
ac/flags/avctx is worth it. IMHO these could be either on teh stack or in the
slice context

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20240724/b429e178/attachment.sig>


More information about the ffmpeg-devel mailing list