avformat/segafilm: Do not assume AV_CODEC_ID_NONE is 0
Suggested-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit d34e4904cd
)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
@ -144,11 +144,11 @@ static int film_read_header(AVFormatContext *s)
|
|||||||
film->video_type = AV_CODEC_ID_NONE;
|
film->video_type = AV_CODEC_ID_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!film->video_type && !film->audio_type)
|
if (film->video_type == AV_CODEC_ID_NONE && film->audio_type == AV_CODEC_ID_NONE)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
/* initialize the decoder streams */
|
/* initialize the decoder streams */
|
||||||
if (film->video_type) {
|
if (film->video_type != AV_CODEC_ID_NONE) {
|
||||||
st = avformat_new_stream(s, NULL);
|
st = avformat_new_stream(s, NULL);
|
||||||
if (!st)
|
if (!st)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
@ -169,7 +169,7 @@ static int film_read_header(AVFormatContext *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (film->audio_type) {
|
if (film->audio_type != AV_CODEC_ID_NONE) {
|
||||||
st = avformat_new_stream(s, NULL);
|
st = avformat_new_stream(s, NULL);
|
||||||
if (!st)
|
if (!st)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
@ -244,7 +244,7 @@ static int film_read_header(AVFormatContext *s)
|
|||||||
film->sample_table[i].pts = AV_RB32(&scratch[8]) & 0x7FFFFFFF;
|
film->sample_table[i].pts = AV_RB32(&scratch[8]) & 0x7FFFFFFF;
|
||||||
film->sample_table[i].keyframe = (scratch[8] & 0x80) ? 0 : 1;
|
film->sample_table[i].keyframe = (scratch[8] & 0x80) ? 0 : 1;
|
||||||
video_frame_counter++;
|
video_frame_counter++;
|
||||||
if (film->video_type)
|
if (film->video_type != AV_CODEC_ID_NONE)
|
||||||
av_add_index_entry(s->streams[film->video_stream_index],
|
av_add_index_entry(s->streams[film->video_stream_index],
|
||||||
film->sample_table[i].sample_offset,
|
film->sample_table[i].sample_offset,
|
||||||
film->sample_table[i].pts,
|
film->sample_table[i].pts,
|
||||||
@ -253,10 +253,10 @@ static int film_read_header(AVFormatContext *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (film->audio_type)
|
if (film->audio_type != AV_CODEC_ID_NONE)
|
||||||
s->streams[film->audio_stream_index]->duration = audio_frame_counter;
|
s->streams[film->audio_stream_index]->duration = audio_frame_counter;
|
||||||
|
|
||||||
if (film->video_type)
|
if (film->video_type != AV_CODEC_ID_NONE)
|
||||||
s->streams[film->video_stream_index]->duration = video_frame_counter;
|
s->streams[film->video_stream_index]->duration = video_frame_counter;
|
||||||
|
|
||||||
film->current_sample = 0;
|
film->current_sample = 0;
|
||||||
|
Reference in New Issue
Block a user