41 #define SCREEN_WIDE 640
42 #define SCREEN_HIGH 429
52 #define NEXT_BYTE(v) v = forward ? v + 1 : v - 1;
56 unsigned val, saved_val = 0;
58 const uint8_t *src, *source_end = source + src_len;
62 int forward = (frame_off <= -
SCREEN_WIDE) || (frame_off >= 0);
63 int read_two_nibbles, flag;
76 src = source + src_len - 1;
91 if (!mode || (tmplen == 4)) {
92 if (src < source || src >= source_end)
102 if (!read_two_nibbles) {
103 if (src < source || src >= source_end)
106 val |= *src << shift;
112 read_two_nibbles = 0;
114 mask = (1 << shift) - 1;
115 val = ((val >> 2) & ~mask) | (val &
mask);
117 if ((val & (0xC << shift))) {
128 saved_val = val >> (4 + shift);
130 val &= (1 << (shift + 4)) - 1;
133 advance_mode = val & 1;
134 len = (val >> 1) - 1;
135 mode += 1 + advance_mode;
138 if (len <= 0 ||
FFABS(dst_end - dst) <
len)
145 frame_end - dst < frame_off + len ||
146 frame_end - dst < len)
148 for (i = 0; i <
len; i++)
149 dst[i] = dst[frame_off + i];
155 frame_end - dst < frame_off + len ||
156 frame_end - dst < len)
158 for (i = len - 1; i >= 0; i--)
159 dst[i] = dst[frame_off + i];
164 if (source + src_len - src < len)
166 memcpy(dst, src, len);
170 if (src - source < len)
174 memcpy(dst, src, len);
178 val = forward ? dst[-1] : dst[1];
180 memset(dst, val, len);
184 memset(dst, val, len);
206 type = bytestream_get_byte(&c->
stream);
208 int blobs = bytestream_get_byte(&c->
stream);
209 if (pkt->
size < blobs * 65 + 2) {
216 int command_size = (type &
BMV_PRINT) ? 8 : 10;
221 c->
stream += command_size;
228 for (i = 0; i < 256; i++)
229 c->
pal[i] = bytestream_get_be24(&c->
stream);
236 scr_off = (int16_t)bytestream_get_le16(&c->
stream);
256 outptr = frame->
data[0];
259 for (i = 0; i < avctx->
height; i++) {
260 memcpy(outptr, srcptr, avctx->
width);
261 srcptr += avctx->
width;
284 16512, 8256, 4128, 2064, 1032, 516, 258, 192, 129, 88, 64, 56, 48, 40, 36, 32
297 int *got_frame_ptr,
AVPacket *avpkt)
301 int buf_size = avpkt->
size;
302 int blocks = 0, total_blocks, i;
304 int16_t *output_samples;
307 total_blocks = *buf++;
308 if (buf_size < total_blocks * 65 + 1) {
310 total_blocks * 65 + 1, buf_size);
320 output_samples = (int16_t *)frame->
data[0];
322 for (blocks = 0; blocks < total_blocks; blocks++) {
324 code = (code >> 1) | (code << 7);
327 for (i = 0; i < 32; i++) {
328 *output_samples++ = av_clip_int16((scale[0] * (int8_t)*buf++) >> 5);
329 *output_samples++ = av_clip_int16((scale[1] * (int8_t)*buf++) >> 5);
static int bmv_aud_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
AVCodec ff_bmv_video_decoder
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
AVCodec ff_bmv_audio_decoder
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define AV_CH_LAYOUT_STEREO
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
enum AVSampleFormat sample_fmt
audio sample format
8 bit with PIX_FMT_RGB32 palette
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame, int frame_off)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint16_t mask[17]
#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.
uint64_t channel_layout
Audio channel layout.
static void frame_end(MpegEncContext *s)
audio channel layout utility functions
int width
picture width / height.
static av_cold int decode_init(AVCodecContext *avctx)
static const int bmv_aud_mults[16]
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int palette_has_changed
Tell user application that palette has changed from previous frame.
static const uint16_t scale[4]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
static av_cold int init(AVCodecParserContext *s)
int channels
number of audio channels
static av_cold int bmv_aud_decode_init(AVCodecContext *avctx)
uint8_t frame_base[SCREEN_WIDE *(SCREEN_HIGH+1)]
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame