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;
156 context->lastSample[0] &= 0xFF00;
157 context->lastSample[1] &= 0xFF00;
160 if (context->input_frames == 7)
161 data_size = avctx->
channels * context->buffered_samples;
169 bytestream_put_byte(&
out, stereo ? 0x21 : 0x20);
170 bytestream_put_byte(&
out, 0x10);
171 bytestream_put_le32(&
out, data_size);
174 bytestream_put_byte(&
out, (context->lastSample[1])>>8);
175 bytestream_put_byte(&
out, (context->lastSample[0])>>8);
177 bytestream_put_le16(&
out, context->lastSample[0]);
180 for (i = 0; i < data_size; i++)
183 avpkt->
pts = context->input_frames <= 7 ? context->first_pts : frame->
pts;
186 context->input_frames++;
188 context->input_frames =
FFMAX(context->input_frames, 8);