/* * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
enum CBSContentType { // Unit content may contain some references to other structures, but all // managed via buffer reference counting. The descriptor defines the // structure offsets of every buffer reference.
CBS_CONTENT_TYPE_INTERNAL_REFS, // Unit content is something more complex. The descriptor defines // special functions to manage the content.
CBS_CONTENT_TYPE_COMPLEX,
};
enum { // Maximum number of unit types described by the same non-range // unit type descriptor.
CBS_MAX_LIST_UNIT_TYPES = 3, // Maximum number of reference buffer offsets in any one unit.
CBS_MAX_REF_OFFSETS = 2, // Special value used in a unit type descriptor to indicate that it // applies to a large range of types rather than a set of discrete // values.
CBS_UNIT_TYPE_RANGE = -1,
};
typedefconststruct CodedBitstreamUnitTypeDescriptor { // Number of entries in the unit_types array, or the special value // CBS_UNIT_TYPE_RANGE to indicate that the range fields should be // used instead. int nb_unit_types;
union { // Array of unit types that this entry describes.
CodedBitstreamUnitType list[CBS_MAX_LIST_UNIT_TYPES]; // Start and end of unit type range, used if nb_unit_types is // CBS_UNIT_TYPE_RANGE. struct {
CodedBitstreamUnitType start;
CodedBitstreamUnitType end;
} range;
} unit_type;
// The type of content described. enum CBSContentType content_type; // The size of the structure which should be allocated to contain // the decomposed content of this type of unit.
size_t content_size;
union { // This union's state is determined by content_type: // ref for CBS_CONTENT_TYPE_INTERNAL_REFS, // complex for CBS_CONTENT_TYPE_COMPLEX. struct { // Number of entries in the ref_offsets array. // May be zero, then the structure is POD-like. int nb_offsets; // The structure must contain two adjacent elements: // type *field; // AVBufferRef *field_ref; // where field points to something in the buffer referred to by // field_ref. This offset is then set to offsetof(struct, field).
size_t offsets[CBS_MAX_REF_OFFSETS];
} ref;
// A class for the private data, used to declare private AVOptions. // This field is NULL for types that do not declare any options. // If this field is non-NULL, the first member of the filter private data // must be a pointer to AVClass. const AVClass *priv_class;
size_t priv_data_size;
// List of unit type descriptors for this codec. // Terminated by a descriptor with nb_unit_types equal to zero. const CodedBitstreamUnitTypeDescriptor *unit_types;
// Split frag->data into coded bitstream units, creating the // frag->units array. Fill data but not content on each unit. // The header argument should be set if the fragment came from // a header block, which may require different parsing for some // codecs (e.g. the AVCC header in H.264). int (*split_fragment)(CodedBitstreamContext *ctx,
CodedBitstreamFragment *frag, int header);
// Read the unit->data bitstream and decompose it, creating // unit->content. int (*read_unit)(CodedBitstreamContext *ctx,
CodedBitstreamUnit *unit);
// Write the data bitstream from unit->content into pbc. // Return value AVERROR(ENOSPC) indicates that pbc was too small. int (*write_unit)(CodedBitstreamContext *ctx,
CodedBitstreamUnit *unit,
PutBitContext *pbc);
// Return 1 when the unit should be dropped according to 'skip', // 0 otherwise. int (*discarded_unit)(CodedBitstreamContext *ctx, const CodedBitstreamUnit *unit, enum AVDiscard skip);
// Read the data from all of frag->units and assemble it into // a bitstream for the whole fragment. int (*assemble_fragment)(CodedBitstreamContext *ctx,
CodedBitstreamFragment *frag);
// Reset the codec internal state. void (*flush)(CodedBitstreamContext *ctx);
// Helper functions for read/write of common bitstream elements, including // generation of trace output. The simple functions are equivalent to // their non-simple counterparts except that their range is unrestricted // (i.e. only limited by the amount of bits used) and they lack // the ability to use subscripts.
int ff_cbs_read_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, constchar *name, constint *subscripts, uint32_t *write_to,
uint32_t range_min, uint32_t range_max);
int ff_cbs_read_simple_unsigned(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, constchar *name, uint32_t *write_to);
int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, constchar *name, constint *subscripts, uint32_t value,
uint32_t range_min, uint32_t range_max);
int ff_cbs_write_simple_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, constchar *name, uint32_t value);
int ff_cbs_read_signed(CodedBitstreamContext *ctx, GetBitContext *gbc, int width, constchar *name, constint *subscripts, int32_t *write_to,
int32_t range_min, int32_t range_max);
int ff_cbs_write_signed(CodedBitstreamContext *ctx, PutBitContext *pbc, int width, constchar *name, constint *subscripts, int32_t value,
int32_t range_min, int32_t range_max);
// The largest unsigned value representable in N bits, suitable for use as // range_max in the above functions. #define MAX_UINT_BITS(length) ((UINT64_C(1) << (length)) - 1)
// The largest signed value representable in N bits, suitable for use as // range_max in the above functions. #define MAX_INT_BITS(length) ((INT64_C(1) << ((length) - 1)) - 1)
// The smallest signed value representable in N bits, suitable for use as // range_min in the above functions. #define MIN_INT_BITS(length) (-(INT64_C(1) << ((length) - 1)))
// Start of a syntax element during read tracing. #define CBS_TRACE_READ_START() \
GetBitContext trace_start; \ do { \ if (ctx->trace_enable) \
trace_start = *gbc; \
} while (0)
// End of a syntax element for tracing, make callback. #define CBS_TRACE_READ_END() \ do { \ if (ctx->trace_enable) { \ int start_position = get_bits_count(&trace_start); \ int end_position = get_bits_count(gbc); \
av_assert0(start_position <= end_position); \
ctx->trace_read_callback(ctx->trace_context, &trace_start, \
end_position - start_position, \
name, subscripts, value); \
} \
} while (0)
// End of a syntax element with no subscript entries. #define CBS_TRACE_READ_END_NO_SUBSCRIPTS() \ do { \ constint *subscripts = NULL; \
CBS_TRACE_READ_END(); \
} while (0)
// End of a syntax element which is made up of subelements which // are aleady traced, so we are only showing the value. #define CBS_TRACE_READ_END_VALUE_ONLY() \ do { \ if (ctx->trace_enable) { \
ctx->trace_read_callback(ctx->trace_context, &trace_start, 0, \
name, subscripts, value); \
} \
} while (0)
// Start of a syntax element during write tracing. #define CBS_TRACE_WRITE_START() \ int start_position; \ do { \ if (ctx->trace_enable) \
start_position = put_bits_count(pbc);; \
} while (0)
// End of a syntax element for tracing, make callback. #define CBS_TRACE_WRITE_END() \ do { \ if (ctx->trace_enable) { \ int end_position = put_bits_count(pbc); \
av_assert0(start_position <= end_position); \
ctx->trace_write_callback(ctx->trace_context, pbc, \
end_position - start_position, \
name, subscripts, value); \
} \
} while (0)
// End of a syntax element with no subscript entries. #define CBS_TRACE_WRITE_END_NO_SUBSCRIPTS() \ do { \ constint *subscripts = NULL; \
CBS_TRACE_WRITE_END(); \
} while (0)
// End of a syntax element which is made up of subelements which are // aleady traced, so we are only showing the value. This forges a // PutBitContext to point to the position of the start of the syntax // element, but the other state doesn't matter because length is zero. #define CBS_TRACE_WRITE_END_VALUE_ONLY() \ do { \ if (ctx->trace_enable) { \
PutBitContext tmp; \
init_put_bits(&tmp, pbc->buf, start_position); \
skip_put_bits(&tmp, start_position); \
ctx->trace_write_callback(ctx->trace_context, &tmp, 0, \
name, subscripts, value); \
} \
} while (0)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.