[FFmpeg-devel] [PATCH] liavcodec: add bit-rate support to RoQ video encoder

Victor Luchitz vluchits at gmail.com
Mon Jan 22 18:36:00 EET 2024


The rationale behind the bit_rate check is that RoQ was originally
designed with early CD-ROM games in mind (The 7th Guest, The
11th Hour), thus the lowest bit_rate that would make any sense in
that context should be based around that. You really want to get
the best picture quality without exceeding the 150KB/s limit of the
drive.

I also did try various lower bitrates, including the default one, on a
variety of files, and they resulted in either extremely poor visuals,
or the encoder spending a lot of extra time trying to downgrade the
picture quality before giving up. Or both. I didn't try extremely low
resolutions such as 128x128, as I don't see why anyone would
want to specify a bitrate that is less than that of a 1x CD-ROM
drive, while also using a viewport the size of a post stamp.

Either way, I'd really appreciate your input on how to deal with this
situation.

On Mon, Jan 22, 2024 at 5:19 PM Tomas Härdin <git at haerdin.se> wrote:

> mån 2024-01-22 klockan 15:59 +0200 skrev Martin Storsjö:
> > On Mon, 22 Jan 2024, Tomas Härdin wrote:
> >
> > > > > > > >  -    if (frame->quality)
> > > > > > -        enc->lambda = frame->quality - 1;
> > > > > > -    else
> > > > > > -        enc->lambda = 2*ROQ_LAMBDA_SCALE;
> > > > > > +    if (avctx->bit_rate <= ROQ_DEFAULT_MIN_BIT_RATE) {
> > > > > > +        /* no specific bit rate desired, use frame quality
> > > > > > */
> > > > > > +        if (frame->quality)
> > > > > > +            enc->lambda = frame->quality - 1;
> > > > > > +        else
> > > > > > +            enc->lambda = 2*ROQ_LAMBDA_SCALE;
> > > > > > +    }
> > > > >
> > > > > This looks like a bit of a janky way to switch between qscale
> > > > > and
> > > > > bitrate. Isn't there a way to detect whether an option has been
> > > > > set
> > > > > explicitly? At the very least this behavior should be
> > > > > documented in
> > > > > doc/encoders.texi
> > > > >
> > > >
> > > > Originally, the code just checked for bit_rate !=
> > > > AV_CODEC_DEFAULT_BITRATE,
> > > > which required including options_table.h, which in turn produced
> > > > a
> > > > bunch
> > > > of compilation warnings about certain fields being deprecated.
> > > > None
> > > > of the
> > > > other codecs include that file + many simply check the bit_rate
> > > > field
> > > > against
> > > > magic constants.
> > >
> > > grepping for 200000 didn't reveal anything like that. Do you have a
> > > specific example of an encoder that does this?
> > >
> > > Perhaps we could move AV_CODEC_DEFAULT_BITRATE somewhere else, to
> > > avoid
> > > pulling in a bunch of unrelated stuff. Maybe that doesn't need to
> > > hold
> > > up this patch though. Tbh the way bitrate is defaulted to a value,
> > > which makes it impossible to differentiate between a user-supplied
> > > -b
> > > 200k an no -b at all, is even more janky. The default is also
> > > ridiculously low..
> > >
> > > I know some encoders like libvpx allow specifying both quality (-
> > > crf)
> > > and bitrate at the same time
> >
> > FWIW, it's possible for an encoder to individually override the
> > defaults
> > for fields like these. See e.g. x264_defaults in libx264.c, where it
> > overrides the default bitrate to zero.
>
> Ooh, didn't know that. That sounds like a decent solution here. Can RoQ
> really not do < 800 kbps at all or is it just that it looks bad with
> say 256x256 but perhaps more decent with 128x128 or so?
>
> /Tomas
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>


-- 
Best regards,
 Victor Luchitz


More information about the ffmpeg-devel mailing list