51 const uint8_t *buf = avpkt->
data;
52 const uint8_t *buf_end = buf + avpkt->
size;
56 int outcnt = 0, maxcnt;
66 if (avpkt->
size < 2 +
w*
h / 513)
76 if (!
c->frame_buffer) {
79 if (!
c->frame_buffer || !
c->last_frame_buffer) {
89 out = (uint8_t*)
c->frame_buffer;
90 prev = (uint8_t*)
c->last_frame_buffer;
92 for (
i = 0;
i < 8;
i++)
95 while (outcnt < maxcnt && buf_end - 2 >= buf) {
99 if (!(
code & 0x8000)) {
105 if ((
code & 0x6000) == 0x6000) {
107 int oidx = (
code >> 10) & 7;
110 count = (
code & 0x3FF) + 3;
113 if (buf_end - 3 < buf)
119 start = (outcnt +
offsets[oidx]) % maxcnt;
121 if (maxcnt - start < count || maxcnt - outcnt < count)
126 "Frame reference does not exist\n");
130 memcpy(
out + 2 * outcnt, prev + 2 * start, 2 * count);
135 if (!(
code & 0x6000)) {
137 }
else if ((
code & 0x6000) == 0x2000) {
140 if (buf_end - 1 < buf)
145 if (outcnt <
offset || maxcnt - outcnt < count)
158 (
const uint8_t*)
c->frame_buffer, avctx->
width * 2,
160 FFSWAP(uint16_t *,
c->frame_buffer,
c->last_frame_buffer);
static av_cold void decode_flush(AVCodecContext *avctx)
const FFCodec ff_kgv1_decoder
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
common internal and external API header
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
Overlapping memcpy() implementation.
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
static const int offsets[]
static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
static av_cold int decode_init(AVCodecContext *avctx)
static av_cold int decode_end(AVCodecContext *avctx)
static void decode_flush(AVCodecContext *avctx)
static av_cold int decode_init(AVCodecContext *avctx)
static av_cold int decode_end(AVCodecContext *avctx)
static int decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_frame, AVPacket *avpkt)
#define FFSWAP(type, a, b)
Memory handling functions.
#define AV_PIX_FMT_RGB555
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
uint16_t * last_frame_buffer