#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
+#include "internal.h"
-static const enum PixelFormat pixfmt_rgb24[] = {
- PIX_FMT_BGR24, PIX_FMT_RGB32, PIX_FMT_NONE };
+static const enum AVPixelFormat pixfmt_rgb24[] = {
+ AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE };
-/*
- * Decoder context
- */
typedef struct EightBpsContext {
AVCodecContext *avctx;
AVFrame pic;
uint32_t pal[256];
} EightBpsContext;
-
-/*
- *
- * Decode a frame
- *
- */
static int decode_frame(AVCodecContext *avctx, void *data,
- int *data_size, AVPacket *avpkt)
+ int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
c->pic.reference = 0;
c->pic.buffer_hints = FF_BUFFER_HINTS_VALID;
- if (avctx->get_buffer(avctx, &c->pic) < 0){
+ if (ff_get_buffer(avctx, &c->pic) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
if (planes == 4)
planes--;
- px_inc = planes + (avctx->pix_fmt == PIX_FMT_RGB32);
+ px_inc = planes + (avctx->pix_fmt == AV_PIX_FMT_RGB32);
for (p = 0; p < planes; p++) {
/* Lines length pointer for this plane */
memcpy (c->pic.data[1], c->pal, AVPALETTE_SIZE);
}
- *data_size = sizeof(AVFrame);
+ *got_frame = 1;
*(AVFrame*)data = c->pic;
/* always report that the buffer was completely consumed */
return buf_size;
}
-
-/*
- *
- * Init 8BPS decoder
- *
- */
static av_cold int decode_init(AVCodecContext *avctx)
{
EightBpsContext * const c = avctx->priv_data;
switch (avctx->bits_per_coded_sample) {
case 8:
- avctx->pix_fmt = PIX_FMT_PAL8;
+ avctx->pix_fmt = AV_PIX_FMT_PAL8;
c->planes = 1;
c->planemap[0] = 0; // 1st plane is palette indexes
break;
c->planemap[2] = 0; // 3rd plane is blue
break;
case 32:
- avctx->pix_fmt = PIX_FMT_RGB32;
+ avctx->pix_fmt = AV_PIX_FMT_RGB32;
c->planes = 4;
#if HAVE_BIGENDIAN
c->planemap[0] = 1; // 1st plane is red
return 0;
}
-
-
-
-/*
- *
- * Uninit 8BPS decoder
- *
- */
static av_cold int decode_end(AVCodecContext *avctx)
{
EightBpsContext * const c = avctx->priv_data;
return 0;
}
-
-
AVCodec ff_eightbps_decoder = {
.name = "8bps",
.type = AVMEDIA_TYPE_VIDEO,