22 #include "libavutil/avassert.h"
23 #include "libavutil/channel_layout.h"
42 #define SCREEN_WIDE 640
43 #define SCREEN_HIGH 429
53 #define NEXT_BYTE(v) v = forward ? v + 1 : v - 1;
57 unsigned val, saved_val = 0;
59 const uint8_t *
src, *source_end = source + src_len;
63 int forward = (frame_off <= -
SCREEN_WIDE) || (frame_off >= 0);
64 int read_two_nibbles, flag;
77 src = source + src_len - 1;
92 if (!mode || (tmplen == 4)) {
93 if (src < source || src >= source_end)
105 if (!read_two_nibbles) {
106 if (src < source || src >= source_end)
109 val |= *src <<
shift;
115 read_two_nibbles = 0;
117 mask = (1 <<
shift) - 1;
118 val = ((val >> 2) & ~mask) | (val &
mask);
120 if ((val & (0xC << shift))) {
131 saved_val = val >> (4 +
shift);
133 val &= (1 << (shift + 4)) - 1;
136 advance_mode = val & 1;
137 len = (val >> 1) - 1;
139 mode += 1 + advance_mode;
142 if (len <= 0 ||
FFABS(dst_end - dst) < len)
149 frame_end - dst < frame_off + len ||
150 frame_end - dst < len)
152 for (i = 0; i <
len; i++)
153 dst[i] = dst[frame_off + i];
159 frame_end - dst < frame_off + len ||
160 frame_end - dst < len)
162 for (i = len - 1; i >= 0; i--)
163 dst[i] = dst[frame_off + i];
168 if (source + src_len - src < len)
170 memcpy(dst, src, len);
174 if (src - source < len)
178 memcpy(dst, src, len);
182 val = forward ? dst[-1] : dst[1];
184 memset(dst, val, len);
188 memset(dst, val, len);
208 type = bytestream_get_byte(&c->
stream);
210 int blobs = bytestream_get_byte(&c->
stream);
211 if (pkt->
size < blobs * 65 + 2) {
218 int command_size = (type &
BMV_PRINT) ? 8 : 10;
223 c->
stream += command_size;
230 for (i = 0; i < 256; i++)
231 c->
pal[i] = 0xFFU << 24 | bytestream_get_be24(&c->
stream);
238 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;
289 16512, 8256, 4128, 2064, 1032, 516, 258, 192, 129, 88, 64, 56, 48, 40, 36, 32
302 int *got_frame_ptr,
AVPacket *avpkt)
306 int buf_size = avpkt->
size;
307 int blocks = 0, total_blocks, i;
309 int16_t *output_samples;
312 total_blocks = *buf++;
313 if (buf_size < total_blocks * 65 + 1) {
315 total_blocks * 65 + 1, buf_size);
323 output_samples = (int16_t *)frame->
data[0];
325 for (blocks = 0; blocks < total_blocks; blocks++) {
327 code = (code >> 1) | (code << 7);
330 for (i = 0; i < 32; i++) {
331 *output_samples++ = av_clip_int16((scale[0] * (int8_t)*buf++) >> 5);
332 *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
const char const char void * val
static int shift(int a, int b)
This structure describes decoded (raw) audio or video data.
static av_cold int init(AVCodecContext *avctx)
AVCodec ff_bmv_audio_decoder
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
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)
enum AVSampleFormat sample_fmt
audio sample format
const char * name
Name of the codec implementation.
#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. ...
Libavcodec external API header.
uint64_t channel_layout
Audio channel layout.
int width
picture width / height.
static av_cold int decode_init(AVCodecContext *avctx)
static const int bmv_aud_mults[16]
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.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static const uint16_t scale[4]
common internal api header.
#define AVERROR_INVALIDDATA
int channels
number of audio channels
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static av_cold int bmv_aud_decode_init(AVCodecContext *avctx)
uint8_t frame_base[SCREEN_WIDE *(SCREEN_HIGH+1)]
8 bit with PIX_FMT_RGB32 palette
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.