summaryrefslogtreecommitdiff
path: root/libavformat/segment.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2012-11-17 17:20:29 +0100
committerStefano Sabatini <stefasab@gmail.com>2012-11-20 22:48:28 +0100
commit5a1ac463e02a0754abd014a3f49f8f7a90ff7cac (patch)
tree1180116c32a4fe20ed0b84328a54e37cb123ee6d /libavformat/segment.c
parent2b31aa88955adcc392ace1f8e026f4c820fbd66b (diff)
lavf/segment: do not pre-increment segment_idx value
Increment the value just when a new segment with the given index is started. Simplify logic, improve readability.
Diffstat (limited to 'libavformat/segment.c')
-rw-r--r--libavformat/segment.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 0dd9faf7f6..c494bbf7f9 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -142,11 +142,12 @@ static int segment_start(AVFormatContext *s, int write_header)
oc = seg->avf;
}
+ seg->segment_idx++;
if (seg->segment_idx_wrap)
seg->segment_idx %= seg->segment_idx_wrap;
if (av_get_frame_filename(oc->filename, sizeof(oc->filename),
- s->filename, seg->segment_idx++) < 0) {
+ s->filename, seg->segment_idx) < 0) {
av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", s->filename);
return AVERROR(EINVAL);
}
@@ -407,7 +408,7 @@ static int seg_write_header(AVFormatContext *s)
oc = seg->avf;
if (av_get_frame_filename(oc->filename, sizeof(oc->filename),
- s->filename, seg->segment_idx++) < 0) {
+ s->filename, seg->segment_idx) < 0) {
ret = AVERROR(EINVAL);
goto fail;
}