29 #define ROQ_FRAME_SIZE 735
30 #define ROQ_HEADER_SIZE 8
32 #define MAX_DPCM (127*127)
93 diff = current - *previous;
102 result += diff > result*result+result;
107 diff = result*result;
110 predicted = *previous +
diff;
113 if (predicted > 32767 || predicted < -32768) {
119 result |= negative << 7;
121 *previous = predicted;
129 int i, stereo, data_size,
ret;
130 const int16_t *
in = frame ? (
const int16_t *)frame->
data[0] :
NULL;
136 if (!in && context->input_frames >= 8)
139 if (in && context->input_frames < 8) {
140 memcpy(&context->frame_buffer[context->buffered_samples * avctx->
channels],
142 context->buffered_samples += avctx->
frame_size;
143 if (context->input_frames == 0)
144 context->first_pts = frame->
pts;
145 if (context->input_frames < 7) {
146 context->input_frames++;
150 if (context->input_frames < 8)
151 in = context->frame_buffer;
154 context->lastSample[0] &= 0xFF00;
155 context->lastSample[1] &= 0xFF00;
158 if (context->input_frames == 7)
159 data_size = avctx->
channels * context->buffered_samples;
167 bytestream_put_byte(&
out, stereo ? 0x21 : 0x20);
168 bytestream_put_byte(&
out, 0x10);
169 bytestream_put_le32(&
out, data_size);
172 bytestream_put_byte(&
out, (context->lastSample[1])>>8);
173 bytestream_put_byte(&
out, (context->lastSample[0])>>8);
175 bytestream_put_le16(&
out, context->lastSample[0]);
178 for (i = 0; i < data_size; i++)
181 avpkt->
pts = context->input_frames <= 7 ? context->first_pts : frame->
pts;
184 context->input_frames++;
186 context->input_frames =
FFMAX(context->input_frames, 8);