MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / framecrc_write_packet

Function framecrc_write_packet

libavformat/framecrcenc.c:68–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
69{
70 uint32_t crc = av_adler32_update(0, pkt->data, pkt->size);
71 char buf[256];
72
73 snprintf(buf, sizeof(buf), "%d, %10"PRId64", %10"PRId64", %8"PRId64", %8d, 0x%08"PRIx32,
74 pkt->stream_index, pkt->dts, pkt->pts, pkt->duration, pkt->size, crc);
75 if (pkt->flags != AV_PKT_FLAG_KEY)
76 av_strlcatf(buf, sizeof(buf), ", F=0x%0X", pkt->flags);
77 if (pkt->side_data_elems) {
78 av_strlcatf(buf, sizeof(buf), ", S=%d", pkt->side_data_elems);
79
80 for (int i = 0; i < pkt->side_data_elems; i++) {
81 const AVPacketSideData *const sd = &pkt->side_data[i];
82 const uint8_t *data = sd->data;
83 uint32_t side_data_crc = 0;
84
85 switch (sd->type) {
86#if HAVE_BIGENDIAN
87 uint8_t bswap_buf[FFMAX3(sizeof(AVCPBProperties),
88 sizeof(AVProducerReferenceTime),
89 sizeof(AVDynamicHDRPlus))];
90 case AV_PKT_DATA_PALETTE:
91 case AV_PKT_DATA_REPLAYGAIN:
92 case AV_PKT_DATA_DISPLAYMATRIX:
93 case AV_PKT_DATA_STEREO3D:
94 case AV_PKT_DATA_AUDIO_SERVICE_TYPE:
95 case AV_PKT_DATA_FALLBACK_TRACK:
96 case AV_PKT_DATA_MASTERING_DISPLAY_METADATA:
97 case AV_PKT_DATA_SPHERICAL:
98 case AV_PKT_DATA_CONTENT_LIGHT_LEVEL:
99 case AV_PKT_DATA_S12M_TIMECODE:
100 for (size_t j = 0; j < sd->size / 4; j++) {
101 uint8_t buf[4];
102 AV_WL32(buf, AV_RB32(sd->data + 4 * j));
103 side_data_crc = av_adler32_update(side_data_crc, buf, 4);
104 }
105 break;
106 case AV_PKT_DATA_CPB_PROPERTIES:
107#define BSWAP(struct, field) bswap(bswap_buf, offsetof(struct, field), sizeof(((struct){0}).field))
108#define BSWAP_RAT(struct, field) do {BSWAP(struct, field.num); BSWAP(struct, field.den);} while(0)
109 if (sd->size == sizeof(AVCPBProperties)) {
110 memcpy(bswap_buf, sd->data, sizeof(AVCPBProperties));
111 data = bswap_buf;
112 BSWAP(AVCPBProperties, max_bitrate);
113 BSWAP(AVCPBProperties, min_bitrate);
114 BSWAP(AVCPBProperties, avg_bitrate);
115 BSWAP(AVCPBProperties, buffer_size);
116 BSWAP(AVCPBProperties, vbv_delay);
117 }
118 goto pod;
119 case AV_PKT_DATA_PRFT:
120 if (sd->size == sizeof(AVProducerReferenceTime)) {
121 memcpy(bswap_buf, sd->data, sizeof(AVProducerReferenceTime));
122 data = bswap_buf;
123 BSWAP(AVProducerReferenceTime, wallclock);
124 BSWAP(AVProducerReferenceTime, flags);
125 }

Callers

nothing calls this directly

Calls 4

av_adler32_updateFunction · 0.85
av_strlcatfFunction · 0.85
av_packet_side_data_nameFunction · 0.85
avio_writeFunction · 0.85

Tested by

no test coverage detected