FFmpeg
nal.h
Go to the documentation of this file.
1 /*
2  * NAL helper functions for muxers
3  *
4  * This file is part of FFmpeg.
5  *
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.
10  *
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.
15  *
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
19  */
20 
21 #ifndef AVFORMAT_NAL_H
22 #define AVFORMAT_NAL_H
23 
24 #include <stdint.h>
25 #include "avio.h"
26 
27 typedef struct NALU {
28  int offset;
29  uint32_t size;
30 } NALU;
31 
32 typedef struct NALUList {
33  NALU *nalus;
34  unsigned nalus_array_size;
35  unsigned nb_nalus; ///< valid entries in nalus
36 } NALUList;
37 
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.
41  *
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.
48  */
49 int ff_nal_units_create_list(NALUList *list, const uint8_t *buf, int size);
50 
51 /* Writes a NALUList to the specified AVIOContext. The list must originate
52  * from ff_nal_units_create_list() with the same buf. */
54  const uint8_t *buf);
55 
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,
58  const uint8_t *end,
59  int nal_length_size);
60 
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);
63 
64 uint8_t *ff_nal_unit_extract_rbsp(const uint8_t *src, uint32_t src_len,
65  uint32_t *dst_len, int header_len);
66 
67 #endif /* AVFORMAT_NAL_H */
ff_nal_find_startcode
const uint8_t * ff_nal_find_startcode(const uint8_t *p, const uint8_t *end)
Definition: nal.c:68
NALUList::nalus_array_size
unsigned nalus_array_size
Definition: evc.c:75
NALU::offset
int offset
Definition: evc.c:69
NALU::size
uint32_t size
Definition: evc.c:70
s
#define s(width, name)
Definition: cbs_vp9.c:198
NALUList::nalus
NALU * nalus
Definition: evc.c:74
NALUList::nb_nalus
unsigned nb_nalus
valid entries in nalus
Definition: evc.c:76
list
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
Definition: filter_design.txt:25
AVIOContext
Bytestream IO Context.
Definition: avio.h:160
ff_nal_parse_units
int ff_nal_parse_units(AVIOContext *s, const uint8_t *buf, int size)
Definition: nal.c:110
size
int size
Definition: twinvq_data.h:10344
avio.h
ff_nal_units_write_list
void ff_nal_units_write_list(const NALUList *list, AVIOContext *pb, const uint8_t *buf)
Definition: nal.c:121
NALU
Definition: evc.c:68
NALUList
Definition: evc.c:73
ff_nal_unit_extract_rbsp
uint8_t * ff_nal_unit_extract_rbsp(const uint8_t *src, uint32_t src_len, uint32_t *dst_len, int header_len)
Definition: nal.c:160
ff_nal_units_create_list
int ff_nal_units_create_list(NALUList *list, const uint8_t *buf, int size)
Definition: nal.c:115
ff_nal_mp4_find_startcode
const uint8_t * ff_nal_mp4_find_startcode(const uint8_t *start, const uint8_t *end, int nal_length_size)
Definition: nal.c:143
src
#define src
Definition: vp8dsp.c:248
ff_nal_parse_units_buf
int ff_nal_parse_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
Definition: nal.c:130