diff mbox

[FFmpeg-devel] lavfi/buffersrc: fix directly setting channel layout

Message ID 20170221065843.56781-1-atomnuker@gmail.com
State Accepted
Headers show

Commit Message

Rostislav Pehlivanov Feb. 21, 2017, 6:58 a.m. UTC
When setting the channel layout directly using AVBufferSrcParameters
the channel layout was correctly set however the init function still
expected the old string format to set the number of channels (when it
hadn't already been specified).

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
---
 libavfilter/buffersrc.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

Paul B Mahol Feb. 21, 2017, 9:08 a.m. UTC | #1
On 2/21/17, Rostislav Pehlivanov <atomnuker@gmail.com> wrote:
> When setting the channel layout directly using AVBufferSrcParameters
> the channel layout was correctly set however the init function still
> expected the old string format to set the number of channels (when it
> hadn't already been specified).
>
> Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
> ---
>  libavfilter/buffersrc.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
> index 77fd174219..37d1992b50 100644
> --- a/libavfilter/buffersrc.c
> +++ b/libavfilter/buffersrc.c
> @@ -341,14 +341,16 @@ static av_cold int init_audio(AVFilterContext *ctx)
>          return AVERROR(EINVAL);
>      }
>
> -    if (s->channel_layout_str) {
> +    if (s->channel_layout_str || s->channel_layout) {
>          int n;
>
> -        s->channel_layout = av_get_channel_layout(s->channel_layout_str);
> -        if (!s->channel_layout) {
> -            av_log(ctx, AV_LOG_ERROR, "Invalid channel layout %s.\n",
> -                   s->channel_layout_str);
> -            return AVERROR(EINVAL);
> +        if (s->channel_layout_str) {
> +            s->channel_layout =
> av_get_channel_layout(s->channel_layout_str);
> +            if (!s->channel_layout) {
> +                av_log(ctx, AV_LOG_ERROR, "Invalid channel layout %s.\n",
> +                       s->channel_layout_str);
> +                return AVERROR(EINVAL);
> +            }
>          }
>          n = av_get_channel_layout_nb_channels(s->channel_layout);
>          if (s->channels) {
> --
> 2.12.0.rc1.440.g5b76565f74
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

lgtm
wm4 Feb. 21, 2017, 9:36 a.m. UTC | #2
On Tue, 21 Feb 2017 10:08:45 +0100
Paul B Mahol <onemda@gmail.com> wrote:

> On 2/21/17, Rostislav Pehlivanov <atomnuker@gmail.com> wrote:
> > When setting the channel layout directly using AVBufferSrcParameters
> > the channel layout was correctly set however the init function still
> > expected the old string format to set the number of channels (when it
> > hadn't already been specified).
> >
> > Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
> > ---
> >  libavfilter/buffersrc.c | 14 ++++++++------
> >  1 file changed, 8 insertions(+), 6 deletions(-)
> >
> > diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
> > index 77fd174219..37d1992b50 100644
> > --- a/libavfilter/buffersrc.c
> > +++ b/libavfilter/buffersrc.c
> > @@ -341,14 +341,16 @@ static av_cold int init_audio(AVFilterContext *ctx)
> >          return AVERROR(EINVAL);
> >      }
> >
> > -    if (s->channel_layout_str) {
> > +    if (s->channel_layout_str || s->channel_layout) {
> >          int n;
> >
> > -        s->channel_layout = av_get_channel_layout(s->channel_layout_str);
> > -        if (!s->channel_layout) {
> > -            av_log(ctx, AV_LOG_ERROR, "Invalid channel layout %s.\n",
> > -                   s->channel_layout_str);
> > -            return AVERROR(EINVAL);
> > +        if (s->channel_layout_str) {
> > +            s->channel_layout =
> > av_get_channel_layout(s->channel_layout_str);
> > +            if (!s->channel_layout) {
> > +                av_log(ctx, AV_LOG_ERROR, "Invalid channel layout %s.\n",
> > +                       s->channel_layout_str);
> > +                return AVERROR(EINVAL);
> > +            }
> >          }
> >          n = av_get_channel_layout_nb_channels(s->channel_layout);
> >          if (s->channels) {
> > --
> > 2.12.0.rc1.440.g5b76565f74
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >  
> 
> lgtm

Should probably go into stable as well.
diff mbox

Patch

diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index 77fd174219..37d1992b50 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -341,14 +341,16 @@  static av_cold int init_audio(AVFilterContext *ctx)
         return AVERROR(EINVAL);
     }
 
-    if (s->channel_layout_str) {
+    if (s->channel_layout_str || s->channel_layout) {
         int n;
 
-        s->channel_layout = av_get_channel_layout(s->channel_layout_str);
-        if (!s->channel_layout) {
-            av_log(ctx, AV_LOG_ERROR, "Invalid channel layout %s.\n",
-                   s->channel_layout_str);
-            return AVERROR(EINVAL);
+        if (s->channel_layout_str) {
+            s->channel_layout = av_get_channel_layout(s->channel_layout_str);
+            if (!s->channel_layout) {
+                av_log(ctx, AV_LOG_ERROR, "Invalid channel layout %s.\n",
+                       s->channel_layout_str);
+                return AVERROR(EINVAL);
+            }
         }
         n = av_get_channel_layout_nb_channels(s->channel_layout);
         if (s->channels) {