diff mbox series

[FFmpeg-devel,2/3] avcodec/kmvc: Move commonly used variables to the front of the context

Message ID 20210322020634.701593-2-andreas.rheinhardt@gmail.com
State Accepted
Commit efbfee4c1a61705dc5a4067ac8e70d7db618a7e9
Headers show
Series [FFmpeg-devel,1/3] avcodec/kmvc: Prefer in-band palette
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt March 22, 2021, 2:06 a.m. UTC
Reduces codesize because the offset in pointer+offset addressing
requires less bytes to encode. Reduces the size of .text from 8871B
to 8146B (GCC 10, -O3, x64).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/kmvc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Tomas Härdin March 24, 2021, 1:46 p.m. UTC | #1
mån 2021-03-22 klockan 03:06 +0100 skrev Andreas Rheinhardt:
> Reduces codesize because the offset in pointer+offset addressing
> requires less bytes to encode. Reduces the size of .text from 8871B
> to 8146B (GCC 10, -O3, x64).
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/kmvc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c
> index 8d9f0a9693..dd1ae05f2d 100644
> --- a/libavcodec/kmvc.c
> +++ b/libavcodec/kmvc.c
> @@ -44,12 +44,12 @@
>  typedef struct KmvcContext {
>      AVCodecContext *avctx;

Couldn't this be removed too? Doesn't have to hold up this patch of
course

/Tomas
Andreas Rheinhardt March 24, 2021, 1:49 p.m. UTC | #2
Tomas Härdin:
> mån 2021-03-22 klockan 03:06 +0100 skrev Andreas Rheinhardt:
>> Reduces codesize because the offset in pointer+offset addressing
>> requires less bytes to encode. Reduces the size of .text from 8871B
>> to 8146B (GCC 10, -O3, x64).
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
>> ---
>>  libavcodec/kmvc.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c
>> index 8d9f0a9693..dd1ae05f2d 100644
>> --- a/libavcodec/kmvc.c
>> +++ b/libavcodec/kmvc.c
>> @@ -44,12 +44,12 @@
>>  typedef struct KmvcContext {
>>      AVCodecContext *avctx;
> 
> Couldn't this be removed too? Doesn't have to hold up this patch of
> course
> 
It is currently used for log messages; such usage is fairly common, but
it can of course be changed. Don't know if it is beneficial though.

- Andreas
Tomas Härdin March 24, 2021, 2:08 p.m. UTC | #3
ons 2021-03-24 klockan 14:49 +0100 skrev Andreas Rheinhardt:
> Tomas Härdin:
> > mån 2021-03-22 klockan 03:06 +0100 skrev Andreas Rheinhardt:
> > > Reduces codesize because the offset in pointer+offset addressing
> > > requires less bytes to encode. Reduces the size of .text from 8871B
> > > to 8146B (GCC 10, -O3, x64).
> > > 
> > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> > > ---
> > >  libavcodec/kmvc.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c
> > > index 8d9f0a9693..dd1ae05f2d 100644
> > > --- a/libavcodec/kmvc.c
> > > +++ b/libavcodec/kmvc.c
> > > @@ -44,12 +44,12 @@
> > >  typedef struct KmvcContext {
> > >      AVCodecContext *avctx;
> > 
> > Couldn't this be removed too? Doesn't have to hold up this patch of
> > course
> > 
> It is currently used for log messages; such usage is fairly common, but
> it can of course be changed. Don't know if it is beneficial though.

Maybe moving it further down the struct saves some .text?

/Tomas
Andreas Rheinhardt March 24, 2021, 2:26 p.m. UTC | #4
Tomas Härdin:
> ons 2021-03-24 klockan 14:49 +0100 skrev Andreas Rheinhardt:
>> Tomas Härdin:
>>> mån 2021-03-22 klockan 03:06 +0100 skrev Andreas Rheinhardt:
>>>> Reduces codesize because the offset in pointer+offset addressing
>>>> requires less bytes to encode. Reduces the size of .text from 8871B
>>>> to 8146B (GCC 10, -O3, x64).
>>>>
>>>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
>>>> ---
>>>>  libavcodec/kmvc.c | 4 ++--
>>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c
>>>> index 8d9f0a9693..dd1ae05f2d 100644
>>>> --- a/libavcodec/kmvc.c
>>>> +++ b/libavcodec/kmvc.c
>>>> @@ -44,12 +44,12 @@
>>>>  typedef struct KmvcContext {
>>>>      AVCodecContext *avctx;
>>>
>>> Couldn't this be removed too? Doesn't have to hold up this patch of
>>> course
>>>
>> It is currently used for log messages; such usage is fairly common, but
>> it can of course be changed. Don't know if it is beneficial though.
> 
> Maybe moving it further down the struct saves some .text?
> 
Moving the GetBitContext to the top spot is beneficial (saves 77B);
removing avctx from the context is even more so: 77B+4B in decode_init.
I can do so if desired.

- Andreas
Tomas Härdin March 24, 2021, 2:32 p.m. UTC | #5
ons 2021-03-24 klockan 15:26 +0100 skrev Andreas Rheinhardt:
> Tomas Härdin:
> > ons 2021-03-24 klockan 14:49 +0100 skrev Andreas Rheinhardt:
> > > Tomas Härdin:
> > > > mån 2021-03-22 klockan 03:06 +0100 skrev Andreas Rheinhardt:
> > > > > Reduces codesize because the offset in pointer+offset addressing
> > > > > requires less bytes to encode. Reduces the size of .text from 8871B
> > > > > to 8146B (GCC 10, -O3, x64).
> > > > > 
> > > > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> > > > > ---
> > > > >  libavcodec/kmvc.c | 4 ++--
> > > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > > 
> > > > > diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c
> > > > > index 8d9f0a9693..dd1ae05f2d 100644
> > > > > --- a/libavcodec/kmvc.c
> > > > > +++ b/libavcodec/kmvc.c
> > > > > @@ -44,12 +44,12 @@
> > > > >  typedef struct KmvcContext {
> > > > >      AVCodecContext *avctx;
> > > > 
> > > > Couldn't this be removed too? Doesn't have to hold up this patch of
> > > > course
> > > > 
> > > It is currently used for log messages; such usage is fairly common, but
> > > it can of course be changed. Don't know if it is beneficial though.
> > 
> > Maybe moving it further down the struct saves some .text?
> > 
> Moving the GetBitContext to the top spot is beneficial (saves 77B);
> removing avctx from the context is even more so: 77B+4B in decode_init.
> I can do so if desired.

Eh, whatever. The patchset works and looks decent enough.

/Tomas
diff mbox series

Patch

diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c
index 8d9f0a9693..dd1ae05f2d 100644
--- a/libavcodec/kmvc.c
+++ b/libavcodec/kmvc.c
@@ -44,12 +44,12 @@ 
 typedef struct KmvcContext {
     AVCodecContext *avctx;
 
+    GetByteContext g;
+    uint8_t *cur, *prev;
     int setpal;
     int palsize;
     uint32_t pal[MAX_PALSIZE];
-    uint8_t *cur, *prev;
     uint8_t frm0[320 * 200], frm1[320 * 200];
-    GetByteContext g;
 } KmvcContext;
 
 typedef struct BitBuf {