Re: [FFmpeg-devel] [PATCH] libavcodec/gifenc: Only write palette entries that actually used

2021-02-05 Thread Jean First

Derek Buitenhuis wrote on 04.02.21 19:42:

On 04/02/2021 17:26, Paul B Mahol wrote:

How would that work?
I'm not against if that does not break existing usage.

Somethng like '-no_global_paltte 1' to not use a global
palette, and write a palette each frame. Default would be
off, so curent behavior is maintained.


Please do not negate options. So instead of  '-no_global_palette' just 
use '-global_palette'.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [OPW] OPW Project Proposal

2016-09-27 Thread Jean First
On Sun Sep 25 2016 14:32:25 GMT+0200 (CEST), Pallavi Kumari wrote:

[...]

> I want to propose the idea of implementing filters for ffmpeg that would
> give different audio fingerprints for an audio which could be reused by
> other people for variety of applications. Goal of this system is given a
> song as a input, it would spits out similar sounding songs. Some of its
> applications are:
[...]

Hi Pallavi,

Your work could also be useful for applications similar to
https://github.com/stendardo/shenidam
Good luck with your work.

Kind Regards,
Jean
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Question on tbr, tbn, tbc

2015-04-13 Thread Jean First
On Mon Apr 13 2015 15:30:03 GMT+0200 (CEST), Kamaldeep Tumkur wrote:
 I have an mpeg4 transcoded from an mov source that has the following:

 Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661),
 yuv420p(tv, bt709), 480x270 [SAR 1:1 DAR 16:9], 462 kb/s, 25 fps, 25 tbr,
 12800 tbn, 50 tbc (default)

 Why is tbn value so high? Why do the tbc and tbn values not match the tbr?
 And what kind of irregularities can this potentially cause during playback?
 How can it be corrected?

 When used in http based streaming with flash, this mp4 results in a black
 screen right at start up that continues till the end. On seeking, the video
 displays back again.

 Thanks for your inputs and guidance.
 ___
 ffmpeg-devel mailing list
 ffmpeg-devel@ffmpeg.org
 http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Hi,

Please continue this conversation on the ffmpeg-user mailinglist !

The default value is set so high so you can combine multiple streams
with different timebases in the same container without having to worry
for offsets. It should not cause any problems during playback. If you
want to set it to a specific value during encoding you can set the
video_track_timescale option to a specific value.

Jean
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/3] lavc/libopenjpegenc: add layerrates parameter to allow different compression rates per layer

2015-02-02 Thread Jean First
From fe0afff9c7b8c6f78dcad0720965c6f6a50e7813 Mon Sep 17 00:00:00 2001
From: Jean First jeanfi...@gmail.com
Date: Mon, 2 Feb 2015 12:57:03 +0100
Subject: [PATCH] lavc/libopenjpegenc: move opj_create_compress, opj_cio_open
 and opj_set_event_mgr to libopenjpeg_encode_frame

 libopenjpegenc crashes with pointer being freed was not allocated when 
threading
 is enabled with:
 ffmpeg -i tests/vsynth1/01.pgm -vcodec libopenjpeg file.j2k

Signed-off-by: Jean First jeanfi...@gmail.com
---
 libavcodec/libopenjpegenc.c | 42 --
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index 4039663..53d0fe9 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -43,9 +43,7 @@
 typedef struct {
 AVClass *avclass;
 opj_image_t *image;
-opj_cio_t *stream;
 opj_cparameters_t enc_params;
-opj_cinfo_t *compress;
 opj_event_mgr_t event_mgr;
 int format;
 int profile;
@@ -221,12 +219,6 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext 
*avctx)
 ctx-enc_params.tp_on = 1;
 }
 
-ctx-compress = opj_create_compress(ctx-format);
-if (!ctx-compress) {
-av_log(avctx, AV_LOG_ERROR, Error creating the compressor\n);
-return AVERROR(ENOMEM);
-}
-
 ctx-image = mj2_create_image(avctx, ctx-enc_params);
 if (!ctx-image) {
 av_log(avctx, AV_LOG_ERROR, Error creating the mj2 image\n);
@@ -240,17 +232,9 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext 
*avctx)
 goto fail;
 }
 
