43 #define BITSTREAM_READER_LE
50 #define PALETTE_COUNT 256
81 int motion_offset = current_offset + delta_y * dst->
linesize[0]
83 if (motion_offset < 0) {
119 B = bytestream2_get_byte(&s->
mv_ptr);
126 x = -14 + ((B - 56) % 29);
127 y = 8 + ((B - 56) / 29);
130 ff_tlog(s->
avctx,
"motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
145 B = bytestream2_get_byte(&s->
mv_ptr);
152 x = -(-14 + ((B - 56) % 29));
153 y = -( 8 + ((B - 56) / 29));
156 ff_tlog(s->
avctx,
"motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
163 unsigned char B, BL, BH;
169 B = bytestream2_get_byte(&s->
mv_ptr);
173 BH = (B >> 4) & 0x0F;
177 ff_tlog(s->
avctx,
"motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
221 for (y = 0; y < 8; y++) {
222 flags = bytestream2_get_byte(&s->
stream_ptr) | 0x100;
223 for (; flags != 1; flags >>= 1)
232 for (y = 0; y < 8; y += 2) {
233 for (x = 0; x < 8; x += 2, flags >>= 1) {
251 unsigned int flags = 0;
264 for (y = 0; y < 16; y++) {
274 for (x = 0; x < 4; x++, flags >>= 1)
290 for (y = 0; y < 16; y++) {
291 for (x = 0; x < 4; x++, flags >>= 1)
307 for (y = 0; y < 8; y++) {
314 for (x = 0; x < 8; x++, flags >>= 1)
342 for (y = 0; y < 8; y++) {
345 for (x = 0; x < 8; x++, flags >>= 2)
356 for (y = 0; y < 8; y += 2) {
357 for (x = 0; x < 8; x += 2, flags >>= 2) {
373 for (y = 0; y < 8; y++) {
374 for (x = 0; x < 8; x += 2, flags >>= 2) {
381 for (y = 0; y < 8; y += 2) {
382 for (x = 0; x < 8; x++, flags >>= 2) {
413 for (y = 0; y < 16; y++) {
420 for (x = 0; x < 4; x++, flags >>= 2)
431 uint64_t flags = bytestream2_get_le64(&s->
stream_ptr);
439 for (y = 0; y < 16; y++) {
440 for (x = 0; x < 4; x++, flags >>= 2)
466 for (y = 0; y < 8; y++) {
480 for (y = 0; y < 8; y += 2) {
481 for (x = 0; x < 8; x += 2) {
505 for (y = 0; y < 8; y++) {
527 for (y = 0; y < 8; y++) {
542 sample[0] = bytestream2_get_byte(&s->
stream_ptr);
543 sample[1] = bytestream2_get_byte(&s->
stream_ptr);
545 for (y = 0; y < 8; y++) {
546 for (x = 0; x < 8; x += 2) {
574 uint16_t *pixel_ptr = (uint16_t*)s->
pixel_ptr;
580 if (!(P[0] & 0x8000)) {
582 for (y = 0; y < 8; y++) {
583 flags = bytestream2_get_byte(&s->
stream_ptr) | 0x100;
584 for (; flags != 1; flags >>= 1)
585 *pixel_ptr++ = P[flags & 1];
592 for (y = 0; y < 8; y += 2) {
593 for (x = 0; x < 8; x += 2, flags >>= 1) {
596 pixel_ptr[x + s->
stride] =
597 pixel_ptr[x + 1 + s->
stride] = P[flags & 1];
599 pixel_ptr += s->
stride * 2;
610 unsigned int flags = 0;
611 uint16_t *pixel_ptr = (uint16_t*)s->
pixel_ptr;
618 if (!(P[0] & 0x8000)) {
620 for (y = 0; y < 16; y++) {
630 for (x = 0; x < 4; x++, flags >>= 1)
631 *pixel_ptr++ = P[flags & 1];
632 pixel_ptr += s->
stride - 4;
634 if (y == 7) pixel_ptr -= 8 * s->
stride - 4;
643 if (!(P[2] & 0x8000)) {
647 for (y = 0; y < 16; y++) {
648 for (x = 0; x < 4; x++, flags >>= 1)
649 *pixel_ptr++ = P[flags & 1];
650 pixel_ptr += s->
stride - 4;
653 pixel_ptr -= 8 * s->
stride - 4;
664 for (y = 0; y < 8; y++) {
671 for (x = 0; x < 8; x++, flags >>= 1)
672 *pixel_ptr++ = P[flags & 1];
686 uint16_t *pixel_ptr = (uint16_t*)s->
pixel_ptr;
689 for (x = 0; x < 4; x++)
692 if (!(P[0] & 0x8000)) {
693 if (!(P[2] & 0x8000)) {
696 for (y = 0; y < 8; y++) {
699 for (x = 0; x < 8; x++, flags >>= 2)
700 *pixel_ptr++ = P[flags & 0x03];
710 for (y = 0; y < 8; y += 2) {
711 for (x = 0; x < 8; x += 2, flags >>= 2) {
714 pixel_ptr[x + s->
stride] =
715 pixel_ptr[x + 1 + s->
stride] = P[flags & 0x03];
717 pixel_ptr += s->
stride * 2;
726 if (!(P[2] & 0x8000)) {
727 for (y = 0; y < 8; y++) {
728 for (x = 0; x < 8; x += 2, flags >>= 2) {
730 pixel_ptr[x + 1] = P[flags & 0x03];
735 for (y = 0; y < 8; y += 2) {
736 for (x = 0; x < 8; x++, flags >>= 2) {
738 pixel_ptr[x + s->
stride] = P[flags & 0x03];
740 pixel_ptr += s->
stride * 2;
754 uint16_t *pixel_ptr = (uint16_t*)s->
pixel_ptr;
756 for (x = 0; x < 4; x++)
761 if (!(P[0] & 0x8000)) {
764 for (y = 0; y < 16; y++) {
768 for (x = 0; x < 4; x++)
773 for (x = 0; x < 4; x++, flags >>= 2)
774 *pixel_ptr++ = P[flags & 0x03];
776 pixel_ptr += s->
stride - 4;
778 if (y == 7) pixel_ptr -= 8 * s->
stride - 4;
784 uint64_t flags = bytestream2_get_le64(&s->
stream_ptr);
786 for (x = 4; x < 8; x++)
788 vert = !(P[4] & 0x8000);
793 for (y = 0; y < 16; y++) {
794 for (x = 0; x < 4; x++, flags >>= 2)
795 *pixel_ptr++ = P[flags & 0x03];
798 pixel_ptr += s->
stride - 4;
800 if (y == 7) pixel_ptr -= 8 * s->
stride - 4;
801 }
else if (y & 1) pixel_ptr += s->
line_inc;
818 uint16_t *pixel_ptr = (uint16_t*)s->
pixel_ptr;
821 for (y = 0; y < 8; y++) {
822 for (x = 0; x < 8; x++)
823 pixel_ptr[x] = bytestream2_get_le16(&s->
stream_ptr);
834 uint16_t *pixel_ptr = (uint16_t*)s->
pixel_ptr;
837 for (y = 0; y < 8; y += 2) {
838 for (x = 0; x < 8; x += 2) {
841 pixel_ptr[x + s->
stride] =
844 pixel_ptr += s->
stride * 2;
855 uint16_t *pixel_ptr = (uint16_t*)s->
pixel_ptr;
858 for (y = 0; y < 8; y++) {
863 for (x = 0; x < 8; x++)
864 pixel_ptr[x] = P[x >> 2];
876 uint16_t *pixel_ptr = (uint16_t*)s->
pixel_ptr;
881 for (y = 0; y < 8; y++) {
882 for (x = 0; x < 8; x++)
918 for (line = 0; line < 8; ++line) {
934 off_x = ((uint16_t)opcode - 0xC000) % frame->
linesize[0];
935 off_y = ((uint16_t)opcode - 0xC000) / frame->
linesize[0];
937 }
else if (opcode > 0) {
938 off_x = ((uint16_t)opcode - 0x4000) % frame->
linesize[0];
939 off_y = ((uint16_t)opcode - 0x4000) / frame->
linesize[0];
940 copy_from(s, frame, frame, off_x, off_y);
964 for (pass = 0; pass < 2; ++
pass) {
968 opcode = bytestream2_get_le16(&decoding_map_ptr);
971 " block @ (%3d, %3d): opcode 0x%X, data ptr offset %d\n",
982 "decode finished with %d bytes left over\n",
992 for (line = 0; line < 8; ++line) {
1007 }
else if (opcode > 0) {
1020 int pass, x, y, changed_block;
1021 int16_t opcode, skip;
1038 for (pass = 0; pass < 2; ++
pass) {
1041 skip = bytestream2_get_le16(&skip_map_ptr);
1048 if (skip != -0x8000 && skip) {
1049 opcode = bytestream2_get_le16(&decoding_map_ptr);
1055 skip = bytestream2_get_le16(&skip_map_ptr);
1063 skip = bytestream2_get_le16(&skip_map_ptr);
1070 if (skip != -0x8000 && skip) {
1076 skip = bytestream2_get_le16(&skip_map_ptr);
1079 if (changed_block) {
1094 "decode finished with %d bytes left over\n",
1102 unsigned char opcode;
1129 " block @ (%3d, %3d): encoding 0x%X, data ptr offset %d\n",
1150 "decode finished with %d bytes left over\n",
1202 void *
data,
int *got_frame,
1206 int buf_size = avpkt->
size;
1212 int video_data_size;
1236 frame_format =
AV_RL8(buf);
1237 send_buffer =
AV_RL8(buf + 1);
1238 video_data_size =
AV_RL16(buf + 2);
1242 switch(frame_format) {
1263 if (video_data_size <= 0)
1266 if (buf_size < 8 + s->decoding_map_size + 14 + video_data_size)
1289 if (buf_size < 8 + video_data_size + s->decoding_map_size + s->
skip_map_size)
1309 if (buf_size < 8 + video_data_size + s->decoding_map_size)
1322 if (buf_size < 8 + s->decoding_map_size + video_data_size + s->
skip_map_size) {
1341 switch(frame_format) {
1353 *got_frame = send_buffer;
1378 .
name =
"interplayvideo",
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
const unsigned char * decoding_map
ptrdiff_t const GLvoid * data
static void ipvideo_format_06_secondpass(IpvideoContext *s, AVFrame *frame, int16_t opcode)
unsigned char * pixel_ptr
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static av_cold int init(AVCodecContext *avctx)
static void(*const ipvideo_format_06_passes[])(IpvideoContext *s, AVFrame *frame, int16_t op)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static void(*const ipvideo_format_10_passes[])(IpvideoContext *s, AVFrame *frame, int16_t op)
static int ipvideo_decode_block_opcode_0x4(IpvideoContext *s, AVFrame *frame)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static void ipvideo_decode_format_11_opcodes(IpvideoContext *s, AVFrame *frame)
static int(*const ipvideo_decode_block16[])(IpvideoContext *s, AVFrame *frame)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static int ipvideo_decode_block_opcode_0xA(IpvideoContext *s, AVFrame *frame)
static int ipvideo_decode_block_opcode_0x2(IpvideoContext *s, AVFrame *frame)
8 bits with AV_PIX_FMT_RGB32 palette
static int ipvideo_decode_block_opcode_0x9(IpvideoContext *s, AVFrame *frame)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
static int ipvideo_decode_block_opcode_0x7_16(IpvideoContext *s, AVFrame *frame)
static void ipvideo_format_10_secondpass(IpvideoContext *s, AVFrame *frame, int16_t opcode)
bitstream reader API header.
static void ipvideo_format_06_firstpass(IpvideoContext *s, AVFrame *frame, int16_t opcode)
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
static int get_bits_left(GetBitContext *gb)
static int ipvideo_decode_block_opcode_0x5(IpvideoContext *s, AVFrame *frame)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int ipvideo_decode_block_opcode_0x8_16(IpvideoContext *s, AVFrame *frame)
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette...
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
static void ipvideo_decode_format_10_opcodes(IpvideoContext *s, AVFrame *frame)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int ipvideo_decode_block_opcode_0xD(IpvideoContext *s, AVFrame *frame)
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
static int ipvideo_decode_block_opcode_0xE_16(IpvideoContext *s, AVFrame *frame)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
int flags
AV_CODEC_FLAG_*.
static av_cold int ipvideo_decode_end(AVCodecContext *avctx)
const char * name
Name of the codec implementation.
static void ipvideo_decode_format_06_opcodes(IpvideoContext *s, AVFrame *frame)
static int ipvideo_decode_block_opcode_0xC_16(IpvideoContext *s, AVFrame *frame)
GetByteContext stream_ptr
static int ipvideo_decode_block_opcode_0x0(IpvideoContext *s, AVFrame *frame)
av_cold void ff_hpeldsp_init(HpelDSPContext *c, int flags)
static int ipvideo_decode_block_opcode_0x8(IpvideoContext *s, AVFrame *frame)
int width
picture width / height.
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
static int ipvideo_decode_block_opcode_0x3(IpvideoContext *s, AVFrame *frame)
static int copy_from(IpvideoContext *s, AVFrame *src, AVFrame *dst, int delta_x, int delta_y)
static int ipvideo_decode_block_opcode_0x1(IpvideoContext *s, AVFrame *frame)
AVFrame * second_last_frame
static void error(const char *err)
static av_always_inline int bytestream2_tell(GetByteContext *g)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
static int ipvideo_decode_block_opcode_0x6(IpvideoContext *s, AVFrame *frame)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
op_pixels_func put_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
static int ipvideo_decode_block_opcode_0xD_16(IpvideoContext *s, AVFrame *frame)
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.
AVFrame * cur_decode_frame
static int ipvideo_decode_block_opcode_0x6_16(IpvideoContext *s, AVFrame *frame)
static void ipvideo_format_10_firstpass(IpvideoContext *s, AVFrame *frame, int16_t opcode)
AVCodec ff_interplay_video_decoder
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
static int ipvideo_decode_block_opcode_0xB_16(IpvideoContext *s, AVFrame *frame)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int ipvideo_decode_block_opcode_0xE(IpvideoContext *s, AVFrame *frame)
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
common internal api header.
static int ipvideo_decode_block_opcode_0x9_16(IpvideoContext *s, AVFrame *frame)
#define AV_CODEC_CAP_PARAM_CHANGE
Codec supports changed parameters at any point.
int upper_motion_limit_offset
AVFrame * prev_decode_frame
#define AV_PIX_FMT_RGB555
static int ipvideo_decode_block_opcode_0xF(IpvideoContext *s, AVFrame *frame)
const unsigned char * skip_map
static int ipvideo_decode_block_opcode_0xB(IpvideoContext *s, AVFrame *frame)
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
static int ipvideo_decode_block_opcode_0xA_16(IpvideoContext *s, AVFrame *frame)
int frame_number
Frame counter, set by libavcodec.
static int ipvideo_decode_block_opcode_0x7(IpvideoContext *s, AVFrame *frame)
#define FFSWAP(type, a, b)
static int(*const ipvideo_decode_block[])(IpvideoContext *s, AVFrame *frame)
static int ipvideo_decode_block_opcode_0xC(IpvideoContext *s, AVFrame *frame)
This structure stores compressed data.
static int ipvideo_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.