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

Function dv_write_pack

libavformat/dvenc.c:98–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98static int dv_write_pack(enum DVPackType pack_id, DVMuxContext *c, uint8_t* buf, int channel, int seq)
99{
100 struct tm tc;
101 time_t ct;
102 uint32_t timecode;
103 int audio_type = 0;
104
105 buf[0] = (uint8_t)pack_id;
106 switch (pack_id) {
107 case DV_TIMECODE:
108 timecode = av_timecode_get_smpte_from_framenum(&c->tc, c->frames);
109 timecode |= 1<<23 | 1<<15 | 1<<7 | 1<<6; // biphase and binary group flags
110 AV_WB32(buf + 1, timecode);
111 break;
112 case DV_AUDIO_SOURCE: /* AAUX source pack */
113 if (c->ast[channel]->codecpar->sample_rate == 44100) {
114 audio_type = 1;
115 } else if (c->ast[channel]->codecpar->sample_rate == 32000)
116 audio_type = 2;
117 buf[1] = (1 << 7) | /* locked mode -- SMPTE only supports locked mode */
118 (1 << 6) | /* reserved -- always 1 */
119 (dv_audio_frame_size(c->sys, c->frames, c->ast[channel]->codecpar->sample_rate) -
120 c->sys->audio_min_samples[audio_type]);
121 /* # of samples */
122 buf[2] = (0 << 7) | /* multi-stereo */
123 (0 << 5) | /* #of audio channels per block: 0 -- 1 channel */
124 (0 << 4) | /* pair bit: 0 -- one pair of channels */
125 (seq >= c->sys->difseg_size/2); /* audio mode (1st or 2nd channel) */
126 buf[3] = (1 << 7) | /* res */
127 (1 << 6) | /* multi-language flag */
128 (c->sys->dsf << 5) | /* system: 60fields/50fields */
129 (DV_PROFILE_IS_HD(c->sys) ? 0x3 : c->sys->video_stype ? 2 : 0); /* stype */
130 buf[4] = (1 << 7) | /* emphasis: 1 -- off */
131 (0 << 6) | /* emphasis time constant: 0 -- reserved */
132 (audio_type << 3) | /* frequency: 0 -- 48kHz, 1 -- 44,1kHz, 2 -- 32kHz */
133 0; /* quantization: 0 -- 16-bit linear, 1 -- 12-bit nonlinear */
134
135 break;
136 case DV_AUDIO_CONTROL:
137 buf[1] = (0 << 6) | /* copy protection: 0 -- unrestricted */
138 (1 << 4) | /* input source: 1 -- digital input */
139 (3 << 2) | /* compression: 3 -- no information */
140 0; /* misc. info/SMPTE emphasis off */
141 buf[2] = (1 << 7) | /* recording start point: 1 -- no */
142 (1 << 6) | /* recording end point: 1 -- no */
143 (1 << 3) | /* recording mode: 1 -- original */
144 7;
145 buf[3] = (1 << 7) | /* direction: 1 -- forward */
146 (c->sys->pix_fmt == AV_PIX_FMT_YUV420P ? 0x20 : /* speed */
147 c->sys->ltc_divisor * 4);
148 buf[4] = (1 << 7) | /* reserved -- always 1 */
149 0x7f; /* genre category */
150 break;
151 case DV_AUDIO_RECDATE:
152 case DV_VIDEO_RECDATE: /* VAUX recording date */
153 ct = c->start_time + av_rescale_rnd(c->frames, c->sys->time_base.num,
154 c->sys->time_base.den, AV_ROUND_DOWN);
155 brktimegm(ct, &tc);

Callers 2

dv_inject_audioFunction · 0.70
dv_inject_metadataFunction · 0.70

Calls 4

dv_audio_frame_sizeFunction · 0.85
brktimegmFunction · 0.85
av_rescale_rndFunction · 0.50

Tested by

no test coverage detected