FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
libopenjpegenc.c File Reference

JPEG 2000 encoder using libopenjpeg. More...

#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "internal.h"
#include <openjpeg.h>

Go to the source code of this file.

Data Structures

struct  LibOpenJPEGContext
 
struct  PacketWriter
 

Macros

#define OFFSET(x)   offsetof(LibOpenJPEGContext, x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static void error_callback (const char *msg, void *data)
 
static void warning_callback (const char *msg, void *data)
 
static void info_callback (const char *msg, void *data)
 
static OPJ_SIZE_T stream_write (void *out_buffer, OPJ_SIZE_T nb_bytes, void *user_data)
 
static OPJ_OFF_T stream_skip (OPJ_OFF_T nb_bytes, void *user_data)
 
static OPJ_BOOL stream_seek (OPJ_OFF_T nb_bytes, void *user_data)
 
static void cinema_parameters (opj_cparameters_t *p)
 
static opj_image_t * mj2_create_image (AVCodecContext *avctx, opj_cparameters_t *parameters)
 
static av_cold int libopenjpeg_encode_init (AVCodecContext *avctx)
 
static int libopenjpeg_copy_packed8 (AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image)
 
static int libopenjpeg_copy_packed12 (AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image)
 
static int libopenjpeg_copy_packed16 (AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image)
 
static int libopenjpeg_copy_unpacked8 (AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image)
 
static int libopenjpeg_copy_unpacked16 (AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image)
 
static int libopenjpeg_encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
 

Variables

static const AVOption options []
 
static const AVClass openjpeg_class
 
AVCodec ff_libopenjpeg_encoder
 

Detailed Description

JPEG 2000 encoder using libopenjpeg.

Definition in file libopenjpegenc.c.

Macro Definition Documentation

#define OFFSET (   x)    offsetof(LibOpenJPEGContext, x)

Definition at line 717 of file libopenjpegenc.c.

Definition at line 718 of file libopenjpegenc.c.

Function Documentation

static void error_callback ( const char *  msg,
void data 
)
static

Definition at line 49 of file libopenjpegenc.c.

Referenced by libopenjpeg_encode_frame().

static void warning_callback ( const char *  msg,
void data 
)
static

Definition at line 54 of file libopenjpegenc.c.

Referenced by libopenjpeg_encode_frame().

static void info_callback ( const char *  msg,
void data 
)
static

Definition at line 59 of file libopenjpegenc.c.

Referenced by libopenjpeg_encode_frame().

static OPJ_SIZE_T stream_write ( void out_buffer,
OPJ_SIZE_T  nb_bytes,
void user_data 
)
static

Definition at line 69 of file libopenjpegenc.c.

Referenced by libopenjpeg_encode_frame().

static OPJ_OFF_T stream_skip ( OPJ_OFF_T  nb_bytes,
void user_data 
)
static

Definition at line 89 of file libopenjpegenc.c.

Referenced by libopenjpeg_encode_frame().

static OPJ_BOOL stream_seek ( OPJ_OFF_T  nb_bytes,
void user_data 
)
static

Definition at line 117 of file libopenjpegenc.c.

Referenced by libopenjpeg_encode_frame().

static void cinema_parameters ( opj_cparameters_t *  p)
static

Definition at line 134 of file libopenjpegenc.c.

Referenced by libopenjpeg_encode_init().

static opj_image_t* mj2_create_image ( AVCodecContext avctx,
opj_cparameters_t *  parameters 
)
static

Definition at line 171 of file libopenjpegenc.c.

Referenced by libopenjpeg_encode_frame().

static av_cold int libopenjpeg_encode_init ( AVCodecContext avctx)
static

Definition at line 276 of file libopenjpegenc.c.

static int libopenjpeg_copy_packed8 ( AVCodecContext avctx,
const AVFrame frame,
opj_image_t *  image 
)
static

Definition at line 345 of file libopenjpegenc.c.

Referenced by libopenjpeg_encode_frame().

static int libopenjpeg_copy_packed12 ( AVCodecContext avctx,
const AVFrame frame,
opj_image_t *  image 
)
static

Definition at line 385 of file libopenjpegenc.c.

Referenced by libopenjpeg_encode_frame().

static int libopenjpeg_copy_packed16 ( AVCodecContext avctx,
const AVFrame frame,
opj_image_t *  image 
)
static

Definition at line 424 of file libopenjpegenc.c.

Referenced by libopenjpeg_encode_frame().

static int libopenjpeg_copy_unpacked8 ( AVCodecContext avctx,
const AVFrame frame,
opj_image_t *  image 
)
static

Definition at line 464 of file libopenjpegenc.c.

Referenced by libopenjpeg_encode_frame().

