Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH] avutil/channel_layout: don't clear the opaque pointer on type conversion
Date: Fri, 22 Mar 2024 13:01:27 -0300
Message-ID: <20240322160127.1635-1-jamrial@gmail.com> (raw)

Otherwise it would not be lossless.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavutil/channel_layout.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index a83618bcc7..3054ee08a5 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -902,9 +902,11 @@ int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrde
             lossy = 1;
         }
         if (!lossy || allow_lossy) {
+            void *opaque = channel_layout->opaque;
             av_channel_layout_uninit(channel_layout);
             channel_layout->order       = AV_CHANNEL_ORDER_UNSPEC;
             channel_layout->nb_channels = nb_channels;
+            channel_layout->opaque      = opaque;
             return lossy;
         }
         return AVERROR(ENOSYS);
@@ -916,8 +918,10 @@ int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrde
                 return AVERROR(ENOSYS);
             lossy = has_channel_names(channel_layout);
             if (!lossy || allow_lossy) {
+                void *opaque = channel_layout->opaque;
                 av_channel_layout_uninit(channel_layout);
                 av_channel_layout_from_mask(channel_layout, mask);
+                channel_layout->opaque = opaque;
                 return lossy;
             }
         }
@@ -925,6 +929,7 @@ int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrde
     case AV_CHANNEL_ORDER_CUSTOM: {
         AVChannelLayout custom = { 0 };
         int ret = av_channel_layout_custom_init(&custom, channel_layout->nb_channels);
+        void *opaque = channel_layout->opaque;
         if (ret < 0)
             return ret;
         if (channel_layout->order != AV_CHANNEL_ORDER_UNSPEC)
@@ -932,6 +937,7 @@ int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrde
                 custom.u.map[i].id = av_channel_layout_channel_from_index(channel_layout, i);
         av_channel_layout_uninit(channel_layout);
         *channel_layout = custom;
+        channel_layout->opaque = opaque;
         return 0;
         }
     case AV_CHANNEL_ORDER_AMBISONIC:
@@ -946,10 +952,12 @@ int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrde
                 return AVERROR(ENOSYS);
             lossy = has_channel_names(channel_layout);
             if (!lossy || allow_lossy) {
+                void *opaque = channel_layout->opaque;
                 av_channel_layout_uninit(channel_layout);
                 channel_layout->order       = AV_CHANNEL_ORDER_AMBISONIC;
                 channel_layout->nb_channels = nb_channels;
                 channel_layout->u.mask      = mask;
+                channel_layout->opaque      = opaque;
                 return lossy;
             }
         }
-- 
2.44.0

_______________________________________________
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".

             reply	other threads:[~2024-03-22 16:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22 16:01 James Almer [this message]
2024-03-25 12:37 ` James Almer

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=20240322160127.1635-1-jamrial@gmail.com \
    --to=jamrial@gmail.com \
    --cc=ffmpeg-devel@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