Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/3] avcodec/{h263, ituh263, msmpeg4, snow}dec: Use proper, logcontext
@ 2025-03-05  2:24 Andreas Rheinhardt
  0 siblings, 0 replies; only message in thread
From: Andreas Rheinhardt @ 2025-03-05  2:24 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

[-- Attachment #1: Type: text/plain, Size: 28 bytes --]

Patches attached

- Andreas

[-- Attachment #2: 0001-avcodec-h263-ituh263-msmpeg4-snow-dec-Use-proper-log.patch --]
[-- Type: text/x-patch, Size: 4575 bytes --]

From 6c50b26de89f1bbcfe025aaf3b28c94b68376414 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Wed, 5 Mar 2025 00:50:49 +0100
Subject: [PATCH 1/3] avcodec/{h263,ituh263,msmpeg4,snow}dec: Use proper
 logcontext

The logging functions here can be reached by codecs without
private class, so that the log callback will receive a non-NULL
object whose AVClass pointer is NULL. Although the default log
callback handles this gracefully, it is probably an API violation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h263dec.c    | 2 +-
 libavcodec/ituh263dec.c | 2 +-
 libavcodec/msmpeg4dec.c | 6 +++---
 libavcodec/snowdec.c    | 6 ++++--
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 9ccdd914ce..982a56ae05 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -242,7 +242,7 @@ static int decode_slice(MpegEncContext *s)
 
             s->mv_dir  = MV_DIR_FORWARD;
             s->mv_type = MV_TYPE_16X16;
-            ff_dlog(s, "%d %06X\n",
+            ff_dlog(s->avctx, "%d %06X\n",
                     get_bits_count(&s->gb), show_bits(&s->gb, 24));
 
             ff_tlog(NULL, "Decoding MB at %dx%d\n", s->mb_x, s->mb_y);
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index e0f3034e57..9d6b26ad98 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -1264,7 +1264,7 @@ int ff_h263_decode_picture_header(MpegEncContext *s)
                 s->avctx->framerate.den  = 1000 + get_bits1(&s->gb);
                 s->avctx->framerate.den *= get_bits(&s->gb, 7);
                 if(s->avctx->framerate.den == 0){
-                    av_log(s, AV_LOG_ERROR, "zero framerate\n");
+                    av_log(s->avctx, AV_LOG_ERROR, "zero framerate\n");
                     return -1;
                 }
                 gcd= av_gcd(s->avctx->framerate.den, s->avctx->framerate.num);
diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index d42219f464..0604dc8963 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -77,7 +77,7 @@ static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code)
     int code, val, sign, shift;
 
     code = get_vlc2(&s->gb, ff_h263_mv_vlc, H263_MV_VLC_BITS, 2);
-    ff_dlog(s, "MV code %d at %d %d pred: %d\n", code, s->mb_x,s->mb_y, pred);
+    ff_dlog(s->avctx, "MV code %d at %d %d pred: %d\n", code, s->mb_x,s->mb_y, pred);
     if (code < 0)
         return 0xffff;
 
@@ -267,14 +267,14 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64])
         s->mv[0][0][1] = my;
         *mb_type_ptr = MB_TYPE_FORWARD_MV | MB_TYPE_16x16;
     } else {
-        ff_dlog(s, "I at %d %d %d %06X\n", s->mb_x, s->mb_y,
+        ff_dlog(s->avctx, "I at %d %d %d %06X\n", s->mb_x, s->mb_y,
                 ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0),
                 show_bits(&s->gb, 24));
         s->ac_pred = get_bits1(&s->gb);
         *mb_type_ptr = MB_TYPE_INTRA;
         if(s->inter_intra_pred){
             s->h263_aic_dir= get_vlc2(&s->gb, ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 1);
-            ff_dlog(s, "%d%d %d %d/",
+            ff_dlog(s->avctx, "%d%d %d %d/",
                     s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y);
         }
         if(s->per_mb_rl_table && cbp){
diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c
index 50dcaf8b93..d99da8a4f3 100644
--- a/libavcodec/snowdec.c
+++ b/libavcodec/snowdec.c
@@ -481,14 +481,16 @@ static int decode_header(SnowContext *s){
             }else if(s->chroma_h_shift == 2 && s->chroma_v_shift==2){
                 s->avctx->pix_fmt= AV_PIX_FMT_YUV410P;
             } else {
-                av_log(s, AV_LOG_ERROR, "unsupported color subsample mode %d %d\n", s->chroma_h_shift, s->chroma_v_shift);
+                av_log(s->avctx, AV_LOG_ERROR,
+                       "unsupported color subsample mode %d %d\n",
+                       s->chroma_h_shift, s->chroma_v_shift);
                 s->chroma_h_shift = s->chroma_v_shift = 1;
                 s->avctx->pix_fmt= AV_PIX_FMT_YUV420P;
                 return AVERROR_INVALIDDATA;
             }
             s->nb_planes = 3;
         } else {
-            av_log(s, AV_LOG_ERROR, "unsupported color space\n");
+            av_log(s->avctx, AV_LOG_ERROR, "unsupported color space\n");
             s->chroma_h_shift = s->chroma_v_shift = 1;
             s->avctx->pix_fmt= AV_PIX_FMT_YUV420P;
             return AVERROR_INVALIDDATA;
-- 
2.45.2


[-- Attachment #3: 0002-avcodec-Don-t-log-to-private-context.patch --]
[-- Type: text/x-patch, Size: 19233 bytes --]

From d7299dea3090e8c6ac43b4595291d6d88215a95f Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Wed, 5 Mar 2025 01:27:29 +0100
Subject: [PATCH 2/3] avcodec: Don't log to private context

While it is save for these codecs (they all have private contexts),
it is customary to always use the AVCodecContext for logging.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/ccaption_dec.c              | 21 +++++++++-------
 libavcodec/dvdsubdec.c                 | 34 +++++++++++++-------------
 libavcodec/h264_refs.c                 |  2 +-
 libavcodec/h264_slice.c                |  2 +-
 libavcodec/j2kenc.c                    |  2 +-
 libavcodec/motion_est.c                |  4 +--
 libavcodec/mpegvideo_enc.c             |  2 +-
 libavcodec/msmpeg4enc.c                |  2 +-
 libavcodec/ratecontrol.c               | 12 ++++-----
 libavcodec/x86/mpegvideoenc_template.c |  2 +-
 10 files changed, 43 insertions(+), 40 deletions(-)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index d8b992bb94..01bdc4d537 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -253,6 +253,7 @@ struct Screen {
 
 typedef struct CCaptionSubContext {
     AVClass *class;
+    void *logctx;
     int real_time;
     int real_time_latency_msec;
     int data_field;
@@ -280,6 +281,8 @@ static av_cold int init_decoder(AVCodecContext *avctx)
 {
     CCaptionSubContext *ctx = avctx->priv_data;
 
+    ctx->logctx = avctx;
+
     av_bprint_init(&ctx->buffer[0], 0, AV_BPRINT_SIZE_UNLIMITED);
     av_bprint_init(&ctx->buffer[1], 0, AV_BPRINT_SIZE_UNLIMITED);
     /* taking by default roll up to 2 */
@@ -359,7 +362,7 @@ static void write_char(CCaptionSubContext *ctx, struct Screen *screen, char ch)
         return;
     }
     else {
-        av_log(ctx, AV_LOG_WARNING, "Data ignored due to columns exceeding screen width\n");
+        av_log(ctx->logctx, AV_LOG_WARNING, "Data ignored due to columns exceeding screen width\n");
         return;
     }
 }
@@ -649,7 +652,7 @@ static void handle_pac(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
     int indent, i;
 
     if (row_map[index] <= 0) {
-        av_log(ctx, AV_LOG_DEBUG, "Invalid pac index encountered\n");
+        av_log(ctx->logctx, AV_LOG_DEBUG, "Invalid pac index encountered\n");
         return;
     }
 
@@ -749,9 +752,9 @@ static void handle_char(CCaptionSubContext *ctx, char hi, char lo)
         ctx->screen_touched = 1;
 
     if (lo)
-       ff_dlog(ctx, "(%c,%c)\n", hi, lo);
+       ff_dlog(ctx->logctx, "(%c,%c)\n", hi, lo);
     else
-       ff_dlog(ctx, "(%c)\n", hi);
+       ff_dlog(ctx->logctx, "(%c)\n", hi);
 }
 
 static int process_cc608(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
@@ -803,7 +806,7 @@ static int process_cc608(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
             break;
         case 0x2d:
             /* carriage return */
-            ff_dlog(ctx, "carriage return\n");
+            ff_dlog(ctx->logctx, "carriage return\n");
             if (!ctx->real_time)
                 ret = capture_screen(ctx);
             roll_up(ctx);
@@ -820,11 +823,11 @@ static int process_cc608(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
             break;
         case 0x2f:
             /* end of caption */
-            ff_dlog(ctx, "handle_eoc\n");
+            ff_dlog(ctx->logctx, "handle_eoc\n");
             ret = handle_eoc(ctx);
             break;
         default:
-            ff_dlog(ctx, "Unknown command 0x%hhx 0x%hhx\n", hi, lo);
+            ff_dlog(ctx->logctx, "Unknown command 0x%hhx 0x%hhx\n", hi, lo);
             break;
         }
     } else if (hi >= 0x11 && hi <= 0x13) {
@@ -842,7 +845,7 @@ static int process_cc608(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
         }
     } else {
         /* Ignoring all other non data code */
-        ff_dlog(ctx, "Unknown command 0x%hhx 0x%hhx\n", hi, lo);
+        ff_dlog(ctx->logctx, "Unknown command 0x%hhx 0x%hhx\n", hi, lo);
     }
 
     return ret;
@@ -888,7 +891,7 @@ static int decode(AVCodecContext *avctx, AVSubtitle *sub,
         update_time(ctx, in_time);
 
         if (ctx->buffer[bidx].str[0] || ctx->real_time) {
-            ff_dlog(ctx, "cdp writing data (%s)\n", ctx->buffer[bidx].str);
+            ff_dlog(avctx, "cdp writing data (%s)\n", ctx->buffer[bidx].str);
             start_time = ctx->buffer_time[0];
             sub->pts = start_time;
             end_time = ctx->buffer_time[1];
diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index f8769353a0..78658f7d2f 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -217,8 +217,8 @@ static void reset_rects(AVSubtitle *sub_header)
 
 #define READ_OFFSET(a) (big_offsets ? AV_RB32(a) : AV_RB16(a))
 
-static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
-                                const uint8_t *buf, int buf_size)
+static int decode_dvd_subtitles(void *logctx, DVDSubContext *ctx,
+                                AVSubtitle *sub_header, const uint8_t *buf, int buf_size)
 {
     int cmd_pos, pos, cmd, x1, y1, x2, y2, next_cmd_pos;
     int big_offsets, offset_size, is_8bit = 0;
@@ -248,7 +248,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
 
     if (cmd_pos < 0 || cmd_pos > buf_size - 2 - offset_size) {
         if (cmd_pos > size) {
-            av_log(ctx, AV_LOG_ERROR, "Discarding invalid packet\n");
+            av_log(logctx, AV_LOG_ERROR, "Discarding invalid packet\n");
             return 0;
         }
         return AVERROR(EAGAIN);
@@ -257,7 +257,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
     while (cmd_pos > 0 && cmd_pos < buf_size - 2 - offset_size) {
         date = AV_RB16(buf + cmd_pos);
         next_cmd_pos = READ_OFFSET(buf + cmd_pos + 2);
-        ff_dlog(NULL, "cmd_pos=0x%04x next=0x%04x date=%d\n",
+        ff_dlog(logctx, "cmd_pos=0x%04x next=0x%04x date=%d\n",
                 cmd_pos, next_cmd_pos, date);
         pos = cmd_pos + 2 + offset_size;
         offset1 = -1;
@@ -265,7 +265,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
         x1 = y1 = x2 = y2 = 0;
         while (pos < buf_size) {
             cmd = buf[pos++];
-            ff_dlog(NULL, "cmd=%02x\n", cmd);
+            ff_dlog(logctx, "cmd=%02x\n", cmd);
             switch(cmd) {
             case 0x00:
                 /* menu subpicture */
@@ -298,7 +298,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
                 alpha[1] = buf[pos + 1] >> 4;
                 alpha[0] = buf[pos + 1] & 0x0f;
                 pos += 2;
-                ff_dlog(NULL, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
+                ff_dlog(logctx, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
                 break;
             case 0x05:
             case 0x85:
@@ -310,7 +310,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
                 y2 = ((buf[pos + 4] & 0x0f) << 8) | buf[pos + 5];
                 if (cmd & 0x80)
                     is_8bit = 1;
-                ff_dlog(NULL, "x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2);
+                ff_dlog(logctx, "x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2);
                 pos += 6;
                 break;
             case 0x06:
@@ -318,7 +318,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
                     goto fail;
                 offset1 = AV_RB16(buf + pos);
                 offset2 = AV_RB16(buf + pos + 2);
-                ff_dlog(NULL, "offset1=0x%04"PRIx64" offset2=0x%04"PRIx64"\n", offset1, offset2);
+                ff_dlog(logctx, "offset1=0x%04"PRIx64" offset2=0x%04"PRIx64"\n", offset1, offset2);
                 pos += 4;
                 break;
             case 0x86:
@@ -326,7 +326,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
                     goto fail;
                 offset1 = AV_RB32(buf + pos);
                 offset2 = AV_RB32(buf + pos + 4);
-                ff_dlog(NULL, "offset1=0x%04"PRIx64" offset2=0x%04"PRIx64"\n", offset1, offset2);
+                ff_dlog(logctx, "offset1=0x%04"PRIx64" offset2=0x%04"PRIx64"\n", offset1, offset2);
                 pos += 8;
                 break;
 
@@ -349,7 +349,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
             case 0xff:
                 goto the_end;
             default:
-                ff_dlog(NULL, "unrecognised subpicture command 0x%x\n", cmd);
+                ff_dlog(logctx, "unrecognised subpicture command 0x%x\n", cmd);
                 goto the_end;
             }
         }
@@ -412,7 +412,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
             }
         }
         if (next_cmd_pos < cmd_pos) {
-            av_log(ctx, AV_LOG_ERROR, "Invalid command offset\n");
+            av_log(logctx, AV_LOG_ERROR, "Invalid command offset\n");
             break;
         }
         if (next_cmd_pos == cmd_pos)
@@ -535,7 +535,7 @@ static int dvdsub_decode(AVCodecContext *avctx, AVSubtitle *sub,
         appended = 1;
     }
 
-    is_menu = decode_dvd_subtitles(ctx, sub, buf, buf_size);
+    is_menu = decode_dvd_subtitles(avctx, ctx, sub, buf, buf_size);
     if (is_menu == AVERROR(EAGAIN)) {
         *data_size = 0;
         return appended ? 0 : append_to_cached_buf(avctx, buf, buf_size);
@@ -560,7 +560,7 @@ static int dvdsub_decode(AVCodecContext *avctx, AVSubtitle *sub,
     return buf_size;
 }
 
-static int parse_ifo_palette(DVDSubContext *ctx, char *p)
+static int parse_ifo_palette(void *logctx, DVDSubContext *ctx, char *p)
 {
     FILE *ifo;
     char ifostr[12];
@@ -572,11 +572,11 @@ static int parse_ifo_palette(DVDSubContext *ctx, char *p)
 
     ctx->has_palette = 0;
     if ((ifo = avpriv_fopen_utf8(p, "r")) == NULL) {
-        av_log(ctx, AV_LOG_WARNING, "Unable to open IFO file \"%s\": %s\n", p, av_err2str(AVERROR(errno)));
+        av_log(logctx, AV_LOG_WARNING, "Unable to open IFO file \"%s\": %s\n", p, av_err2str(AVERROR(errno)));
         return AVERROR_EOF;
     }
     if (fread(ifostr, 12, 1, ifo) != 1 || memcmp(ifostr, "DVDVIDEO-VTS", 12)) {
-        av_log(ctx, AV_LOG_WARNING, "\"%s\" is not a proper IFO file\n", p);
+        av_log(logctx, AV_LOG_WARNING, "\"%s\" is not a proper IFO file\n", p);
         ret = AVERROR_INVALIDDATA;
         goto end;
     }
@@ -612,7 +612,7 @@ static int parse_ifo_palette(DVDSubContext *ctx, char *p)
         }
     }
     if (ctx->has_palette == 0) {
-        av_log(ctx, AV_LOG_WARNING, "Failed to read palette from IFO file \"%s\"\n", p);
+        av_log(logctx, AV_LOG_WARNING, "Failed to read palette from IFO file \"%s\"\n", p);
         ret = AVERROR_INVALIDDATA;
     }
 end:
@@ -670,7 +670,7 @@ static av_cold int dvdsub_init(AVCodecContext *avctx)
         return ret;
 
     if (ctx->ifo_str)
-        parse_ifo_palette(ctx, ctx->ifo_str);
+        parse_ifo_palette(avctx, ctx, ctx->ifo_str);
     if (ctx->palette_str) {
         ctx->has_palette = 1;
         ff_dvdsub_parse_palette(ctx->palette, ctx->palette_str);
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index 5eb2855065..050ca92292 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -409,7 +409,7 @@ int ff_h264_build_ref_list(H264Context *h, H264SliceContext *sl)
                     if (h->default_ref[list2].parent && !h->default_ref[list2].parent->gray
                         && !(!FIELD_PICTURE(h) && (h->default_ref[list2].reference&3) != 3)) {
                         sl->ref_list[list][index] = h->default_ref[list2];
-                        av_log(h, AV_LOG_DEBUG, "replacement of gray gap frame\n");
+                        av_log(h->avctx, AV_LOG_DEBUG, "replacement of gray gap frame\n");
                         break;
                     }
                 }
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index cb22b76730..726a56d004 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -2100,7 +2100,7 @@ int ff_h264_queue_decode_slice(H264Context *h, const H2645NAL *nal)
                 if (ret < 0)
                     return ret;
             } else if (h->cur_pic_ptr && !FIELD_PICTURE(h) && !h->first_field && h->nal_unit_type  == H264_NAL_IDR_SLICE) {
-                av_log(h, AV_LOG_WARNING, "Broken frame packetizing\n");
+                av_log(h->avctx, AV_LOG_WARNING, "Broken frame packetizing\n");
                 ret = ff_h264_field_end(h, h->slice_ctx, 1);
                 ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 0);
                 ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 1);
diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 60cc0f3093..b7a213af34 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -1726,7 +1726,7 @@ static av_cold int j2kenc_init(AVCodecContext *avctx)
     s->avctx = avctx;
     av_log(s->avctx, AV_LOG_DEBUG, "init\n");
     if (parse_layer_rates(s)) {
-        av_log(s, AV_LOG_WARNING, "Layer rates invalid. Encoding with 1 layer based on quality metric.\n");
+        av_log(avctx, AV_LOG_WARNING, "Layer rates invalid. Encoding with 1 layer based on quality metric.\n");
         s->nlayers = 1;
         s->layer_rates[0] = 0;
         s->compression_rate_enc = 0;
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 46c4ca2dd9..3c427cbb40 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -1526,11 +1526,11 @@ void ff_estimate_b_frame_motion(MpegEncContext * s,
     c->skip=0;
     bmin = estimate_motion_b(s, mb_x, mb_y, s->b_back_mv_table, 2, s->b_code) +
            2 * c->mb_penalty_factor;
-    ff_dlog(s, " %d %d ", s->b_forw_mv_table[xy][0], s->b_forw_mv_table[xy][1]);
+    ff_dlog(s->avctx, " %d %d ", s->b_forw_mv_table[xy][0], s->b_forw_mv_table[xy][1]);
 
     c->skip=0;
     fbmin= bidir_refine(s, mb_x, mb_y) + c->mb_penalty_factor;
-    ff_dlog(s, "%d %d %d %d\n", dmin, fmin, bmin, fbmin);
+    ff_dlog(s->avctx, "%d %d %d %d\n", dmin, fmin, bmin, fbmin);
 
     if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME) {
 //FIXME mb type penalty
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 8c22dbb5f5..cffe8cc8d3 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -3767,7 +3767,7 @@ static int encode_picture(MpegEncContext *s, const AVPacket *pkt)
             s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
         if (s->msmpeg4_version >= MSMP4_V3)
             s->no_rounding=1;
-        ff_dlog(s, "Scene change detected, encoding as I Frame %"PRId64" %"PRId64"\n",
+        ff_dlog(s->avctx, "Scene change detected, encoding as I Frame %"PRId64" %"PRId64"\n",
                 s->mb_var_sum, s->mc_mb_var_sum);
     }
 
diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c
index 26b896bee3..89f4533d05 100644
--- a/libavcodec/msmpeg4enc.c
+++ b/libavcodec/msmpeg4enc.c
@@ -236,7 +236,7 @@ void ff_msmpeg4_encode_picture_header(MpegEncContext * s)
     s->per_mb_rl_table = 0;
     if (s->msmpeg4_version == MSMP4_WMV1)
         s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE && s->pict_type==AV_PICTURE_TYPE_P);
-    ff_dlog(s, "%d %"PRId64" %d %d %d\n", s->pict_type, s->bit_rate,
+    ff_dlog(s->avctx, "%d %"PRId64" %d %d %d\n", s->pict_type, s->bit_rate,
             s->inter_intra_pred, s->width, s->height);
 
     if (s->pict_type == AV_PICTURE_TYPE_I) {
diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
index 86ec7a3443..f8596bfdc3 100644
--- a/libavcodec/ratecontrol.c
+++ b/libavcodec/ratecontrol.c
@@ -232,7 +232,7 @@ static double modify_qscale(MpegEncContext *s, const RateControlEntry *rce,
             }
         }
     }
-    ff_dlog(s, "q:%f max:%f min:%f size:%f index:%f agr:%f\n",
+    ff_dlog(s->avctx, "q:%f max:%f min:%f size:%f index:%f agr:%f\n",
             q, max_rate, min_rate, buffer_size, rcc->buffer_index,
             s->rc_buffer_aggressivity);
     if (s->rc_qsquish == 0.0 || qmin == qmax) {
@@ -461,7 +461,7 @@ static int init_pass2(MpegEncContext *s)
     /* check bitrate calculations and print info */
     qscale_sum = 0.0;
     for (i = 0; i < rcc->num_entries; i++) {
-        ff_dlog(s, "[lavc rc] entry[%d].new_qscale = %.3f  qp = %.3f\n",
+        ff_dlog(s->avctx, "[lavc rc] entry[%d].new_qscale = %.3f  qp = %.3f\n",
                 i,
                 rcc->entry[i].new_qscale,
                 rcc->entry[i].new_qscale / FF_QP2LAMBDA);
@@ -714,7 +714,7 @@ int ff_vbv_update(MpegEncContext *s, int frame_size)
     const double min_rate   = s->avctx->rc_min_rate / fps;
     const double max_rate   = s->avctx->rc_max_rate / fps;
 
-    ff_dlog(s, "%d %f %d %f %f\n",
+    ff_dlog(s->avctx, "%d %f %d %f %f\n",
             buffer_size, rcc->buffer_index, frame_size, min_rate, max_rate);
 
     if (buffer_size) {
@@ -929,7 +929,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
     if (s->avctx->flags & AV_CODEC_FLAG_PASS2) {
         av_assert0(picture_number >= 0);
         if (picture_number >= rcc->num_entries) {
-            av_log(s, AV_LOG_ERROR, "Input is longer than 2-pass log file\n");
+            av_log(s->avctx, AV_LOG_ERROR, "Input is longer than 2-pass log file\n");
             return -1;
         }
         rce         = &rcc->entry[picture_number];
@@ -952,7 +952,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
         else
             wanted_bits_double = s->bit_rate * (double)dts_pic->f->pts / fps;
         if (wanted_bits_double > INT64_MAX) {
-            av_log(s, AV_LOG_WARNING, "Bits exceed 64bit range\n");
+            av_log(s->avctx, AV_LOG_WARNING, "Bits exceed 64bit range\n");
             wanted_bits = INT64_MAX;
         } else
             wanted_bits = (int64_t)wanted_bits_double;
@@ -971,7 +971,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
             av_assert0(pict_type == rce->new_pict_type);
 
         q = rce->new_qscale / br_compensation;
-        ff_dlog(s, "%f %f %f last:%d var:%"PRId64" type:%d//\n", q, rce->new_qscale,
+        ff_dlog(s->avctx, "%f %f %f last:%d var:%"PRId64" type:%d//\n", q, rce->new_qscale,
                 br_compensation, s->frame_bits, var, pict_type);
     } else {
         rce->pict_type     =
diff --git a/libavcodec/x86/mpegvideoenc_template.c b/libavcodec/x86/mpegvideoenc_template.c
index 4096d6391f..f937c7166b 100644
--- a/libavcodec/x86/mpegvideoenc_template.c
+++ b/libavcodec/x86/mpegvideoenc_template.c
@@ -401,7 +401,7 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
         block[0x3D] = temp_block[0x2F]; block[0x3E] = temp_block[0x37];
         block[0x37] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F];
     } else {
-        av_log(s, AV_LOG_DEBUG, "s->idsp.perm_type: %d\n",
+        av_log(s->avctx, AV_LOG_DEBUG, "s->idsp.perm_type: %d\n",
                 (int)s->idsp.perm_type);
         av_assert0(s->idsp.perm_type == FF_IDCT_PERM_NONE ||
                 s->idsp.perm_type == FF_IDCT_PERM_LIBMPEG2 ||
-- 
2.45.2


[-- Attachment #4: 0003-avutil-log-Set-AVClass-in-av_expr_eval.patch --]
[-- Type: text/x-patch, Size: 1275 bytes --]

From e0422e7d02fe761e9d67533271fa40ab3d582b15 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Wed, 5 Mar 2025 03:14:16 +0100
Subject: [PATCH 3/3] avutil/log: Set AVClass* in av_expr_eval()

Otherwise it is possible for av_log() to receive a non-NULL object
with a NULL AVClass pointer; the default log callback handles it
gracefully, yet this is probably an API violation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavutil/eval.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/libavutil/eval.c b/libavutil/eval.c
index 298925a6e5..7fa5d5d9d5 100644
--- a/libavutil/eval.c
+++ b/libavutil/eval.c
@@ -791,12 +791,14 @@ int av_expr_count_func(AVExpr *e, unsigned *counter, int size, int arg)
 
 double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
 {
-    Parser p = { 0 };
-    p.var= e->var;
-    p.prng_state= e->prng_state;
+    Parser p = {
+        .class        = &eval_class,
+        .const_values = const_values,
+        .opaque       = opaque,
+        .var          = e->var,
+        .prng_state   = e->prng_state,
+    };
 
-    p.const_values = const_values;
-    p.opaque     = opaque;
     return eval_expr(&p, e);
 }
 
-- 
2.45.2


[-- Attachment #5: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-03-05  2:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-05  2:24 [FFmpeg-devel] [PATCH 1/3] avcodec/{h263, ituh263, msmpeg4, snow}dec: Use proper, logcontext Andreas Rheinhardt

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git