29 #define ROQ_FRAME_SIZE 735
30 #define ROQ_HEADER_SIZE 8
32 #define MAX_DPCM (127*127)
94 diff = current - *previous;
103 result += diff > result*result+result;
108 diff = result*result;
111 predicted = *previous + diff;
114 if (predicted > 32767 || predicted < -32768) {
120 result |= negative << 7;
122 *previous = predicted;
130 int i, stereo, data_size,
ret;
131 const int16_t *
in = frame ? (
const int16_t *)frame->
data[0] : NULL;
137 if (!in && context->input_frames >= 8)
140 if (in && context->input_frames < 8) {
141 memcpy(&context->frame_buffer[context->buffered_samples * avctx->
channels],
143 context->buffered_samples += avctx->
frame_size;
144 if (context->input_frames == 0)
145 context->first_pts = frame->
pts;
146 if (context->input_frames < 7) {
147 context->input_frames++;
151 if (context->input_frames < 8)
152 in = context->frame_buffer;
155 context->lastSample[0] &= 0xFF00;
156 context->lastSample[1] &= 0xFF00;
159 if (context->input_frames == 7)
160 data_size = avctx->
channels * context->buffered_samples;
168 bytestream_put_byte(&
out, stereo ? 0x21 : 0x20);
169 bytestream_put_byte(&
out, 0x10);
170 bytestream_put_le32(&
out, data_size);
173 bytestream_put_byte(&
out, (context->lastSample[1])>>8);
174 bytestream_put_byte(&
out, (context->lastSample[0])>>8);
176 bytestream_put_le16(&
out, context->lastSample[0]);
179 for (i = 0; i < data_size; i++)
182 avpkt->
pts = context->input_frames <= 7 ? context->first_pts : frame->
pts;
185 context->input_frames++;
187 context->input_frames =
FFMAX(context->input_frames, 8);