FFmpeg
Data Structures | Macros | Functions | Variables
libopenjpegdec.c File Reference
#include "libavutil/common.h"
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavutil/pixfmt.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"
#include "thread.h"
#include <openjpeg.h>

Go to the source code of this file.

Data Structures

struct  LibOpenJPEGContext
 
struct  BufferReader
 

Macros

#define JP2_SIG_TYPE   0x6A502020
 
#define JP2_SIG_VALUE   0x0D0A870A
 
#define RGB_PIXEL_FORMATS
 
#define GRAY_PIXEL_FORMATS
 
#define YUV_PIXEL_FORMATS
 
#define XYZ_PIXEL_FORMATS   AV_PIX_FMT_XYZ12
 
#define OFFSET(x)   offsetof(LibOpenJPEGContext, x)
 
#define VD   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_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_read (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 int libopenjpeg_matches_pix_fmt (const opj_image_t *image, enum AVPixelFormat pix_fmt)
 
static enum AVPixelFormat libopenjpeg_guess_pix_fmt (const opj_image_t *image)
 
static int libopenjpeg_ispacked (enum AVPixelFormat pix_fmt)
 
static void libopenjpeg_copy_to_packed8 (AVFrame *picture, opj_image_t *image)
 
static void libopenjpeg_copy_to_packed16 (AVFrame *picture, opj_image_t *image)
 
static void libopenjpeg_copyto8 (AVFrame *picture, opj_image_t *image)
 
static void libopenjpeg_copyto16 (AVFrame *picture, opj_image_t *image)
 
static av_cold int libopenjpeg_decode_init (AVCodecContext *avctx)
 
static int libopenjpeg_decode_frame (AVCodecContext *avctx, AVFrame *picture, int *got_frame, AVPacket *avpkt)
 

Variables

static enum AVPixelFormat libopenjpeg_rgb_pix_fmts []
 
static enum AVPixelFormat libopenjpeg_gray_pix_fmts []
 
static enum AVPixelFormat libopenjpeg_yuv_pix_fmts []
 
static enum AVPixelFormat libopenjpeg_all_pix_fmts []
 
static const AVOption options []
 
static const AVClass openjpeg_class
 
const FFCodec ff_libopenjpeg_decoder
 

Detailed Description

JPEG 2000 decoder using libopenjpeg

Definition in file libopenjpegdec.c.

Macro Definition Documentation

◆ JP2_SIG_TYPE

#define JP2_SIG_TYPE   0x6A502020

Definition at line 40 of file libopenjpegdec.c.

◆ JP2_SIG_VALUE

#define JP2_SIG_VALUE   0x0D0A870A

Definition at line 41 of file libopenjpegdec.c.

◆ RGB_PIXEL_FORMATS

#define RGB_PIXEL_FORMATS
Value:

Definition at line 45 of file libopenjpegdec.c.

◆ GRAY_PIXEL_FORMATS

#define GRAY_PIXEL_FORMATS
Value:

Definition at line 48 of file libopenjpegdec.c.

◆ YUV_PIXEL_FORMATS

#define YUV_PIXEL_FORMATS
Value:

Definition at line 52 of file libopenjpegdec.c.

◆ XYZ_PIXEL_FORMATS

#define XYZ_PIXEL_FORMATS   AV_PIX_FMT_XYZ12

Definition at line 64 of file libopenjpegdec.c.

◆ OFFSET

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

Definition at line 487 of file libopenjpegdec.c.

◆ VD

Definition at line 488 of file libopenjpegdec.c.

Function Documentation

◆ error_callback()

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

Definition at line 85 of file libopenjpegdec.c.

Referenced by libopenjpeg_decode_frame().

◆ warning_callback()

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

Definition at line 90 of file libopenjpegdec.c.

Referenced by libopenjpeg_decode_frame().

◆ info_callback()

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

Definition at line 95 of file libopenjpegdec.c.

Referenced by libopenjpeg_decode_frame().

◆ stream_read()

static OPJ_SIZE_T stream_read ( void *  out_buffer,
OPJ_SIZE_T  nb_bytes,
void *  user_data 
)
static

Definition at line 106 of file libopenjpegdec.c.

Referenced by libopenjpeg_decode_frame().

◆ stream_skip()

static OPJ_OFF_T stream_skip ( OPJ_OFF_T  nb_bytes,
void *  user_data 
)
static

Definition at line 123 of file libopenjpegdec.c.

Referenced by libopenjpeg_decode_frame().

◆ stream_seek()

static OPJ_BOOL stream_seek ( OPJ_OFF_T  nb_bytes,
void *  user_data 
)
static

Definition at line 148 of file libopenjpegdec.c.

Referenced by libopenjpeg_decode_frame().

◆ libopenjpeg_matches_pix_fmt()

static int libopenjpeg_matches_pix_fmt ( const opj_image_t *  image,
enum AVPixelFormat  pix_fmt 
)
inlinestatic

Definition at line 158 of file libopenjpegdec.c.

Referenced by libopenjpeg_decode_frame(), and libopenjpeg_guess_pix_fmt().

◆ libopenjpeg_guess_pix_fmt()

static enum AVPixelFormat libopenjpeg_guess_pix_fmt ( const opj_image_t *  image)
inlinestatic

Definition at line 195 of file libopenjpegdec.c.

Referenced by libopenjpeg_decode_frame().

◆ libopenjpeg_ispacked()

static int libopenjpeg_ispacked ( enum AVPixelFormat  pix_fmt)
inlinestatic