-memset(ctx-event_mgr, 0, sizeof(opj_event_mgr_t));
-ctx-event_mgr.info_handler= info_callback;
-ctx-event_mgr.error_handler = error_callback;
-ctx-event_mgr.warning_handler = warning_callback;
-opj_set_event_mgr((opj_common_ptr) ctx-compress, ctx-event_mgr, avctx);
-
 return 0;
 
 fail:
-opj_destroy_compress(ctx-compress);
-ctx-compress = NULL;
 opj_image_destroy(ctx-image);
 ctx-image = NULL;
 av_freep(avctx-coded_frame);
@@ -464,9 +448,9 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 const AVFrame *frame, int *got_packet)
 {
 LibOpenJPEGContext *ctx = avctx-priv_data;
-opj_cinfo_t *compress   = ctx-compress;
 opj_image_t *image  = ctx-image;
-opj_cio_t *stream   = ctx-stream;
+opj_cinfo_t *compress   = NULL;
+opj_cio_t *stream   = NULL;
 int cpyresult = 0;
 int ret, len;
 AVFrame *gbrframe;
@@ -559,6 +543,12 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 return -1;
 }
 
+compress = opj_create_compress(ctx-format);
+if (!compress) {
+av_log(avctx, AV_LOG_ERROR, Error creating the compressor\n);
+return AVERROR(ENOMEM);
+}
+
 opj_setup_encoder(compress, ctx-enc_params, image);
 
 stream = opj_cio_open((opj_common_ptr) compress, NULL, 0);
@@ -567,6 +557,12 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 return AVERROR(ENOMEM);
 }
 
+memset(ctx-event_mgr, 0, sizeof(opj_event_mgr_t));
+ctx-event_mgr.info_handler= info_callback;
+ctx-event_mgr.error_handler   = error_callback;
+ctx-event_mgr.warning_handler = warning_callback;
+opj_set_event_mgr((opj_common_ptr) compress, ctx-event_mgr, avctx);
+
 if (!opj_encode(compress, stream, image, NULL)) {
 av_log(avctx, AV_LOG_ERROR, Error during the opj encode\n);
 return -1;
@@ -580,6 +576,12 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 memcpy(pkt-data, stream-buffer, len);
 pkt-flags |= AV_PKT_FLAG_KEY;
 *got_packet = 1;
+
+opj_cio_close(stream);
+stream = NULL;
+opj_destroy_compress(compress);
+compress = NULL;
+
 return 0;
 }
 
@@ -587,10 +589,6 @@ static av_cold int libopenjpeg_encode_close(AVCodecContext 
*avctx)
 {
 LibOpenJPEGContext *ctx = avctx-priv_data;
 
-opj_cio_close(ctx-stream);
-ctx-stream = NULL;
-opj_destroy_compress(ctx-compress);
-ctx-compress = NULL;
 opj_image_destroy(ctx-image);
 ctx-image = NULL;
 av_freep(avctx-coded_frame);
-- 
2.2.2

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/3] lavc/libopenjpegenc: add layerrates parameter to allow different compression rates per layer

2015-02-02 Thread Jean First
On Mon Feb 02 2015 17:20:44 GMT+0100 (CET), Michael Niedermayer wrote:
 On Mon, Feb 02, 2015 at 01:18:35PM +0100, Jean First wrote:
  libopenjpegenc.c |   42 --
  1 file changed, 20 insertions(+), 22 deletions(-)
 6bed682adf441fa060b9fef84df173cd758320ed  
 0001-lavc-libopenjpegenc-move-opj_create_compress-opj_cio.patch
 From fe0afff9c7b8c6f78dcad0720965c6f6a50e7813 Mon Sep 17 00:00:00 2001
 From: Jean First jeanfi...@gmail.com
 Date: Mon, 2 Feb 2015 12:57:03 +0100
 Subject: [PATCH] lavc/libopenjpegenc: move opj_create_compress, opj_cio_open
  and opj_set_event_mgr to libopenjpeg_encode_frame

  libopenjpegenc crashes with pointer being freed was not allocated when 
 threading
  is enabled with:
  ffmpeg -i tests/vsynth1/01.pgm -vcodec libopenjpeg file.j2k
 cannot reproduce
 do i assume correctly that this is a bug in libopenjpeg and unlreated
 to this patch ?


