Commit Graph

40 Commits

Author SHA1 Message Date
Anton Khirnov 0f957cfba2 lavc/bsf: move IS_EMPTY() to packet_internal()
It will be useful in other places.
2023-07-07 12:07:24 +02:00
Andreas Rheinhardt f4098bbc3b 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>
2022-03-23 23:45:45 +01:00
Martin Storsjö a78f136f3f configure: Use a separate config_components.h header for $ALL_COMPONENTS
This avoids unnecessary rebuilds of most source files if only the
list of enabled components has changed, but not the other properties
of the build, set in config.h.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-03-16 14:12:49 +02:00
Andreas Rheinhardt bbc24363f1 avcodec/bsf: Unref the packet when flushing
The documentation does not require the packet to be blank in this case
(i.e. it can now contain opaque_ref), but it does contain that the
contents will be reset upon success.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-14 13:41:34 +02:00
Andreas Rheinhardt b99fb4df42 avcodec/bsf: Use null-bsf for passthrough when available
When an empty list bsf is used for passthrough, there is a check
for every packet in bsf_list_filter() before ff_bsf_get_packet_ref()
is called. Directly using the null bsf avoids that.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-14 13:41:26 +02:00
Andreas Rheinhardt 97bc4695fb avcodec/bsf: ff_list_bsf static
It is a special BSF that is only available via the av_bsf_list-API;
it is not part of the list generated from the declarations in
bitstream_filters.c and therefore needn't have external linkage.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-08 22:59:14 +02:00
Andreas Rheinhardt afeefb306e avcodec/bsf: Avoid allocation for AVBSFInternal
Do this by allocating AVBSFContext together with the data that is
currently in AVBSFInternal; or rather: Put AVBSFContext at the beginning
of a new structure called FFBSFContext (which encompasses more than just
the internal fields and is a proper context in its own right, hence the
name) and remove the AVBSFInternal altogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:54 +02:00
Gyan Doshi 301d275301 avcodec/bsf: switch to av_get_token to parse bsf list string
The recently added setts bsf makes use of the eval API whose
expressions can contain commas. The existing parsing in
av_bsf_list_parse_str() uses av_strtok to naively split
the string at commas, thus preventing the use of setts filter
with expressions containing commas.

av_get_token can work with escaped commas, allowing full use of setts.
2021-07-04 09:54:33 +05:30
James Almer 0bf3a7361d avutil: remove deprecated AVClass.child_class_next
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 11:48:04 -03:00
Andreas Rheinhardt 3e16d1c8a6 avcodec/bsf: Simplify getting codec name
All codec ids on BSF whitelists have a codec descriptor, so one can just
use avcodec_get_name() without worrying about the case of what happens
when no codec descriptor is found.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-06 03:20:59 +02:00
Andreas Rheinhardt 9bf2b32da0 avcodec/bsf: Fix segfault when freeing half-allocated BSF
When allocating a BSF fails, it could happen that the BSF's close
function has been called despite a failure to allocate the private data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-02 18:09:26 +02:00
Anton Khirnov c0d6eaca50 bsf: switch to child_class_iterate() 2020-06-10 12:36:44 +02:00
Anton Khirnov bdd6aa25c1 avcodec.h: split bitstream filters API into its own header 2020-05-22 14:38:57 +02:00
Anton Khirnov bf80725352 lavc: rename bsf.h to bsf_internal.h
This will allow adding a public header named bsf.h
2020-05-22 14:38:57 +02:00
Marton Balint 425e08d571 avcodec/bsf: support shorthand options for av_bsf_list_parse_str
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-05-02 19:14:08 +02:00
Limin Wang 56b9130fff avcodec/bsf: simplify the code
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-25 20:39:25 +02:00
Andreas Rheinhardt ee593bff98 avcodec/bsf: Use macro for "packet is empty"
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-20 18:25:02 +02:00
Marton Balint 7d89445473 avcodec/bsf: use simplified algorithm for bsf_list chained filtering
Based on the one in ffmpeg.c and it is not using an extra flush_idx variable.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-17 21:26:55 +02:00
Andreas Rheinhardt ea46b45e9c avcodec/bsf: Beautify log messages from bitstream filters
Up until now, the name of every AVBSFContext for logging purposes was
"AVBSFContext", so that the default logging callback produced output
like "[AVBSFContext @ 0x55813bae92c0] Extradata". This has been changed
to "[trace_headers @ 0x60a000000700] Extradata" by adding an item_name-
function to the AVClass for bitstream filters.

