FFmpeg
Loading...
Searching...
No Matches
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
27typedef struct NALU {
28 int offset;
29 uint32_t size;
30} NALU;
31
32typedef 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 */
49int 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. */
53void ff_nal_units_write_list(const NALUList *list, AVIOContext *pb,
54 const uint8_t *buf);
55
56const uint8_t *ff_nal_find_startcode(const uint8_t *p, const uint8_t *end);
57const uint8_t *ff_nal_mp4_find_startcode(const uint8_t *start,
58 const uint8_t *end,
59 int nal_length_size);
60
61int ff_nal_parse_units(AVIOContext *s, const uint8_t *buf, int size);
62int ff_nal_parse_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size);
63
64uint8_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 */
Buffered I/O operations.
#define s(width, name)
Definition cbs_vp9.c:198
void ff_nal_units_write_list(const NALUList *list, AVIOContext *pb, const uint8_t *buf)
Definition nal.c:124
int ff_nal_parse_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
Definition nal.c:133
int ff_nal_parse_units(AVIOContext *s, const uint8_t *buf, int size)
Definition nal.c:113
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:163
int ff_nal_units_create_list(NALUList *list, const uint8_t *buf, int size)
Definition nal.c:118
const uint8_t * ff_nal_mp4_find_startcode(const uint8_t *start, const uint8_t *end, int nal_length_size)
Definition nal.c:146
const uint8_t * ff_nal_find_startcode(const uint8_t *p, const uint8_t *end)
Definition nal.c:68
Bytestream IO Context.
Definition avio.h:160
Definition evc.c:73
unsigned nb_nalus
valid entries in nalus
Definition evc.c:76
unsigned nalus_array_size
Definition evc.c:75
NALU * nalus
Definition evc.c:74
Definition evc.c:68
int offset
Definition evc.c:69
uint32_t size
Definition evc.c:70
#define src
Definition vp8dsp.c:248
int size