History

lavc: add a packet side data type for VBV-like parameters

Anton Khirnov committed 11 years ago

Commit f0b769c1 parent e63e3793 files · +69 −0Browse files

Unified · Split

3 files
  1. doc/APIchanges +1 −0
  2. libavcodec/avcodec.h +54 −0
  3. libavcodec/utils.c +14 −0
doc/APIchanges+1−0
@@ -16,6 +16,7 @@ API changes, most recent first: · 15 unmodified lines
1616 2015-xx-xx - xxxxxxx - lavc 57.11.0 - avcodec.h
1717 xxxxxxx - Add av_packet_add_side_data().
1818 xxxxxxx - Add AVCodecContext.coded_side_data.
19+ xxxxxxx - Add AVCPBProperties API.
1920
2021 2015-xx-xx - xxxxxxx - lavc 57.9.1 - avcodec.h
2122 Deprecate rtp_callback without replacement, i.e. it won't be possible to
libavcodec/avcodec.h+54−0
@@ -1036,6 +1036,44 @@ typedef struct AVPanScan{ · 1035 unmodified lines
10361036 int16_t position[3][2];
10371037 }AVPanScan;
10381038
1039+/**
1040+ * This structure describes the bitrate properties of an encoded bitstream. It
1041+ * roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD
1042+ * parameters for H.264/HEVC.
1043+ */
1044+typedef struct AVCPBProperties {
1045+ /**
1046+ * Maximum bitrate of the stream, in bits per second.
1047+ * Zero if unknown or unspecified.
1048+ */
1049+ int max_bitrate;
1050+ /**
1051+ * Minimum bitrate of the stream, in bits per second.
1052+ * Zero if unknown or unspecified.
1053+ */
1054+ int min_bitrate;
1055+ /**
1056+ * Average bitrate of the stream, in bits per second.
1057+ * Zero if unknown or unspecified.
1058+ */
1059+ int avg_bitrate;
1060+
1061+ /**
1062+ * The size of the buffer to which the ratecontrol is applied, in bits.
1063+ * Zero if unknown or unspecified.
1064+ */
1065+ int buffer_size;
1066+
1067+ /**
1068+ * The delay between the time the packet this structure is associated with
1069+ * is received and the time when it should be decoded, in periods of a 27MHz
1070+ * clock.
1071+ *
1072+ * UINT64_MAX when unknown or unspecified.
1073+ */
1074+ uint64_t vbv_delay;
1075+} AVCPBProperties;
1076+
10391077 #if FF_API_QSCALE_TYPE
10401078 #define FF_QSCALE_TYPE_MPEG1 0
10411079 #define FF_QSCALE_TYPE_MPEG2 1
@@ -1137,6 +1175,11 @@ enum AVPacketSideDataType { · 95 unmodified lines
11371175 * e.g. no decoder available for codec.
11381176 */
11391177 AV_PKT_DATA_FALLBACK_TRACK,
1178+
1179+ /**
1180+ * This side data corresponds to the AVCPBProperties struct.
1181+ */
1182+ AV_PKT_DATA_CPB_PROPERTIES,
11401183 };
11411184
11421185 typedef struct AVPacketSideData {
@@ -4630,6 +4673,17 @@ const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev); · 3487 unmodified lines
46304673 */
46314674 const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name);
46324675
4676+/**
4677+ * Allocate a CPB properties structure and initialize its fields to default
4678+ * values.
4679+ *
4680+ * @param size if non-NULL, the size of the allocated struct will be written
4681+ * here. This is useful for embedding it in side data.
4682+ *
4683+ * @return the newly allocated struct or NULL on failure
4684+ */
4685+AVCPBProperties *av_cpb_properties_alloc(size_t *size);
4686+
46334687 /**
46344688 * @}
46354689 */
libavcodec/utils.c+14−0
@@ -2369,3 +2369,17 @@ const uint8_t *avpriv_find_start_code(const uint8_t *restrict p, · 2368 unmodified lines
23692369
23702370 return p + 4;
23712371 }
2372+
2373+AVCPBProperties *av_cpb_properties_alloc(size_t *size)
2374+{
2375+ AVCPBProperties *props = av_mallocz(sizeof(AVCPBProperties));
2376+ if (!props)
2377+ return NULL;
2378+
2379+ if (size)
2380+ *size = sizeof(*props);
2381+
2382+ props->vbv_delay = UINT64_MAX;
2383+
2384+ return props;
2385+}

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