Re: [libav-devel] [PATCH] adpcmenc: ensure calls to adpcm_ima_compress_sample() are in the right order

2012-10-07 Thread Måns Rullgård
Justin Ruggles  writes:

> Should fix fate-acodec-adpcm-ima_wav with several compilers.
> ---
>  libavcodec/adpcmenc.c |5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
> index 5c95ad7..f81d7fd 100644
> --- a/libavcodec/adpcmenc.c
> +++ b/libavcodec/adpcmenc.c
> @@ -537,8 +537,9 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
> AVPacket *avpkt,
>  ADPCMChannelStatus *status = &c->status[ch];
>  const int16_t *smp = &samples_p[ch][1 + i * 8];
>  for (j = 0; j < 8; j += 2) {
> -*dst++ = adpcm_ima_compress_sample(status, smp[j
> ]) |
> -(adpcm_ima_compress_sample(status, smp[j + 
> 1]) << 4);
> +uint8_t v = adpcm_ima_compress_sample(status, smp[j  
>   ]);
> +v|= adpcm_ima_compress_sample(status, smp[j 
> + 1]) << 4;
> +*dst++ = v;
>  }
>  }
>  }
> -- 

LGTM

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] adpcmenc: ensure calls to adpcm_ima_compress_sample() are in the right order

2012-10-07 Thread Justin Ruggles
Should fix fate-acodec-adpcm-ima_wav with several compilers.
---
 libavcodec/adpcmenc.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 5c95ad7..f81d7fd 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -537,8 +537,9 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 ADPCMChannelStatus *status = &c->status[ch];
 const int16_t *smp = &samples_p[ch][1 + i * 8];
 for (j = 0; j < 8; j += 2) {
-*dst++ = adpcm_ima_compress_sample(status, smp[j]) 
|
-(adpcm_ima_compress_sample(status, smp[j + 1]) 
<< 4);
+uint8_t v = adpcm_ima_compress_sample(status, smp[j
]);
+v|= adpcm_ima_compress_sample(status, smp[j + 
1]) << 4;
+*dst++ = v;
 }
 }
 }
-- 
1.7.1

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


Re: [libav-devel] [PATCH] adpcmenc: ensure calls to adpcm_ima_compress_sample() are in the right order

2012-10-07 Thread Måns Rullgård
Derek Buitenhuis  writes:

> On 07/10/2012 4:02 PM, Justin Ruggles wrote:
>> +uint8_t v =  adpcm_ima_compress_sample(status, 
>> smp[j]);
>> +v|= (adpcm_ima_compress_sample(status, 
>> smp[j + 1]) << 4);
>> +*dst++ = v
>
> Someone will complain about alignment.

No, but about useless parens.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] adpcmenc: ensure calls to adpcm_ima_compress_sample() are in the right order

2012-10-07 Thread Derek Buitenhuis
On 07/10/2012 4:02 PM, Justin Ruggles wrote:
> +uint8_t v =  adpcm_ima_compress_sample(status, smp[j 
>]);
> +v|= (adpcm_ima_compress_sample(status, smp[j 
> + 1]) << 4);
> +*dst++ = v

Someone will complain about alignment.

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


[libav-devel] [PATCH] adpcmenc: ensure calls to adpcm_ima_compress_sample() are in the right order

2012-10-07 Thread Justin Ruggles
Should fix fate-acodec-adpcm-ima_wav with several compilers.
---
 libavcodec/adpcmenc.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 5c95ad7..c172d48 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -537,8 +537,9 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 ADPCMChannelStatus *status = &c->status[ch];
 const int16_t *smp = &samples_p[ch][1 + i * 8];
 for (j = 0; j < 8; j += 2) {
-*dst++ = adpcm_ima_compress_sample(status, smp[j]) 
|
-(adpcm_ima_compress_sample(status, smp[j + 1]) 
<< 4);
+uint8_t v =  adpcm_ima_compress_sample(status, smp[j   
 ]);
+v|= (adpcm_ima_compress_sample(status, smp[j + 
1]) << 4);
+*dst++ = v;
 }
 }
 }
