49 for (i = 0; i <
len; i++)
58 static const int extradata_nal_types_hevc[] = {
61 static const int extradata_nal_types_h264[] = {
67 int extradata_size = 0, filtered_size = 0;
68 const int *extradata_nal_types;
69 int nb_extradata_nal_types;
70 int i, has_sps = 0, has_vps = 0, ret = 0;
73 extradata_nal_types = extradata_nal_types_hevc;
76 extradata_nal_types = extradata_nal_types_h264;
100 if (extradata_size &&
104 uint8_t *extradata, *filtered_data;
113 filtered_data = filtered_buf->
data;
124 *size = extradata_size;
128 if (
val_in_array(extradata_nal_types, nb_extradata_nal_types,
142 pkt->
buf = filtered_buf;
144 pkt->
size = filtered_size;
156 uint32_t
state = UINT32_MAX;
157 int has_extradata = 0, extradata_size = 0;
163 }
else if (has_extradata &&
IS_MARKER(state)) {
164 extradata_size = ptr - 4 - pkt->
data;
169 if (extradata_size) {
174 memcpy(*data, pkt->
data, extradata_size);
176 *size = extradata_size;
179 pkt->
data += extradata_size;
180 pkt->
size -= extradata_size;
191 uint32_t
state = UINT32_MAX;
194 for (i = 0; i < pkt->
size; i++) {
195 state = (state << 8) | pkt->
data[i];
198 else if (found && state != 0x1B5 && state < 0x200 && state >= 0x100) {
205 memcpy(*data, pkt->
data, *size);
224 uint32_t
state = UINT32_MAX;
228 if (state == 0x1B3 || state == 0x1B6) {
229 if (ptr - pkt->
data > 4) {
230 *size = ptr - 4 - pkt->
data;
235 memcpy(*data, pkt->
data, *size);
249 static const struct {
291 ret = s->
extract(ctx, pkt, &extradata, &extradata_size);
297 extradata, extradata_size);
328 #define OFFSET(x) offsetof(ExtractExtradataContext, x) 329 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM) 332 { .i64 = 0 }, 0, 1,
FLAGS },
344 .
name =
"extract_extradata",
347 .priv_class = &extract_extradata_class,
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, void *logctx, int is_nalff, int nal_length_size, enum AVCodecID codec_id, int small_padding)
Split an input packet into NAL units.
const char const char void * val
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
#define LIBAVUTIL_VERSION_INT
static av_cold int init(AVCodecContext *avctx)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
The bitstream filter state.
const char * av_default_item_name(void *ptr)
Return the context name.
void * priv_data
Opaque filter-specific private data.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride, int16_t *high, ptrdiff_t high_stride, int len, int clip)
static av_cold int end(AVCodecContext *avctx)
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
const uint8_t * avpriv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state)
H.264 common definitions.
AVCodecID
Identify the syntax and semantics of the bitstream.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
preferred ID for MPEG-1/2 video decoding
#define FF_ARRAY_ELEMS(a)
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
Libavcodec external API header.
AVBufferRef * av_buffer_alloc(int size)
Allocate an AVBuffer of the given size using av_malloc().
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
uint8_t * data
The data buffer.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Describe the class of an AVClass context structure.
int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t *data, size_t size)
Wrap an existing array as a packet side data.
A reference to a data buffer.
common internal and external API header
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
This structure stores compressed data.
AVCodecParameters * par_in
Parameters of the input stream.
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
Called by bitstream filters to get packet for filtering.