Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avcodec/internal: Hide stuff only used by the core decode API
@ 2022-05-09 21:18 Andreas Rheinhardt
  2022-05-10  7:33 ` [FFmpeg-devel] [PATCH 2/3] avformat/internal: Move FFERROR_REDO to demux.h Andreas Rheinhardt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2022-05-09 21:18 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

The general decoding API uses bitstream filters and an AVFifo
and therefore AVCodecInternal contains pointers to an AVBSFContext
and to an AVFifo and lavc/internal.h includes lavc/bsf.h and
lavu/fifo.h.
Yet actually, only two files are supposed to use these, namely
avcodec.c and (mainly) decode.c. For all the other files,
it should be an opaque type that they should not touch and that
they need not know anything about. This can be achieved by not
including these headers and using the structs instead of the
corresponding typedefs.
This also forces translation units that really use the BSF
and the FIFO APIs themselves to include the relevant headers
directly instead of relying on indirect inclusions (up until now,
even avcodec.c and decode.c relied on fifo.h to be included
by internal.h).
Of course, it also avoids unnecessary rebuilds when bsf.h or fifo.h
change.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/avcodec.c   | 1 +
 libavcodec/cuviddec.c  | 1 +
 libavcodec/decode.c    | 1 +
 libavcodec/internal.h  | 6 ++----
 libavcodec/libvpxenc.c | 1 +
 5 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index d11f035481..f4ce6b8459 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -28,6 +28,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
 #include "libavutil/channel_layout.h"
+#include "libavutil/fifo.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/mem.h"
 #include "libavutil/opt.h"
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 81d4c89215..cb3cda7e24 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -34,6 +34,7 @@
 #include "libavutil/pixdesc.h"
 
 #include "avcodec.h"
+#include "bsf.h"
 #include "codec_internal.h"
 #include "decode.h"
 #include "hwconfig.h"
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 69e68ab09d..209585c540 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -32,6 +32,7 @@
 #include "libavutil/bprint.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
+#include "libavutil/fifo.h"
 #include "libavutil/frame.h"
 #include "libavutil/hwcontext.h"
 #include "libavutil/imgutils.h"
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 2fa56d3a59..17e1de8127 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -28,11 +28,9 @@
 
 #include "libavutil/buffer.h"
 #include "libavutil/channel_layout.h"
-#include "libavutil/fifo.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/pixfmt.h"
 #include "avcodec.h"
-#include "bsf.h"
 #include "config.h"
 
 #define FF_SANE_NB_CHANNELS 512U
@@ -73,14 +71,14 @@ typedef struct AVCodecInternal {
      * avcodec_flush_buffers().
      */
     AVPacket *in_pkt;
-    AVBSFContext *bsf;
+    struct AVBSFContext *bsf;
 
     /**
      * Properties (timestamps+side data) extracted from the last packet passed
      * for decoding.
      */
     AVPacket *last_pkt_props;
-    AVFifo *pkt_props;
+    struct AVFifo *pkt_props;
 
     /**
      * temporary buffer used for encoders to store their bitstream
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index e35b47b87e..187a9e9a36 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -42,6 +42,7 @@
 #include "libavutil/base64.h"
 #include "libavutil/common.h"
 #include "libavutil/cpu.h"
+#include "libavutil/fifo.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
-- 
2.32.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH 2/3] avformat/internal: Move FFERROR_REDO to demux.h
  2022-05-09 21:18 [FFmpeg-devel] [PATCH] avcodec/internal: Hide stuff only used by the core decode API Andreas Rheinhardt
@ 2022-05-10  7:33 ` Andreas Rheinhardt
  2022-05-10  7:33 ` [FFmpeg-devel] [PATCH 3/3] avformat/internal: Hide BSF stuff only used by the core APIs Andreas Rheinhardt
  2022-05-11 18:26 ` [FFmpeg-devel] [PATCH] avcodec/internal: Hide stuff only used by the core decode API Andreas Rheinhardt
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2022-05-10  7:33 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

It is demuxer-only.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/demux.h    | 6 ++++++
 libavformat/internal.h | 6 ------
 libavformat/lxfdec.c   | 1 +
 libavformat/smacker.c  | 1 +
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavformat/demux.h b/libavformat/demux.h
index a008c3dba1..1f57e062f6 100644
--- a/libavformat/demux.h
+++ b/libavformat/demux.h
@@ -55,6 +55,12 @@ typedef struct FFStreamInfo {
     int     fps_last_dts_idx;
 } FFStreamInfo;
 
