40 #define SCREEN_WIDE 640
41 #define SCREEN_HIGH 429
52 #define NEXT_BYTE(v) v = forward ? v + 1 : v - 1;
54 static int decode_bmv_frame(
const uint8_t *source,
int src_len, uint8_t *frame,
int frame_off)
56 int val, saved_val = 0;
58 const uint8_t *src, *source_end = source + src_len;
60 uint8_t *dst, *dst_end;
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)
144 frame_end - dst < frame_off + len)
146 for (i = 0; i <
len; i++)
147 dst[i] = dst[frame_off + i];
152 frame_end - dst < frame_off + len)
154 for (i = len - 1; i >= 0; i--)
155 dst[i] = dst[frame_off + i];
160 if (source + src_len - src < len)
162 memcpy(dst, src, len);
166 if (src - source < len)
170 memcpy(dst, src, len);
174 val = forward ? dst[-1] : dst[1];
176 memset(dst, val, len);
180 memset(dst, val, len);
197 uint8_t *srcptr, *outptr;
200 type = bytestream_get_byte(&c->
stream);
202 int blobs = bytestream_get_byte(&c->
stream);
203 if (pkt->
size < blobs * 65 + 2) {
210 int command_size = (type &
BMV_PRINT) ? 8 : 10;
215 c->
stream += command_size;
222 for (i = 0; i < 256; i++)
223 c->
pal[i] = bytestream_get_be24(&c->
stream);
230 scr_off = (int16_t)bytestream_get_le16(&c->
stream);
248 for (i = 0; i < avctx->
height; i++) {
249 memcpy(outptr, srcptr, avctx->
width);
250 srcptr += avctx->
width;
294 16512, 8256, 4128, 2064, 1032, 516, 258, 192, 129, 88, 64, 56, 48, 40, 36, 32
315 int *got_frame_ptr,
AVPacket *avpkt)
318 const uint8_t *buf = avpkt->
data;
319 int buf_size = avpkt->
size;
320 int blocks = 0, total_blocks, i;
322 int16_t *output_samples;
325 total_blocks = *buf++;
326 if (buf_size < total_blocks * 65 + 1) {
328 total_blocks * 65 + 1, buf_size);
338 output_samples = (int16_t *)c->
frame.
data[0];
340 for (blocks = 0; blocks < total_blocks; blocks++) {
341 uint8_t code = *buf++;
342 code = (code >> 1) | (code << 7);
345 for (i = 0; i < 32; i++) {
346 *output_samples++ = av_clip_int16((scale[0] * (int8_t)*buf++) >> 5);
347 *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
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
AVFrame * coded_frame
the picture in the bitstream
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt)
AVCodec ff_bmv_audio_decoder
struct BMVDecContext BMVDecContext
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
enum AVSampleFormat sample_fmt
audio sample format
static int init(AVCodecParserContext *s)
static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame, int frame_off)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static const uint16_t mask[17]
int reference
is this picture used as reference The values for this are the same as the MpegEncContext.picture_structure variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
#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.
int width
picture width / height.
struct AVFrame AVFrame
Audio Video Frame.
static av_cold int decode_init(AVCodecContext *avctx)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
static const int bmv_aud_mults[16]
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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.
8 bit with PIX_FMT_RGB32 palette
struct BMVAudioDecContext BMVAudioDecContext
int channels
number of audio channels
void avcodec_get_frame_defaults(AVFrame *pic)
Set the fields of the given AVFrame to default values.
static av_cold int bmv_aud_decode_init(AVCodecContext *avctx)
uint8_t frame_base[SCREEN_WIDE *(SCREEN_HIGH+1)]
static av_cold int decode_end(AVCodecContext *avctx)
int nb_samples
number of audio samples (per channel) described by this frame