+ if (s->pb->eof_reached) {
+ av_log(s, AV_LOG_ERROR, "incomplete header\n");
+ return s->pb->error ? s->pb->error : AVERROR_EOF;
+ }
+
+ if (av_image_check_size(width, height, 0, s) < 0)
+ return AVERROR_INVALIDDATA;
+ if (sample_rate > 0) {
+ if (sample_rate < 14 || sample_rate > INT_MAX) {
+ av_log(s, AV_LOG_ERROR, "invalid sample rate: %u\n", sample_rate);
+ return AVERROR_INVALIDDATA;
+ }
+ if (bytes_per_sample < 1 || bytes_per_sample > 2) {
+ av_log(s, AV_LOG_ERROR, "invalid bytes per sample: %u\n",
+ bytes_per_sample);
+ return AVERROR_INVALIDDATA;
+ }
+ if (channels < 1 || channels > 2) {
+ av_log(s, AV_LOG_ERROR, "invalid channels: %u\n", channels);
+ return AVERROR_INVALIDDATA;
+ }
+ idcin->audio_present = 1;
+ } else {
+ /* if sample rate is 0, assume no audio */
+ idcin->audio_present = 0;
+ }
+