[FFmpeg-devel] [PATCH v2 3/6] ffv1enc: split off encoder initialization into a separate function

Michael Niedermayer michael at niedermayer.cc
Thu Nov 14 21:56:26 EET 2024


On Thu, Nov 14, 2024 at 08:21:02AM +0100, Lynne via ffmpeg-devel wrote:
> On 11/14/24 00:46, Michael Niedermayer wrote:
> 
> > On Mon, Nov 11, 2024 at 04:40:15AM +0100, Lynne via ffmpeg-devel wrote:
> > > ---
> > >   libavcodec/ffv1enc.c | 354 +++++++++++++++++++++++--------------------
> > >   libavcodec/ffv1enc.h |  30 ++++
> > >   2 files changed, 217 insertions(+), 167 deletions(-)
> > >   create mode 100644 libavcodec/ffv1enc.h
> > > 
> > > diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
> > > index 7a6c718b41..ca2c9f32e2 100644
> > > --- a/libavcodec/ffv1enc.c
> > > +++ b/libavcodec/ffv1enc.c
> > [...]
> > 
> > > @@ -873,7 +907,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
> > >                       continue;
> > >                   if (maxw * maxh * (int64_t)(s->bits_per_raw_sample+1) * plane_count > 8<<24)
> > >                       continue;
> > > -                if (s->version < 4)
> > > +                if (avctx->level < 4)
> > >                       if (  ff_need_new_slices(avctx->width , s->num_h_slices, s->chroma_h_shift)
> > >                           ||ff_need_new_slices(avctx->height, s->num_v_slices, s->chroma_v_shift))
> > >                           continue;
> > avctx->level is read only from the point of view of the encoder
> > while s->level can (and is sometimes) changed by the encoder
> > So in cases where version is adjusted across 4, level would be wrong,
> > it may be that this doesnt occur ATM but its still not correct
> 
> 
> It cannot happen, not with the way the code is written. This is functionally
> correct.

it is semantically incorrect, s->version is the used version
avctx->level is what the user specified.

If the user does not specify a level, then avctx->level will be -99
s->version can be arbitrary and is the correct field to use


thx

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

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.
-------------- 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/20241114/c8bfc19b/attachment.sig>


More information about the ffmpeg-devel mailing list