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] libavcodec/libopusenc: fix type mismatch in OPUS_GET_LOOKAHEAD call (PR #21231)
@ 2025-12-18  6:42 cenzhanquan1 via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: cenzhanquan1 via ffmpeg-devel @ 2025-12-18  6:42 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: cenzhanquan1

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

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

only message in thread, other threads:[~2025-12-18  6:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-18  6:42 [FFmpeg-devel] [PATCH] libavcodec/libopusenc: fix type mismatch in OPUS_GET_LOOKAHEAD call (PR #21231) cenzhanquan1 via ffmpeg-devel

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