summaryrefslogtreecommitdiff
path: root/libavcodec/vcr1.c
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2012-04-09 18:11:35 +0200
committerDiego Biurrun <diego@biurrun.de>2012-05-09 23:24:07 +0200
commit51c4d870936976039807bbc881850cf6491fc89a (patch)
tree7267877b69860653641c04ab9afc74c9acf7afbf /libavcodec/vcr1.c
parentdb1e403cfbfdba00826c458fa80c4cd83d5499ec (diff)
vcr1: group encoder code together to save #ifdefs
Diffstat (limited to 'libavcodec/vcr1.c')
-rw-r--r--libavcodec/vcr1.c90
1 files changed, 43 insertions, 47 deletions
diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c
index 681150d80e..a745e58300 100644
--- a/libavcodec/vcr1.c
+++ b/libavcodec/vcr1.c
@@ -27,10 +27,6 @@
#include "avcodec.h"
#include "dsputil.h"
-/* Disable the encoder. */
-#undef CONFIG_VCR1_ENCODER
-#define CONFIG_VCR1_ENCODER 0
-
typedef struct VCR1Context {
AVCodecContext *avctx;
AVFrame picture;
@@ -38,6 +34,33 @@ typedef struct VCR1Context {
int offset[4];
} 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,
int *data_size, AVPacket *avpkt)
{
@@ -113,6 +136,22 @@ static int decode_frame(AVCodecContext *avctx, void *data,
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
static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
int buf_size, void *data)
@@ -134,57 +173,14 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
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)
{
common_init(avctx);
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 = {
.name = "vcr1",
.type = AVMEDIA_TYPE_VIDEO,