1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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>
This commit is contained in:
Mans Rullgard 2011-12-08 14:48:12 +00:00
parent 9a1420bfda
commit baf3b6e594

View File

@ -33,6 +33,17 @@ typedef struct CLJRContext{
AVFrame picture; AVFrame picture;
} CLJRContext; } 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, static int decode_frame(AVCodecContext *avctx,
void *data, int *data_size, void *data, int *data_size,
AVPacket *avpkt) AVPacket *avpkt)
@ -86,6 +97,34 @@ static int decode_frame(AVCodecContext *avctx,
return buf_size; 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 #if CONFIG_CLJR_ENCODER
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
PutBitContext pb; PutBitContext pb;
@ -118,60 +157,13 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
return put_bits_count(&pb) / 8; 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 = { AVCodec ff_cljr_encoder = {
.name = "cljr", .name = "cljr",
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.id = CODEC_ID_CLJR, .id = CODEC_ID_CLJR,
.priv_data_size = sizeof(CLJRContext), .priv_data_size = sizeof(CLJRContext),
.init = encode_init, .init = common_init,
.encode = encode_frame, .encode = encode_frame,
.pix_fmts = (const enum PixelFormat[]) { PIX_FMT_YUV411P, .pix_fmts = (const enum PixelFormat[]) { PIX_FMT_YUV411P,
PIX_FMT_NONE }, PIX_FMT_NONE },