Yes, that's my guess. Any other implementation I saw using libopenjpeg
did initialise and encode the date in the same thread.
Jean

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 3/3] lavc/libopenjpegenc: add cinema_setup_encoder function to allow creation of dci compliant files

2015-01-28 Thread Jean First
 code originates from image_to_j2k.c provided by openjpeg

Signed-off-by: Jean First jeanfi...@gmail.com
---
 libavcodec/libopenjpegenc.c | 118 
 1 file changed, 118 insertions(+)

diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index b9a8bac..8c8bf67 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -26,6 +26,11 @@
 
 #define  OPJ_STATIC
 
+#define CINEMA_24_CS 1302083 /* Codestream length for 24fps */
+#define CINEMA_48_CS 651041  /* Codestream length for 48fps */
+#define COMP_24_CS 1041666   /* Maximum size per color component for 2K  4K @ 
24fps */
+#define COMP_48_CS 520833/* Maximum size per color component for 2K @ 
48fps */
+
 #include libavutil/avassert.h
 #include libavutil/common.h
 #include libavutil/imgutils.h
@@ -75,6 +80,25 @@ static void info_callback(const char *msg, void *data)
 av_log(data, AV_LOG_DEBUG, %s\n, msg);
 }
 
+static int initialise_4K_poc(opj_poc_t *POC, int numres)
+{
+POC[0].tile= 1;
+POC[0].resno0  = 0;
+POC[0].compno0 = 0;
+POC[0].layno1  = 1;
+POC[0].resno1  = numres - 1;
+POC[0].compno1 = 3;
+POC[0].prg1= CPRL;
+POC[1].tile= 1;
+POC[1].resno0  = numres - 1;
+POC[1].compno0 = 0;
+POC[1].layno1  = 1;
+POC[1].resno1  = numres;
+POC[1].compno1 = 3;
+POC[1].prg1= CPRL;
+return 2;
+}
+
 static void cinema_parameters(opj_cparameters_t *p)
 {
 p-tile_size_on = 0;
@@ -110,8 +134,98 @@ static void cinema_parameters(opj_cparameters_t *p)
 p-irreversible = 1;
 }
 