static int libopenjpeg_copy_unpacked16 ( AVCodecContext avctx,
const AVFrame frame,
opj_image_t *  image 
)
static

Definition at line 505 of file libopenjpegenc.c.

Referenced by libopenjpeg_encode_frame().

static int libopenjpeg_encode_frame ( AVCodecContext avctx,
AVPacket pkt,
const AVFrame frame,
int got_packet 
)
static

Definition at line 548 of file libopenjpegenc.c.

Variable Documentation

const AVOption options[]
static
Initial value:
= {
{ "format", "Codec Format", OFFSET(format), AV_OPT_TYPE_INT, { .i64 = OPJ_CODEC_JP2 }, OPJ_CODEC_J2K, OPJ_CODEC_JP2, VE, "format" },
{ "j2k", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ_CODEC_J2K }, 0, 0, VE, "format" },
{ "jp2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ_CODEC_JP2 }, 0, 0, VE, "format" },
{ "profile", NULL, OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = OPJ_STD_RSIZ }, OPJ_STD_RSIZ, OPJ_CINEMA4K, VE, "profile" },
{ "jpeg2000", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ_STD_RSIZ }, 0, 0, VE, "profile" },
{ "cinema2k", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ_CINEMA2K }, 0, 0, VE, "profile" },
{ "cinema4k", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ_CINEMA4K }, 0, 0, VE, "profile" },
{ "cinema_mode", "Digital Cinema", OFFSET(cinema_mode), AV_OPT_TYPE_INT, { .i64 = OPJ_OFF }, OPJ_OFF, OPJ_CINEMA4K_24, VE, "cinema_mode" },
{ "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ_OFF }, 0, 0, VE, "cinema_mode" },
{ "2k_24", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ_CINEMA2K_24 }, 0, 0, VE, "cinema_mode" },
{ "2k_48", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ_CINEMA2K_48 }, 0, 0, VE, "cinema_mode" },
{ "4k_24", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ_CINEMA4K_24 }, 0, 0, VE, "cinema_mode" },
{ "prog_order", "Progression Order", OFFSET(prog_order), AV_OPT_TYPE_INT, { .i64 = OPJ_LRCP }, OPJ_LRCP, OPJ_CPRL, VE, "prog_order" },
{ "lrcp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ_LRCP }, 0, 0, VE, "prog_order" },
{ "rlcp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ_RLCP }, 0, 0, VE, "prog_order" },
{ "rpcl", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ_RPCL }, 0, 0, VE, "prog_order" },
{ "pcrl", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ_PCRL }, 0, 0, VE, "prog_order" },
{ "cprl", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = OPJ_CPRL }, 0, 0, VE, "prog_order" },
{ "numresolution", NULL, OFFSET(numresolution), AV_OPT_TYPE_INT, { .i64 = 6 }, 0, 33, VE },
{ "irreversible", NULL, OFFSET(irreversible), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ "disto_alloc", NULL, OFFSET(disto_alloc), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE },
{ "fixed_quality", NULL, OFFSET(fixed_quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define VE
static const char * format
Definition: movenc.c:47
mfxU16 profile
Definition: qsvenc.c:44
#define OFFSET(x)

Definition at line 719 of file libopenjpegenc.c.

const AVClass openjpeg_class
static
Initial value:
= {
.class_name = "libopenjpeg",
.item_name = av_default_item_name,
.option = options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:86
av_default_item_name
static const AVOption options[]

Definition at line 745 of file libopenjpegenc.c.

AVCodec ff_libopenjpeg_encoder
Initial value:
= {
.name = "libopenjpeg",
.long_name = NULL_IF_CONFIG_SMALL("OpenJPEG JPEG 2000"),
.priv_data_size = sizeof(LibOpenJPEGContext),
.pix_fmts = (const enum AVPixelFormat[]) {
},
.priv_class = &openjpeg_class,
}
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:418
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:412
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:414
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:389
8 bits gray, 8 bits alpha
Definition: pixfmt.h:154
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:415
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:64
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:369
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:395
static const AVClass openjpeg_class
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:383
#define AV_CODEC_CAP_INTRA_ONLY
Codec is intra only.
Definition: avcodec.h:1095
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:102
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:411
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:394
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:392
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:384
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:417
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:188
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:419
#define AV_PIX_FMT_YA16
Definition: pixfmt.h:364
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:365
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:382
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:1065
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:94
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:377
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:398
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:363
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:416
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:378
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:397
static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx)
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:390
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:387
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:189
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:379
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:68
#define AV_PIX_FMT_XYZ12
Definition: pixfmt.h:421
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:376
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:388
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:396
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:380
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:386
static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
Y , 8bpp.
Definition: pixfmt.h:70
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:413
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:69
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:100
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:391

Definition at line 752 of file libopenjpegenc.c.