Furthermore, the correct category has been set so that the introductory
part before the actual message (everything before "Extradata" in the
above examples) are displayed in a different colour than the rest.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-03-21 18:52:45 -03:00
Andreas Rheinhardt d0ba6715d2 avcodec/bsf: Don't set defaults for AVClass without options
This happened for AVBSFContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-03-21 18:52:10 -03:00
Limin Wang ebbc976ae6 avcodec/bsf: replace ctx->internal-> with bsfi-> for better readability
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-01-04 20:59:31 +01:00
Jun Zhao 0099f71502 lavc/bsf: fix memory leak after av_dict_parse_string fail
In case of failure, all the successfully set entries are stored in
*pm. We need to manually free the created dictionary to avoid
memory leak.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-01-04 09:03:30 +08:00
James Almer d889ae3396 avcodec/bsf: check that AVBSFInternal was allocated before dereferencing it
This can happen when av_bsf_free() is called on av_bsf_alloc() failure.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2019-09-23 10:02:03 -03:00
Marton Balint 3a09dbdb4a avcodec: remove some dead assignments
Signed-off-by: Marton Balint <cus@passwd.hu>
2019-08-22 21:38:41 +02:00
James Almer 674b59c075 avcodec/bsf_list: implement a AVBSFContext.flush callback
Signed-off-by: James Almer <jamrial@gmail.com>
2019-01-06 15:11:59 -03:00
James Almer b33f5299a5 avcodec/bsf: add a flushing mechanism to AVBSFContext
Meant to reset the internal bsf state without the need to reinitialize it.

Signed-off-by: James Almer <jamrial@gmail.com>
2018-08-16 23:43:10 -03:00
James Almer 265ec55983 avcodec/bsf: use av_packet_make_refcounted to ensure packets are ref counted
Simplifies code.

Signed-off-by: James Almer <jamrial@gmail.com>
2018-04-02 00:37:46 -03:00
James Almer ed1f08bfb5 avcodec/bsf: make sure the AVBSFInternal stored packet is reference counted
Some bitstream filters may buffer said packet in their own contexts
for latter use. The documentation for av_bsf_send_packet() doesn't
forbid feeding it non-reference counted packets, which depending on
the way said packets were internally buffered by the bsf it may
result in the data described in them becoming invalid or unavailable
at any time.
This was the case with vp9_superframe after commit e1bc3f4396, which
was then promptly fixed in 37f4a093f7 and 7a02b364b6. It is still the
case even today with vp9_reorder_raw.

With this change the bitstream filters will not have to worry how to
store or consume the packets fed to them.

Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2018-03-23 22:10:39 -03:00
Jan Sebechlebsky f92e1af844 avcodec/bsf: Check for packet payload when setting BSF EOF flag.
Set BSF EOF flag only if pkt == NULL or both data and
side data are not present in packet.

Signed-off-by: Jan Sebechlebsky <sebechlebskyjan@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2017-04-22 22:32:24 -03:00
James Almer 844a115cd3 Revert "avcodec/bsf: Forbid packet without payload in av_bsf_send_packet"
This reverts commit bfdca87ab5.

Packets with no data or side data will be valid EOF signal in an
upcoming merge.

Signed-off-by: James Almer <jamrial@gmail.com>
2017-04-22 21:52:06 -03:00
Steven Liu d9c2cfd316 avcodec/bsf: fix resource leak in av_bsf_list_parse_str
cid: 1396268
when av_strdup(str) error, the lst need release

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2017-01-11 04:09:47 +08:00
Michael Niedermayer 762bf6f4af avcodec/bsf: Fix av_bsf_list_free()
Negate null check
Fixes CID1396248

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-01-08 15:26:01 +01:00
Jan Sebechlebsky bcd1153162 libavcodec/bsfs: Fix bsf option setting
AV_OPT_SEARCH_CHILDREN flag must be passed to av_opt_set_dict()
to set options for private context.

Signed-off-by: Jan Sebechlebsky <sebechlebskyjan@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-26 02:10:42 +02:00
Jan Sebechlebsky 57503fab4f avcodec/bsf: Add custom item name function for bsf list
which will
construct string description of filter chain. This is
done using lazy-initialization, so there is no overhead
if item name is never accessed.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-21 11:54:53 +02:00
Jan Sebechlebsky b746ed70ef avcodec/bsf: Add list BSF API
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-15 14:03:46 +02:00
Jan Sebechlebsky 7ae52f8a6b avcodec/bsf: Add ff_bsf_get_packet_ref() function
Use of this function can save unnecessary malloc operation
in bitstream filter.

Signed-off-by: Jan Sebechlebsky <sebechlebskyjan@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-13 12:46:18 +02:00
Jan Sebechlebsky bfdca87ab5 avcodec/bsf: Forbid packet without payload in av_bsf_send_packet
Signed-off-by: Jan Sebechlebsky <sebechlebskyjan@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-13 10:59:50 +02:00
Jan Sebechlebsky 7d5501be1e avcodec/bsf: Set EOF flag only in pkt == NULL
Set BSF EOF flag only if pkt == NULL in av_bsf_send_packet().

Signed-off-by: Jan Sebechlebsky <sebechlebskyjan@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-13 10:59:50 +02:00
Derek Buitenhuis af9cac1be1 Merge commit '33d18982fa03feb061c8f744a4f0a9175c1f63ab'
* commit '33d18982fa03feb061c8f744a4f0a9175c1f63ab':
  lavc: add a new bitstream filtering API

Conversions-by: Hendrik Leppkes <h.leppkes@gmail.com>
Conversions-by: Derek Buitenguis <derek.buitenhuis@gmail.com>
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-17 18:47:40 +01:00
Anton Khirnov 33d18982fa lavc: add a new bitstream filtering API
Deprecate the current bitstream filtering API.
2016-03-20 08:15:01 +01:00