summaryrefslogtreecommitdiff
path: root/libavcodec/libopenjpegenc.c
diff options
context:
space:
mode:
authorJean First <jeanfirst@gmail.com>2015-01-28 16:41:24 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-02-02 17:32:54 +0100
commit6d1d036e2ca8a62067037eed73b16766bf5265b4 (patch)
treec7328e3015e49cc8f8396fce1811160ccf8e5063 /libavcodec/libopenjpegenc.c
parent6e95c67330b2707ef967bc0158bde717b50c6902 (diff)
downloadffmpeg-6d1d036e2ca8a62067037eed73b16766bf5265b4.tar.gz
lavc/libopenjpegenc: factorize cinema parameters to it's own function
Signed-off-by: Jean First <jeanfirst@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/libopenjpegenc.c')
-rw-r--r--libavcodec/libopenjpegenc.c64
1 files changed, 38 insertions, 26 deletions
diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index 33ccda68f2..0a4658d8cf 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -73,6 +73,43 @@ static void info_callback(const char *msg, void *data)
av_log(data, AV_LOG_DEBUG, "%s\n", msg);
}
+static void cinema_parameters(opj_cparameters_t *p)
+{
+ p->tile_size_on = 0;
+ p->cp_tdx = 1;
+ p->cp_tdy = 1;
+
+ /* Tile part */
+ p->tp_flag = 'C';
+ p->tp_on = 1;
+
+ /* Tile and Image shall be at (0, 0) */
+ p->cp_tx0 = 0;
+ p->cp_ty0 = 0;
+ p->image_offset_x0 = 0;
+ p->image_offset_y0 = 0;
+
+ /* Codeblock size= 32 * 32 */
+ p->cblockw_init = 32;
+ p->cblockh_init = 32;
+ p->csty |= 0x01;
+
+ /* The progression order shall be CPRL */
+ p->prog_order = CPRL;
+
+ /* No ROI */
+ p->roi_compno = -1;
+
+ /* No subsampling */
+ p->subsampling_dx = 1;
+ p->subsampling_dy = 1;
+
+ /* 9-7 transform */
+ p->irreversible = 1;
+
+ p->tcp_mct = 1;
+}
+
static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *parameters)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
@@ -194,32 +231,7 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx)
ctx->enc_params.tcp_rates[0] = FFMAX(avctx->compression_level, 0) * 2;
if (ctx->cinema_mode > 0) {
- ctx->enc_params.irreversible = 1;
- ctx->enc_params.tcp_mct = 1;
- ctx->enc_params.tile_size_on = 0;
- /* no subsampling */
- ctx->enc_params.cp_tdx=1;
- ctx->enc_params.cp_tdy=1;
- ctx->enc_params.subsampling_dx = 1;
- ctx->enc_params.subsampling_dy = 1;
- /* Tile and Image shall be at (0,0) */
- ctx->enc_params.cp_tx0 = 0;
- ctx->enc_params.cp_ty0 = 0;
- ctx->enc_params.image_offset_x0 = 0;
- ctx->enc_params.image_offset_y0 = 0;
- /* Codeblock size= 32*32 */
- ctx->enc_params.cblockw_init = 32;
- ctx->enc_params.cblockh_init = 32;
- ctx->enc_params.csty |= 0x01;
- /* No ROI */
- ctx->enc_params.roi_compno = -1;
-
- if (ctx->enc_params.prog_order != CPRL) {
- av_log(avctx, AV_LOG_ERROR, "prog_order forced to CPRL\n");
- ctx->enc_params.prog_order = CPRL;
- }
- ctx->enc_params.tp_flag = 'C';
- ctx->enc_params.tp_on = 1;
+ cinema_parameters(&ctx->enc_params);
}
ctx->compress = opj_create_compress(ctx->format);