Prevent error condition in case sample_rate is unset or set to a negative
value. In particular, fix divide-by-zero error occurring in ffmpeg due to
sample_rate set to 0 in output_packet(), in code:
ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) /
ist->st->codec->sample_rate;
Fix trac ticket #324.
| ... | ... |
@@ -56,6 +56,12 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap) |
| 56 | 56 |
|
| 57 | 57 |
if (s1 && s1->sample_rate) |
| 58 | 58 |
st->codec->sample_rate = s1->sample_rate; |
| 59 |
+ if (st->codec->sample_rate <= 0) {
|
|
| 60 |
+ av_log(s, AV_LOG_ERROR, "Invalid sample rate %d specified\n", |
|
| 61 |
+ st->codec->sample_rate); |
|
| 62 |
+ return AVERROR(EINVAL); |
|
| 63 |
+ } |
|
| 64 |
+ |
|
| 59 | 65 |
if (s1 && s1->channels) |
| 60 | 66 |
st->codec->channels = s1->channels; |
| 61 | 67 |
|