[FFmpeg-devel] [PATCH 1/3] audioconvert: include the long name of channels in the library.

Stefano Sabatini stefasab at gmail.com
Mon Jul 30 00:48:28 CEST 2012


On date Monday 2012-07-30 00:40:07 +0200, Nicolas George encoded:
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  libavutil/audioconvert.c |   63 +++++++++++++++++++++++++---------------------
>  1 file changed, 34 insertions(+), 29 deletions(-)
> 
> diff --git a/libavutil/audioconvert.c b/libavutil/audioconvert.c
> index e17f52e..7010144 100644
> --- a/libavutil/audioconvert.c
> +++ b/libavutil/audioconvert.c
> @@ -28,38 +28,43 @@
>  #include "audioconvert.h"
>  #include "bprint.h"
>  
> -static const char * const channel_names[] = {
> -    [0]  = "FL",        /* front left */
> -    [1]  = "FR",        /* front right */
> -    [2]  = "FC",        /* front center */
> -    [3]  = "LFE",       /* low frequency */
> -    [4]  = "BL",        /* back left */
> -    [5]  = "BR",        /* back right */
> -    [6]  = "FLC",       /* front left-of-center  */
> -    [7]  = "FRC",       /* front right-of-center */
> -    [8]  = "BC",        /* back-center */
> -    [9]  = "SL",        /* side left */
> -    [10] = "SR",        /* side right */
> -    [11] = "TC",        /* top center */
> -    [12] = "TFL",       /* top front left */
> -    [13] = "TFC",       /* top front center */
> -    [14] = "TFR",       /* top front right */
> -    [15] = "TBL",       /* top back left */
> -    [16] = "TBC",       /* top back center */
> -    [17] = "TBR",       /* top back right */
> -    [29] = "DL",        /* downmix left */
> -    [30] = "DR",        /* downmix right */
> -    [31] = "WL",        /* wide left */
> -    [32] = "WR",        /* wide right */
> -    [33] = "SDL",       /* surround direct left */
> -    [34] = "SDR",       /* surround direct right */
> +struct channel_name {
> +    const char *short_name;
> +    const char *long_name;
> +};
> +
> +static const struct channel_name channel_names[] = {
> +     [0] = { "FL",        "front left"            },
> +     [1] = { "FR",        "front right"           },
> +     [2] = { "FC",        "front center"          },
> +     [3] = { "LFE",       "low frequency"         },
> +     [4] = { "BL",        "back left"             },
> +     [5] = { "BR",        "back right"            },
> +     [6] = { "FLC",       "front left-of-center"  },
> +     [7] = { "FRC",       "front right-of-center" },
> +     [8] = { "BC",        "back center"           },
> +     [9] = { "SL",        "side left"             },
> +    [10] = { "SR",        "side right"            },
> +    [11] = { "TC",        "top center"            },
> +    [12] = { "TFL",       "top front left"        },
> +    [13] = { "TFC",       "top front center"      },
> +    [14] = { "TFR",       "top front right"       },
> +    [15] = { "TBL",       "top back left"         },
> +    [16] = { "TBC",       "top back center"       },
> +    [17] = { "TBR",       "top back right"        },
> +    [29] = { "DL",        "downmix left"          },
> +    [30] = { "DR",        "downmix right"         },
> +    [31] = { "WL",        "wide left"             },
> +    [32] = { "WR",        "wide right"            },
> +    [33] = { "SDL",       "surround direct left"  },
> +    [34] = { "SDR",       "surround direct right" },
>  };
>  
>  static const char *get_channel_name(int channel_id)
>  {
>      if (channel_id < 0 || channel_id >= FF_ARRAY_ELEMS(channel_names))
>          return NULL;
> -    return channel_names[channel_id];
> +    return channel_names[channel_id].short_name;
>  }
>  
>  static const struct {
> @@ -107,9 +112,9 @@ static uint64_t get_channel_layout_single(const char *name, int name_len)
>              return channel_layout_map[i].layout;
>      }
>      for (i = 0; i < FF_ARRAY_ELEMS(channel_names); i++)
> -        if (channel_names[i] &&
> -            strlen(channel_names[i]) == name_len &&
> -            !memcmp(channel_names[i], name, name_len))
> +        if (channel_names[i].short_name &&
> +            strlen(channel_names[i].short_name) == name_len &&
> +            !memcmp(channel_names[i].short_name, name, name_len))
>              return (int64_t)1 << i;
>      i = strtol(name, &end, 10);
>      if (end - name == name_len ||

LGTM, thanks.
-- 
FFmpeg = Fostering and Fundamental Magic Peaceless Elaborated Gymnast


More information about the ffmpeg-devel mailing list