44 #define BITSTREAM_READER_LE
47 #define PALETTE_COUNT 256
59 const unsigned char *
buf;
75 #define CHECK_STREAM_PTR(stream_ptr, stream_end, n) \
76 if (stream_end - stream_ptr < n) { \
77 av_log(s->avctx, AV_LOG_ERROR, "Interplay video warning: stream_ptr out of bounds (%p >= %p)\n", \
78 stream_ptr + n, stream_end); \
87 if (motion_offset < 0) {
132 x = -14 + ((B - 56) % 29);
133 y = 8 + ((B - 56) / 29);
136 av_dlog(
NULL,
" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
160 x = -(-14 + ((B - 56) % 29));
161 y = -( 8 + ((B - 56) / 29));
164 av_dlog(
NULL,
" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
171 unsigned char B, BL, BH;
183 BH = (B >> 4) & 0x0F;
187 av_dlog(
NULL,
" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
232 for (y = 0; y < 8; y++) {
234 for (; flags != 1; flags >>= 1)
245 for (y = 0; y < 8; y += 2) {
246 for (x = 0; x < 8; x += 2, flags >>= 1) {
264 unsigned int flags = 0;
278 for (y = 0; y < 16; y++) {
285 for (x = 0; x < 4; x++, flags >>= 1)
303 for (y = 0; y < 16; y++) {
304 for (x = 0; x < 4; x++, flags >>= 1)
319 for (y = 0; y < 8; y++) {
326 for (; flags != 1; flags >>= 1)
354 for (y = 0; y < 8; y++) {
357 for (x = 0; x < 8; x++, flags >>= 2)
370 for (y = 0; y < 8; y += 2) {
371 for (x = 0; x < 8; x += 2, flags >>= 2) {
389 for (y = 0; y < 8; y++) {
390 for (x = 0; x < 8; x += 2, flags >>= 2) {
397 for (y = 0; y < 8; y += 2) {
398 for (x = 0; x < 8; x++, flags >>= 2) {
426 for (y = 0; y < 16; y++) {
434 for (x = 0; x < 4; x++, flags >>= 2)
450 for (y = 0; y < 16; y++) {
458 for (x = 0; x < 4; x++, flags >>= 2)
480 for (y = 0; y < 8; y++) {
497 for (y = 0; y < 8; y += 2) {
498 for (x = 0; x < 8; x += 2) {
519 for (y = 0; y < 8; y++) {
542 for (y = 0; y < 8; y++) {
554 unsigned char sample[2];
561 for (y = 0; y < 8; y++) {
562 for (x = 0; x < 8; x += 2) {
592 uint16_t *pixel_ptr = (uint16_t*)s->
pixel_ptr;
600 if (!(P[0] & 0x8000)) {
604 for (y = 0; y < 8; y++) {
606 for (; flags != 1; flags >>= 1)
607 *pixel_ptr++ = P[flags & 1];
616 for (y = 0; y < 8; y += 2) {
617 for (x = 0; x < 8; x += 2, flags >>= 1) {
620 pixel_ptr[x + s->
stride] =
621 pixel_ptr[x + 1 + s->
stride] = P[flags & 1];
623 pixel_ptr += s->
stride * 2;
634 unsigned int flags = 0;
635 uint16_t *pixel_ptr = (uint16_t*)s->
pixel_ptr;
644 if (!(P[0] & 0x8000)) {
649 for (y = 0; y < 16; y++) {
657 for (x = 0; x < 4; x++, flags >>= 1)
658 *pixel_ptr++ = P[flags & 1];
659 pixel_ptr += s->
stride - 4;
661 if (y == 7) pixel_ptr -= 8 * s->
stride - 4;
674 for (y = 0; y < 16; y++) {
675 for (x = 0; x < 4; x++, flags >>= 1)
676 *pixel_ptr++ = P[flags & 1];
677 pixel_ptr += s->
stride - 4;
680 pixel_ptr -= 8 * s->
stride - 4;
691 for (y = 0; y < 8; y++) {
698 for (; flags != 1; flags >>= 1)
699 *pixel_ptr++ = P[flags & 1];
713 uint16_t *pixel_ptr = (uint16_t*)s->
pixel_ptr;
718 for (x = 0; x < 4; x++)
721 if (!(P[0] & 0x8000)) {
722 if (!(P[2] & 0x8000)) {
727 for (y = 0; y < 8; y++) {
730 for (x = 0; x < 8; x++, flags >>= 2)
731 *pixel_ptr++ = P[flags & 0x03];
743 for (y = 0; y < 8; y += 2) {
744 for (x = 0; x < 8; x += 2, flags >>= 2) {
747 pixel_ptr[x + s->
stride] =
748 pixel_ptr[x + 1 + s->
stride] = P[flags & 0x03];
750 pixel_ptr += s->
stride * 2;
761 if (!(P[2] & 0x8000)) {
762 for (y = 0; y < 8; y++) {
763 for (x = 0; x < 8; x += 2, flags >>= 2) {
765 pixel_ptr[x + 1] = P[flags & 0x03];
770 for (y = 0; y < 8; y += 2) {
771 for (x = 0; x < 8; x++, flags >>= 2) {
773 pixel_ptr[x + s->
stride] = P[flags & 0x03];
775 pixel_ptr += s->
stride * 2;
789 uint16_t *pixel_ptr = (uint16_t*)s->
pixel_ptr;
800 for (y = 0; y < 16; y++) {
803 for (x = 0; x < 4; x++)
808 for (x = 0; x < 4; x++, flags >>= 2)
809 *pixel_ptr++ = P[flags & 0x03];
811 pixel_ptr += s->
stride - 4;
813 if (y == 7) pixel_ptr -= 8 * s->
stride - 4;
824 for (y = 0; y < 16; y++) {
827 for (x = 0; x < 4; x++)
832 for (x = 0; x < 4; x++, flags >>= 2)
833 *pixel_ptr++ = P[flags & 0x03];
836 pixel_ptr += s->
stride - 4;
838 if (y == 7) pixel_ptr -= 8 * s->
stride - 4;
839 }
else if (y & 1) pixel_ptr += s->
line_inc;
850 uint16_t *pixel_ptr = (uint16_t*)s->
pixel_ptr;
855 for (y = 0; y < 8; y++) {
856 for (x = 0; x < 8; x++)
857 pixel_ptr[x] = bytestream_get_le16(&s->
stream_ptr);
868 uint16_t *pixel_ptr = (uint16_t*)s->
pixel_ptr;
873 for (y = 0; y < 8; y += 2) {
874 for (x = 0; x < 8; x += 2) {
877 pixel_ptr[x + s->
stride] =
880 pixel_ptr += s->
stride * 2;
891 uint16_t *pixel_ptr = (uint16_t*)s->
pixel_ptr;
896 for (y = 0; y < 8; y++) {
901 for (x = 0; x < 8; x++)
902 pixel_ptr[x] = P[x >> 2];
914 uint16_t *pixel_ptr = (uint16_t*)s->
pixel_ptr;
920 for (y = 0; y < 8; y++) {
921 for (x = 0; x < 8; x++)
955 unsigned char opcode;
957 static int frame = 0;
960 av_dlog(
NULL,
"------------------ frame %d\n", frame);
986 av_dlog(
NULL,
" block @ (%3d, %3d): encoding 0x%X, data ptr @ %p\n",
1029 void *
data,
int *data_size,
1032 const uint8_t *buf = avpkt->
data;
1033 int buf_size = avpkt->
size;
1041 if (buf_size < s->decoding_map_size)
1092 .
name =
"interplayvideo",
int(* get_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of each frame to get a buffer for it.
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
op_pixels_func put_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
static int ipvideo_decode_block_opcode_0x6(IpvideoContext *s)
const unsigned char * decoding_map
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
unsigned char * pixel_ptr
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int ipvideo_decode_block_opcode_0x1(IpvideoContext *s)
#define CODEC_CAP_PARAM_CHANGE
Codec supports changed parameters at any point.
static int ipvideo_decode_block_opcode_0x7_16(IpvideoContext *s)
static int ipvideo_decode_block_opcode_0xF(IpvideoContext *s)
static int ipvideo_decode_block_opcode_0xA(IpvideoContext *s)
static int ipvideo_decode_block_opcode_0x4(IpvideoContext *s)
static int ipvideo_decode_block_opcode_0x6_16(IpvideoContext *s)
static int ipvideo_decode_block_opcode_0xD_16(IpvideoContext *s)
static int ipvideo_decode_block_opcode_0x3(IpvideoContext *s)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
static void ipvideo_decode_opcodes(IpvideoContext *s)
AVFrame second_last_frame
bitstream reader API header.
static int ipvideo_decode_block_opcode_0x8_16(IpvideoContext *s)
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
av_cold void dsputil_init(DSPContext *c, AVCodecContext *avctx)
static int init(AVCodecParserContext *s)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int ipvideo_decode_block_opcode_0xE(IpvideoContext *s)
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.
static int ipvideo_decode_block_opcode_0xE_16(IpvideoContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int(*const ipvideo_decode_block[])(IpvideoContext *s)
static int ipvideo_decode_block_opcode_0x8(IpvideoContext *s)
static av_cold int ipvideo_decode_end(AVCodecContext *avctx)
void av_log(void *avcl, int level, const char *fmt,...)
static int ipvideo_decode_block_opcode_0xB_16(IpvideoContext *s)
const char * name
Name of the codec implementation.
static int(*const ipvideo_decode_block16[])(IpvideoContext *s)
int width
picture width / height.
struct AVFrame AVFrame
Audio Video Frame.
static int ipvideo_decode_block_opcode_0xD(IpvideoContext *s)
const unsigned char * stream_ptr
struct IpvideoContext IpvideoContext
static int ipvideo_decode_block_opcode_0x7(IpvideoContext *s)
#define av_dlog(pctx,...)
av_dlog macros Useful to print debug messages that shouldn't get compiled in normally.
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
const unsigned char * stream_end
static int ipvideo_decode_block_opcode_0xB(IpvideoContext *s)
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.
static av_cold int ipvideo_decode_init(AVCodecContext *avctx)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int palette_has_changed
Tell user application that palette has changed from previous frame.
static int copy_from(IpvideoContext *s, AVFrame *src, int delta_x, int delta_y)
AVCodec ff_interplay_video_decoder
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int ipvideo_decode_block_opcode_0xC_16(IpvideoContext *s)
int upper_motion_limit_offset
8 bit with PIX_FMT_RGB32 palette
const unsigned char * buf
static int ipvideo_decode_block_opcode_0x2(IpvideoContext *s)
static int ipvideo_decode_block_opcode_0x5(IpvideoContext *s)
static int ipvideo_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
static int ipvideo_decode_block_opcode_0x0(IpvideoContext *s)
static int ipvideo_decode_block_opcode_0x9_16(IpvideoContext *s)
static int ipvideo_decode_block_opcode_0x9(IpvideoContext *s)
static int ipvideo_decode_block_opcode_0xA_16(IpvideoContext *s)
static int ipvideo_decode_block_opcode_0xC(IpvideoContext *s)
#define CHECK_STREAM_PTR(stream_ptr, stream_end, n)