[FFmpeg-cvslog] amf: Replace writer_id option with LIBAV_AMF_WRITER_ID constant

Alexander Kravchenko git at videolan.org
Wed Mar 28 21:38:32 EEST 2018


ffmpeg | branch: master | Alexander Kravchenko <AAKravchenko at luxoft.com> | Wed Feb 28 06:33:05 2018 +0000| [80a4e6a46f21256e9bf508ead686563616945ad5] | committer: Diego Biurrun

amf: Replace writer_id option with LIBAV_AMF_WRITER_ID constant

AMFTraceWriter is an abstraction to configure how AMF outputs its logs
for the current process and can be configured to output different levels
of trace output. If multiple LibavWriter objects are used in one process,
there will be duplication of output in av_log. Use a constant writer_id
to prevent this scenario.

Signed-off-by: Diego Biurrun <diego at biurrun.de>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=80a4e6a46f21256e9bf508ead686563616945ad5
---

 libavcodec/amfenc.c | 8 +++++---
 libavcodec/amfenc.h | 4 +---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c
index f305a48bf7..74b020b4d8 100644
--- a/libavcodec/amfenc.c
+++ b/libavcodec/amfenc.c
@@ -46,6 +46,8 @@
 #include <dlfcn.h>
 #endif
 
+#define LIBAV_AMF_WRITER_ID L"libav_log"
+
 #define PTS_PROP L"PtsProp"
 
 const enum AVPixelFormat ff_amf_pix_fmts[] = {
@@ -171,8 +173,8 @@ static int amf_init_context(AVCodecContext *avctx)
     // connect AMF logger to av_log
     ctx->tracer.vtbl = &tracer_vtbl;
     ctx->tracer.avctx = avctx;
-    ctx->trace->pVtbl->RegisterWriter(ctx->trace, ctx->writer_id, (AMFTraceWriter*)&ctx->tracer, 1);
-    ctx->trace->pVtbl->SetWriterLevel(ctx->trace, ctx->writer_id, AMF_TRACE_TRACE);
+    ctx->trace->pVtbl->RegisterWriter(ctx->trace, LIBAV_AMF_WRITER_ID,(AMFTraceWriter *)&ctx->tracer, 1);
+    ctx->trace->pVtbl->SetWriterLevel(ctx->trace, LIBAV_AMF_WRITER_ID, AMF_TRACE_TRACE);
 
     res = ctx->factory->pVtbl->CreateContext(ctx->factory, &ctx->context);
     AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN, "CreateContext() failed with error %d\n", res);
@@ -283,7 +285,7 @@ int av_cold ff_amf_encode_close(AVCodecContext *avctx)
     av_buffer_unref(&ctx->hw_frames_ctx);
 
     if (ctx->trace) {
-        ctx->trace->pVtbl->UnregisterWriter(ctx->trace, ctx->writer_id);
+        ctx->trace->pVtbl->UnregisterWriter(ctx->trace, LIBAV_AMF_WRITER_ID);
     }
     if (ctx->library) {
         dlclose(ctx->library);
diff --git a/libavcodec/amfenc.h b/libavcodec/amfenc.h
index f3b82be770..a8153ef12e 100644
--- a/libavcodec/amfenc.h
+++ b/libavcodec/amfenc.h
@@ -80,7 +80,6 @@ typedef struct AmfContext {
 
     // common encoder options
     int                 log_to_dbg;
-    char                *writer_id;
 
     // Static options, have to be set before Init() call
     int                 usage;
@@ -152,7 +151,6 @@ extern const enum AVPixelFormat ff_amf_pix_fmts[];
     }
 
 #define AMF_COMMON_OPTIONS \
-    { "log_to_dbg",     "Enable AMF logging to debug output",   OFFSET(log_to_dbg), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, \
-    { "writer_id",      "Enable AMF logging to writer id",      OFFSET(writer_id),  AV_OPT_TYPE_STRING, { .str = "libavcodec" }, 0, 1, VE } \
+    { "log_to_dbg",     "Enable AMF logging to debug output",   OFFSET(log_to_dbg), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE } \
 
 #endif //AVCODEC_AMFENC_H



More information about the ffmpeg-cvslog mailing list