2 * Copyright (c) 2014 Tim Walker <tdskywalker@gmail.com>
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
23 * internal header for HEVC (de)muxer utilities
26 #ifndef AVFORMAT_HEVC_H
27 #define AVFORMAT_HEVC_H
33 * Writes Annex B formatted HEVC NAL units to the provided AVIOContext.
35 * The NAL units are converted to an MP4-compatible format (start code prefixes
36 * are replaced by 4-byte size fields, as per ISO/IEC 14496-15).
38 * If filter_ps is non-zero, any HEVC parameter sets found in the input will be
39 * discarded, and *ps_count will be set to the number of discarded PS NAL units.
41 * @param pb address of the AVIOContext where the data shall be written
42 * @param buf_in address of the buffer holding the input data
43 * @param size size (in bytes) of the input buffer
44 * @param filter_ps whether to write parameter set NAL units to the output (0)
45 * or to discard them (non-zero)
46 * @param ps_count address of the variable where the number of discarded
47 * parameter set NAL units shall be written, may be NULL
48 * @return the amount (in bytes) of data written in case of success, a negative
49 * value corresponding to an AVERROR code in case of failure
51 int ff_hevc_annexb2mp4(AVIOContext *pb, const uint8_t *buf_in,
52 int size, int filter_ps, int *ps_count);
55 * Writes Annex B formatted HEVC NAL units to a data buffer.
57 * The NAL units are converted to an MP4-compatible format (start code prefixes
58 * are replaced by 4-byte size fields, as per ISO/IEC 14496-15).
60 * If filter_ps is non-zero, any HEVC parameter sets found in the input will be
61 * discarded, and *ps_count will be set to the number of discarded PS NAL units.
63 * On success, *size holds the size (in bytes) of the output data buffer.
65 * @param buf_in address of the buffer holding the input data
66 * @param size address of the variable holding the size (in bytes) of the input
67 * buffer (on input) and of the output buffer (on success)
68 * @param buf_out on success, address of the variable holding the address of
70 * @param filter_ps whether to write parameter set NAL units to the output (0)
71 * or to discard them (non-zero)
72 * @param ps_count address of the variable where the number of discarded
73 * parameter set NAL units shall be written, may be NULL
74 * @return 0 in case of success, a negative value corresponding to an AVERROR
75 * code in case of failure
76 * @note *buf_out will be treated as uninitialized on input and won't be freed.
78 int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out,
79 int *size, int filter_ps, int *ps_count);
82 * Writes HEVC extradata (parameter sets, declarative SEI NAL units) to the
83 * provided AVIOContext.
85 * If the extradata is Annex B format, it gets converted to hvcC format before
88 * @param pb address of the AVIOContext where the hvcC shall be written
89 * @param data address of the buffer holding the data needed to write the hvcC
90 * @param size size (in bytes) of the data buffer
91 * @param ps_array_completeness whether all parameter sets are in the hvcC (1)
92 * or there may be additional parameter sets in the bitstream (0)
93 * @return >=0 in case of success, a negative value corresponding to an AVERROR
94 * code in case of failure
96 int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data,
97 int size, int ps_array_completeness);
99 #endif /* AVFORMAT_HEVC_H */