]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/libopenjpegenc.c
Merge commit '0c00fd80ee4791bd70b634084307fc9f179e0412'
[ffmpeg] / libavcodec / libopenjpegenc.c
index bd741df9853cc56b0aaafc6612391e0023586245..0388fc513126989089ac95008e7808c3c087c711 100644 (file)
  */
 
 /**
-* @file
-* JPEG 2000 encoder using libopenjpeg
-*/
+ * @file
+ * JPEG 2000 encoder using libopenjpeg
+ */
 
 #define  OPJ_STATIC
 #include <openjpeg.h>
 
-#include "libavutil/opt.h"
-#include "libavutil/imgutils.h"
 #include "libavutil/avassert.h"
-#include "avcodec.h"
+#include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/opt.h"
+#include "avcodec.h"
 #include "internal.h"
 
 typedef struct {
@@ -284,9 +284,8 @@ static int libopenjpeg_copy_unpacked8(AVCodecContext *avctx, const AVFrame *fram
         for (y = 0; y < height; ++y) {
             image_index = y * width;
             frame_index = y * frame->linesize[compno];
-            for (x = 0; x < width; ++x) {
+            for (x = 0; x < width; ++x)
                 image->comps[compno].data[image_index++] = frame->data[compno][frame_index++];
-            }
         }
     }
 
@@ -319,9 +318,8 @@ static int libopenjpeg_copy_unpacked16(AVCodecContext *avctx, const AVFrame *fra
         for (y = 0; y < height; ++y) {
             image_index = y * width;
             frame_index = y * (frame->linesize[compno] / 2);
-            for (x = 0; x < width; ++x) {
+            for (x = 0; x < width; ++x)
                 image->comps[compno].data[image_index++] = frame_ptr[frame_index++];
-            }
         }
     }
 
@@ -333,7 +331,7 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 {
     LibOpenJPEGContext *ctx = avctx->priv_data;
     opj_cinfo_t *compress = ctx->compress;
-    opj_image_t *image = ctx->image;
+    opj_image_t *image    = ctx->image;
     opj_cio_t *stream;
     int cpyresult = 0;
     int ret, len;
@@ -342,7 +340,7 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     // x1, y1 is the width, height of the reference grid
     image->x0 = 0;
     image->y0 = 0;
-    image->x1 = (avctx->width - 1) * ctx->enc_params.subsampling_dx + 1;
+    image->x1 = (avctx->width  - 1) * ctx->enc_params.subsampling_dx + 1;
     image->y1 = (avctx->height - 1) * ctx->enc_params.subsampling_dy + 1;
 
     switch (avctx->pix_fmt) {
@@ -432,7 +430,7 @@ static av_cold int libopenjpeg_encode_close(AVCodecContext *avctx)
     opj_destroy_compress(ctx->compress);
     opj_image_destroy(ctx->image);
     av_freep(&avctx->coded_frame);
-    return 0 ;
+    return 0;
 }
 
 #define OFFSET(x) offsetof(LibOpenJPEGContext, x)
@@ -456,7 +454,7 @@ static const AVOption options[] = {
     { "rpcl",          NULL,                0,                     AV_OPT_TYPE_CONST, { RPCL        }, 0,         0,           VE, "prog_order"  },
     { "pcrl",          NULL,                0,                     AV_OPT_TYPE_CONST, { PCRL        }, 0,         0,           VE, "prog_order"  },
     { "cprl",          NULL,                0,                     AV_OPT_TYPE_CONST, { CPRL        }, 0,         0,           VE, "prog_order"  },
-    { "numresolution", NULL,                OFFSET(numresolution), AV_OPT_TYPE_INT,   { 6           }, 1,         10,          VE                },
+    { "numresolution", NULL,                OFFSET(numresolution), AV_OPT_TYPE_INT,   { 6           }, 1,         INT_MAX,     VE                },
     { "numlayers",     NULL,                OFFSET(numlayers),     AV_OPT_TYPE_INT,   { 1           }, 1,         10,          VE                },
     { "disto_alloc",   NULL,                OFFSET(disto_alloc),   AV_OPT_TYPE_INT,   { 1           }, 0,         1,           VE                },
     { "fixed_alloc",   NULL,                OFFSET(fixed_alloc),   AV_OPT_TYPE_INT,   { 0           }, 0,         1,           VE                },
@@ -474,13 +472,13 @@ static const AVClass class = {
 AVCodec ff_libopenjpeg_encoder = {
     .name           = "libopenjpeg",
     .type           = AVMEDIA_TYPE_VIDEO,
-    .id             = CODEC_ID_JPEG2000,
+    .id             = AV_CODEC_ID_JPEG2000,
     .priv_data_size = sizeof(LibOpenJPEGContext),
     .init           = libopenjpeg_encode_init,
     .encode2        = libopenjpeg_encode_frame,
     .close          = libopenjpeg_encode_close,
     .capabilities   = 0,
-    .pix_fmts       = (const enum PixelFormat[]){
+    .pix_fmts       = (const enum PixelFormat[]) {
         PIX_FMT_RGB24, PIX_FMT_RGBA, PIX_FMT_RGB48, PIX_FMT_RGBA64,
         PIX_FMT_GRAY8, PIX_FMT_GRAY8A, PIX_FMT_GRAY16,
         PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_YUVA420P,