From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 05630490A6 for ; Thu, 1 Feb 2024 20:36:43 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8B31168D08E; Thu, 1 Feb 2024 22:36:40 +0200 (EET) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5903068C9F8 for ; Thu, 1 Feb 2024 22:36:34 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id CBE21E9D49 for ; Thu, 1 Feb 2024 21:36:33 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZwJMNS2Y5_tm for ; Thu, 1 Feb 2024 21:36:31 +0100 (CET) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id 5671FE95FB for ; Thu, 1 Feb 2024 21:36:31 +0100 (CET) Date: Thu, 1 Feb 2024 21:36:31 +0100 (CET) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <170677812437.8914.7666506536395922524@lain.khirnov.net> Message-ID: <46247782-1fde-d0e3-23b8-2b3180b1d780@passwd.hu> References: <20240129232755.9622-4-cus@passwd.hu> <20240131230136.30924-1-cus@passwd.hu> <170677812437.8914.7666506536395922524@lain.khirnov.net> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v2 4/5] avutil/channel_layout: add av_channel_layout_retype() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Thu, 1 Feb 2024, Anton Khirnov wrote: > Quoting Marton Balint (2024-02-01 00:01:36) >> diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h >> index 37629ab5d2..7e27a00d39 100644 >> --- a/libavutil/channel_layout.h >> +++ b/libavutil/channel_layout.h >> @@ -817,6 +817,17 @@ int av_channel_layout_check(const AVChannelLayout *channel_layout); >> */ >> int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1); >> >> +/** >> + * Try changing the AVChannelOrder of a channel layout. > > What exactly is the rule for when the change succeeds or not? I would > expect it to be when all the channels can be represented in the new > order, but that is not the case for conversion to unspec. Yes, you are right. Converting to unspec indeed makes you lose the channel designations, so the conversion will not be lossless. On the other hand, when you specify UNSPEC as a target, you don't actually expect to keep the designations, so what is the point of returning an error... I think this is one of those cases when both behaviour (always doing the conversion, or returning a failure in case the source order is not already unspec) can make sense. We have to decide though if a custom layout with all channels as UNKNOWN can be losslessly converted to UNSPEC layout or not. And if yes, then would not that conflict with av_channel_layout_channel_from_index() which returns AV_CHAN_NONE and not AV_CHAN_UNKNOWN for UNSPEC layouts... So if you have a preference, I can change this (and document it), I don't particularly feel strongly about any of the two approaches. Probably there is no bad choce as long as it is properly documented. > >> + * >> + * @param channel_layout channel layout which will be changed >> + * @param order the desired channel layout order >> + * @return 0 on success or if the channel layout is already in the desired order >> + * 1 if using the desired order is not possible for the specified layout > > AVERROR(ENOSYS) seems more consistent to me By using a positive result all negative return values can be considered serious errors which have to be propagated back to the user. In the next patch I try to simplify a custom channel layout: + ret = av_channel_layout_retype(ch_layout, AV_CHANNEL_ORDER_NATIVE); + if (ret < 0) + goto out; I can do simply this, because I don't care if the simplification was successful. Regards, Marton _______________________________________________ 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".