summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/av_common.c11
-rw-r--r--common/av_common.h1
-rw-r--r--common/common.h28
-rw-r--r--common/encode_lavc.c19
-rw-r--r--common/encode_lavc.h2
-rw-r--r--common/msg.c21
-rw-r--r--common/stats.c1
-rw-r--r--common/tags.c2
-rw-r--r--common/version.h.in4
9 files changed, 67 insertions, 22 deletions
diff --git a/common/av_common.c b/common/av_common.c
index 5d07349af0..277601d2fc 100644
--- a/common/av_common.c
+++ b/common/av_common.c
@@ -402,3 +402,14 @@ void mp_free_av_packet(AVPacket **pkt)
}
av_packet_free(pkt);
}
+
+void mp_codec_info_from_av(const AVCodecContext *avctx, struct mp_codec_params *c)
+{
+ c->codec_profile = av_get_profile_name(avctx->codec, avctx->profile);
+ if (!c->codec_profile)
+ c->codec_profile = avcodec_profile_name(avctx->codec_id, avctx->profile);
+ c->codec = avctx->codec_descriptor->name;
+ c->codec_desc = avctx->codec_descriptor->long_name;
+ c->decoder = avctx->codec->name;
+ c->decoder_desc = avctx->codec->long_name;
+}
diff --git a/common/av_common.h b/common/av_common.h
index 1f05e14fab..c584085890 100644
--- a/common/av_common.h
+++ b/common/av_common.h
@@ -50,5 +50,6 @@ void mp_avdict_print_unset(struct mp_log *log, int msgl, struct AVDictionary *d)
int mp_set_avopts(struct mp_log *log, void *avobj, char **kv);
int mp_set_avopts_pos(struct mp_log *log, void *avobj, void *posargs, char **kv);
void mp_free_av_packet(AVPacket **pkt);
+void mp_codec_info_from_av(const AVCodecContext *avctx, struct mp_codec_params *c);
#endif
diff --git a/common/common.h b/common/common.h
index cd9bea93c2..7466ea2d61 100644
--- a/common/common.h
+++ b/common/common.h
@@ -24,6 +24,13 @@
#include <stdbool.h>
#include <stdint.h>
+#include "config.h"
+
+#if HAVE_POSIX || defined(__MINGW32__)
+#include <strings.h>
+#include <unistd.h>
+#endif
+
#include "osdep/compiler.h"
#include "mpv_talloc.h"
@@ -164,4 +171,25 @@ char **mp_dup_str_array(void *tctx, char **s);
abort(); \
} while (0)
+#ifdef _MSC_VER
+#define strncasecmp _strnicmp
+#define strcasecmp _stricmp
+
+#ifndef STDIN_FILENO
+#define STDIN_FILENO 0
+#endif
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
+#endif
+#ifndef STDERR_FILENO
+#define STDERR_FILENO 2
+#endif
+#ifndef O_NONBLOCK
+#define O_NONBLOCK 0
+#endif
+
+typedef long long ssize_t;
+typedef unsigned short mode_t;
+#endif
+
#endif /* MPLAYER_MPCOMMON_H */
diff --git a/common/encode_lavc.c b/common/encode_lavc.c
index a250f9c994..33743007dd 100644
--- a/common/encode_lavc.c
+++ b/common/encode_lavc.c
@@ -117,12 +117,6 @@ struct encode_lavc_context *encode_lavc_init(struct mpv_global *global)
if (!strcmp(filename, "-"))
filename = "pipe:1";
- if (filename && (
- !strcmp(filename, "/dev/stdout") ||
- !strcmp(filename, "pipe:") ||
- !strcmp(filename, "pipe:1")))
- mp_msg_force_stderr(global, true);
-
encode_lavc_discontinuity(ctx);
p->muxer = avformat_alloc_context();
@@ -946,4 +940,17 @@ fail:
return false;
}
+void encoder_update_log(struct mpv_global *global)
+{
+ struct encode_opts *options = mp_get_config_group(NULL, global, &encode_config);
+ if (options->file && (!strcmp(options->file, "-") ||
+ !strcmp(options->file, "/dev/stdout") ||
+ !strcmp(options->file, "pipe:") ||
+ !strcmp(options->file, "pipe:1")))
+ {
+ mp_msg_force_stderr(global, true);
+ }
+ talloc_free(options);
+}
+
// vim: ts=4 sw=4 et
diff --git a/common/encode_lavc.h b/common/encode_lavc.h
index 8517726529..125108e538 100644
--- a/common/encode_lavc.h
+++ b/common/encode_lavc.h
@@ -111,4 +111,6 @@ bool encoder_encode(struct encoder_context *p, AVFrame *frame);
// Caller needs to acquire encode_lavc_context.lock (or call it from on_ready).
AVRational encoder_get_mux_timebase_unlocked(struct encoder_context *p);
+void encoder_update_log(struct mpv_global *global);
+
#endif
diff --git a/common/msg.c b/common/msg.c
index 9b17d5925b..99bc82d06f 100644
--- a/common/msg.c
+++ b/common/msg.c
@@ -22,7 +22,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
#include "mpv_talloc.h"
@@ -195,8 +194,7 @@ int mp_msg_level(struct mp_log *log)
static inline int term_msg_fileno(struct mp_log_root *root, int lev)
{
- return (root->force_stderr || lev == MSGL_STATUS || lev == MSGL_FATAL ||
- lev == MSGL_ERR || lev == MSGL_WARN) ? STDERR_FILENO : STDOUT_FILENO;
+ return root->force_stderr ? STDERR_FILENO : STDOUT_FILENO;
}
// Reposition cursor and clear lines for outputting the status line. In certain
@@ -216,9 +214,9 @@ static void prepare_prefix(struct mp_log_root *root, bstr *out, int lev, int ter
// Set cursor state
if (new_lines && !root->status_lines) {
- bstr_xappend(root, out, bstr0("\033[?25l"));
+ bstr_xappend(root, out, bstr0(TERM_ESC_HIDE_CURSOR));
} else if (!new_lines && root->status_lines) {
- bstr_xappend(root, out, bstr0("\033[?25h"));
+ bstr_xappend(root, out, bstr0(TERM_ESC_RESTORE_CURSOR));
}
int line_skip = 0;
@@ -498,9 +496,9 @@ static void write_term_msg(struct mp_log *log, int lev, bstr text, bstr *out)
write_msg_to_buffers(log, lev, line);
}
- if (lev == MSGL_STATUS && print_term) {
+ if (lev == MSGL_STATUS) {
int line_w = 0;
- if (str.len)
+ if (str.len && print_term)
append_terminal_line(log, lev, str, &root->term_msg_tmp, &line_w);
term_msg_lines += !term_w ? (str.len ? 1 : 0)
: (line_w + term_w - 1) / term_w;
@@ -563,12 +561,9 @@ void mp_msg_va(struct mp_log *log, int lev, const char *format, va_list va)
int fileno = term_msg_fileno(root, lev);
FILE *stream = fileno == STDERR_FILENO ? stderr : stdout;
if (root->term_msg.len) {
- if (root->term_status_msg.len) {
- fprintf(stream, "%.*s%.*s", BSTR_P(root->term_msg),
- BSTR_P(root->term_status_msg));
- } else {
- fprintf(stream, "%.*s", BSTR_P(root->term_msg));
- }
+ fwrite(root->term_msg.start, root->term_msg.len, 1, stream);
+ if (root->term_status_msg.len)
+ fwrite(root->term_status_msg.start, root->term_status_msg.len, 1, stream);
fflush(stream);
}
}
diff --git a/common/stats.c b/common/stats.c
index c5f1e50590..fac3c73598 100644
--- a/common/stats.c
+++ b/common/stats.c
@@ -1,6 +1,5 @@
#include <stdatomic.h>
#include <time.h>
-#include <unistd.h>
#include "common.h"
#include "global.h"
diff --git a/common/tags.c b/common/tags.c
index 43f557dd6c..67e428766a 100644
--- a/common/tags.c
+++ b/common/tags.c
@@ -17,9 +17,9 @@
#include <stddef.h>
#include <limits.h>
-#include <strings.h>
#include <assert.h>
#include <libavutil/dict.h>
+#include "common.h"
#include "tags.h"
#include "misc/bstr.h"
diff --git a/common/version.h.in b/common/version.h.in
index 25d6441210..392f0ddc0d 100644
--- a/common/version.h.in
+++ b/common/version.h.in
@@ -1,5 +1,7 @@
#define VERSION "@VERSION@"
-#define MPVCOPYRIGHT "Copyright © 2000-2024 mpv/MPlayer/mplayer2 projects"
+#define MPVCOPYRIGHT_T(C) "Copyright " C " 2000-2024 mpv/MPlayer/mplayer2 projects"
+#define MPVCOPYRIGHT MPVCOPYRIGHT_T("\xC2\xA9")
+#define MPVCOPYRIGHT_W MPVCOPYRIGHT_T(L"\xA9")
#ifndef NO_BUILD_TIMESTAMPS
#define BUILDDATE __DATE__ " " __TIME__
#else