From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id EEA8044B0F for ; Mon, 20 Oct 2025 06:59:27 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'Z74NgLiywExHRueWqyZrE7+9Av2wIrUTGX078YPI9ww=', expected b'G8ySUN6oIiTkMgdwtzxFc6/FHWeIcGd1zluXHFdvVs0=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1760943558; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=Z74NgLiywExHRueWqyZrE7+9Av2wIrUTGX078YPI9ww=; b=eJmHkgUUnkqbWXETCh2K1OefF0QlVD9a7FbYWADO+BrnUoLgPULwWYXUNwmw9ceBMxekG +a5b4xdvqC/toYRuXAOjcZ6K385vLVOXlJhBLn2QrsKrEO80nrnNifhq+BSfBv+fv0ySaDE 9Xu7ClnDokH4zI2hg7rah/5idGRyNZbSRrUKr4J6dLoA0u03lx3pGMduxg34H7vXx9Q5LvT tENuEX6aovyBASB5IjiJQ+4e8VlJaqFP4WeEs2kpmNnkqi1hDuAbdkxFH6MDq4V20+kAZd6 vqObK9yLWpcIyey5DwDVugSTXI2+kI4FLUnnDIF7gZZmu87/s7NOSvPmMhKw== Received: from [172.19.0.2] (unknown [172.19.0.2]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 19D7668F4AE; Mon, 20 Oct 2025 09:59:18 +0300 (EEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1760943543; b=Dg5Qki7m0rmuuVlhcJstwzqG4Z5q1tsAOb3mnrsBn14tHI8pBhbxpuSjmFWE8UiSWIL5G lrYfo0RgWG/Ox0MKWQUQoQQfwMus6JafviA1WmDc2ypZwzbGeduDtrcsvTuhwjozPg/Hg3z YNkt94d83fv8XXwzhtnwWBE6e3FOFIQGEA/fUwggo9D7BJx0mOscxPE2RHpWz7wUgOw/ezx yBsR3CptNbUsmgV+D0/PCfa784aZTVG05oiIKvj+FvnZxlRIkWc6++iynikO5fXinc1MaUf XXOCrUkCc5b07lphPz62BkoZD0Dlu8G10q0miwQyNcIlSIxM2QZ7OMswDJTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1760943543; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=ZNKLHkfA2gDRsrmP3zq/NC0wBLq/n7/FBGAhm7C1gqk=; b=LnQ/nnsYetcXAhM6Jaz1YYYIds5Fopl4yULQuhNrsSTgH8obwiSbxeEsHWCf8Mzc97H6J XWf6GIQ5hcTg/gDO+90dbvjH+M1Tjw4eHt/L4lYEETUp7S37FXVY2jz5qjQY9rMKpaAhg/3 I53emV9n2V/P9LaF3i4DnKEk47AL5LD1rKD62XMPliLe7hSSo0HDRx8/ka7UdBw0PCkKIg9 0okTrQrr/ADbx++Y71fsXVJ/yvfW7kCrmkg/L17QijeLIRFCB61dWeUSUb4G9UXkY2PUOGN 6++vBw/hTG/DeXLUHuQ4Cjzb29DD8uHq7/2sZMIBKAl+zyGXs2bGBb8/Ykww== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1760943535; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=G8ySUN6oIiTkMgdwtzxFc6/FHWeIcGd1zluXHFdvVs0=; b=sLV/RQMyAt5R7Q0epuMNhIzQCJnZUImMbsL5n/+7ybZAGygJgiMm86RsDIA/fJhv+vWiH UC++7ircxbnLWKNwPRPqCByiX+Is8zycrG7Ug+BypX3jSeyL4A9LK/WQyO2IdAhOT2P5tUS NvaF+HnNpkpcDkGgpIfrIcS0UKc7IakTxlgH7v61iQyTpDALSacPZz4Eq7E9Trf/qdHjkBb YrvFcBrRvLyZ+BUIrF3/46SvVsprL6qSXFOcR6ihnian9AdtmZrP0ndrnACPzr09g6wlWzt fLcUebbNEUqQOgoAUCgUBTKbpjVWYJZVLUiIMdmoHm7HybexfB6ynqLyE5jg== Received: from 547bf0a948a1 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 5291768F2F2 for ; Mon, 20 Oct 2025 09:58:55 +0300 (EEST) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Mon, 20 Oct 2025 06:58:54 -0000 Message-ID: <176094353550.62.18127321010934052245@bf907ddaa564> Message-ID-Hash: W2HN6UXKARO3M4M6ISHEXKHZ6VWLFC4T X-Message-ID-Hash: W2HN6UXKARO3M4M6ISHEXKHZ6VWLFC4T X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] avcodec/liblc3dec: support sample format negotiation and planar layout. (PR #20723) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: cenzhanquan1 via ffmpeg-devel Cc: cenzhanquan1 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #20723 opened by cenzhanquan1 URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20723 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20723.patch 1. Adds support for respecting the requested sample format. Previously, the decoder always used AV_SAMPLE_FMT_FLTP. Now it checks if the caller requested a specific format via avctx->request_sample_fmt and honors that request when supported. 2. Improves planar/interleaved audio buffer handling. The decoding logic now properly handles both planar and interleaved sample formats by calculating the correct stride and buffer pointers based on the actual sample format. The changes include: - Added format mapping between AVSampleFormat and lc3_pcm_format - Implemented format selection logic in initialization. - Updated buffer pointer calculation for planar/interleaved data. - Maintained backward compatibility with existing behavior. Signed-off-by: cenzhanquan1 >>From 34082d39cec5df8220ea81400240defe8da241bb Mon Sep 17 00:00:00 2001 From: cenzhanquan1 Date: Mon, 20 Oct 2025 14:52:24 +0800 Subject: [PATCH] avcodec/liblc3dec: support sample format negotiation and planar layout. 1. Adds support for respecting the requested sample format. Previously, the decoder always used AV_SAMPLE_FMT_FLTP. Now it checks if the caller requested a specific format via avctx->request_sample_fmt and honors that request when supported. 2. Improves planar/interleaved audio buffer handling. The decoding logic now properly handles both planar and interleaved sample formats by calculating the correct stride and buffer pointers based on the actual sample format. The changes include: - Added format mapping between AVSampleFormat and lc3_pcm_format - Implemented format selection logic in initialization. - Updated buffer pointer calculation for planar/interleaved data. - Maintained backward compatibility with existing behavior. Signed-off-by: cenzhanquan1 --- libavcodec/liblc3dec.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/libavcodec/liblc3dec.c b/libavcodec/liblc3dec.c index d250ace38a..023559d67d 100644 --- a/libavcodec/liblc3dec.c +++ b/libavcodec/liblc3dec.c @@ -43,6 +43,14 @@ static av_cold int liblc3_decode_init(AVCodecContext *avctx) int ep_mode; unsigned decoder_size; + static const struct { + enum AVSampleFormat av_format; + enum lc3_pcm_format lc3_format; + } format_map[] = { + { AV_SAMPLE_FMT_FLT, LC3_PCM_FORMAT_FLOAT }, + { AV_SAMPLE_FMT_FLTP, LC3_PCM_FORMAT_FLOAT }, + }; + if (avctx->extradata_size < 6) return AVERROR_INVALIDDATA; if (channels < 0 || channels > DECODER_MAX_CHANNELS) { @@ -83,6 +91,15 @@ static av_cold int liblc3_decode_init(AVCodecContext *avctx) } avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; + if (avctx->request_sample_fmt != AV_SAMPLE_FMT_NONE) { + for (int i = 0; i < FF_ARRAY_ELEMS(format_map); i++) { + if (format_map[i].av_format == avctx->request_sample_fmt) { + avctx->sample_fmt = avctx->request_sample_fmt; + break; + } + } + } + avctx->delay = lc3_hr_delay_samples( liblc3->hr_mode, liblc3->frame_us, liblc3->srate_hz); avctx->internal->skip_samples = avctx->delay; @@ -106,6 +123,8 @@ static int liblc3_decode(AVCodecContext *avctx, AVFrame *frame, int channels = avctx->ch_layout.nb_channels; uint8_t *in = avpkt->data; int block_bytes, ret; + size_t sample_size; + int is_planar; frame->nb_samples = av_rescale( liblc3->frame_us, liblc3->srate_hz, 1000*1000); @@ -113,11 +132,17 @@ static int liblc3_decode(AVCodecContext *avctx, AVFrame *frame, return ret; block_bytes = avpkt->size; + is_planar = av_sample_fmt_is_planar(avctx->sample_fmt); + sample_size = av_get_bytes_per_sample(avctx->sample_fmt); + for (int ch = 0; ch < channels; ch++) { int nbytes = block_bytes / channels + (ch < block_bytes % channels); + void *pcm_data = is_planar ? frame->extended_data[ch] : + (uint8_t *)frame->extended_data[0] + ch * sample_size; + int stride = is_planar ? 1 : channels; ret = lc3_decode(liblc3->decoder[ch], in, nbytes, - LC3_PCM_FORMAT_FLOAT, frame->data[ch], 1); + LC3_PCM_FORMAT_FLOAT, pcm_data, stride); if (ret < 0) return AVERROR_INVALIDDATA; -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org