#11188: ffmpeg_opt.c correct_input_start_times(void) calculates wrong ts_offset
-------------------------------------+-------------------------------------
             Reporter:  Jens Viebig  |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:               |                  Version:
  undetermined                       |  unspecified
             Keywords:               |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 Summary of the bug:
 The abs_start_seek calculation in correct_input_start_times(void) is not
 done correctly since the sum on the left is evaluated before the shorthand
 if, giving unexecpected results

 abs_start_seek = is->start_time + (ifile->start_time != AV_NOPTS_VALUE) ?
 ifile->start_time : 0;

 This expression almost always evaluates to "ifile->start_time" but is
 expected to be evaluated to: is->start_time + ifile->start_time

 As an example:

 is->start_time = 10
 ifile->start_time = 20

 abs_start_seek = 10 + (20 != AV_NOPTS_VALUE) ? 20 : 0;
 evaluates to
 abs_start_seek = 10 + (true) ? 20 : 0;
 then
 abs_start_seek = 11 ? 20 : 0;
 then
 abs_start_seek = 20


 We already submitted a patch for this issue, but it seems it was
 misunderstood by the maintainers and is still not merged to the current
 codebase
 https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2023-May/309555.html

 With the patch the evaluation is corrected to:
 abs_start_seek = is->start_time + ((ifile->start_time != AV_NOPTS_VALUE) ?
 ifile->start_time : 0);

 With the example, this evaluates to:

 is->start_time = 10
 ifile->start_time = 20

 abs_start_seek = 10 + ((20 != AV_NOPTS_VALUE) ? 20 : 0);
 evaluates to
 abs_start_seek = 10 + ((true) ? 20 : 0);
 then
 abs_start_seek = 10 + 20;
 then
 abs_start_seek = 30;
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/11188>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
_______________________________________________
FFmpeg-trac mailing list
FFmpeg-trac@avcodec.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-trac

To unsubscribe, visit link above, or email
ffmpeg-trac-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to