changeset 10460:059265d3cc65 libavcodec

Move PNM init/end functions to the PNM common code. This is done in preparation for the PNM encoder/decoder split.
author diego
date Tue, 27 Oct 2009 17:15:05 +0000
parents a6bb56636f90
children bfb6c7ff97b4
files pnm.c pnm.h pnmenc.c
diffstat 3 files changed, 37 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/pnm.c	Tue Oct 27 16:57:35 2009 +0000
+++ b/pnm.c	Tue Oct 27 17:15:05 2009 +0000
@@ -162,3 +162,23 @@
     }
     return 0;
 }
+
+av_cold int ff_pnm_end(AVCodecContext *avctx)
+{
+    PNMContext *s = avctx->priv_data;
+
+    if (s->picture.data[0])
+        avctx->release_buffer(avctx, &s->picture);
+
+    return 0;
+}
+
+av_cold int ff_pnm_init(AVCodecContext *avctx)
+{
+    PNMContext *s = avctx->priv_data;
+
+    avcodec_get_frame_defaults((AVFrame*)&s->picture);
+    avctx->coded_frame = (AVFrame*)&s->picture;
+
+    return 0;
+}
--- a/pnm.h	Tue Oct 27 16:57:35 2009 +0000
+++ b/pnm.h	Tue Oct 27 17:15:05 2009 +0000
@@ -33,5 +33,7 @@
 } PNMContext;
 
 int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s);
+av_cold int ff_pnm_end(AVCodecContext *avctx);
+av_cold int ff_pnm_init(AVCodecContext *avctx);
 
 #endif /* AVCODEC_PNM_H */
--- a/pnmenc.c	Tue Oct 27 16:57:35 2009 +0000
+++ b/pnmenc.c	Tue Oct 27 17:15:05 2009 +0000
@@ -24,16 +24,6 @@
 #include "pnm.h"
 
 
-static av_cold int common_init(AVCodecContext *avctx)
-{
-    PNMContext *s = avctx->priv_data;
-
-    avcodec_get_frame_defaults((AVFrame*)&s->picture);
-    avctx->coded_frame = (AVFrame*)&s->picture;
-
-    return 0;
-}
-
 static int pnm_decode_frame(AVCodecContext *avctx, void *data,
                             int *data_size, AVPacket *avpkt)
 {
@@ -332,16 +322,6 @@
     return s->bytestream - s->bytestream_start;
 }
 
-static av_cold int common_end(AVCodecContext *avctx)
-{
-    PNMContext *s = avctx->priv_data;
-
-    if (s->picture.data[0])
-        avctx->release_buffer(avctx, &s->picture);
-
-    return 0;
-}
-
 
 #if CONFIG_PGM_DECODER
 AVCodec pgm_decoder = {
@@ -349,9 +329,9 @@
     CODEC_TYPE_VIDEO,
     CODEC_ID_PGM,
     sizeof(PNMContext),
-    common_init,
+    ff_pnm_init,
     NULL,
-    common_end,
+    ff_pnm_end,
     pnm_decode_frame,
     CODEC_CAP_DR1,
     .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE},
@@ -365,7 +345,7 @@
     CODEC_TYPE_VIDEO,
     CODEC_ID_PGM,
     sizeof(PNMContext),
-    common_init,
+    ff_pnm_init,
     pnm_encode_frame,
     .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
@@ -378,9 +358,9 @@
     CODEC_TYPE_VIDEO,
     CODEC_ID_PGMYUV,
     sizeof(PNMContext),
-    common_init,
+    ff_pnm_init,
     NULL,
-    common_end,
+    ff_pnm_end,
     pnm_decode_frame,
     CODEC_CAP_DR1,
     .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
@@ -394,7 +374,7 @@
     CODEC_TYPE_VIDEO,
     CODEC_ID_PGMYUV,
     sizeof(PNMContext),
-    common_init,
+    ff_pnm_init,
     pnm_encode_frame,
     .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"),
@@ -407,9 +387,9 @@
     CODEC_TYPE_VIDEO,
     CODEC_ID_PPM,
     sizeof(PNMContext),
-    common_init,
+    ff_pnm_init,
     NULL,
-    common_end,
+    ff_pnm_end,
     pnm_decode_frame,
     CODEC_CAP_DR1,
     .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE},
@@ -423,7 +403,7 @@
     CODEC_TYPE_VIDEO,
     CODEC_ID_PPM,
     sizeof(PNMContext),
-    common_init,
+    ff_pnm_init,
     pnm_encode_frame,
     .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
@@ -436,9 +416,9 @@
     CODEC_TYPE_VIDEO,
     CODEC_ID_PBM,
     sizeof(PNMContext),
-    common_init,
+    ff_pnm_init,
     NULL,
-    common_end,
+    ff_pnm_end,
     pnm_decode_frame,
     CODEC_CAP_DR1,
     .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE},
@@ -452,7 +432,7 @@
     CODEC_TYPE_VIDEO,
     CODEC_ID_PBM,
     sizeof(PNMContext),
-    common_init,
+    ff_pnm_init,
     pnm_encode_frame,
     .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
@@ -465,9 +445,9 @@
     CODEC_TYPE_VIDEO,
     CODEC_ID_PAM,
     sizeof(PNMContext),
-    common_init,
+    ff_pnm_init,
     NULL,
-    common_end,
+    ff_pnm_end,
     pnm_decode_frame,
     CODEC_CAP_DR1,
     .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE},
@@ -481,7 +461,7 @@
     CODEC_TYPE_VIDEO,
     CODEC_ID_PAM,
     sizeof(PNMContext),
-    common_init,
+    ff_pnm_init,
     pam_encode_frame,
     .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),