Commit 28d02524 authored by Andreas Rheinhardt's avatar Andreas Rheinhardt Committed by Michael Niedermayer

avformat/flvenc: Forward errors from allocating keyframe index

While the function adding a new element to the keyframe index checked
the allocation, the caller didn't check the return value. This has been
changed. To do so, the return value has been changed to an ordinary ret
instead of pb->error. This doesn't pose a problem, as write_packet() in
mux.c already checks for write errors (since 9ad1e0c1).
Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent a94e6b50
...@@ -887,7 +887,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -887,7 +887,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
unsigned ts; unsigned ts;
int size = pkt->size; int size = pkt->size;
uint8_t *data = NULL; uint8_t *data = NULL;
int flags = -1, flags_size, ret; int flags = -1, flags_size, ret = 0;
int64_t cur_offset = avio_tell(pb); int64_t cur_offset = avio_tell(pb);
if (par->codec_type == AVMEDIA_TYPE_AUDIO && !pkt->size) { if (par->codec_type == AVMEDIA_TYPE_AUDIO && !pkt->size) {
...@@ -1057,15 +1057,17 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -1057,15 +1057,17 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
case AVMEDIA_TYPE_VIDEO: case AVMEDIA_TYPE_VIDEO:
flv->videosize += (avio_tell(pb) - cur_offset); flv->videosize += (avio_tell(pb) - cur_offset);
flv->lasttimestamp = flv->acurframeindex / flv->framerate; flv->lasttimestamp = flv->acurframeindex / flv->framerate;
flv->acurframeindex++;
if (pkt->flags & AV_PKT_FLAG_KEY) { if (pkt->flags & AV_PKT_FLAG_KEY) {
double ts = flv->acurframeindex / flv->framerate; double ts = flv->lasttimestamp;
int64_t pos = cur_offset; int64_t pos = cur_offset;
flv->lastkeyframetimestamp = flv->acurframeindex / flv->framerate; flv->lastkeyframetimestamp = ts;
flv->lastkeyframelocation = pos; flv->lastkeyframelocation = pos;
flv_append_keyframe_info(s, flv, ts, pos); ret = flv_append_keyframe_info(s, flv, ts, pos);
if (ret < 0)
goto fail;
} }
flv->acurframeindex++;
break; break;
case AVMEDIA_TYPE_AUDIO: case AVMEDIA_TYPE_AUDIO:
...@@ -1077,10 +1079,10 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -1077,10 +1079,10 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
break; break;
} }
} }
fail:
av_free(data); av_free(data);
return pb->error; return ret;
} }
static int flv_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt) static int flv_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment