[FFmpeg-devel,1/2] avcodec/dvdsubdec: Avoid branch in decode_run_8bit()

Submitted by Michael Niedermayer on Sept. 13, 2018, 2:24 a.m.

Details

Message ID 20180913022450.19376-1-michael@niedermayer.cc
State Accepted
Commit 71bf0330505e2108935d05c5c018ec65eac4b946
Headers show

Commit Message

Michael Niedermayer Sept. 13, 2018, 2:24 a.m.
Speed improvment 35.5 sec -> 34.7sec

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/dvdsubdec.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Paul B Mahol Sept. 14, 2018, 8:43 p.m.
On 9/13/18, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Speed improvment 35.5 sec -> 34.7sec
>
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/dvdsubdec.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>

lgtm
Michael Niedermayer Sept. 15, 2018, 1 p.m.
On Fri, Sep 14, 2018 at 10:43:14PM +0200, Paul B Mahol wrote:
> On 9/13/18, Michael Niedermayer <michael@niedermayer.cc> wrote:
> > Speed improvment 35.5 sec -> 34.7sec
> >
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/dvdsubdec.c | 5 +----
> >  1 file changed, 1 insertion(+), 4 deletions(-)
> >
> 
> lgtm

will apply

thx

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index f1ac9e353e..13d52c8c68 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -83,10 +83,7 @@  static int decode_run_8bit(GetBitContext *gb, int *color)
 {
     int len;
     int has_run = get_bits1(gb);
-    if (get_bits1(gb))
-        *color = get_bits(gb, 8);
-    else
-        *color = get_bits(gb, 2);
+    *color = get_bits(gb, 2 + 6*get_bits1(gb));
     if (has_run) {
         if (get_bits1(gb)) {
             len = get_bits(gb, 7);