[FFmpeg-devel] [PATCH] options_table: replace INT64_MAX with a sligthly smaller value

Michael Niedermayer michael at niedermayer.cc
Sun Nov 20 13:56:07 EET 2016


On Sat, Nov 19, 2016 at 02:01:54PM +0100, Andreas Cadhalpun wrote:
> On 19.11.2016 01:39, Michael Niedermayer wrote:
> > On Fri, Nov 18, 2016 at 11:06:56PM +0100, Andreas Cadhalpun wrote:
> >> AVOption.max is a double, which has not enough precision for INT64_MAX.
> >>
> >> It gets interpreted as INT64_MIN, when converted back to int64_t.
> >>
> >> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
> >> ---
> >>  libavcodec/options_table.h | 10 ++++++----
> >>  1 file changed, 6 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
> >> index 48de667..f117ce4 100644
> >> --- a/libavcodec/options_table.h
> >> +++ b/libavcodec/options_table.h
> >> @@ -41,8 +41,10 @@
> >>  
> >>  #define AV_CODEC_DEFAULT_BITRATE 200*1000
> >>  
> >> +#define FF_INT64_MAX (INT64_MAX - 0x1000)
> > 
> > Missing documentation
> 
> Added a comment.
> 

> >> +
> >>  static const AVOption avcodec_options[] = {
> >> -{"b", "set bitrate (in bits/s)", OFFSET(bit_rate), AV_OPT_TYPE_INT64, {.i64 = AV_CODEC_DEFAULT_BITRATE }, 0, INT64_MAX, A|V|E},
> >> +{"b", "set bitrate (in bits/s)", OFFSET(bit_rate), AV_OPT_TYPE_INT64, {.i64 = AV_CODEC_DEFAULT_BITRATE }, 0, FF_INT64_MAX, A|V|E},
> >>  {"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), AV_OPT_TYPE_INT64, {.i64 = 128*1000 }, 0, INT_MAX, A|E},
> >>  {"bt", "Set video bitrate tolerance (in bits/s). In 1-pass mode, bitrate tolerance specifies how far "
> >>         "ratecontrol is willing to deviate from the target average bitrate value. This is not related "
> >> @@ -444,11 +446,11 @@ static const AVOption avcodec_options[] = {
> >>  #if FF_API_PRIVATE_OPT
> >>  {"min_prediction_order", NULL, OFFSET(min_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
> >>  {"max_prediction_order", NULL, OFFSET(max_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
> >> -{"timecode_frame_start", "GOP timecode frame start number, in non-drop-frame format", OFFSET(timecode_frame_start), AV_OPT_TYPE_INT64, {.i64 = -1 }, -1, INT64_MAX, V|E},
> >> +{"timecode_frame_start", "GOP timecode frame start number, in non-drop-frame format", OFFSET(timecode_frame_start), AV_OPT_TYPE_INT64, {.i64 = -1 }, -1, FF_INT64_MAX, V|E},
> >>  #endif
> > 
> >>  {"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX},
> >> -{"channel_layout", NULL, OFFSET(channel_layout), AV_OPT_TYPE_INT64, {.i64 = DEFAULT }, 0, INT64_MAX, A|E|D, "channel_layout"},
> >> +{"channel_layout", NULL, OFFSET(channel_layout), AV_OPT_TYPE_INT64, {.i64 = DEFAULT }, 0, FF_INT64_MAX, A|E|D, "channel_layout"},
> >> -{"request_channel_layout", NULL, OFFSET(request_channel_layout), AV_OPT_TYPE_INT64, {.i64 = DEFAULT }, 0, INT64_MAX, A|D, "request_channel_layout"},
> >> +{"request_channel_layout", NULL, OFFSET(request_channel_layout), AV_OPT_TYPE_INT64, {.i64 = DEFAULT }, 0, FF_INT64_MAX, A|D, "request_channel_layout"},
> > 
> > this doesnt feel right
> > layout is not a scalar
> 
> Then why is it limited to positive values?

it is a unsigend field, it cannot be negative
i posted a patch long ago that added support for UINT64_MAX,
ive updated it and taken care of the comments and will post that in a
moment. This also should take care of the other issues i hope

[...]

-- 
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: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20161120/317b040e/attachment.sig>


More information about the ffmpeg-devel mailing list