summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2020-04-18 10:49:54 +0200
committerMarton Balint <cus@passwd.hu>2020-04-26 22:39:01 +0200
commit1128aa875367f66ac11adc30364d5652919a2591 (patch)
tree72a92801d4bff46f69093b364cc3bf2016d87ff7 /libavformat
parent499f43ae90c0b03264e874c199a5904280766782 (diff)
avformat: only allow a single bitstream filter when muxing
Current muxers only use a single bitstream filter, so there is no need to maintain code which operates on a list of bitstream filters. When multiple bitstream filters are needed muxers can simply use a list bitstream filter. If there is a use case in the future when different bitstream filters should be added at subsequent packets then a new API possibly involving reconfiguring the list bitstream filter can be added knowing the exact requirements. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/dashenc.c6
-rw-r--r--libavformat/internal.h5
-rw-r--r--libavformat/mux.c6
-rw-r--r--libavformat/segment.c6
-rw-r--r--libavformat/utils.c24
5 files changed, 15 insertions, 32 deletions
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index b08253618d..9f83785792 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -2325,10 +2325,8 @@ static int dash_check_bitstream(struct AVFormatContext *s, const AVPacket *avpkt
if (ret == 1) {
AVStream *st = s->streams[avpkt->stream_index];
AVStream *ost = oc->streams[0];
- st->internal->bsfcs = ost->internal->bsfcs;
- st->internal->nb_bsfcs = ost->internal->nb_bsfcs;
- ost->internal->bsfcs = NULL;
- ost->internal->nb_bsfcs = 0;
+ st->internal->bsfc = ost->internal->bsfc;
+ ost->internal->bsfc = NULL;
}
return ret;
}
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 329b2e972d..6786b732ac 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -152,12 +152,11 @@ struct AVStreamInternal {
int reorder;
/**
- * bitstream filters to run on stream
+ * bitstream filter to run on stream
* - encoding: Set by muxer using ff_stream_add_bitstream_filter
* - decoding: unused
*/
- AVBSFContext **bsfcs;
- int nb_bsfcs;
+ AVBSFContext *bsfc;
/**
* Whether or not check_bitstream should still be run on each packet
diff --git a/libavformat/mux.c b/libavformat/mux.c
index c348b8fdc8..3d1f71ab1a 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -811,7 +811,7 @@ static int prepare_input_packet(AVFormatContext *s, AVPacket *pkt)
static int do_packet_auto_bsf(AVFormatContext *s, AVPacket *pkt) {
AVStream *st = s->streams[pkt->stream_index];
- int i, ret;
+ int ret;
if (!(s->flags & AVFMT_FLAG_AUTO_BSF))
return 1;
@@ -825,8 +825,8 @@ static int do_packet_auto_bsf(AVFormatContext *s, AVPacket *pkt) {
}
}
- for (i = 0; i < st->internal->nb_bsfcs; i++) {
- AVBSFContext *ctx = st->internal->bsfcs[i];
+ if (st->internal->bsfc) {
+ AVBSFContext *ctx = st->internal->bsfc;
// TODO: when any bitstream filter requires flushing at EOF, we'll need to
// flush each stream's BSF chain on write_trailer.
if ((ret = av_bsf_send_packet(ctx, pkt)) < 0) {
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 60b72b7d15..32c09827eb 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -1034,10 +1034,8 @@ static int seg_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
if (ret == 1) {
AVStream *st = s->streams[pkt->stream_index];
AVStream *ost = oc->streams[pkt->stream_index];
- st->internal->bsfcs = ost->internal->bsfcs;
- st->internal->nb_bsfcs = ost->internal->nb_bsfcs;
- ost->internal->bsfcs = NULL;
- ost->internal->nb_bsfcs = 0;
+ st->internal->bsfc = ost->internal->bsfc;
+ ost->internal->bsfc = NULL;
}
return ret;
}
diff --git a/libavformat/utils.c b/libavformat/utils.c
index a36d6738cd..3b53f97bee 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4408,10 +4408,7 @@ static void free_stream(AVStream **pst)
if (st->internal) {
avcodec_free_context(&st->internal->avctx);
- for (i = 0; i < st->internal->nb_bsfcs; i++) {
- av_bsf_free(&st->internal->bsfcs[i]);
- av_freep(&st->internal->bsfcs);
- }
+ av_bsf_free(&st->internal->bsfc);
av_freep(&st->internal->priv_pts);
av_bsf_free(&st->internal->extract_extradata.bsf);
av_packet_free(&st->internal->extract_extradata.pkt);
@@ -5572,7 +5569,8 @@ int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *a
int ret;
const AVBitStreamFilter *bsf;
AVBSFContext *bsfc;
- AVCodecParameters *in_par;
+
+ av_assert0(!st->internal->bsfc);
if (!(bsf = av_bsf_get_by_name(name))) {
av_log(NULL, AV_LOG_ERROR, "Unknown bitstream filter '%s'\n", name);
@@ -5582,15 +5580,8 @@ int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *a
if ((ret = av_bsf_alloc(bsf, &bsfc)) < 0)
return ret;
- if (st->internal->nb_bsfcs) {
- in_par = st->internal->bsfcs[st->internal->nb_bsfcs - 1]->par_out;
- bsfc->time_base_in = st->internal->bsfcs[st->internal->nb_bsfcs - 1]->time_base_out;
- } else {
- in_par = st->codecpar;
- bsfc->time_base_in = st->time_base;
- }
-
- if ((ret = avcodec_parameters_copy(bsfc->par_in, in_par)) < 0) {
+ bsfc->time_base_in = st->time_base;
+ if ((ret = avcodec_parameters_copy(bsfc->par_in, st->codecpar)) < 0) {
av_bsf_free(&bsfc);
return ret;
}
@@ -5613,10 +5604,7 @@ int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *a
return ret;
}
- if ((ret = av_dynarray_add_nofree(&st->internal->bsfcs, &st->internal->nb_bsfcs, bsfc))) {
- av_bsf_free(&bsfc);
- return ret;
- }
+ st->internal->bsfc = bsfc;
av_log(NULL, AV_LOG_VERBOSE,
"Automatically inserted bitstream filter '%s'; args='%s'\n",