70 opj_cparameters_t *parameters)
73 opj_image_cmptparm_t *cmptparm;
74 OPJ_COLOR_SPACE color_space;
94 color_space = CLRSPC_GRAY;
100 color_space = CLRSPC_SRGB;
118 color_space = CLRSPC_SYCC;
122 "The requested pixel format '%s' is not supported\n",
127 cmptparm =
av_mallocz(numcomps *
sizeof(*cmptparm));
133 for (i = 0; i < numcomps; i++) {
136 cmptparm[i].sgnd = 0;
137 cmptparm[i].dx = sub_dx[i];
138 cmptparm[i].dy = sub_dy[i];
139 cmptparm[i].w = avctx->
width / sub_dx[i];
140 cmptparm[i].h = avctx->
height / sub_dy[i];
143 img = opj_image_create(numcomps, cmptparm, color_space);
153 opj_set_default_encoder_parameters(&ctx->
enc_params);
196 int image_index, frame_index;
197 const int numcomps = image->numcomps;
199 for (compno = 0; compno < numcomps; ++compno)
200 for (y = 0; y < avctx->
height; ++y) {
201 image_index = y * avctx->
width;
202 frame_index = y * frame->
linesize[0] + compno;
203 for (x = 0; x < avctx->
width; ++x) {
204 image->comps[compno].data[image_index++] =
205 frame->
data[0][frame_index];
206 frame_index += numcomps;
216 int image_index, frame_index;
217 const int numcomps = image->numcomps;
218 uint16_t *frame_ptr = (uint16_t *)frame->
data[0];
220 for (compno = 0; compno < numcomps; ++compno)
221 for (y = 0; y < avctx->
height; ++y) {
222 image_index = y * avctx->
width;
223 frame_index = y * (frame->
linesize[0] / 2) + compno;
224 for (x = 0; x < avctx->
width; ++x) {
225 image->comps[compno].data[image_index++] =
226 frame_ptr[frame_index];
227 frame_index += numcomps;
238 int image_index, frame_index;
239 const int numcomps = image->numcomps;
241 for (compno = 0; compno < numcomps; ++compno) {
242 width = avctx->
width / image->comps[compno].dx;
243 height = avctx->
height / image->comps[compno].dy;
244 for (y = 0; y <
height; ++y) {
245 image_index = y *
width;
246 frame_index = y * frame->
linesize[compno];
247 for (x = 0; x <
width; ++x)
248 image->comps[compno].data[image_index++] =
249 frame->
data[compno][frame_index++];
261 int image_index, frame_index;
262 const int numcomps = image->numcomps;
265 for (compno = 0; compno < numcomps; ++compno) {
266 width = avctx->
width / image->comps[compno].dx;
267 height = avctx->
height / image->comps[compno].dy;
268 frame_ptr = (uint16_t *)frame->
data[compno];
270 image_index = y *
width;
271 frame_index = y * (frame->
linesize[compno] / 2);
272 for (x = 0; x <
width; ++x)
273 image->comps[compno].data[image_index++] =
274 frame_ptr[frame_index++];
280 const AVFrame *frame,
int *got_packet)
329 "The frame's pixel format '%s' is not supported\n",
335 opj_setup_encoder(compress, &ctx->
enc_params, image);
336 stream = opj_cio_open((opj_common_ptr) compress,
NULL, 0);
342 if (!opj_encode(compress, stream, image,
NULL)) {
343 opj_cio_close(stream);
348 len = cio_tell(stream);
350 opj_cio_close(stream);
354 memcpy(pkt->
data, stream->buffer, len);
357 opj_cio_close(stream);
365 opj_destroy_compress(ctx->
compress);
366 opj_image_destroy(ctx->
image);
370 #define OFFSET(x) offsetof(LibOpenJPEGContext, x) 371 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM 407 .
name =
"libopenjpeg",
428 .priv_class = &
class,
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
8 bits gray, 8 bits alpha
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
packed RGB 8:8:8, 24bpp, RGBRGB...
#define AV_PIX_FMT_RGBA64
AVCodec ff_libopenjpeg_encoder
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
static av_cold int libopenjpeg_encode_close(AVCodecContext *avctx)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
opj_cparameters_t enc_params
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
static opj_image_t * libopenjpeg_create_image(AVCodecContext *avctx, opj_cparameters_t *parameters)
static void libopenjpeg_copy_packed16(AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image)
static void warning_callback(const char *msg, void *data)
#define AV_PIX_FMT_YUV444P16
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
const char * name
Name of the codec implementation.
#define AV_PIX_FMT_YUV444P10
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int flags
A combination of AV_PKT_FLAG values.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
#define AV_PIX_FMT_YUV422P9
uint8_t nb_components
The number of components each pixel has, (1-4)
#define AV_PIX_FMT_GRAY16
int width
picture width / height.
int ff_alloc_packet(AVPacket *avpkt, int size)
Check AVPacket size and/or allocate data.
static void libopenjpeg_copy_packed8(AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image)
#define AV_PIX_FMT_YUV444P9
static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx)
#define AV_PIX_FMT_YUV420P16
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
main external API structure.
static void libopenjpeg_copy_unpacked16(AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image)
#define AV_PIX_FMT_YUV420P10
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Describe the class of an AVClass context structure.
opj_event_mgr_t event_mgr
static void libopenjpeg_copy_unpacked8(AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image)
#define AV_PIX_FMT_YUV420P9
static void info_callback(const char *msg, void *data)
static enum AVPixelFormat pix_fmts[]
int global_quality
Global quality for codecs which cannot change it per frame.
#define AV_PIX_FMT_YUV422P10
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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)
common internal api header.
common internal and external API header
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static av_cold int init(AVCodecParserContext *s)
static const AVOption options[]
static void error_callback(const char *msg, void *data)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
int depth
Number of bits in the component.
AVPixelFormat
Pixel format.
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AV_PIX_FMT_YUV422P16