ref: 8d5a812190ce13b329d3b0f826d78f8aaa503714
parent: 2118bc9fa326ffcfd59080868d95bd7b4bf94889
author: James Almer <jamrial@gmail.com>
date: Sat Oct 27 06:50:25 EDT 2018
tools/dav1d: don't call write_header and write_trailer when it's not needed
--- a/tools/output/null.c
+++ b/tools/output/null.c
@@ -31,26 +31,14 @@
typedef struct MuxerPriv NullOutputContext;
-static int null_open(NullOutputContext *const c, const char *const file,
- const Dav1dPictureParameters *const p,
- const unsigned fps[2])
-{
- return 0;
-}
-
static int null_write(NullOutputContext *const c, Dav1dPicture *const p) {
dav1d_picture_unref(p);
return 0;
}
-static void null_close(NullOutputContext *const c) {
-}
-
const Muxer null_muxer = {
.priv_data_size = 0,
.name = "null",
.extension = "null",
- .write_header = null_open,
.write_picture = null_write,
- .write_trailer = null_close,
};
--- a/tools/output/output.c
+++ b/tools/output/output.c
@@ -118,7 +118,7 @@
}
c->impl = impl;
c->data = (MuxerPriv *) &c[1];
- if ((res = impl->write_header(c->data, filename, p, fps)) < 0) {
+ if (impl->write_header && (res = impl->write_header(c->data, filename, p, fps)) < 0) {
free(c);
return res;
}
@@ -137,6 +137,7 @@
}
void output_close(MuxerContext *const ctx) {
- ctx->impl->write_trailer(ctx->data);
+ if (ctx->impl->write_trailer)
+ ctx->impl->write_trailer(ctx->data);
free(ctx);
}