diff mbox

[FFmpeg-devel] libavcodec/libx265.c: support for the x265 loglevel configured with ffmpeg loglevel option

Message ID 1539580090-80513-1-git-send-email-lance.lmwang@gmail.com
State New
Headers show

Commit Message

Lance Wang Oct. 15, 2018, 5:08 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

---
 libavcodec/libx265.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Derek Buitenhuis Oct. 16, 2018, 4:50 p.m. UTC | #1
On 15/10/2018 06:08, lance.lmwang@gmail.com wrote:
> From: Limin Wang<lance.lmwang@gmail.com>
> 
> ---
>   libavcodec/libx265.c | 18 ++++++++++++++++++
>   1 file changed, 18 insertions(+)

A few questions:

* Do we do anything similar elsewhere in FFmpeg?
* Does x265 have a log callback we can register? I'd prefer that way, if possible.
* Can you use x265_param_parse() instead of setting the struct memebers directly?
  This is ABI-comptable for any future changes.

- Derek
diff mbox

Patch

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 27c90b3..3a08767 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -108,6 +108,24 @@  static av_cold int libx265_encode_init(AVCodecContext *avctx)
         return AVERROR(EINVAL);
     }
 
+    switch (av_log_get_level()) {
+        case AV_LOG_ERROR:
+            ctx->params->logLevel = X265_LOG_ERROR;
+            break;
+        case AV_LOG_INFO:
+            ctx->params->logLevel = X265_LOG_INFO;
+            break;
+        case AV_LOG_DEBUG:
+            ctx->params->logLevel = X265_LOG_DEBUG;
+            break;
+        case AV_LOG_WARNING:
+            ctx->params->logLevel = X265_LOG_WARNING;
+            break;
+        case AV_LOG_TRACE:
+            ctx->params->logLevel = X265_LOG_FULL;
+            break;
+    }
+
     ctx->params->frameNumThreads = avctx->thread_count;
     ctx->params->fpsNum          = avctx->time_base.den;
     ctx->params->fpsDenom        = avctx->time_base.num * avctx->ticks_per_frame;