-- 
1.7.1

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


Re: [libav-devel] [PATCH] adpcmenc: ensure calls to adpcm_ima_compress_sample() are in the right order

2012-10-07 Thread Måns Rullgård
Justin Ruggles  writes:

> Should fix fate-acodec-adpcm-ima_wav with several compilers.
> ---
>  libavcodec/adpcmenc.c |4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
> index 5c95ad7..6816f60 100644
> --- a/libavcodec/adpcmenc.c
> +++ b/libavcodec/adpcmenc.c
> @@ -537,8 +537,8 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
> AVPacket *avpkt,
>  ADPCMChannelStatus *status = &c->status[ch];
>  const int16_t *smp = &samples_p[ch][1 + i * 8];
>  for (j = 0; j < 8; j += 2) {
> -*dst++ = adpcm_ima_compress_sample(status, smp[j
> ]) |
> -(adpcm_ima_compress_sample(status, smp[j + 
> 1]) << 4);
> +*dst=  adpcm_ima_compress_sample(status, smp[j   
>  ]);
> +*dst++ |= (adpcm_ima_compress_sample(status, smp[j + 
> 1]) << 4);
>  }
>  }
>  }
> -- 

Use a temporary variable and touch *dst only once.  Otherwise the
compiler will probably do unnecessary memory accesses since it doesn't
know dst and smp don't alias.

-- 
Måns Rullgård
m...@mansr.com
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] adpcmenc: ensure calls to adpcm_ima_compress_sample() are in the right order

2012-10-07 Thread Martin Storsjö

On Sat, 6 Oct 2012, Justin Ruggles wrote:


Should fix fate-acodec-adpcm-ima_wav with several compilers.
---
libavcodec/adpcmenc.c |4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 5c95ad7..6816f60 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -537,8 +537,8 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
ADPCMChannelStatus *status = &c->status[ch];
const int16_t *smp = &samples_p[ch][1 + i * 8];
for (j = 0; j < 8; j += 2) {
-*dst++ = adpcm_ima_compress_sample(status, smp[j]) 
|
-(adpcm_ima_compress_sample(status, smp[j + 1]) 
<< 4);
+*dst=  adpcm_ima_compress_sample(status, smp[j
]);
+*dst++ |= (adpcm_ima_compress_sample(status, smp[j + 1]) 
<< 4);
}
}
}
--
1.7.1


LGTM, fixes FATE on MSVC for me.

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


Re: [libav-devel] [PATCH] adpcmenc: ensure calls to adpcm_ima_compress_sample() are in the right order

2012-10-06 Thread Derek Buitenhuis
On 06/10/2012 11:59 PM, Justin Ruggles wrote:
> Should fix fate-acodec-adpcm-ima_wav with several compilers.
> ---
>  libavcodec/adpcmenc.c |4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

For the record, these are MSVC and PathScale EKOPath.

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


[libav-devel] [PATCH] adpcmenc: ensure calls to adpcm_ima_compress_sample() are in the right order

2012-10-06 Thread Justin Ruggles
Should fix fate-acodec-adpcm-ima_wav with several compilers.
---
 libavcodec/adpcmenc.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 5c95ad7..6816f60 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -537,8 +537,8 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 ADPCMChannelStatus *status = &c->status[ch];
 const int16_t *smp = &samples_p[ch][1 + i * 8];
 for (j = 0; j < 8; j += 2) {
-*dst++ = adpcm_ima_compress_sample(status, smp[j]) 
|
-(adpcm_ima_compress_sample(status, smp[j + 1]) 
<< 4);
+*dst=  adpcm_ima_compress_sample(status, smp[j
]);
+*dst++ |= (adpcm_ima_compress_sample(status, smp[j + 
1]) << 4);
 }
 }
 }
-- 
1.7.1

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