+/**
+ * Returned by demuxers to indicate that data was consumed but discarded
+ * (ignored streams or junk data). The framework will re-call the demuxer.
+ */
+#define FFERROR_REDO FFERRTAG('R','E','D','O')
+
 #define RELATIVE_TS_BASE (INT64_MAX - (1LL << 48))
 
 static av_always_inline int is_relative(int64_t ts)
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 44516578b0..5363c0c355 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -651,12 +651,6 @@ int ff_alloc_extradata(AVCodecParameters *par, int size);
  */
 int ff_copy_whiteblacklists(AVFormatContext *dst, const AVFormatContext *src);
 
-/**
- * Returned by demuxers to indicate that data was consumed but discarded
- * (ignored streams or junk data). The framework will re-call the demuxer.
- */
-#define FFERROR_REDO FFERRTAG('R','E','D','O')
-
 /*
  * A wrapper around AVFormatContext.io_close that should be used
  * instead of calling the pointer directly.
diff --git a/libavformat/lxfdec.c b/libavformat/lxfdec.c
index 2d0270d718..8003ae98b7 100644
--- a/libavformat/lxfdec.c
+++ b/libavformat/lxfdec.c
@@ -24,6 +24,7 @@
 #include "libavutil/intreadwrite.h"
 #include "libavcodec/bytestream.h"
 #include "avformat.h"
+#include "demux.h"
 #include "internal.h"
 
 #define LXF_MAX_PACKET_HEADER_SIZE 256
diff --git a/libavformat/smacker.c b/libavformat/smacker.c
index eac50040d7..1d54e8e917 100644
--- a/libavformat/smacker.c
+++ b/libavformat/smacker.c
@@ -29,6 +29,7 @@
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "avio_internal.h"
+#include "demux.h"
 #include "internal.h"
 
 #define SMACKER_PAL 0x01
-- 
2.32.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH 3/3] avformat/internal: Hide BSF stuff only used by the core APIs
  2022-05-09 21:18 [FFmpeg-devel] [PATCH] avcodec/internal: Hide stuff only used by the core decode API Andreas Rheinhardt
  2022-05-10  7:33 ` [FFmpeg-devel] [PATCH 2/3] avformat/internal: Move FFERROR_REDO to demux.h Andreas Rheinhardt
@ 2022-05-10  7:33 ` Andreas Rheinhardt
  2022-05-11 18:26 ` [FFmpeg-devel] [PATCH] avcodec/internal: Hide stuff only used by the core decode API Andreas Rheinhardt
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2022-05-10  7:33 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

The general demuxing API uses bitstream filters to extract extradata
and the muxing API uses them in order to transform packets into
the format desired by the target format. Therefore FFStream contains
pointers to AVBSFContexts and lavf/internal.h includes lavc/bsf.h.

Yet actually, only a few files files are supposed to use these,
namely avformat.c, demux.c and mux.c. For all the other files,
it should be an opaque type that they should not touch and that
they need not know anything about. This can be achieved by not
including these headers and using the structs instead of the
corresponding typedefs.
This also forces translation units that really use the BSF API
themselves to include lavc/bsf.h directly instead of relying on
indirect inclusions (a few other files also use the BSF API;
they already abided by this).
Of course, it also avoids unnecessary rebuilds when bsf.h changes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/internal.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index 5363c0c355..b6b8fbf56f 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -24,7 +24,6 @@
 #include <stdint.h>
 
 #include "libavcodec/avcodec.h"
-#include "libavcodec/bsf.h"
 #include "libavcodec/packet_internal.h"
 
 #include "avformat.h"
@@ -212,7 +211,7 @@ typedef struct FFStream {
      * - encoding: Set by muxer using ff_stream_add_bitstream_filter
      * - decoding: unused
      */
-    AVBSFContext *bsfc;
+    struct AVBSFContext *bsfc;
 
     /**
      * Whether or not check_bitstream should still be run on each packet
@@ -232,7 +231,7 @@ typedef struct FFStream {
      * inited=1/bsf=NULL signals that extracting is not possible (codec not
      * supported) */
     struct {
-        AVBSFContext *bsf;
+        struct AVBSFContext *bsf;
         int inited;
     } extract_extradata;
 
-- 
2.32.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avcodec/internal: Hide stuff only used by the core decode API
  2022-05-09 21:18 [FFmpeg-devel] [PATCH] avcodec/internal: Hide stuff only used by the core decode API Andreas Rheinhardt
  2022-05-10  7:33 ` [FFmpeg-devel] [PATCH 2/3] avformat/internal: Move FFERROR_REDO to demux.h Andreas Rheinhardt
  2022-05-10  7:33 ` [FFmpeg-devel] [PATCH 3/3] avformat/internal: Hide BSF stuff only used by the core APIs Andreas Rheinhardt
