Go to the documentation of this file.
32 const uint8_t *
a = p + 4 - ((intptr_t)p & 3);
34 for (end -= 3; p <
a && p < end; p++) {
35 if (p[0] == 0 && p[1] == 0 && p[2] == 1)
39 for (end -= 3; p < end; p += 4) {
40 uint32_t x = *(
const uint32_t*)p;
43 if ((x - 0x01010101) & (~x) & 0x80808080) {
45 if (p[0] == 0 && p[2] == 1)
47 if (p[2] == 0 && p[3] == 1)
51 if (p[2] == 0 && p[4] == 1)
53 if (p[4] == 0 && p[5] == 1)
59 for (end += 3; p < end; p++) {
60 if (p[0] == 0 && p[1] == 0 && p[2] == 1)
74 const uint8_t *buf_in,
int size)
76 const uint8_t *p = buf_in;
77 const uint8_t *end = p +
size;
78 const uint8_t *nal_start, *nal_end;
83 const size_t nalu_limit = SIZE_MAX /
sizeof(*
list->nalus);
84 while (nal_start < end && !*(nal_start++));
91 avio_write(pb, nal_start, nal_end - nal_start);
92 }
else if (
list->nb_nalus >= nalu_limit) {
96 (
list->nb_nalus + 1) *
sizeof(*
list->nalus));
100 tmp[
list->nb_nalus++] = (
NALU){ .offset = nal_start - p,
101 .size = nal_end - nal_start };
103 size += 4 + nal_end - nal_start;
123 for (
unsigned i = 0;
i <
list->nb_nalus;
i++) {
145 uint8_t *buf, *end, *start;
146 uint8_t *
sps, *
pps, *sps_ext;
147 uint32_t sps_size = 0, pps_size = 0, sps_ext_size = 0;
148 int ret, nb_sps = 0, nb_pps = 0, nb_sps_ext = 0;
177 while (end - buf > 4) {
182 nal_type = buf[0] & 0x1f;
192 }
else if (nal_type == 8) {
200 }
else if (nal_type == 13) {
202 if (
size > UINT16_MAX || nb_sps_ext >= 256) {
216 if (sps_size < 6 || !pps_size) {
232 if (
sps[3] != 66 &&
sps[3] != 77 &&
sps[3] != 88) {
257 uint16_t sps_size, pps_size;
264 if (*
size < 11 || in[0] != 1)
268 if (11 + sps_size > *
size)
270 pps_size =
AV_RB16(&in[9 + sps_size]);
271 if (11 + sps_size + pps_size > *
size)
278 memcpy(
out + 4, &in[8], sps_size);
280 memcpy(
out + 8 + sps_size, &in[11 + sps_size], pps_size);
290 unsigned int res = 0;
292 if (end - start < nal_length_size)
294 while (nal_length_size--)
295 res = (res << 8) | *start++;
297 if (res > end - start)
304 uint32_t *dst_len,
int header_len)
315 while (
i < header_len &&
i < src_len)
318 while (
i + 2 < src_len)
365 return ((v >> 1) ^ sign) - sign;
370 int i, j,
ret, rbsp_size, aspect_ratio_idc, pic_order_cnt_type;
371 int num_ref_frames_in_pic_order_cnt_cycle;
372 int delta_scale, lastScale = 8, nextScale = 8;
373 int sizeOfScalingList;
385 memset(
sps, 0,
sizeof(*
sps));
398 if (
sps->profile_idc == 100 ||
sps->profile_idc == 110 ||
399 sps->profile_idc == 122 ||
sps->profile_idc == 244 ||
sps->profile_idc == 44 ||
400 sps->profile_idc == 83 ||
sps->profile_idc == 86 ||
sps->profile_idc == 118 ||
401 sps->profile_idc == 128 ||
sps->profile_idc == 138 ||
sps->profile_idc == 139 ||
402 sps->profile_idc == 134) {
404 if (
sps->chroma_format_idc == 3) {
411 for (
i = 0;
i < ((
sps->chroma_format_idc != 3) ? 8 : 12);
i++) {
416 sizeOfScalingList =
i < 6 ? 16 : 64;
417 for (j = 0; j < sizeOfScalingList; j++) {
418 if (nextScale != 0) {
420 nextScale = (lastScale + delta_scale) & 0xff;
422 lastScale = nextScale == 0 ? lastScale : nextScale;
427 sps->chroma_format_idc = 1;
428 sps->bit_depth_luma = 8;
429 sps->bit_depth_chroma = 8;
435 if (pic_order_cnt_type == 0) {
437 }
else if (pic_order_cnt_type == 1) {
442 for (
i = 0;
i < num_ref_frames_in_pic_order_cnt_cycle;
i++)
452 if (!
sps->frame_mbs_only_flag)
466 aspect_ratio_idc =
get_bits(&gb, 8);
467 if (aspect_ratio_idc == 0xff) {
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int ff_nal_units_create_list(NALUList *list, const uint8_t *buf, int size)
static int avc_parse_nal_units(AVIOContext *pb, NALUList *list, const uint8_t *buf_in, int size)
int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
int ff_avc_decode_sps(H264SPS *sps, const uint8_t *buf, int buf_size)
static int get_se_golomb(GetBitContext *gb)
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
#define FF_ARRAY_ELEMS(a)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
uint8_t * ff_nal_unit_extract_rbsp(const uint8_t *src, uint32_t src_len, uint32_t *dst_len, int header_len)
static const AVRational avc_sample_aspect_ratio[17]
Rational number (pair of numerator and denominator).
static int get_ue_golomb(GetBitContext *gb)
static unsigned int get_bits1(GetBitContext *s)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining list
int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
void avio_w8(AVIOContext *s, int b)
void ff_nal_units_write_list(const NALUList *list, AVIOContext *pb, const uint8_t *buf)
int ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size)
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
void avio_wb32(AVIOContext *s, unsigned int val)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
static void skip_bits1(GetBitContext *s)
#define i(width, name, range_min, range_max)
uint8_t chroma_format_idc
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static const uint8_t * avc_find_startcode_internal(const uint8_t *p, const uint8_t *end)
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
#define AV_INPUT_BUFFER_PADDING_SIZE
int ff_avc_write_annexb_extradata(const uint8_t *in, uint8_t **buf, int *size)
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
void avio_wb16(AVIOContext *s, unsigned int val)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
const uint8_t * ff_avc_mp4_find_startcode(const uint8_t *start, const uint8_t *end, int nal_length_size)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
const uint8_t * ff_avc_find_startcode(const uint8_t *p, const uint8_t *end)