]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/j2kenc.c
vble: remove flags copy, its not used in any speed relevant code.
[ffmpeg] / libavcodec / j2kenc.c
index 21e11e12e1383286e38f086bea1057570a631a54..50b2b2137aa50c4fe6aa1ce007bef459095af648 100644 (file)
@@ -59,7 +59,7 @@ typedef struct {
 
 typedef struct {
     AVCodecContext *avctx;
-    AVFrame *picture;
+    AVFrame picture;
 
     int width, height; ///< image width and height
     uint8_t cbps[4]; ///< bits per sample in particular components
@@ -285,7 +285,11 @@ static int put_cod(J2kEncoderContext *s)
     // SGcod
     bytestream_put_byte(&s->buf, 0); // progression level
     bytestream_put_be16(&s->buf, 1); // num of layers
-    bytestream_put_byte(&s->buf, 0); // multiple component transformation
+    if(s->avctx->pix_fmt == PIX_FMT_YUV444P){
+        bytestream_put_byte(&s->buf, 2); // ICT
+    }else{
+        bytestream_put_byte(&s->buf, 0); // unspecified
+    }
     // SPcod
     bytestream_put_byte(&s->buf, codsty->nreslevels - 1); // num of decomp. levels
     bytestream_put_byte(&s->buf, codsty->log2_cblk_width-2); // cblk width
@@ -326,7 +330,7 @@ static uint8_t *put_sot(J2kEncoderContext *s, int tileno)
     uint8_t *psotptr;
 
     if (s->buf_end - s->buf < 12)
-        return -1;
+        return NULL;
 
     bytestream_put_be16(&s->buf, J2K_SOT);
     bytestream_put_be16(&s->buf, 10); // Lsot
@@ -394,18 +398,18 @@ static void copy_frame(J2kEncoderContext *s)
             for (compno = 0; compno < s->ncomponents; compno++){
                 J2kComponent *comp = tile->comp + compno;
                 int *dst = comp->data;
-                line = s->picture->data[compno]
-                       + comp->coord[1][0] * s->picture->linesize[compno]
+                line = s->picture.data[compno]
+                       + comp->coord[1][0] * s->picture.linesize[compno]
                        + comp->coord[0][0];
                 for (y = comp->coord[1][0]; y < comp->coord[1][1]; y++){
                     uint8_t *ptr = line;
                     for (x = comp->coord[0][0]; x < comp->coord[0][1]; x++)
                         *dst++ = *ptr++ - (1 << 7);
-                    line += s->picture->linesize[compno];
+                    line += s->picture.linesize[compno];
                 }
             }
         } else{
-            line = s->picture->data[0] + tile->comp[0].coord[1][0] * s->picture->linesize[0]
+            line = s->picture.data[0] + tile->comp[0].coord[1][0] * s->picture.linesize[0]
                    + tile->comp[0].coord[0][0] * s->ncomponents;
 
             i = 0;
@@ -416,7 +420,7 @@ static void copy_frame(J2kEncoderContext *s)
                         tile->comp[compno].data[i] = *ptr++  - (1 << 7);
                     }
                 }
-                line += s->picture->linesize[0];
+                line += s->picture.linesize[0];
             }
         }
     }
@@ -926,9 +930,10 @@ static int encode_frame(AVCodecContext *avctx,
     s->buf = s->buf_start = buf;
     s->buf_end = buf + buf_size;
 
-    s->picture = data;
+    s->picture = *(AVFrame*)data;
+    avctx->coded_frame= &s->picture;
 
-    s->lambda = s->picture->quality * LAMBDA_SCALE;
+    s->lambda = s->picture.quality * LAMBDA_SCALE;
 
     copy_frame(s);
     reinit(s);
@@ -945,8 +950,8 @@ static int encode_frame(AVCodecContext *avctx,
 
     for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){
         uint8_t *psotptr;
-        if ((psotptr = put_sot(s, tileno)) < 0)
-            return psotptr;
+        if (!(psotptr = put_sot(s, tileno)))
+            return -1;
         if (s->buf_end - s->buf < 2)
             return -1;
         bytestream_put_be16(&s->buf, J2K_SOD);
@@ -1038,9 +1043,11 @@ AVCodec ff_jpeg2000_encoder = {
     encode_frame,
     j2kenc_destroy,
     .capabilities= CODEC_CAP_EXPERIMENTAL,
+    .long_name = NULL_IF_CONFIG_SMALL("JPEG 2000"),
     .pix_fmts =
-        (enum PixelFormat[]) {PIX_FMT_GRAY8, PIX_FMT_RGB24,
+        (enum PixelFormat[]) {PIX_FMT_RGB24, PIX_FMT_YUV444P, PIX_FMT_GRAY8,
+/*                              PIX_FMT_YUV420P,
                               PIX_FMT_YUV422P, PIX_FMT_YUV444P,
-                              PIX_FMT_YUV410P, PIX_FMT_YUV411P,
+                              PIX_FMT_YUV410P, PIX_FMT_YUV411P,*/
                               -1}
 };