aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/bsf.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-03-21 22:25:27 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-03-23 23:45:45 +0100
commitf4098bbc3b10926f618cf89e24780c9e6ae9b8b5 (patch)
treedb7d738eeeefadfc5b2400c4375b2a50d9d07516 /libavcodec/bsf.c
parent1dcd0adedd15f2595d51febbfc171c576c9e080a (diff)
downloadffmpeg-f4098bbc3b10926f618cf89e24780c9e6ae9b8b5.tar.gz
avcodec/bsf: Add FFBitStreamFilter, hide internals of BSFs
This patch is analogous to 20f972701806be20a77f808db332d9489343bb78: It hides the internal part of AVBitStreamFilter by adding a new internal structure FFBitStreamFilter (declared in bsf_internal.h) that has an AVBitStreamFilter as its first member; the internal part of AVBitStreamFilter is moved to this new structure. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/bsf.c')
-rw-r--r--libavcodec/bsf.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index 60761e6f7d..42cc1b5ab0 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -18,7 +18,6 @@
#include <string.h>
-#include "config.h"
#include "config_components.h"
#include "libavutil/avassert.h"
@@ -35,6 +34,11 @@
#define IS_EMPTY(pkt) (!(pkt)->data && !(pkt)->side_data_elems)
+static av_always_inline const FFBitStreamFilter *ff_bsf(const AVBitStreamFilter *bsf)
+{
+ return (const FFBitStreamFilter*)bsf;
+}
+
typedef struct FFBSFContext {
AVBSFContext pub;
AVPacket *buffer_pkt;
@@ -57,8 +61,8 @@ void av_bsf_free(AVBSFContext **pctx)
bsfi = ffbsfcontext(ctx);
if (ctx->priv_data) {
- if (ctx->filter->close)
- ctx->filter->close(ctx);
+ if (ff_bsf(ctx->filter)->close)
+ ff_bsf(ctx->filter)->close(ctx);
if (ctx->filter->priv_class)
av_opt_free(ctx->priv_data);
av_freep(&ctx->priv_data);
@@ -119,8 +123,8 @@ int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
goto fail;
}
/* allocate priv data and init private options */
- if (filter->priv_data_size) {
- ctx->priv_data = av_mallocz(filter->priv_data_size);
+ if (ff_bsf(filter)->priv_data_size) {
+ ctx->priv_data = av_mallocz(ff_bsf(filter)->priv_data_size);
if (!ctx->priv_data) {
ret = AVERROR(ENOMEM);
goto fail;
@@ -175,8 +179,8 @@ int av_bsf_init(AVBSFContext *ctx)
ctx->time_base_out = ctx->time_base_in;
- if (ctx->filter->init) {
- ret = ctx->filter->init(ctx);
+ if (ff_bsf(ctx->filter)->init) {
+ ret = ff_bsf(ctx->filter)->init(ctx);
if (ret < 0)
return ret;
}
@@ -192,8 +196,8 @@ void av_bsf_flush(AVBSFContext *ctx)
av_packet_unref(bsfi->buffer_pkt);
- if (ctx->filter->flush)
- ctx->filter->flush(ctx);
+ if (ff_bsf(ctx->filter)->flush)
+ ff_bsf(ctx->filter)->flush(ctx);
}
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
@@ -226,7 +230,7 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
{
- return ctx->filter->filter(ctx, pkt);
+ return ff_bsf(ctx->filter)->filter(ctx, pkt);
}
int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt)
@@ -399,10 +403,10 @@ static const AVClass bsf_list_class = {
.version = LIBAVUTIL_VERSION_INT,
};
-static const AVBitStreamFilter list_bsf = {
- .name = "bsf_list",
+static const FFBitStreamFilter list_bsf = {
+ .p.name = "bsf_list",
+ .p.priv_class = &bsf_list_class,
.priv_data_size = sizeof(BSFListContext),
- .priv_class = &bsf_list_class,
.init = bsf_list_init,
.filter = bsf_list_filter,
.flush = bsf_list_flush,
@@ -495,7 +499,7 @@ int av_bsf_list_finalize(AVBSFList **lst, AVBSFContext **bsf)
goto end;
}
- ret = av_bsf_alloc(&list_bsf, bsf);
+ ret = av_bsf_alloc(&list_bsf.p, bsf);
if (ret < 0)
return ret;
@@ -550,9 +554,9 @@ end:
int av_bsf_get_null_filter(AVBSFContext **bsf)
{
#if CONFIG_NULL_BSF
- extern const AVBitStreamFilter ff_null_bsf;
- return av_bsf_alloc(&ff_null_bsf, bsf);
+ extern const FFBitStreamFilter ff_null_bsf;
+ return av_bsf_alloc(&ff_null_bsf.p, bsf);
#else
- return av_bsf_alloc(&list_bsf, bsf);
+ return av_bsf_alloc(&list_bsf.p, bsf);
#endif
}