FFmpeg
Loading...
Searching...
No Matches
hevc.h
Go to the documentation of this file.
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 */
51int 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 success, *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 success)
68 * @param buf_out on success, address of the variable holding the address of
69 * the output 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 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.
77 */
78int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out,
79 int *size, int filter_ps, int *ps_count);
80
81/**
82 * Writes HEVC extradata (parameter sets and declarative SEI NAL units with
83 * nuh_layer_id == 0, as a HEVCDecoderConfigurationRecord) to the
84 * provided AVIOContext.
85 *
86 * If the extradata is Annex B format, it gets converted to hvcC format before
87 * writing.
88 *
89 * @param pb address of the AVIOContext where the hvcC shall be written
90 * @param data address of the buffer holding the data needed to write the hvcC
91 * @param size size (in bytes) of the data buffer
92 * @param ps_array_completeness whether all parameter sets are in the hvcC (1)
93 * or there may be additional parameter sets in the bitstream (0)
94 * @param logctx opaque struct starting with an AVClass element, used for logging
95 * @return >=0 in case of success, a negative value corresponding to an AVERROR
96 * code in case of failure
97 */
98int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data,
99 int size, int ps_array_completeness, void *logctx);
100
101/**
102 * Writes L-HEVC extradata (parameter sets with nuh_layer_id > 0, as a
103 * LHEVCDecoderConfigurationRecord) to the provided AVIOContext.
104 *
105 * If the extradata is Annex B format, it gets converted to lhvC format before
106 * writing. Otherwise, hvcC formatted extradata is expected, not lhvC.
107 *
108 * @param pb address of the AVIOContext where the lhvC shall be written
109 * @param data address of the buffer holding the data needed to write the lhvC
110 * @param size size (in bytes) of the data buffer
111 * @param ps_array_completeness whether all parameter sets are in the lhvC (1)
112 * or there may be additional parameter sets in the bitstream (0)
113 * @param logctx opaque struct starting with an AVClass element, used for logging
114 * @return >=0 in case of success, a negative value corresponding to an AVERROR
115 * code in case of failure
116 */
117int ff_isom_write_lhvc(AVIOContext *pb, const uint8_t *data,
118 int size, int ps_array_completeness, void *logctx);
119#endif /* AVFORMAT_HEVC_H */
Buffered I/O operations.
int ff_isom_write_lhvc(AVIOContext *pb, const uint8_t *data, int size, int ps_array_completeness, void *logctx)
Writes L-HEVC extradata (parameter sets with nuh_layer_id > 0, as a LHEVCDecoderConfigurationRecord) ...
Definition hevc.c:1408
int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out, int *size, int filter_ps, int *ps_count)
Writes Annex B formatted HEVC NAL units to a data buffer.
Definition hevc.c:1252
int ff_hevc_annexb2mp4(AVIOContext *pb, const uint8_t *buf_in, int size, int filter_ps, int *ps_count)
Writes Annex B formatted HEVC NAL units to the provided AVIOContext.
Definition hevc.c:1204
int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data, int size, int ps_array_completeness, void *logctx)
Writes HEVC extradata (parameter sets and declarative SEI NAL units with nuh_layer_id == 0,...
Definition hevc.c:1401
const char data[16]
Definition mxf.c:149
Bytestream IO Context.
Definition avio.h:160
int size