Re: [FFmpeg-devel] [PATCH] h261dec, ituh263dec: Avoid unnecessary -1 inside inner loop.

2014-09-01 Thread Reimar Döffinger
On Mon, Sep 01, 2014 at 03:01:15PM +0200, Michael Niedermayer wrote:
> On Sun, Aug 31, 2014 at 08:36:01PM +0200, Reimar Döffinger wrote:
> > 3646 -> 3597 decicycles in inner loop when decoding
> > vsynth1-flv.
> > 
> > Signed-off-by: Reimar Döffinger 
> > ---
> >  libavcodec/h261dec.c| 7 ---
> >  libavcodec/ituh263dec.c | 9 +
> >  2 files changed, 9 insertions(+), 7 deletions(-)
> 
> 
> LGTM
> 
> thx

Pushed.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] h261dec, ituh263dec: Avoid unnecessary -1 inside inner loop.

2014-09-01 Thread Michael Niedermayer
On Sun, Aug 31, 2014 at 08:36:01PM +0200, Reimar Döffinger wrote:
> 3646 -> 3597 decicycles in inner loop when decoding
> vsynth1-flv.
> 
> Signed-off-by: Reimar Döffinger 
> ---
>  libavcodec/h261dec.c| 7 ---
>  libavcodec/ituh263dec.c | 9 +
>  2 files changed, 9 insertions(+), 7 deletions(-)


LGTM

thx

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

Old school: Use the lowest level language in which you can solve the problem
conveniently.
New school: Use the highest level language in which the latest supercomputer
can solve the problem without the user falling asleep waiting.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] h261dec, ituh263dec: Avoid unnecessary -1 inside inner loop.

2014-08-31 Thread Reimar Döffinger
On Sun, Aug 31, 2014 at 12:23:48PM -0700, Timothy Gu wrote:
> On Aug 31, 2014 11:36 AM, "Reimar Döffinger" 
> wrote:
> >
> > 3646 -> 3597 decicycles in inner loop when decoding
> > vsynth1-flv.
> 
> Wow.

Note sure what way you meant it, but unfortunately it's not much really.
On the other hand it's not much or tricky code...
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] h261dec, ituh263dec: Avoid unnecessary -1 inside inner loop.

2014-08-31 Thread Timothy Gu
On Aug 31, 2014 11:36 AM, "Reimar Döffinger" 
wrote:
>
> 3646 -> 3597 decicycles in inner loop when decoding
> vsynth1-flv.

Wow.

[...]

Timothy
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] h261dec, ituh263dec: Avoid unnecessary -1 inside inner loop.

2014-08-31 Thread Reimar Döffinger
3646 -> 3597 decicycles in inner loop when decoding
vsynth1-flv.

Signed-off-by: Reimar Döffinger 
---
 libavcodec/h261dec.c| 7 ---
 libavcodec/ituh263dec.c | 9 +
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index f286d23..c9470b1 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -305,6 +305,7 @@ static int h261_decode_block(H261Context *h, int16_t 
*block, int n, int coded)
 }
 {
 OPEN_READER(re, &s->gb);
+i--; // offset by -1 to allow direct indexing of scan_table
 for (;;) {
 UPDATE_CACHE(re, &s->gb);
 GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TCOEFF_VLC_BITS, 2, 
0);
@@ -330,17 +331,17 @@ static int h261_decode_block(H261Context *h, int16_t 
*block, int n, int coded)
 SKIP_COUNTER(re, &s->gb, 1);
 }
 i += run;
-if (i > 64) {
+if (i >= 64) {
 av_log(s->avctx, AV_LOG_ERROR, "run overflow at %dx%d\n",
s->mb_x, s->mb_y);
 return -1;
 }
-j= scan_table[i-1];
+j= scan_table[i];
 block[j] = level;
 }
 CLOSE_READER(re, &s->gb);
 }
-s->block_last_index[n] = i - 1;
+s->block_last_index[n] = i;
 return 0;
 }
 
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 083f5ae..bea4d5a 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -481,6 +481,7 @@ static int h263_decode_block(MpegEncContext * s, int16_t * 
block,
 retry:
 {
 OPEN_READER(re, &s->gb);
+i--; // offset by -1 to allow direct indexing of scan_table
 for(;;) {
 UPDATE_CACHE(re, &s->gb);
 GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
@@ -529,9 +530,9 @@ retry:
 SKIP_COUNTER(re, &s->gb, 1);
 }
 i += run;
-if (i > 64){
-// redo update without last flag
-i = i - run + ((run-1)&63);
+if (i >= 64){
+// redo update without last flag, revert -1 offset
+i = i - run + ((run-1)&63) + 1;
 if (i < 64) {
 // only last marker, no overrun
 block[scan_table[i]] = level;
@@ -549,7 +550,7 @@ retry:
 av_log(s->avctx, AV_LOG_ERROR, "run overflow at %dx%d i:%d\n", 
s->mb_x, s->mb_y, s->mb_intra);
 return -1;
 }
-j = scan_table[i-1];
+j = scan_table[i];
 block[j] = level;
 }
 CLOSE_READER(re, &s->gb);
-- 
2.1.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel