- destination = vid->frame.data[0];
- frame_end = vid->frame.data[0] + vid->frame.linesize[0] * avctx->height;
-
- switch(block_type = *buf++)
- {
- case PALETTE_BLOCK: set_palette(&vid->frame, buf); return 0;
- case VIDEO_YOFFSET_DIFFERENCE_FRAME_BLOCK:
- yoffset = bytestream_get_le16(&buf);
- if(yoffset >= avctx->height) { return -1; }
- destination += vid->frame.linesize[0] * yoffset;
+ wrap_to_next_line = vid->frame->linesize[0] - avctx->width;
+
+ if (avpkt->side_data_elems > 0 &&
+ avpkt->side_data[0].type == AV_PKT_DATA_PALETTE) {
+ bytestream2_init(&vid->g, avpkt->side_data[0].data,
+ avpkt->side_data[0].size);
+ if ((ret = set_palette(vid)) < 0)
+ return ret;
+ }
+
+ bytestream2_init(&vid->g, avpkt->data, avpkt->size);
+ dst = vid->frame->data[0];
+ frame_end = vid->frame->data[0] + vid->frame->linesize[0] * avctx->height;
+
+ switch(block_type = bytestream2_get_byte(&vid->g)){
+ case PALETTE_BLOCK: {
+ *got_frame = 0;
+ if ((ret = set_palette(vid)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "error reading palette\n");
+ return ret;
+ }
+ return bytestream2_tell(&vid->g);
+ }
+ case VIDEO_YOFF_P_FRAME:
+ yoffset = bytestream2_get_le16(&vid->g);
+ if(yoffset >= avctx->height)
+ return AVERROR_INVALIDDATA;
+ dst += vid->frame->linesize[0] * yoffset;