Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: cenzhanquan1 via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: cenzhanquan1 <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] libavcodec/libopusenc: fix type mismatch in OPUS_GET_LOOKAHEAD call (PR #21231)
Date: Thu, 18 Dec 2025 06:42:20 -0000
Message-ID: <176604014091.60.4889013895499978745@2cb04c0e5124> (raw)

PR #21231 opened by cenzhanquan1
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21231
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21231.patch

Problem:
Compilation fails when building with Opus library due to type mismatch in
OPUS_GET_LOOKAHEAD macro call. The error is:
"invalid operands to binary - (have 'int *' and 'opus_int32 *')"

Root cause:
- AVCodecContext.initial_padding is of type 'int', so &avctx->initial_padding is 'int*';
- Opus's OPUS_GET_LOOKAHEAD macro expands to __opus_check_int_ptr, which requires
  a 'opus_int32*' pointer for pointer subtraction;
- Mismatched pointer types trigger compilation error in the macro's pointer arithmetic.

Solution:
Use an intermediate 'opus_int32' variable to adapt the type:
1. Declare opus_int32 lookahead and initialize with avctx->initial_padding;
2. Pass &lookahead to OPUS_GET_LOOKAHEAD (matches required 'opus_int32*' type);
3. Sync the result back to avctx->initial_padding to preserve original logic.

This fix maintains full functionality while resolving the type mismatch, with no
performance impact or behavior changes.

Signed-off-by: cenzhanquan1 <cenzhanquan1@xiaomi.com>


>From daca8ca736f3b1266ebc23cda88a75a1ddd217ab Mon Sep 17 00:00:00 2001
From: cenzhanquan1 <cenzhanquan1@xiaomi.com>
Date: Thu, 18 Dec 2025 14:38:48 +0800
Subject: [PATCH] libavcodec/libopusenc: fix type mismatch in
 OPUS_GET_LOOKAHEAD call

Problem:
Compilation fails when building with Opus library due to type mismatch in
OPUS_GET_LOOKAHEAD macro call. The error is:
"invalid operands to binary - (have 'int *' and 'opus_int32 *')"

Root cause:
- AVCodecContext.initial_padding is of type 'int', so &avctx->initial_padding is 'int*';
- Opus's OPUS_GET_LOOKAHEAD macro expands to __opus_check_int_ptr, which requires
  a 'opus_int32*' pointer for pointer subtraction;
- Mismatched pointer types trigger compilation error in the macro's pointer arithmetic.

Solution:
Use an intermediate 'opus_int32' variable to adapt the type:
1. Declare opus_int32 lookahead and initialize with avctx->initial_padding;
2. Pass &lookahead to OPUS_GET_LOOKAHEAD (matches required 'opus_int32*' type);
3. Sync the result back to avctx->initial_padding to preserve original logic.

This fix maintains full functionality while resolving the type mismatch, with no
performance impact or behavior changes.

Signed-off-by: cenzhanquan1 <cenzhanquan1@xiaomi.com>
---
 libavcodec/libopusenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
index 131886c8ea..543d4eba24 100644
--- a/libavcodec/libopusenc.c
+++ b/libavcodec/libopusenc.c
@@ -419,7 +419,7 @@ static av_cold int libopus_encode_init(AVCodecContext *avctx)
         goto fail;
     }
 
-    ret = opus_multistream_encoder_ctl(enc, OPUS_GET_LOOKAHEAD(&avctx->initial_padding));
+    ret = opus_multistream_encoder_ctl(enc, OPUS_GET_LOOKAHEAD((opus_int32*)&avctx->initial_padding));
     if (ret != OPUS_OK)
         av_log(avctx, AV_LOG_WARNING,
                "Unable to get number of lookahead samples: %s\n",
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

                 reply	other threads:[~2025-12-18  6:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=176604014091.60.4889013895499978745@2cb04c0e5124 \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=code@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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