[FFmpeg-devel] [PATCH 11/17 v2] avformat/evc: don't use an AVIOContext as log context

James Almer jamrial at gmail.com
Tue Jun 20 00:11:34 EEST 2023


Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/evc_parse.h | 6 ++++--
 libavformat/evc.c      | 4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavcodec/evc_parse.h b/libavcodec/evc_parse.h
index a1fbbc643d..6fc19d0868 100644
--- a/libavcodec/evc_parse.h
+++ b/libavcodec/evc_parse.h
@@ -89,7 +89,8 @@ static inline int evc_get_nalu_type(const uint8_t *bits, int bits_size, void *lo
         unsigned char *p = (unsigned char *)bits;
         // forbidden_zero_bit
         if ((p[0] & 0x80) != 0) {
-            av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit header\n");
+            if (logctx) // Don't log without a context
+                av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit header\n");
             return -1;
         }
 
@@ -105,7 +106,8 @@ static inline uint32_t evc_read_nal_unit_length(const uint8_t *bits, int bits_si
     uint32_t nalu_len = 0;
 
     if (bits_size < EVC_NALU_LENGTH_PREFIX_SIZE) {
-        av_log(logctx, AV_LOG_ERROR, "Can't read NAL unit length\n");
+        if (logctx) // Don't log without a context
+            av_log(logctx, AV_LOG_ERROR, "Can't read NAL unit length\n");
         return 0;
     }
 
diff --git a/libavformat/evc.c b/libavformat/evc.c
index 421ff84cb7..caead88bba 100644
--- a/libavformat/evc.c
+++ b/libavformat/evc.c
@@ -361,7 +361,7 @@ int ff_isom_write_evcc(AVIOContext *pb, const uint8_t *data,
     evcc_init(&evcc);
 
     while (bytes_to_read > EVC_NALU_LENGTH_PREFIX_SIZE) {
-        nalu_size = evc_read_nal_unit_length(data, EVC_NALU_LENGTH_PREFIX_SIZE, pb);
+        nalu_size = evc_read_nal_unit_length(data, EVC_NALU_LENGTH_PREFIX_SIZE, NULL);
         if (nalu_size == 0) break;
 
         data += EVC_NALU_LENGTH_PREFIX_SIZE;
@@ -369,7 +369,7 @@ int ff_isom_write_evcc(AVIOContext *pb, const uint8_t *data,
 
         if (bytes_to_read < nalu_size) break;
 
-        nalu_type = evc_get_nalu_type(data, bytes_to_read, pb);
+        nalu_type = evc_get_nalu_type(data, bytes_to_read, NULL);
         if (nalu_type < EVC_NOIDR_NUT || nalu_type > EVC_UNSPEC_NUT62) {
             ret = AVERROR_INVALIDDATA;
             goto end;
-- 
2.41.0



More information about the ffmpeg-devel mailing list