---
 Changelog              |    1 +
 doc/general.texi       |    2 +-
 libavcodec/allcodecs.c |    2 +-
 libavcodec/cljr.c      |   50 ++++++++++++++++++++++++++++++-----------------
 libavcodec/version.h   |    2 +-
 libavformat/riff.c     |    2 +-
 6 files changed, 37 insertions(+), 22 deletions(-)

diff --git a/Changelog b/Changelog
index bfb411e..ab4136a 100644
--- a/Changelog
+++ b/Changelog
@@ -105,6 +105,7 @@ easier to use. The changes are:
 - CRI ADX audio format demuxer
 - Playstation Portable PMP format demuxer
 - PCM format support in OMA demuxer
+- CLJR encoder
 
 
 version 0.7:
diff --git a/doc/general.texi b/doc/general.texi
index ca9731e..2c74e6d 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -382,7 +382,7 @@ following image formats are supported:
     @tab Codec used in Delphine Software International games.
 @item Discworld II BMV Video @tab     @tab  X
 @item Cinepak                @tab     @tab  X
-@item Cirrus Logic AccuPak   @tab     @tab  X
+@item Cirrus Logic AccuPak   @tab  X  @tab  X
     @tab fourcc: CLJR
 @item Creative YUV (CYUV)    @tab     @tab  X
 @item DFA                    @tab     @tab  X
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 82023ff..59795b1 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -87,7 +87,7 @@ void avcodec_register_all(void)
     REGISTER_DECODER (CAVS, cavs);
     REGISTER_DECODER (CDGRAPHICS, cdgraphics);
     REGISTER_DECODER (CINEPAK, cinepak);
-    REGISTER_DECODER (CLJR, cljr);
+    REGISTER_ENCDEC  (CLJR, cljr);
     REGISTER_DECODER (CSCD, cscd);
     REGISTER_DECODER (CYUV, cyuv);
     REGISTER_DECODER (DFA, dfa);
diff --git a/libavcodec/cljr.c b/libavcodec/cljr.c
index 6c7d7b0..4ac79f4 100644
--- a/libavcodec/cljr.c
+++ b/libavcodec/cljr.c
@@ -25,18 +25,15 @@
  */
 
 #include "avcodec.h"
-#include "dsputil.h"
 #include "get_bits.h"
-
-/* Disable the encoder. */
-#undef CONFIG_CLJR_ENCODER
-#define CONFIG_CLJR_ENCODER 0
+#include "put_bits.h"
 
 typedef struct CLJRContext{
     AVCodecContext *avctx;
     AVFrame picture;
 } CLJRContext;
 
+#if CONFIG_CLJR_DECODER
 static int decode_frame(AVCodecContext *avctx,
                         void *data, int *data_size,
                         AVPacket *avpkt)
@@ -89,27 +86,39 @@ static int decode_frame(AVCodecContext *avctx,
 
     return buf_size;
 }
+#endif /* CONFIG_CLJR_DECODER */
 
 #if CONFIG_CLJR_ENCODER
 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int 
buf_size, void *data){
-    CLJRContext * const a = avctx->priv_data;
-    AVFrame *pict = data;
-    AVFrame * const p= (AVFrame*)&a->picture;
-    int size;
+    PutBitContext pb;
+    AVFrame *p = data;
+    int x, y;
 
-    *p = *pict;
     p->pict_type= AV_PICTURE_TYPE_I;
     p->key_frame= 1;
 
-    emms_c();
+    init_put_bits(&pb, buf, buf_size / 8);
 
-    avpriv_align_put_bits(&a->pb);
-    while(get_bit_count(&a->pb)&31)
-        put_bits(&a->pb, 8, 0);
+    for (y = 0; y < avctx->height; y++) {
+        uint8_t *luma = &p->data[0][y * p->linesize[0]];
+        uint8_t *cb   = &p->data[1][y * p->linesize[1]];
+        uint8_t *cr   = &p->data[2][y * p->linesize[2]];
+        for (x = 0; x < avctx->width; x += 4) {
+            put_bits(&pb, 5, luma[3] >> 3);
+            put_bits(&pb, 5, luma[2] >> 3);
+            put_bits(&pb, 5, luma[1] >> 3);
+            put_bits(&pb, 5, luma[0] >> 3);
+            luma += 4;
+            put_bits(&pb, 6, *(cb++) >> 2);
+            put_bits(&pb, 6, *(cr++) >> 2);
+        }
+    }
 
-    size= get_bit_count(&a->pb)/32;
+    flush_put_bits(&pb);
 
-    return size*4;
+    emms_c();
+
+    return put_bits_count(&pb) / 8;
 }
 #endif
 
@@ -120,6 +129,7 @@ static av_cold void common_init(AVCodecContext *avctx){
     a->avctx= avctx;
 }
 
+#if CONFIG_CLJR_DECODER
 static av_cold int decode_init(AVCodecContext *avctx){
 
     common_init(avctx);
@@ -135,6 +145,7 @@ static av_cold int decode_end(AVCodecContext *avctx) {
     if (a->picture.data[0]);
         avctx->release_buffer(avctx, &a->picture);
 }
+#endif
 
 #if CONFIG_CLJR_ENCODER
 static av_cold int encode_init(AVCodecContext *avctx){
@@ -145,6 +156,7 @@ static av_cold int encode_init(AVCodecContext *avctx){
 }
 #endif
 
+#if CONFIG_CLJR_DECODER
 AVCodec ff_cljr_decoder = {
     .name           = "cljr",
     .type           = AVMEDIA_TYPE_VIDEO,
@@ -156,7 +168,7 @@ AVCodec ff_cljr_decoder = {
     .capabilities   = CODEC_CAP_DR1,
     .long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"),
 };
-
+#endif
 #if CONFIG_CLJR_ENCODER
 AVCodec ff_cljr_encoder = {
     .name           = "cljr",
@@ -165,6 +177,8 @@ AVCodec ff_cljr_encoder = {
     .priv_data_size = sizeof(CLJRContext),
     .init           = encode_init,
     .encode         = encode_frame,
-    .long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"),
+    .pix_fmts       = (const enum PixelFormat[]) { PIX_FMT_YUV411P,
+                                                   PIX_FMT_NONE },
+    .long_name      = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"),
 };
 #endif
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 3918b13..a41234f 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -21,7 +21,7 @@
 #define AVCODEC_VERSION_H
 
 #define LIBAVCODEC_VERSION_MAJOR 53
-#define LIBAVCODEC_VERSION_MINOR 26
+#define LIBAVCODEC_VERSION_MINOR 27
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/libavformat/riff.c b/libavformat/riff.c
index 2a989cd..1161e97 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -264,7 +264,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
     { CODEC_ID_TARGA,        MKTAG('t', 'g', 'a', ' ') },
     { CODEC_ID_PNG,          MKTAG('M', 'P', 'N', 'G') },
     { CODEC_ID_PNG,          MKTAG('P', 'N', 'G', '1') },
-    { CODEC_ID_CLJR,         MKTAG('c', 'l', 'j', 'r') },
+    { CODEC_ID_CLJR,         MKTAG('C', 'L', 'J', 'R') },
     { CODEC_ID_DIRAC,        MKTAG('d', 'r', 'a', 'c') },
     { CODEC_ID_RPZA,         MKTAG('a', 'z', 'p', 'r') },
     { CODEC_ID_RPZA,         MKTAG('R', 'P', 'Z', 'A') },
-- 
1.7.7

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to