@ 2022-05-11 18:26 ` Andreas Rheinhardt
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2022-05-11 18:26 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Andreas Rheinhardt:
> The general decoding API uses bitstream filters and an AVFifo
> and therefore AVCodecInternal contains pointers to an AVBSFContext
> and to an AVFifo and lavc/internal.h includes lavc/bsf.h and
> lavu/fifo.h.
> Yet actually, only two files are supposed to use these, namely
> avcodec.c and (mainly) decode.c. For all the other files,
> it should be an opaque type that they should not touch and that
> they need not know anything about. This can be achieved by not
> including these headers and using the structs instead of the
> corresponding typedefs.
> This also forces translation units that really use the BSF
> and the FIFO APIs themselves to include the relevant headers
> directly instead of relying on indirect inclusions (up until now,
> even avcodec.c and decode.c relied on fifo.h to be included
> by internal.h).
> Of course, it also avoids unnecessary rebuilds when bsf.h or fifo.h
> change.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/avcodec.c   | 1 +
>  libavcodec/cuviddec.c  | 1 +
>  libavcodec/decode.c    | 1 +
>  libavcodec/internal.h  | 6 ++----
>  libavcodec/libvpxenc.c | 1 +
>  5 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
> index d11f035481..f4ce6b8459 100644
> --- a/libavcodec/avcodec.c
> +++ b/libavcodec/avcodec.c
> @@ -28,6 +28,7 @@
>  #include "libavutil/avstring.h"
>  #include "libavutil/bprint.h"
>  #include "libavutil/channel_layout.h"
> +#include "libavutil/fifo.h"
>  #include "libavutil/imgutils.h"
>  #include "libavutil/mem.h"
>  #include "libavutil/opt.h"
> diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
> index 81d4c89215..cb3cda7e24 100644
> --- a/libavcodec/cuviddec.c
> +++ b/libavcodec/cuviddec.c
> @@ -34,6 +34,7 @@
>  #include "libavutil/pixdesc.h"
>  
>  #include "avcodec.h"
> +#include "bsf.h"
>  #include "codec_internal.h"
>  #include "decode.h"
>  #include "hwconfig.h"
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 69e68ab09d..209585c540 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -32,6 +32,7 @@
>  #include "libavutil/bprint.h"
>  #include "libavutil/channel_layout.h"
>  #include "libavutil/common.h"
> +#include "libavutil/fifo.h"
>  #include "libavutil/frame.h"
>  #include "libavutil/hwcontext.h"
>  #include "libavutil/imgutils.h"
> diff --git a/libavcodec/internal.h b/libavcodec/internal.h
> index 2fa56d3a59..17e1de8127 100644
> --- a/libavcodec/internal.h
> +++ b/libavcodec/internal.h
> @@ -28,11 +28,9 @@
>  
>  #include "libavutil/buffer.h"
>  #include "libavutil/channel_layout.h"
> -#include "libavutil/fifo.h"
>  #include "libavutil/mathematics.h"
>  #include "libavutil/pixfmt.h"
>  #include "avcodec.h"
> -#include "bsf.h"
>  #include "config.h"
>  
>  #define FF_SANE_NB_CHANNELS 512U
> @@ -73,14 +71,14 @@ typedef struct AVCodecInternal {
>       * avcodec_flush_buffers().
>       */
>      AVPacket *in_pkt;
> -    AVBSFContext *bsf;
> +    struct AVBSFContext *bsf;
>  
>      /**
>       * Properties (timestamps+side data) extracted from the last packet passed
>       * for decoding.
>       */
>      AVPacket *last_pkt_props;
> -    AVFifo *pkt_props;
> +    struct AVFifo *pkt_props;
>  
>      /**
>       * temporary buffer used for encoders to store their bitstream
> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> index e35b47b87e..187a9e9a36 100644
> --- a/libavcodec/libvpxenc.c
> +++ b/libavcodec/libvpxenc.c
> @@ -42,6 +42,7 @@
>  #include "libavutil/base64.h"
>  #include "libavutil/common.h"
>  #include "libavutil/cpu.h"
> +#include "libavutil/fifo.h"
>  #include "libavutil/internal.h"
>  #include "libavutil/intreadwrite.h"
>  #include "libavutil/mathematics.h"

Will apply this patchset tomorrow unless there are objections.

- Andreas
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-11 18:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-09 21:18 [FFmpeg-devel] [PATCH] avcodec/internal: Hide stuff only used by the core decode API Andreas Rheinhardt
2022-05-10  7:33 ` [FFmpeg-devel] [PATCH 2/3] avformat/internal: Move FFERROR_REDO to demux.h Andreas Rheinhardt
2022-05-10  7:33 ` [FFmpeg-devel] [PATCH 3/3] avformat/internal: Hide BSF stuff only used by the core APIs Andreas Rheinhardt
2022-05-11 18:26 ` [FFmpeg-devel] [PATCH] avcodec/internal: Hide stuff only used by the core decode API Andreas Rheinhardt

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git