History

lavc: move small misc definitions into a separate header

This will allow to avoid #including the entire avcodec.h in some places.

Anton Khirnov committed 5 years ago

Commit ff0a9601 parent cf1746d4 files · +182 −138Browse files

Unified · Split

4 files
  1. doc/APIchanges +10 −0
  2. libavcodec/Makefile +1 −0
  3. libavcodec/avcodec.h +1 −138
  4. libavcodec/defs.h +170 −0
doc/APIchanges+10−0
@@ -14,6 +14,16 @@ libavutil: 2021-04-27 · 13 unmodified lines
14 14
15API changes, most recent first:15API changes, most recent first:
16 16
172021-xx-xx - xxxxxxxxxx - lavc 59.1.100 - avcodec.h defs.h
18 Add new installed header defs.h. The following definitions are moved
19 into it from avcodec.h:
20 - AVDiscard
21 - AVAudioServiceType
22 - AVPanScan
23 - AVCPBProperties and av_cpb_properties_alloc()
24 - AVProducerReferenceTime
25 - av_xiphlacing()
26
172021-04-27 - cb3ac722f4 - lavc 59.0.100 - avcodec.h272021-04-27 - cb3ac722f4 - lavc 59.0.100 - avcodec.h
18 Constified AVCodecParserContext.parser.28 Constified AVCodecParserContext.parser.
19 29
libavcodec/Makefile+1−0
@@ -12,6 +12,7 @@ HEADERS = ac3_parser.h \ · 11 unmodified lines
12 codec_id.h \12 codec_id.h \
13 codec_par.h \13 codec_par.h \
14 d3d11va.h \14 d3d11va.h \
15 defs.h \
15 dirac.h \16 dirac.h \
16 dv_profile.h \17 dv_profile.h \
17 dxva2.h \18 dxva2.h \
libavcodec/avcodec.h+1−138
@@ -46,6 +46,7 @@ · 45 unmodified lines
46#include "codec_desc.h"46#include "codec_desc.h"
47#include "codec_par.h"47#include "codec_par.h"
48#include "codec_id.h"48#include "codec_id.h"
49#include "defs.h"
49#include "packet.h"50#include "packet.h"
50#include "version.h"51#include "version.h"
51 52
@@ -181,16 +182,6 @@ · 129 unmodified lines
181 * @{182 * @{
182 */183 */
183 184
184/**
185 * @ingroup lavc_decoding
186 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
187 * This is mainly needed because some optimized bitstream readers read
188 * 32 or 64 bit at once and could read over the end.<br>
189 * Note: If the first 23 bits of the additional bytes are not 0, then damaged
190 * MPEG bitstreams could cause overread and segfault.
191 */
192#define AV_INPUT_BUFFER_PADDING_SIZE 64
193
194/**185/**
195 * @ingroup lavc_encoding186 * @ingroup lavc_encoding
196 * minimum encoding buffer size187 * minimum encoding buffer size
@@ -198,34 +189,6 @@ · 1 unmodified line
198 */189 */
199#define AV_INPUT_BUFFER_MIN_SIZE 16384190#define AV_INPUT_BUFFER_MIN_SIZE 16384
200 191
201/**
202 * @ingroup lavc_decoding
203 */
204enum AVDiscard{
205 /* We leave some space between them for extensions (drop some
206 * keyframes for intra-only or drop just some bidir frames). */
207 AVDISCARD_NONE =-16, ///< discard nothing
208 AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi
209 AVDISCARD_NONREF = 8, ///< discard all non reference
210 AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
211 AVDISCARD_NONINTRA= 24, ///< discard all non intra frames
212 AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
213 AVDISCARD_ALL = 48, ///< discard all
214};
215
216enum AVAudioServiceType {
217 AV_AUDIO_SERVICE_TYPE_MAIN = 0,
218 AV_AUDIO_SERVICE_TYPE_EFFECTS = 1,
219 AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
220 AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3,
221 AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4,
222 AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5,
223 AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6,
224 AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7,
225 AV_AUDIO_SERVICE_TYPE_KARAOKE = 8,
226 AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI
227};
228
229/**192/**
230 * @ingroup lavc_encoding193 * @ingroup lavc_encoding
231 */194 */
@@ -393,86 +356,6 @@ typedef struct RcOverride{ · 161 unmodified lines
393 */356 */
394#define AV_CODEC_EXPORT_DATA_FILM_GRAIN (1 << 3)357#define AV_CODEC_EXPORT_DATA_FILM_GRAIN (1 << 3)
395 358
396/**
397 * Pan Scan area.
398 * This specifies the area which should be displayed.
399 * Note there may be multiple such areas for one frame.
400 */
401typedef struct AVPanScan {
402 /**
403 * id
404 * - encoding: Set by user.
405 * - decoding: Set by libavcodec.
406 */
407 int id;
408
409 /**
410 * width and height in 1/16 pel
411 * - encoding: Set by user.
412 * - decoding: Set by libavcodec.
413 */
414 int width;
415 int height;
416
417 /**
418 * position of the top left corner in 1/16 pel for up to 3 fields/frames
419 * - encoding: Set by user.
420 * - decoding: Set by libavcodec.
421 */
422 int16_t position[3][2];
423} AVPanScan;
424
425/**
426 * This structure describes the bitrate properties of an encoded bitstream. It
427 * roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD
428 * parameters for H.264/HEVC.
429 */
430typedef struct AVCPBProperties {
431 /**
432 * Maximum bitrate of the stream, in bits per second.
433 * Zero if unknown or unspecified.
434 */
435 int64_t max_bitrate;
436 /**
437 * Minimum bitrate of the stream, in bits per second.
438 * Zero if unknown or unspecified.
439 */
440 int64_t min_bitrate;
441 /**
442 * Average bitrate of the stream, in bits per second.
443 * Zero if unknown or unspecified.
444 */
445 int64_t avg_bitrate;
446
447 /**
448 * The size of the buffer to which the ratecontrol is applied, in bits.
449 * Zero if unknown or unspecified.
450 */
451 int64_t buffer_size;
452
453 /**
454 * The delay between the time the packet this structure is associated with
455 * is received and the time when it should be decoded, in periods of a 27MHz
456 * clock.
457 *
458 * UINT64_MAX when unknown or unspecified.
459 */
460 uint64_t vbv_delay;
461} AVCPBProperties;
462
463/**
464 * This structure supplies correlation between a packet timestamp and a wall clock
465 * production time. The definition follows the Producer Reference Time ('prft')
466 * as defined in ISO/IEC 14496-12
467 */
468typedef struct AVProducerReferenceTime {
469 /**
470 * A UTC timestamp, in microseconds, since Unix epoch (e.g, av_gettime()).
471 */
472 int64_t wallclock;
473 int flags;
474} AVProducerReferenceTime;
475
476/**359/**
477 * The decoder will keep a reference to the frame and may reuse it later.360 * The decoder will keep a reference to the frame and may reuse it later.
478 */361 */
@@ -3300,32 +3183,12 @@ void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size); · 2821 unmodified lines
3300 */3183 */
3301void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size);3184void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size);
3302 3185
3303/**
3304 * Encode extradata length to a buffer. Used by xiph codecs.
3305 *
3306 * @param s buffer to write to; must be at least (v/255+1) bytes long
3307 * @param v size of extradata in bytes
3308 * @return number of bytes written to the buffer.
3309 */
3310unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
3311
3312/**3186/**
3313 * @return a positive value if s is open (i.e. avcodec_open2() was called on it3187 * @return a positive value if s is open (i.e. avcodec_open2() was called on it
3314 * with no corresponding avcodec_close()), 0 otherwise.3188 * with no corresponding avcodec_close()), 0 otherwise.
3315 */3189 */
3316int avcodec_is_open(AVCodecContext *s);3190int avcodec_is_open(AVCodecContext *s);
3317 3191
3318/**
3319 * Allocate a CPB properties structure and initialize its fields to default
3320 * values.
3321 *
3322 * @param size if non-NULL, the size of the allocated struct will be written
3323 * here. This is useful for embedding it in side data.
3324 *
3325 * @return the newly allocated struct or NULL on failure
3326 */
3327AVCPBProperties *av_cpb_properties_alloc(size_t *size);
3328
3329/**3192/**
3330 * @}3193 * @}
3331 */3194 */
libavcodec/defs.h+170−0
@@ -0,0 +1,170 @@
1/*
2 *
3 * This file is part of FFmpeg.
4 *
5 * FFmpeg is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * FFmpeg is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with FFmpeg; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef AVCODEC_DEFS_H
21#define AVCODEC_DEFS_H
22
23/**
24 * @file
25 * @ingroup libavc
26 * Misc types and constants that do not belong anywhere else.
27 */
28
29#include <stdint.h>
30#include <stdlib.h>
31
32/**
33 * @ingroup lavc_decoding
34 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
35 * This is mainly needed because some optimized bitstream readers read
36 * 32 or 64 bit at once and could read over the end.<br>
37 * Note: If the first 23 bits of the additional bytes are not 0, then damaged
38 * MPEG bitstreams could cause overread and segfault.
39 */
40#define AV_INPUT_BUFFER_PADDING_SIZE 64
41
42/**
43 * @ingroup lavc_decoding
44 */
45enum AVDiscard{
46 /* We leave some space between them for extensions (drop some
47 * keyframes for intra-only or drop just some bidir frames). */
48 AVDISCARD_NONE =-16, ///< discard nothing
49 AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi
50 AVDISCARD_NONREF = 8, ///< discard all non reference
51 AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
52 AVDISCARD_NONINTRA= 24, ///< discard all non intra frames
53 AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
54 AVDISCARD_ALL = 48, ///< discard all
55};
56
57enum AVAudioServiceType {
58 AV_AUDIO_SERVICE_TYPE_MAIN = 0,
59 AV_AUDIO_SERVICE_TYPE_EFFECTS = 1,
60 AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
61 AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3,
62 AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4,
63 AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5,
64 AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6,
65 AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7,
66 AV_AUDIO_SERVICE_TYPE_KARAOKE = 8,
67 AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI
68};
69
70/**
71 * Pan Scan area.
72 * This specifies the area which should be displayed.
73 * Note there may be multiple such areas for one frame.
74 */
75typedef struct AVPanScan {
76 /**
77 * id
78 * - encoding: Set by user.
79 * - decoding: Set by libavcodec.
80 */
81 int id;
82
83 /**
84 * width and height in 1/16 pel
85 * - encoding: Set by user.
86 * - decoding: Set by libavcodec.
87 */
88 int width;
89 int height;
90
91 /**
92 * position of the top left corner in 1/16 pel for up to 3 fields/frames
93 * - encoding: Set by user.
94 * - decoding: Set by libavcodec.
95 */
96 int16_t position[3][2];
97} AVPanScan;
98
99/**
100 * This structure describes the bitrate properties of an encoded bitstream. It
101 * roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD
102 * parameters for H.264/HEVC.
103 */
104typedef struct AVCPBProperties {
105 /**
106 * Maximum bitrate of the stream, in bits per second.
107 * Zero if unknown or unspecified.
108 */
109 int64_t max_bitrate;
110 /**
111 * Minimum bitrate of the stream, in bits per second.
112 * Zero if unknown or unspecified.
113 */
114 int64_t min_bitrate;
115 /**
116 * Average bitrate of the stream, in bits per second.
117 * Zero if unknown or unspecified.
118 */
119 int64_t avg_bitrate;
120
121 /**
122 * The size of the buffer to which the ratecontrol is applied, in bits.
123 * Zero if unknown or unspecified.
124 */
125 int64_t buffer_size;
126
127 /**
128 * The delay between the time the packet this structure is associated with
129 * is received and the time when it should be decoded, in periods of a 27MHz
130 * clock.
131 *
132 * UINT64_MAX when unknown or unspecified.
133 */
134 uint64_t vbv_delay;
135} AVCPBProperties;
136
137/**
138 * Allocate a CPB properties structure and initialize its fields to default
139 * values.
140 *
141 * @param size if non-NULL, the size of the allocated struct will be written
142 * here. This is useful for embedding it in side data.
143 *
144 * @return the newly allocated struct or NULL on failure
145 */
146AVCPBProperties *av_cpb_properties_alloc(size_t *size);
147
148/**
149 * This structure supplies correlation between a packet timestamp and a wall clock
150 * production time. The definition follows the Producer Reference Time ('prft')
151 * as defined in ISO/IEC 14496-12
152 */
153typedef struct AVProducerReferenceTime {
154 /**
155 * A UTC timestamp, in microseconds, since Unix epoch (e.g, av_gettime()).
156 */
157 int64_t wallclock;
158 int flags;
159} AVProducerReferenceTime;
160
161/**
162 * Encode extradata length to a buffer. Used by xiph codecs.
163 *
164 * @param s buffer to write to; must be at least (v/255+1) bytes long
165 * @param v size of extradata in bytes
166 * @return number of bytes written to the buffer.
167 */
168unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
169
170#endif // AVCODEC_DEFS_H

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t