aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2015-12-17 13:25:52 +0100
committerHendrik Leppkes <h.leppkes@gmail.com>2015-12-17 13:25:52 +0100
commitdd6ee019ea828a2700e38366983ef343612021c6 (patch)
tree1c5d8ea9a7d23133d4caa4887cf787d936b33049 /libavcodec
parentbe52b95d311bb392fe99a6bb3b8db74e255043e3 (diff)
parentf0b769c16daafa64720dcba7fa81a9f5255e1d29 (diff)
downloadffmpeg-dd6ee019ea828a2700e38366983ef343612021c6.tar.gz
Merge commit 'f0b769c16daafa64720dcba7fa81a9f5255e1d29'
* commit 'f0b769c16daafa64720dcba7fa81a9f5255e1d29': lavc: add a packet side data type for VBV-like parameters Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/avcodec.h54
-rw-r--r--libavcodec/utils.c14
2 files changed, 68 insertions, 0 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 2821286d23..e7f016cdcc 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1185,6 +1185,44 @@ typedef struct AVPanScan{
int16_t position[3][2];
}AVPanScan;
+/**
+ * This structure describes the bitrate properties of an encoded bitstream. It
+ * roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD
+ * parameters for H.264/HEVC.
+ */
+typedef struct AVCPBProperties {
+ /**
+ * Maximum bitrate of the stream, in bits per second.
+ * Zero if unknown or unspecified.
+ */
+ int max_bitrate;
+ /**
+ * Minimum bitrate of the stream, in bits per second.
+ * Zero if unknown or unspecified.
+ */
+ int min_bitrate;
+ /**
+ * Average bitrate of the stream, in bits per second.
+ * Zero if unknown or unspecified.
+ */
+ int avg_bitrate;
+
+ /**
+ * The size of the buffer to which the ratecontrol is applied, in bits.
+ * Zero if unknown or unspecified.
+ */
+ int buffer_size;
+
+ /**
+ * The delay between the time the packet this structure is associated with
+ * is received and the time when it should be decoded, in periods of a 27MHz
+ * clock.
+ *
+ * UINT64_MAX when unknown or unspecified.
+ */
+ uint64_t vbv_delay;
+} AVCPBProperties;
+
#if FF_API_QSCALE_TYPE
#define FF_QSCALE_TYPE_MPEG1 0
#define FF_QSCALE_TYPE_MPEG2 1
@@ -1293,6 +1331,11 @@ enum AVPacketSideDataType {
AV_PKT_DATA_FALLBACK_TRACK,
/**
+ * This side data corresponds to the AVCPBProperties struct.
+ */
+ AV_PKT_DATA_CPB_PROPERTIES,
+
+ /**
* Recommmends skipping the specified number of samples
* @code
* u32le number of samples to skip from start of this packet
@@ -5328,6 +5371,17 @@ const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev);
const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name);
/**
+ * Allocate a CPB properties structure and initialize its fields to default
+ * values.
+ *
+ * @param size if non-NULL, the size of the allocated struct will be written
+ * here. This is useful for embedding it in side data.
+ *
+ * @return the newly allocated struct or NULL on failure
+ */
+AVCPBProperties *av_cpb_properties_alloc(size_t *size);
+
+/**
* @}
*/
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index b039885847..488b67c064 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -3488,3 +3488,17 @@ const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p,
return p + 4;
}
+
+AVCPBProperties *av_cpb_properties_alloc(size_t *size)
+{
+ AVCPBProperties *props = av_mallocz(sizeof(AVCPBProperties));
+ if (!props)
+ return NULL;
+
+ if (size)
+ *size = sizeof(*props);
+
+ props->vbv_delay = UINT64_MAX;
+
+ return props;
+}