static int decode_subpacket(COOKContext *q, const uint8_t *inbuffer, int sub_packet_size, int16_t *outbuffer) { /* packet dump */ // for (i=0 ; i<sub_packet_size ; i++) { // av_log(NULL, AV_LOG_ERROR, "%02x", inbuffer[i]); // } // av_log(NULL, AV_LOG_ERROR, "\n"); decode_bytes_and_gain(q, inbuffer, &q->gains1); if (q->joint_stereo) { joint_decode(q, q->decode_buffer_1, q->decode_buffer_2); } else { mono_decode(q, q->decode_buffer_1); if (q->nb_channels == 2) { decode_bytes_and_gain(q, inbuffer + sub_packet_size/2, &q->gains2); mono_decode(q, q->decode_buffer_2); } } mlt_compensate_output(q, q->decode_buffer_1, &q->gains1, q->mono_previous_buffer1, outbuffer, 0); if (q->nb_channels == 2) { if (q->joint_stereo) { mlt_compensate_output(q, q->decode_buffer_2, &q->gains1, q->mono_previous_buffer2, outbuffer, 1); } else { mlt_compensate_output(q, q->decode_buffer_2, &q->gains2, q->mono_previous_buffer2, outbuffer, 1); } } return q->samples_per_frame * sizeof(int16_t); }
/** * Cook subpacket decoding. This function returns one decoded subpacket, * usually 1024 samples per channel. * * @param q pointer to the COOKContext * @param inbuffer pointer to the inbuffer * @param outbuffer pointer to the outbuffer */ static void decode_subpacket(COOKContext *q, COOKSubpacket* p, const uint8_t *inbuffer, int16_t *outbuffer) { int sub_packet_size = p->size; /* packet dump */ // for (i=0 ; i<sub_packet_size ; i++) { // av_log(q->avctx, AV_LOG_ERROR, "%02x", inbuffer[i]); // } // av_log(q->avctx, AV_LOG_ERROR, "\n"); memset(q->decode_buffer_1,0,sizeof(q->decode_buffer_1)); decode_bytes_and_gain(q, p, inbuffer, &p->gains1); if (p->joint_stereo) { joint_decode(q, p, q->decode_buffer_1, q->decode_buffer_2); } else { mono_decode(q, p, q->decode_buffer_1); if (p->num_channels == 2) { decode_bytes_and_gain(q, p, inbuffer + sub_packet_size/2, &p->gains2); mono_decode(q, p, q->decode_buffer_2); } } mlt_compensate_output(q, q->decode_buffer_1, &p->gains1, p->mono_previous_buffer1, outbuffer, p->ch_idx); if (p->num_channels == 2) { if (p->joint_stereo) { mlt_compensate_output(q, q->decode_buffer_2, &p->gains1, p->mono_previous_buffer2, outbuffer, p->ch_idx + 1); } else { mlt_compensate_output(q, q->decode_buffer_2, &p->gains2, p->mono_previous_buffer2, outbuffer, p->ch_idx + 1); } } }
/** * Cook subpacket decoding. This function returns one decoded subpacket, * usually 1024 samples per channel. * * @param q pointer to the COOKContext * @param inbuffer pointer to the inbuffer * @param outbuffer pointer to the outbuffer */ static int decode_subpacket(COOKContext *q, COOKSubpacket *p, const uint8_t *inbuffer, float **outbuffer) { int sub_packet_size = p->size; int res; memset(q->decode_buffer_1, 0, sizeof(q->decode_buffer_1)); decode_bytes_and_gain(q, p, inbuffer, &p->gains1); if (p->joint_stereo) { if ((res = joint_decode(q, p, q->decode_buffer_1, q->decode_buffer_2)) < 0) return res; } else { if ((res = mono_decode(q, p, q->decode_buffer_1)) < 0) return res; if (p->num_channels == 2) { decode_bytes_and_gain(q, p, inbuffer + sub_packet_size / 2, &p->gains2); if ((res = mono_decode(q, p, q->decode_buffer_2)) < 0) return res; } } mlt_compensate_output(q, q->decode_buffer_1, &p->gains1, p->mono_previous_buffer1, outbuffer ? outbuffer[p->ch_idx] : NULL); if (p->num_channels == 2) { if (p->joint_stereo) mlt_compensate_output(q, q->decode_buffer_2, &p->gains1, p->mono_previous_buffer2, outbuffer ? outbuffer[p->ch_idx + 1] : NULL); else mlt_compensate_output(q, q->decode_buffer_2, &p->gains2, p->mono_previous_buffer2, outbuffer ? outbuffer[p->ch_idx + 1] : NULL); } return 0; }