X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Frl2.c;h=8b6a7f1827ba90deeace93217e43a3a2d8fda99f;hb=bd96c54fe4819b3ca9a975e2083d67f4443c559b;hp=eb1682dfcb7c2983a9a5c06175aac0e470c9e357;hpb=7167ac33a8f2c7d063384c267f984f23d2b73854;p=ffmpeg diff --git a/libavformat/rl2.c b/libavformat/rl2.c index eb1682dfcb7..8b6a7f1827b 100644 --- a/libavformat/rl2.c +++ b/libavformat/rl2.c @@ -55,7 +55,7 @@ typedef struct Rl2DemuxContext { * @param p probe buffer * @return 0 when the probe buffer does not contain rl2 data, > 0 otherwise */ -static int rl2_probe(AVProbeData *p) +static int rl2_probe(const AVProbeData *p) { if(AV_RB32(&p->buf[0]) != FORM_TAG) @@ -127,8 +127,9 @@ static av_cold int rl2_read_header(AVFormatContext *s) if(signature == RLV3_TAG && back_size > 0) st->codecpar->extradata_size += back_size; - if(ff_get_extradata(s, st->codecpar, pb, st->codecpar->extradata_size) < 0) - return AVERROR(ENOMEM); + ret = ff_get_extradata(s, st->codecpar, pb, st->codecpar->extradata_size); + if (ret < 0) + return ret; /** setup audio stream if present */ if(sound_rate){ @@ -171,18 +172,24 @@ static av_cold int rl2_read_header(AVFormatContext *s) /** read offset and size tables */ for(i=0; i < frame_count;i++) { - if (avio_feof(pb)) - return AVERROR_INVALIDDATA; + if (avio_feof(pb)) { + ret = AVERROR_INVALIDDATA; + goto end; + } chunk_size[i] = avio_rl32(pb); } for(i=0; i < frame_count;i++) { - if (avio_feof(pb)) - return AVERROR_INVALIDDATA; + if (avio_feof(pb)) { + ret = AVERROR_INVALIDDATA; + goto end; + } chunk_offset[i] = avio_rl32(pb); } for(i=0; i < frame_count;i++) { - if (avio_feof(pb)) - return AVERROR_INVALIDDATA; + if (avio_feof(pb)) { + ret = AVERROR_INVALIDDATA; + goto end; + } audio_size[i] = avio_rl32(pb) & 0xFFFF; } @@ -203,7 +210,7 @@ static av_cold int rl2_read_header(AVFormatContext *s) ++video_frame_counter; } - +end: av_free(chunk_size); av_free(audio_size); av_free(chunk_offset); @@ -230,9 +237,9 @@ static int rl2_read_packet(AVFormatContext *s, /** check if there is a valid video or audio entry that can be used */ for(i=0; inb_streams; i++){ - if(rl2->index_pos[i] < s->streams[i]->nb_index_entries - && s->streams[i]->index_entries[ rl2->index_pos[i] ].pos < pos){ - sample = &s->streams[i]->index_entries[ rl2->index_pos[i] ]; + if(rl2->index_pos[i] < s->streams[i]->internal->nb_index_entries + && s->streams[i]->internal->index_entries[ rl2->index_pos[i] ].pos < pos){ + sample = &s->streams[i]->internal->index_entries[ rl2->index_pos[i] ]; pos= sample->pos; stream_id= i; } @@ -249,7 +256,6 @@ static int rl2_read_packet(AVFormatContext *s, /** fill the packet */ ret = av_get_packet(pb, pkt, sample->size); if(ret != sample->size){ - av_packet_unref(pkt); return AVERROR(EIO); } @@ -277,7 +283,7 @@ static int rl2_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp return -1; rl2->index_pos[stream_index] = index; - timestamp = st->index_entries[index].timestamp; + timestamp = st->internal->index_entries[index].timestamp; for(i=0; i < s->nb_streams; i++){ AVStream *st2 = s->streams[i]; @@ -294,7 +300,7 @@ static int rl2_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp return 0; } -AVInputFormat ff_rl2_demuxer = { +const AVInputFormat ff_rl2_demuxer = { .name = "rl2", .long_name = NULL_IF_CONFIG_SMALL("RL2"), .priv_data_size = sizeof(Rl2DemuxContext),