[FFmpeg-cvslog] vcr1: group encoder code together to save #ifdefs

Diego Biurrun git at videolan.org
Thu May 10 23:33:14 CEST 2012


ffmpeg | branch: master | Diego Biurrun <diego at biurrun.de> | Mon Apr  9 18:11:35 2012 +0200| [51c4d870936976039807bbc881850cf6491fc89a] | committer: Diego Biurrun

vcr1: group encoder code together to save #ifdefs

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=51c4d870936976039807bbc881850cf6491fc89a
---

 libavcodec/vcr1.c |   90 +++++++++++++++++++++++++---------------------------
 1 files changed, 43 insertions(+), 47 deletions(-)

diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c
index 681150d..a745e58 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,



More information about the ffmpeg-cvslog mailing list