Re: [FFmpeg-devel] [PATCH] avformat/mov_chan: respect channel order when parsing and creating chan atom

2024-03-23 Thread Marton Balint




On Mon, 18 Mar 2024, Marton Balint wrote:




On Mon, 18 Mar 2024, Andreas Rheinhardt wrote:


 Marton Balint:

 Previously we always assumed that the channels are in native order, even
 if
 they were not. The new channel layout API allows us to signal the proper
 channel order, so let's do so.

 Fixes ticket #98.
 ---
  libavformat/mov_chan.c | 464 +++--
  1 file changed, 211 insertions(+), 253 deletions(-)



[...]


 +#define TAG(_0)  (struct
 MovChannelLayoutMap){.tag = _0}
 +#define ID(_0)   (struct
 MovChannelLayoutMap){.id = c_##_0}


 Code like

 typedef struct Foo {
int a;
 } Foo;

 Foo bar[] = {
(Foo) {.a = 1},
 };

 is not valid C11 (or C17), because initializers for static objects are
 subject to severe restrictions; in particular, compound literals are not
 allowed. GCC and Clang ignore this except when using -pedantic, but MSVC
 does not: https://godbolt.org/z/hvnrh63za
 Just remove the "(MovChannelLayoutMap)".


Ok, will do, thanks.


Will apply.

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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avformat/mov_chan: respect channel order when parsing and creating chan atom

2024-03-17 Thread Marton Balint




On Mon, 18 Mar 2024, Andreas Rheinhardt wrote:


Marton Balint:

Previously we always assumed that the channels are in native order, even if
they were not. The new channel layout API allows us to signal the proper
channel order, so let's do so.

Fixes ticket #98.
---
 libavformat/mov_chan.c | 464 +++--
 1 file changed, 211 insertions(+), 253 deletions(-)

diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
index ead3a9b91b..d48cfeabb0 100644
--- a/libavformat/mov_chan.c
+++ b/libavformat/mov_chan.c
@@ -25,228 +25,163 @@

 #include 

+#include "libavutil/avassert.h"
 #include "libavutil/channel_layout.h"
 #include "libavcodec/codec_id.h"
 #include "mov_chan.h"

-struct MovChannelLayoutMap {
-uint32_t tag;
-uint64_t layout;
-};
-
-static const struct MovChannelLayoutMap mov_ch_layout_map_misc[] = {
-{ MOV_CH_LAYOUT_USE_DESCRIPTIONS,   0 },
-{ MOV_CH_LAYOUT_USE_BITMAP, 0 },
-{ MOV_CH_LAYOUT_DISCRETEINORDER,0 },
-{ MOV_CH_LAYOUT_UNKNOWN,0 },
-{ MOV_CH_LAYOUT_TMH_10_2_STD,   0 }, // L,   R,  C,Vhc, Lsd, Rsd,
- // Ls,  Rs, Vhl,  Vhr, Lw,  Rw,
- // Csd, Cs, LFE1, LFE2
-{ MOV_CH_LAYOUT_TMH_10_2_FULL,  0 }, // L,   R,  C,Vhc,  Lsd, Rsd,
- // Ls,  Rs, Vhl,  Vhr,  Lw,  Rw,
- // Csd, Cs, LFE1, LFE2, Lc,  Rc,
- // HI,  VI, Haptic
-{ 0, 0 },
-};
-
-static const struct MovChannelLayoutMap mov_ch_layout_map_1ch[] = {
-{ MOV_CH_LAYOUT_MONO,   AV_CH_LAYOUT_MONO }, // C
-{ 0, 0 },
-};
-
-static const struct MovChannelLayoutMap mov_ch_layout_map_2ch[] = {
-{ MOV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_STEREO }, // L, R
-{ MOV_CH_LAYOUT_STEREOHEADPHONES,   AV_CH_LAYOUT_STEREO }, // L, R
-{ MOV_CH_LAYOUT_BINAURAL,   AV_CH_LAYOUT_STEREO }, // L, R
-{ MOV_CH_LAYOUT_MIDSIDE,AV_CH_LAYOUT_STEREO }, // C, 
sides
-{ MOV_CH_LAYOUT_XY, AV_CH_LAYOUT_STEREO }, // X 
(left), Y (right)
-
-{ MOV_CH_LAYOUT_MATRIXSTEREO,   AV_CH_LAYOUT_STEREO_DOWNMIX }, // Lt, 
Rt
-
-{ MOV_CH_LAYOUT_AC3_1_0_1,  AV_CH_LAYOUT_MONO |// C, 
LFE
-AV_CH_LOW_FREQUENCY },
-{ 0, 0 },
-};
-
-static const struct MovChannelLayoutMap mov_ch_layout_map_3ch[] = {
-{ MOV_CH_LAYOUT_MPEG_3_0_A, AV_CH_LAYOUT_SURROUND }, // L, R, C
-{ MOV_CH_LAYOUT_MPEG_3_0_B, AV_CH_LAYOUT_SURROUND }, // C, L, R
-{ MOV_CH_LAYOUT_AC3_3_0,AV_CH_LAYOUT_SURROUND }, // L, C, R
-
-{ MOV_CH_LAYOUT_ITU_2_1,AV_CH_LAYOUT_2_1  }, // L, R, Cs
-
-{ MOV_CH_LAYOUT_DVD_4,  AV_CH_LAYOUT_2POINT1  }, // L, R, LFE
-{ 0, 0 },
-};
-
-static const struct MovChannelLayoutMap mov_ch_layout_map_4ch[] = {
-{ MOV_CH_LAYOUT_AMBISONIC_B_FORMAT, 0 },// W, X, Y, Z
-
-{ MOV_CH_LAYOUT_QUADRAPHONIC,   AV_CH_LAYOUT_QUAD}, // L, R, Rls, 
Rrs
-
-{ MOV_CH_LAYOUT_MPEG_4_0_A, AV_CH_LAYOUT_4POINT0 }, // L, R, C, Cs
-{ MOV_CH_LAYOUT_MPEG_4_0_B, AV_CH_LAYOUT_4POINT0 }, // C, L, R, Cs
-{ MOV_CH_LAYOUT_AC3_3_1,AV_CH_LAYOUT_4POINT0 }, // L, C, R, Cs
-
-{ MOV_CH_LAYOUT_ITU_2_2,AV_CH_LAYOUT_2_2 }, // L, R, Ls, Rs
-
-{ MOV_CH_LAYOUT_DVD_5,  AV_CH_LAYOUT_2_1 |  // L, R, LFE, 
Cs
-AV_CH_LOW_FREQUENCY  },
-{ MOV_CH_LAYOUT_AC3_2_1_1,  AV_CH_LAYOUT_2_1 |  // L, R, Cs, 
LFE
-AV_CH_LOW_FREQUENCY  },
-
-{ MOV_CH_LAYOUT_DVD_10, AV_CH_LAYOUT_3POINT1 }, // L, R, C, LFE
-{ MOV_CH_LAYOUT_AC3_3_0_1,  AV_CH_LAYOUT_3POINT1 }, // L, C, R, LFE
-{ MOV_CH_LAYOUT_DTS_3_1,AV_CH_LAYOUT_3POINT1 }, // C, L, R, LFE
-{ 0, 0 },
-};
-
-static const struct MovChannelLayoutMap mov_ch_layout_map_5ch[] = {
-{ MOV_CH_LAYOUT_PENTAGONAL, AV_CH_LAYOUT_5POINT0_BACK }, // L, R, 
Rls, Rrs, C
-
-{ MOV_CH_LAYOUT_MPEG_5_0_A, AV_CH_LAYOUT_5POINT0 },  // L, R, 
C,  Ls, Rs
-{ MOV_CH_LAYOUT_MPEG_5_0_B, AV_CH_LAYOUT_5POINT0 },  // L, R, 
Ls, Rs, C
-{ MOV_CH_LAYOUT_MPEG_5_0_C, AV_CH_LAYOUT_5POINT0 },  // L, C, 
R,  Ls, Rs
-{ MOV_CH_LAYOUT_MPEG_5_0_D, AV_CH_LAYOUT_5POINT0 },  // C, L, 
R,  Ls, Rs
-
-{ MOV_CH_LAYOUT_DVD_6,  AV_CH_LAYOUT_2_2 |   // L, R, 
LFE, Ls, Rs
-AV_CH_LOW_FREQUENCY },
-{ MOV_CH_LAYOUT_DVD_18, AV_CH_LAYOUT_2_2 |   // L, R, 
Ls, Rs, LFE
-AV_CH_LOW_FREQUENCY },
-
-{ MOV_CH_LAYOUT_DVD_11, 

Re: [FFmpeg-devel] [PATCH] avformat/mov_chan: respect channel order when parsing and creating chan atom

2024-03-17 Thread Andreas Rheinhardt
Marton Balint:
> Previously we always assumed that the channels are in native order, even if
> they were not. The new channel layout API allows us to signal the proper
> channel order, so let's do so.
> 
> Fixes ticket #98.
> ---
>  libavformat/mov_chan.c | 464 +++--
>  1 file changed, 211 insertions(+), 253 deletions(-)
> 
> diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
> index ead3a9b91b..d48cfeabb0 100644
> --- a/libavformat/mov_chan.c
> +++ b/libavformat/mov_chan.c
> @@ -25,228 +25,163 @@
>  
>  #include 
>  
> +#include "libavutil/avassert.h"
>  #include "libavutil/channel_layout.h"
>  #include "libavcodec/codec_id.h"
>  #include "mov_chan.h"
>  
> -struct MovChannelLayoutMap {
> -uint32_t tag;
> -uint64_t layout;
> -};
> -
> -static const struct MovChannelLayoutMap mov_ch_layout_map_misc[] = {
> -{ MOV_CH_LAYOUT_USE_DESCRIPTIONS,   0 },
> -{ MOV_CH_LAYOUT_USE_BITMAP, 0 },
> -{ MOV_CH_LAYOUT_DISCRETEINORDER,0 },
> -{ MOV_CH_LAYOUT_UNKNOWN,0 },
> -{ MOV_CH_LAYOUT_TMH_10_2_STD,   0 }, // L,   R,  C,Vhc, Lsd, Rsd,
> - // Ls,  Rs, Vhl,  Vhr, Lw,  Rw,
> - // Csd, Cs, LFE1, LFE2
> -{ MOV_CH_LAYOUT_TMH_10_2_FULL,  0 }, // L,   R,  C,Vhc,  Lsd, 
> Rsd,
> - // Ls,  Rs, Vhl,  Vhr,  Lw,  Rw,
> - // Csd, Cs, LFE1, LFE2, Lc,  Rc,
> - // HI,  VI, Haptic
> -{ 0, 0 },
> -};
> -
> -static const struct MovChannelLayoutMap mov_ch_layout_map_1ch[] = {
> -{ MOV_CH_LAYOUT_MONO,   AV_CH_LAYOUT_MONO }, // C
> -{ 0, 0 },
> -};
> -
> -static const struct MovChannelLayoutMap mov_ch_layout_map_2ch[] = {
> -{ MOV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_STEREO }, // L, 
> R
> -{ MOV_CH_LAYOUT_STEREOHEADPHONES,   AV_CH_LAYOUT_STEREO }, // L, 
> R
> -{ MOV_CH_LAYOUT_BINAURAL,   AV_CH_LAYOUT_STEREO }, // L, 
> R
> -{ MOV_CH_LAYOUT_MIDSIDE,AV_CH_LAYOUT_STEREO }, // C, 
> sides
> -{ MOV_CH_LAYOUT_XY, AV_CH_LAYOUT_STEREO }, // X 
> (left), Y (right)
> -
> -{ MOV_CH_LAYOUT_MATRIXSTEREO,   AV_CH_LAYOUT_STEREO_DOWNMIX }, // 
> Lt, Rt
> -
> -{ MOV_CH_LAYOUT_AC3_1_0_1,  AV_CH_LAYOUT_MONO |// C, 
> LFE
> -AV_CH_LOW_FREQUENCY },
> -{ 0, 0 },
> -};
> -
> -static const struct MovChannelLayoutMap mov_ch_layout_map_3ch[] = {
> -{ MOV_CH_LAYOUT_MPEG_3_0_A, AV_CH_LAYOUT_SURROUND }, // L, R, C
> -{ MOV_CH_LAYOUT_MPEG_3_0_B, AV_CH_LAYOUT_SURROUND }, // C, L, R
> -{ MOV_CH_LAYOUT_AC3_3_0,AV_CH_LAYOUT_SURROUND }, // L, C, R
> -
> -{ MOV_CH_LAYOUT_ITU_2_1,AV_CH_LAYOUT_2_1  }, // L, R, Cs
> -
> -{ MOV_CH_LAYOUT_DVD_4,  AV_CH_LAYOUT_2POINT1  }, // L, R, LFE
> -{ 0, 0 },
> -};
> -
> -static const struct MovChannelLayoutMap mov_ch_layout_map_4ch[] = {
> -{ MOV_CH_LAYOUT_AMBISONIC_B_FORMAT, 0 },// W, X, Y, Z
> -
> -{ MOV_CH_LAYOUT_QUADRAPHONIC,   AV_CH_LAYOUT_QUAD}, // L, R, 
> Rls, Rrs
> -
> -{ MOV_CH_LAYOUT_MPEG_4_0_A, AV_CH_LAYOUT_4POINT0 }, // L, R, C, 
> Cs
> -{ MOV_CH_LAYOUT_MPEG_4_0_B, AV_CH_LAYOUT_4POINT0 }, // C, L, R, 
> Cs
> -{ MOV_CH_LAYOUT_AC3_3_1,AV_CH_LAYOUT_4POINT0 }, // L, C, R, 
> Cs
> -
> -{ MOV_CH_LAYOUT_ITU_2_2,AV_CH_LAYOUT_2_2 }, // L, R, Ls, 
> Rs
> -
> -{ MOV_CH_LAYOUT_DVD_5,  AV_CH_LAYOUT_2_1 |  // L, R, 
> LFE, Cs
> -AV_CH_LOW_FREQUENCY  },
> -{ MOV_CH_LAYOUT_AC3_2_1_1,  AV_CH_LAYOUT_2_1 |  // L, R, Cs, 
> LFE
> -AV_CH_LOW_FREQUENCY  },
> -
> -{ MOV_CH_LAYOUT_DVD_10, AV_CH_LAYOUT_3POINT1 }, // L, R, C, 
> LFE
> -{ MOV_CH_LAYOUT_AC3_3_0_1,  AV_CH_LAYOUT_3POINT1 }, // L, C, R, 
> LFE
> -{ MOV_CH_LAYOUT_DTS_3_1,AV_CH_LAYOUT_3POINT1 }, // C, L, R, 
> LFE
> -{ 0, 0 },
> -};
> -
> -static const struct MovChannelLayoutMap mov_ch_layout_map_5ch[] = {
> -{ MOV_CH_LAYOUT_PENTAGONAL, AV_CH_LAYOUT_5POINT0_BACK }, // L, 
> R, Rls, Rrs, C
> -
> -{ MOV_CH_LAYOUT_MPEG_5_0_A, AV_CH_LAYOUT_5POINT0 },  // L, 
> R, C,  Ls, Rs
> -{ MOV_CH_LAYOUT_MPEG_5_0_B, AV_CH_LAYOUT_5POINT0 },  // L, 
> R, Ls, Rs, C
> -{ MOV_CH_LAYOUT_MPEG_5_0_C, AV_CH_LAYOUT_5POINT0 },  // L, 
> C, R,  Ls, Rs
> -{ MOV_CH_LAYOUT_MPEG_5_0_D, AV_CH_LAYOUT_5POINT0 },  // C, 
> L, R,  Ls, Rs
> -
> -{ MOV_CH_LAYOUT_DVD_6,  AV_CH_LAYOUT_2_2 |   // L, 
> R, LFE, Ls, Rs
> -