diff options
author | John Stebbins <[email protected]> | 2016-03-23 11:30:26 -0600 |
---|---|---|
committer | John Stebbins <[email protected]> | 2016-03-23 11:30:26 -0600 |
commit | c352488fe13972f75eff209d3eb9c610225e3901 (patch) | |
tree | 2d39fce2e089a96190a931ae781df4f2b834e5fa | |
parent | 9bb4ff4a5c13e5d8cc1a192a3b94de121212dace (diff) |
stream: fix potential use of uninitialized variable
-rw-r--r-- | libhb/stream.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/libhb/stream.c b/libhb/stream.c index 0c89b8f59..261d50f84 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -1763,18 +1763,26 @@ int hb_stream_seek_chapter( hb_stream_t * stream, int chapter_num ) stream->chapter = chapter_num - 1; stream->chapter_end = sum_dur; - int64_t pos = ( ( ( sum_dur - chapter->duration ) * AV_TIME_BASE ) / 90000 ) + ffmpeg_initial_timestamp( stream ); + if (chapter != NULL && chapter_num > 1) + { + int64_t pos = (((sum_dur - chapter->duration) * AV_TIME_BASE) / 90000) + + ffmpeg_initial_timestamp(stream); - hb_deep_log( 2, "Seeking to chapter %d: starts %"PRId64", ends %"PRId64", AV pos %"PRId64, - chapter_num, sum_dur - chapter->duration, sum_dur, pos); + if (pos > 0) + { + hb_deep_log(2, + "Seeking to chapter %d: starts %"PRId64", ends %"PRId64 + ", AV pos %"PRId64, + chapter_num, sum_dur - chapter->duration, sum_dur, pos); - if ( chapter_num > 1 && pos > 0 ) - { - AVStream *st = stream->ffmpeg_ic->streams[stream->ffmpeg_video_id]; - // timebase must be adjusted to match timebase of stream we are - // using for seeking. - pos = av_rescale(pos, st->time_base.den, AV_TIME_BASE * (int64_t)st->time_base.num); - avformat_seek_file( stream->ffmpeg_ic, stream->ffmpeg_video_id, 0, pos, pos, AVSEEK_FLAG_BACKWARD); + AVStream *st = stream->ffmpeg_ic->streams[stream->ffmpeg_video_id]; + // timebase must be adjusted to match timebase of stream we are + // using for seeking. + pos = av_rescale(pos, st->time_base.den, + AV_TIME_BASE * (int64_t)st->time_base.num); + avformat_seek_file(stream->ffmpeg_ic, stream->ffmpeg_video_id, 0, + pos, pos, AVSEEK_FLAG_BACKWARD); + } } return 1; } |