summaryrefslogtreecommitdiff
path: root/libavcodec/cljr.c
diff options
context:
space:
mode:
authorMans Rullgard <mans@mansr.com>2011-12-08 14:48:12 +0000
committerMans Rullgard <mans@mansr.com>2011-12-08 15:56:30 +0000
commitbaf3b6e5947e3bfaa8778cfd16df4f2465854e2b (patch)
tree43a67e1395c897b95f170684d5f54378d683bfae /libavcodec/cljr.c
parent9a1420bfda41f32a9e1b6d57517d2d4c6924c434 (diff)
downloadffmpeg-baf3b6e5947e3bfaa8778cfd16df4f2465854e2b.tar.gz
cljr: group encode/decode parts under single ifdefs
This groups the encode/decode parts under single ifdefs and eliminates the encode_init() function as it merely calls common_init(). Also fix whitespace in moved code. Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libavcodec/cljr.c')
-rw-r--r--libavcodec/cljr.c88
1 files changed, 40 insertions, 48 deletions
diff --git a/libavcodec/cljr.c b/libavcodec/cljr.c
index 1b8bc53fb3..b418647ddb 100644
--- a/libavcodec/cljr.c
+++ b/libavcodec/cljr.c
@@ -33,6 +33,17 @@ typedef struct CLJRContext{
AVFrame picture;
} CLJRContext;
+static av_cold int common_init(AVCodecContext *avctx)
+{
+ CLJRContext * const a = avctx->priv_data;
+
+ avctx->coded_frame = (AVFrame*)&a->picture;
+ a->avctx = avctx;
+
+ return 0;
+}
+
+#if CONFIG_CLJR_DECODER
static int decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
@@ -86,6 +97,34 @@ static int decode_frame(AVCodecContext *avctx,
return buf_size;
}
+static av_cold int decode_init(AVCodecContext *avctx)
+{
+ avctx->pix_fmt = PIX_FMT_YUV411P;
+ return common_init(avctx);
+}
+
+static av_cold int decode_end(AVCodecContext *avctx)
+{
+ CLJRContext *a = avctx->priv_data;
+
+ if (a->picture.data[0])
+ avctx->release_buffer(avctx, &a->picture);
+ return 0;
+}
+
+AVCodec ff_cljr_decoder = {
+ .name = "cljr",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = CODEC_ID_CLJR,
+ .priv_data_size = sizeof(CLJRContext),
+ .init = decode_init,
+ .close = decode_end,
+ .decode = decode_frame,
+ .capabilities = CODEC_CAP_DR1,
+ .long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"),
+};
+#endif
+
#if CONFIG_CLJR_ENCODER
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
PutBitContext pb;
@@ -118,60 +157,13 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
return put_bits_count(&pb) / 8;
}
-#endif
-
-static av_cold void common_init(AVCodecContext *avctx){
- CLJRContext * const a = avctx->priv_data;
-
- avctx->coded_frame= (AVFrame*)&a->picture;
- a->avctx= avctx;
-}
-
-static av_cold int decode_init(AVCodecContext *avctx){
-
- common_init(avctx);
-
- avctx->pix_fmt= PIX_FMT_YUV411P;
-
- return 0;
-}
-
-static av_cold int decode_end(AVCodecContext *avctx) {
- CLJRContext *a = avctx->priv_data;
-
- if (a->picture.data[0])
- avctx->release_buffer(avctx, &a->picture);
- return 0;
-}
-
-#if CONFIG_CLJR_ENCODER
-static av_cold int encode_init(AVCodecContext *avctx){
-
- common_init(avctx);
-
- return 0;
-}
-#endif
-AVCodec ff_cljr_decoder = {
- .name = "cljr",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = CODEC_ID_CLJR,
- .priv_data_size = sizeof(CLJRContext),
- .init = decode_init,
- .close = decode_end,
- .decode = decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"),
-};
-
-#if CONFIG_CLJR_ENCODER
AVCodec ff_cljr_encoder = {
.name = "cljr",
.type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_CLJR,
.priv_data_size = sizeof(CLJRContext),
- .init = encode_init,
+ .init = common_init,
.encode = encode_frame,
.pix_fmts = (const enum PixelFormat[]) { PIX_FMT_YUV411P,
PIX_FMT_NONE },