Message ID | 20170721132211.GT3740@nb4 |
---|---|
State | New |
Headers | show |
2017-07-21 15:22 GMT+02:00 Michael Niedermayer <michael@niedermayer.cc>: > On Thu, Jul 20, 2017 at 09:54:05PM +0100, Mark Thompson wrote: > PS: heres the patch without whitespace changes (much more readable) Please use this variant and push a cosmetic change. > commit a0f2f597f0922a37486732a961c94af0507af234 > Author: Mark Thompson <sw@jkqxz.net> > Date: Thu Jul 20 21:54:05 2017 +0100 > > pixdesc: Explicitly handle invalid arguments to av_find_best_pix_fmt_of_2() > > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> > > diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c > index 1983ce9ef5..a9dd11a498 100644 > --- a/libavutil/pixdesc.c > +++ b/libavutil/pixdesc.c > @@ -2633,6 +2633,11 @@ enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, en > const AVPixFmtDescriptor *desc2 = av_pix_fmt_desc_get(dst_pix_fmt2); > int score1, score2; > > + if (!desc1) > + dst_pix_fmt = dst_pix_fmt2; > + else if (!desc2) > + dst_pix_fmt = dst_pix_fmt1; > + else { and please keep the style (and ease debugging) by adding braces. Carl Eugen
On 21/07/17 14:29, Carl Eugen Hoyos wrote: > 2017-07-21 15:22 GMT+02:00 Michael Niedermayer <michael@niedermayer.cc>: >> On Thu, Jul 20, 2017 at 09:54:05PM +0100, Mark Thompson wrote: > >> PS: heres the patch without whitespace changes (much more readable) > > Please use this variant and push a cosmetic change. > >> commit a0f2f597f0922a37486732a961c94af0507af234 >> Author: Mark Thompson <sw@jkqxz.net> >> Date: Thu Jul 20 21:54:05 2017 +0100 >> >> pixdesc: Explicitly handle invalid arguments to av_find_best_pix_fmt_of_2() >> >> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> >> >> diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c >> index 1983ce9ef5..a9dd11a498 100644 >> --- a/libavutil/pixdesc.c >> +++ b/libavutil/pixdesc.c >> @@ -2633,6 +2633,11 @@ enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, en >> const AVPixFmtDescriptor *desc2 = av_pix_fmt_desc_get(dst_pix_fmt2); >> int score1, score2; >> >> + if (!desc1) >> + dst_pix_fmt = dst_pix_fmt2; >> + else if (!desc2) >> + dst_pix_fmt = dst_pix_fmt1; >> + else { > > and please keep the style (and ease debugging) by adding braces. Sure, changed. Patch split and applied. Thanks, - Mark
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 1983ce9ef5..a9dd11a498 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2633,6 +2633,11 @@ enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, en const AVPixFmtDescriptor *desc2 = av_pix_fmt_desc_get(dst_pix_fmt2); int score1, score2; + if (!desc1) + dst_pix_fmt = dst_pix_fmt2; + else if (!desc2) + dst_pix_fmt = dst_pix_fmt1; + else { loss_mask= loss_ptr?~*loss_ptr:~0; /* use loss mask if provided */ if(!has_alpha) loss_mask &= ~FF_LOSS_ALPHA; @@ -2649,6 +2654,7 @@ enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, en } else { dst_pix_fmt = score1 < score2 ? dst_pix_fmt2 : dst_pix_fmt1; } + } if (loss_ptr) *loss_ptr = av_get_pix_fmt_loss(dst_pix_fmt, src_pix_fmt, has_alpha)