Commit | Line | Data |
---|---|---|
2ba45a60 DM |
1 | /* |
2 | * Copyright (c) 2014 Tim Walker <tdskywalker@gmail.com> | |
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 | /** | |
22 | * @file | |
23 | * internal header for HEVC (de)muxer utilities | |
24 | */ | |
25 | ||
26 | #ifndef AVFORMAT_HEVC_H | |
27 | #define AVFORMAT_HEVC_H | |
28 | ||
29 | #include <stdint.h> | |
30 | #include "avio.h" | |
31 | ||
32 | /** | |
33 | * Writes Annex B formatted HEVC NAL units to the provided AVIOContext. | |
34 | * | |
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). | |
37 | * | |
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. | |
40 | * | |
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 | |
50 | */ | |
51 | int ff_hevc_annexb2mp4(AVIOContext *pb, const uint8_t *buf_in, | |
52 | int size, int filter_ps, int *ps_count); | |
53 | ||
54 | /** | |
55 | * Writes Annex B formatted HEVC NAL units to a data buffer. | |
56 | * | |
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). | |
59 | * | |
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. | |
62 | * | |
63 | * On output, *size holds the size (in bytes) of the output data buffer. | |
64 | * | |
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 output) | |
68 | * @param buf_out address of the variable holding the address of the output | |
69 | * buffer | |
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 the amount (in bytes) of data written in case of success, a negative | |
75 | * value corresponding to an AVERROR code in case of failure | |
76 | */ | |
77 | int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out, | |
78 | int *size, int filter_ps, int *ps_count); | |
79 | ||
80 | /** | |
81 | * Writes HEVC extradata (parameter sets, declarative SEI NAL units) to the | |
82 | * provided AVIOContext. | |
83 | * | |
84 | * If the extradata is Annex B format, it gets converted to hvcC format before | |
85 | * writing. | |
86 | * | |
87 | * @param pb address of the AVIOContext where the hvcC shall be written | |
88 | * @param data address of the buffer holding the data needed to write the hvcC | |
89 | * @param size size (in bytes) of the data buffer | |
90 | * @param ps_array_completeness whether all parameter sets are in the hvcC (1) | |
91 | * or there may be additional parameter sets in the bitstream (0) | |
92 | * @return >=0 in case of success, a negative value corresponding to an AVERROR | |
93 | * code in case of failure | |
94 | */ | |
95 | int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data, | |
96 | int size, int ps_array_completeness); | |
97 | ||
98 | #endif /* AVFORMAT_HEVC_H */ |