29 #define ROQ_FRAME_SIZE 735
30 #define ROQ_HEADER_SIZE 8
32 #define MAX_DPCM (127*127)
49 #if FF_API_OLD_ENCODE_AUDIO
84 #if FF_API_OLD_ENCODE_AUDIO
105 diff = current - *previous;
114 result += diff > result*result+result;
119 diff = result*result;
122 predicted = *previous + diff;
125 if (predicted > 32767 || predicted < -32768) {
131 result |= negative << 7;
133 *previous = predicted;
139 const AVFrame *frame,
int *got_packet_ptr)
141 int i, stereo, data_size, ret;
142 const int16_t *in = frame ? (
const int16_t *)frame->
data[0] :
NULL;
148 if (!in && context->input_frames >= 8)
151 if (in && context->input_frames < 8) {
152 memcpy(&context->frame_buffer[context->buffered_samples * avctx->
channels],
154 context->buffered_samples += avctx->
frame_size;
155 if (context->input_frames == 0)
156 context->first_pts = frame->
pts;
157 if (context->input_frames < 7) {
158 context->input_frames++;
161 in = context->frame_buffer;
165 context->lastSample[0] &= 0xFF00;
166 context->lastSample[1] &= 0xFF00;
169 if (context->input_frames == 7 || !in)
170 data_size = avctx->
channels * context->buffered_samples;
180 bytestream_put_byte(&out, stereo ? 0x21 : 0x20);
181 bytestream_put_byte(&out, 0x10);
182 bytestream_put_le32(&out, data_size);
185 bytestream_put_byte(&out, (context->lastSample[1])>>8);
186 bytestream_put_byte(&out, (context->lastSample[0])>>8);
188 bytestream_put_le16(&out, context->lastSample[0]);
191 for (i = 0; i < data_size; i++)
192 *out++ =
dpcm_predict(&context->lastSample[i & 1], *in++);
194 avpkt->
pts = context->input_frames <= 7 ? context->first_pts : frame->
pts;
197 context->input_frames++;
199 context->input_frames =
FFMAX(context->input_frames, 8);
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
This structure describes decoded (raw) audio or video data.
AVFrame * coded_frame
the picture in the bitstream
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static av_cold int roq_dpcm_encode_close(AVCodecContext *avctx)
int64_t pts
presentation timestamp in time_base units (time when frame should be shown to user) If AV_NOPTS_VALUE...
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static int init(AVCodecParserContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static int roq_dpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
AVFrame * avcodec_alloc_frame(void)
Allocate an AVFrame and set its fields to default values.
int bit_rate
the average bitrate
int ff_alloc_packet(AVPacket *avpkt, int size)
Check AVPacket size and/or allocate data.
static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx)
int frame_size
Number of samples per channel in an audio frame.
static av_const unsigned int ff_sqrt(unsigned int a)
int sample_rate
samples per second
main external API structure.
static void close(AVCodecParserContext *s)
static unsigned char dpcm_predict(short *previous, short current)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
AVSampleFormat
Audio Sample Formats.
int channels
number of audio channels
AVCodec ff_roq_dpcm_encoder
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...