Commit 51c4d870 authored by Diego Biurrun's avatar Diego Biurrun

vcr1: group encoder code together to save #ifdefs

parent db1e403c
...@@ -27,10 +27,6 @@ ...@@ -27,10 +27,6 @@
#include "avcodec.h" #include "avcodec.h"
#include "dsputil.h" #include "dsputil.h"
/* Disable the encoder. */
#undef CONFIG_VCR1_ENCODER
#define CONFIG_VCR1_ENCODER 0
typedef struct VCR1Context { typedef struct VCR1Context {
AVCodecContext *avctx; AVCodecContext *avctx;
AVFrame picture; AVFrame picture;
...@@ -38,6 +34,33 @@ typedef struct VCR1Context { ...@@ -38,6 +34,33 @@ typedef struct VCR1Context {
int offset[4]; int offset[4];
} VCR1Context; } VCR1Context;
static av_cold void common_init(AVCodecContext *avctx)
{
VCR1Context *const a = avctx->priv_data;
avctx->coded_frame = &a->picture;
a->avctx = avctx;
}
static av_cold int decode_init(AVCodecContext *avctx)
{
common_init(avctx);
avctx->pix_fmt = PIX_FMT_YUV410P;
return 0;
}
static av_cold int decode_end(AVCodecContext *avctx)
{
VCR1Context *s = avctx->priv_data;
if (s->picture.data[0])
avctx->release_buffer(avctx, &s->picture);
return 0;
}
static int decode_frame(AVCodecContext *avctx, void *data, static int decode_frame(AVCodecContext *avctx, void *data,
int *data_size, AVPacket *avpkt) int *data_size, AVPacket *avpkt)
{ {
...@@ -113,6 +136,22 @@ static int decode_frame(AVCodecContext *avctx, void *data, ...@@ -113,6 +136,22 @@ static int decode_frame(AVCodecContext *avctx, void *data,
return buf_size; return buf_size;
} }
AVCodec ff_vcr1_decoder = {
.name = "vcr1",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_VCR1,
.priv_data_size = sizeof(VCR1Context),
.init = decode_init,
.close = decode_end,
.decode = decode_frame,
.capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("ATI VCR1"),
};
/* Disable the encoder. */
#undef CONFIG_VCR1_ENCODER
#define CONFIG_VCR1_ENCODER 0
#if CONFIG_VCR1_ENCODER #if CONFIG_VCR1_ENCODER
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
int buf_size, void *data) int buf_size, void *data)
...@@ -134,57 +173,14 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, ...@@ -134,57 +173,14 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
return size * 4; return size * 4;
} }
#endif
static av_cold void common_init(AVCodecContext *avctx)
{
VCR1Context *const a = avctx->priv_data;
avctx->coded_frame = &a->picture;
a->avctx = avctx;
}
static av_cold int decode_init(AVCodecContext *avctx)
{
common_init(avctx);
avctx->pix_fmt = PIX_FMT_YUV410P;
return 0;
}
static av_cold int decode_end(AVCodecContext *avctx)
{
VCR1Context *s = avctx->priv_data;
if (s->picture.data[0])
avctx->release_buffer(avctx, &s->picture);
return 0;
}
#if CONFIG_VCR1_ENCODER
static av_cold int encode_init(AVCodecContext *avctx) static av_cold int encode_init(AVCodecContext *avctx)
{ {
common_init(avctx); common_init(avctx);
return 0; return 0;
} }
#endif
AVCodec ff_vcr1_decoder = {
.name = "vcr1",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_VCR1,
.priv_data_size = sizeof(VCR1Context),
.init = decode_init,
.close = decode_end,
.decode = decode_frame,
.capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("ATI VCR1"),
};
#if CONFIG_VCR1_ENCODER
AVCodec ff_vcr1_encoder = { AVCodec ff_vcr1_encoder = {
.name = "vcr1", .name = "vcr1",
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment