2 * NAL helper functions for muxers
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef AVFORMAT_NAL_H
22 #define AVFORMAT_NAL_H
32 typedef struct NALUList
{
34 unsigned nalus_array_size
;
35 unsigned nb_nalus
; ///< valid entries in nalus
38 /* This function will parse the given annex B buffer and create
39 * a NALUList from it. This list can be passed to ff_nal_units_write_list()
40 * to write the access unit reformatted to mp4.
42 * @param list A NALUList. The list->nalus and list->nalus_array_size
43 * must be valid when calling this function and may be updated.
44 * nb_nalus is set by this function on success.
45 * @param buf buffer containing annex B H.264 or H.265. Must be padded.
46 * @param size size of buf, excluding padding.
47 * @return < 0 on error, the size of the mp4-style packet on success.
49 int ff_nal_units_create_list(NALUList
*list
, const uint8_t *buf
, int size
);
51 /* Writes a NALUList to the specified AVIOContext. The list must originate
52 * from ff_nal_units_create_list() with the same buf. */
53 void ff_nal_units_write_list(const NALUList
*list
, AVIOContext
*pb
,
56 const uint8_t *ff_nal_find_startcode(const uint8_t *p
, const uint8_t *end
);
57 const uint8_t *ff_nal_mp4_find_startcode(const uint8_t *start
,
61 int ff_nal_parse_units(AVIOContext
*s
, const uint8_t *buf
, int size
);
62 int ff_nal_parse_units_buf(const uint8_t *buf_in
, uint8_t **buf
, int *size
);
64 uint8_t *ff_nal_unit_extract_rbsp(const uint8_t *src
, uint32_t src_len
,
65 uint32_t *dst_len
, int header_len
);
67 #endif /* AVFORMAT_NAL_H */