Definition at line 227 of file libopenjpegdec.c.

Referenced by libopenjpeg_decode_frame().

◆ libopenjpeg_copy_to_packed8()

static void libopenjpeg_copy_to_packed8 ( AVFrame picture,
opj_image_t *  image 
)
inlinestatic

Definition at line 242 of file libopenjpegdec.c.

Referenced by libopenjpeg_decode_frame().

◆ libopenjpeg_copy_to_packed16()

static void libopenjpeg_copy_to_packed16 ( AVFrame picture,
opj_image_t *  image 
)
inlinestatic

Definition at line 254 of file libopenjpegdec.c.

Referenced by libopenjpeg_decode_frame().

◆ libopenjpeg_copyto8()

static void libopenjpeg_copyto8 ( AVFrame picture,
opj_image_t *  image 
)
inlinestatic

Definition at line 272 of file libopenjpegdec.c.

Referenced by libopenjpeg_decode_frame().

◆ libopenjpeg_copyto16()

static void libopenjpeg_copyto16 ( AVFrame picture,
opj_image_t *  image 
)
inlinestatic

Definition at line 290 of file libopenjpegdec.c.

Referenced by libopenjpeg_decode_frame().

◆ libopenjpeg_decode_init()

static av_cold int libopenjpeg_decode_init ( AVCodecContext avctx)
static

Definition at line 313 of file libopenjpegdec.c.

◆ libopenjpeg_decode_frame()

static int libopenjpeg_decode_frame ( AVCodecContext avctx,
AVFrame picture,
int got_frame,
AVPacket avpkt 
)
static

Definition at line 321 of file libopenjpegdec.c.

Variable Documentation

◆ libopenjpeg_rgb_pix_fmts

enum AVPixelFormat libopenjpeg_rgb_pix_fmts[]
static
Initial value:

Definition at line 66 of file libopenjpegdec.c.

Referenced by libopenjpeg_guess_pix_fmt().

◆ libopenjpeg_gray_pix_fmts

enum AVPixelFormat libopenjpeg_gray_pix_fmts[]
static
Initial value:

Definition at line 69 of file libopenjpegdec.c.

Referenced by libopenjpeg_guess_pix_fmt().

◆ libopenjpeg_yuv_pix_fmts

enum AVPixelFormat libopenjpeg_yuv_pix_fmts[]
static
Initial value:

Definition at line 72 of file libopenjpegdec.c.

Referenced by libopenjpeg_guess_pix_fmt().

◆ libopenjpeg_all_pix_fmts

enum AVPixelFormat libopenjpeg_all_pix_fmts[]
static

◆ options

const AVOption options[]
static
Initial value:
= {
{ "lowqual", "Limit the number of layers used for decoding",
OFFSET(lowqual), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VD },
{ NULL },
}

Definition at line 490 of file libopenjpegdec.c.

◆ openjpeg_class

const AVClass openjpeg_class
static
Initial value:
= {
.class_name = "libopenjpeg",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 496 of file libopenjpegdec.c.

◆ ff_libopenjpeg_decoder

const FFCodec ff_libopenjpeg_decoder
Initial value:
= {
.p.name = "libopenjpeg",
CODEC_LONG_NAME("OpenJPEG JPEG 2000"),
.p.type = AVMEDIA_TYPE_VIDEO,
.p.max_lowres = 31,
.p.priv_class = &openjpeg_class,
.p.wrapper_name = "libopenjpeg",
.priv_data_size = sizeof(LibOpenJPEGContext),
}

Definition at line 503 of file libopenjpegdec.c.

AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:502
AV_PIX_FMT_YA8
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
Definition: pixfmt.h:133
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:494
FF_CODEC_CAP_NOT_INIT_THREADSAFE
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
Definition: codec_internal.h:34
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:497
XYZ_PIXEL_FORMATS
#define XYZ_PIXEL_FORMATS
Definition: libopenjpegdec.c:64
libopenjpeg_decode_init
static av_cold int libopenjpeg_decode_init(AVCodecContext *avctx)
Definition: libopenjpegdec.c:313
options
static const AVOption options[]
Definition: libopenjpegdec.c:490
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:503
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:457
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:462
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:471
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:306
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:472
VD
#define VD
Definition: libopenjpegdec.c:488
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:442
GRAY_PIXEL_FORMATS
#define GRAY_PIXEL_FORMATS
Definition: libopenjpegdec.c:48
RGB_PIXEL_FORMATS
#define RGB_PIXEL_FORMATS
Definition: libopenjpegdec.c:45
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:107
AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:449
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:460
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
LibOpenJPEGContext
Definition: libopenjpegdec.c:79
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
openjpeg_class
static const AVClass openjpeg_class
Definition: libopenjpegdec.c:496
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:464
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:466
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:167
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:498
AV_PIX_FMT_YA16
#define AV_PIX_FMT_YA16
Definition: pixfmt.h:444
AV_CODEC_ID_JPEG2000
@ AV_CODEC_ID_JPEG2000
Definition: codec_id.h:140
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:458
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:495
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:468
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:469
OFFSET
#define OFFSET(x)
Definition: libopenjpegdec.c:487
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:441
YUV_PIXEL_FORMATS
#define YUV_PIXEL_FORMATS
Definition: libopenjpegdec.c:52
libopenjpeg_decode_frame
static int libopenjpeg_decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_frame, AVPacket *avpkt)
Definition: libopenjpegdec.c:321
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:166