diff mbox series

[FFmpeg-devel,6/7] avcodec/hap: Avoid unnecessary opt.h inclusion

Message ID AS8P250MB07444F0BFEDB2B3F8FB22CAE8F7B2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 4f58372c10dfc5d8c4ae46738b5a1c79633ee5ff
Headers show
Series [FFmpeg-devel,1/7] avcodec/dxvenc: Don't cast const away | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Jan. 24, 2024, 7:52 p.m. UTC
It presumably exists because HapContext contains an AVClass*.
Yet AVClass is actually defined in log.h and even this inclusion
can be avoided by struct AVClass*. This avoids opt.h inclusions
in hap.c and hapdec.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/hap.h               | 5 ++---
 libavcodec/hapqa_extract_bsf.c | 2 ++
 2 files changed, 4 insertions(+), 3 deletions(-)

Comments

Vittorio Giovara Jan. 25, 2024, 7:27 p.m. UTC | #1
On Wed, Jan 24, 2024 at 9:06 PM Andreas Rheinhardt <
andreas.rheinhardt@outlook.com> wrote:

> It presumably exists because HapContext contains an AVClass*.
> Yet AVClass is actually defined in log.h and even this inclusion
> can be avoided by struct AVClass*. This avoids opt.h inclusions
> in hap.c and hapdec.c.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/hap.h               | 5 ++---
>  libavcodec/hapqa_extract_bsf.c | 2 ++
>  2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/hap.h b/libavcodec/hap.h
> index a888b58fd7..1de6d45428 100644
> --- a/libavcodec/hap.h
> +++ b/libavcodec/hap.h
> @@ -23,10 +23,9 @@
>  #ifndef AVCODEC_HAP_H
>  #define AVCODEC_HAP_H
>
> +#include <stddef.h>
>  #include <stdint.h>
>
> -#include "libavutil/opt.h"
> -
>  #include "bytestream.h"
>  #include "texturedsp.h"
>
> @@ -59,7 +58,7 @@ typedef struct HapChunk {
>  } HapChunk;
>
>  typedef struct HapContext {
> -    AVClass *class;
> +    const struct AVClass *class;
>
>      GetByteContext gbc;
>
> diff --git a/libavcodec/hapqa_extract_bsf.c
> b/libavcodec/hapqa_extract_bsf.c
> index 0d9b40aaa6..eac9eafe42 100644
> --- a/libavcodec/hapqa_extract_bsf.c
> +++ b/libavcodec/hapqa_extract_bsf.c
> @@ -30,6 +30,8 @@
>  #include "bytestream.h"
>  #include "hap.h"
>
> +#include "libavutil/opt.h"
>

Is this include only for AVClass? Should it be log.h then?
Andreas Rheinhardt Jan. 26, 2024, 6:41 a.m. UTC | #2
Vittorio Giovara:
> On Wed, Jan 24, 2024 at 9:06 PM Andreas Rheinhardt <
> andreas.rheinhardt@outlook.com> wrote:
> 
>> It presumably exists because HapContext contains an AVClass*.
>> Yet AVClass is actually defined in log.h and even this inclusion
>> can be avoided by struct AVClass*. This avoids opt.h inclusions
>> in hap.c and hapdec.c.
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>>  libavcodec/hap.h               | 5 ++---
>>  libavcodec/hapqa_extract_bsf.c | 2 ++
>>  2 files changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavcodec/hap.h b/libavcodec/hap.h
>> index a888b58fd7..1de6d45428 100644
>> --- a/libavcodec/hap.h
>> +++ b/libavcodec/hap.h
>> @@ -23,10 +23,9 @@
>>  #ifndef AVCODEC_HAP_H
>>  #define AVCODEC_HAP_H
>>
>> +#include <stddef.h>
>>  #include <stdint.h>
>>
>> -#include "libavutil/opt.h"
>> -
>>  #include "bytestream.h"
>>  #include "texturedsp.h"
>>
>> @@ -59,7 +58,7 @@ typedef struct HapChunk {
>>  } HapChunk;
>>
>>  typedef struct HapContext {
>> -    AVClass *class;
>> +    const struct AVClass *class;
>>
>>      GetByteContext gbc;
>>
>> diff --git a/libavcodec/hapqa_extract_bsf.c
>> b/libavcodec/hapqa_extract_bsf.c
>> index 0d9b40aaa6..eac9eafe42 100644
>> --- a/libavcodec/hapqa_extract_bsf.c
>> +++ b/libavcodec/hapqa_extract_bsf.c
>> @@ -30,6 +30,8 @@
>>  #include "bytestream.h"
>>  #include "hap.h"
>>
>> +#include "libavutil/opt.h"
>>
> 
> Is this include only for AVClass? Should it be log.h then?

Yes. log.h can be avoided by using struct AVClass* (there is actually
still an implicit inclusion of log.h via bytestream.h).

- Andreas
diff mbox series

Patch

diff --git a/libavcodec/hap.h b/libavcodec/hap.h
index a888b58fd7..1de6d45428 100644
--- a/libavcodec/hap.h
+++ b/libavcodec/hap.h
@@ -23,10 +23,9 @@ 
 #ifndef AVCODEC_HAP_H
 #define AVCODEC_HAP_H
 
+#include <stddef.h>
 #include <stdint.h>
 
-#include "libavutil/opt.h"
-
 #include "bytestream.h"
 #include "texturedsp.h"
 
@@ -59,7 +58,7 @@  typedef struct HapChunk {
 } HapChunk;
 
 typedef struct HapContext {
-    AVClass *class;
+    const struct AVClass *class;
 
     GetByteContext gbc;
 
diff --git a/libavcodec/hapqa_extract_bsf.c b/libavcodec/hapqa_extract_bsf.c
index 0d9b40aaa6..eac9eafe42 100644
--- a/libavcodec/hapqa_extract_bsf.c
+++ b/libavcodec/hapqa_extract_bsf.c
@@ -30,6 +30,8 @@ 
 #include "bytestream.h"
 #include "hap.h"
 
+#include "libavutil/opt.h"
+
 typedef struct HapqaExtractContext {
     const AVClass *class;
     int texture;/* index of the texture to keep (0 for rgb or 1 for alpha) */