61 for (pass = 1; pass <= 2; pass++) {
62 long value, range_start, range_end;
67 for (str = list_string; *str;) {
68 value = strtol(str, &value_end, 0);
71 str = (
const char *)value_end;
75 range_end = strtol(str, &value_end, 0);
118 if (
ctx->passthrough)
121 err = ff_cbs_read_packet(
ctx->cbc, frag,
pkt);
127 ff_cbs_discard_units(
ctx->cbc, frag,
ctx->discard,
ctx->discard_flags);
128 if (
ctx->mode != NOOP) {
130 for (j = 0; j <
ctx->nb_types; j++) {
134 if (
ctx->mode == REMOVE ? j < ctx->nb_types
135 : j >=
ctx->nb_types)
136 ff_cbs_delete_unit(frag,
i);
146 err = ff_cbs_write_packet(
ctx->cbc,
pkt, frag);
155 ff_cbs_fragment_reset(frag);
165 if (
ctx->pass_types &&
ctx->remove_types) {
167 "remove_types is required.\n");
171 if (
ctx->pass_types) {
174 &
ctx->type_list, &
ctx->nb_types);
179 }
else if (
ctx->remove_types) {
182 &
ctx->type_list, &
ctx->nb_types);
188 ctx->passthrough =
true;
198 ctx->cbc->decompose_unit_types =
ctx->type_list;
199 ctx->cbc->nb_decompose_unit_types = 0;
205 err = ff_cbs_read_extradata(
ctx->cbc, frag, bsf->
par_in);
209 err = ff_cbs_write_extradata(
ctx->cbc, bsf->
par_out, frag);
214 ff_cbs_fragment_reset(frag);
226 ff_cbs_fragment_free(&
ctx->fragment);
227 ff_cbs_close(&
ctx->cbc);
230#define OFFSET(x) offsetof(FilterUnitsContext, x)
231#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
233 {
"pass_types",
"List of unit types to pass through the filter.",
236 {
"remove_types",
"List of unit types to remove in the filter.",
240 {
"discard",
"Remove the selected frames",
243 {
"none" ,
"discard none",
246 {
"default" ,
"discard none, but can be changed after dynamically",
249 {
"nonref",
"discard all non-reference frames",
252 {
"bidir",
"discard all bidirectional frames",
255 {
"nonintra",
"discard all frames except I frames",
258 {
"nonkey",
"discard all frames except keyframes",
261 {
"all",
"discard all frames",
265 {
"discard_flags",
"flags to control the discard frame behavior",
268 {
"keep_non_vcl",
"non-vcl units even if the picture has been dropped",
275 .class_name =
"filter_units",
282 .p.name =
"filter_units",
static AVFormatContext * ctx
static av_cold void close(AVCodecParserContext *s)
const FFBitStreamFilter ff_filter_units_bsf
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
Called by bitstream filters to get packet for filtering.
enum AVCodecID ff_cbs_all_codec_ids[]
Table of all supported codec IDs.
#define i(width, name, range_min, range_max)
int(* init)(AVBSFContext *ctx)
static int filter_units_make_type_list(const char *list_string, CodedBitstreamUnitType **type_list, int *nb_types)
static int filter_units_filter(AVBSFContext *bsf, AVPacket *pkt)
static int filter_units_init(AVBSFContext *bsf)
static void filter_units_close(AVBSFContext *bsf)
static const AVClass filter_units_class
static const AVOption filter_units_options[]
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
@ AVDISCARD_ALL
discard all
@ AVDISCARD_NONKEY
discard all frames except keyframes
@ AVDISCARD_BIDIR
discard all bidirectional frames
@ AVDISCARD_DEFAULT
discard useless packets like 0 size packets in avi
@ AVDISCARD_NONE
discard nothing
@ AVDISCARD_NONINTRA
discard all non intra frames
@ AVDISCARD_NONREF
discard all non reference
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
#define LIBAVUTIL_VERSION_INT
@ DISCARD_FLAG_KEEP_NON_VCL
keep non-vcl units even if the picture has been dropped.
uint32_t CodedBitstreamUnitType
The codec-specific type of a bitstream unit.
Memory handling functions.
The bitstream filter state.
void * priv_data
Opaque filter-specific private data.
AVCodecParameters * par_in
Parameters of the input stream.
AVCodecParameters * par_out
Parameters of the output stream.
Describe the class of an AVClass context structure.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
Context structure for coded bitstream operations.
Coded bitstream fragment structure, combining one or more units.
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
int nb_units
Number of units in this fragment.
CodedBitstreamUnitType type
Codec-specific type of this unit.
CodedBitstreamFragment fragment
CodedBitstreamUnitType * type_list
const char * remove_types
CodedBitstreamContext * cbc
#define av_malloc_array(a, b)
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)