tools/dav1d: don't call write_header and write_trailer when it's not needed

parent 2118bc9f
......@@ -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,
};
......@@ -118,7 +118,7 @@ int output_open(MuxerContext **const c_out,
}
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 @@ int output_write(MuxerContext *const ctx, Dav1dPicture *const p) {
}
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);
}
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