summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-04-21 19:14:34 +0200
committerJan Ekström <jeebjp@gmail.com>2018-04-29 02:21:32 +0300
commit05e75e794623754f6e1e77ea20f46629bc71882b (patch)
tree95d7bc17111b6458a3b2a1fde5152c9bc78a657b
parentd2349cb833efd99b2f3382a7629b9e70f2b50d24 (diff)
downloadmpv-05e75e794623754f6e1e77ea20f46629bc71882b.tar.bz2
mpv-05e75e794623754f6e1e77ea20f46629bc71882b.tar.xz
encode: some more cleanups
-rw-r--r--common/encode.h1
-rw-r--r--common/encode_lavc.c34
-rw-r--r--common/encode_lavc.h2
-rw-r--r--player/main.c1
4 files changed, 6 insertions, 32 deletions
diff --git a/common/encode.h b/common/encode.h
index 047207eea4..c29cb3bc67 100644
--- a/common/encode.h
+++ b/common/encode.h
@@ -57,7 +57,6 @@ struct encode_opts {
// interface for mplayer.c
struct encode_lavc_context *encode_lavc_init(struct encode_opts *options,
struct mpv_global *global);
-void encode_lavc_finish(struct encode_lavc_context *ctx);
void encode_lavc_free(struct encode_lavc_context *ctx);
void encode_lavc_discontinuity(struct encode_lavc_context *ctx);
bool encode_lavc_showhelp(struct mp_log *log, struct encode_opts *options);
diff --git a/common/encode_lavc.c b/common/encode_lavc.c
index ac6c0e6bf7..81b12d4936 100644
--- a/common/encode_lavc.c
+++ b/common/encode_lavc.c
@@ -133,7 +133,7 @@ static bool value_has_flag(const char *value, const char *flag)
}
#define CHECK_FAIL(ctx, val) \
- if (ctx && (ctx->failed || ctx->finished)) { \
+ if (ctx && (ctx->failed)) { \
MP_ERR(ctx, \
"Called a function on a %s encoding context. Bailing out.\n", \
ctx->failed ? "failed" : "finished"); \
@@ -141,7 +141,7 @@ static bool value_has_flag(const char *value, const char *flag)
}
#define CHECK_FAIL_UNLOCK(ctx, val) \
- if (ctx && (ctx->failed || ctx->finished)) { \
+ if (ctx && (ctx->failed)) { \
MP_ERR(ctx, \
"Called a function on a %s encoding context. Bailing out.\n", \
ctx->failed ? "failed" : "finished"); \
@@ -155,12 +155,6 @@ int encode_lavc_available(struct encode_lavc_context *ctx)
return ctx && ctx->avc;
}
-int encode_lavc_oformat_flags(struct encode_lavc_context *ctx)
-{
- CHECK_FAIL(ctx, 0);
- return ctx->avc ? ctx->avc->oformat->flags : 0;
-}
-
struct encode_lavc_context *encode_lavc_init(struct encode_opts *options,
struct mpv_global *global)
{
@@ -200,8 +194,9 @@ struct encode_lavc_context *encode_lavc_init(struct encode_opts *options,
if (*in)
++in;
}
- } else
+ } else {
ctx->avc->oformat = av_guess_format(NULL, filename, NULL);
+ }
if (!ctx->avc->oformat) {
encode_lavc_fail(ctx, "format not found\n");
@@ -381,28 +376,11 @@ int encode_lavc_start(struct encode_lavc_context *ctx)
void encode_lavc_free(struct encode_lavc_context *ctx)
{
- if (!ctx)
- return;
-
- if (!ctx->finished) {
- encode_lavc_fail(ctx,
- "called encode_lavc_free without encode_lavc_finish\n");
- }
-
- pthread_mutex_destroy(&ctx->lock);
- talloc_free(ctx);
-}
-
-void encode_lavc_finish(struct encode_lavc_context *ctx)
-{
unsigned i;
if (!ctx)
return;
- if (ctx->finished)
- return;
-
if (ctx->avc) {
if (ctx->header_written > 0)
av_write_trailer(ctx->avc); // this is allowed to fail
@@ -459,7 +437,8 @@ void encode_lavc_finish(struct encode_lavc_context *ctx)
ctx->avc = NULL;
}
- ctx->finished = true;
+ pthread_mutex_destroy(&ctx->lock);
+ talloc_free(ctx);
}
void encode_lavc_set_video_fps(struct encode_lavc_context *ctx, float fps)
@@ -1193,7 +1172,6 @@ void encode_lavc_fail(struct encode_lavc_context *ctx, const char *format, ...)
if (ctx->failed)
return;
ctx->failed = true;
- encode_lavc_finish(ctx);
}
// vim: ts=4 sw=4 et
diff --git a/common/encode_lavc.h b/common/encode_lavc.h
index 0e72b0d605..467520cc6d 100644
--- a/common/encode_lavc.h
+++ b/common/encode_lavc.h
@@ -91,7 +91,6 @@ struct encode_lavc_context {
// has encoding failed?
bool failed;
- bool finished;
};
// interface for vo/ao drivers
@@ -108,7 +107,6 @@ int encode_lavc_open_codec(struct encode_lavc_context *ctx,
int encode_lavc_available(struct encode_lavc_context *ctx);
int encode_lavc_timesyncfailed(struct encode_lavc_context *ctx);
int encode_lavc_start(struct encode_lavc_context *ctx); // returns 1 on success
-int encode_lavc_oformat_flags(struct encode_lavc_context *ctx);
double encode_lavc_getoffset(struct encode_lavc_context *ctx,
AVCodecContext *codec);
void encode_lavc_fail(struct encode_lavc_context *ctx, const char *format, ...); // report failure of encoding
diff --git a/player/main.c b/player/main.c
index bb80591220..b070b1aabe 100644
--- a/player/main.c
+++ b/player/main.c
@@ -165,7 +165,6 @@ void mp_destroy(struct MPContext *mpctx)
uninit_video_out(mpctx);
#if HAVE_ENCODING
- encode_lavc_finish(mpctx->encode_lavc_ctx);
encode_lavc_free(mpctx->encode_lavc_ctx);
#endif