[FFmpeg-devel] [PATCH] ffmpeg: add -map_channel option.

Michael Niedermayer michaelni at gmx.at
Wed Oct 19 23:42:15 CEST 2011


[...]
> diff --git a/libswresample/audioconvert.h b/libswresample/audioconvert.h
> index e5fd4df..ca98d54 100644
> --- a/libswresample/audioconvert.h
> +++ b/libswresample/audioconvert.h
> @@ -42,11 +42,14 @@ typedef struct AVAudioConvert AVAudioConvert;
>   * @param in_fmt Input sample format
>   * @param channels Number of channels
>   * @param flags See AV_CPU_FLAG_xx
> + * @param ch_map list of the channels id to pick from the source stream, NULL
> + *               if all channels must be selected
>   * @return NULL on error
>   */
>  AVAudioConvert *swr_audio_convert_alloc(enum AVSampleFormat out_fmt,
>                                          enum AVSampleFormat in_fmt,
> -                                        int channels, int flags);
> +                                        int channels, const int *ch_map,
> +                                        int flags);
>  
>  /**
>   * Free audio sample format converter context.
> diff --git a/libswresample/swresample.c b/libswresample/swresample.c
> index bb5b523..67b9831 100644
> --- a/libswresample/swresample.c
> +++ b/libswresample/swresample.c
> @@ -75,7 +75,7 @@ SwrContext *swr_alloc(void){
>  
>  SwrContext *swr_alloc2(struct SwrContext *s, int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate,
>                         int64_t  in_ch_layout, enum AVSampleFormat  in_sample_fmt, int  in_sample_rate,
> -                       int log_offset, void *log_ctx){
> +                       const int *channel_map, int log_offset, void *log_ctx){
>      if(!s) s= swr_alloc();
>      if(!s) return NULL;
>  
> @@ -89,6 +89,7 @@ SwrContext *swr_alloc2(struct SwrContext *s, int64_t out_ch_layout, enum AVSampl
>      av_set_int(s, "isf", in_sample_fmt);
>      av_set_int(s, "isr", in_sample_rate);
>  
> +    s->channel_map = channel_map;
>      s-> in.ch_count= av_get_channel_layout_nb_channels(s-> in_ch_layout);
>      s->out.ch_count= av_get_channel_layout_nb_channels(s->out_ch_layout);
>      s->int_sample_fmt = AV_SAMPLE_FMT_S16;

> @@ -176,7 +177,7 @@ int swr_init(SwrContext *s){
>      if(!s->out_ch_layout)
>          s->out_ch_layout= av_get_default_channel_layout(s->out.ch_count);
>  
> -    s->rematrix= s->out_ch_layout  !=s->in_ch_layout;
> +    s->rematrix= s->out_ch_layout != s->in_ch_layout && s->channel_map < 0;

pointer < 0 ?

also shouldnt rematrix be independant of the existence of a channel_map

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111019/2fcd8fad/attachment.asc>


More information about the ffmpeg-devel mailing list