History

avformat/avio: privatize source of truth for AVIOContext::written

Looking at 3f75e5116b900f1428aa13041fc7d6301bf1988a, the field was supposed to be private, but during merging the field and the group that had the comment about it got separated. Thus, move the actual privately utilized state of this variable into the private FFIOContext. Additionally, name the private field somewhat better, so that it does not get confused with the amount of bytes written out.

Jan Ekström committed 5 years ago

Commit d39b58d1 parent 97cff842 files · +13 −4Browse files

Unified · Split

2 files
  1. libavformat/avio_internal.h +6 −0
  2. libavformat/aviobuf.c +7 −4
libavformat/avio_internal.h+6−0
@@ -66,6 +66,12 @@ typedef struct FFIOContext { · 65 unmodified lines
6666 * used after probing to ensure seekback and to reset the buffer size
6767 */
6868 int orig_buffer_size;
69+
70+ /**
71+ * Written output size
72+ * is updated each time a successful writeout ends up further position-wise
73+ */
74+ int64_t written_output_size;
6975 } FFIOContext;
7076
7177 static av_always_inline FFIOContext *ffiocontext(AVIOContext *ctx)
libavformat/aviobuf.c+7−4
@@ -164,8 +164,10 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len) · 163 unmodified lines
164164 if (ret < 0) {
165165 s->error = ret;
166166 } else {
167− if (s->pos + len > s->written)
168− s->written = s->pos + len;
167+ if (s->pos + len > ctx->written_output_size) {
168+ ctx->written_output_size = s->pos + len;
169+ s->written = ctx->written_output_size;
170+ }
169171 }
170172 }
171173 if (ctx->current_type == AVIO_DATA_MARKER_SYNC_POINT ||
@@ -337,13 +339,14 @@ int64_t avio_skip(AVIOContext *s, int64_t offset) · 165 unmodified lines
337339
338340 int64_t avio_size(AVIOContext *s)
339341 {
342+ FFIOContext *const ctx = ffiocontext(s);
340343 int64_t size;
341344
342345 if (!s)
343346 return AVERROR(EINVAL);
344347
345− if (s->written)
346− return s->written;
348+ if (ctx->written_output_size)
349+ return ctx->written_output_size;
347350
348351 if (!s->seek)
349352 return AVERROR(ENOSYS);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t