Lines Matching defs:frame
47 DECLARE_ALIGNED(SBC_ALIGN, struct sbc_frame, frame);
51 static int sbc_analyze_audio(SBCDSPContext *s, struct sbc_frame *frame)
56 switch (frame->subbands) {
58 for (ch = 0; ch < frame->channels; ch++) {
60 s->increment + frame->blocks * 4];
61 for (blk = 0; blk < frame->blocks;
65 frame->sb_sample_f[blk][ch],
66 frame->sb_sample_f[blk + 1][ch] -
67 frame->sb_sample_f[blk][ch]);
71 return frame->blocks * 4;
74 for (ch = 0; ch < frame->channels; ch++) {
76 s->increment + frame->blocks * 8];
77 for (blk = 0; blk < frame->blocks;
81 frame->sb_sample_f[blk][ch],
82 frame->sb_sample_f[blk + 1][ch] -
83 frame->sb_sample_f[blk][ch]);
87 return frame->blocks * 8;
95 * Packs the SBC frame from frame into the memory in avpkt.
96 * Returns the length of the packed frame.
98 static size_t sbc_pack_frame(AVPacket *avpkt, struct sbc_frame *frame,
121 avpkt->data[1] = (frame->frequency & 0x03) << 6;
122 avpkt->data[1] |= (((frame->blocks >> 2) - 1) & 0x03) << 4;
123 avpkt->data[1] |= (frame->mode & 0x03) << 2;
124 avpkt->data[1] |= (frame->allocation & 0x01) << 1;
125 avpkt->data[1] |= ((frame->subbands == 8) & 0x01) << 0;
127 avpkt->data[2] = frame->bitpool;
129 if (frame->bitpool > frame->subbands << (4 + (frame->mode == STEREO
130 || frame->mode == JOINT_STEREO)))
141 if (frame->mode == JOINT_STEREO) {
142 put_bits(&pb, frame->subbands, joint);
144 crc_pos += frame->subbands;
147 for (ch = 0; ch < frame->channels; ch++) {
148 for (sb = 0; sb < frame->subbands; sb++) {
149 put_bits(&pb, 4, frame->scale_factor[ch][sb] & 0x0F);
151 crc_header[crc_pos >> 3] |= frame->scale_factor[ch][sb] & 0x0F;
160 avpkt->data[3] = ff_sbc_crc8(frame->crc_ctx, crc_header, crc_pos);
162 ff_sbc_calculate_bits(frame, bits);
164 for (ch = 0; ch < frame->channels; ch++) {
165 for (sb = 0; sb < frame->subbands; sb++) {
167 (32 - (frame->scale_factor[ch][sb] +
170 (frame->scale_factor[ch][sb] +
175 for (blk = 0; blk < frame->blocks; blk++) {
176 for (ch = 0; ch < frame->channels; ch++) {
177 for (sb = 0; sb < frame->subbands; sb++) {
184 frame->sb_sample_f[blk][ch][sb])) >> 32;
199 struct sbc_frame *frame = &sbc->frame;
215 frame->mode = SBC_MODE_MONO;
216 frame->subbands = 8;
217 frame->blocks = MSBC_BLOCKS;
218 frame->allocation = SBC_AM_LOUDNESS;
219 frame->bitpool = 26;
231 frame->mode = SBC_MODE_MONO;
233 frame->subbands = 4;
235 frame->subbands = 8;
238 frame->mode = SBC_MODE_JOINT_STEREO;
240 frame->mode = SBC_MODE_STEREO;
242 frame->subbands = 4;
244 frame->subbands = 8;
247 frame->blocks = av_clip(((sbc->max_delay * avctx->sample_rate + 2)
248 / (1000000 * frame->subbands)) - 10, 4, 16) & ~3;
250 frame->allocation = SBC_AM_LOUDNESS;
252 d = frame->blocks * ((frame->mode == SBC_MODE_DUAL_CHANNEL) + 1);
253 frame->bitpool = (((avctx->bit_rate * frame->subbands * frame->blocks) / avctx->sample_rate)
254 - 4 * frame->subbands * avctx->ch_layout.nb_channels
255 - (frame->mode == SBC_MODE_JOINT_STEREO)*frame->subbands - 32 + d/2) / d;
257 frame->bitpool = avctx->global_quality / FF_QP2LAMBDA;
259 avctx->frame_size = 4*((frame->subbands >> 3) + 1) * 4*(frame->blocks >> 2);
264 frame->frequency = i;
266 frame->channels = avctx->ch_layout.nb_channels;
267 frame->codesize = frame->subbands * frame->blocks * avctx->ch_layout.nb_channels * 2;
268 frame->crc_ctx = av_crc_get_table(AV_CRC_8_EBU);
271 sbc->dsp.position = (SBC_X_BUFFER_SIZE - frame->subbands * 9) & ~7;
282 struct sbc_frame *frame = &sbc->frame;
283 uint8_t joint = frame->mode == SBC_MODE_JOINT_STEREO;
284 uint8_t dual = frame->mode == SBC_MODE_DUAL_CHANNEL;
287 int frame_length = 4 + (4 * frame->subbands * frame->channels) / 8
288 + ((frame->blocks * frame->bitpool * (1 + dual)
289 + joint * frame->subbands) + 7) / 8;
291 /* input must be large enough to encode a complete frame */
292 if (av_frame->nb_samples * frame->channels * 2 < frame->codesize)
299 if (frame->subbands == 8)
302 frame->subbands * frame->blocks, frame->channels);
306 frame->subbands * frame->blocks, frame->channels);
308 sbc_analyze_audio(&sbc->dsp, &sbc->frame);
310 if (frame->mode == JOINT_STEREO)
311 j = sbc->dsp.sbc_calc_scalefactors_j(frame->sb_sample_f,
312 frame->scale_factor,
313 frame->blocks,
314 frame->subbands);
316 sbc->dsp.sbc_calc_scalefactors(frame->sb_sample_f,
317 frame->scale_factor,
318 frame->blocks,
319 frame->channels,
320 frame->subbands);
322 sbc_pack_frame(avpkt, frame, j, sbc->msbc);