+static void cinema_setup_encoder(AVCodecContext *avctx, opj_image_t *image)
+{
+LibOpenJPEGContext *ctx = avctx-priv_data;
+opj_cparameters_t *parameters = ctx-enc_params;
+int i;
+float temp_rate;
+
+switch (parameters-cp_cinema) {
+case CINEMA2K_24:
+case CINEMA2K_48:
+if (parameters-numresolution  6) {
+parameters-numresolution = 6;
+}
+if (!((image-comps[0].w == 2048) || (image-comps[0].h == 1080))) 
{
+av_log(avctx, AV_LOG_WARNING, Image coordinates %d x %d is 
not 2K compliant.\nJPEG Digital Cinema Profile-3 
+(2K profile) compliance requires that at least one of 
coordinates match 2048 x 1080\n,
+image-comps[0].w, image-comps[0].h);
+parameters-cp_rsiz = STD_RSIZ;
+}
+break;
+
+case CINEMA4K_24:
+if (parameters-numresolution  1) {
+parameters-numresolution = 1;
+} else if (parameters-numresolution  7) {
+parameters-numresolution = 7;
+}
+if (!((image-comps[0].w == 4096) || (image-comps[0].h == 2160))) 
{
+av_log(avctx, AV_LOG_WARNING, Image coordinates %d x %d is 
not 4K compliant.\nJPEG Digital Cinema Profile-4
+(4K profile) compliance requires that at least one of 
coordinates match 4096 x 2160\n,
+image-comps[0].w, image-comps[0].h);
+parameters-cp_rsiz = STD_RSIZ;
+}
+parameters-numpocs = initialise_4K_poc(parameters-POC, 
parameters-numresolution);
+break;
+case OFF:
+/* do nothing */
+break;
+}
+
+switch (parameters-cp_cinema) {
+case CINEMA2K_24:
+case CINEMA4K_24:
+for (i = 0; i  parameters-tcp_numlayers; i++) {
+temp_rate = 0;
+if (ctx-tcp_rates[i] == 0) {
+parameters-tcp_rates[0] = ((float) (image-numcomps * 
image-comps[0].w * image-comps[0].h * image-comps[0].prec)) /
+   (CINEMA_24_CS * 8 * 
image-comps[0].dx * image-comps[0].dy);
+} else {
+temp_rate = ((float) (image-numcomps * image-comps[0].w 
* image-comps[0].h * image-comps[0].prec)) /
+(ctx-tcp_rates[i] * 8 * image-comps[0].dx * 
image-comps[0].dy);
+if (temp_rate  CINEMA_24_CS) {
+parameters-tcp_rates[i] = ((float) (image-numcomps * 
image-comps[0].w * image-comps[0].h * image-comps[0].prec)) /
+   (CINEMA_24_CS * 8 * 
image-comps[0].dx * image-comps[0].dy);
+} else {
+parameters-tcp_rates[i] = ctx-tcp_rates[i];
+}
+}
+}
+parameters-max_comp_size = COMP_24_CS;
+break;
+
+case CINEMA2K_48:
+for (i = 0; i  parameters-tcp_numlayers; i++) {
+temp_rate = 0;
+if (ctx-tcp_rates[i] == 0) {
+parameters-tcp_rates[0] = ((float) (image-numcomps * 
image-comps[0].w * image-comps[0].h * image-comps[0].prec)) /
+   (CINEMA_48_CS * 8

[FFmpeg-devel] [PATCH] lavc/libopenjpegenc: move opj_setup_encoder to libopenjpeg_encode_frame

2015-01-23 Thread Jean First
if the openjpeg parameter tcp_rates is not 0 ( using the ffmpeg 
compression_level option ) 
every 2nd image per thread is badly encoded. By moving the opj_setup_encoder 
function from
libopenjpeg_encode_init to libopenjpeg_encode_frame this can be prevented.

This fixes ticket #3754.

Signed-off-by: Jean First jeanfi...@gmail.com
---
 libavcodec/libopenjpegenc.c | 19 ---
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index 66633f4..4039663 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -233,14 +233,6 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext 
*avctx)
 err = AVERROR(EINVAL);
 goto fail;
 }
-opj_setup_encoder(ctx-compress, ctx-enc_params, ctx-image);
-
-ctx-stream = opj_cio_open((opj_common_ptr) ctx-compress, NULL, 0);
-if (!ctx-stream) {
-av_log(avctx, AV_LOG_ERROR, Error creating the cio stream\n);
-err = AVERROR(ENOMEM);
-goto fail;
-}
 
 avctx-coded_frame = av_frame_alloc();
 if (!avctx-coded_frame) {
@@ -257,8 +249,6 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext 
*avctx)
 return 0;
 
 fail:
-opj_cio_close(ctx-stream);
-ctx-stream = NULL;
 opj_destroy_compress(ctx-compress);
 ctx-compress = NULL;
 opj_image_destroy(ctx-image);
@@ -569,7 +559,14 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 return -1;
 }
 
-cio_seek(stream, 0);
+opj_setup_encoder(compress, ctx-enc_params, image);
+
+stream = opj_cio_open((opj_common_ptr) compress, NULL, 0);
+if (!stream) {
+av_log(avctx, AV_LOG_ERROR, Error creating the cio stream\n);
+return AVERROR(ENOMEM);
+}
+
 if (!opj_encode(compress, stream, image, NULL)) {
 av_log(avctx, AV_LOG_ERROR, Error during the opj encode\n);
 return -1;
-- 
2.2.2

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel