1919#include <limits.h>
2020
2121#include <subrandr/subrandr.h>
22+ #include <subrandr/logging.h>
2223
2324#include "mpv_talloc.h"
2425
@@ -56,6 +57,37 @@ static void enable_output(struct sd *sd, bool enable)
5657 }
5758}
5859
60+ static inline int mp_level_from_sbr_log_level (sbr_log_level level )
61+ {
62+ switch (level ) {
63+ case SBR_LOG_LEVEL_TRACE :
64+ return MSGL_TRACE ;
65+ case SBR_LOG_LEVEL_DEBUG :
66+ return MSGL_DEBUG ;
67+ case SBR_LOG_LEVEL_INFO : // fallthrough
68+ case SBR_LOG_LEVEL_WARN :
69+ return MSGL_V ;
70+ case SBR_LOG_LEVEL_ERROR : // fallthrough
71+ default :
72+ return MSGL_WARN ;
73+ }
74+ }
75+
76+ static void mp_msg_sbr_log_callback (sbr_log_level level ,
77+ const char * source , size_t source_len ,
78+ const char * message , size_t message_len ,
79+ void * user_data )
80+ {
81+ struct sd * sd = user_data ;
82+ int mp_level = mp_level_from_sbr_log_level (level );
83+
84+ if (mp_msg_test (sd -> log , mp_level )) {
85+ if (source_len > 0 )
86+ mp_msg (sd -> log , mp_level , "[%.*s] " , (int )source_len , source );
87+ mp_msg (sd -> log , mp_level , "%.*s\n" , (int )message_len , message );
88+ }
89+ }
90+
5991static int init (struct sd * sd )
6092{
6193 if (!sd -> codec -> codec )
@@ -74,6 +106,8 @@ static int init(struct sd *sd)
74106 sd -> priv = ctx ;
75107
76108 ctx -> sbr_library = library ;
109+ sbr_library_set_log_callback (ctx -> sbr_library , mp_msg_sbr_log_callback , sd );
110+
77111 ctx -> bitmaps = talloc_zero (ctx , struct sub_bitmaps );
78112 ctx -> bitmaps -> format = SUBBITMAP_BGRA ;
79113 ctx -> bitmaps -> num_parts = 1 ;
0 commit comments