[Libav-user] Using av_channel_layout_copy() function in Win, Linux, Mac (c++)

Denis Gottardello info at denisgottardello.it
Wed Aug 30 17:50:35 EEST 2023


Perfect. Best regards.

In data mercoledì 30 agosto 2023 16:14:03 CEST, John Regan via Libav-user ha scritto:
> On Wed, 30 Aug 2023 15:39:08 +0200
> 
> Denis Gottardello <info at denisgottardello.it> wrote:
> > Hi. When I try to compile the following line of code
> > 
> > av_channel_layout_copy(&c->ch_layout,
> > &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO);
> > 
> > taken from mux.c example I obtain the error:
> > 
> > /home/denis/Cpp/ffmpeg-6.0/libavutil/channel_layout.h:362: *error:
> > taking address of rvalue [-fpermissive]*
> > ../../ffmpeg-6.0/libavutil/channel_layout.h:362:5: error: taking
> > address of rvalue [-fpermissive] 362 |     { .order =
> > AV_CHANNEL_ORDER_NATIVE, .nb_channels = (nb), .u = { .mask = (m) }} |
> > 
> >     
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >     ~~~~~~~~> 
> > ../../ffmpeg-6.0/libavutil/channel_layout.h:369:45: note: in
> > expansion of macro ‘AV_CHANNEL_LAYOUT_MASK’ 369 | #define
> > AV_CHANNEL_LAYOUT_STEREO            AV_CHANNEL_LAYOUT_MASK(2,
> > AV_CH_LAYOUT_STEREO) |
> > ^~~~~~~~~~~~~~~~~~~~~~ ../ffmpegTest/main.cpp:157:65: note: in
> > expansion of macro ‘AV_CHANNEL_LAYOUT_STEREO’ 157 |
> > av_channel_layout_copy(&c->ch_layout,
> > &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO); |
> > 
> >                                          ^~~~~~~~~~~~~~~~~~~~~~~~
> > 
> > How can I translate it to work in Windows, Linux and Mac?
> > Something like this?
> > 
> >         AVChannelLayout a= AV_CHANNEL_LAYOUT_STEREO;
> >         av_channel_layout_copy(&c->ch_layout, &a);
> 
> If you're assigning one of the standard layouts you should be able to
> just do
> 
>     c->ch_layout = AV_CHANNEL_LAYOUT_STEREO;
> 
> At least, assuming that the AVCodecContext has just been allocated
> (like it is in mux.c). If you had an existing channel layout set, you'd
> want to do a copy since that will free any custom channel layout data
> for you.
> 
> From your output it looks like you're compiling as C++, and some of the
> code in mux.c is valid C code, but not valid C++ code (such as taking
> the address of an rvalue).
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
> 
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".
-- 
+39.347.4070897
http://www.labcsp.com[1] 
http://www.denisgottardello.it[2] 
GMT+1
Skype: mrdebug

--------
[1] http://www.labcsp.com
[2] http://www.denisgottardello.it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20230830/d1e6f573/attachment.htm>


More information about the Libav-user mailing list