[FFmpeg-devel] [PATCH] lavf/img2dec: document and amend logic in find_image_range()

Michael Niedermayer michaelni at gmx.at
Sat Aug 4 16:00:29 CEST 2012


On Sat, Aug 04, 2012 at 01:22:27PM +0200, Stefano Sabatini wrote:
> Also rename the parameter max_start to start_index, which seems more
> consistent with the assumed logic.
> 
> "start_index" represents the minimum accepted value for the first index,
> and not the maximum value as implicitely assumed by the parameter name.
> 
> Also we require the start index to start from 1, in order not to break
> compatibility with the behavior predating the start_number option
> addition.
> ---
>  libavformat/img2dec.c |   23 ++++++++++++++++-------
>  1 files changed, 16 insertions(+), 7 deletions(-)

please seperate variable renaming from functional changes
it makes the patch harder to read and also would be more annoying if
we ended up on this commit in a git bisect


[...]
>  static int find_image_range(int *pfirst_index, int *plast_index,
> -                            const char *path, int max_start)
> +                            const char *path, int start_index)
>  {
>      char buf[1024];
>      int range, last_index, range1, first_index;
>  
>      /* find the first image */
> -    for (first_index = max_start; first_index < max_start + 5; first_index++) {
> +    for (first_index = start_index; first_index < start_index + SEARCH_FIRST_INDEX_RANGE; first_index++) {
[...]
>      if (p->filename && ff_guess_image2_codec(p->filename)) {
> @@ -253,7 +262,7 @@ static int read_header(AVFormatContext *s1)
>  #endif
>          } else {
>              if (find_image_range(&first_index, &last_index, s->path,
> -                                 s->start_number - 1) < 0)
> +                                 s->start_number) < 0)
>                  return AVERROR(ENOENT);
>          }
>          s->img_first = first_index;
> @@ -377,7 +386,7 @@ static const AVOption options[] = {
>      { "video_size",   "", OFFSET(video_size),   AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
>      { "framerate",    "", OFFSET(framerate),    AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC },
>      { "loop",         "", OFFSET(loop),         AV_OPT_TYPE_INT,    {.dbl = 0},    0, 1, DEC },
> -    { "start_number", "first number in the sequence", OFFSET(start_number), AV_OPT_TYPE_INT, {.dbl = 1}, 1, INT_MAX, DEC },
> +    { "start_number", "first number in the sequence", OFFSET(start_number), AV_OPT_TYPE_INT, {.dbl = 1}, 0, INT_MAX, DEC },
>      { NULL },

This change the default start from 0 to 1

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

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120804/1b1b6408/attachment.asc>


More information about the ffmpeg-devel mailing list