[FFmpeg-devel] [PATCH 2/3] lavc/libopenjpegenc: add layerrates parameter to allow different compression rates per layer
Michael Niedermayer
michaelni at gmx.at
Thu Jan 29 01:09:43 CET 2015
On Wed, Jan 28, 2015 at 04:41:25PM +0100, Jean First wrote:
> syntax is: 20,10,2
> this adds 3 layers, the first with a 20x, the second with 10x and
> a third with 2x compression.
>
> Layers define the progression by image quality within the code stream and,
> although not defined by the JPEG 2000 standard, in general codecs try to
> build layers in such a way that the image quality will increase monotonically
> with each layer.
>
> Signed-off-by: Jean First <jeanfirst at gmail.com>
> ---
>
> it remove the numlayers parameter, but i'm not sure it ever worked. Unfortunately
> the j2k_dump provided by openjpeg won't show the individual rates per layer - I
> also tried the files provided in http://samples.ffmpeg.org/jpeg2000/fdis_j2kp4files.zip
> and the rates shown are always 0.0
>
> TODO: Write the libopenjpegenc documentation
>
> libavcodec/libopenjpegenc.c | 21 ++++++++++++++++++---
> 1 file changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
> index bbf6190..b9a8bac 100644
> --- a/libavcodec/libopenjpegenc.c
> +++ b/libavcodec/libopenjpegenc.c
> @@ -56,6 +56,8 @@ typedef struct {
> int disto_alloc;
> int fixed_alloc;
> int fixed_quality;
> + char *layerrates;
> + float tcp_rates[100]; /** User specified rate stored in case of cinema option */
/**< ...
> } LibOpenJPEGContext;
>
> static void error_callback(const char *msg, void *data)
> @@ -224,8 +226,21 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx)
> ctx->enc_params.cp_disto_alloc = ctx->disto_alloc;
> ctx->enc_params.cp_fixed_alloc = ctx->fixed_alloc;
> ctx->enc_params.cp_fixed_quality = ctx->fixed_quality;
> - ctx->enc_params.tcp_numlayers = ctx->numlayers;
> - ctx->enc_params.tcp_rates[0] = FFMAX(avctx->compression_level, 0) * 2;
> + ctx->enc_params.tcp_numlayers = 0;
> +
> + char *s = ctx->layerrates;
mixing delaration and statement
> + while (sscanf(s, "%f", &ctx->tcp_rates[ctx->enc_params.tcp_numlayers]) == 1) {
> + ctx->enc_params.tcp_numlayers++;
> + while (*s && *s != ',')
> + s++;
> + if (!*s)
> + break;
> + s++;
> + }
missing tcp_rates[] size check
also "auto"
also this crashes:
./ffmpeg -i tests/vsynth1/01.pgm -vcodec libopenjpeg file.j2k
==11538== Invalid free() / delete / delete[] / realloc()
==11538== at 0x4C2B5D9: free (vg_replace_malloc.c:446)
==11538== by 0xE09663: av_free (mem.c:232)
==11538== by 0xE09688: av_freep (mem.c:239)
==11538== by 0xE0F5C8: av_opt_free (opt.c:1441)
==11538== by 0xA8CCA6: avcodec_close (utils.c:2858)
==11538== by 0xC976E0: worker (frame_thread_encoder.c:113)
==11538== by 0xD1BFE99: start_thread (pthread_create.c:308)
==11538== by 0xD4C92EC: clone (clone.S:112)
==11538== Address 0x10ee24f0 is 0 bytes inside a block of size 5 free'd
==11538== at 0x4C2B5D9: free (vg_replace_malloc.c:446)
==11538== by 0xE09663: av_free (mem.c:232)
==11538== by 0xE09688: av_freep (mem.c:239)
==11538== by 0xE0F5C8: av_opt_free (opt.c:1441)
==11538== by 0xA8CCA6: avcodec_close (utils.c:2858)
==11538== by 0xC976E0: worker (frame_thread_encoder.c:113)
==11538== by 0xD1BFE99: start_thread (pthread_create.c:308)
==11538== by 0xD4C92EC: clone (clone.S:112)
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150129/9ddcf2fc/attachment.asc>
More information about the ffmpeg-devel
mailing list