[FFmpeg-cvslog] avutil/channel_layout: don't clear the opaque pointer on type conversion

James Almer git at videolan.org
Mon Mar 25 14:45:19 EET 2024


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Fri Mar 22 13:00:46 2024 -0300| [65a04cae6ff89e8543e83e83533760b9c1b57b68] | committer: James Almer

avutil/channel_layout: don't clear the opaque pointer on type conversion

Otherwise it would not be lossless.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=65a04cae6ff89e8543e83e83533760b9c1b57b68
---

 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;
             }
         }



More information about the ffmpeg-cvslog mailing list