>From 32307b20cf1115753888cb2b86068a1c18241c8b Mon Sep 17 00:00:00 2001 From: Ayush Tripathi <[email protected]>
Date: Tue, 24 Mar 2026 00:46:47 +0530 Subject: [PATCH] avcodec/decode: improve debug logging in avcodec_send_packet Add debug-level logging to distinguish between normal packets and drain (NULL) packets in avcodec_send_packet(). This improves observability of packet flow during decoding while keeping overhead minimal by gating logs behind AV_LOG_DEBUG level. Signed-off-by: Ayush Tripathi <[email protected]> --- libavcodec/decode.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index f1b143e821..1c38ae0a50 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -710,13 +710,6 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame, int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt) { - if (!avpkt) { - av_log(avctx, AV_LOG_DEBUG, "Drain packet received (NULL packet)\n"); - } else if (!avpkt->size && avpkt->data) { - av_log(avctx, AV_LOG_ERROR, "Invalid packet detected (size=0 but data present)\n"); - } else { - av_log(avctx, AV_LOG_DEBUG, "Normal packet (size=%d, data=%p)\n", avpkt->size, avpkt->data); - } AVCodecInternal *avci = avctx->internal; DecodeContext *dc = decode_ctx(avci); int ret; @@ -724,11 +717,19 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacke if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec)) return AVERROR(EINVAL); + if (av_log_get_level() >= AV_LOG_DEBUG) { + if (!avpkt) { + av_log(avctx, AV_LOG_DEBUG, "Drain packet received (NULL packet)\n"); + } else { + av_log(avctx, AV_LOG_DEBUG, "Normal packet (size=%d)\n", avpkt->size); + } + } + if (dc->draining_started) return AVERROR_EOF; if (avpkt && !avpkt->size && avpkt->data) { - av_log(avctx, AV_LOG_ERROR, "Invalid packet: data present but size is 0\n"); + av_log(avctx, AV_LOG_ERROR, "Invalid packet: data present but size is 0 (avcodec_send_packet)\n"); return AVERROR(EINVAL); } -- 2.50.1 (Apple Git-155) _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
