Re: [libav-devel] [PATCH 5/7] ac3dec: simplify an expression.

2013-11-19 Thread Tim W.
On 19 Nov 2013, at 01:15, Diego Biurrun di...@biurrun.de wrote:

 On Mon, Nov 18, 2013 at 12:41:47PM +0100, Tim Walker wrote:
 --- a/libavcodec/ac3dec.c
 +++ b/libavcodec/ac3dec.c
 @@ -178,9 +178,8 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
 
 /* allow downmixing to stereo or mono */
 -if (avctx-channels  0  avctx-request_channels  0 
 -avctx-request_channels  avctx-channels 
 -avctx-request_channels = 2) {
 +if (avctx-request_channels  0  avctx-request_channels = 2 
 +avctx-request_channels  avctx-channels) {
 avctx-channels = avctx-request_channels;
 
 what ensures that avctx-channels is non-negative?  (Yes, I wonder why
 that struct member is signed in the first place.)
 
 Diego

(avctx-request_channels  0  avctx-request_channels  avctx-channels) 
implies (avctx-channels  0) or false (so the result is unchanged).

Would:

 if (avctx-request_channels  0  avctx-request_channels = 2 
 avctx-channels  avctx-request_channels) {


Be clearer?

Tim
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 5/7] ac3dec: simplify an expression.

2013-11-18 Thread Tim Walker
---
 libavcodec/ac3dec.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 3edb3af..6419208 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -178,9 +178,8 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
 avctx-sample_fmt = AV_SAMPLE_FMT_FLTP;
 
 /* allow downmixing to stereo or mono */
-if (avctx-channels  0  avctx-request_channels  0 
-avctx-request_channels  avctx-channels 
-avctx-request_channels = 2) {
+if (avctx-request_channels  0  avctx-request_channels = 2 
+avctx-request_channels  avctx-channels) {
 avctx-channels = avctx-request_channels;
 }
 s-downmixed = 1;
-- 
1.8.3.4 (Apple Git-47)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 5/7] ac3dec: simplify an expression.

2013-11-18 Thread Diego Biurrun
On Mon, Nov 18, 2013 at 12:41:47PM +0100, Tim Walker wrote:
 --- a/libavcodec/ac3dec.c
 +++ b/libavcodec/ac3dec.c
 @@ -178,9 +178,8 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
  
  /* allow downmixing to stereo or mono */
 -if (avctx-channels  0  avctx-request_channels  0 
 -avctx-request_channels  avctx-channels 
 -avctx-request_channels = 2) {
 +if (avctx-request_channels  0  avctx-request_channels = 2 
 +avctx-request_channels  avctx-channels) {
  avctx-channels = avctx-request_channels;

what ensures that avctx-channels is non-negative?  (Yes, I wonder why
that struct member is signed in the first place.)

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel